import { defineComponent, ref, reactive, computed, useSSRContext } from 'vue'; import { ssrRenderAttrs, ssrIncludeBooleanAttr, ssrLooseContain, ssrLooseEqual, ssrRenderList, ssrRenderAttr, ssrInterpolate, ssrRenderStyle, ssrRenderComponent, ssrRenderClass } from 'vue/server-renderer'; import { u as useApi } from './useApi-B-E5eLsI.mjs'; import { u as useToast } from './useToast-CS21XT61.mjs'; import { l as langName } from './useLangOptions-DMhiAuTa.mjs'; import { _ as __nuxt_component_0 } from './LangSelect-C_QPlcDf.mjs'; import { _ as _export_sfc } from './server.mjs'; import './useLoading-D4zrSa2m.mjs'; 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 'pinia'; import 'perfect-debounce'; const LANG_ANY = "*"; const _sfc_main = /* @__PURE__ */ defineComponent({ __name: "calltranslate", __ssrInlineRender: true, setup(__props) { const REGIONS = [ { value: 1, label: "中国" }, { value: 2, label: "美国" }, { value: 3, label: "东亚" }, { value: 4, label: "东南亚" }, { value: 5, label: "南亚" }, { value: 6, label: "中东" }, { value: 7, label: "欧洲" }, { value: 8, label: "俄罗斯" }, { value: 9, label: "非洲" }, { value: 10, label: "南美" }, { value: 11, label: "北美" }, { value: 12, label: "大洋洲" }, { value: 13, label: "巴西" }, { value: 14, label: "印度" } ]; function regionLabel(v) { return REGIONS.find((x) => x.value === v)?.label ?? "区域" + v; } const TRANS_TYPES = { translate: { label: "🧩 三段式翻译", color: "#059669", bg: "#dcfce7" }, "ast-translate": { label: "🚀 端到端翻译", color: "#c2410c", bg: "#fff7ed" } }; function typeLabel(t) { return t && TRANS_TYPES[t] ? TRANS_TYPES[t].label : t || "未知"; } function typeStyle(t) { const s = t ? TRANS_TYPES[t] : void 0; return s ? { background: s.bg, color: s.color } : { background: "#f1f5f9", color: "#64748b" }; } useApi(); useToast(); const scopeApp = ref(""); const scopeApps = ref([]); const curRegion = ref(REGIONS[0].value); const rules = ref([]); const agents = ref([]); const editorOpen = ref(false); const editing = ref(null); ref(null); ref(0); const ed = reactive({ name: "", srcLangs: "", dstLangs: "", srcAny: false, dstAny: false, bidir: true, region: 0, priority: 100, agentId: "", remark: "", enable: true }); const transAgents = computed(() => agents.value.filter((a) => a.type in TRANS_TYPES)); const agentGroups = computed( () => Object.keys(TRANS_TYPES).map((t) => ({ type: t, label: TRANS_TYPES[t].label, items: transAgents.value.filter((a) => a.type === t) })).filter((g) => g.items.length) ); const curAgent = computed(() => agents.value.find((a) => a.id === ed.agentId) || null); const langWarn = computed(() => { const a = curAgent.value; if (!a || !a.support_langs) return ""; const sup = a.support_langs.split(",").map((x) => x.trim()).filter(Boolean); if (!sup.length) return ""; const picked = [ ...ed.srcAny ? [] : ed.srcLangs.split(","), ...ed.dstAny ? [] : ed.dstLangs.split(",") ].map((x) => x.trim()).filter(Boolean); const miss = picked.filter((c) => !sup.includes(c)); if (!miss.length) return ""; return `Agent「${a.name || a.id}」未声明支持:${miss.join("、")}`; }); function isAny(s) { return (s || "").trim() === LANG_ANY; } function langsLabel(s) { if (isAny(s)) return "任意语言"; const arr = (s || "").split(",").map((x) => x.trim()).filter(Boolean); if (!arr.length) return "—"; if (arr.length <= 3) return arr.map((c) => langName(c)).join("、"); return arr.slice(0, 3).map((c) => langName(c)).join("、") + ` 等 ${arr.length} 种`; } function agentName(id) { return agents.value.find((a) => a.id === id)?.name || id || "未配置"; } function agentType(id) { return agents.value.find((a) => a.id === id)?.type || ""; } const syncOpen = ref(false); const syncDesc = ref(""); const syncTargets = ref([]); const syncRegions = computed(() => REGIONS.filter((r) => r.value !== ed.region)); const testOpen = ref(false); const testSrc = ref("zh-CN"); const testDst = ref("en-US"); const testResult = ref(null); return (_ctx, _push, _parent, _attrs) => { _push(`
一条规则覆盖「多源语言 × 多目标语言」,命中后走它指定的 Agent。多条规则按优先级从高到低匹配,第一条命中的生效。
⚠ ${ssrInterpolate(langWarn.value)}
`); } else { _push(``); } _push(`当前区域还没有翻译规则
建议先加一条「任意 → 任意」的兜底规则,再往上叠精确规则