Browse Source

记录数据更新时间;

songjie/feature-20260120101758-dc后台
songjie 3 weeks ago
parent
commit
2838202a4f
  1. 28
      src/views/PlatformData/UserActivityStats.vue
  2. 28
      src/views/PlatformData/UserLoginStats.vue
  3. 20
      src/views/PlatformData/UserOverview.vue

28
src/views/PlatformData/UserActivityStats.vue

@ -140,6 +140,11 @@
/> />
</div> </div>
</el-dialog> </el-dialog>
<!-- 悬浮刷新时间 -->
<div class="refresh-time" v-if="lastUpdateTime">
数据刷新时间{{ lastUpdateTime }}
</div>
</div> </div>
</template> </template>
@ -158,6 +163,7 @@ const chartDateRange = ref('');
const chartMode = ref(route.query.mode || 'day'); // day, week, month const chartMode = ref(route.query.mode || 'day'); // day, week, month
const chartRef = ref(null); const chartRef = ref(null);
let chartInstance = null; let chartInstance = null;
const lastUpdateTime = ref('');
// URL // URL
const initQueryParams = () => { const initQueryParams = () => {
@ -208,6 +214,13 @@ const formatDate = (date) => {
return `${d.getFullYear()}-${pad(d.getMonth() + 1)}-${pad(d.getDate())}`; return `${d.getFullYear()}-${pad(d.getMonth() + 1)}-${pad(d.getDate())}`;
}; };
const formatDateTime = (date) => {
if (!date) return '';
const d = new Date(date);
const pad = (n) => n < 10 ? '0' + n : n;
return `${d.getFullYear()}-${pad(d.getMonth() + 1)}-${pad(d.getDate())} ${pad(d.getHours())}:${pad(d.getMinutes())}:${pad(d.getSeconds())}`;
};
const fetchChartData = async () => { const fetchChartData = async () => {
const params = { const params = {
mode: chartMode.value mode: chartMode.value
@ -226,6 +239,7 @@ const fetchChartData = async () => {
if (Array.isArray(data)) { if (Array.isArray(data)) {
updateChart(data); updateChart(data);
} }
lastUpdateTime.value = formatDateTime(new Date());
} catch (e) { } catch (e) {
console.error('获取DeepChart趋势数据失败:', e); console.error('获取DeepChart趋势数据失败:', e);
} }
@ -479,6 +493,7 @@ const fetchTableData = async () => {
tableData.value = []; tableData.value = [];
total.value = 0; total.value = 0;
} }
lastUpdateTime.value = formatDateTime(new Date());
} catch (e) { } catch (e) {
console.error('获取DeepChart活跃用户明细失败:', e); console.error('获取DeepChart活跃用户明细失败:', e);
} }
@ -602,4 +617,17 @@ onMounted(() => {
color: #606266; color: #606266;
margin-right: 20px; margin-right: 20px;
} }
.refresh-time {
position: fixed;
bottom: 20px;
right: 20px;
background: rgba(0, 0, 0, 0.6);
color: #fff;
padding: 8px 15px;
border-radius: 20px;
font-size: 12px;
z-index: 2000;
box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.1);
}
</style> </style>

28
src/views/PlatformData/UserLoginStats.vue

@ -231,6 +231,11 @@
</div> </div>
</div> </div>
<!-- 悬浮刷新时间 -->
<div class="refresh-time" v-if="lastUpdateTime">
数据刷新时间{{ lastUpdateTime }}
</div>
</div> </div>
</template> </template>
@ -251,6 +256,7 @@ const searchRegion = ref('');
const dateRangeRegion = ref(''); const dateRangeRegion = ref('');
const loading = ref(false); const loading = ref(false);
const loadingRegion = ref(false); const loadingRegion = ref(false);
const lastUpdateTime = ref('');
const chartTrendRef = ref(null); const chartTrendRef = ref(null);
let chartTrendInstance = null; let chartTrendInstance = null;
@ -352,6 +358,13 @@ const formatDate = (date) => {
return `${d.getFullYear()}-${pad(d.getMonth() + 1)}-${pad(d.getDate())}`; return `${d.getFullYear()}-${pad(d.getMonth() + 1)}-${pad(d.getDate())}`;
}; };
const formatDateTime = (date) => {
if (!date) return '';
const d = new Date(date);
const pad = (n) => n < 10 ? '0' + n : n;
return `${d.getFullYear()}-${pad(d.getMonth() + 1)}-${pad(d.getDate())} ${pad(d.getHours())}:${pad(d.getMinutes())}:${pad(d.getSeconds())}`;
};
const fetchLoginData = async () => { const fetchLoginData = async () => {
let params = {}; let params = {};
if (dateRange.value && dateRange.value.length === 2) { if (dateRange.value && dateRange.value.length === 2) {
@ -552,6 +565,7 @@ const fetchAllLoginData = async () => {
fetchLoginChannelMemberData(), fetchLoginChannelMemberData(),
fetchLoginChannelNoMemberData() fetchLoginChannelNoMemberData()
]); ]);
lastUpdateTime.value = formatDateTime(new Date());
} catch (error) { } catch (error) {
console.error('获取登录数据失败:', error); console.error('获取登录数据失败:', error);
} finally { } finally {
@ -647,6 +661,7 @@ const fetchAllRegionData = async () => {
fetchRegionHistogramData(), fetchRegionHistogramData(),
fetchRegionDistributionData() fetchRegionDistributionData()
]); ]);
lastUpdateTime.value = formatDateTime(new Date());
} catch (error) { } catch (error) {
console.error('获取地区数据失败:', error); console.error('获取地区数据失败:', error);
} finally { } finally {
@ -1289,4 +1304,17 @@ onMounted(() => {
width: 100%; width: 100%;
height: 300px; height: 300px;
} }
.refresh-time {
position: fixed;
bottom: 20px;
right: 20px;
background: rgba(0, 0, 0, 0.6);
color: #fff;
padding: 8px 15px;
border-radius: 20px;
font-size: 12px;
z-index: 2000;
box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.1);
}
</style> </style>

20
src/views/PlatformData/UserOverview.vue

@ -183,6 +183,10 @@
</div> </div>
</div> </div>
<!-- 悬浮刷新时间 -->
<div class="refresh-time" v-if="lastUpdateTime">
数据刷新时间{{ lastUpdateTime }}
</div>
</div> </div>
</template> </template>
@ -199,6 +203,7 @@ const router = useRouter();
const activeTab = ref(route.query.tab || 'overview'); const activeTab = ref(route.query.tab || 'overview');
const dateRange = ref(''); const dateRange = ref('');
const loading = ref(false); const loading = ref(false);
const lastUpdateTime = ref('');
const hasDateRange = computed(() => { const hasDateRange = computed(() => {
return dateRange.value && dateRange.value.length === 2; return dateRange.value && dateRange.value.length === 2;
@ -277,6 +282,7 @@ const fetchData = async () => {
overviewData.value = res.list; overviewData.value = res.list;
initCharts(); initCharts();
isOverviewLoaded.value = true; isOverviewLoaded.value = true;
lastUpdateTime.value = formatDate(new Date());
} }
} catch (error) { } catch (error) {
console.error('获取用户概览数据失败:', error); console.error('获取用户概览数据失败:', error);
@ -352,6 +358,7 @@ const fetchDetailData = async (forceUpdate = false) => {
} }
isDetailLoaded.value = true; isDetailLoaded.value = true;
lastUpdateTime.value = formatDate(new Date());
} }
} catch(e) { } catch(e) {
console.error('获取数据明细失败:', e); console.error('获取数据明细失败:', e);
@ -849,4 +856,17 @@ onMounted(() => {
width: 100%; width: 100%;
height: 350px; height: 350px;
} }
.refresh-time {
position: fixed;
bottom: 20px;
right: 20px;
background: rgba(0, 0, 0, 0.6);
color: #fff;
padding: 8px 15px;
border-radius: 20px;
font-size: 12px;
z-index: 2000;
box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.1);
}
</style> </style>
Loading…
Cancel
Save