Skip to content

Commit

Permalink
token error
Browse files Browse the repository at this point in the history
Signed-off-by: guhaomine <[email protected]>
  • Loading branch information
guhaomine committed Oct 9, 2023
1 parent 21e119c commit cf4250c
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 16 deletions.
12 changes: 7 additions & 5 deletions frontend/image-tool/src/business/chengdu/hook/useToken.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
);
}
16 changes: 8 additions & 8 deletions frontend/pc-tool/src/hook/useToken.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
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,
);
}
6 changes: 3 additions & 3 deletions frontend/text-tool/src/hook/useToken.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down

0 comments on commit cf4250c

Please sign in to comment.