Skip to content

Commit

Permalink
前端状态数据修复 (#207)
Browse files Browse the repository at this point in the history
前端状态数据修复
样式修复

Co-authored-by: jinnrry <[email protected]>
  • Loading branch information
Jinnrry and Jinnrry authored Sep 24, 2024
1 parent f137d59 commit b192680
Show file tree
Hide file tree
Showing 5 changed files with 206 additions and 43 deletions.
4 changes: 3 additions & 1 deletion fe/src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,11 @@ import HomeAside from '@/components/HomeAside.vue';
import {ref, watch} from 'vue'
const route = useRoute()
const pageName = ref(route.name)
watch(
() => route.fullPath,
() => {
Expand Down
19 changes: 5 additions & 14 deletions fe/src/components/HomeHeader.vue
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<template>
<div id="header_main">
<div id="logo">
<router-link to="/" style="text-underline: none">
<el-text :line-clamp="1" size="large"><h1>Pmail</h1></el-text>
<router-link to="/" style="text-decoration: none">
<el-text :line-clamp="1" size="large"><h1>PMail</h1></el-text>
</router-link>
</div>
<div id="settings" @click="settings" v-if="isLogin">
Expand Down Expand Up @@ -41,14 +41,12 @@
<script setup>
import {TbSettings} from "vue-icons-plus/tb";
import {ref} from 'vue'
import {ElMessage} from 'element-plus'
import SecuritySettings from '@/components/SecuritySettings.vue'
import lang from '../i18n/i18n';
import GroupSettings from './GroupSettings.vue';
import RuleSettings from './RuleSettings.vue';
import UserManagement from './UserManagement.vue';
import PluginSettings from './PluginSettings.vue';
import {http} from "@/utils/axios";
import {useGlobalStatusStore} from "@/stores/useGlobalStatusStore";
const globalStatus = useGlobalStatusStore();
Expand All @@ -59,16 +57,9 @@ const userInfos = globalStatus.userInfos;
const openSettings = ref(false)
const settings = function () {
if (Object.keys(userInfos).length === 0) {
http.post("/api/user/info", {}).then(res => {
if (res.errorNo === 0) {
userInfos.value = res.data
openSettings.value = true;
} else {
ElMessage({
type: 'error',
message: res.errorMsg,
})
}
globalStatus.init(()=>{
Object.assign(userInfos,globalStatus.userInfos)
openSettings.value = true;
})
} else {
openSettings.value = true;
Expand Down
23 changes: 19 additions & 4 deletions fe/src/stores/useGlobalStatusStore.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,29 @@
import {defineStore} from "pinia";
import {http} from "@/utils/axios";

const useGlobalStatusStore = defineStore('useGlobalStatusStore', {
state() {
return {
isLogin: true,
userInfos:{}
userInfos: {}
}
},
getters: {},
actions: {}
getters: {
isLogin(state) {
return Object.keys(state.userInfos) !== 0
}
},
actions: {
init(callback) {
let that = this
http.post("/api/user/info", {}).then(res => {
if (res.errorNo === 0) {
Object.assign(that.userInfos, res.data)
console.log("userInfos")
callback()
}
})
}
}
})


Expand Down
39 changes: 15 additions & 24 deletions fe/src/views/EditerView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<div style="display: flex; flex-direction:column;">
<div style=" margin-bottom: 10px;">
<el-form-item :label="lang.sender" prop="sender">
<el-input style="max-width: 200px" :disabled="!userInfos.is_admin"
<el-input style="max-width: 200px" :disabled="!(globalStatus.userInfos.is_admin)"
v-model="ruleForm.sender" :placeholder="lang.sender_desc"/>
<div>@</div>
<el-select v-model="ruleForm.pickDomain">
Expand Down Expand Up @@ -124,7 +124,6 @@ const router = useRouter();
const groupStore = useGroupStore()
const globalStatus = useGlobalStatusStore();
const userInfos = globalStatus.userInfos
if (lang.lang === "zhCn") {
i18nChangeLanguage('zh-CN')
Expand Down Expand Up @@ -162,28 +161,20 @@ const fileList = reactive([]);
const init = function () {
if (Object.keys(userInfos.value).length === 0) {
http.post("/api/user/info", {}).then(res => {
if (res.errorNo === 0) {
userInfos.value = res.data
ruleForm.sender = res.data.account
ruleForm.domains = res.data.domains
ruleForm.pickDomain = res.data.domains[0]
ruleForm.nickName = res.data.name
} else {
ElMessage({
type: 'error',
message: res.errorMsg,
})
}
})
} else {
ruleForm.sender = userInfos.value.account
ruleForm.domains = userInfos.value.domains
ruleForm.pickDomain = userInfos.value.domains[0]
ruleForm.nickName = userInfos.value.name
}
if ( Object.keys(globalStatus.userInfos)==0 || globalStatus.userInfos === null || globalStatus.userInfos == undefined ){
globalStatus.init(()=>{
ruleForm.sender = globalStatus.userInfos.account
ruleForm.domains = globalStatus.userInfos.domains
ruleForm.pickDomain = globalStatus.userInfos.domains[0]
ruleForm.nickName = globalStatus.userInfos.name
})
}else{
console.log(globalStatus.userInfos)
ruleForm.sender = globalStatus.userInfos.account
ruleForm.domains = globalStatus.userInfos.domains
ruleForm.pickDomain = globalStatus.userInfos.domains[0]
ruleForm.nickName = globalStatus.userInfos.name
}
}
init()
Expand Down
Loading

0 comments on commit b192680

Please sign in to comment.