本文整理汇总了TypeScript中@jupyterlab/coreutils.PageConfig.getBaseUrl方法的典型用法代码示例。如果您正苦于以下问题:TypeScript PageConfig.getBaseUrl方法的具体用法?TypeScript PageConfig.getBaseUrl怎么用?TypeScript PageConfig.getBaseUrl使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类@jupyterlab/coreutils.PageConfig
的用法示例。
在下文中一共展示了PageConfig.getBaseUrl方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1:
manager.ready.then(() => {
const specs = manager.specs;
if (!specs) {
return;
}
let baseUrl = PageConfig.getBaseUrl();
for (let name in specs.kernelspecs) {
let displayName = specs.kernelspecs[name].display_name;
let rank = name === specs.default ? 0 : Infinity;
let kernelIconUrl = specs.kernelspecs[name].resources['logo-64x64'];
if (kernelIconUrl) {
let index = kernelIconUrl.indexOf('kernelspecs');
kernelIconUrl = baseUrl + kernelIconUrl.slice(index);
}
launcher.add({
displayName,
category: 'Console',
name,
iconClass: 'jp-CodeConsoleIcon',
callback,
rank,
kernelIconUrl
});
}
});
示例2: DisposableSet
const onSpecsChanged = () => {
if (disposables) {
disposables.dispose();
disposables = null;
}
const specs = manager.specs;
if (!specs) {
return;
}
disposables = new DisposableSet();
let baseUrl = PageConfig.getBaseUrl();
for (let name in specs.kernelspecs) {
let rank = name === specs.default ? 0 : Infinity;
let kernelIconUrl = specs.kernelspecs[name].resources['logo-64x64'];
if (kernelIconUrl) {
let index = kernelIconUrl.indexOf('kernelspecs');
kernelIconUrl = baseUrl + kernelIconUrl.slice(index);
}
disposables.add(
launcher.add({
command: CommandIDs.create,
args: { isLauncher: true, kernelPreference: { name } },
category: 'Console',
rank,
kernelIconUrl
})
);
}
};
示例3: it
it('should use default settings', () => {
let settings = ServerConnection.makeSettings();
expect(settings.baseUrl).to.be(PageConfig.getBaseUrl());
expect(settings.wsUrl).to.be(PageConfig.getWsUrl());
expect(settings.user).to.be('');
expect(settings.password).to.be('');
expect(settings.withCredentials).to.be(false);
expect(settings.timeout).to.be(0);
expect(settings.token).to.be(PageConfig.getOption('token'));
expect(Object.keys(settings.requestHeaders).length).to.be(0);
});
示例4: makeSettings
function makeSettings(options: Partial<ServerConnection.ISettings> = {}): ServerConnection.ISettings {
let baseUrl = options.baseUrl || PageConfig.getBaseUrl();
return {
baseUrl,
wsUrl: options.wsUrl || PageConfig.getWsUrl(baseUrl),
user: options.user || '',
password: options.password || '',
withCredentials: !!options.withCredentials,
timeout: options.timeout || 0,
token: options.token || PageConfig.getOption('token'),
requestHeaders: { ...options.requestHeaders || {} },
xhrFactory: options.xhrFactory || xhrFactory,
wsFactory: options.wsFactory || wsFactory
};
}
示例5: setApi
private setApi() {
let baseUrl;
if (this.api) {
return;
}
try {
const coreutils = require('@jupyterlab/coreutils');
coreutils.PageConfig.getOption('pageUrl');
baseUrl = coreutils.PageConfig.getBaseUrl();
} catch (e) {
baseUrl = `${window.location.origin}/`;
}
this.api = new BeakerXApi(baseUrl);
}
示例6:
services.ready.then(() => {
const specs = services.specs;
const baseUrl = PageConfig.getBaseUrl();
for (let name in specs.kernelspecs) {
let rank = name === specs.default ? 0 : Infinity;
let kernelIconUrl = specs.kernelspecs[name].resources['logo-64x64'];
if (kernelIconUrl) {
let index = kernelIconUrl.indexOf('kernelspecs');
kernelIconUrl = baseUrl + kernelIconUrl.slice(index);
}
launcher.add({
command: CommandIDs.createNew,
args: { isLauncher: true, kernelName: name },
category: 'Notebook',
rank,
kernelIconUrl
});
}
});
示例7: prepareImageSrc
private prepareImageSrc(config): string {
let baseUrl;
if (config.value[0] !== '.') {
return `${ config.value }`;
}
try {
const coreutils = require('@jupyterlab/coreutils');
coreutils.PageConfig.getOption('pageUrl');
baseUrl = coreutils.PageConfig.getBaseUrl();
} catch (e) {
baseUrl = `${window.location.origin}/`;
}
let notebookPath = `${ baseUrl }${ document.body.dataset.notebookPath}`;
return '/files' + new URL(config.value, notebookPath).pathname;
}
示例8: TreeWidget
execute: () => {
if (!widget) {
let options = {
baseUrl: PageConfig.getBaseUrl(),
isLab: true,
};
widget = new TreeWidget(options);
widget.update();
}
if (!tracker.has(widget)) {
tracker.add(widget);
}
if (!widget.isAttached) {
app.shell.addToMainArea(widget);
} else {
widget.update();
}
app.shell.activateById(widget.id);
}
示例9:
services.ready.then(() => {
let specs = services.specs;
let baseUrl = PageConfig.getBaseUrl();
for (let name in specs.kernelspecs) {
let displayName = specs.kernelspecs[name].display_name;
let rank = name === specs.default ? 0 : Infinity;
let kernelIconUrl = specs.kernelspecs[name].resources['logo-64x64'];
if (kernelIconUrl) {
let index = kernelIconUrl.indexOf('kernelspecs');
kernelIconUrl = baseUrl + kernelIconUrl.slice(index);
}
launcher.add({
displayName,
category: 'Notebook',
name,
iconClass: 'jp-NotebookRunningIcon',
callback,
rank,
kernelIconUrl
});
}
});
示例10:
manager.ready.then(() => {
const specs = manager.specs;
if (!specs) {
return;
}
let baseUrl = PageConfig.getBaseUrl();
for (let name in specs.kernelspecs) {
let rank = name === specs.default ? 0 : Infinity;
let kernelIconUrl = specs.kernelspecs[name].resources['logo-64x64'];
if (kernelIconUrl) {
let index = kernelIconUrl.indexOf('kernelspecs');
kernelIconUrl = baseUrl + kernelIconUrl.slice(index);
}
launcher.add({
command: CommandIDs.create,
args: { isLauncher: true, kernelPreference: { name } },
category: 'Console',
rank,
kernelIconUrl
});
}
});