login wallpapers cache

This commit is contained in:
jxxghp
2024-08-29 16:15:42 +08:00
parent 340bb08f2a
commit ec54ec2607
3 changed files with 36 additions and 14 deletions
+1 -1
View File
@@ -40,7 +40,7 @@ export default api
export async function fetchGlobalSettings() { export async function fetchGlobalSettings() {
try { try {
const result: { [key: string]: any } = await api.get('system/env') const result: { [key: string]: any } = await api.get('system/global')
return result.data || {} return result.data || {}
} catch (error) { } catch (error) {
console.error('Failed to fetch global settings', error) console.error('Failed to fetch global settings', error)
+12 -2
View File
@@ -15,6 +15,9 @@ const { global: globalTheme } = useTheme()
// Vuex Store // Vuex Store
const store = useStore() const store = useStore()
// 从 provide 中获取全局设置
const globalSettings: any = inject('globalSettings')
// 表单 // 表单
const form = ref({ const form = ref({
username: '', username: '',
@@ -52,8 +55,15 @@ let intervalTimer: NodeJS.Timeout | null = null
// 获取背景图片 // 获取背景图片
async function fetchBackgroundImage() { async function fetchBackgroundImage() {
try { try {
backgroundImages.value = await api.get('/login/wallpapers') const results: string[] = await api.get('/login/wallpapers')
if (backgroundImages.value && backgroundImages.value.length > 0) { 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) backgroundImages.value.sort(() => Math.random() - 0.5)
backgroundImageUrl.value = backgroundImages.value[0] backgroundImageUrl.value = backgroundImages.value[0]
+23 -11
View File
@@ -2,8 +2,8 @@
import { formatDateDifference } from '@/@core/utils/formatters' import { formatDateDifference } from '@/@core/utils/formatters'
import api from '@/api' import api from '@/api'
// 从 provide 中获取全局设置 // 系统环境变量
const globalSettings: any = inject('globalSettings') const systemEnv = ref<any>({})
// 所有Release // 所有Release
const allRelease = ref<any>([]) const allRelease = ref<any>([])
@@ -27,6 +27,17 @@ function showReleaseDialog(title: string, body: string) {
releaseDialog.value = true 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 // 查询所有Release
async function queryAllRelease() { async function queryAllRelease() {
try { try {
@@ -48,6 +59,7 @@ function releaseTime(releaseDate: string) {
} }
onMounted(() => { onMounted(() => {
querySystemEnv()
queryAllRelease() queryAllRelease()
}) })
</script> </script>
@@ -65,9 +77,9 @@ onMounted(() => {
<dt class="block text-sm font-bold">软件版本</dt> <dt class="block text-sm font-bold">软件版本</dt>
<dd class="flex text-sm sm:col-span-2 sm:mt-0"> <dd class="flex text-sm sm:col-span-2 sm:mt-0">
<span class="flex-grow flex flex-row items-center truncate"> <span class="flex-grow flex flex-row items-center truncate">
<code class="truncate">{{ globalSettings.VERSION }}</code> <code class="truncate">{{ systemEnv.VERSION }}</code>
<a <a
v-if="latestRelease === globalSettings.VERSION" v-if="latestRelease === systemEnv.VERSION"
href="https://github.com/jxxghp/MoviePilot/releases" href="https://github.com/jxxghp/MoviePilot/releases"
target="_blank" target="_blank"
rel="noopener noreferrer" rel="noopener noreferrer"
@@ -82,12 +94,12 @@ onMounted(() => {
</dd> </dd>
</div> </div>
</div> </div>
<div v-if="globalSettings.FRONTEND_VERSION"> <div v-if="systemEnv.FRONTEND_VERSION">
<div class="max-w-6xl py-4 sm:grid sm:grid-cols-3 sm:gap-4"> <div class="max-w-6xl py-4 sm:grid sm:grid-cols-3 sm:gap-4">
<dt class="block text-sm font-bold">前端版本</dt> <dt class="block text-sm font-bold">前端版本</dt>
<dd class="flex text-sm sm:col-span-2 sm:mt-0"> <dd class="flex text-sm sm:col-span-2 sm:mt-0">
<span class="flex-grow flex flex-row items-center truncate"> <span class="flex-grow flex flex-row items-center truncate">
<code class="truncate">{{ globalSettings.FRONTEND_VERSION }}</code> <code class="truncate">{{ systemEnv.FRONTEND_VERSION }}</code>
</span> </span>
</dd> </dd>
</div> </div>
@@ -97,7 +109,7 @@ onMounted(() => {
<dt class="block text-sm font-bold">认证资源版本</dt> <dt class="block text-sm font-bold">认证资源版本</dt>
<dd class="flex text-sm sm:col-span-2 sm:mt-0"> <dd class="flex text-sm sm:col-span-2 sm:mt-0">
<span class="flex-grow flex flex-row items-center truncate"> <span class="flex-grow flex flex-row items-center truncate">
<code class="truncate">{{ globalSettings.AUTH_VERSION }}</code> <code class="truncate">{{ systemEnv.AUTH_VERSION }}</code>
</span> </span>
</dd> </dd>
</div> </div>
@@ -107,7 +119,7 @@ onMounted(() => {
<dt class="block text-sm font-bold">站点资源版本</dt> <dt class="block text-sm font-bold">站点资源版本</dt>
<dd class="flex text-sm sm:col-span-2 sm:mt-0"> <dd class="flex text-sm sm:col-span-2 sm:mt-0">
<span class="flex-grow flex flex-row items-center truncate"> <span class="flex-grow flex flex-row items-center truncate">
<code class="truncate">{{ globalSettings.INDEXER_VERSION }}</code> <code class="truncate">{{ systemEnv.INDEXER_VERSION }}</code>
</span> </span>
</dd> </dd>
</div> </div>
@@ -117,7 +129,7 @@ onMounted(() => {
<dt class="block text-sm font-bold">配置目录</dt> <dt class="block text-sm font-bold">配置目录</dt>
<dd class="flex text-sm sm:col-span-2 sm:mt-0"> <dd class="flex text-sm sm:col-span-2 sm:mt-0">
<span class="flex-grow undefined"> <span class="flex-grow undefined">
<code>{{ globalSettings.CONFIG_DIR }}</code> <code>{{ systemEnv.CONFIG_DIR }}</code>
</span> </span>
</dd> </dd>
</div> </div>
@@ -133,7 +145,7 @@ onMounted(() => {
<dt class="block text-sm font-bold">时区</dt> <dt class="block text-sm font-bold">时区</dt>
<dd class="flex text-sm sm:col-span-2 sm:mt-0"> <dd class="flex text-sm sm:col-span-2 sm:mt-0">
<span class="flex-grow undefined"> <span class="flex-grow undefined">
<code>{{ globalSettings.TZ }}</code> <code>{{ systemEnv.TZ }}</code>
</span> </span>
</dd> </dd>
</div> </div>
@@ -225,7 +237,7 @@ onMounted(() => {
最新软件版本 最新软件版本
</span> </span>
<span <span
v-if="release.tag_name === globalSettings.VERSION" v-if="release.tag_name === systemEnv.VERSION"
class="px-2 inline-flex text-xs leading-5 font-semibold rounded-full whitespace-nowrap cursor-default bg-indigo-500 bg-opacity-80 border border-indigo-500 !text-indigo-100" class="px-2 inline-flex text-xs leading-5 font-semibold rounded-full whitespace-nowrap cursor-default bg-indigo-500 bg-opacity-80 border border-indigo-500 !text-indigo-100"
> >
当前版本 当前版本