From 707b181c171822306422d22da633d4c7eca7c3cd Mon Sep 17 00:00:00 2001 From: haha Date: Fri, 5 Jul 2024 01:08:49 +0800 Subject: [PATCH] update code --- .env.production | 2 +- .../state/{publish.png => download.png} | Bin public/images/state/{free.png => idle.png} | Bin .../state/{inferencing.png => infer.png} | Bin .../images/state/{training.png => train.png} | Bin .../images/state/{noreg.png => unregist.png} | Bin .../state/{updating.png => upgrade.png} | Bin src/api/device/index.js | 2 +- src/api/info/index.js | 11 + src/utils/request.ts | 3 + src/views/dashboard/index.vue | 505 ++++++++++-------- tsconfig.json | 1 + 12 files changed, 294 insertions(+), 230 deletions(-) rename public/images/state/{publish.png => download.png} (100%) rename public/images/state/{free.png => idle.png} (100%) rename public/images/state/{inferencing.png => infer.png} (100%) rename public/images/state/{training.png => train.png} (100%) rename public/images/state/{noreg.png => unregist.png} (100%) rename public/images/state/{updating.png => upgrade.png} (100%) create mode 100644 src/api/info/index.js diff --git a/.env.production b/.env.production index 8aca6a6..48df29a 100644 --- a/.env.production +++ b/.env.production @@ -1,3 +1,3 @@ # 代理前缀 -VITE_APP_BASE_API = '/dev-api' +VITE_APP_BASE_API = '/mk/ai/api/' diff --git a/public/images/state/publish.png b/public/images/state/download.png similarity index 100% rename from public/images/state/publish.png rename to public/images/state/download.png diff --git a/public/images/state/free.png b/public/images/state/idle.png similarity index 100% rename from public/images/state/free.png rename to public/images/state/idle.png diff --git a/public/images/state/inferencing.png b/public/images/state/infer.png similarity index 100% rename from public/images/state/inferencing.png rename to public/images/state/infer.png diff --git a/public/images/state/training.png b/public/images/state/train.png similarity index 100% rename from public/images/state/training.png rename to public/images/state/train.png diff --git a/public/images/state/noreg.png b/public/images/state/unregist.png similarity index 100% rename from public/images/state/noreg.png rename to public/images/state/unregist.png diff --git a/public/images/state/updating.png b/public/images/state/upgrade.png similarity index 100% rename from public/images/state/updating.png rename to public/images/state/upgrade.png diff --git a/src/api/device/index.js b/src/api/device/index.js index d834350..6890dbe 100644 --- a/src/api/device/index.js +++ b/src/api/device/index.js @@ -2,7 +2,7 @@ import request from "@/utils/request"; const getStatus=()=>{ return request({ - url:'/devices/status', + url:'/devices/status/detail', method:'get' }) } diff --git a/src/api/info/index.js b/src/api/info/index.js new file mode 100644 index 0000000..f051e8b --- /dev/null +++ b/src/api/info/index.js @@ -0,0 +1,11 @@ +import request from "@/utils/request"; +const statistics=()=>{ + return request({ + url: "/info/statistics", + method: "get" + }); +} + +export default { + statistics +} \ No newline at end of file diff --git a/src/utils/request.ts b/src/utils/request.ts index 9b37d50..0b72fea 100644 --- a/src/utils/request.ts +++ b/src/utils/request.ts @@ -35,6 +35,9 @@ service.interceptors.response.use( return response; } + if(true){ + return response; + } const { code, data, msg } = response.data; if (code === ResultEnum.SUCCESS) { return data; diff --git a/src/views/dashboard/index.vue b/src/views/dashboard/index.vue index 747c621..77b2838 100644 --- a/src/views/dashboard/index.vue +++ b/src/views/dashboard/index.vue @@ -1,112 +1,115 @@ @@ -116,80 +119,90 @@ import ModelFlow from './components/ModelFlow.vue' import IndexNotice from './components/IndexNotice.vue' import ServiceStatus from './components/ServiceStatus.vue' import DeviceAPI from "@/api/device"; -let svTemp=ref(55.5) -let rd=()=>{ return +(""+Math.random()).substring(3,5)}; -let rd2=()=>{ return +(""+Math.random()).substring(3,4)}; -let topInfos = reactive([ - { title: '模型总数', count: rd(),ucnt:rd2(), clsName: 'c1', icon: "images/nav/nav1.png" }, - { title: '算子总数', count: rd(), ucnt:rd2(),clsName: 'c1', icon: "images/nav/nav2.png" }, - { title: '数据集总数', count: rd(), ucnt:rd2(),clsName: 'c1', icon: "images/nav/nav3.png" }, - { title: '评估报告总数', count: rd(),ucnt:rd2(), clsName: 'c1', icon: "images/nav/nav4.png" }, - { title: '互联总数', count: rd(), ucnt:rd2(),clsName: 'c1', icon: "images/nav/nav5.png" }, - { title: '总访问量', count: rd(), ucnt:rd2(),clsName: 'c1', icon: "images/nav/nav1.png" }, -]); +import InfoApi from '@/api/info' -let devInfos = reactive([ - { id: 1001, name: '设备名称1', netType: 'network001', modelName: '模型名称', state: 'offline', temperature:rd() , memory: rd(), cpu:rd() }, - { id: 1002, name: '设备名称2', netType: 'network001', modelName: '模型名称', state: 'compile', temperature:rd() , memory: rd(), cpu:rd() }, - { id: 1003, name: '设备名称3', netType: 'network001', modelName: '模型名称', state: 'free', temperature:rd() , memory: rd(), cpu:rd() }, - { id: 1004, name: '设备名称4', netType: 'network001', modelName: '模型名称', state: 'inferencing', temperature:rd() , memory: rd(), cpu:rd() }, - { id: 1005, name: '设备名称5', netType: 'network001', modelName: '模型名称', state: 'noreg', temperature:rd() , memory: rd(), cpu:rd() }, - { id: 1006, name: '设备名称6', netType: 'network001', modelName: '模型名称', state: 'publish', temperature:rd() , memory: rd(), cpu:rd() }, - { id: 1007, name: '设备名称1', netType: 'network001', modelName: '模型名称', state: 'training', temperature:rd() , memory: rd(), cpu:rd() }, - { id: 1008, name: '设备名称2', netType: 'network001', modelName: '模型名称', state: 'updating', temperature:rd() , memory: rd(), cpu:rd() }, - { id: 1009, name: '设备名称3', netType: 'network001', modelName: '模型名称', state: 'offline', temperature:rd() , memory: rd(), cpu:rd() }, - { id: 1010, name: '设备名称4', netType: 'network001', modelName: '模型名称', state: 'training', temperature:rd() , memory: rd(), cpu:rd() }, - { id: 1011, name: '设备名称5', netType: 'network001', modelName: '模型名称', state: 'training', temperature:rd() , memory: rd(), cpu:rd() }, - { id: 1012, name: '设备名称6', netType: 'network001', modelName: '模型名称', state: 'training', temperature:rd() , memory: rd(), cpu:rd() }, -]) -const winWidth=ref(0) -const isSmallScreen=computed(()=>{ - return winWidth.value<1440; +let svTemp = ref(55.5) +let rd = () => { return +("" + Math.random()).substring(3, 5) }; +let rd2 = () => { return +("" + Math.random()).substring(3, 4) }; +let topInfos = ref(null); + + +let devInfos = ref(null) +/* +[ + { id: 1001, name: '设备名称1', netType: 'network001', modelName: '模型名称', state: 'offline', temperature: rd(), memory: rd(), cpu: rd() }, + { id: 1002, name: '设备名称2', netType: 'network001', modelName: '模型名称', state: 'compile', temperature: rd(), memory: rd(), cpu: rd() }, + { id: 1003, name: '设备名称3', netType: 'network001', modelName: '模型名称', state: 'free', temperature: rd(), memory: rd(), cpu: rd() }, + { id: 1004, name: '设备名称4', netType: 'network001', modelName: '模型名称', state: 'inferencing', temperature: rd(), memory: rd(), cpu: rd() }, + { id: 1005, name: '设备名称5', netType: 'network001', modelName: '模型名称', state: 'noreg', temperature: rd(), memory: rd(), cpu: rd() }, + { id: 1006, name: '设备名称6', netType: 'network001', modelName: '模型名称', state: 'publish', temperature: rd(), memory: rd(), cpu: rd() }, + { id: 1007, name: '设备名称1', netType: 'network001', modelName: '模型名称', state: 'training', temperature: rd(), memory: rd(), cpu: rd() }, + { id: 1008, name: '设备名称2', netType: 'network001', modelName: '模型名称', state: 'updating', temperature: rd(), memory: rd(), cpu: rd() }, + { id: 1009, name: '设备名称3', netType: 'network001', modelName: '模型名称', state: 'offline', temperature: rd(), memory: rd(), cpu: rd() }, + { id: 1010, name: '设备名称4', netType: 'network001', modelName: '模型名称', state: 'training', temperature: rd(), memory: rd(), cpu: rd() }, + { id: 1011, name: '设备名称5', netType: 'network001', modelName: '模型名称', state: 'training', temperature: rd(), memory: rd(), cpu: rd() }, + { id: 1012, name: '设备名称6', netType: 'network001', modelName: '模型名称', state: 'training', temperature: rd(), memory: rd(), cpu: rd() }, +]*/ +const winWidth = ref(0) +const isSmallScreen = computed(() => { + return winWidth.value < 1440; }); -const getState=(e:any)=>{ - if(e=="offline"){ +const getState = (e: any) => { + if (e == "offline") { return "离线"; } - if(e=="compile"){ + if (e == "compile") { return "编译中"; } - if(e=="free"){ + if (e == "idle") { return "空闲"; } - if(e=="inferencing"){ + if (e == "infer") { return "推理中"; } - if(e=="noreg"){ + if (e == "unregist") { return "未注册"; } - if(e=="publish"){ + if (e == "download") { return "部署中"; } - if(e=="training"){ + if (e == "train") { return "训练中"; } - - return "升级中"; + + return "升级中"; } -onMounted(()=>{ - winWidth.value=window.outerWidth; - window.onresize=()=>{ - setTimeout(()=>{ - winWidth.value=window.outerWidth; - },100); +onMounted(() => { + winWidth.value = window.outerWidth; + window.onresize = () => { + setTimeout(() => { + winWidth.value = window.outerWidth; + }, 100); } - DeviceAPI.getStatus().then(d=>{ - debugger; + DeviceAPI.getStatus().then(d => { + devInfos.value=d.data.data.device_status_list||[]; }); + InfoApi.statistics().then(d => { + topInfos.value = [ + { title: '模型总数', count: d.data.total_model_count, ucnt: d.data.user_model_count, clsName: 'c1', icon: "images/nav/nav1.png" }, + { title: '算子总数', count: d.data.total_operator_count, ucnt: d.data.user_operator_count, clsName: 'c1', icon: "images/nav/nav2.png" }, + { title: '数据集总数', count: d.data.total_dataset_count, ucnt: d.data.user_dataset_count, clsName: 'c1', icon: "images/nav/nav3.png" }, + { title: '评估报告总数', count: d.data.total_connection_count, ucnt: d.data.user_connection_count, clsName: 'c1', icon: "images/nav/nav4.png" }, + { title: '互联总数', count: d.data.total_task_count, ucnt: d.data.user_task_count, clsName: 'c1', icon: "images/nav/nav5.png" }, + { title: '总访问量', count: d.data.total_visit_count, ucnt: d.data.user_visit_count, clsName: 'c1', icon: "images/nav/nav1.png" }, + ]; + + }) });