refactor(components): 使用defineAsyncComponent优化异步组件加载
fix(public.js): 添加getScriptParameter函数并处理请求参数 style(index.html): 移除多余空行和注释 perf(bi.js): 移除冗余ajax方法并优化请求参数处理 docs(sign-in.txt): 调整样式和响应式布局
This commit is contained in:
2455
js/details.js
2455
js/details.js
File diff suppressed because it is too large
Load Diff
15
js/public.js
15
js/public.js
@@ -4,12 +4,22 @@ axios.defaults.emulateJSON = true;
|
||||
|
||||
const withVer = (p) => `${p}?v=${window.__ASSET_VERSION__}`;
|
||||
|
||||
const getScriptParameter = (paramName) => {
|
||||
const currentScript = document.currentScript;
|
||||
if (currentScript && currentScript.src) {
|
||||
const url = new URL(currentScript.src, window.location.origin);
|
||||
return url.searchParams.get(paramName);
|
||||
}
|
||||
return null;
|
||||
};
|
||||
|
||||
// 导出ajax函数
|
||||
const ajax = (url, data) => {
|
||||
axios.defaults.withCredentials = true;
|
||||
axios.defaults.emulateJSON = true;
|
||||
|
||||
url = url.indexOf("https://") > -1 ? url : forumBaseURL + url;
|
||||
if (data) data["v"] = getScriptParameter("v") || "v2";
|
||||
return new Promise(function (resolve, reject) {
|
||||
if (location.hostname == "127.0.0.1") axios.defaults.headers.common["Authorization"] = "n1pstcsmw6m6bcx49z705xhvduqviw29";
|
||||
|
||||
@@ -41,6 +51,7 @@ const ajaxdelete = (url, data) => {
|
||||
|
||||
url = url.indexOf("https://") > -1 ? url : forumBaseURL + url;
|
||||
return new Promise(function (resolve, reject) {
|
||||
if (data) data["v"] = getScriptParameter("v") || "v2";
|
||||
axios
|
||||
.delete(url, {
|
||||
emulateJSON: true,
|
||||
@@ -70,6 +81,10 @@ const ajaxGet = (url) => {
|
||||
axios.defaults.emulateJSON = true;
|
||||
|
||||
url = url.indexOf("https://") > -1 ? url : forumBaseURL + url;
|
||||
|
||||
const paramSymbol = url.includes("?") ? "&" : "?";
|
||||
url = `${url}${paramSymbol}v=${getScriptParameter("v") || "v2" }`;
|
||||
|
||||
return new Promise(function (resolve, reject) {
|
||||
if (location.hostname == "127.0.0.1") axios.defaults.headers.common["Authorization"] = "n1pstcsmw6m6bcx49z705xhvduqviw29";
|
||||
|
||||
|
||||
Reference in New Issue
Block a user