• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

TypeScript chrome.addBasePath函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了TypeScript中ui/chrome.addBasePath函数的典型用法代码示例。如果您正苦于以下问题:TypeScript addBasePath函数的具体用法?TypeScript addBasePath怎么用?TypeScript addBasePath使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了addBasePath函数的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。

示例1: requestFile

export async function requestFile(
  payload: FetchFilePayload,
  line?: string
): Promise<FetchFileResponse> {
  const { uri, revision, path } = payload;
  const url = `/api/code/repo/${uri}/blob/${encodeURIComponent(revision)}/${path}`;
  const query: any = {};
  if (line) {
    query.line = line;
  }
  const response: Response = await fetch(chrome.addBasePath(Url.format({ pathname: url, query })));

  if (response.status >= 200 && response.status < 300) {
    const contentType = response.headers.get('Content-Type');

    if (contentType && contentType.startsWith('text/')) {
      const lang = contentType.split(';')[0].substring('text/'.length);
      if (lang === 'big') {
        return {
          payload,
          content: '',
          isOversize: true,
        };
      }
      return {
        payload,
        lang,
        content: await response.text(),
        isUnsupported: false,
      };
    } else if (contentType && contentType.startsWith('image/')) {
      return {
        payload,
        isImage: true,
        content: '',
        url,
        isUnsupported: false,
      };
    } else {
      return {
        payload,
        isImage: false,
        content: '',
        url,
        isUnsupported: true,
      };
    }
  } else if (response.status === 404) {
    return {
      payload,
      isNotFound: true,
    };
  }
  throw new Error('invalid file type');
}
开发者ID:elastic,项目名称:kibana,代码行数:55,代码来源:file.ts


示例2: get

  (uiCapabilities: UICapabilities, kbnBaseUrl: string, $route: any, kbnUrl: any) => {
    const route = get($route, 'current.$$route') as any;
    if (!route.requireUICapability) {
      return;
    }

    if (!get(uiCapabilities, route.requireUICapability)) {
      const url = chrome.addBasePath(`${kbnBaseUrl}#/home`);
      kbnUrl.redirect(url);
      throw uiRoutes.WAIT_FOR_URL_CHANGE_TOKEN;
    }
  }
开发者ID:elastic,项目名称:kibana,代码行数:12,代码来源:route_setup.ts


示例3: moveToDiscover

export function moveToDiscover(indexPatternId: string, kbnBaseUrl: string) {
  const _g = rison.encode({});

  // Add the index pattern ID to the appState part of the URL.
  const _a = rison.encode({
    index: indexPatternId,
  });

  const baseUrl = chrome.addBasePath(kbnBaseUrl);
  const hash = `#/discover?_g=${_g}&_a=${_a}`;

  window.location.href = `${baseUrl}${hash}`;
}
开发者ID:elastic,项目名称:kibana,代码行数:13,代码来源:navigation.ts


示例4: getKibanaHref

export function getKibanaHref({
  location,
  pathname = '',
  hash,
  query = {}
}: KibanaHrefArgs): string {
  const search = getSearchString(location, pathname, query);
  const href = url.format({
    pathname: chrome.addBasePath(pathname),
    hash: `${hash}?${search}`
  });
  return href;
}
开发者ID:njd5475,项目名称:kibana,代码行数:13,代码来源:url_helpers.ts


示例5: getKibanaHref

export function getKibanaHref({
  location,
  pathname = '',
  hash,
  query = {}
}: KibanaHrefArgs): string {
  const queryWithRisonParams = getQueryWithRisonParams(location, query);
  const search = stringifyWithoutEncoding(queryWithRisonParams);
  const href = url.format({
    pathname: chrome.addBasePath(pathname),
    hash: `${hash}?${search}`
  });
  return href;
}
开发者ID:liuyepiaoxiang,项目名称:kibana,代码行数:14,代码来源:url_helpers.ts


示例6: trackUiMetric

export function trackUiMetric(appName: string, metricType: string | string[]) {
  if (!getCanTrackUiMetrics()) {
    return;
  }

  if (appName.includes(':')) {
    throw createErrorMessage(`app name '${appName}'`);
  }

  if (metricType.includes(':')) {
    throw createErrorMessage(`metric type ${metricType}`);
  }

  const metricTypes = Array.isArray(metricType) ? metricType.join(',') : metricType;
  const uri = chrome.addBasePath(`${API_BASE_PATH}/${appName}/${metricTypes}`);
  _http.post(uri);
}
开发者ID:elastic,项目名称:kibana,代码行数:17,代码来源:index.ts


示例7: fetchText

  private async fetchText(resource: Uri) {
    const repo = `${resource.authority}${resource.path}`;
    const revision = resource.query;
    const file = resource.fragment;
    const response = await fetch(
      chrome.addBasePath(`/api/code/repo/${repo}/blob/${revision}/${file}`)
    );
    if (response.status === 200) {
      const contentType = response.headers.get('Content-Type');

      if (contentType && contentType.startsWith('text/')) {
        const lang = contentType.split(';')[0].substring('text/'.length);
        const text = await response.text();
        return { text, lang };
      }
    } else {
      return null;
    }
  }
开发者ID:elastic,项目名称:kibana,代码行数:19,代码来源:textmodel_resolver.ts


示例8: getRisonHref

export function getRisonHref({
  location,
  pathname,
  hash,
  query = {}
}: RisonHrefArgs) {
  const currentQuery = toQuery(location.search);
  const nextQuery = {
    ...TIMEPICKER_DEFAULTS,
    ...pick(currentQuery, PERSISTENT_APM_PARAMS),
    ...query
  };

  // Create _g value for non-apm links
  const g = createG(nextQuery);
  const encodedG = rison.encode(g);
  const encodedA = query._a ? rison.encode(query._a) : ''; // TODO: Do we need to url-encode the _a values before rison encoding _a?
  const risonQuery: RisonEncoded = {
    _g: encodedG
  };

  if (encodedA) {
    risonQuery._a = encodedA;
  }

  // don't URI-encode the already-encoded rison
  const search = qs.stringify(risonQuery, undefined, undefined, {
    encodeURIComponent: (v: string) => v
  });

  const href = url.format({
    pathname: chrome.addBasePath(pathname),
    hash: `${hash}?${search}`
  });

  return href;
}
开发者ID:njd5475,项目名称:kibana,代码行数:37,代码来源:rison_helpers.ts


示例9: saveRole

/*
 * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
 * or more contributor license agreements. Licensed under the Elastic License;
 * you may not use this file except in compliance with the Elastic License.
 */
import { omit } from 'lodash';
import chrome from 'ui/chrome';
import { Role } from '../../../common/model/role';

const apiBase = chrome.addBasePath(`/api/security/role`);

export async function saveRole($http: any, role: Role) {
  const data = omit(role, 'name', 'transient_metadata', '_unrecognized_applications');
  return await $http.put(`${apiBase}/${role.name}`, data);
}

export async function deleteRole($http: any, name: string) {
  return await $http.delete(`${apiBase}/${name}`);
}
开发者ID:gingerwizard,项目名称:kibana,代码行数:19,代码来源:roles.ts


示例10: createUserActionUri

export function createUserActionUri(appName: string, actionType: string): string {
  return chrome.addBasePath(`/api/user_action/${appName}/${actionType}`);
}
开发者ID:njd5475,项目名称:kibana,代码行数:3,代码来源:user_action.ts



注:本文中的ui/chrome.addBasePath函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
TypeScript chrome.getBasePath函数代码示例发布时间:2022-05-25
下一篇:
TypeScript button.Button类代码示例发布时间:2022-05-25
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap