Browse Source

静态资源加载失效问题修复

songxy 9 months ago
parent
commit
f480f1a739
1 changed files with 4 additions and 3 deletions
  1. 4 3
      client/src/utils/auth.ts

+ 4 - 3
client/src/utils/auth.ts

@@ -60,11 +60,12 @@ export const setLoginForm = (loginForm: LoginFormType) => {
   loginForm.password = encrypt(loginForm.password) as string
   wsCache.set(LoginFormKey, loginForm, { exp: 30 * 24 * 60 * 60 })
 }
-export const getAssetURL = (image: string) => {
+export const getAssetURL = (url: string) => {
   // 参数一: 相对路径
   // 参数二: 当前路径的URL
-  const url = window.location.origin
-  return new URL(`${image}`, url + '/src/assets/imgs/OA/').href + '.png'
+  // const url = window.location.origin
+  if (!url) return ''
+  return new URL('../assets/imgs/OA/' + url + '.png', import.meta.url).href
 }
 export const removeLoginForm = () => {
   wsCache.delete(LoginFormKey)