石墨仪设备 前端仓库
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.

74 lines
1.7 KiB

6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
  1. <script setup lang="ts">
  2. import { useRouter } from "vue-router";
  3. import { exceptionOb } from "./services/httpRequest";
  4. import { createWebSocket, sharedWsUrl } from "./services/socket";
  5. import { onMounted } from "vue";
  6. import { getConfig, getContainerList } from "./services/sysConfig/sysConfig";
  7. import { useSettingStore } from "./stores/setting";
  8. import { getLiquidList } from "./services/liquid/liquidManage";
  9. import { useStatusStore } from "./stores/status";
  10. import { ElMessage } from "element-plus";
  11. import { getUserList } from "./services/user/userManager";
  12. import { useUserStore } from "./stores/user";
  13. const router = useRouter();
  14. const settingStore = useSettingStore();
  15. const statusStore = useStatusStore();
  16. const userStore = useUserStore();
  17. const wsClient = createWebSocket(sharedWsUrl);
  18. wsClient.dataOb.subscribe(data => {
  19. if (data.type === "status") {
  20. statusStore.setStatus(data.data);
  21. } else if (data.type === "warn") {
  22. ElMessage({
  23. message: data.data.msg,
  24. type: "warning",
  25. });
  26. }
  27. });
  28. wsClient.connect();
  29. exceptionOb.subscribe(exp => {
  30. if (exp === "invalidToken") {
  31. router.replace("/login");
  32. }
  33. });
  34. onMounted(() => {
  35. getConfig().then(res => {
  36. if (res.success) {
  37. settingStore.setConfigs(res.data);
  38. }
  39. });
  40. getLiquidList({ pageNum: 1, pageSize: 9999 }).then(res => {
  41. if (res.success) {
  42. settingStore.setLiquidList(res.data.list);
  43. }
  44. });
  45. getContainerList().then(res => {
  46. if (res.success) {
  47. settingStore.setContainerConf(res.data);
  48. }
  49. });
  50. getUserList({ pageNum: 1, pageSize: 9999 }).then(res => {
  51. if (res.success) {
  52. userStore.setUserList(res.data.list);
  53. }
  54. });
  55. });
  56. </script>
  57. <template>
  58. <div>
  59. <router-view></router-view>
  60. </div>
  61. </template>
  62. <style>
  63. html,
  64. body {
  65. margin: 0;
  66. padding: 0;
  67. box-sizing: border-box;
  68. }
  69. </style>