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

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. import { getOreList } from "./services/ore/oreManage";
  14. const router = useRouter();
  15. const settingStore = useSettingStore();
  16. const statusStore = useStatusStore();
  17. const userStore = useUserStore();
  18. const wsClient = createWebSocket(sharedWsUrl);
  19. wsClient.dataOb.subscribe(data => {
  20. if (data.type === "status") {
  21. statusStore.setStatus(data.data);
  22. } else if (data.type === "warn") {
  23. ElMessage({
  24. message: data.data.msg,
  25. type: "warning",
  26. });
  27. } else if (data.type === "crafts") {
  28. console.log("crafts:", data);
  29. } else if (data.type === "container") {
  30. settingStore.setContainerConf(data.data.containerList);
  31. }
  32. });
  33. wsClient.connect();
  34. exceptionOb.subscribe(exp => {
  35. if (exp === "invalidToken") {
  36. router.replace("/login");
  37. }
  38. });
  39. onMounted(() => {
  40. getConfig().then(res => {
  41. if (res.success) {
  42. settingStore.setConfigs(res.data);
  43. }
  44. });
  45. getLiquidList({ pageNum: 1, pageSize: 9999 }).then(res => {
  46. if (res.success) {
  47. settingStore.setLiquidList(res.data.list);
  48. }
  49. });
  50. getContainerList().then(res => {
  51. if (res.success) {
  52. settingStore.setContainerConf(res.data);
  53. }
  54. });
  55. getUserList({ pageNum: 1, pageSize: 9999 }).then(res => {
  56. if (res.success) {
  57. userStore.setUserList(res.data.list);
  58. }
  59. });
  60. getOreList({ pageNum: 1, pageSize: 9999 }).then(res => {
  61. if (res.success) {
  62. settingStore.setOreList(res.data.list);
  63. }
  64. });
  65. });
  66. </script>
  67. <template>
  68. <div>
  69. <router-view></router-view>
  70. </div>
  71. </template>
  72. <style>
  73. html,
  74. body {
  75. margin: 0;
  76. padding: 0;
  77. box-sizing: border-box;
  78. }
  79. </style>