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(editing.value ? "编辑规则" : "新增规则")}

${ssrInterpolate(scopeApp.value || "全局默认")}
匹配条件
源语言
`); if (ed.srcAny) { _push(`
任意源语言
`); } else { _push(ssrRenderComponent(__nuxt_component_0, { modelValue: ed.srcLangs, "onUpdate:modelValue": ($event) => ed.srcLangs = $event, multiple: "" }, null, _parent)); } _push(`
${ssrInterpolate(ed.bidir ? "双向互译" : "单向翻译")}
目标语言
`); if (ed.dstAny) { _push(`
任意目标语言
`); } else { _push(ssrRenderComponent(__nuxt_component_0, { modelValue: ed.dstLangs, "onUpdate:modelValue": ($event) => ed.dstLangs = $event, multiple: "" }, null, _parent)); } _push(`
生效区域
优先级(越大越先匹配)
规则名(便于识别)
命中后使用的 Agent
翻译 Agent *
备注
`); if (curAgent.value) { _push(`
${ssrInterpolate(typeLabel(curAgent.value.type))}${ssrInterpolate(curAgent.value.description || "(无描述)")}`); if (curAgent.value.support_langs) { _push(`支持:${ssrInterpolate(curAgent.value.support_langs)}`); } else { _push(``); } if (!curAgent.value.enable) { _push(`⚠ 该 Agent 当前为停用状态`); } else { _push(``); } _push(`
`); } else { _push(``); } if (langWarn.value) { _push(`

⚠ ${ssrInterpolate(langWarn.value)}

`); } else { _push(``); } _push(`
`); if (!rules.value.length) { _push(`
🌐

当前区域还没有翻译规则

建议先加一条「任意 → 任意」的兜底规则,再往上叠精确规则

`); } else { _push(`
优先级匹配条件Agent区域操作
`); ssrRenderList(rules.value, (r, i) => { _push(`
${ssrInterpolate(r.priority)}#${ssrInterpolate(i + 1)}
${ssrInterpolate(langsLabel(r.src_langs))}${ssrInterpolate(r.bidir ? "⇄" : "→")}${ssrInterpolate(langsLabel(r.dst_langs))}
`); if (r.name || r.remark) { _push(`
${ssrInterpolate(r.name)}`); if (r.remark) { _push(` · ${ssrInterpolate(r.remark)}`); } else { _push(``); } _push(`
`); } else { _push(``); } _push(`
${ssrInterpolate(typeLabel(agentType(r.agent_id)))}${ssrInterpolate(agentName(r.agent_id))}
${ssrInterpolate(r.region === 0 ? "全部区域" : regionLabel(r.region))}
`); if (r.enable) { _push(`启用`); } else { _push(`停用`); } _push(`
`); }); _push(`
`); } _push(`

选路试算

用后端运行时同一套匹配逻辑,算一遍这个方向实际会走哪条规则。

源语言`); _push(ssrRenderComponent(__nuxt_component_0, { modelValue: testSrc.value, "onUpdate:modelValue": ($event) => testSrc.value = $event }, null, _parent)); _push(`
目标语言`); _push(ssrRenderComponent(__nuxt_component_0, { modelValue: testDst.value, "onUpdate:modelValue": ($event) => testDst.value = $event }, null, _parent)); _push(`
`); if (testResult.value) { _push(`
`); if (testResult.value.matched) { _push(`
命中规则:${ssrInterpolate(testResult.value.rule?.name || "#" + testResult.value.rule?.id)}(优先级 ${ssrInterpolate(testResult.value.rule?.priority)})
${ssrInterpolate(langsLabel(testResult.value.rule?.src_langs))} ${ssrInterpolate(testResult.value.rule?.bidir ? "⇄" : "→")} ${ssrInterpolate(langsLabel(testResult.value.rule?.dst_langs))} · Agent:${ssrInterpolate(testResult.value.agent?.name || testResult.value.rule?.agent_id)} `); if (testResult.value.agent) { _push(`(${ssrInterpolate(typeLabel(testResult.value.agent.type))})`); } else { _push(``); } _push(`
`); } else { _push(`
没有任何规则命中 —— 这个方向的通话翻译会不可用,建议补一条兜底规则。
`); } _push(`
`); } else { _push(``); } _push(`

同步到其他区域

${ssrInterpolate(syncDesc.value)}

✦ 同步内容:语言条件、Agent、优先级、启停状态一并复制到目标区域。
选择目标区域
`); ssrRenderList(syncRegions.value, (r) => { _push(``); }); _push(`

⚠ 目标区域已有「同 Agent + 同语言条件」的规则则覆盖,否则新建。

`); }; } }); const _sfc_setup = _sfc_main.setup; _sfc_main.setup = (props, ctx) => { const ssrContext = useSSRContext(); (ssrContext.modules || (ssrContext.modules = /* @__PURE__ */ new Set())).add("pages/calltranslate.vue"); return _sfc_setup ? _sfc_setup(props, ctx) : void 0; }; const calltranslate = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-c0bab860"]]); export { calltranslate as default }; //# sourceMappingURL=calltranslate-D-FgQw8P.mjs.map