feat(experiments): 场景管理与百分比配置 #5
@@ -46,6 +46,7 @@ type Details = {
|
||||
createdAt: string;
|
||||
}>;
|
||||
};
|
||||
const guideVisible = ref(false);
|
||||
const scenes = ref<ExperimentScene[]>([]),
|
||||
sceneManager = ref(false);
|
||||
const list = ref<Experiment[]>([]),
|
||||
@@ -151,7 +152,11 @@ function open(item?: Experiment) {
|
||||
: {
|
||||
id: crypto.randomUUID(),
|
||||
name: "",
|
||||
scope: scenes.value.find(s => s.enabled)?.id ?? "",
|
||||
scope:
|
||||
(
|
||||
scenes.value.find(s => s.enabled && s.runtime === "ui") ??
|
||||
scenes.value.find(s => s.enabled)
|
||||
)?.id ?? "",
|
||||
state: "draft",
|
||||
config: {
|
||||
audience: "all",
|
||||
@@ -164,6 +169,23 @@ function open(item?: Experiment) {
|
||||
};
|
||||
editor.value = true;
|
||||
}
|
||||
function createTrial() {
|
||||
open();
|
||||
if (!edit.value) return;
|
||||
edit.value.name = "新老 UI 验收";
|
||||
edit.value.scope =
|
||||
(
|
||||
scenes.value.find(s => s.id === "ui" && s.enabled) ??
|
||||
scenes.value.find(s => s.runtime === "ui" && s.enabled)
|
||||
)?.id ?? "";
|
||||
edit.value.config.audience = "specified";
|
||||
edit.value.config.accounts = [];
|
||||
edit.value.config.traffic = 10000;
|
||||
edit.value.config.weightB = 10000;
|
||||
edit.value.config.description =
|
||||
"只选择自己的账号,启动后先验证新版;在指定用户中切换A/B对照。结束时保留A可维持原界面,再另建正式实验。";
|
||||
guideVisible.value = false;
|
||||
}
|
||||
async function save() {
|
||||
if (!edit.value?.scope) return ElMessage.warning("请先创建或选择实验场景");
|
||||
if (!edit.value?.name.trim()) return ElMessage.warning("请输入实验名称");
|
||||
@@ -172,6 +194,11 @@ async function save() {
|
||||
!edit.value.config.cutoff
|
||||
)
|
||||
return ElMessage.warning("请选择注册时间分界");
|
||||
if (
|
||||
edit.value.config.audience === "specified" &&
|
||||
!edit.value.config.accounts.length
|
||||
)
|
||||
return ElMessage.warning("请选择至少一个入组账号,验收时先选择自己");
|
||||
saving.value = true;
|
||||
try {
|
||||
await digital(`experiments/${edit.value.id}`, "put", edit.value);
|
||||
@@ -307,10 +334,17 @@ onMounted(load);
|
||||
<p>稳定的登录账号分流。前台消费结果,后台掌控完整实验流程。</p>
|
||||
</div>
|
||||
<div>
|
||||
<el-button @click="sceneManager = true">管理实验场景</el-button
|
||||
<el-button @click="guideVisible = true">操作指南</el-button
|
||||
><el-button @click="sceneManager = true">管理实验场景</el-button
|
||||
><el-button type="primary" @click="open()">创建实验</el-button>
|
||||
</div>
|
||||
</div>
|
||||
<el-alert
|
||||
title="第一次使用:先点「操作指南」,按“仅自己验收 → 正式实验 → 保留最终方案”走一遍。保存草稿不会改变前台,启动后才生效。"
|
||||
type="info"
|
||||
:closable="false"
|
||||
style="margin-bottom: 16px"
|
||||
/>
|
||||
<div class="stats">
|
||||
<el-card shadow="never"
|
||||
><strong>{{ stats.running }}</strong
|
||||
@@ -742,10 +776,81 @@ onMounted(load);
|
||||
></template
|
||||
></el-dialog
|
||||
>
|
||||
<el-dialog
|
||||
v-model="guideVisible"
|
||||
title="实验全流程操作指南"
|
||||
width="min(760px,95vw)"
|
||||
><ol class="workflow-guide">
|
||||
<li>
|
||||
<strong>创建场景:测什么</strong>
|
||||
<p>
|
||||
点击「管理实验场景 →
|
||||
新建场景」,填写名称并选择已接入的功能。预置“新老
|
||||
UI”“对话风格”可以直接使用,不必重复创建。
|
||||
</p>
|
||||
</li>
|
||||
<li>
|
||||
<strong>先只让自己验收</strong>
|
||||
<p>
|
||||
创建实验,选择新老 UI
|
||||
场景;人群选「指定名单」并选择自己的账号,实验流量填100%,B组填100%。保存后还是草稿,不生效。
|
||||
</p>
|
||||
</li>
|
||||
<li>
|
||||
<strong>启动并去前台看效果</strong>
|
||||
<p>
|
||||
在列表点击「启动」,再登录前台并刷新。B是现代深色粉,A是经典深色金。仅你的账号入组,其他人使用默认方案。
|
||||
</p>
|
||||
</li>
|
||||
<li>
|
||||
<strong>对照 A/B 并解释分组</strong>
|
||||
<p>
|
||||
点击「管理 / 明细 →
|
||||
指定用户」,给自己指定A或B并保存;刷新前台查看。通过「分组解释」查实际方案与原因。指定记录有有效期,移除后恢复原分组。
|
||||
</p>
|
||||
</li>
|
||||
<li>
|
||||
<strong>创建正式实验并看指标</strong>
|
||||
<p>
|
||||
验收结束时保留A可维持原界面,再创建正式实验:人群选目标用户,流量100%、B组50%,就是入组用户A/B各一半。启动后在「效果概览」看曝光和聊天漏斗。规则启动后冻结,需要新规则时另建实验。
|
||||
</p>
|
||||
</li>
|
||||
<li>
|
||||
<strong>暂停或结束</strong>
|
||||
<p>
|
||||
暂停时用户回默认方案,恢复后继续原分组;结束时选择最终A/B方案,会应用于所有用户,不能重新启动。确认要正式推广后再结束并保留新版。
|
||||
</p>
|
||||
</li>
|
||||
</ol>
|
||||
<el-alert
|
||||
title="对话风格实验流程相同,只需额外选择A/B两组叙事预设。实验、指定用户和场景管理都在后台操作,前台没有实验开关。"
|
||||
:closable="false"
|
||||
/><template #footer
|
||||
><el-button @click="guideVisible = false">知道了</el-button
|
||||
><el-button type="primary" @click="createTrial"
|
||||
>按“仅自己验收”示例创建</el-button
|
||||
></template
|
||||
></el-dialog
|
||||
>
|
||||
<SceneManager v-model="sceneManager" :scenes="scenes" @saved="load" />
|
||||
</div>
|
||||
</template>
|
||||
<style scoped>
|
||||
.workflow-guide {
|
||||
padding-left: 22px;
|
||||
line-height: 1.8;
|
||||
}
|
||||
|
||||
.workflow-guide li {
|
||||
margin-bottom: 16px;
|
||||
}
|
||||
|
||||
.workflow-guide p {
|
||||
margin: 6px 0;
|
||||
font-size: 13px;
|
||||
color: var(--el-text-color-secondary);
|
||||
}
|
||||
|
||||
.heading {
|
||||
display: flex;
|
||||
gap: 15px;
|
||||
|
||||
Reference in New Issue
Block a user