瀏覽代碼

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

songxy 9 月之前
父節點
當前提交
f480f1a739
共有 1 個文件被更改,包括 4 次插入3 次删除
  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)