mirror of
https://github.com/Wei-Shaw/sub2api.git
synced 2026-10-31 08:25:35 +00:00
fix(frontend): 补齐 en 语言包缺失 key 并对 site_logo 统一应用 sanitizeUrl
This commit is contained in:
@@ -194,6 +194,7 @@ import { useI18n } from 'vue-i18n'
|
||||
import { useAdminSettingsStore, useAppStore, useAuthStore, useOnboardingStore } from '@/stores'
|
||||
import VersionBadge from '@/components/common/VersionBadge.vue'
|
||||
import { sanitizeSvg } from '@/utils/sanitize'
|
||||
import { sanitizeUrl } from '@/utils/url'
|
||||
import { FeatureFlags, makeSidebarFlag } from '@/utils/featureFlags'
|
||||
import { useBatchImageAccess } from '@/composables/useBatchImageAccess'
|
||||
|
||||
@@ -256,7 +257,7 @@ const expandedGroups = ref<Set<string>>(new Set())
|
||||
|
||||
// Site settings from appStore (cached, no flicker)
|
||||
const siteName = computed(() => appStore.siteName)
|
||||
const siteLogo = computed(() => appStore.siteLogo)
|
||||
const siteLogo = computed(() => sanitizeUrl(appStore.siteLogo || '', { allowRelative: true, allowDataUrl: true }))
|
||||
const siteVersion = computed(() => appStore.siteVersion)
|
||||
const settingsLoaded = computed(() => appStore.publicSettingsLoaded)
|
||||
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
import { readFileSync } from 'node:fs'
|
||||
import { dirname, resolve } from 'node:path'
|
||||
import { fileURLToPath } from 'node:url'
|
||||
|
||||
import { describe, expect, it } from 'vitest'
|
||||
|
||||
const dir = dirname(fileURLToPath(import.meta.url))
|
||||
const sidebarSource = readFileSync(resolve(dir, '../AppSidebar.vue'), 'utf8')
|
||||
const homeViewSource = readFileSync(resolve(dir, '../../../views/HomeView.vue'), 'utf8')
|
||||
const keyUsageViewSource = readFileSync(resolve(dir, '../../../views/KeyUsageView.vue'), 'utf8')
|
||||
|
||||
describe('site_logo sanitization', () => {
|
||||
it('AppSidebar imports sanitizeUrl and applies it to siteLogo', () => {
|
||||
expect(sidebarSource).toContain("import { sanitizeUrl } from '@/utils/url'")
|
||||
expect(sidebarSource).toContain('sanitizeUrl(appStore.siteLogo')
|
||||
})
|
||||
|
||||
it('HomeView applies sanitizeUrl to siteLogo', () => {
|
||||
expect(homeViewSource).toContain('sanitizeUrl(appStore.cachedPublicSettings?.site_logo || appStore.siteLogo')
|
||||
})
|
||||
|
||||
it('KeyUsageView applies sanitizeUrl to siteLogo', () => {
|
||||
expect(keyUsageViewSource).toContain('sanitizeUrl(appStore.cachedPublicSettings?.site_logo || appStore.siteLogo')
|
||||
})
|
||||
|
||||
it('all three pass allowRelative and allowDataUrl options', () => {
|
||||
for (const src of [sidebarSource, homeViewSource, keyUsageViewSource]) {
|
||||
expect(src).toContain('allowRelative: true')
|
||||
expect(src).toContain('allowDataUrl: true')
|
||||
}
|
||||
})
|
||||
})
|
||||
Reference in New Issue
Block a user