feat: update

This commit is contained in:
Fine 2023-06-27 10:24:19 +08:00
parent 3753b64ca0
commit c73cde3f46
9 changed files with 50 additions and 40 deletions

View File

@ -15,11 +15,14 @@ limitations under the License. -->
<template> <template>
<div class="nav-bar flex-h"> <div class="nav-bar flex-h">
<div class="title flex-h"> <div class="title flex-h">
<el-breadcrumb separator=">"> <el-breadcrumb separator=">" v-if="pathNames.length">
<el-breadcrumb-item v-for="(item, index) in appStore.pathNames" :key="index" :to="{ path: '/' }"> <el-breadcrumb-item v-for="(names, index) in pathNames" :key="index">
{{ route.name === "ViewWidget" ? "" : appStore.pageTitle || t(pageName) }} <a v-for="(item, i) in names" :href="item.path" :key="i">
{{ route.name === "ViewWidget" ? "" : item.name }}
</a>
</el-breadcrumb-item> </el-breadcrumb-item>
</el-breadcrumb> </el-breadcrumb>
<span v-else>{{ pageName && t(pageName) }}</span>
</div> </div>
<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>
@ -51,20 +54,25 @@ limitations under the License. -->
import { useI18n } from "vue-i18n"; import { useI18n } from "vue-i18n";
import timeFormat from "@/utils/timeFormat"; import timeFormat from "@/utils/timeFormat";
import { useAppStoreWithOut } from "@/store/modules/app"; import { useAppStoreWithOut } from "@/store/modules/app";
import { useDashboardStore } from "@/store/modules/dashboard";
import { useSelectorStore } from "@/store/modules/selectors";
import { ElMessage } from "element-plus"; import { ElMessage } from "element-plus";
import { deduplication } from "@/utils/arrayAlgorithm"; import { MetricCatalog } from "@/views/dashboard/data";
import type { DashboardItem } from "@/types/dashboard";
/*global Indexable */ /*global Indexable */
const { t } = useI18n(); const { t } = useI18n();
const appStore = useAppStoreWithOut(); const appStore = useAppStoreWithOut();
const dashboardStore = useDashboardStore();
const selectorStore = useSelectorStore();
const route = useRoute(); const route = useRoute();
const pageName = ref<string>(""); const pageName = ref<string>("");
const pathNames = ref<any[]>([]);
const timeRange = ref<number>(0); const timeRange = ref<number>(0);
resetDuration(); resetDuration();
getVersion(); getVersion();
setConfig(String(route.meta.title)); setConfig(String(route.meta.title));
getPathNames();
function handleReload() { function handleReload() {
const gap = appStore.duration.end.getTime() - appStore.duration.start.getTime(); const gap = appStore.duration.end.getTime() - appStore.duration.start.getTime();
@ -85,16 +93,22 @@ limitations under the License. -->
} }
function getPathNames() { function getPathNames() {
const p = route.params; const obj = dashboardStore.currentDashboard;
console.log(route.meta);
}
watch( if (!dashboardStore.entity) {
() => route.meta.title, return;
(title: unknown) => { }
setConfig(String(title)); console.log(dashboardStore.dashboards);
}, const root = dashboardStore.dashboards.filter((d: DashboardItem) => d.isRoot && obj.layer === d.layer);
); pathNames.value.push(root);
if (obj.entity === MetricCatalog.SERVICE) {
const arr = dashboardStore.dashboards.filter(
(d: DashboardItem) => obj.entity === d.entity && obj.layer === d.layer,
);
pathNames.value.push(arr);
}
}
async function getVersion() { async function getVersion() {
const res = await appStore.fetchVersion(); const res = await appStore.fetchVersion();
@ -116,6 +130,27 @@ limitations under the License. -->
appStore.updateUTC(d.utc); appStore.updateUTC(d.utc);
} }
} }
watch(
() => route.meta.title,
() => {
pathNames.value = [];
setConfig("");
if (!route.meta.layer) {
setConfig(String(route.meta.title));
}
},
);
watch(
() => dashboardStore.currentDashboard,
() => {
pathNames.value = [];
setConfig("");
if (route.meta.layer) {
getPathNames();
}
},
);
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
.nav-bar { .nav-bar {

View File

@ -31,7 +31,6 @@ interface AppState {
eventStack: (() => unknown)[]; eventStack: (() => unknown)[];
timer: Nullable<TimeoutHandle>; timer: Nullable<TimeoutHandle>;
autoRefresh: boolean; autoRefresh: boolean;
pageTitle: string;
version: string; version: string;
isMobile: boolean; isMobile: boolean;
reloadTimer: Nullable<IntervalHandle>; reloadTimer: Nullable<IntervalHandle>;
@ -51,7 +50,6 @@ export const appStore = defineStore({
eventStack: [], eventStack: [],
timer: null, timer: null,
autoRefresh: false, autoRefresh: false,
pageTitle: "",
version: "", version: "",
isMobile: false, isMobile: false,
reloadTimer: null, reloadTimer: null,
@ -143,9 +141,6 @@ export const appStore = defineStore({
setAutoRefresh(auto: boolean) { setAutoRefresh(auto: boolean) {
this.autoRefresh = auto; this.autoRefresh = auto;
}, },
setPageTitle(title: string) {
this.pageTitle = title;
},
runEventStack() { runEventStack() {
if (this.timer) { if (this.timer) {
clearTimeout(this.timer); clearTimeout(this.timer);

View File

@ -19,12 +19,8 @@ limitations under the License. -->
</div> </div>
</template> </template>
<script lang="ts" setup> <script lang="ts" setup>
import { useAppStoreWithOut } from "@/store/modules/app";
import Header from "./alarm/Header.vue"; import Header from "./alarm/Header.vue";
import Content from "./alarm/Content.vue"; import Content from "./alarm/Content.vue";
const appStore = useAppStoreWithOut();
appStore.setPageTitle("Alerting");
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
.alarm { .alarm {

View File

@ -19,13 +19,8 @@ limitations under the License. -->
</div> </div>
</template> </template>
<script lang="ts" setup> <script lang="ts" setup>
import { useAppStoreWithOut } from "@/store/modules/app";
import Header from "./event/Header.vue"; import Header from "./event/Header.vue";
import Content from "./event/Content.vue"; import Content from "./event/Content.vue";
const appStore = useAppStoreWithOut();
appStore.setPageTitle("Events");
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
.event { .event {

View File

@ -44,7 +44,6 @@ limitations under the License. -->
d.layer === dashboardStore.layerId && [EntityType[0].value, EntityType[1].value].includes(d.entity) && d.isRoot, d.layer === dashboardStore.layerId && [EntityType[0].value, EntityType[1].value].includes(d.entity) && d.isRoot,
); );
if (!item) { if (!item) {
appStore.setPageTitle(dashboardStore.layer);
dashboardStore.setCurrentDashboard(null); dashboardStore.setCurrentDashboard(null);
dashboardStore.setEntity(EntityType[1].value); dashboardStore.setEntity(EntityType[1].value);
return; return;

View File

@ -66,7 +66,6 @@ limitations under the License. -->
const utcHour = ref<number>(appStore.utcHour); const utcHour = ref<number>(appStore.utcHour);
const utcMin = ref<number>(appStore.utcMin); const utcMin = ref<number>(appStore.utcMin);
appStore.setPageTitle("Setting");
const handleReload = () => { const handleReload = () => {
const gap = appStore.duration.end.getTime() - appStore.duration.start.getTime(); const gap = appStore.duration.end.getTime() - appStore.duration.start.getTime();
const dates: Date[] = [ const dates: Date[] = [

View File

@ -47,7 +47,6 @@ limitations under the License. -->
import GridLayout from "./panel/Layout.vue"; import GridLayout from "./panel/Layout.vue";
import Tool from "./panel/Tool.vue"; import Tool from "./panel/Tool.vue";
import { useDashboardStore } from "@/store/modules/dashboard"; import { useDashboardStore } from "@/store/modules/dashboard";
import { useAppStoreWithOut } from "@/store/modules/app";
import Configuration from "./configuration"; import Configuration from "./configuration";
import type { LayoutConfig } from "@/types/dashboard"; import type { LayoutConfig } from "@/types/dashboard";
import WidgetLink from "./components/WidgetLink.vue"; import WidgetLink from "./components/WidgetLink.vue";
@ -57,7 +56,6 @@ limitations under the License. -->
components: { ...Configuration, GridLayout, Tool, WidgetLink }, components: { ...Configuration, GridLayout, Tool, WidgetLink },
setup() { setup() {
const dashboardStore = useDashboardStore(); const dashboardStore = useDashboardStore();
const appStore = useAppStoreWithOut();
const { t } = useI18n(); const { t } = useI18n();
const p = useRoute().params; const p = useRoute().params;
const layoutKey = ref<string>(`${p.layerId}_${p.entity}_${p.name}`); const layoutKey = ref<string>(`${p.layerId}_${p.entity}_${p.name}`);
@ -77,7 +75,6 @@ limitations under the License. -->
const layout: any = c.configuration || {}; const layout: any = c.configuration || {};
dashboardStore.setLayout(setWidgetsID(layout.children || [])); dashboardStore.setLayout(setWidgetsID(layout.children || []));
appStore.setPageTitle(layout.name);
if (p.entity) { if (p.entity) {
dashboardStore.setCurrentDashboard({ dashboardStore.setCurrentDashboard({
layer: p.layerId, layer: p.layerId,

View File

@ -135,7 +135,6 @@ limitations under the License. -->
import { useI18n } from "vue-i18n"; import { useI18n } from "vue-i18n";
import { ElMessageBox, ElMessage } from "element-plus"; import { ElMessageBox, ElMessage } from "element-plus";
import { ElTable } from "element-plus"; import { ElTable } from "element-plus";
import { useAppStoreWithOut } from "@/store/modules/app";
import { useDashboardStore } from "@/store/modules/dashboard"; import { useDashboardStore } from "@/store/modules/dashboard";
import router from "@/router"; import router from "@/router";
import type { DashboardItem, LayoutConfig } from "@/types/dashboard"; import type { DashboardItem, LayoutConfig } from "@/types/dashboard";
@ -145,7 +144,6 @@ limitations under the License. -->
/*global Nullable*/ /*global Nullable*/
const { t } = useI18n(); const { t } = useI18n();
const appStore = useAppStoreWithOut();
const dashboardStore = useDashboardStore(); const dashboardStore = useDashboardStore();
const pageSize = 20; const pageSize = 20;
const dashboards = ref<DashboardItem[]>([]); const dashboards = ref<DashboardItem[]>([]);
@ -157,7 +155,6 @@ limitations under the License. -->
const multipleSelection = ref<DashboardItem[]>([]); const multipleSelection = ref<DashboardItem[]>([]);
const dashboardFile = ref<Nullable<HTMLDivElement>>(null); const dashboardFile = ref<Nullable<HTMLDivElement>>(null);
appStore.setPageTitle("Dashboard List");
const handleSelectionChange = (val: DashboardItem[]) => { const handleSelectionChange = (val: DashboardItem[]) => {
multipleSelection.value = val; multipleSelection.value = val;
}; };
@ -481,7 +478,7 @@ limitations under the License. -->
.table { .table {
padding: 20px 10px; padding: 20px 10px;
background-color: #fff; background-color: #fff;
box-shadow: 0px 1px 4px 0px #00000029; box-shadow: 0 1px 4px 0 #00000029;
border-radius: 5px; border-radius: 5px;
width: 100%; width: 100%;
height: 100%; height: 100%;

View File

@ -53,12 +53,9 @@ limitations under the License. -->
import { useSelectorStore } from "@/store/modules/selectors"; import { useSelectorStore } from "@/store/modules/selectors";
import { EntityType } from "./data"; import { EntityType } from "./data";
import { ElMessage } from "element-plus"; import { ElMessage } from "element-plus";
import { useAppStoreWithOut } from "@/store/modules/app";
import { useDashboardStore } from "@/store/modules/dashboard"; import { useDashboardStore } from "@/store/modules/dashboard";
const appStore = useAppStoreWithOut();
const dashboardStore = useDashboardStore(); const dashboardStore = useDashboardStore();
appStore.setPageTitle("Dashboard New");
const { t } = useI18n(); const { t } = useI18n();
const selectorStore = useSelectorStore(); const selectorStore = useSelectorStore();
const states = reactive({ const states = reactive({