mirror of
https://github.com/kuaifan/dootask.git
synced 2026-01-09 23:18:14 +00:00
perf: 优化全局提示
This commit is contained in:
parent
13c4fa4f1f
commit
ab47f01625
@ -22,6 +22,9 @@
|
||||
<!--图片预览-->
|
||||
<PreviewImageState/>
|
||||
|
||||
<!--身份提示-->
|
||||
<AuthException/>
|
||||
|
||||
<!--网络提示-->
|
||||
<NetworkException v-if="windowLandscape"/>
|
||||
|
||||
@ -43,6 +46,7 @@
|
||||
import FloatSpinner from "./components/FloatSpinner";
|
||||
import RightBottom from "./components/RightBottom";
|
||||
import PreviewImageState from "./components/PreviewImage/state";
|
||||
import AuthException from "./components/AuthException";
|
||||
import NetworkException from "./components/NetworkException";
|
||||
import GuidePage from "./components/GuidePage";
|
||||
import TaskOperation from "./pages/manage/components/TaskOperation";
|
||||
@ -56,6 +60,7 @@ export default {
|
||||
mixins: [ctrlPressed],
|
||||
|
||||
components: {
|
||||
AuthException,
|
||||
MeetingManager,
|
||||
DropdownMenu,
|
||||
TaskOperation,
|
||||
|
||||
69
resources/assets/js/components/AuthException.vue
Normal file
69
resources/assets/js/components/AuthException.vue
Normal file
@ -0,0 +1,69 @@
|
||||
<template>
|
||||
<Modal
|
||||
:value="show"
|
||||
:width="416"
|
||||
:closable="false"
|
||||
:mask-closable="false"
|
||||
:footer-hide="true">
|
||||
<div class="ivu-modal-confirm">
|
||||
<div class="ivu-modal-confirm-head">
|
||||
<div class="ivu-modal-confirm-head-icon ivu-modal-confirm-head-icon-error"><Icon type="ios-close-circle"/></div><div class="ivu-modal-confirm-head-title">{{$L('温馨提示')}}</div>
|
||||
</div>
|
||||
<div class="ivu-modal-confirm-body">
|
||||
<div>{{ajaxAuthException}}</div>
|
||||
</div>
|
||||
<div v-if="$isSubElectron" class="ivu-modal-confirm-footer">
|
||||
<Button type="text" @click="onClose">{{$L('关闭窗口')}}</Button>
|
||||
<Button type="primary" @click="onRefresh">{{$L('刷新')}}</Button>
|
||||
</div>
|
||||
<div v-else class="ivu-modal-confirm-footer">
|
||||
<Button type="primary" @click="onConfirm">{{$L('确定')}}</Button>
|
||||
</div>
|
||||
</div>
|
||||
</Modal>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import {mapState} from "vuex";
|
||||
|
||||
export default {
|
||||
name: 'AuthException',
|
||||
data() {
|
||||
return {
|
||||
routePath: null,
|
||||
}
|
||||
},
|
||||
|
||||
computed: {
|
||||
...mapState(['ajaxAuthException']),
|
||||
|
||||
show() {
|
||||
return this.routePath !== '/login' && !!this.ajaxAuthException
|
||||
}
|
||||
},
|
||||
|
||||
watch: {
|
||||
'$route': {
|
||||
handler(to) {
|
||||
this.routePath = to.path
|
||||
},
|
||||
immediate: true,
|
||||
},
|
||||
},
|
||||
|
||||
methods: {
|
||||
onClose() {
|
||||
window.close();
|
||||
},
|
||||
|
||||
onRefresh() {
|
||||
$A.reloadUrl()
|
||||
},
|
||||
|
||||
onConfirm() {
|
||||
this.$store.state.ajaxAuthException = null
|
||||
this.$store.dispatch("logout")
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
@ -19,7 +19,7 @@ export default {
|
||||
},
|
||||
|
||||
mounted() {
|
||||
this.src = $.apiUrl('../images/guide.png');
|
||||
this.src = $.apiUrl('../images/other/guide.png');
|
||||
},
|
||||
|
||||
watch: {
|
||||
|
||||
@ -8,14 +8,14 @@
|
||||
v-model="show"
|
||||
:width="416"
|
||||
:closable="false"
|
||||
:footer-hide="true"
|
||||
class-name="common-network-exception-modal">
|
||||
:mask-closable="false"
|
||||
:footer-hide="true">
|
||||
<div class="ivu-modal-confirm">
|
||||
<div class="ivu-modal-confirm-head">
|
||||
<div class="ivu-modal-confirm-head-icon ivu-modal-confirm-head-icon-error"><Icon type="ios-close-circle"/></div><div class="ivu-modal-confirm-head-title">{{$L('温馨提示')}}</div>
|
||||
</div>
|
||||
<div class="ivu-modal-confirm-body">
|
||||
<div>{{$L('网络连接失败,请检查网络设置。')}}</div>
|
||||
<div>{{ajaxNetworkException}}</div>
|
||||
</div>
|
||||
<div class="ivu-modal-confirm-footer">
|
||||
<Button type="primary" @click="show = false">{{$L('确定')}}</Button>
|
||||
|
||||
28
resources/assets/js/functions/web.js
vendored
28
resources/assets/js/functions/web.js
vendored
@ -848,16 +848,13 @@ import {convertLocalResourcePath} from "../components/Replace/utils";
|
||||
if (config === false) {
|
||||
return;
|
||||
}
|
||||
if ($A.isJson(config) && config.content === false) {
|
||||
return;
|
||||
}
|
||||
if (millisecond > 0) {
|
||||
setTimeout(() => { $A.modalWarning(config) }, millisecond);
|
||||
return;
|
||||
}
|
||||
if (typeof config === "string" && config === "Network exception") {
|
||||
return;
|
||||
}
|
||||
if ($A.isJson(config) && config.content === "Network exception") {
|
||||
return;
|
||||
}
|
||||
$A.Modal.warning($A.modalConfig(config));
|
||||
},
|
||||
|
||||
@ -865,16 +862,13 @@ import {convertLocalResourcePath} from "../components/Replace/utils";
|
||||
if (config === false) {
|
||||
return;
|
||||
}
|
||||
if ($A.isJson(config) && config.content === false) {
|
||||
return;
|
||||
}
|
||||
if (millisecond > 0) {
|
||||
setTimeout(() => { $A.modalError(config) }, millisecond);
|
||||
return;
|
||||
}
|
||||
if (typeof config === "string" && config === "Network exception") {
|
||||
return;
|
||||
}
|
||||
if ($A.isJson(config) && config.content === "Network exception") {
|
||||
return;
|
||||
}
|
||||
$A.Modal.error($A.modalConfig(config));
|
||||
},
|
||||
|
||||
@ -891,14 +885,14 @@ import {convertLocalResourcePath} from "../components/Replace/utils";
|
||||
},
|
||||
|
||||
messageWarning(msg) {
|
||||
if (typeof msg === "string" && msg === "Network exception") {
|
||||
if (msg === false) {
|
||||
return;
|
||||
}
|
||||
$A.Message.warning($A.L(msg));
|
||||
},
|
||||
|
||||
messageError(msg) {
|
||||
if (typeof msg === "string" && msg === "Network exception") {
|
||||
if (msg === false) {
|
||||
return;
|
||||
}
|
||||
$A.Message.error($A.L(msg));
|
||||
@ -921,10 +915,16 @@ import {convertLocalResourcePath} from "../components/Replace/utils";
|
||||
},
|
||||
|
||||
noticeWarning(config) {
|
||||
if (config === false) {
|
||||
return;
|
||||
}
|
||||
$A.Notice.warning($A.noticeConfig(config));
|
||||
},
|
||||
|
||||
noticeError(config) {
|
||||
if (config === false) {
|
||||
return;
|
||||
}
|
||||
if (typeof config === "string") {
|
||||
config = {
|
||||
desc: config,
|
||||
|
||||
@ -229,11 +229,6 @@ export default {
|
||||
//
|
||||
this.getDemoAccount();
|
||||
this.getNeedStartHome();
|
||||
//
|
||||
if (this.$Electron) {
|
||||
this.$Electron.sendMessage('webTabDestroyAll')
|
||||
this.$Electron.sendMessage('childWindowDestroyAll')
|
||||
}
|
||||
},
|
||||
|
||||
deactivated() {
|
||||
@ -444,6 +439,7 @@ export default {
|
||||
this.$store.dispatch("call", {
|
||||
url: `${url}system/setting`,
|
||||
checkNetwork: false,
|
||||
networkFailureRetry: false
|
||||
}).then(async ({data}) => {
|
||||
if (typeof data.server_version === "undefined" && typeof data.all_group_mute === "undefined") {
|
||||
reject(`服务器(${$A.getDomain(value)})版本过低`)
|
||||
|
||||
@ -1083,7 +1083,7 @@ export default {
|
||||
data: {
|
||||
userid: [userid]
|
||||
},
|
||||
skipAuthError: true
|
||||
checkAuth: false
|
||||
});
|
||||
tempUser = data.find(item => item.userid == userid);
|
||||
} catch (_) {}
|
||||
|
||||
@ -625,7 +625,7 @@ export default {
|
||||
data: {
|
||||
userid: [this.userInfo.userid]
|
||||
},
|
||||
skipAuthError: true
|
||||
checkAuth: false
|
||||
}).then(({data}) => {
|
||||
this.addData.department_id = data[0]?.department[0] || 0;
|
||||
this.getProcdefList().then(_ => {
|
||||
|
||||
115
resources/assets/js/store/actions.js
vendored
115
resources/assets/js/store/actions.js
vendored
@ -210,13 +210,14 @@ export default {
|
||||
reject({ret: -1, data: {}, msg: "No server address"})
|
||||
return
|
||||
}
|
||||
|
||||
// 加密传输
|
||||
const encrypt = []
|
||||
if (params.encrypt === true) {
|
||||
// 有数据才加密
|
||||
if (params.data) {
|
||||
// PGP加密
|
||||
// 有数据才加密
|
||||
if (state.apiKeyData.type === 'pgp') {
|
||||
// PGP加密
|
||||
encrypt.push(`encrypt_type=${state.apiKeyData.type};encrypt_id=${state.apiKeyData.id}`)
|
||||
params.method = "post" // 加密传输时强制使用post
|
||||
params.data = {encrypted: await dispatch("pgpEncryptApi", params.data)}
|
||||
@ -227,51 +228,54 @@ export default {
|
||||
if (encrypt.length > 0) {
|
||||
params.header.encrypt = encrypt.join(";")
|
||||
}
|
||||
|
||||
// 数据转换
|
||||
if (params.method === "post") {
|
||||
params.data = JSON.stringify(params.data)
|
||||
}
|
||||
// Spinner
|
||||
|
||||
// 等待效果(Spinner)
|
||||
if (params.spinner === true || (typeof params.spinner === "number" && params.spinner > 0)) {
|
||||
const {before, complete} = params
|
||||
params.before = () => {
|
||||
dispatch("showSpinner", typeof params.spinner === "number" ? params.spinner : 0)
|
||||
typeof before === "function" && before()
|
||||
}
|
||||
//
|
||||
params.complete = () => {
|
||||
dispatch("hiddenSpinner")
|
||||
typeof complete === "function" && complete()
|
||||
}
|
||||
}
|
||||
// 请求回调
|
||||
|
||||
// 请求成功
|
||||
params.success = async (result, status, xhr) => {
|
||||
state.ajaxNetworkException = false
|
||||
state.ajaxNetworkException = null
|
||||
|
||||
// 数据校验
|
||||
if (!$A.isJson(result)) {
|
||||
console.log(result, status, xhr)
|
||||
reject({ret: -1, data: {}, msg: $A.L('返回参数错误')})
|
||||
return
|
||||
}
|
||||
|
||||
// 数据解密
|
||||
if (params.encrypt === true && result.encrypted) {
|
||||
result = await dispatch("pgpDecryptApi", result.encrypted)
|
||||
}
|
||||
const {ret, data, msg} = result
|
||||
|
||||
// 身份判断(身份丢失)
|
||||
if (ret === -1) {
|
||||
state.userId = 0
|
||||
if (params.skipAuthError !== true) {
|
||||
//身份丢失
|
||||
$A.modalError({
|
||||
content: msg,
|
||||
onOk: () => {
|
||||
dispatch("logout")
|
||||
}
|
||||
})
|
||||
reject(result)
|
||||
if (params.checkAuth !== false) {
|
||||
state.ajaxAuthException = msg || $A.L('请登录后继续...')
|
||||
reject(Object.assign(result, {msg: false}))
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
// 身份判断(需要昵称)
|
||||
if (ret === -2 && params.checkNick !== false) {
|
||||
// 需要昵称
|
||||
dispatch("userEditInput", 'nickname').then(() => {
|
||||
dispatch("call", cloneParams).then(resolve).catch(reject)
|
||||
}).catch(err => {
|
||||
@ -279,8 +283,9 @@ export default {
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
// 身份判断(需要联系电话)
|
||||
if (ret === -3 && params.checkTel !== false) {
|
||||
// 需要联系电话
|
||||
dispatch("userEditInput", 'tel').then(() => {
|
||||
dispatch("call", cloneParams).then(resolve).catch(reject)
|
||||
}).catch(err => {
|
||||
@ -288,48 +293,54 @@ export default {
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
// 返回数据
|
||||
if (ret === 1) {
|
||||
resolve({data, msg, xhr})
|
||||
} else {
|
||||
reject({ret, data, msg: msg || $A.L('未知错误')})
|
||||
//
|
||||
if (ret === -4001) {
|
||||
dispatch("forgetProject", data.project_id)
|
||||
} else if (ret === -4002) {
|
||||
if (data.force === 1) {
|
||||
state.taskArchiveView = 0
|
||||
}
|
||||
dispatch("forgetTask", data.task_id)
|
||||
} else if (ret === -4003) {
|
||||
dispatch("forgetDialog", data.dialog_id)
|
||||
} else if (ret === -4004) {
|
||||
dispatch("getTaskForParent", data.task_id).catch(() => {})
|
||||
}
|
||||
}
|
||||
}
|
||||
params.error = (xhr, status) => {
|
||||
const networkException = window.navigator.onLine === false || (status === 0 && xhr.readyState === 4)
|
||||
if (networkException
|
||||
&& cloneParams.method !== "post"
|
||||
&& cloneParams.__networkFailureRetry !== true) {
|
||||
// 网络异常,重试一次
|
||||
setTimeout(_ => {
|
||||
cloneParams.__networkFailureRetry = true
|
||||
dispatch("call", cloneParams).then(resolve).catch(reject)
|
||||
}, 1000)
|
||||
return
|
||||
}
|
||||
if (params.checkNetwork !== false) {
|
||||
state.ajaxNetworkException = networkException
|
||||
|
||||
// 错误处理
|
||||
reject({ret, data, msg: msg || $A.L('未知错误')})
|
||||
if (ret === -4001) {
|
||||
dispatch("forgetProject", data.project_id)
|
||||
} else if (ret === -4002) {
|
||||
data.force === 1 && (state.taskArchiveView = 0)
|
||||
dispatch("forgetTask", data.task_id)
|
||||
} else if (ret === -4003) {
|
||||
dispatch("forgetDialog", data.dialog_id)
|
||||
} else if (ret === -4004) {
|
||||
dispatch("getTaskForParent", data.task_id).catch(() => {})
|
||||
}
|
||||
if (networkException) {
|
||||
reject({ret: -1001, data: {}, msg: $A.L('网络异常,请重试。')})
|
||||
} else {
|
||||
reject({ret: -1, data: {}, msg: $A.L('请求失败,请重试。')})
|
||||
}
|
||||
|
||||
// 请求失败
|
||||
params.error = async (xhr, status) => {
|
||||
const reason = {ret: -1, data: {}, msg: $A.L('请求失败,请重试。')}
|
||||
const isNetworkException = window.navigator.onLine === false || (status === 0 && xhr.readyState === 4)
|
||||
|
||||
// 网络异常
|
||||
if (isNetworkException) {
|
||||
// 重试一次
|
||||
if (cloneParams.method !== "post" && cloneParams.networkFailureRetry !== false) {
|
||||
await new Promise(resolve => setTimeout(resolve, 1000));
|
||||
dispatch("call", Object.assign(cloneParams, {networkFailureRetry: false})).then(resolve).catch(reject)
|
||||
return
|
||||
}
|
||||
// 异常提示
|
||||
reason.ret = -1001
|
||||
reason.msg = params.checkNetwork !== false ? false : $A.L('网络异常,请重试。')
|
||||
if (params.checkNetwork !== false) {
|
||||
state.ajaxNetworkException = $A.L("网络连接失败,请检查网络设置。")
|
||||
}
|
||||
}
|
||||
|
||||
// 异常处理
|
||||
reject(reason)
|
||||
console.error(xhr, status);
|
||||
}
|
||||
//
|
||||
|
||||
// 发起请求
|
||||
$A.ajaxc(params)
|
||||
})
|
||||
},
|
||||
@ -770,7 +781,7 @@ export default {
|
||||
data: {
|
||||
userid: [...new Set(array.map(({userid}) => userid))]
|
||||
},
|
||||
skipAuthError: true
|
||||
checkAuth: false
|
||||
}).then(result => {
|
||||
time = $A.dayjs().unix();
|
||||
array.forEach(value => {
|
||||
|
||||
3
resources/assets/js/store/state.js
vendored
3
resources/assets/js/store/state.js
vendored
@ -95,7 +95,8 @@ export default {
|
||||
cacheKeyboard: {},
|
||||
|
||||
// Ajax
|
||||
ajaxNetworkException: false,
|
||||
ajaxAuthException: null,
|
||||
ajaxNetworkException: null,
|
||||
|
||||
// Websocket
|
||||
ws: null,
|
||||
|
||||
|
Before Width: | Height: | Size: 21 KiB After Width: | Height: | Size: 21 KiB |
Loading…
x
Reference in New Issue
Block a user