feat(experiments): 拆分实验类型测试方案与用户管理入口

- 实验类型:新增独立创建、数据格式、默认值、调用示例和接入验收页

- 测试方案:按类型编辑 A/B 返回值,统一百分比并保留生命周期和效果审计

- 用户管理:新增分页查人、方案分组预览、人工指定和恢复自动分组

- 文档:同步菜单与组件职责,移除固定业务接入点场景弹窗
This commit is contained in:
湛兮
2026-10-27 11:40:28 +08:00
parent 043e6d0e36
commit db3fd9bee1
9 changed files with 1189 additions and 458 deletions
+97
View File
@@ -0,0 +1,97 @@
<script setup lang="ts">
/** 类型化返回值编辑器,不执行输入内容,JSON语法错误显式阻止保存。 */
import { ref, watch } from "vue";
const props = withDefaults(
defineProps<{
modelValue: unknown;
kind: "string" | "number" | "boolean" | "json";
disabled?: boolean;
options?: Array<{ label: string; value: string }>;
}>(),
{ disabled: false, options: undefined }
);
const emit = defineEmits<{
"update:modelValue": [value: unknown];
valid: [value: boolean];
}>();
const raw = ref(JSON.stringify(props.modelValue, null, 2) ?? "null"),
error = ref("");
watch(
() => props.modelValue,
value => {
let current: unknown;
try {
current = JSON.parse(raw.value);
} catch {
current = undefined;
}
if (JSON.stringify(value) !== JSON.stringify(current))
raw.value = JSON.stringify(value, null, 2) ?? "null";
}
);
function jsonInput(value: string) {
raw.value = value;
try {
const parsed = JSON.parse(value);
error.value = "";
emit("update:modelValue", parsed);
emit("valid", true);
} catch {
error.value = "请输入有效 JSON,字符串需加双引号";
emit("valid", false);
}
}
</script>
<template>
<el-select
v-if="options"
:model-value="modelValue as string"
:disabled="disabled"
@update:model-value="v => emit('update:modelValue', v)"
><el-option
v-for="o in options"
:key="o.value"
:label="o.label"
:value="o.value"
/></el-select>
<el-switch
v-else-if="kind === 'boolean'"
:model-value="Boolean(modelValue)"
:disabled="disabled"
active-text="开启"
inactive-text="关闭"
@update:model-value="v => emit('update:modelValue', v)"
/>
<el-input-number
v-else-if="kind === 'number'"
:model-value="typeof modelValue === 'number' ? modelValue : 0"
:disabled="disabled"
@update:model-value="v => emit('update:modelValue', v ?? 0)"
/>
<el-input
v-else-if="kind === 'string'"
:model-value="String(modelValue ?? '')"
maxlength="12000"
:disabled="disabled"
@update:model-value="v => emit('update:modelValue', v)"
/>
<div v-else class="json-value">
<el-input
:model-value="raw"
type="textarea"
:rows="5"
:disabled="disabled"
@update:model-value="jsonInput"
/><small v-if="error" role="alert">{{ error }}</small>
</div>
</template>
<style scoped>
.el-select,
.json-value {
width: 100%;
}
.json-value small {
color: var(--el-color-danger);
}
</style>