fix: update time range

This commit is contained in:
Qiuxia Fan 2022-01-12 16:06:25 +08:00
parent 299980b2d5
commit 5b95557905
3 changed files with 37 additions and 29 deletions

View File

@ -18,10 +18,10 @@ limitations under the License. -->
<div class="app-config"> <div class="app-config">
<span class="red" v-show="timeRange">{{ t("timeTips") }}</span> <span class="red" v-show="timeRange">{{ t("timeTips") }}</span>
<TimePicker <TimePicker
v-model="time"
:value="time" :value="time"
position="bottom" position="bottom"
format="YYYY-MM-DD HH:mm" format="YYYY-MM-DD HH:mm"
@input="changeTimeRange"
/> />
<span> <span>
UTC{{ utcHour >= 0 ? "+" : "" UTC{{ utcHour >= 0 ? "+" : ""
@ -62,19 +62,18 @@ const setConfig = (value: string) => {
pageName.value = value || ""; pageName.value = value || "";
theme.value = route.path.includes("/infrastructure/") ? "dark" : "light"; theme.value = route.path.includes("/infrastructure/") ? "dark" : "light";
}; };
const time = computed({ const time = computed(() => [
get() { appStore.durationRow.start,
return [appStore.durationRow.start, appStore.durationRow.end]; appStore.durationRow.end,
}, ]);
set(val: Date[]) { function changeTimeRange(val: Date[]) {
timeRange.value = timeRange.value =
val[1].getTime() - val[0].getTime() > 60 * 24 * 60 * 60 * 1000 ? 1 : 0; val[1].getTime() - val[0].getTime() > 60 * 24 * 60 * 60 * 1000 ? 1 : 0;
if (timeRange.value) { if (timeRange.value) {
return; return;
} }
appStore.setDuration(timeFormat(val)); appStore.setDuration(timeFormat(val));
}, }
});
setConfig(String(route.meta.title)); setConfig(String(route.meta.title));
watch( watch(
() => route.meta.title, () => route.meta.title,
@ -93,17 +92,20 @@ watch(
color: #222; color: #222;
font-size: 12px; font-size: 12px;
} }
.nav-bar.dark { .nav-bar.dark {
background-color: #333840; background-color: #333840;
border-bottom: 1px solid #252a2f; border-bottom: 1px solid #252a2f;
color: #fafbfc; color: #fafbfc;
} }
.title { .title {
font-size: 14px; font-size: 14px;
font-weight: 500; font-weight: 500;
height: 28px; height: 28px;
line-height: 28px; line-height: 28px;
} }
.nav-tabs { .nav-tabs {
padding: 10px; padding: 10px;
} }

View File

@ -98,6 +98,7 @@ export const appStore = defineStore({
actions: { actions: {
setDuration(data: Duration): void { setDuration(data: Duration): void {
this.durationRow = data; this.durationRow = data;
localStorage.setItem("durationRow", JSON.stringify(data, null, 0));
if ((window as any).axiosCancel.length !== 0) { if ((window as any).axiosCancel.length !== 0) {
for (const event of (window as any).axiosCancel) { for (const event of (window as any).axiosCancel) {
setTimeout(event(), 0); setTimeout(event(), 0);

View File

@ -16,6 +16,10 @@ limitations under the License. -->
<div class="widget"> <div class="widget">
<div class="header flex-h"> <div class="header flex-h">
<div>{{ data.widget.title || "" }}</div> <div>{{ data.widget.title || "" }}</div>
<div>
<el-tooltip :content="data.widget.tips">
<Icon iconName="info_outline" size="sm" class="operation" />
</el-tooltip>
<el-popover <el-popover
placement="bottom" placement="bottom"
trigger="click" trigger="click"
@ -32,6 +36,7 @@ limitations under the License. -->
</div> </div>
</el-popover> </el-popover>
</div> </div>
</div>
<div class="body" v-if="data.graph.type" v-loading="loading"> <div class="body" v-if="data.graph.type" v-loading="loading">
<component <component
:is="data.graph.type" :is="data.graph.type"