提交 | 用户 | 时间
|
820397
|
1 |
<template> |
H |
2 |
<div> |
effbd8
|
3 |
<h1>IAILAB 平台主页</h1> |
820397
|
4 |
</div> |
effbd8
|
5 |
<el-skeleton :loading="loading" animated> |
H |
6 |
<div id="app" v-for="(item, index) in appList" :key="`dynamics-${index}`"> |
|
7 |
<div class="card" @click="gotoApp(item)"> |
aed8e1
|
8 |
<img :src="item.icon" style="width: 100px; height: 100px"/> |
effbd8
|
9 |
<div> |
aed8e1
|
10 |
{{ item.appName }} |
effbd8
|
11 |
</div> |
H |
12 |
</div> |
|
13 |
</div> |
|
14 |
</el-skeleton> |
|
15 |
|
820397
|
16 |
</template> |
H |
17 |
<script lang="ts" setup> |
effbd8
|
18 |
|
H |
19 |
import * as AppApi from '@/api/system/app' |
|
20 |
import {Apps} from "@/views/Home/types"; |
|
21 |
import {CACHE_KEY, useCache} from "@/hooks/web/useCache"; |
820397
|
22 |
|
H |
23 |
|
aed8e1
|
24 |
defineOptions({name: 'Home'}) |
820397
|
25 |
|
aed8e1
|
26 |
const {wsCache} = useCache() |
effbd8
|
27 |
|
H |
28 |
const loading = ref(true) |
|
29 |
|
|
30 |
let appList = reactive<Apps[]>([]) |
|
31 |
|
|
32 |
const getAppList = async () => { |
|
33 |
const data = await AppApi.getAppList() |
|
34 |
appList = Object.assign(appList, data) |
|
35 |
} |
|
36 |
|
aed8e1
|
37 |
const getAppMenuList = async (id, appCode) => { |
effbd8
|
38 |
const data = await AppApi.getAppMenuList(id) |
H |
39 |
let userInfo = wsCache.get(CACHE_KEY.USER) |
|
40 |
userInfo.menus = data |
|
41 |
wsCache.set(CACHE_KEY.USER, userInfo) |
|
42 |
wsCache.set(CACHE_KEY.ROLE_ROUTERS, data) |
|
43 |
window.location.href = '/plat/index' |
|
44 |
} |
|
45 |
|
|
46 |
const getAllApi = async () => { |
|
47 |
await Promise.all([ |
|
48 |
getAppList() |
|
49 |
]) |
|
50 |
loading.value = false |
|
51 |
} |
|
52 |
|
|
53 |
getAllApi() |
|
54 |
|
|
55 |
// 进入应用 |
|
56 |
const gotoApp = async (item) => { |
aed8e1
|
57 |
let path = window.location.pathname |
H |
58 |
let appName = path.split("/")[0] |
|
59 |
console.log(appName) |
effbd8
|
60 |
let id = item.id |
H |
61 |
let type = item.type |
aed8e1
|
62 |
let appCode = item.appCode |
H |
63 |
if (type === 0) { |
|
64 |
await getAppMenuList(id, appCode) |
effbd8
|
65 |
} else { |
844cbf
|
66 |
const data = await AppApi.getAppMenuList(id) |
H |
67 |
let userInfo = wsCache.get(CACHE_KEY.USER) |
|
68 |
userInfo.menus = data |
|
69 |
wsCache.set(CACHE_KEY.USER, userInfo) |
|
70 |
wsCache.set(CACHE_KEY.ROLE_ROUTERS, data) |
|
71 |
window.open(item.appDomain + '/index', '_blank') |
aed8e1
|
72 |
// window.open('/plat/shasteel', '_blank') |
H |
73 |
// window.location.href = '/plat/shasteel' |
|
74 |
// window.location.href = `/plat/shasteel?key=energy&url=http://localhost:9000&energy=/energy/demo` |
effbd8
|
75 |
} |
H |
76 |
} |
820397
|
77 |
|
H |
78 |
</script> |
effbd8
|
79 |
|
H |
80 |
<style lang="scss" scoped> |
aed8e1
|
81 |
#app { |
effbd8
|
82 |
width: 300px; |
H |
83 |
height: 200px; |
|
84 |
display: inline-block; |
|
85 |
background: transparent; |
|
86 |
} |
aed8e1
|
87 |
|
H |
88 |
.card { |
effbd8
|
89 |
border: thin dashed gainsboro; |
H |
90 |
width: 150px; |
|
91 |
height: 120px; |
|
92 |
padding: 30px; |
|
93 |
text-align: center; |
|
94 |
justify-content: center; |
|
95 |
font-size: 15px; |
|
96 |
font-weight: bolder; |
|
97 |
color: blue; |
|
98 |
background: aliceblue; |
|
99 |
border-radius: 10px; |
|
100 |
} |
|
101 |
</style> |