From ec54ec2607541df79ebf661dc925e00b7a9ef5ad Mon Sep 17 00:00:00 2001 From: jxxghp Date: Thu, 29 Aug 2024 16:15:42 +0800 Subject: [PATCH] login wallpapers cache --- src/api/index.ts | 2 +- src/pages/login.vue | 14 ++++++++-- src/views/setting/AccountSettingAbout.vue | 34 +++++++++++++++-------- 3 files changed, 36 insertions(+), 14 deletions(-) diff --git a/src/api/index.ts b/src/api/index.ts index 4d48d1eb..89b8ba34 100644 --- a/src/api/index.ts +++ b/src/api/index.ts @@ -40,7 +40,7 @@ export default api export async function fetchGlobalSettings() { try { - const result: { [key: string]: any } = await api.get('system/env') + const result: { [key: string]: any } = await api.get('system/global') return result.data || {} } catch (error) { console.error('Failed to fetch global settings', error) diff --git a/src/pages/login.vue b/src/pages/login.vue index 8d3a71e0..1f2bceb5 100644 --- a/src/pages/login.vue +++ b/src/pages/login.vue @@ -15,6 +15,9 @@ const { global: globalTheme } = useTheme() // Vuex Store const store = useStore() +// 从 provide 中获取全局设置 +const globalSettings: any = inject('globalSettings') + // 表单 const form = ref({ username: '', @@ -52,8 +55,15 @@ let intervalTimer: NodeJS.Timeout | null = null // 获取背景图片 async function fetchBackgroundImage() { try { - backgroundImages.value = await api.get('/login/wallpapers') - if (backgroundImages.value && backgroundImages.value.length > 0) { + const results: string[] = await api.get('/login/wallpapers') + if (results && results.length > 0) { + results.map((url: string) => { + if (globalSettings.GLOBAL_IMAGE_CACHE) + backgroundImages.value.push( + `${import.meta.env.VITE_API_BASE_URL}system/cache/image?url=${encodeURIComponent(url)}`, + ) + else backgroundImages.value.push(url) + }) // 随机打乱排序 backgroundImages.value.sort(() => Math.random() - 0.5) backgroundImageUrl.value = backgroundImages.value[0] diff --git a/src/views/setting/AccountSettingAbout.vue b/src/views/setting/AccountSettingAbout.vue index 94f3f0f2..907a9976 100644 --- a/src/views/setting/AccountSettingAbout.vue +++ b/src/views/setting/AccountSettingAbout.vue @@ -2,8 +2,8 @@ import { formatDateDifference } from '@/@core/utils/formatters' import api from '@/api' -// 从 provide 中获取全局设置 -const globalSettings: any = inject('globalSettings') +// 系统环境变量 +const systemEnv = ref({}) // 所有Release const allRelease = ref([]) @@ -27,6 +27,17 @@ function showReleaseDialog(title: string, body: string) { releaseDialog.value = true } +// 查询系统环境变量 +async function querySystemEnv() { + try { + const result: { [key: string]: any } = await api.get('system/env') + + systemEnv.value = result.data + } catch (error) { + console.log(error) + } +} + // 查询所有Release async function queryAllRelease() { try { @@ -48,6 +59,7 @@ function releaseTime(releaseDate: string) { } onMounted(() => { + querySystemEnv() queryAllRelease() }) @@ -65,9 +77,9 @@ onMounted(() => {
软件版本
- {{ globalSettings.VERSION }} + {{ systemEnv.VERSION }} {
-
+
前端版本
- {{ globalSettings.FRONTEND_VERSION }} + {{ systemEnv.FRONTEND_VERSION }}
@@ -97,7 +109,7 @@ onMounted(() => {
认证资源版本
- {{ globalSettings.AUTH_VERSION }} + {{ systemEnv.AUTH_VERSION }}
@@ -107,7 +119,7 @@ onMounted(() => {
站点资源版本
- {{ globalSettings.INDEXER_VERSION }} + {{ systemEnv.INDEXER_VERSION }}
@@ -117,7 +129,7 @@ onMounted(() => {
配置目录
- {{ globalSettings.CONFIG_DIR }} + {{ systemEnv.CONFIG_DIR }}
@@ -133,7 +145,7 @@ onMounted(() => {
时区
- {{ globalSettings.TZ }} + {{ systemEnv.TZ }}
@@ -225,7 +237,7 @@ onMounted(() => { 最新软件版本 当前版本