You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
33 lines
1.1 KiB
JavaScript
33 lines
1.1 KiB
JavaScript
const pageModules = Object.freeze({
|
|
instances: '/cloud/instances.js',
|
|
detail: '/cloud/detail.js',
|
|
deploy: '/cloud/deploy.js',
|
|
isos: '/cloud/iso-images.js',
|
|
keys: '/cloud/ssh-keys.js',
|
|
invoices: '/cloud/invoices.js',
|
|
'invoice-detail': '/cloud/invoice-detail.js',
|
|
reinstall: '/cloud/reinstall.js',
|
|
rescue: '/cloud/rescue.js',
|
|
});
|
|
|
|
const page = document.body.dataset.cloudPage || '';
|
|
const modulePath = pageModules[page];
|
|
if (modulePath) {
|
|
const moduleUrl = new URL(modulePath, location.origin);
|
|
const assetVersion = new URL(import.meta.url).searchParams.get('v');
|
|
if (assetVersion) moduleUrl.searchParams.set('v', assetVersion);
|
|
import(moduleUrl.href).then(module => module.initialize()).catch(error => {
|
|
const target = document.getElementById('cloud-page-error');
|
|
if (target) {
|
|
target.textContent = error?.message || '页面加载失败,请刷新后重试。';
|
|
target.hidden = false;
|
|
}
|
|
});
|
|
} else {
|
|
const target = document.getElementById('cloud-page-error');
|
|
if (target) {
|
|
target.textContent = '页面类型无效,请返回实例列表。';
|
|
target.hidden = false;
|
|
}
|
|
}
|