Commit 0ab68841830874772e263b8424329a2a1a8d1a4e

Authored by 杨泽宇
1 parent f26c363c

debug proxy

src/layout/header.vue
... ... @@ -28,11 +28,13 @@ const handleLogout = () => {
28 28 confirmButtonText: "确认",
29 29 cancelButtonText: "取消",
30 30 type: "warning",
31   - }).then(() => {
32   - store.family.loginStore().removeToken();
33   - }).catch(error => {
34   - console.log(error)
35 31 })
  32 + .then(() => {
  33 + store.family.loginStore().removeToken();
  34 + })
  35 + .catch((error) => {
  36 + console.log(error);
  37 + });
36 38 };
37 39 let asyncData = reactive({
38 40 userInfo: "",
... ... @@ -40,9 +42,10 @@ let asyncData = reactive({
40 42 });
41 43 onMounted(() => {
42 44 asyncData.userInfo = store.family.loginStore().userName;
  45 + asyncData.organizationLogo = store.family.loginStore().organizationLogo;
43 46 asyncData.isCollapse = computed(() => {
44   - return store.family.appStore().isCollapse
45   - })
  47 + return store.family.appStore().isCollapse;
  48 + });
46 49 });
47 50 </script>
48 51  
... ... @@ -55,7 +58,11 @@ onMounted(() =&gt; {
55 58 >
56 59 <router-link to="/">
57 60 <el-image
58   - :src="globalProperties.$cnliveLogo"
  61 + :src="
  62 + asyncData.organizationLogo
  63 + ? asyncData.organizationLogo
  64 + : globalProperties.$cnliveLogo
  65 + "
59 66 fit="contain"
60 67 style="height: 40px"
61 68 ></el-image>
... ... @@ -72,7 +79,9 @@ onMounted(() =&gt; {
72 79 <div class="right-buttons">
73 80 <el-button type="text"><router-link to="/">首页</router-link></el-button>
74 81 <el-button type="text"
75   - >当前用户:<b>{{ asyncData.userInfo? asyncData.userInfo: '超级管理员' }}</b></el-button
  82 + >当前用户:<b>{{
  83 + asyncData.userInfo ? asyncData.userInfo : "超级管理员"
  84 + }}</b></el-button
76 85 >
77 86 <el-button type="text" @click="handleLogout">退出</el-button>
78 87 </div>
... ...
src/pinia/modules/login.ts
... ... @@ -57,7 +57,7 @@ const getters = {
57 57 }
58 58 const actions = {
59 59 setUserInfo(obj: LoginUser) {
60   - this.token = obj.token
  60 + this.token = obj.token? obj.token: this.token
61 61 this.organizationId = obj.organizationId? obj.organizationId: obj.oId
62 62 this.id = obj.id? obj.id: obj.userId
63 63 this.userName = obj.userName
... ...
src/views/dashboard/index.vue
1 1 <script setup lang="ts">
2   -import { ref } from "vue";
  2 +import { ref, onMounted, reactive } from "vue";
3 3 import { propertyList } from "@/api/property";
4 4 import router from "@/router";
5 5 import * as store from "@/pinia/index";
6 6 const title = ref(import.meta.env.VITE_APP_TITLE).value;
  7 +let asyncData = reactive({
  8 + organizationLogo: "",
  9 + organizationName: "",
  10 +});
7 11 propertyList()
8 12 .then((res) => {
9 13 console.log(res);
... ... @@ -11,17 +15,26 @@ propertyList()
11 15 .catch((error) => {
12 16 console.log(error);
13 17 });
14   -console.log(router.getRoutes());
  18 +onMounted(() => {
  19 + asyncData.organizationLogo = store.family.loginStore().organizationLogo;
  20 + asyncData.organizationName = store.family.loginStore().organizationName;
  21 +});
15 22 </script>
16 23  
17 24 <template>
18 25 <div class="dashboard-container">
19   - <div class="dashboard-logo"></div>
20   - <h1>欢迎访问 -- {{ store.family.loginStore().organizationName? store.family.loginStore().organizationName: title }}</h1>
21   - <!-- {{ store.family }}
22   - {{ store.family.menuStore() }} -->
23   - <!-- {{ store.family.loginStore().organizationName }}
24   - {{ store.family.loginStore().oName }} -->
  26 + <img
  27 + :src="
  28 + asyncData.organizationLogo
  29 + ? asyncData.organizationLogo
  30 + : '@/assets/logo.png'
  31 + "
  32 + height="200"
  33 + />
  34 + <h1>
  35 + 欢迎访问 --
  36 + {{ asyncData.organizationName ? asyncData.organizationName : title }}
  37 + </h1>
25 38 </div>
26 39 </template>
27 40  
... ...
src/views/property/index.vue
... ... @@ -93,15 +93,12 @@ const handleStatus = async (obj) =&gt; {
93 93 const handleProxy = (obj) => {
94 94 userProxy({ oId: obj.id }).then((res) => {
95 95 if (res?.data) {
96   - console.log("代理成功的回调");
97   - console.log(res.data);
  96 + store.family.loginStore().setUserInfo(res?.data?.data);
98 97 globalProperties.$message.success("代理成功");
99 98 getMenu().then(() => {
100   - console.log("got menu data");
101 99 setTimeout(() => {
102   - location.href = '/'
103   - console.log("跳");
104   - }, 2000);
  100 + location.href = "/";
  101 + }, 500);
105 102 });
106 103 } else {
107 104 globalProperties.$message.error("代理失败");
... ...