mirror of
https://github.com/kuaifan/dootask.git
synced 2025-12-12 19:35:50 +00:00
perf:代码优化
This commit is contained in:
parent
e928ff1fce
commit
c11f946979
13
resources/assets/js/app.js
vendored
13
resources/assets/js/app.js
vendored
@ -94,12 +94,15 @@ if (!isElectron && !isEEUiApp) {
|
||||
ViewUI.LoadingBar.start();
|
||||
}, 300)
|
||||
if (to.query?.theme) {
|
||||
store.dispatch("setTheme", to.query?.theme)
|
||||
store.dispatch("setTheme", typeof to.query?.theme == 'string' ? to.query?.theme : to.query?.theme[0])
|
||||
}
|
||||
if (to.query?.lang && window.localStorage.getItem("__language:type__") != to.query?.lang) {
|
||||
window.localStorage.setItem("__language:type__", to.query?.lang);
|
||||
window.location.reload();
|
||||
return false;
|
||||
if (to.query?.lang) {
|
||||
let lang = typeof to.query?.lang == 'string' ? to.query?.lang : to.query?.lang[0]
|
||||
if (window.localStorage.getItem("__language:type__") != lang) {
|
||||
window.localStorage.setItem("__language:type__", to.query?.lang);
|
||||
window.location.reload();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
next();
|
||||
});
|
||||
|
||||
15
resources/assets/js/functions/web.js
vendored
15
resources/assets/js/functions/web.js
vendored
@ -734,18 +734,23 @@
|
||||
text = text.replace(atReg, `<span class="mention me" data-id="${userid}">`)
|
||||
// 处理内容连接
|
||||
if (/https*:\/\//.test(text)) {
|
||||
const match = $.apiUrl('').match(/^(?:https?:\/\/)?(?:[^@\n]+@)?(?:www\.)?([^:\/\n]+)/im);
|
||||
const urlMatch = $.apiUrl('../').match(/^(?:https?:\/\/)?(?:[^@\n]+@)?(?:www\.)?([^:\/\n]+)/im);
|
||||
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>")
|
||||
}
|
||||
if (match && match[1] && string.indexOf(match[1]) !== -1) {
|
||||
if (string.indexOf("?") == -1) {
|
||||
string = string.replace(/(href="[^"]*)/g, (string.indexOf("?") == -1 ? '$1?' : '$1&') + `theme=${theme}&lang=${lang}`);
|
||||
}
|
||||
//
|
||||
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);
|
||||
const prefix = searchParams.toString() ? (href.indexOf("?") === -1 ? '?' : '&') : '';
|
||||
string = string.replace(/(href="[^"]*)/g, '$1' + prefix + searchParams.toString())
|
||||
}
|
||||
//
|
||||
return string;
|
||||
}).join("")
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user