diff --git a/README.md b/README.md index 77dc6fb..b031ec0 100644 --- a/README.md +++ b/README.md @@ -218,3 +218,5 @@ pnpm build 管理端站内封面从 H5/Web 域名读取,可通过 `VITE_ROLE_USER_BASE_URL` 覆盖;默认按本地、develop、production 环境分别选择 localhost:3210、dev.mrzhan.top、mrzhan.top。 标签页图标采用 `public/stellar-icon-v2.svg`,同时提供多尺寸 `favicon.ico`、180/192/512 PNG,覆盖浏览器、Apple 主屏幕和 PWA。版本化资源路径用于刷新旧图标缓存。 + +实验场景通过后台「账号实验中心 → 管理实验场景」创建和启停,系统预置项标注来源;新增场景复用已实现的整站 UI 或对话接入点,同一接入点的运行/暂停实验互斥。比例统一按百分比输入,50代表50%,保留0.01%精度;接口内部整数精度不变,既有分组不重算。 diff --git a/src/api/access.ts b/src/api/access.ts index fdba03d..35ea2de 100644 --- a/src/api/access.ts +++ b/src/api/access.ts @@ -1158,7 +1158,9 @@ export type Entry = { export type Experiment = { id: string; name: string; - scope: "ui" | "chat"; + scope: string; + runtime?: "ui" | "chat"; + sceneName?: string; state: "draft" | "running" | "paused" | "finished"; revision?: number; config: { @@ -1174,3 +1176,14 @@ export type Experiment = { description: string; }; }; + +/** 实验场景与应用接入点映射。 */ +export type ExperimentScene = { + id: string; + name: string; + runtime: "ui" | "chat"; + description: string; + enabled: number; + builtin: number; + revision: number; +}; diff --git a/src/views/digital/experiments.vue b/src/views/digital/experiments.vue index b04e852..0b764c9 100644 --- a/src/views/digital/experiments.vue +++ b/src/views/digital/experiments.vue @@ -2,7 +2,13 @@ /** 账号实验中心:完整生命周期、指定用户、解释和审计均在后台完成。 */ import { computed, onMounted, ref } from "vue"; import { ElMessage, ElMessageBox } from "element-plus"; -import { digital, type Content, type Experiment } from "@/api/access"; +import SceneManager from "./scene-manager.vue"; +import { + digital, + type Content, + type Experiment, + type ExperimentScene +} from "@/api/access"; type Account = { account: string; name: string; createdAt: string }; type Details = { assignments: Array<{ @@ -40,6 +46,8 @@ type Details = { createdAt: string; }>; }; +const scenes = ref([]), + sceneManager = ref(false); const list = ref([]), accounts = ref([]), presets = ref([]), @@ -97,14 +105,35 @@ const stats = computed(() => ({ draft: list.value.filter(e => e.state === "draft").length, finished: list.value.filter(e => e.state === "finished").length })); +/** 页面以百分比编辑,接口保留整数精度,50%对应5000。 */ +const trafficPercent = computed({ + get: () => (edit.value?.config.traffic ?? 0) / 100, + set: (value: number | undefined) => { + if (edit.value) edit.value.config.traffic = Math.round((value ?? 0) * 100); + } +}); +const weightBPercent = computed({ + get: () => (edit.value?.config.weightB ?? 0) / 100, + set: (value: number | undefined) => { + if (edit.value) edit.value.config.weightB = Math.round((value ?? 0) * 100); + } +}); +const editingRuntime = computed( + () => scenes.value.find(s => s.id === edit.value?.scope)?.runtime +); +function sceneName(id: string) { + return scenes.value.find(s => s.id === id)?.name ?? id; +} async function load() { loading.value = true; try { - const [experiments, users, content] = await Promise.all([ + const [experiments, users, content, registered] = await Promise.all([ digital("experiments"), digital("accounts"), - digital("content") + digital("content"), + digital("scenes") ]); + scenes.value = registered; list.value = experiments; accounts.value = users; presets.value = content.filter( @@ -122,7 +151,7 @@ function open(item?: Experiment) { : { id: crypto.randomUUID(), name: "", - scope: "ui", + scope: scenes.value.find(s => s.enabled)?.id ?? "", state: "draft", config: { audience: "all", @@ -136,6 +165,7 @@ function open(item?: Experiment) { editor.value = true; } async function save() { + if (!edit.value?.scope) return ElMessage.warning("请先创建或选择实验场景"); if (!edit.value?.name.trim()) return ElMessage.warning("请输入实验名称"); if ( ["new", "existing"].includes(edit.value.config.audience) && @@ -276,7 +306,10 @@ onMounted(load);

账号实验中心

稳定的登录账号分流。前台消费结果,后台掌控完整实验流程。

- 创建实验 +
+ 管理实验场景创建实验 +
{{ row.config.description }}

{{ row.id }} +