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

View File

@@ -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)

View File

@@ -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]

View File

@@ -2,8 +2,8 @@
import { formatDateDifference } from '@/@core/utils/formatters'
import api from '@/api'
// 从 provide 中获取全局设置
const globalSettings: any = inject('globalSettings')
// 系统环境变量
const systemEnv = ref<any>({})
// 所有Release
const allRelease = ref<any>([])
@@ -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()
})
</script>
@@ -65,9 +77,9 @@ onMounted(() => {
<dt class="block text-sm font-bold">软件版本</dt>
<dd class="flex text-sm sm:col-span-2 sm:mt-0">
<span class="flex-grow flex flex-row items-center truncate">
<code class="truncate">{{ globalSettings.VERSION }}</code>
<code class="truncate">{{ systemEnv.VERSION }}</code>
<a
v-if="latestRelease === globalSettings.VERSION"
v-if="latestRelease === systemEnv.VERSION"
href="https://github.com/jxxghp/MoviePilot/releases"
target="_blank"
rel="noopener noreferrer"
@@ -82,12 +94,12 @@ onMounted(() => {
</dd>
</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">
<dt class="block text-sm font-bold">前端版本</dt>
<dd class="flex text-sm sm:col-span-2 sm:mt-0">
<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>
</dd>
</div>
@@ -97,7 +109,7 @@ onMounted(() => {
<dt class="block text-sm font-bold">认证资源版本</dt>
<dd class="flex text-sm sm:col-span-2 sm:mt-0">
<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>
</dd>
</div>
@@ -107,7 +119,7 @@ onMounted(() => {
<dt class="block text-sm font-bold">站点资源版本</dt>
<dd class="flex text-sm sm:col-span-2 sm:mt-0">
<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>
</dd>
</div>
@@ -117,7 +129,7 @@ onMounted(() => {
<dt class="block text-sm font-bold">配置目录</dt>
<dd class="flex text-sm sm:col-span-2 sm:mt-0">
<span class="flex-grow undefined">
<code>{{ globalSettings.CONFIG_DIR }}</code>
<code>{{ systemEnv.CONFIG_DIR }}</code>
</span>
</dd>
</div>
@@ -133,7 +145,7 @@ onMounted(() => {
<dt class="block text-sm font-bold">时区</dt>
<dd class="flex text-sm sm:col-span-2 sm:mt-0">
<span class="flex-grow undefined">
<code>{{ globalSettings.TZ }}</code>
<code>{{ systemEnv.TZ }}</code>
</span>
</dd>
</div>
@@ -225,7 +237,7 @@ onMounted(() => {
最新软件版本
</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"
>
当前版本