数据大屏修改

This commit is contained in:
zhx 2026-05-22 20:17:53 +08:00
parent 0730d0609a
commit 5045256d72

View File

@ -78,7 +78,7 @@ const arpuDashboards = ref<{
}); });
const initialDate = dayjs().tz(DEFAULT_STAT_TIMEZONE); const initialDate = dayjs().tz(DEFAULT_STAT_TIMEZONE);
const dateRange = ref<[string, string] | null>([ const dateRange = ref<[string, string] | null>([
initialDate.subtract(6, 'day').format('YYYY-MM-DD'), initialDate.format('YYYY-MM-DD'),
initialDate.format('YYYY-MM-DD'), initialDate.format('YYYY-MM-DD'),
]); ]);
const selectedCountryCodes = ref<string[]>([]); const selectedCountryCodes = ref<string[]>([]);
@ -117,8 +117,6 @@ const gameQuery = reactive<{
}); });
const query = reactive({ const query = reactive({
periodType: 'DAY',
statTimezone: DEFAULT_STAT_TIMEZONE,
sysOrigin: '', sysOrigin: '',
}); });
@ -148,19 +146,6 @@ const permissionsSysOriginCode = computed(() =>
sysOriginOptions.value.map((item) => String(item.value || '')), sysOriginOptions.value.map((item) => String(item.value || '')),
); );
const periodTypeOptions = [
{ label: '日', value: 'DAY' },
{ label: '周', value: 'WEEK' },
{ label: '月', value: 'MONTH' },
{ label: '全部', value: 'ALL' },
];
const statTimezoneOptions = [
{ label: '利雅得(服务器)', value: 'Asia/Riyadh' },
{ label: 'UTC', value: 'UTC' },
{ label: '北京', value: 'Asia/Shanghai' },
];
const gameProviderOptions = [ const gameProviderOptions = [
{ label: '全部游戏厂商', value: '' }, { label: '全部游戏厂商', value: '' },
{ label: '站内游戏', value: 'INTERNAL' }, { label: '站内游戏', value: 'INTERNAL' },
@ -478,9 +463,7 @@ function hasPermission(code: string) {
const canQuery = computed(() => hasPermission('datav:query')); const canQuery = computed(() => hasPermission('datav:query'));
const canPaidPreview = computed(() => hasPermission('datav:paid:preview')); const canPaidPreview = computed(() => hasPermission('datav:paid:preview'));
const currentTimezoneLabel = computed(() => { const currentTimezoneLabel = '利雅得(服务器)';
return statTimezoneOptions.find((item) => item.value === query.statTimezone)?.label || query.statTimezone;
});
function syncFullscreenState() { function syncFullscreenState() {
fullscreen.value = document.fullscreenElement === datavFullscreen.value; fullscreen.value = document.fullscreenElement === datavFullscreen.value;
@ -506,35 +489,10 @@ async function toggleVisualMode() {
await renderVisualCharts(); await renderVisualCharts();
} }
function defaultRange(periodType: string): [string, string] | null {
const now = dayjs().tz(query.statTimezone || DEFAULT_STAT_TIMEZONE);
if (periodType === 'ALL') {
return null;
}
if (periodType === 'MONTH') {
return [now.startOf('month').format('YYYY-MM-DD'), now.format('YYYY-MM-DD')];
}
if (periodType === 'WEEK') {
const daysSinceMonday = now.day() === 0 ? 6 : now.day() - 1;
return [now.subtract(daysSinceMonday, 'day').format('YYYY-MM-DD'), now.format('YYYY-MM-DD')];
}
return [now.subtract(6, 'day').format('YYYY-MM-DD'), now.format('YYYY-MM-DD')];
}
function handlePeriodChange(value: string) {
dateRange.value = defaultRange(value);
loadDashboard();
}
function handleTimezoneChange() {
dateRange.value = defaultRange(query.periodType);
loadDashboard();
}
function buildParams() { function buildParams() {
const params: Record<string, any> = { const params: Record<string, any> = {
periodType: query.periodType, periodType: 'DAY',
statTimezone: query.statTimezone || DEFAULT_STAT_TIMEZONE, statTimezone: DEFAULT_STAT_TIMEZONE,
sysOrigin: query.sysOrigin || undefined, sysOrigin: query.sysOrigin || undefined,
}; };
if (dateRange.value?.[0] && dateRange.value?.[1]) { if (dateRange.value?.[0] && dateRange.value?.[1]) {
@ -545,13 +503,13 @@ function buildParams() {
} }
function buildRecentDayParams(dayCount: number) { function buildRecentDayParams(dayCount: number) {
const end = dayjs().tz(query.statTimezone || DEFAULT_STAT_TIMEZONE); const end = dayjs().tz(DEFAULT_STAT_TIMEZONE);
const start = end.subtract(dayCount - 1, 'day'); const start = end.subtract(dayCount - 1, 'day');
return { return {
periodType: 'DAY', periodType: 'DAY',
startDate: start.format('YYYY-MM-DD'), startDate: start.format('YYYY-MM-DD'),
endDate: end.format('YYYY-MM-DD'), endDate: end.format('YYYY-MM-DD'),
statTimezone: query.statTimezone || DEFAULT_STAT_TIMEZONE, statTimezone: DEFAULT_STAT_TIMEZONE,
sysOrigin: query.sysOrigin || undefined, sysOrigin: query.sysOrigin || undefined,
}; };
} }
@ -1221,18 +1179,6 @@ onBeforeUnmount(() => {
style="width: 150px" style="width: 150px"
@change="loadDashboard" @change="loadDashboard"
/> />
<Select
v-model:value="query.statTimezone"
:options="statTimezoneOptions"
style="width: 170px"
@change="handleTimezoneChange"
/>
<Select
v-model:value="query.periodType"
:options="periodTypeOptions"
style="width: 110px"
@change="handlePeriodChange"
/>
<DateRangePicker <DateRangePicker
v-model:value="dateRange" v-model:value="dateRange"
allow-clear allow-clear