shuisheng 1 vuosi sitten
vanhempi
sitoutus
c14bc7e0e9
2 muutettua tiedostoa jossa 8 lisäystä ja 2 poistoa
  1. 2 1
      src/App.vue
  2. 6 1
      src/utils/index.ts

+ 2 - 1
src/App.vue

@@ -22,6 +22,7 @@ import { useCheckUpdate } from '@/hooks/use-common';
 import { loginMessage } from '@/hooks/use-login';
 import { usePiniaCacheStore } from '@/store/cache';
 import { useUserStore } from '@/store/user';
+import { getHostnameUrl } from '@/utils';
 import { getLastBuildDate, setLastBuildDate } from '@/utils/localStorage/app';
 import { getToken } from '@/utils/localStorage/user';
 
@@ -38,7 +39,7 @@ const themeOverrides: GlobalThemeOverrides = {
 
 onMounted(() => {
   checkUpdate({
-    htmlUrl: 'http://localhost:8000',
+    htmlUrl: getHostnameUrl(),
   });
   handleUpdate();
   loginMessage();

+ 6 - 1
src/utils/index.ts

@@ -93,11 +93,16 @@ export const getLiveRoomPageUrl = (liveRoomId: number) => {
   return `${getHostnameUrl()}/pull/${liveRoomId}`;
 };
 
+/**
+ * 例子:当前地址栏:https://live.hsslive.cn,结果:https://live.hsslive.cn
+ * 例子:当前地址栏:https://live.hsslive.cn/push?liveType=1&roomId=101,结果:https://live.hsslive.cn
+ */
 export const getHostnameUrl = () => {
   // window.location.host,包含了域名的一个DOMString,可能在该串最后带有一个":"并跟上 URL 的端口号。
   // window.location.hostname,包含了域名的一个DOMString
   const { protocol, host } = window.location;
-  return `${protocol}//${host}`;
+  const res = `${protocol}//${host}`;
+  return res;
 };
 
 /**