mirror of
https://github.com/kuaifan/dootask.git
synced 2026-02-23 17:30:33 +00:00
perf: 优化自定义sso登录
This commit is contained in:
parent
0aa7679a71
commit
e45bcf34a3
@ -245,28 +245,48 @@ export default {
|
|||||||
placeholder: "请输入服务器地址",
|
placeholder: "请输入服务器地址",
|
||||||
onOk: (value, cb) => {
|
onOk: (value, cb) => {
|
||||||
if (value) {
|
if (value) {
|
||||||
if (!$A.leftExists(value, "http://") && !$A.leftExists(value, "https://")) {
|
this.inputServerChack(value).then(_ => cb)
|
||||||
value = "http://" + value;
|
} else {
|
||||||
}
|
this.clearServerUrl();
|
||||||
if (!$A.rightExists(value, "/api/")) {
|
|
||||||
value = value + ($A.rightExists(value, "/") ? "api/" : "/api/");
|
|
||||||
}
|
|
||||||
this.$store.dispatch("call", {
|
|
||||||
url: value + 'system/setting',
|
|
||||||
}).then(() => {
|
|
||||||
this.setServerUrl(value)
|
|
||||||
cb()
|
|
||||||
}).catch(({msg}) => {
|
|
||||||
$A.modalError(msg || "服务器地址无效", 301);
|
|
||||||
cb()
|
|
||||||
});
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
this.clearServerUrl();
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
|
inputServerChack(value) {
|
||||||
|
return new Promise(resolve => {
|
||||||
|
let url = value;
|
||||||
|
if (!/\/api\/$/.test(url)) {
|
||||||
|
url = url + ($A.rightExists(url, "/") ? "api/" : "/api/");
|
||||||
|
}
|
||||||
|
if (!/^https*:\/\//i.test(url)) {
|
||||||
|
url = `http://${url}`;
|
||||||
|
}
|
||||||
|
this.$store.dispatch("call", {
|
||||||
|
url: `${url}system/setting`,
|
||||||
|
checkNetwork: false,
|
||||||
|
}).then(() => {
|
||||||
|
this.setServerUrl(url)
|
||||||
|
resolve()
|
||||||
|
}).catch(({ret, msg}) => {
|
||||||
|
if (ret === -1001) {
|
||||||
|
if (!/^https*:\/\//i.test(value)) {
|
||||||
|
this.inputServerChack(`https://${value}`).then(resolve);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
msg = "服务器地址无效";
|
||||||
|
}
|
||||||
|
$A.modalError({
|
||||||
|
content: msg,
|
||||||
|
onOk: () => {
|
||||||
|
setTimeout(this.inputServerUrl, 301)
|
||||||
|
}
|
||||||
|
}, 301);
|
||||||
|
resolve()
|
||||||
|
});
|
||||||
|
})
|
||||||
|
},
|
||||||
|
|
||||||
chackServerUrl(tip) {
|
chackServerUrl(tip) {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
if (this.isNotServer()) {
|
if (this.isNotServer()) {
|
||||||
|
|||||||
7
resources/assets/js/store/actions.js
vendored
7
resources/assets/js/store/actions.js
vendored
@ -77,8 +77,11 @@ export default {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
params.error = (xhr, status) => {
|
params.error = (xhr, status) => {
|
||||||
state.ajaxNetworkException = window.navigator.onLine === false || (status === 0 && xhr.readyState === 4);
|
const networkException = window.navigator.onLine === false || (status === 0 && xhr.readyState === 4);
|
||||||
if (state.ajaxNetworkException) {
|
if (params.checkNetwork !== false) {
|
||||||
|
state.ajaxNetworkException = networkException;
|
||||||
|
}
|
||||||
|
if (networkException) {
|
||||||
reject({ret: -1001, data: {}, msg: "Network exception"})
|
reject({ret: -1001, data: {}, msg: "Network exception"})
|
||||||
} else {
|
} else {
|
||||||
reject({ret: -1, data: {}, msg: "System error"})
|
reject({ret: -1, data: {}, msg: "System error"})
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user