123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284 |
- <template>
- <div class="layout-padding">
- <div class="!overflow-auto px-1">
- <div class="el-card p-2">
- <div class="flex justify-between">
- <Title :title="t('activations.analytics')">
- <template #default>
- <el-popover class="box-item" placement="right" trigger="hover" width="250">
- <template #reference>
- <el-icon class="ml-1" style="color: #a4b8cf"><QuestionFilled /></el-icon>
- </template>
- <template #default>
- <div class="ant-popover-inner-content">
- <div class="um-page-tips-content" style="line-height: 24px">
- <p>
- <span class="highlight">活跃用户:</span>
- <span>启动过应用的用户(去重),启动过一次的用户即视为活跃用户,包括新用户与老用户</span>
- </p>
- <p><span class="highlight">活跃构成:</span><span>活跃用户中新增用户的占比比例</span></p>
- <p><span class="highlight">活跃粘度:</span><span>DAU/过去7日活跃用户,DAU/过去30日活跃用户</span></p>
- <p><span class="highlight">过去7日活跃用户:</span><span>过去7日(不含今日)的活跃用户数(去重)</span></p>
- <p><span class="highlight">过去30日活跃用户:</span><span>过去30日(不含今日)的活跃用户数(去重)</span></p>
- <p><span class="highlight">分时活跃用户:</span><span>活跃用户在24小时中的分布情况(每小时间去重)​</span></p>
- <p><span class="highlight">周活跃率:</span><span>周活跃用户占截止本周累计用户的比例</span></p>
- <p><span class="highlight">月活跃率:</span><span>月活跃用户占截止本月累计用户的比例</span></p>
- <p>
- <span>
- 按天、周或月查看数据可进行版本、渠道的交叉筛选。周区间定义为周日至次周周六。按周(按月)显示时,界面上用每周的周日(每个月的第一日)来代表该周(该月)
- </span>
- </p>
- </div>
- </div>
- </template>
- </el-popover>
- </template>
- </Title>
- </div>
- <div>
- <el-row shadow="hover" class="ml10 mt-2">
- <el-form :inline="true" :model="formData" @keyup.enter="query" ref="queryRef">
- <el-form-item>
- <el-date-picker v-model="formData.time" type="daterange" start-placeholder="开始时间" end-placeholder="结束时间" />
- </el-form-item>
- <el-form-item>
- <el-select v-model="selectedChannelCompare" class="w-[140px]" placeholder="全部渠道">
- <el-option v-for="item in channelCompareOptions" :key="item.value" :label="item.label" :value="item.value" />
- </el-select>
- </el-form-item>
- <el-form-item>
- <el-select v-model="selectedChannelCompare" class="w-[140px]" placeholder="全部版本">
- <el-option v-for="item in channelCompareOptions" :key="item.value" :label="item.label" :value="item.value" />
- </el-select>
- </el-form-item>
- </el-form>
- </el-row>
- </div>
- </div>
- <div class="mt-2 el-card p-2">
- <div class="">
- <div class="flex items-center justify-between mb-2 mt-3">
- <div>
- <el-select v-model="selectedChannelCompare" class="w-[140px] ml-2" style="width: 140px" placeholder="版本对比">
- <el-option v-for="item in channelCompareOptions" :key="item.value" :label="item.label" :value="item.value" />
- </el-select>
- <el-button type="primary" class="ml-2">{{ t('activations.version') }}</el-button>
- </div>
- <div class="flex items-center">
- <el-radio-group v-model="timeGranularity" size="small">
- <el-radio-button label="hour">小时</el-radio-button>
- <el-radio-button label="day">天</el-radio-button>
- <el-radio-button label="week">周</el-radio-button>
- <el-radio-button label="month">月</el-radio-button>
- </el-radio-group>
- </div>
- </div>
- <div class="relative">
- <div ref="lineChartRef" style="width: 100%; height: 320px"></div>
- </div>
- </div>
- <!-- 明细表格 -->
- <div class="mt-3">
- <div class="flex items-center justify-between mb-2">
- <div class="text-base font-medium cursor-pointer select-none" @click="showDetail1 = !showDetail1">
- {{ showDetail1 ? '收起明细数据' : '展开明细数据' }}
- </div>
- <div>
- <el-button>导出</el-button>
- </div>
- </div>
- <el-table v-if="showDetail1" :data="pagedTableRows" border>
- <el-table-column prop="date" label="日期" align="center" min-width="140" />
- <el-table-column prop="hyyh" label="启动次数" align="center" min-width="140" />
- <el-table-column prop="ratio" label="启动次数(占比)" align="center" min-width="220">
-
- </el-table-column>
- </el-table>
- <div v-if="showDetail1" class="flex justify-end mt-2">
- <el-pagination
- v-model:current-page="currentPage"
- v-model:page-size="pageSize"
- background
- layout="total, prev, pager, next, sizes"
- :total="tableRows.length"
- :page-sizes="[5, 10, 20]"
- />
- </div>
- </div>
- </div>
- </div>
- </div>
- </template>
- <script setup lang="ts">
- import { ref, onMounted, watch, computed, defineAsyncComponent } from 'vue';
- import * as echarts from 'echarts';
- import { useI18n } from 'vue-i18n';
- const { t } = useI18n();
- interface TableRow {
- date: string;
- newUsers: number;
- ratio: string;
- }
- const formData = ref<Record<string, any>>({});
- const query = () => {
- console.log(formData.value);
- };
- const selectedChannelCompare = ref('');
- const channelCompareOptions = [
- { label: '渠道对比', value: 'compare' },
- { label: '渠道A', value: 'a' },
- { label: '渠道B', value: 'b' },
- ];
- // 图表相关
- const timeGranularity = ref<'hour' | 'day' | 'week' | 'month'>('week');
- const lineChartRef = ref<HTMLDivElement | null>(null);
- let chartInstance: echarts.ECharts | null = null;
- const lineChartData = ref<Array<{ x: string; value: number }>>([
- { x: '2025-07-01', value: 900 },
- { x: '2025-07-08', value: 1000 },
- { x: '2025-07-15', value: 1100 },
- { x: '2025-07-22', value: 1000 },
- { x: '2025-07-29', value: 600 },
- { x: '2025-08-05', value: 300 },
- { x: '2025-08-12', value: 250 },
- { x: '2025-08-19', value: 200 },
- { x: '2025-08-26', value: 650 },
- { x: '2025-09-02', value: 950 },
- { x: '2025-09-09', value: 900 },
- { x: '2025-09-16', value: 120 },
- ]);
- function initLineChart(): void {
- if (!lineChartRef.value) return;
- if (chartInstance) chartInstance.dispose();
- chartInstance = echarts.init(lineChartRef.value);
- const option: echarts.EChartsOption = {
- tooltip: { trigger: 'axis' },
- grid: { left: 40, right: 20, top: 20, bottom: 30 },
- xAxis: {
- type: 'category',
- data: lineChartData.value.map((d) => d.x),
- axisLine: { lineStyle: { color: '#e5e7eb' } },
- axisLabel: { color: '#6b7280' },
- axisTick: { alignWithLabel: true },
- },
- yAxis: {
- type: 'value',
- axisLine: { show: false },
- splitLine: { lineStyle: { color: '#f3f4f6' } },
- axisLabel: { color: '#6b7280' },
- },
- series: [
- {
- name: '新增人数',
- type: 'line',
- smooth: true,
- showSymbol: true,
- symbolSize: 6,
- itemStyle: { color: '#409EFF' },
- lineStyle: { color: '#409EFF' },
- data: lineChartData.value.map((d) => d.value),
- },
- ],
- };
- chartInstance.setOption(option);
- }
- onMounted(() => {
- initLineChart();
- initQualityChart();
- });
- watch(timeGranularity, () => {
- // 静态页面:仅重新渲染
- initLineChart();
- });
- // 表格相关(静态数据)
- const tableRows = ref<TableRow[]>(
- Array.from({ length: 42 }).map((_, idx) => ({
- date: `2025-08-${String(11).padStart(2, '0')}`,
- newUsers: 727,
- hyyh: '115',
- ratio: '97.45%',
- }))
- );
- const currentPage = ref(1);
- const pageSize = ref(5);
- const pagedTableRows = computed(() => {
- const startIndex = (currentPage.value - 1) * pageSize.value;
- return tableRows.value.slice(startIndex, startIndex + pageSize.value);
- });
- const Title = defineAsyncComponent(() => import('/@/components/Title/index.vue'));
- // 展开/收起明细
- const showDetail1 = ref(true);
- // 用户质量(留存率)
- const qualityChartRef = ref<HTMLDivElement | null>(null);
- let qualityChart: echarts.ECharts | null = null;
- const qualityXAxis = ref<string[]>([
- '2025-07-01',
- '2025-07-08',
- '2025-07-15',
- '2025-07-22',
- '2025-07-29',
- '2025-08-05',
- '2025-08-12',
- '2025-08-19',
- '2025-08-26',
- '2025-09-02',
- '2025-09-09',
- '2025-09-16',
- ]);
- const retentionSeries = ref<number[]>([20, 23, 27, 24, 22, 15, 5, 4, 16, 26, 25, 2]);
- const industryAvgSeries = ref<number[]>([16, 18, 20, 24, 25, 24, 16, 10, 15, 22, 21, 12]);
- const peerSameScaleSeries = ref<number[]>([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]);
- function initQualityChart(): void {
- if (!qualityChartRef.value) return;
- if (qualityChart) qualityChart.dispose();
- qualityChart = echarts.init(qualityChartRef.value);
- const option: echarts.EChartsOption = {
- tooltip: { trigger: 'axis', valueFormatter: (v) => `${v}%` },
- legend: { data: ['留存率', '同行业App', '同行业同规模App'] },
- grid: { left: 40, right: 20, top: 30, bottom: 30 },
- xAxis: { type: 'category', data: qualityXAxis.value },
- yAxis: {
- type: 'value',
- min: 0,
- max: 30,
- axisLabel: { formatter: '{value}%' },
- splitLine: { lineStyle: { color: '#f3f4f6' } },
- },
- series: [
- { name: '留存率', type: 'line', smooth: true, data: retentionSeries.value },
- { name: '同行业App', type: 'line', smooth: true, data: industryAvgSeries.value, color: '#f59e0b' },
- { name: '同行业同规模App', type: 'line', smooth: true, data: peerSameScaleSeries.value, color: '#60a5fa' },
- ],
- };
- qualityChart.setOption(option);
- }
- </script>
- <style lang="scss" scoped>
- .highlight {
- color: #2196f3;
- }
- </style>
|