feat(admin-vpc): 重构概览和网络目录
parent
f86af4979c
commit
e839e82f67
@ -0,0 +1,507 @@
|
||||
.admin-vpc-control {
|
||||
padding-bottom: 28px;
|
||||
}
|
||||
|
||||
.admin-vpc-control [hidden] {
|
||||
display: none !important;
|
||||
}
|
||||
|
||||
.admin-vpc-feature,
|
||||
.admin-vpc-state {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
width: fit-content;
|
||||
border-radius: 999px;
|
||||
font-weight: 750;
|
||||
line-height: 1.2;
|
||||
}
|
||||
|
||||
.admin-vpc-feature {
|
||||
min-height: 38px;
|
||||
padding: 8px 13px;
|
||||
font-size: 13px;
|
||||
}
|
||||
|
||||
.admin-vpc-feature.is-enabled,
|
||||
.admin-vpc-state.is-success {
|
||||
color: #08785b;
|
||||
background: #e3f8ef;
|
||||
}
|
||||
|
||||
.admin-vpc-feature.is-disabled,
|
||||
.admin-vpc-state.is-warning {
|
||||
color: #8a5700;
|
||||
background: #fff3d5;
|
||||
}
|
||||
|
||||
.admin-vpc-state.is-danger {
|
||||
color: #b42318;
|
||||
background: #ffebee;
|
||||
}
|
||||
|
||||
.admin-vpc-state {
|
||||
padding: 6px 10px;
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
.admin-vpc-control > .admin-config-status {
|
||||
width: 100%;
|
||||
margin: 0 0 14px;
|
||||
padding: 9px 12px;
|
||||
border-radius: 9px;
|
||||
}
|
||||
|
||||
.admin-vpc-tabs {
|
||||
display: flex;
|
||||
gap: 8px;
|
||||
margin: 0 0 16px;
|
||||
padding: 6px;
|
||||
border: 1px solid #e2e8f0;
|
||||
border-radius: 12px;
|
||||
background: #f8fafc;
|
||||
overflow-x: auto;
|
||||
}
|
||||
|
||||
.admin-vpc-tabs .btn {
|
||||
flex: 0 0 auto;
|
||||
min-width: 128px;
|
||||
}
|
||||
|
||||
.admin-vpc-panel {
|
||||
display: grid;
|
||||
gap: 16px;
|
||||
}
|
||||
|
||||
.admin-vpc-summary {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(6, minmax(0, 1fr));
|
||||
gap: 12px;
|
||||
}
|
||||
|
||||
.admin-vpc-summary-card {
|
||||
min-width: 0;
|
||||
min-height: 136px;
|
||||
margin: 0;
|
||||
padding: 18px;
|
||||
border: 1px solid #e4eaf1;
|
||||
text-align: left;
|
||||
color: #1d2939;
|
||||
background: #fff;
|
||||
}
|
||||
|
||||
button.admin-vpc-summary-card {
|
||||
cursor: pointer;
|
||||
transition: transform .16s ease, border-color .16s ease,
|
||||
box-shadow .16s ease;
|
||||
}
|
||||
|
||||
button.admin-vpc-summary-card:hover,
|
||||
button.admin-vpc-summary-card:focus-visible {
|
||||
transform: translateY(-2px);
|
||||
border-color: #9edfd4;
|
||||
box-shadow: 0 12px 24px rgba(17, 94, 89, .09);
|
||||
}
|
||||
|
||||
.admin-vpc-summary-card span {
|
||||
color: #64748b;
|
||||
font-size: 13px;
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
.admin-vpc-summary-card strong {
|
||||
display: block;
|
||||
margin: 12px 0 8px;
|
||||
color: #0f172a;
|
||||
font-size: 30px;
|
||||
line-height: 1;
|
||||
}
|
||||
|
||||
.admin-vpc-summary-card small {
|
||||
display: block;
|
||||
color: #8a99ab;
|
||||
font-size: 12px;
|
||||
line-height: 1.45;
|
||||
}
|
||||
|
||||
.admin-vpc-summary-card.is-success {
|
||||
border-top: 3px solid #22a77a;
|
||||
}
|
||||
|
||||
.admin-vpc-summary-card.is-warning {
|
||||
border-top: 3px solid #e5a500;
|
||||
}
|
||||
|
||||
.admin-vpc-summary-card.is-danger {
|
||||
border-top: 3px solid #e24755;
|
||||
}
|
||||
|
||||
.admin-vpc-section {
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.admin-vpc-section-head {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 16px;
|
||||
padding: 20px 22px;
|
||||
border-bottom: 1px solid #e5ebf2;
|
||||
}
|
||||
|
||||
.admin-vpc-section-head h2 {
|
||||
margin: 0 0 4px;
|
||||
color: #0f172a;
|
||||
font-size: 18px;
|
||||
font-weight: 750;
|
||||
}
|
||||
|
||||
.admin-vpc-section-head p:last-child {
|
||||
margin: 0;
|
||||
color: #7d8a9c;
|
||||
font-size: 13px;
|
||||
}
|
||||
|
||||
.admin-vpc-region-grid {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(3, minmax(0, 1fr));
|
||||
gap: 14px;
|
||||
padding: 20px 22px;
|
||||
}
|
||||
|
||||
.admin-vpc-region {
|
||||
min-width: 0;
|
||||
padding: 17px;
|
||||
border: 1px solid #dfe7ef;
|
||||
border-radius: 12px;
|
||||
background: #fbfcfe;
|
||||
}
|
||||
|
||||
.admin-vpc-region.is-ready {
|
||||
border-color: #b8e8d9;
|
||||
background: #f7fdfa;
|
||||
}
|
||||
|
||||
.admin-vpc-region.is-blocked {
|
||||
border-color: #f1d6d9;
|
||||
background: #fffafb;
|
||||
}
|
||||
|
||||
.admin-vpc-region > header {
|
||||
display: flex;
|
||||
align-items: flex-start;
|
||||
justify-content: space-between;
|
||||
gap: 10px;
|
||||
}
|
||||
|
||||
.admin-vpc-region h3 {
|
||||
margin: 0 0 3px;
|
||||
color: #172033;
|
||||
font-size: 16px;
|
||||
}
|
||||
|
||||
.admin-vpc-region header p {
|
||||
margin: 0;
|
||||
color: #8a99ab;
|
||||
font-size: 12px;
|
||||
text-transform: uppercase;
|
||||
}
|
||||
|
||||
.admin-vpc-region header > span {
|
||||
flex: 0 0 auto;
|
||||
padding: 5px 8px;
|
||||
border-radius: 999px;
|
||||
color: #08785b;
|
||||
background: #e3f8ef;
|
||||
font-size: 11px;
|
||||
font-weight: 750;
|
||||
}
|
||||
|
||||
.admin-vpc-region.is-blocked header > span {
|
||||
color: #b42318;
|
||||
background: #ffebee;
|
||||
}
|
||||
|
||||
.admin-vpc-region dl {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(3, minmax(0, 1fr));
|
||||
gap: 8px;
|
||||
margin: 16px 0 0;
|
||||
}
|
||||
|
||||
.admin-vpc-region dl > div {
|
||||
min-width: 0;
|
||||
padding: 10px;
|
||||
border-radius: 9px;
|
||||
background: #fff;
|
||||
}
|
||||
|
||||
.admin-vpc-region dt {
|
||||
color: #8a99ab;
|
||||
font-size: 11px;
|
||||
font-weight: 650;
|
||||
}
|
||||
|
||||
.admin-vpc-region dd {
|
||||
margin: 5px 0 0;
|
||||
color: #26354a;
|
||||
font-size: 14px;
|
||||
font-weight: 750;
|
||||
}
|
||||
|
||||
.admin-vpc-region ul {
|
||||
display: grid;
|
||||
gap: 5px;
|
||||
margin: 14px 0 0;
|
||||
padding: 0;
|
||||
color: #a23a45;
|
||||
font-size: 12px;
|
||||
list-style: none;
|
||||
}
|
||||
|
||||
.admin-vpc-region ul li::before {
|
||||
content: "•";
|
||||
margin-right: 6px;
|
||||
}
|
||||
|
||||
.admin-vpc-region-ok {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
margin: 14px 0 0;
|
||||
color: #08785b;
|
||||
font-size: 12px;
|
||||
font-weight: 650;
|
||||
}
|
||||
|
||||
.admin-vpc-empty {
|
||||
margin: 0;
|
||||
padding: 28px;
|
||||
color: #7d8a9c;
|
||||
text-align: center;
|
||||
grid-column: 1 / -1;
|
||||
}
|
||||
|
||||
.admin-vpc-filter {
|
||||
display: grid;
|
||||
grid-template-columns: minmax(220px, 1.5fr) repeat(3, minmax(150px, .7fr));
|
||||
gap: 12px;
|
||||
padding: 18px 22px;
|
||||
border-bottom: 1px solid #e5ebf2;
|
||||
background: #fbfcfe;
|
||||
}
|
||||
|
||||
.admin-vpc-filter label {
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.admin-vpc-filter .form-label {
|
||||
display: block;
|
||||
margin-bottom: 6px;
|
||||
}
|
||||
|
||||
.admin-vpc-filter-actions {
|
||||
display: flex;
|
||||
align-items: flex-end;
|
||||
gap: 8px;
|
||||
grid-column: 1 / -1;
|
||||
}
|
||||
|
||||
.admin-vpc-table th {
|
||||
padding: 13px 14px;
|
||||
color: #7a889b;
|
||||
background: #f8fafc;
|
||||
font-size: 12px;
|
||||
font-weight: 750;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.admin-vpc-table td {
|
||||
padding: 15px 14px;
|
||||
vertical-align: middle;
|
||||
}
|
||||
|
||||
.admin-vpc-table td > strong,
|
||||
.admin-vpc-table td > a,
|
||||
.admin-vpc-table td > small,
|
||||
.admin-vpc-table td > time {
|
||||
display: block;
|
||||
}
|
||||
|
||||
.admin-vpc-table td > strong,
|
||||
.admin-vpc-table td > a {
|
||||
color: #26354a;
|
||||
font-weight: 750;
|
||||
}
|
||||
|
||||
.admin-vpc-table td > small,
|
||||
.admin-vpc-table td > time {
|
||||
margin-top: 4px;
|
||||
color: #8a99ab;
|
||||
font-size: 11px;
|
||||
overflow-wrap: anywhere;
|
||||
}
|
||||
|
||||
.admin-vpc-pagination {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
gap: 12px;
|
||||
padding: 17px 22px;
|
||||
border-top: 1px solid #e5ebf2;
|
||||
color: #6f7f92;
|
||||
font-size: 13px;
|
||||
}
|
||||
|
||||
@media (max-width: 1399.98px) {
|
||||
.admin-vpc-summary {
|
||||
grid-template-columns: repeat(3, minmax(0, 1fr));
|
||||
}
|
||||
|
||||
.admin-vpc-region-grid {
|
||||
grid-template-columns: repeat(2, minmax(0, 1fr));
|
||||
}
|
||||
}
|
||||
|
||||
@media (max-width: 991.98px) {
|
||||
.admin-vpc-filter {
|
||||
grid-template-columns: repeat(2, minmax(0, 1fr));
|
||||
}
|
||||
}
|
||||
|
||||
@media (max-width: 767.98px) {
|
||||
.admin-vpc-control .cloud-admin-page-head {
|
||||
align-items: stretch !important;
|
||||
}
|
||||
|
||||
.admin-vpc-control .cloud-admin-actions,
|
||||
.admin-vpc-control .cloud-admin-actions .btn,
|
||||
.admin-vpc-feature {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.admin-vpc-feature,
|
||||
.admin-vpc-control .cloud-admin-actions .btn {
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.admin-vpc-tabs .btn {
|
||||
flex: 1 0 118px;
|
||||
}
|
||||
|
||||
.admin-vpc-summary {
|
||||
grid-template-columns: repeat(2, minmax(0, 1fr));
|
||||
}
|
||||
|
||||
.admin-vpc-summary-card {
|
||||
min-height: 120px;
|
||||
padding: 15px;
|
||||
}
|
||||
|
||||
.admin-vpc-summary-card strong {
|
||||
font-size: 26px;
|
||||
}
|
||||
|
||||
.admin-vpc-region-grid,
|
||||
.admin-vpc-filter {
|
||||
grid-template-columns: minmax(0, 1fr);
|
||||
padding: 16px;
|
||||
}
|
||||
|
||||
.admin-vpc-section-head {
|
||||
align-items: flex-start;
|
||||
flex-direction: column;
|
||||
padding: 17px 16px;
|
||||
}
|
||||
|
||||
.admin-vpc-section-head .btn,
|
||||
.admin-vpc-filter-actions,
|
||||
.admin-vpc-filter-actions .btn {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.admin-vpc-filter-actions {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(2, minmax(0, 1fr));
|
||||
}
|
||||
|
||||
.admin-vpc-section .table-responsive {
|
||||
overflow: visible;
|
||||
}
|
||||
|
||||
.admin-vpc-table thead {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.admin-vpc-table,
|
||||
.admin-vpc-table tbody,
|
||||
.admin-vpc-table tr,
|
||||
.admin-vpc-table td {
|
||||
display: block;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.admin-vpc-table tbody {
|
||||
display: grid;
|
||||
gap: 12px;
|
||||
padding: 14px;
|
||||
}
|
||||
|
||||
.admin-vpc-table tr {
|
||||
padding: 4px 13px;
|
||||
border: 1px solid #e1e8f0;
|
||||
border-radius: 12px;
|
||||
background: #fff;
|
||||
}
|
||||
|
||||
.admin-vpc-table td {
|
||||
display: grid;
|
||||
grid-template-columns: minmax(92px, .42fr) minmax(0, 1fr);
|
||||
gap: 10px;
|
||||
padding: 10px 0;
|
||||
border: 0;
|
||||
border-bottom: 1px solid #eef2f6;
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
.admin-vpc-table td:last-child {
|
||||
border-bottom: 0;
|
||||
}
|
||||
|
||||
.admin-vpc-table td::before {
|
||||
content: attr(data-label);
|
||||
color: #8a99ab;
|
||||
font-size: 11px;
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
.admin-vpc-table td[colspan] {
|
||||
display: block;
|
||||
padding: 24px 8px;
|
||||
}
|
||||
|
||||
.admin-vpc-table td[colspan]::before {
|
||||
content: none;
|
||||
}
|
||||
|
||||
.admin-vpc-pagination {
|
||||
align-items: stretch;
|
||||
flex-direction: column;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.admin-vpc-pagination .btn {
|
||||
width: 100%;
|
||||
}
|
||||
}
|
||||
|
||||
@media (max-width: 419.98px) {
|
||||
.admin-vpc-summary {
|
||||
grid-template-columns: minmax(0, 1fr);
|
||||
}
|
||||
|
||||
.admin-vpc-region dl,
|
||||
.admin-vpc-filter-actions {
|
||||
grid-template-columns: minmax(0, 1fr);
|
||||
}
|
||||
}
|
||||
@ -1,66 +1,552 @@
|
||||
const root = document.querySelector('[data-admin-vpc]');
|
||||
const byId = id => document.getElementById(id);
|
||||
const canManage = root?.dataset.canManage === '1';
|
||||
const state = { csrf: window.ADMIN_CSRF_TOKEN || '', regions: [], items: [], featureEnabled: false, busy: false, requestKey: '' };
|
||||
const allowedViews = new Set(['overview', 'networks', 'pools']);
|
||||
const state = {
|
||||
csrf: window.ADMIN_CSRF_TOKEN || '',
|
||||
page: null,
|
||||
view: allowedViews.has(root?.dataset.vpcView) ? root.dataset.vpcView : 'overview',
|
||||
busy: false,
|
||||
poolEditingId: '',
|
||||
requestKey: '',
|
||||
};
|
||||
|
||||
function notice(message, error = false) {
|
||||
const box = byId('admin-vpc-status'); box.textContent = message; box.className = `alert ${error ? 'alert-danger' : 'alert-info'} cloud-admin-notice`;
|
||||
function readBootstrap() {
|
||||
try {
|
||||
const payload = JSON.parse(byId('admin-vpc-bootstrap')?.textContent || 'null');
|
||||
if (payload && payload.overview && payload.networks && payload.pools) return payload;
|
||||
} catch {}
|
||||
return {
|
||||
overview: { feature: { enabled: false, settings_url: '/admin/config' },
|
||||
summary: {}, regions: [], attention: [] },
|
||||
networks: { items: [], filters: { q: '', state: '', region_id: 0 },
|
||||
pagination: { page: 1, per_page: 20, total: 0, total_pages: 1 } },
|
||||
pools: { regions: [], items: [], feature_enabled: false },
|
||||
};
|
||||
}
|
||||
function errorMessage(payload, status) { return String(payload?.detail || payload?.error || `请求失败 (${status})`); }
|
||||
|
||||
function notice(message, tone = 'success') {
|
||||
const box = byId('admin-vpc-status');
|
||||
if (!box) return;
|
||||
box.textContent = message;
|
||||
box.className = `admin-config-status is-${tone}`;
|
||||
}
|
||||
|
||||
function errorMessage(payload, status) {
|
||||
return String(payload?.detail || payload?.error || `请求失败 (${status})`);
|
||||
}
|
||||
|
||||
async function api(path, options = {}) {
|
||||
const method = (options.method || 'GET').toUpperCase(); const headers = new Headers({ Accept: 'application/json' });
|
||||
if (!['GET', 'HEAD'].includes(method)) { headers.set('Content-Type', 'application/json'); headers.set('X-CSRF-Token', state.csrf); }
|
||||
const response = await fetch(path, { method, headers, credentials: 'same-origin', cache: 'no-store', body: options.body === undefined ? undefined : JSON.stringify(options.body) });
|
||||
let payload; try { payload = await response.json(); } catch { throw new Error('服务返回非 JSON 响应。'); }
|
||||
if (response.status === 401) { location.assign('/auth/login'); throw new Error('登录已过期。'); }
|
||||
if (!response.ok) throw new Error(errorMessage(payload, response.status)); return payload;
|
||||
const method = (options.method || 'GET').toUpperCase();
|
||||
const headers = new Headers({ Accept: 'application/json' });
|
||||
if (!['GET', 'HEAD'].includes(method)) {
|
||||
headers.set('Content-Type', 'application/json');
|
||||
headers.set('X-CSRF-Token', state.csrf);
|
||||
}
|
||||
const response = await fetch(path, {
|
||||
method, headers, credentials: 'same-origin', cache: 'no-store',
|
||||
signal: options.signal,
|
||||
body: options.body === undefined ? undefined : JSON.stringify(options.body),
|
||||
});
|
||||
let payload;
|
||||
try { payload = await response.json(); } catch { throw new Error('服务返回非 JSON 响应。'); }
|
||||
if (response.status === 401) {
|
||||
location.assign('/auth/login');
|
||||
throw new Error('登录已过期。');
|
||||
}
|
||||
if (!response.ok) throw new Error(errorMessage(payload, response.status));
|
||||
return payload;
|
||||
}
|
||||
|
||||
function create(tag, className = '', text = '') {
|
||||
const node = document.createElement(tag);
|
||||
if (className) node.className = className;
|
||||
if (text !== '') node.textContent = String(text);
|
||||
return node;
|
||||
}
|
||||
|
||||
function appendTextCell(row, label, primary, secondary = '', options = {}) {
|
||||
const cell = create('td');
|
||||
cell.dataset.label = label;
|
||||
let main;
|
||||
if (options.href) {
|
||||
main = create('a', '', primary || '未记录');
|
||||
main.href = options.href;
|
||||
} else {
|
||||
main = create('strong', '', primary || '未记录');
|
||||
}
|
||||
cell.append(main);
|
||||
if (secondary) cell.append(create('small', options.mono ? 'admin-mono' : '', secondary));
|
||||
row.append(cell);
|
||||
return cell;
|
||||
}
|
||||
|
||||
function formatTime(epoch) {
|
||||
const value = Number(epoch);
|
||||
if (!Number.isFinite(value) || value <= 0) return '未记录';
|
||||
return new Intl.DateTimeFormat('zh-CN', {
|
||||
year: 'numeric', month: '2-digit', day: '2-digit',
|
||||
hour: '2-digit', minute: '2-digit', hour12: false,
|
||||
}).format(new Date(value * 1000));
|
||||
}
|
||||
|
||||
function statePill(network) {
|
||||
return create('span', `admin-vpc-state is-${network.display?.tone || 'warning'}`,
|
||||
network.display?.label || '状态未知');
|
||||
}
|
||||
|
||||
function networkRow(network, attention = false) {
|
||||
const row = create('tr');
|
||||
appendTextCell(row, 'VPC', network.name, network.vpc_key);
|
||||
appendTextCell(row, attention ? '用户' : '所有者',
|
||||
network.owner_name || '未记录', `ID ${network.user_id}`,
|
||||
{ href: network.owner_url || '' });
|
||||
appendTextCell(row, '地区与网段', network.region_name, network.cidr,
|
||||
{ mono: true });
|
||||
if (!attention) appendTextCell(row, '实例', network.port_count, '已连接端口');
|
||||
appendTextCell(row, '宿主机投影',
|
||||
`${network.host_summary?.ready || 0} / ${network.host_summary?.total || 0}`,
|
||||
attention ? `${network.port_count || 0} 个实例端口` : '已收敛 / 全部');
|
||||
const statusCell = create('td');
|
||||
statusCell.dataset.label = '状态';
|
||||
statusCell.append(statePill(network));
|
||||
if (network.active_batch) {
|
||||
statusCell.append(create('small', '', `任务 #${network.active_batch.job_id}`));
|
||||
}
|
||||
row.append(statusCell);
|
||||
if (!attention) appendTextCell(row, '最近变化', formatTime(network.updated_at));
|
||||
const action = create('td');
|
||||
action.dataset.label = '操作';
|
||||
const button = create('button', `btn ${attention ? 'btn-light' : 'btn-primary'} btn-sm`,
|
||||
attention ? '定位网络' : '查看详情');
|
||||
button.type = 'button';
|
||||
if (attention) button.dataset.vpcNetworkFocus = network.vpc_key;
|
||||
else button.dataset.vpcDetail = String(network.id);
|
||||
action.append(button);
|
||||
row.append(action);
|
||||
return row;
|
||||
}
|
||||
|
||||
function emptyRow(columns, text) {
|
||||
const row = create('tr');
|
||||
const cell = create('td', 'text-center text-muted py-4', text);
|
||||
cell.colSpan = columns;
|
||||
row.append(cell);
|
||||
return row;
|
||||
}
|
||||
|
||||
function renderSummary() {
|
||||
const summary = state.page.overview.summary || {};
|
||||
for (const key of ['total', 'active', 'changing', 'degraded', 'ports', 'batches']) {
|
||||
const source = key === 'batches' ? 'active_batches' : key;
|
||||
const node = byId(`admin-vpc-summary-${key}`);
|
||||
if (node) node.textContent = String(summary[source] || 0);
|
||||
}
|
||||
const feature = state.page.overview.feature || {};
|
||||
const featureNode = byId('admin-vpc-feature');
|
||||
if (featureNode) {
|
||||
featureNode.className = `admin-vpc-feature ${feature.enabled ? 'is-enabled' : 'is-disabled'}`;
|
||||
featureNode.replaceChildren();
|
||||
const icon = create('i', `mdi ${feature.enabled ? 'mdi-check-circle-outline' : 'mdi-pause-circle-outline'}`);
|
||||
icon.setAttribute('aria-hidden', 'true');
|
||||
featureNode.append(icon, document.createTextNode(feature.enabled
|
||||
? '用户 VPC 已开启' : '用户 VPC 已关闭'));
|
||||
}
|
||||
}
|
||||
|
||||
function renderRegions() {
|
||||
const box = byId('admin-vpc-regions');
|
||||
box.replaceChildren();
|
||||
const regions = Array.isArray(state.page.overview.regions)
|
||||
? state.page.overview.regions : [];
|
||||
if (!regions.length) {
|
||||
box.append(create('p', 'admin-vpc-empty', '尚未建立地区和 VPC 承载配置。'));
|
||||
return;
|
||||
}
|
||||
for (const region of regions) {
|
||||
const card = create('article', `admin-vpc-region ${region.ready ? 'is-ready' : 'is-blocked'}`);
|
||||
const header = create('header');
|
||||
const heading = create('div');
|
||||
heading.append(create('h3', '', region.name),
|
||||
create('p', '', `${region.code} · ${region.country_code}`));
|
||||
header.append(heading, create('span', '', region.ready ? '可创建' : '暂不可用'));
|
||||
const details = create('dl');
|
||||
for (const [label, value] of [
|
||||
['地址空间', `${region.used} / ${region.capacity}`],
|
||||
['可用子网', region.available],
|
||||
['就绪节点', `${region.hosts_ready} / ${region.hosts_total}`],
|
||||
]) {
|
||||
const item = create('div');
|
||||
item.append(create('dt', '', label), create('dd', '', value));
|
||||
details.append(item);
|
||||
}
|
||||
card.append(header, details);
|
||||
if (Array.isArray(region.blockers) && region.blockers.length) {
|
||||
const list = create('ul');
|
||||
for (const blocker of region.blockers) list.append(create('li', '', blocker.label));
|
||||
card.append(list);
|
||||
} else {
|
||||
const okay = create('p', 'admin-vpc-region-ok');
|
||||
const icon = create('i', 'mdi mdi-check-circle-outline');
|
||||
icon.setAttribute('aria-hidden', 'true');
|
||||
okay.append(icon, document.createTextNode('新建 VPC 的基础条件已满足'));
|
||||
card.append(okay);
|
||||
}
|
||||
box.append(card);
|
||||
}
|
||||
}
|
||||
|
||||
function renderAttention() {
|
||||
const body = byId('admin-vpc-attention-body');
|
||||
body.replaceChildren();
|
||||
const items = Array.isArray(state.page.overview.attention)
|
||||
? state.page.overview.attention : [];
|
||||
if (!items.length) {
|
||||
body.append(emptyRow(6, '当前没有需要人工处理的 VPC。'));
|
||||
return;
|
||||
}
|
||||
for (const network of items) body.append(networkRow(network, true));
|
||||
}
|
||||
|
||||
function renderNetworks() {
|
||||
const data = state.page.networks;
|
||||
const body = byId('admin-vpc-network-body');
|
||||
body.replaceChildren();
|
||||
for (const network of data.items || []) body.append(networkRow(network));
|
||||
if (!data.items?.length) body.append(emptyRow(8, '没有符合条件的 VPC。'));
|
||||
const page = data.pagination || {};
|
||||
byId('admin-vpc-network-count').textContent = `共 ${page.total || 0} 个`;
|
||||
byId('admin-vpc-page-label').textContent =
|
||||
`第 ${page.page || 1} / ${page.total_pages || 1} 页 · 共 ${page.total || 0} 个`;
|
||||
byId('admin-vpc-previous').disabled = (page.page || 1) <= 1;
|
||||
byId('admin-vpc-next').disabled = (page.page || 1) >= (page.total_pages || 1);
|
||||
}
|
||||
|
||||
function renderAll() {
|
||||
renderSummary();
|
||||
renderRegions();
|
||||
renderAttention();
|
||||
renderNetworks();
|
||||
renderPools();
|
||||
}
|
||||
|
||||
function setView(view, updateHistory = true) {
|
||||
if (!allowedViews.has(view)) view = 'overview';
|
||||
state.view = view;
|
||||
root.dataset.vpcView = view;
|
||||
for (const button of root.querySelectorAll('[data-vpc-view]')) {
|
||||
const active = button.dataset.vpcView === view;
|
||||
button.setAttribute('aria-selected', String(active));
|
||||
button.classList.toggle('btn-primary', active);
|
||||
button.classList.toggle('btn-light', !active);
|
||||
}
|
||||
for (const name of allowedViews) {
|
||||
byId(`admin-vpc-panel-${name}`).hidden = name !== view;
|
||||
}
|
||||
if (updateHistory) {
|
||||
const url = new URL(location.href);
|
||||
url.searchParams.set('view', view);
|
||||
history.replaceState(history.state, '', url);
|
||||
}
|
||||
}
|
||||
|
||||
function filterParams(pageOverride = null) {
|
||||
const form = byId('admin-vpc-filter');
|
||||
const params = new URLSearchParams();
|
||||
for (const name of ['q', 'region_id', 'state', 'per_page']) {
|
||||
const value = form.elements.namedItem(name)?.value.trim() || '';
|
||||
if (value && !(name === 'region_id' && value === '0')) params.set(name, value);
|
||||
}
|
||||
const page = pageOverride ?? state.page.networks.pagination?.page ?? 1;
|
||||
if (Number(page) > 1) params.set('page', String(page));
|
||||
return params;
|
||||
}
|
||||
|
||||
function writeNetworkUrl(params) {
|
||||
const url = new URL(location.href);
|
||||
url.search = '';
|
||||
url.searchParams.set('view', 'networks');
|
||||
for (const [key, value] of params) url.searchParams.set(key, value);
|
||||
history.replaceState(history.state, '', url);
|
||||
}
|
||||
|
||||
async function loadNetworks(params = filterParams(1), announce = true) {
|
||||
if (state.busy) return;
|
||||
state.busy = true;
|
||||
const query = params.toString();
|
||||
try {
|
||||
const payload = await api(`/api/v1/admin/vpc-control/vpcs${query ? `?${query}` : ''}`);
|
||||
state.page.networks = payload;
|
||||
renderNetworks();
|
||||
writeNetworkUrl(params);
|
||||
if (announce) notice('VPC 网络目录已更新。');
|
||||
} catch (error) {
|
||||
notice(error.message, 'error');
|
||||
} finally {
|
||||
state.busy = false;
|
||||
}
|
||||
}
|
||||
|
||||
async function refreshControl() {
|
||||
const params = filterParams();
|
||||
const query = params.toString();
|
||||
try {
|
||||
const payload = await api(`/api/v1/admin/vpc-control${query ? `?${query}` : ''}`);
|
||||
state.page = payload;
|
||||
renderAll();
|
||||
notice('VPC 控制面已同步。');
|
||||
} catch (error) {
|
||||
notice(`首屏数据仍可查看;后台同步失败:${error.message}`, 'warning');
|
||||
}
|
||||
}
|
||||
|
||||
function openNetworkState(value) {
|
||||
const form = byId('admin-vpc-filter');
|
||||
form.elements.namedItem('state').value = value;
|
||||
form.elements.namedItem('q').value = '';
|
||||
setView('networks');
|
||||
void loadNetworks(filterParams(1));
|
||||
}
|
||||
|
||||
function focusNetwork(key) {
|
||||
const form = byId('admin-vpc-filter');
|
||||
form.elements.namedItem('q').value = key;
|
||||
form.elements.namedItem('state').value = '';
|
||||
form.elements.namedItem('region_id').value = '0';
|
||||
setView('networks');
|
||||
void loadNetworks(filterParams(1));
|
||||
}
|
||||
|
||||
function detailField(list, label, value) {
|
||||
list.append(create('dt', '', label), create('dd', '', value || '未记录'));
|
||||
}
|
||||
|
||||
async function openDetail(id) {
|
||||
const dialog = byId('admin-vpc-detail');
|
||||
const body = byId('admin-vpc-detail-body');
|
||||
const message = byId('admin-vpc-detail-notice');
|
||||
body.replaceChildren();
|
||||
message.hidden = false;
|
||||
message.className = 'alert alert-info';
|
||||
message.textContent = '正在读取 VPC 详情…';
|
||||
window.VenixDrawerMotion?.openDrawerWithMotion(dialog) || dialog.showModal();
|
||||
try {
|
||||
const payload = await api(`/api/v1/admin/vpc-control/vpcs/${encodeURIComponent(id)}`);
|
||||
const network = payload.vpc;
|
||||
byId('admin-vpc-detail-title').textContent = network.name;
|
||||
const details = create('dl', 'admin-instance-details');
|
||||
detailField(details, '所有者', `${network.owner_name || '未记录'} · ID ${network.user_id}`);
|
||||
detailField(details, '地区', network.region_name);
|
||||
detailField(details, '私网网段', network.cidr);
|
||||
detailField(details, '默认网关', network.gateway);
|
||||
detailField(details, '实例端口', String(network.port_count));
|
||||
detailField(details, '宿主机投影',
|
||||
`${network.host_summary.ready} / ${network.host_summary.total} 已收敛`);
|
||||
body.append(details);
|
||||
message.hidden = true;
|
||||
} catch (error) {
|
||||
message.className = 'alert alert-danger';
|
||||
message.textContent = error.message;
|
||||
}
|
||||
}
|
||||
|
||||
async function closeDetail() {
|
||||
const dialog = byId('admin-vpc-detail');
|
||||
if (window.VenixDrawerMotion) await window.VenixDrawerMotion.closeDrawerWithMotion(dialog);
|
||||
else dialog.close();
|
||||
}
|
||||
|
||||
function newRequestKey() {
|
||||
if (!globalThis.crypto?.getRandomValues) throw new Error('浏览器无法生成安全创建标识,请升级浏览器。');
|
||||
const bytes = new Uint8Array(16); globalThis.crypto.getRandomValues(bytes); return Array.from(bytes, value => value.toString(16).padStart(2, '0')).join('');
|
||||
if (!globalThis.crypto?.getRandomValues) {
|
||||
throw new Error('浏览器无法生成安全创建标识,请升级浏览器。');
|
||||
}
|
||||
const bytes = new Uint8Array(16);
|
||||
globalThis.crypto.getRandomValues(bytes);
|
||||
return Array.from(bytes, value => value.toString(16).padStart(2, '0')).join('');
|
||||
}
|
||||
function renderRegions(selected = '') {
|
||||
const select = byId('admin-vpc-pool-region'); select.replaceChildren();
|
||||
const empty = document.createElement('option'); empty.value = ''; empty.textContent = state.regions.length ? '请选择地区' : '请先创建地区'; select.append(empty);
|
||||
for (const region of state.regions) { const option = document.createElement('option'); option.value = String(region.id); option.textContent = `${region.name} · ${region.country_code}${region.status === 'active' ? '' : '(停用)'}`; option.selected = String(region.id) === String(selected); select.append(option); }
|
||||
|
||||
function poolRegions(selected = '') {
|
||||
const select = byId('admin-vpc-pool-region');
|
||||
select.replaceChildren();
|
||||
const regions = state.page.pools.regions || [];
|
||||
const empty = create('option', '', regions.length ? '请选择地区' : '请先创建地区');
|
||||
empty.value = '';
|
||||
select.append(empty);
|
||||
for (const region of regions) {
|
||||
const option = create('option', '',
|
||||
`${region.name} · ${region.country_code}${region.status === 'active' ? '' : '(停用)'}`);
|
||||
option.value = String(region.id);
|
||||
option.selected = String(region.id) === String(selected);
|
||||
select.append(option);
|
||||
}
|
||||
}
|
||||
function lockAddressFields(editing) {
|
||||
|
||||
function lockPoolFields(editing) {
|
||||
byId('admin-vpc-pool-region').disabled = !canManage || editing;
|
||||
byId('admin-vpc-pool-cidr').disabled = !canManage || (editing && byId('admin-vpc-pool-cidr').dataset.locked === '1');
|
||||
byId('admin-vpc-pool-prefix').disabled = !canManage || (editing && byId('admin-vpc-pool-prefix').dataset.locked === '1');
|
||||
byId('admin-vpc-pool-cidr').disabled = !canManage
|
||||
|| (editing && byId('admin-vpc-pool-cidr').dataset.locked === '1');
|
||||
byId('admin-vpc-pool-prefix').disabled = !canManage
|
||||
|| (editing && byId('admin-vpc-pool-prefix').dataset.locked === '1');
|
||||
}
|
||||
function resetForm() {
|
||||
byId('admin-vpc-pool-form').reset(); byId('admin-vpc-pool-id').value = ''; byId('admin-vpc-pool-revision').value = '0'; byId('admin-vpc-pool-prefix').value = '24'; byId('admin-vpc-pool-state').value = 'active'; byId('admin-vpc-pool-title').textContent = '添加 VPC 地址池'; byId('admin-vpc-pool-capacity').textContent = '保存后显示可分配子网数量。'; delete byId('admin-vpc-pool-cidr').dataset.locked; delete byId('admin-vpc-pool-prefix').dataset.locked; state.requestKey = newRequestKey(); renderRegions(); lockAddressFields(false);
|
||||
|
||||
function resetPoolForm() {
|
||||
const form = byId('admin-vpc-pool-form');
|
||||
form.reset();
|
||||
state.poolEditingId = '';
|
||||
byId('admin-vpc-pool-id').value = '';
|
||||
byId('admin-vpc-pool-revision').value = '0';
|
||||
byId('admin-vpc-pool-prefix').value = '24';
|
||||
byId('admin-vpc-pool-state').value = 'active';
|
||||
byId('admin-vpc-pool-title').textContent = '添加 VPC 地址池';
|
||||
byId('admin-vpc-pool-capacity').textContent = '保存后显示可分配子网数量。';
|
||||
delete byId('admin-vpc-pool-cidr').dataset.locked;
|
||||
delete byId('admin-vpc-pool-prefix').dataset.locked;
|
||||
state.requestKey = newRequestKey();
|
||||
poolRegions();
|
||||
lockPoolFields(false);
|
||||
}
|
||||
|
||||
function editPool(pool) {
|
||||
byId('admin-vpc-pool-id').value = pool.id; byId('admin-vpc-pool-revision').value = pool.revision; byId('admin-vpc-pool-title').textContent = `编辑地址池 · ${pool.name}`; renderRegions(pool.region_id); byId('admin-vpc-pool-name').value = pool.name; byId('admin-vpc-pool-cidr').value = pool.cidr; byId('admin-vpc-pool-prefix').value = pool.allocation_prefix; byId('admin-vpc-pool-state').value = pool.state; byId('admin-vpc-pool-cidr').dataset.locked = pool.address_locked ? '1' : '0'; byId('admin-vpc-pool-prefix').dataset.locked = pool.address_locked ? '1' : '0'; byId('admin-vpc-pool-capacity').textContent = `${pool.used} 个已占用 · ${pool.available} 个可用 · 共 ${pool.capacity} 个 /${pool.allocation_prefix} 子网${pool.address_locked ? ';地址边界已锁定' : ''}`; lockAddressFields(true);
|
||||
}
|
||||
function renderList() {
|
||||
const list = byId('admin-vpc-pool-list'); list.replaceChildren();
|
||||
if (!state.items.length) { const empty = document.createElement('p'); empty.className = 'text-muted'; empty.textContent = '暂无 VPC 地址池。'; list.append(empty); return; }
|
||||
for (const pool of state.items) { const button = document.createElement('button'); button.type = 'button'; button.className = 'btn btn-light cloud-admin-host'; const strong = document.createElement('strong'); strong.textContent = pool.name; const detail = document.createElement('div'); detail.className = 'text-muted'; detail.textContent = `${pool.region_name} · ${pool.cidr} → /${pool.allocation_prefix} · ${pool.used}/${pool.capacity} · ${pool.state === 'active' ? '启用' : '停用'}`; button.append(strong, detail); button.addEventListener('click', () => editPool(pool)); list.append(button); }
|
||||
state.poolEditingId = String(pool.id);
|
||||
byId('admin-vpc-pool-id').value = pool.id;
|
||||
byId('admin-vpc-pool-revision').value = pool.revision;
|
||||
byId('admin-vpc-pool-title').textContent = `编辑地址池 · ${pool.name}`;
|
||||
poolRegions(pool.region_id);
|
||||
byId('admin-vpc-pool-name').value = pool.name;
|
||||
byId('admin-vpc-pool-cidr').value = pool.cidr;
|
||||
byId('admin-vpc-pool-prefix').value = pool.allocation_prefix;
|
||||
byId('admin-vpc-pool-state').value = pool.state;
|
||||
byId('admin-vpc-pool-cidr').dataset.locked = pool.address_locked ? '1' : '0';
|
||||
byId('admin-vpc-pool-prefix').dataset.locked = pool.address_locked ? '1' : '0';
|
||||
byId('admin-vpc-pool-capacity').textContent =
|
||||
`${pool.used} 个已占用 · ${pool.available} 个可用 · 共 ${pool.capacity} 个 /${pool.allocation_prefix} 子网${pool.address_locked ? ';地址边界已锁定' : ''}`;
|
||||
lockPoolFields(true);
|
||||
}
|
||||
async function load() {
|
||||
const payload = await api('/api/v1/admin/vpc-cidr-pools'); state.regions = Array.isArray(payload.regions) ? payload.regions : []; state.items = Array.isArray(payload.items) ? payload.items : []; state.featureEnabled = payload.feature_enabled === true; renderList();
|
||||
|
||||
function renderPools() {
|
||||
const list = byId('admin-vpc-pool-list');
|
||||
list.replaceChildren();
|
||||
const items = state.page.pools.items || [];
|
||||
if (!items.length) {
|
||||
list.append(create('p', 'text-muted', '暂无 VPC 地址池。'));
|
||||
return;
|
||||
}
|
||||
for (const pool of items) {
|
||||
const button = create('button', 'btn btn-light cloud-admin-host');
|
||||
button.type = 'button';
|
||||
button.dataset.poolId = String(pool.id);
|
||||
button.append(create('strong', '', pool.name),
|
||||
create('div', 'text-muted',
|
||||
`${pool.region_name} · ${pool.cidr} → /${pool.allocation_prefix} · ${pool.used}/${pool.capacity} · ${pool.state === 'active' ? '启用' : '停用'}`));
|
||||
list.append(button);
|
||||
}
|
||||
}
|
||||
function requestBody() {
|
||||
const regionId = Number(byId('admin-vpc-pool-region').value); const prefix = Number(byId('admin-vpc-pool-prefix').value); const id = byId('admin-vpc-pool-id').value;
|
||||
|
||||
function poolRequestBody() {
|
||||
const regionId = Number(byId('admin-vpc-pool-region').value);
|
||||
const prefix = Number(byId('admin-vpc-pool-prefix').value);
|
||||
const id = byId('admin-vpc-pool-id').value;
|
||||
if (!Number.isInteger(regionId) || regionId < 1) throw new Error('请选择所属地区。');
|
||||
if (!Number.isInteger(prefix) || prefix < 16 || prefix > 28) throw new Error('VPC 分配前缀必须是 16 至 28 的整数。');
|
||||
const result = { region_id: regionId, name: byId('admin-vpc-pool-name').value.trim(), cidr: byId('admin-vpc-pool-cidr').value.trim(), allocation_prefix: prefix, state: byId('admin-vpc-pool-state').value };
|
||||
if (id) result.expected_revision = Number(byId('admin-vpc-pool-revision').value); else result.request_key = state.requestKey;
|
||||
if (!Number.isInteger(prefix) || prefix < 16 || prefix > 28) {
|
||||
throw new Error('VPC 分配前缀必须是 16 至 28 的整数。');
|
||||
}
|
||||
const result = {
|
||||
region_id: regionId,
|
||||
name: byId('admin-vpc-pool-name').value.trim(),
|
||||
cidr: byId('admin-vpc-pool-cidr').value.trim(),
|
||||
allocation_prefix: prefix,
|
||||
state: byId('admin-vpc-pool-state').value,
|
||||
};
|
||||
if (id) result.expected_revision = Number(byId('admin-vpc-pool-revision').value);
|
||||
else result.request_key = state.requestKey;
|
||||
return result;
|
||||
}
|
||||
async function save(event) {
|
||||
event.preventDefault(); if (!canManage || state.busy) return; let payload; try { payload = requestBody(); } catch (error) { notice(error.message, true); return; }
|
||||
const id = byId('admin-vpc-pool-id').value; state.busy = true; byId('admin-vpc-pool-save').disabled = true; notice('正在保存 VPC 地址池…');
|
||||
try { const result = await api(`/api/v1/admin/vpc-cidr-pools${id ? '/' + encodeURIComponent(id) : ''}`, { method: id ? 'PATCH' : 'POST', body: payload }); await load(); editPool(result.item); notice(id ? 'VPC 地址池已更新。' : 'VPC 地址池已创建。'); }
|
||||
catch (error) { try { await load(); } catch {} notice(error.message, true); }
|
||||
finally { state.busy = false; byId('admin-vpc-pool-save').disabled = !canManage; }
|
||||
|
||||
async function savePool(event) {
|
||||
event.preventDefault();
|
||||
if (!canManage || state.busy) return;
|
||||
let payload;
|
||||
try { payload = poolRequestBody(); } catch (error) {
|
||||
notice(error.message, 'error');
|
||||
return;
|
||||
}
|
||||
const id = byId('admin-vpc-pool-id').value;
|
||||
state.busy = true;
|
||||
byId('admin-vpc-pool-save').disabled = true;
|
||||
notice('正在保存 VPC 地址池…', 'warning');
|
||||
try {
|
||||
const result = await api(`/api/v1/admin/vpc-cidr-pools${id ? `/${encodeURIComponent(id)}` : ''}`, {
|
||||
method: id ? 'PATCH' : 'POST', body: payload,
|
||||
});
|
||||
const refreshed = await api('/api/v1/admin/vpc-control');
|
||||
state.page = refreshed;
|
||||
renderAll();
|
||||
editPool(result.item);
|
||||
notice(id ? 'VPC 地址池已更新。' : 'VPC 地址池已创建。');
|
||||
} catch (error) {
|
||||
notice(error.message, 'error');
|
||||
} finally {
|
||||
state.busy = false;
|
||||
byId('admin-vpc-pool-save').disabled = !canManage;
|
||||
}
|
||||
}
|
||||
async function initialize() {
|
||||
|
||||
function bind() {
|
||||
for (const button of root.querySelectorAll('[data-vpc-view]')) {
|
||||
button.addEventListener('click', () => setView(button.dataset.vpcView));
|
||||
}
|
||||
for (const button of root.querySelectorAll('[data-vpc-summary-state]')) {
|
||||
button.addEventListener('click', () => openNetworkState(button.dataset.vpcSummaryState));
|
||||
}
|
||||
root.addEventListener('click', event => {
|
||||
const focus = event.target.closest('[data-vpc-network-focus]');
|
||||
if (focus) focusNetwork(focus.dataset.vpcNetworkFocus);
|
||||
const detail = event.target.closest('[data-vpc-detail]');
|
||||
if (detail) void openDetail(detail.dataset.vpcDetail);
|
||||
const pool = event.target.closest('[data-pool-id]');
|
||||
if (pool) {
|
||||
const item = state.page.pools.items.find(row => String(row.id) === pool.dataset.poolId);
|
||||
if (item) editPool(item);
|
||||
}
|
||||
});
|
||||
byId('admin-vpc-filter').addEventListener('submit', event => {
|
||||
event.preventDefault();
|
||||
void loadNetworks(filterParams(1));
|
||||
});
|
||||
byId('admin-vpc-filter-reset').addEventListener('click', () => {
|
||||
const form = byId('admin-vpc-filter');
|
||||
form.reset();
|
||||
form.elements.namedItem('region_id').value = '0';
|
||||
form.elements.namedItem('state').value = '';
|
||||
form.elements.namedItem('q').value = '';
|
||||
void loadNetworks(filterParams(1));
|
||||
});
|
||||
byId('admin-vpc-previous').addEventListener('click', () => {
|
||||
void loadNetworks(filterParams((state.page.networks.pagination?.page || 1) - 1));
|
||||
});
|
||||
byId('admin-vpc-next').addEventListener('click', () => {
|
||||
void loadNetworks(filterParams((state.page.networks.pagination?.page || 1) + 1));
|
||||
});
|
||||
for (const button of root.querySelectorAll('[data-vpc-open-state]')) {
|
||||
button.addEventListener('click', () => openNetworkState(button.dataset.vpcOpenState));
|
||||
}
|
||||
byId('admin-vpc-pool-new').addEventListener('click', resetPoolForm);
|
||||
byId('admin-vpc-pool-form').addEventListener('submit', savePool);
|
||||
byId('admin-vpc-detail-close').addEventListener('click', closeDetail);
|
||||
byId('admin-vpc-detail').addEventListener('cancel', event => {
|
||||
event.preventDefault();
|
||||
void closeDetail();
|
||||
});
|
||||
}
|
||||
|
||||
function initialize() {
|
||||
if (!root) return;
|
||||
try { const session = await api('/api/v1/session'); state.csrf = session.csrf_token || state.csrf; if (!session.admin || !state.csrf) throw new Error('管理员会话无效,请重新登录。'); await load(); resetForm(); byId('admin-vpc-pool-new').addEventListener('click', resetForm); byId('admin-vpc-pool-form').addEventListener('submit', save); notice(state.featureEnabled ? 'VPC 地址池目录已读取。用户 VPC 功能已开启。' : 'VPC 地址池目录已读取。用户 VPC 功能已关闭,可在“站点设置 → 云功能开关”中启用。'); }
|
||||
catch (error) { notice(error.message, true); }
|
||||
state.page = readBootstrap();
|
||||
renderAll();
|
||||
resetPoolForm();
|
||||
setView(state.view, false);
|
||||
bind();
|
||||
void refreshControl();
|
||||
}
|
||||
void initialize();
|
||||
|
||||
initialize();
|
||||
|
||||
@ -1,2 +1,2 @@
|
||||
{* Shared Venix CSS/JS cache key. Increment whenever a shared browser asset changes. *}
|
||||
{assign var=venix_asset_version value='2026103113' scope='global'}
|
||||
{assign var=venix_asset_version value='2026103114' scope='global'}
|
||||
|
||||
Loading…
Reference in New Issue