feat(growth): 增长工作台可视化数据看板 #30
@@ -287,3 +287,7 @@ pnpm build
|
|||||||
页面集中展示严格顺序漏斗、成熟队列次日活跃、推荐曝光与有效开聊、分配比例诊断、首字时延和反馈原因、字符预算及最近100笔额度流水。无样本显示暂无样本;超过事件边界会显示截断提示,不注入演示数据,不自动宣称实验显著性。
|
页面集中展示严格顺序漏斗、成熟队列次日活跃、推荐曝光与有效开聊、分配比例诊断、首字时延和反馈原因、字符预算及最近100笔额度流水。无样本显示暂无样本;超过事件边界会显示截断提示,不注入演示数据,不自动宣称实验显著性。
|
||||||
|
|
||||||
运营可配置免费/游客/会员限额、全站字符预算、生成开关、独立推荐实验及探索比例;变更实验参数必须增加版本。会员赠送/撤销需要理由、确认与绑定参数的幂等请求号,是运营权益操作,不创建支付订单或收款。站内活动支持新用户/活跃/沉默分群、时间窗、对照组和频控,仅站内展示,不发送短信、邮件或企微。保存策略和活动均校验版本,失败时保留输入供处理。
|
运营可配置免费/游客/会员限额、全站字符预算、生成开关、独立推荐实验及探索比例;变更实验参数必须增加版本。会员赠送/撤销需要理由、确认与绑定参数的幂等请求号,是运营权益操作,不创建支付订单或收款。站内活动支持新用户/活跃/沉默分群、时间窗、对照组和频控,仅站内展示,不发送短信、邮件或企微。保存策略和活动均校验版本,失败时保留输入供处理。
|
||||||
|
|
||||||
|
### 增长数据可视化
|
||||||
|
|
||||||
|
`src/views/digital/growth-charts.vue` 为增长工作台提供指标卡、严格顺序转化、成熟队列次留、推荐实验转化与最近14个记账日字符预算图表。数据来自真实聚合接口,空样本单独展示;有输出结算包括中止后已产生输出的请求,不等同完整回复。保留对应数据明细,图表随容器尺寸变化并在卸载时释放。
|
||||||
|
|||||||
@@ -0,0 +1,387 @@
|
|||||||
|
<script setup lang="ts">
|
||||||
|
/** 增长可视化:真实聚合数据驱动图表;空样本、队列口径和成本估算边界保持可见。 */
|
||||||
|
import {
|
||||||
|
computed,
|
||||||
|
nextTick,
|
||||||
|
onBeforeUnmount,
|
||||||
|
onMounted,
|
||||||
|
ref,
|
||||||
|
watch
|
||||||
|
} from "vue";
|
||||||
|
import echarts from "@/plugins/echarts";
|
||||||
|
import type { EChartsCoreOption, EChartsType } from "echarts/core";
|
||||||
|
type Row = Record<string, string | number | boolean | null>;
|
||||||
|
const props = defineProps<{
|
||||||
|
overview: {
|
||||||
|
funnel: { stage: string; users: number }[];
|
||||||
|
quality: Row[];
|
||||||
|
retention: Row[];
|
||||||
|
budget: Row[];
|
||||||
|
experiments: Row[];
|
||||||
|
feedback: Row[];
|
||||||
|
};
|
||||||
|
}>();
|
||||||
|
const root = ref<HTMLElement>();
|
||||||
|
const titles = [
|
||||||
|
"用户转化路径",
|
||||||
|
"成熟队列 · 次日留存",
|
||||||
|
"推荐实验 · 转化对比",
|
||||||
|
"字符消耗 · 最近14个记账日"
|
||||||
|
];
|
||||||
|
const subtitles = [
|
||||||
|
"严格顺序去重用户 · 悬停查看人数",
|
||||||
|
"按首次访问日期 · 未成熟队列不纳入",
|
||||||
|
"按版本与排序组展示 · 不代表统计显著",
|
||||||
|
"已结算与预占 · 字符估算,非供应商账单"
|
||||||
|
];
|
||||||
|
const names = [
|
||||||
|
"访问",
|
||||||
|
"角色详情",
|
||||||
|
"开始故事",
|
||||||
|
"发送请求",
|
||||||
|
"完整回复",
|
||||||
|
"有效对话"
|
||||||
|
];
|
||||||
|
const total = (key: string) =>
|
||||||
|
props.overview.quality.reduce((sum, row) => sum + Number(row[key] ?? 0), 0);
|
||||||
|
const percent = (a: number, b: number) =>
|
||||||
|
b > 0 ? `${((a / b) * 100).toFixed(1)}%` : "暂无样本";
|
||||||
|
const metrics = computed(() => {
|
||||||
|
const f = props.overview.funnel;
|
||||||
|
const cohorts = props.overview.retention;
|
||||||
|
const requests = total("requests");
|
||||||
|
return [
|
||||||
|
{
|
||||||
|
label: "访问用户",
|
||||||
|
value: f[0]?.users ?? 0,
|
||||||
|
note: "所选周期 · 顺序漏斗入口"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: "有效对话用户",
|
||||||
|
value: f.at(-1)?.users ?? 0,
|
||||||
|
note: `访问转化 ${percent(f.at(-1)?.users ?? 0, f[0]?.users ?? 0)}`
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: "有输出结算率",
|
||||||
|
value: percent(total("consumed"), requests),
|
||||||
|
note: `${requests.toLocaleString()} 次请求 · 含失败、中止与预占`
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: "成熟队列次留",
|
||||||
|
value: percent(
|
||||||
|
cohorts.reduce((n, r) => n + Number(r.returned), 0),
|
||||||
|
cohorts.reduce((n, r) => n + Number(r.users), 0)
|
||||||
|
),
|
||||||
|
note: "成熟队列用户加权 · 非每日比率平均"
|
||||||
|
}
|
||||||
|
];
|
||||||
|
});
|
||||||
|
const charts: EChartsType[] = [];
|
||||||
|
let observer: ResizeObserver | undefined;
|
||||||
|
const empty = computed(() => [
|
||||||
|
!props.overview.funnel.some(r => r.users > 0),
|
||||||
|
!props.overview.retention.length,
|
||||||
|
!props.overview.experiments.some(r => Number(r.exposedUsers) > 0),
|
||||||
|
!props.overview.budget.length
|
||||||
|
]);
|
||||||
|
/** 只对存在分母的实验与留存绘制百分比,零曝光以空点呈现。 */
|
||||||
|
function options(): EChartsCoreOption[] {
|
||||||
|
const color = ["#6366f1", "#2bb8a5", "#f6ad55"];
|
||||||
|
const base = {
|
||||||
|
color,
|
||||||
|
backgroundColor: "transparent",
|
||||||
|
textStyle: { color: "#8892a3", fontFamily: "inherit" },
|
||||||
|
tooltip: { trigger: "axis", confine: true },
|
||||||
|
grid: { top: 40, left: 16, right: 24, bottom: 20, containLabel: true },
|
||||||
|
xAxis: {
|
||||||
|
type: "category",
|
||||||
|
axisTick: { show: false },
|
||||||
|
axisLine: { show: false }
|
||||||
|
},
|
||||||
|
yAxis: {
|
||||||
|
type: "value",
|
||||||
|
splitLine: { lineStyle: { color: "#94a3b822", type: "dashed" } }
|
||||||
|
}
|
||||||
|
};
|
||||||
|
const retention = props.overview.retention;
|
||||||
|
const experiments = props.overview.experiments;
|
||||||
|
const budget = [...props.overview.budget].sort((a, b) =>
|
||||||
|
String(a.period).localeCompare(String(b.period))
|
||||||
|
);
|
||||||
|
const ratio = (a: unknown, b: unknown) =>
|
||||||
|
Number(b) > 0 ? Number(((Number(a) / Number(b)) * 100).toFixed(2)) : null;
|
||||||
|
return [
|
||||||
|
{
|
||||||
|
...base,
|
||||||
|
xAxis: { ...base.yAxis, minInterval: 1 },
|
||||||
|
yAxis: { ...base.xAxis, inverse: true, data: names },
|
||||||
|
series: [
|
||||||
|
{
|
||||||
|
type: "bar",
|
||||||
|
barMaxWidth: 24,
|
||||||
|
data: props.overview.funnel.map((r, i) => ({
|
||||||
|
value: r.users,
|
||||||
|
itemStyle: {
|
||||||
|
color: [
|
||||||
|
"#6366f1",
|
||||||
|
"#7c7ff2",
|
||||||
|
"#9396f5",
|
||||||
|
"#2bb8a5",
|
||||||
|
"#56c8b9",
|
||||||
|
"#83d8cd"
|
||||||
|
][i],
|
||||||
|
borderRadius: [0, 6, 6, 0]
|
||||||
|
}
|
||||||
|
})),
|
||||||
|
label: { show: true, position: "right", color: "#8892a3" }
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
...base,
|
||||||
|
xAxis: { ...base.xAxis, data: retention.map(r => String(r.cohort)) },
|
||||||
|
yAxis: {
|
||||||
|
...base.yAxis,
|
||||||
|
min: 0,
|
||||||
|
max: 100,
|
||||||
|
axisLabel: { formatter: "{value}%" }
|
||||||
|
},
|
||||||
|
series: [
|
||||||
|
{
|
||||||
|
type: "line",
|
||||||
|
smooth: false,
|
||||||
|
symbolSize: 8,
|
||||||
|
connectNulls: false,
|
||||||
|
areaStyle: { opacity: 0.08 },
|
||||||
|
data: retention.map(r => ratio(r.returned, r.users))
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
...base,
|
||||||
|
legend: { textStyle: { color: "#8892a3" } },
|
||||||
|
xAxis: {
|
||||||
|
...base.xAxis,
|
||||||
|
data: experiments.map(r => `v${r.revision} · ${r.variant}`)
|
||||||
|
},
|
||||||
|
yAxis: {
|
||||||
|
...base.yAxis,
|
||||||
|
min: 0,
|
||||||
|
max: 100,
|
||||||
|
axisLabel: { formatter: "{value}%" }
|
||||||
|
},
|
||||||
|
series: [
|
||||||
|
["详情点击", "clickUsers"],
|
||||||
|
["开始故事", "startUsers"],
|
||||||
|
["有效对话", "activatedUsers"]
|
||||||
|
].map(([name, key]) => ({
|
||||||
|
name,
|
||||||
|
type: "bar",
|
||||||
|
barMaxWidth: 22,
|
||||||
|
itemStyle: { borderRadius: [4, 4, 0, 0] },
|
||||||
|
data: experiments.map(r => ratio(r[key], r.exposedUsers))
|
||||||
|
}))
|
||||||
|
},
|
||||||
|
{
|
||||||
|
...base,
|
||||||
|
legend: { textStyle: { color: "#8892a3" } },
|
||||||
|
xAxis: { ...base.xAxis, data: budget.map(r => String(r.period)) },
|
||||||
|
series: [
|
||||||
|
["已结算", "used"],
|
||||||
|
["预占", "reserved"]
|
||||||
|
].map(([name, key]) => ({
|
||||||
|
name,
|
||||||
|
type: "bar",
|
||||||
|
stack: "budget",
|
||||||
|
barMaxWidth: 30,
|
||||||
|
data: budget.map(r => Number(r[key]))
|
||||||
|
}))
|
||||||
|
}
|
||||||
|
];
|
||||||
|
}
|
||||||
|
function render() {
|
||||||
|
options().forEach((option, i) => charts[i]?.setOption(option, true));
|
||||||
|
}
|
||||||
|
onMounted(async () => {
|
||||||
|
await nextTick();
|
||||||
|
root.value
|
||||||
|
?.querySelectorAll<HTMLElement>(".chart-canvas")
|
||||||
|
.forEach(el =>
|
||||||
|
charts.push(echarts.init(el, undefined, { renderer: "svg" }))
|
||||||
|
);
|
||||||
|
observer = new ResizeObserver(() => charts.forEach(chart => chart.resize()));
|
||||||
|
if (root.value) observer.observe(root.value);
|
||||||
|
render();
|
||||||
|
});
|
||||||
|
watch(() => props.overview, render, { deep: true });
|
||||||
|
onBeforeUnmount(() => {
|
||||||
|
observer?.disconnect();
|
||||||
|
charts.forEach(chart => chart.dispose());
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
<template>
|
||||||
|
<div ref="root" class="growth-dashboard">
|
||||||
|
<div class="metric-grid">
|
||||||
|
<article
|
||||||
|
v-for="(metric, i) in metrics"
|
||||||
|
:key="metric.label"
|
||||||
|
class="metric-card"
|
||||||
|
:style="{ '--accent': ['#6366f1', '#2bb8a5', '#ec9c45', '#8b5cf6'][i] }"
|
||||||
|
>
|
||||||
|
<span>{{ metric.label }}</span
|
||||||
|
><strong>{{
|
||||||
|
typeof metric.value === "number"
|
||||||
|
? metric.value.toLocaleString()
|
||||||
|
: metric.value
|
||||||
|
}}</strong
|
||||||
|
><small>{{ metric.note }}</small>
|
||||||
|
</article>
|
||||||
|
</div>
|
||||||
|
<div class="chart-grid">
|
||||||
|
<article v-for="(title, i) in titles" :key="title" class="chart-panel">
|
||||||
|
<header>
|
||||||
|
<h3>{{ title }}</h3>
|
||||||
|
<span>{{ subtitles[i] }}</span>
|
||||||
|
</header>
|
||||||
|
<div
|
||||||
|
class="chart-body"
|
||||||
|
role="img"
|
||||||
|
:aria-label="`${title},下方提供对应数据明细`"
|
||||||
|
>
|
||||||
|
<div
|
||||||
|
class="chart-canvas"
|
||||||
|
:style="{ visibility: empty[i] ? 'hidden' : 'visible' }"
|
||||||
|
/>
|
||||||
|
<div v-if="empty[i]" class="chart-empty">
|
||||||
|
<span>暂无样本</span><small>真实数据积累后自动呈现</small>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</article>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
<style scoped>
|
||||||
|
.metric-grid {
|
||||||
|
display: grid;
|
||||||
|
grid-template-columns: repeat(4, minmax(0, 1fr));
|
||||||
|
gap: 16px;
|
||||||
|
margin: 8px 0 20px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.metric-card {
|
||||||
|
position: relative;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 12px;
|
||||||
|
padding: 22px;
|
||||||
|
overflow: hidden;
|
||||||
|
background: var(--el-bg-color);
|
||||||
|
border: 1px solid var(--el-border-color-lighter);
|
||||||
|
border-radius: 14px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.metric-card::before {
|
||||||
|
position: absolute;
|
||||||
|
top: 22px;
|
||||||
|
left: 0;
|
||||||
|
width: 3px;
|
||||||
|
height: 24px;
|
||||||
|
content: "";
|
||||||
|
background: var(--accent);
|
||||||
|
border-radius: 3px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.metric-card > span {
|
||||||
|
font-size: 13px;
|
||||||
|
color: var(--el-text-color-secondary);
|
||||||
|
}
|
||||||
|
|
||||||
|
.metric-card strong {
|
||||||
|
font-size: 32px;
|
||||||
|
font-variant-numeric: tabular-nums;
|
||||||
|
line-height: 1.2;
|
||||||
|
color: var(--el-text-color-primary);
|
||||||
|
}
|
||||||
|
|
||||||
|
.metric-card small {
|
||||||
|
font-size: 11px;
|
||||||
|
line-height: 1.6;
|
||||||
|
color: var(--el-text-color-secondary);
|
||||||
|
}
|
||||||
|
|
||||||
|
.chart-grid {
|
||||||
|
display: grid;
|
||||||
|
grid-template-columns: repeat(2, minmax(0, 1fr));
|
||||||
|
gap: 20px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.chart-panel {
|
||||||
|
min-width: 0;
|
||||||
|
padding: 22px 18px 12px;
|
||||||
|
border: 1px solid var(--el-border-color-lighter);
|
||||||
|
border-radius: 14px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.chart-panel header {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 8px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.chart-panel h3 {
|
||||||
|
margin: 0;
|
||||||
|
font-size: 15px;
|
||||||
|
font-weight: 600;
|
||||||
|
color: var(--el-text-color-primary);
|
||||||
|
}
|
||||||
|
|
||||||
|
.chart-panel header span {
|
||||||
|
font-size: 11px;
|
||||||
|
line-height: 1.6;
|
||||||
|
color: var(--el-text-color-secondary);
|
||||||
|
}
|
||||||
|
|
||||||
|
.chart-body {
|
||||||
|
position: relative;
|
||||||
|
}
|
||||||
|
|
||||||
|
.chart-canvas {
|
||||||
|
width: 100%;
|
||||||
|
height: 280px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.chart-empty {
|
||||||
|
position: absolute;
|
||||||
|
inset: 0;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 10px;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
color: var(--el-text-color-secondary);
|
||||||
|
}
|
||||||
|
|
||||||
|
.chart-empty small {
|
||||||
|
color: var(--el-text-color-placeholder);
|
||||||
|
}
|
||||||
|
|
||||||
|
@media (width <= 1200px) {
|
||||||
|
.metric-grid {
|
||||||
|
grid-template-columns: repeat(2, minmax(0, 1fr));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@media (width <= 760px) {
|
||||||
|
.chart-grid {
|
||||||
|
grid-template-columns: minmax(0, 1fr);
|
||||||
|
}
|
||||||
|
|
||||||
|
.metric-card {
|
||||||
|
padding: 16px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.metric-card strong {
|
||||||
|
font-size: 25px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</style>
|
||||||
@@ -2,6 +2,7 @@
|
|||||||
/** C端增长运营:漏斗、推荐实验、质量与额度流水,配置写入采用版本校验和审计。 */
|
/** C端增长运营:漏斗、推荐实验、质量与额度流水,配置写入采用版本校验和审计。 */
|
||||||
import { computed, onMounted, ref } from "vue";
|
import { computed, onMounted, ref } from "vue";
|
||||||
import { ElMessage, ElMessageBox } from "element-plus";
|
import { ElMessage, ElMessageBox } from "element-plus";
|
||||||
|
import GrowthCharts from "./growth-charts.vue";
|
||||||
import { digital } from "@/api/access";
|
import { digital } from "@/api/access";
|
||||||
type Row = Record<string, string | number | boolean | null>;
|
type Row = Record<string, string | number | boolean | null>;
|
||||||
type Config = {
|
type Config = {
|
||||||
@@ -215,7 +216,8 @@ onMounted(load);
|
|||||||
<section v-loading="loading" class="growth-admin">
|
<section v-loading="loading" class="growth-admin">
|
||||||
<header>
|
<header>
|
||||||
<div>
|
<div>
|
||||||
<h2>C端增长与体验</h2>
|
<span class="eyebrow">GROWTH ANALYTICS</span>
|
||||||
|
<h2>增长与体验数据中心</h2>
|
||||||
<p>
|
<p>
|
||||||
真实事件驱动运营;指标空缺时显示暂无样本。字符预算估算不等同Token账单或收入。
|
真实事件驱动运营;指标空缺时显示暂无样本。字符预算估算不等同Token账单或收入。
|
||||||
</p>
|
</p>
|
||||||
@@ -227,7 +229,7 @@ onMounted(load);
|
|||||||
</header>
|
</header>
|
||||||
<el-alert v-if="error" :title="error" type="error" :closable="false" />
|
<el-alert v-if="error" :title="error" type="error" :closable="false" />
|
||||||
<el-tabs v-model="tab">
|
<el-tabs v-model="tab">
|
||||||
<el-tab-pane label="漏斗与留存" name="overview"
|
<el-tab-pane label="数据总览" name="overview"
|
||||||
><template v-if="overview"
|
><template v-if="overview"
|
||||||
><el-alert
|
><el-alert
|
||||||
v-if="overview.truncated"
|
v-if="overview.truncated"
|
||||||
@@ -235,7 +237,8 @@ onMounted(load);
|
|||||||
type="warning"
|
type="warning"
|
||||||
:closable="false"
|
:closable="false"
|
||||||
/>
|
/>
|
||||||
<h3>严格顺序转化漏斗</h3>
|
<GrowthCharts :overview="overview" />
|
||||||
|
<h3>转化阶段明细</h3>
|
||||||
<div class="funnel">
|
<div class="funnel">
|
||||||
<article v-for="(stage, i) in overview.funnel" :key="stage.stage">
|
<article v-for="(stage, i) in overview.funnel" :key="stage.stage">
|
||||||
<span>{{ labels[stage.stage] }}</span
|
<span>{{ labels[stage.stage] }}</span
|
||||||
@@ -497,7 +500,9 @@ onMounted(load);
|
|||||||
</template>
|
</template>
|
||||||
<style scoped>
|
<style scoped>
|
||||||
.growth-admin {
|
.growth-admin {
|
||||||
padding: 20px;
|
padding: 24px;
|
||||||
|
background: var(--el-bg-color-page);
|
||||||
|
border-radius: 16px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.growth-admin header {
|
.growth-admin header {
|
||||||
@@ -516,6 +521,39 @@ onMounted(load);
|
|||||||
color: var(--el-text-color-secondary);
|
color: var(--el-text-color-secondary);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.eyebrow {
|
||||||
|
font-size: 11px;
|
||||||
|
font-weight: 700;
|
||||||
|
color: var(--el-color-primary);
|
||||||
|
letter-spacing: 2px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.growth-admin h2 {
|
||||||
|
margin: 8px 0;
|
||||||
|
font-size: 26px;
|
||||||
|
letter-spacing: -0.5px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.growth-admin :deep(.el-tabs__content) {
|
||||||
|
padding: 20px;
|
||||||
|
background: var(--el-bg-color);
|
||||||
|
border-radius: 14px;
|
||||||
|
}
|
||||||
|
|
||||||
|
@media (width <= 760px) {
|
||||||
|
.growth-admin {
|
||||||
|
padding: 12px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.growth-admin header {
|
||||||
|
flex-wrap: wrap;
|
||||||
|
}
|
||||||
|
|
||||||
|
.growth-admin header > div {
|
||||||
|
flex-basis: 100%;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
.growth-admin h3 {
|
.growth-admin h3 {
|
||||||
margin: 22px 0 12px;
|
margin: 22px 0 12px;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user