mirror of
https://github.com/kuaifan/dootask.git
synced 2025-12-11 18:42:54 +00:00
no message
This commit is contained in:
parent
5489462f90
commit
bfdb72dd0a
17
electron/utils.js
vendored
17
electron/utils.js
vendored
@ -275,11 +275,24 @@ const utils = {
|
||||
* @returns {string|string}
|
||||
*/
|
||||
getDomain(weburl) {
|
||||
let urlReg = /http(s)?:\/\/([^\/]+)/i;
|
||||
let domain = (weburl + "").match(urlReg);
|
||||
const urlReg = /http(s)?:\/\/([^\/]+)/i;
|
||||
const domain = `${weburl}`.match(urlReg);
|
||||
return ((domain != null && domain.length > 0) ? domain[2] : "");
|
||||
},
|
||||
|
||||
/**
|
||||
* 提取 URL 协议
|
||||
* @param weburl
|
||||
* @returns {string}
|
||||
*/
|
||||
getProtocol(weburl) {
|
||||
try {
|
||||
return new URL(weburl).protocol
|
||||
} catch(e){
|
||||
return ""
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* 显示窗口
|
||||
* @param win
|
||||
|
||||
62
resources/assets/js/functions/common.js
vendored
62
resources/assets/js/functions/common.js
vendored
@ -651,6 +651,51 @@ const timezone = require("dayjs/plugin/timezone");
|
||||
return this.rightDelete(url.replace("?&", "?"), '?');
|
||||
},
|
||||
|
||||
/**
|
||||
* 替换url中的hash
|
||||
* @param {string} url - 要修改的URL;如果只提供一个参数,则作为新的hash路径,URL默认为当前页面
|
||||
* @param {string} [path] - 新的hash路径,可包含或不包含#前缀
|
||||
* @returns {string} 替换hash后的URL
|
||||
*/
|
||||
urlReplaceHash(url, path = undefined) {
|
||||
// 如果只传了一个参数,将其视为path,url默认为当前页面
|
||||
if (path === undefined) {
|
||||
path = url;
|
||||
url = window.location.href;
|
||||
}
|
||||
|
||||
// 确保url有值
|
||||
url = url || window.location.href;
|
||||
|
||||
try {
|
||||
// 使用URL API正确解析URL各部分
|
||||
const urlObj = new URL(url);
|
||||
|
||||
// 确保path是字符串并格式正确
|
||||
path = String(path || '');
|
||||
if (path && path.startsWith('#')) {
|
||||
path = path.substring(1);
|
||||
}
|
||||
|
||||
// 设置新的hash
|
||||
urlObj.hash = path;
|
||||
|
||||
return urlObj.toString();
|
||||
} catch (e) {
|
||||
// 如果URL解析失败,回退到简单的字符串替换方法
|
||||
if (!path) {
|
||||
return url.replace(/#.*$/, '');
|
||||
}
|
||||
|
||||
const hashPath = path.startsWith('#') ? path : '#' + path;
|
||||
if (url.includes('#')) {
|
||||
return url.replace(/#.*$/, hashPath);
|
||||
} else {
|
||||
return url + hashPath;
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* 刷新当前地址
|
||||
* @returns {string}
|
||||
@ -1017,11 +1062,24 @@ const timezone = require("dayjs/plugin/timezone");
|
||||
* @returns {string|string}
|
||||
*/
|
||||
getDomain(weburl) {
|
||||
let urlReg = /http(s)?:\/\/([^\/]+)/i;
|
||||
let domain = (weburl + "").match(urlReg);
|
||||
const urlReg = /http(s)?:\/\/([^\/]+)/i;
|
||||
const domain = `${weburl}`.match(urlReg);
|
||||
return ((domain != null && domain.length > 0) ? domain[2] : "");
|
||||
},
|
||||
|
||||
/**
|
||||
* 提取 URL 协议
|
||||
* @param weburl
|
||||
* @returns {string}
|
||||
*/
|
||||
getProtocol(weburl) {
|
||||
try {
|
||||
return new URL(weburl).protocol
|
||||
} catch(e){
|
||||
return ""
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* 滚动到View
|
||||
* @param element
|
||||
|
||||
@ -2364,7 +2364,7 @@ export default {
|
||||
block: 'end',
|
||||
behavior: 'smooth'
|
||||
})
|
||||
}, 500, 100, 3)
|
||||
}, 500, 500, 3)
|
||||
}
|
||||
},
|
||||
|
||||
@ -3799,7 +3799,7 @@ export default {
|
||||
params: {
|
||||
titleFixed: true,
|
||||
allowAccess: true,
|
||||
url: $A.rightDelete(window.location.href, window.location.hash) + `#${path}`
|
||||
url: $A.urlReplaceHash(path)
|
||||
},
|
||||
})
|
||||
} else {
|
||||
|
||||
@ -202,7 +202,7 @@ export default {
|
||||
params: {
|
||||
titleFixed: true,
|
||||
allowAccess: true,
|
||||
url: $A.rightDelete(window.location.href, window.location.hash) + `#${path}`
|
||||
url: $A.urlReplaceHash(path)
|
||||
},
|
||||
})
|
||||
} else {
|
||||
|
||||
@ -236,7 +236,7 @@ export default {
|
||||
url: 'web.js',
|
||||
params: {
|
||||
allowAccess: true,
|
||||
url: $A.rightDelete(window.location.href, window.location.hash) + `#${path}`
|
||||
url: $A.urlReplaceHash(path)
|
||||
},
|
||||
})
|
||||
} else {
|
||||
|
||||
@ -189,7 +189,7 @@ export default {
|
||||
params: {
|
||||
titleFixed: true,
|
||||
allowAccess: true,
|
||||
url: $A.rightDelete(window.location.href, window.location.hash) + `#${path}`
|
||||
url: $A.urlReplaceHash(path)
|
||||
},
|
||||
})
|
||||
} else {
|
||||
|
||||
@ -1899,7 +1899,7 @@ export default {
|
||||
params: {
|
||||
titleFixed: true,
|
||||
allowAccess: true,
|
||||
url: $A.rightDelete(window.location.href, window.location.hash) + `#${path}`
|
||||
url: $A.urlReplaceHash(path)
|
||||
},
|
||||
});
|
||||
} else {
|
||||
|
||||
@ -1123,7 +1123,7 @@ export default {
|
||||
params: {
|
||||
titleFixed: true,
|
||||
allowAccess: true,
|
||||
url: $A.rightDelete(window.location.href, window.location.hash) + `#${path}`
|
||||
url: $A.urlReplaceHash(path)
|
||||
},
|
||||
});
|
||||
} else {
|
||||
|
||||
10
resources/assets/js/store/actions.js
vendored
10
resources/assets/js/store/actions.js
vendored
@ -1171,13 +1171,15 @@ export default {
|
||||
*/
|
||||
userUrl({state}, url) {
|
||||
return new Promise(resolve => {
|
||||
const newUrl = $A.urlAddParams(url, {
|
||||
const params = {
|
||||
language: languageName,
|
||||
theme: state.themeConf,
|
||||
userid: state.userId,
|
||||
token: state.userToken,
|
||||
})
|
||||
resolve(newUrl)
|
||||
}
|
||||
if ($A.getDomain(url) == $A.getDomain($A.mainUrl()) || $A.getProtocol(url) == "file:") {
|
||||
params.token = state.userToken
|
||||
}
|
||||
resolve($A.urlAddParams(url, params))
|
||||
})
|
||||
},
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user