add cache for getting user info and system configs

This commit is contained in:
RockYang
2024-08-08 14:37:33 +08:00
parent 7a11a9ef15
commit e54e908fbc
36 changed files with 185 additions and 110 deletions

View File

@@ -16,6 +16,7 @@
import {ref} from "vue";
import {httpGet} from "@/utils/http";
import {showMessageError} from "@/utils/dialog";
import {getLicenseInfo, getSystemInfo} from "@/store/cache";
const title = ref("")
const version = ref(process.env.VUE_APP_VERSION)
@@ -30,14 +31,14 @@ const props = defineProps({
});
// 获取系统配置
httpGet("/api/config/get?key=system").then(res => {
getSystemInfo().then(res => {
title.value = res.data.title??process.env.VUE_APP_TITLE
copyRight.value = res.data.copyright.length>1?res.data.copyright:'极客学长 © 2023 - '+new Date().getFullYear()+' All rights reserved.'
}).catch(e => {
showMessageError("获取系统配置失败:" + e.message)
})
httpGet("/api/config/license").then(res => {
getLicenseInfo().then(res => {
license.value = res.data
}).catch(e => {
showMessageError("获取 License 失败:" + e.message)

View File

@@ -221,14 +221,15 @@
</template>
<script setup>
import {nextTick, onUnmounted, ref, watch} from "vue"
import {httpGet, httpPost} from "@/utils/http";
import {ref, watch} from "vue"
import {httpPost} from "@/utils/http";
import {ElMessage} from "element-plus";
import {setUserToken} from "@/store/session";
import {validateEmail, validateMobile} from "@/utils/validate";
import {Checked, Close, Iphone, Lock, Message} from "@element-plus/icons-vue";
import SendMsg from "@/components/SendMsg.vue";
import {arrayContains} from "@/utils/libs";
import {getSystemInfo} from "@/store/cache";
// eslint-disable-next-line no-undef
const props = defineProps({
@@ -256,7 +257,7 @@ const wxImg = ref("/images/wx.png")
// eslint-disable-next-line no-undef
const emits = defineEmits(['hide', 'success']);
httpGet("/api/config/get?key=system").then(res => {
getSystemInfo().then(res => {
if (res.data) {
const registerWays = res.data['register_ways']
if (arrayContains(registerWays, "mobile")) {

View File

@@ -50,7 +50,7 @@ import {ElMessage} from "element-plus";
import {Plus} from "@element-plus/icons-vue";
import Compressor from "compressorjs";
import {dateFormat} from "@/utils/libs";
import {checkSession} from "@/action/session";
import {checkSession} from "@/store/cache";
const user = ref({
vip: false,

View File

@@ -56,8 +56,8 @@
<script setup>
import {onMounted, ref} from "vue";
import {httpGet} from "@/utils/http";
import {ElMessage} from "element-plus";
import {getSystemInfo} from "@/store/cache";
const title = ref(process.env.VUE_APP_TITLE)
const version = ref(process.env.VUE_APP_VERSION)
@@ -99,7 +99,7 @@ const capabilities = ref([
])
onMounted(() => {
httpGet("/api/config/get?key=system").then(res => {
getSystemInfo().then(res => {
title.value = res.data.title
}).catch(e => {
ElMessage.error("获取系统配置失败:" + e.message)

View File

@@ -36,7 +36,7 @@
import {useTagsStore} from '@/store/tags';
import {onBeforeRouteUpdate, useRoute, useRouter} from 'vue-router';
import {ArrowDown, Close} from "@element-plus/icons-vue";
import {checkAdminSession} from "@/action/session";
import {checkAdminSession} from "@/store/cache";
import {ElMessageBox} from "element-plus";
import {computed} from "vue";