mirror of
https://github.com/kuaifan/dootask.git
synced 2025-12-12 19:35:50 +00:00
perf: 复制链接去除主题语言参数
This commit is contained in:
parent
e43dd53e4f
commit
6ffb458ffc
8
resources/assets/js/functions/web.js
vendored
8
resources/assets/js/functions/web.js
vendored
@ -735,8 +735,8 @@
|
||||
// 处理内容连接
|
||||
if (/https*:\/\//.test(text)) {
|
||||
const urlMatch = $.apiUrl('../').match(/^(?:https?:\/\/)?(?:[^@\n]+@)?(?:www\.)?([^:\/\n]+)/im);
|
||||
const theme = window.localStorage.getItem("__theme:mode__")
|
||||
const lang = window.localStorage.getItem("__language:type__")
|
||||
// const theme = window.localStorage.getItem("__theme:mode__")
|
||||
// const lang = window.localStorage.getItem("__language:type__")
|
||||
text = text.split(/(<[^>]*>)/g).map(string => {
|
||||
if (string && !/<[^>]*>/.test(string)) {
|
||||
string = string.replace(/(^|[^'"])((https*:\/\/)((\w|=|\?|\.|\/|&|-|:|\+|%|;|#|@|,|!)+))/g, "$1<a href=\"$2\" target=\"_blank\">$2</a>")
|
||||
@ -745,8 +745,8 @@
|
||||
const href = string.match(/href="([^"]+)"/)?.[1] || ''
|
||||
if (urlMatch?.[1] && href.indexOf(urlMatch[1]) !== -1) {
|
||||
const searchParams = new URLSearchParams()
|
||||
href.indexOf("theme=") === -1 && searchParams.append('theme', theme);
|
||||
href.indexOf("lang=") === -1 && searchParams.append('lang', lang);
|
||||
// href.indexOf("theme=") === -1 && searchParams.append('theme', theme);
|
||||
// href.indexOf("lang=") === -1 && searchParams.append('lang', lang);
|
||||
const prefix = searchParams.toString() ? (href.indexOf("?") === -1 ? '?' : '&') : '';
|
||||
string = string.replace(/(href="[^"]*)/g, '$1' + prefix + searchParams.toString())
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user