import { defineComponent, ref, reactive, computed, useSSRContext } from 'vue'; import { ssrRenderAttrs, ssrRenderStyle, ssrRenderList, ssrRenderClass, ssrInterpolate, ssrIncludeBooleanAttr, ssrRenderAttr, ssrLooseContain, ssrLooseEqual } from 'vue/server-renderer'; import { u as useApi } from './useApi-B6h53Mkt.mjs'; import { u as useToast } from './useToast-C76a6bSX.mjs'; import { u as useAuthStore } from './auth-QFkCoU1C.mjs'; import { _ as _export_sfc, b as useRouter } from './server.mjs'; import './useLoading-D6mc40Wj.mjs'; import './state-DQnwRar-.mjs'; import 'pinia'; import '../nitro/nitro.mjs'; import 'node:http'; import 'node:https'; import 'node:events'; import 'node:buffer'; import 'node:fs'; import 'node:path'; import 'node:crypto'; import 'node:url'; import '../routes/renderer.mjs'; import 'vue-bundle-renderer/runtime'; import 'unhead/server'; import 'devalue'; import 'unhead/utils'; import 'perfect-debounce'; const ORPHAN_KEY = "__orphan__"; const _sfc_main = /* @__PURE__ */ defineComponent({ __name: "apps", __ssrInlineRender: true, setup(__props) { useApi(); useToast(); useAuthStore(); useRouter(); const view = ref("list"); const products = ref([]); const apps2 = ref([]); const envs = ref([]); const loading = ref(false); const envSavingId = ref(0); const expanded = reactive({}); const regionOptions = ["中国", "美国", "东亚", "东南亚", "南亚", "中东", "欧洲", "俄罗斯", "非洲", "南美", "北美", "大洋洲", "巴西", "印度"]; const groups = computed(() => { const byName = /* @__PURE__ */ new Map(); for (const d of apps2.value) { const name = d.app_name || ""; if (!byName.has(name)) byName.set(name, []); byName.get(name).push(d); } const known = new Set(products.value.map((p) => p.name)); const res = products.value.map((p) => ({ key: p.name, product: p, deployments: byName.get(p.name) || [] })); const orphan = []; for (const [name, ds] of byName) { if (name === "" || !known.has(name)) orphan.push(...ds); } if (orphan.length) res.push({ key: ORPHAN_KEY, product: null, deployments: orphan }); return res; }); function isExpanded(key) { return expanded[key] !== false; } function dbName(dsn) { const m = (dsn || "").match(/\/([^/?]+)\?/); return m ? m[1] : "-"; } const pIsEditing = ref(false); const pForm = reactive({ id: 0, name: "", image_name: "", remark: "", enabled: true }); const dIsEditing = ref(false); const dMode = ref("existing"); const dForm = reactive({ id: 0, app_name: "", name: "", region: "", env_id: 0, base_url: "", service_dsn: "", deploy_dir: "", image_name: "", image_tag: "", remark: "", enabled: true }); const availableRegions = computed(() => { const used = new Set( apps2.value.filter((d) => d.app_name === dForm.app_name && d.id !== dForm.id).map((d) => d.region).filter(Boolean) ); return regionOptions.filter((r) => !used.has(r)); }); const testPassed = ref(false); const testing = ref(false); const testResult = reactive({ show: false, apiOk: false, apiMsg: "", dbOk: false, dbMsg: "" }); ref(null); const az = reactive({ appId: 0, appLabel: "", start: "", end: "", resultShow: false, resultClass: "", mode: "", steps: [], curIndex: 0, curTotal: 0, curName: "", pct: 0, errMsg: "", report: null, running: false, btnText: "开始分析" }); ref(null); ref(null); const up = reactive({ id: 0, label: "", envName: "", deployDir: "", tag: "", log: "", show: false, running: false, ok: false, canRun: false, btnText: "开始升级" }); return (_ctx, _push, _parent, _attrs) => { _push(`
应用 是一个产品(如 Voitrans);其下挂多条 部署(各区域一份)。 卡片 = 应用;卡片内表格 = 该应用的区域部署。
${ssrInterpolate(g.product ? g.product.remark || "—" : "未填所属应用名、或应用已删除的历史部署;编辑部署可归位到某个应用")}
| 部署 | 区域 | 环境 | 状态 | 业务库 | 启用 | 操作 |
|---|---|---|---|---|---|---|
| 部署${ssrInterpolate(a.name || "部署#" + a.id)}#${ssrInterpolate(a.id)} | ${ssrInterpolate(a.region || "—")} | `); if (a.status === "pending") { _push(`待部署`); } else { _push(`已接入`); } _push(` | ${ssrInterpolate(dbName(a.service_dsn))} | `); if (a.enabled) { _push(`是`); } else { _push(`否`); } _push(` | `);
if (a.status !== "pending") {
_push(``);
} else {
_push(``);
}
_push(` |