提交 | 用户 | 时间
|
cb6cd2
|
1 |
<template> |
H |
2 |
<ToolHeader/> |
|
3 |
<div> |
|
4 |
<h1>XmcPms鞍钢鲅鱼圈能源管控系统主页</h1> |
|
5 |
</div> |
|
6 |
<el-skeleton :loading="loading" animated> |
|
7 |
<div id="app" v-for="(item, index) in appList" :key="`dynamics-${index}`"> |
|
8 |
<div class="card" @click="gotoApp(item)"> |
|
9 |
{{item.appName}} |
|
10 |
</div> |
|
11 |
</div> |
|
12 |
</el-skeleton> |
|
13 |
|
|
14 |
</template> |
|
15 |
<script lang="ts" setup> |
|
16 |
|
|
17 |
import * as AppApi from '@/api/system/app' |
|
18 |
import ToolHeader from "@/layout/components/ToolHeader.vue"; |
|
19 |
import {Apps} from "@/views/Home/types"; |
|
20 |
import {CACHE_KEY, useCache} from "@/hooks/web/useCache"; |
|
21 |
import {usePermissionStore} from "@/store/modules/permission"; |
|
22 |
const permissionStore = usePermissionStore() |
|
23 |
const { push } = useRouter() |
|
24 |
|
|
25 |
defineOptions({ name: 'Home2' }) |
|
26 |
|
|
27 |
const { wsCache } = useCache() |
|
28 |
|
|
29 |
const loading = ref(true) |
|
30 |
let appList = reactive<Apps[]>([]) |
|
31 |
|
|
32 |
const getAppList = async () => { |
|
33 |
const data = await AppApi.getAppList() |
|
34 |
console.log(data) |
|
35 |
appList = Object.assign(appList, data) |
|
36 |
} |
|
37 |
|
|
38 |
const getAllApi = async () => { |
|
39 |
await Promise.all([ |
|
40 |
getAppList() |
|
41 |
]) |
|
42 |
loading.value = false |
|
43 |
} |
|
44 |
|
|
45 |
getAllApi() |
|
46 |
|
|
47 |
// 进入应用 |
|
48 |
const gotoApp = async (app) => { |
|
49 |
if(app.appType == 1) { |
|
50 |
|
|
51 |
} else { |
|
52 |
const data = await AppApi.getAppMenuList(app) |
|
53 |
let data2 = [{ |
|
54 |
path: '/', |
|
55 |
redirect: '/home', |
|
56 |
name: 'Index', |
|
57 |
meta: { |
|
58 |
hidden: true, |
|
59 |
breadcrumb: false |
|
60 |
} |
|
61 |
}] |
|
62 |
if(data && data.length > 0) { |
|
63 |
data.forEach(item => { |
|
64 |
data2.push(item) |
|
65 |
}) |
|
66 |
} |
|
67 |
wsCache.set(CACHE_KEY.ROLE_ROUTERS, data2) |
|
68 |
let user = wsCache.get('user') |
|
69 |
user.menus = data2 |
|
70 |
wsCache.set('user', user) |
|
71 |
// 后端过滤菜单 |
|
72 |
await permissionStore.generateRoutes() |
|
73 |
push({path: '/home'}) |
|
74 |
} |
|
75 |
} |
|
76 |
|
|
77 |
</script> |
|
78 |
|
|
79 |
<style lang="scss" scoped> |
|
80 |
#app{ |
|
81 |
width: 300px; |
|
82 |
height: 140px; |
|
83 |
display: inline-block; |
|
84 |
background: transparent; |
|
85 |
} |
|
86 |
.card{ |
|
87 |
width: 300px; |
|
88 |
height: 100px; |
|
89 |
padding: 30px; |
|
90 |
text-align: center; |
|
91 |
justify-content: center; |
|
92 |
font-size: 30px; |
|
93 |
font-weight: bolder; |
|
94 |
color: blue; |
|
95 |
background: aliceblue; |
|
96 |
border-radius: 10px; |
|
97 |
} |
|
98 |
</style> |