提交 | 用户 | 时间
|
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)"> |
|
8 |
<img :src="item.icon" style="width: 100px; height: 100px" /> |
|
9 |
<div> |
|
10 |
{{item.appName}} |
|
11 |
</div> |
|
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"; |
|
22 |
import * as authUtil from "@/utils/auth"; |
820397
|
23 |
|
H |
24 |
|
|
25 |
defineOptions({ name: 'Home' }) |
|
26 |
|
effbd8
|
27 |
const { wsCache } = useCache() |
H |
28 |
|
|
29 |
const loading = ref(true) |
|
30 |
|
|
31 |
let appList = reactive<Apps[]>([]) |
|
32 |
|
|
33 |
const getAppList = async () => { |
|
34 |
const data = await AppApi.getAppList() |
|
35 |
appList = Object.assign(appList, data) |
|
36 |
} |
|
37 |
|
|
38 |
const getAppMenuList = async (id) => { |
|
39 |
const data = await AppApi.getAppMenuList(id) |
|
40 |
let userInfo = wsCache.get(CACHE_KEY.USER) |
|
41 |
userInfo.menus = data |
|
42 |
wsCache.set(CACHE_KEY.USER, userInfo) |
|
43 |
wsCache.set(CACHE_KEY.ROLE_ROUTERS, data) |
|
44 |
window.location.href = '/plat/index' |
|
45 |
} |
|
46 |
|
|
47 |
const getAllApi = async () => { |
|
48 |
await Promise.all([ |
|
49 |
getAppList() |
|
50 |
]) |
|
51 |
loading.value = false |
|
52 |
} |
|
53 |
|
|
54 |
getAllApi() |
|
55 |
|
|
56 |
// 进入应用 |
|
57 |
const gotoApp = async (item) => { |
|
58 |
let id = item.id |
|
59 |
let type = item.type |
|
60 |
if(type === 0) { |
|
61 |
getAppMenuList(id) |
|
62 |
} else { |
844cbf
|
63 |
const data = await AppApi.getAppMenuList(id) |
H |
64 |
let userInfo = wsCache.get(CACHE_KEY.USER) |
|
65 |
userInfo.menus = data |
|
66 |
wsCache.set(CACHE_KEY.USER, userInfo) |
|
67 |
wsCache.set(CACHE_KEY.ROLE_ROUTERS, data) |
effbd8
|
68 |
// await OAuth2Login(formData.value) |
844cbf
|
69 |
// window.open(item.appDomain + '/login?appid=' + item.id + "&username=" + authUtil.getLoginForm().username, '_blank') |
H |
70 |
window.open(item.appDomain + '/index', '_blank') |
effbd8
|
71 |
} |
H |
72 |
} |
820397
|
73 |
|
H |
74 |
</script> |
effbd8
|
75 |
|
H |
76 |
<style lang="scss" scoped> |
|
77 |
#app{ |
|
78 |
width: 300px; |
|
79 |
height: 200px; |
|
80 |
display: inline-block; |
|
81 |
background: transparent; |
|
82 |
} |
|
83 |
.card{ |
|
84 |
border: thin dashed gainsboro; |
|
85 |
width: 150px; |
|
86 |
height: 120px; |
|
87 |
padding: 30px; |
|
88 |
text-align: center; |
|
89 |
justify-content: center; |
|
90 |
font-size: 15px; |
|
91 |
font-weight: bolder; |
|
92 |
color: blue; |
|
93 |
background: aliceblue; |
|
94 |
border-radius: 10px; |
|
95 |
} |
|
96 |
</style> |