diff --git a/frontend/image-tool/src/business/chengdu/hook/useToken.ts b/frontend/image-tool/src/business/chengdu/hook/useToken.ts index b1290a80..21ad0371 100644 --- a/frontend/image-tool/src/business/chengdu/hook/useToken.ts +++ b/frontend/image-tool/src/business/chengdu/hook/useToken.ts @@ -3,15 +3,17 @@ import Cookies from 'js-cookie'; window.Cookies = Cookies; let hostname = document.location.hostname || document.location.host; -let dot = hostname.indexOf('.'); -let parentHost = isIp(hostname) ? hostname : hostname.substring(dot + 1); +// let dot = hostname.indexOf('.'); +// let parentHost = isIp(hostname) ? hostname : hostname.substring(dot + 1); export default function useToken() { - let token = Cookies.get(`${parentHost} token`); + let token = Cookies.get(`${hostname} token`); token = token ? `Bearer ${token}` : ''; return token; } -function isIp(str:string = ''){ - return /((25[0-5]|2[0-4]\d|((1\d{2})|([1-9]?\d)))\.){3}(25[0-5]|2[0-4]\d|((1\d{2})|([1-9]?\d)))/.test(str); +function isIp(str: string = '') { + return /((25[0-5]|2[0-4]\d|((1\d{2})|([1-9]?\d)))\.){3}(25[0-5]|2[0-4]\d|((1\d{2})|([1-9]?\d)))/.test( + str, + ); } diff --git a/frontend/pc-tool/src/hook/useToken.ts b/frontend/pc-tool/src/hook/useToken.ts index 7f725bf4..21ad0371 100644 --- a/frontend/pc-tool/src/hook/useToken.ts +++ b/frontend/pc-tool/src/hook/useToken.ts @@ -3,17 +3,17 @@ import Cookies from 'js-cookie'; window.Cookies = Cookies; let hostname = document.location.hostname || document.location.host; -let dot = hostname.indexOf('.'); -let parentHost = isIp(hostname) ? hostname : hostname.substring(dot + 1); +// let dot = hostname.indexOf('.'); +// let parentHost = isIp(hostname) ? hostname : hostname.substring(dot + 1); export default function useToken() { - let token = Cookies.get(`${parentHost} token`); + let token = Cookies.get(`${hostname} token`); token = token ? `Bearer ${token}` : ''; return token; } - - -function isIp(str:string = ''){ - return /((25[0-5]|2[0-4]\d|((1\d{2})|([1-9]?\d)))\.){3}(25[0-5]|2[0-4]\d|((1\d{2})|([1-9]?\d)))/.test(str); -} \ No newline at end of file +function isIp(str: string = '') { + return /((25[0-5]|2[0-4]\d|((1\d{2})|([1-9]?\d)))\.){3}(25[0-5]|2[0-4]\d|((1\d{2})|([1-9]?\d)))/.test( + str, + ); +} diff --git a/frontend/text-tool/src/hook/useToken.ts b/frontend/text-tool/src/hook/useToken.ts index 7f725bf4..5bb1c899 100644 --- a/frontend/text-tool/src/hook/useToken.ts +++ b/frontend/text-tool/src/hook/useToken.ts @@ -3,11 +3,11 @@ import Cookies from 'js-cookie'; window.Cookies = Cookies; let hostname = document.location.hostname || document.location.host; -let dot = hostname.indexOf('.'); -let parentHost = isIp(hostname) ? hostname : hostname.substring(dot + 1); +// let dot = hostname.indexOf('.'); +// let parentHost = isIp(hostname) ? hostname : hostname.substring(dot + 1); export default function useToken() { - let token = Cookies.get(`${parentHost} token`); + let token = Cookies.get(`${hostname} token`); token = token ? `Bearer ${token}` : ''; return token; }