From ebc552900444d25b1158bf53d07f24c9ee36cc75 Mon Sep 17 00:00:00 2001 From: liriming <1343021927@qq.com> Date: 星期一, 20 一月 2025 14:40:57 +0800 Subject: [PATCH] 预警配置 --- src/views/Home/Index.vue | 93 +++++++++++++++++++++++++++++++++++++++++++++- 1 files changed, 91 insertions(+), 2 deletions(-) diff --git a/src/views/Home/Index.vue b/src/views/Home/Index.vue index b824385..822f800 100644 --- a/src/views/Home/Index.vue +++ b/src/views/Home/Index.vue @@ -1,12 +1,101 @@ <template> <div> - <h1>这里是应用首页</h1> + <h1>IAILAB 平台主页</h1> </div> + <el-skeleton :loading="loading" animated> + <div id="app" v-for="(item, index) in appList" :key="`dynamics-${index}`"> + <div class="card" @click="gotoApp(item)"> + <img :src="item.icon" style="width: 100px; height: 100px"/> + <div> + {{ item.appName }} + </div> + </div> + </div> + </el-skeleton> + </template> <script lang="ts" setup> +import * as AppApi from '@/api/system/app' +import {Apps} from "@/views/Home/types"; +import {CACHE_KEY, useCache} from "@/hooks/web/useCache"; -defineOptions({ name: 'Home' }) +defineOptions({name: 'Home'}) + +const {wsCache} = useCache() + +const loading = ref(true) + +let appList = reactive<Apps[]>([]) + +const getAppList = async () => { + const data = await AppApi.getAppList() + appList = Object.assign(appList, data) +} + +const getAppMenuList = async (id, appCode) => { + const data = await AppApi.getAppMenuList(id) + let userInfo = wsCache.get(CACHE_KEY.USER) + userInfo.menus = data + wsCache.set(CACHE_KEY.USER, userInfo) + wsCache.set(CACHE_KEY.ROLE_ROUTERS, data) + window.location.href = '/plat/index' +} + +const getAllApi = async () => { + await Promise.all([ + getAppList() + ]) + loading.value = false +} + +getAllApi() + +// 进入应用 +const gotoApp = async (item) => { + let path = window.location.pathname + let appName = path.split("/")[0] + console.log(appName) + let id = item.id + let type = item.type + let appCode = item.appCode + if (type === 0) { + await getAppMenuList(id, appCode) + } else { + const data = await AppApi.getAppMenuList(id) + let userInfo = wsCache.get(CACHE_KEY.USER) + userInfo.menus = data + wsCache.set(CACHE_KEY.USER, userInfo) + wsCache.set(CACHE_KEY.ROLE_ROUTERS, data) + window.open(item.appDomain + '/index', '_blank') + // window.open('/plat/shasteel', '_blank') + // window.location.href = '/plat/shasteel' + // window.location.href = `/plat/shasteel?key=energy&url=http://localhost:9000&energy=/energy/demo` + } +} </script> + +<style lang="scss" scoped> +#app { + width: 300px; + height: 200px; + display: inline-block; + background: transparent; +} + +.card { + border: thin dashed gainsboro; + width: 150px; + height: 120px; + padding: 30px; + text-align: center; + justify-content: center; + font-size: 15px; + font-weight: bolder; + color: blue; + background: aliceblue; + border-radius: 10px; +} +</style> -- Gitblit v1.9.3