石墨仪设备 前端仓库
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

84 lines
2.1 KiB

<script setup lang="ts">
import { useRouter } from "vue-router";
import { exceptionOb } from "./services/httpRequest";
import { createWebSocket, sharedWsUrl } from "./services/socket";
import { onMounted } from "vue";
import { getConfig, getContainerList } from "./services/sysConfig/sysConfig";
import { useSettingStore } from "./stores/setting";
import { getLiquidList } from "./services/liquid/liquidManage";
import { useStatusStore } from "./stores/status";
import { ElMessage } from "element-plus";
import { getUserList } from "./services/user/userManager";
import { useUserStore } from "./stores/user";
import { getOreList } from "./services/ore/oreManage";
const router = useRouter();
const settingStore = useSettingStore();
const statusStore = useStatusStore();
const userStore = useUserStore();
const wsClient = createWebSocket(sharedWsUrl);
wsClient.dataOb.subscribe(data => {
if (data.type === "status") {
statusStore.setStatus(data.data);
} else if (data.type === "warn") {
ElMessage({
message: data.data.msg,
type: "warning",
});
} else if (data.type === "crafts") {
console.log("crafts:", data);
} else if (data.type === "container") {
settingStore.setContainerConf(data.data.containerList);
}
});
wsClient.connect();
exceptionOb.subscribe(exp => {
if (exp === "invalidToken") {
router.replace("/login");
}
});
onMounted(() => {
getConfig().then(res => {
if (res.success) {
settingStore.setConfigs(res.data);
}
});
getLiquidList({ pageNum: 1, pageSize: 9999 }).then(res => {
if (res.success) {
settingStore.setLiquidList(res.data.list);
}
});
getContainerList().then(res => {
if (res.success) {
settingStore.setContainerConf(res.data);
}
});
getUserList({ pageNum: 1, pageSize: 9999 }).then(res => {
if (res.success) {
userStore.setUserList(res.data.list);
}
});
getOreList({ pageNum: 1, pageSize: 9999 }).then(res => {
if (res.success) {
settingStore.setOreList(res.data.list);
}
});
});
</script>
<template>
<div>
<router-view></router-view>
</div>
</template>
<style>
html,
body {
margin: 0;
padding: 0;
box-sizing: border-box;
}
</style>