fix: update types

This commit is contained in:
Fine 2023-07-10 17:21:19 +08:00
parent 2f903e0255
commit a1232f9b5a
6 changed files with 43 additions and 31 deletions

View File

@ -407,6 +407,6 @@ const msg = {
detail: "Detail", detail: "Detail",
marketplace: "Marketplace", marketplace: "Marketplace",
menus: "Menus", menus: "Menus",
saveReload: "Save and reload page", saveReload: "Save and reload the page",
}; };
export default msg; export default msg;

View File

@ -406,6 +406,6 @@ const msg = {
detail: "Detail", detail: "Detail",
marketplace: "Marketplace", marketplace: "Marketplace",
menus: "Menus", menus: "Menus",
saveReload: "Save and reload page", saveReload: "Save and reload the page",
}; };
export default msg; export default msg;

View File

@ -16,11 +16,12 @@
*/ */
import Layout from "@/layout/Index.vue"; import Layout from "@/layout/Index.vue";
import { useAppStoreWithOut } from "@/store/modules/app"; import { useAppStoreWithOut } from "@/store/modules/app";
import type { MenuOptions } from "@/types/app";
async function layerDashboards() { async function layerDashboards() {
const appStore = useAppStoreWithOut(); const appStore = useAppStoreWithOut();
await appStore.getActivateMenus(); await appStore.getActivateMenus();
const routes = appStore.currentMenus.map((item: any) => { const routes = appStore.currentMenus.map((item: MenuOptions) => {
const route: any = { const route: any = {
path: "", path: "",
name: item.name, name: item.name,
@ -33,7 +34,7 @@ async function layerDashboards() {
children: item.subItems && item.subItems.length ? [] : undefined, children: item.subItems && item.subItems.length ? [] : undefined,
}; };
for (const child of item.subItems || []) { for (const child of item.subItems || []) {
const d: any = { const d = {
name: child.name, name: child.name,
path: child.path, path: child.path,
meta: { meta: {
@ -41,18 +42,18 @@ async function layerDashboards() {
layer: child.layer, layer: child.layer,
icon: child.icon || "cloud_queue", icon: child.icon || "cloud_queue",
}, },
component: () => import("@/views/Layer.vue"),
}; };
d.component = () => import("@/views/Layer.vue");
route.children.push(d); route.children.push(d);
const tab: any = { const tab = {
name: `${child.name}ActiveTabIndex`, name: `${child.name}ActiveTabIndex`,
path: `/${child.name}/tab/:activeTabIndex`, path: `/${child.name}/tab/:activeTabIndex`,
component: () => import("@/views/Layer.vue"),
meta: { meta: {
notShow: true, notShow: true,
layer: child.layer, layer: child.layer,
}, },
}; };
tab.component = () => import("@/views/Layer.vue");
route.children.push(tab); route.children.push(tab);
} }
if (!item.subItems.length) { if (!item.subItems.length) {

View File

@ -22,7 +22,7 @@ import getLocalTime from "@/utils/localtime";
import type { AxiosResponse } from "axios"; import type { AxiosResponse } from "axios";
import dateFormatStep, { dateFormatTime } from "@/utils/dateFormat"; import dateFormatStep, { dateFormatTime } from "@/utils/dateFormat";
import { TimeType } from "@/constants/data"; import { TimeType } from "@/constants/data";
import type { MenuOptions } from "@/types/app"; import type { MenuOptions, SubItem } from "@/types/app";
/*global Nullable*/ /*global Nullable*/
interface AppState { interface AppState {
durationRow: Recordable; durationRow: Recordable;
@ -180,7 +180,7 @@ export const appStore = defineStore({
d.id = d.name; d.id = d.name;
if (d.subItems && d.subItems.length) { if (d.subItems && d.subItems.length) {
d.hasGroup = true; d.hasGroup = true;
d.subItems = d.subItems.map((item: any, sub: number) => { d.subItems = d.subItems.map((item: SubItem, sub: number) => {
const id = `${item.title.replace(/\s+/g, "-")}`; const id = `${item.title.replace(/\s+/g, "-")}`;
item.name = `${id}-${index}${sub}`; item.name = `${id}-${index}${sub}`;
item.path = `/${t}/${id}`; item.path = `/${t}/${id}`;
@ -193,7 +193,7 @@ export const appStore = defineStore({
}); });
this.activateMenus = menus.filter((d: MenuOptions) => { this.activateMenus = menus.filter((d: MenuOptions) => {
if (d.activate) { if (d.activate) {
d.subItems = d.subItems.filter((item: any) => { d.subItems = d.subItems.filter((item: SubItem) => {
if (item.activate) { if (item.activate) {
return item; return item;
} }

22
src/types/app.d.ts vendored
View File

@ -56,14 +56,16 @@ export interface MenuOptions {
path?: string; path?: string;
hasGroup?: boolean; hasGroup?: boolean;
id?: string; id?: string;
subItems: { subItems: SubItem[];
layer: string; }
icon: string;
title: string; export interface SubItem {
activate: boolean; layer: string;
name?: string; icon: string;
path?: string; title: string;
notShow?: boolean; activate: boolean;
id?: string; name?: string;
}[]; path?: string;
notShow?: boolean;
id?: string;
} }

View File

@ -14,16 +14,16 @@ See the License for the specific language governing permissions and
limitations under the License. --> limitations under the License. -->
<template> <template>
<div class="menus flex-v"> <div class="menus flex-v">
<el-tree <div class="tree-body">
ref="treeRef" <el-tree
:data="appStore.activateMenus" ref="treeRef"
show-checkbox :data="appStore.activateMenus"
node-key="id" show-checkbox
default-expand-all node-key="id"
:default-checked-keys="appStore.checkedKeys" default-expand-all
:props="defaultProps" :default-checked-keys="appStore.checkedKeys"
/> :props="defaultProps"
<div class="footer flex-v"> />
<el-button class="btn" size="small" type="primary" @click="getCheckedNodes"> <el-button class="btn" size="small" type="primary" @click="getCheckedNodes">
{{ t("saveReload") }} {{ t("saveReload") }}
</el-button> </el-button>
@ -60,12 +60,21 @@ limitations under the License. -->
padding: 10px; padding: 10px;
} }
.tree-body {
padding-left: 30px;
padding-top: 20px;
width: 100%;
height: 100%;
background-color: #fff;
}
.footer { .footer {
padding: 80px 10px 20px; padding: 0 10px;
background-color: #fff; background-color: #fff;
} }
.btn { .btn {
width: 150px; width: 150px;
margin-top: 20px;
} }
</style> </style>