Commit 0ab68841830874772e263b8424329a2a1a8d1a4e
1 parent
f26c363c
debug proxy
Showing
4 changed files
with
42 additions
and
23 deletions
src/layout/header.vue
| @@ -28,11 +28,13 @@ const handleLogout = () => { | @@ -28,11 +28,13 @@ const handleLogout = () => { | ||
| 28 | confirmButtonText: "确认", | 28 | confirmButtonText: "确认", |
| 29 | cancelButtonText: "取消", | 29 | cancelButtonText: "取消", |
| 30 | type: "warning", | 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 | let asyncData = reactive({ | 39 | let asyncData = reactive({ |
| 38 | userInfo: "", | 40 | userInfo: "", |
| @@ -40,9 +42,10 @@ let asyncData = reactive({ | @@ -40,9 +42,10 @@ let asyncData = reactive({ | ||
| 40 | }); | 42 | }); |
| 41 | onMounted(() => { | 43 | onMounted(() => { |
| 42 | asyncData.userInfo = store.family.loginStore().userName; | 44 | asyncData.userInfo = store.family.loginStore().userName; |
| 45 | + asyncData.organizationLogo = store.family.loginStore().organizationLogo; | ||
| 43 | asyncData.isCollapse = computed(() => { | 46 | asyncData.isCollapse = computed(() => { |
| 44 | - return store.family.appStore().isCollapse | ||
| 45 | - }) | 47 | + return store.family.appStore().isCollapse; |
| 48 | + }); | ||
| 46 | }); | 49 | }); |
| 47 | </script> | 50 | </script> |
| 48 | 51 | ||
| @@ -55,7 +58,11 @@ onMounted(() => { | @@ -55,7 +58,11 @@ onMounted(() => { | ||
| 55 | > | 58 | > |
| 56 | <router-link to="/"> | 59 | <router-link to="/"> |
| 57 | <el-image | 60 | <el-image |
| 58 | - :src="globalProperties.$cnliveLogo" | 61 | + :src=" |
| 62 | + asyncData.organizationLogo | ||
| 63 | + ? asyncData.organizationLogo | ||
| 64 | + : globalProperties.$cnliveLogo | ||
| 65 | + " | ||
| 59 | fit="contain" | 66 | fit="contain" |
| 60 | style="height: 40px" | 67 | style="height: 40px" |
| 61 | ></el-image> | 68 | ></el-image> |
| @@ -72,7 +79,9 @@ onMounted(() => { | @@ -72,7 +79,9 @@ onMounted(() => { | ||
| 72 | <div class="right-buttons"> | 79 | <div class="right-buttons"> |
| 73 | <el-button type="text"><router-link to="/">首页</router-link></el-button> | 80 | <el-button type="text"><router-link to="/">首页</router-link></el-button> |
| 74 | <el-button type="text" | 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 | <el-button type="text" @click="handleLogout">退出</el-button> | 86 | <el-button type="text" @click="handleLogout">退出</el-button> |
| 78 | </div> | 87 | </div> |
src/pinia/modules/login.ts
| @@ -57,7 +57,7 @@ const getters = { | @@ -57,7 +57,7 @@ const getters = { | ||
| 57 | } | 57 | } |
| 58 | const actions = { | 58 | const actions = { |
| 59 | setUserInfo(obj: LoginUser) { | 59 | setUserInfo(obj: LoginUser) { |
| 60 | - this.token = obj.token | 60 | + this.token = obj.token? obj.token: this.token |
| 61 | this.organizationId = obj.organizationId? obj.organizationId: obj.oId | 61 | this.organizationId = obj.organizationId? obj.organizationId: obj.oId |
| 62 | this.id = obj.id? obj.id: obj.userId | 62 | this.id = obj.id? obj.id: obj.userId |
| 63 | this.userName = obj.userName | 63 | this.userName = obj.userName |
src/views/dashboard/index.vue
| 1 | <script setup lang="ts"> | 1 | <script setup lang="ts"> |
| 2 | -import { ref } from "vue"; | 2 | +import { ref, onMounted, reactive } from "vue"; |
| 3 | import { propertyList } from "@/api/property"; | 3 | import { propertyList } from "@/api/property"; |
| 4 | import router from "@/router"; | 4 | import router from "@/router"; |
| 5 | import * as store from "@/pinia/index"; | 5 | import * as store from "@/pinia/index"; |
| 6 | const title = ref(import.meta.env.VITE_APP_TITLE).value; | 6 | const title = ref(import.meta.env.VITE_APP_TITLE).value; |
| 7 | +let asyncData = reactive({ | ||
| 8 | + organizationLogo: "", | ||
| 9 | + organizationName: "", | ||
| 10 | +}); | ||
| 7 | propertyList() | 11 | propertyList() |
| 8 | .then((res) => { | 12 | .then((res) => { |
| 9 | console.log(res); | 13 | console.log(res); |
| @@ -11,17 +15,26 @@ propertyList() | @@ -11,17 +15,26 @@ propertyList() | ||
| 11 | .catch((error) => { | 15 | .catch((error) => { |
| 12 | console.log(error); | 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 | </script> | 22 | </script> |
| 16 | 23 | ||
| 17 | <template> | 24 | <template> |
| 18 | <div class="dashboard-container"> | 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 | </div> | 38 | </div> |
| 26 | </template> | 39 | </template> |
| 27 | 40 |
src/views/property/index.vue
| @@ -93,15 +93,12 @@ const handleStatus = async (obj) => { | @@ -93,15 +93,12 @@ const handleStatus = async (obj) => { | ||
| 93 | const handleProxy = (obj) => { | 93 | const handleProxy = (obj) => { |
| 94 | userProxy({ oId: obj.id }).then((res) => { | 94 | userProxy({ oId: obj.id }).then((res) => { |
| 95 | if (res?.data) { | 95 | if (res?.data) { |
| 96 | - console.log("代理成功的回调"); | ||
| 97 | - console.log(res.data); | 96 | + store.family.loginStore().setUserInfo(res?.data?.data); |
| 98 | globalProperties.$message.success("代理成功"); | 97 | globalProperties.$message.success("代理成功"); |
| 99 | getMenu().then(() => { | 98 | getMenu().then(() => { |
| 100 | - console.log("got menu data"); | ||
| 101 | setTimeout(() => { | 99 | setTimeout(() => { |
| 102 | - location.href = '/' | ||
| 103 | - console.log("跳"); | ||
| 104 | - }, 2000); | 100 | + location.href = "/"; |
| 101 | + }, 500); | ||
| 105 | }); | 102 | }); |
| 106 | } else { | 103 | } else { |
| 107 | globalProperties.$message.error("代理失败"); | 104 | globalProperties.$message.error("代理失败"); |