From 81f8a01cc1a7000bf41677a89d533fff363996b3 Mon Sep 17 00:00:00 2001 From: kuaifan Date: Wed, 20 Apr 2022 06:39:30 +0800 Subject: [PATCH] no message --- cmd | 6 ++- resources/assets/js/App.vue | 4 +- .../assets/js/components/NetworkException.vue | 47 +++++++++++++++++++ resources/assets/js/pages/manage.vue | 14 ++++-- resources/assets/js/store/actions.js | 7 ++- resources/assets/js/store/state.js | 1 + 6 files changed, 70 insertions(+), 9 deletions(-) create mode 100644 resources/assets/js/components/NetworkException.vue diff --git a/cmd b/cmd index a1266017b..a4aaa0ad2 100755 --- a/cmd +++ b/cmd @@ -126,6 +126,10 @@ run_electron() { if [ "$argv" != "dev" ] && [ "$argv" != "--nobuild" ]; then npx mix --production -- --env --electron fi + if [ "$argv" == "dev" ]; then + run_exec php "php bin/run --mode=$argv" + supervisorctl_restart php + fi node ./electron/build.js $argv } @@ -293,7 +297,7 @@ if [ $# -gt 0 ]; then [[ -z "$(env_get APP_KEY)" ]] && run_exec php "php artisan key:generate" run_exec php "php bin/run --mode=prod" # 检查数据库 - remaining=10 + remaining=20 while [ ! -f "${cur_path}/docker/mysql/data/$(env_get DB_DATABASE)/db.opt" ]; do ((remaining=$remaining-1)) if [ $remaining -lt 0 ]; then diff --git a/resources/assets/js/App.vue b/resources/assets/js/App.vue index 44e1c248c..d7e4810fe 100755 --- a/resources/assets/js/App.vue +++ b/resources/assets/js/App.vue @@ -7,6 +7,7 @@ + @@ -16,9 +17,10 @@ import Spinner from "./components/Spinner"; import RightBottom from "./components/RightBottom"; import PreviewImageState from "./components/PreviewImage/state"; import {mapState} from "vuex"; +import NetworkException from "./components/NetworkException"; export default { - components: {PreviewImageState, RightBottom, Spinner}, + components: {NetworkException, PreviewImageState, RightBottom, Spinner}, data() { return { diff --git a/resources/assets/js/components/NetworkException.vue b/resources/assets/js/components/NetworkException.vue new file mode 100644 index 000000000..dfa17b82e --- /dev/null +++ b/resources/assets/js/components/NetworkException.vue @@ -0,0 +1,47 @@ + + + diff --git a/resources/assets/js/pages/manage.vue b/resources/assets/js/pages/manage.vue index 3d580f10c..b32a66eff 100644 --- a/resources/assets/js/pages/manage.vue +++ b/resources/assets/js/pages/manage.vue @@ -937,11 +937,15 @@ export default { getReportUnread(timeout) { this.reportUnreadTimeout && clearTimeout(this.reportUnreadTimeout) this.reportUnreadTimeout = setTimeout(() => { - this.$store.dispatch("call", { - url: 'report/unread', - }).then(({data}) => { - this.reportUnreadNumber = data.total || 0; - }).catch(() => {}); + if (this.userId === 0) { + this.reportUnreadNumber = 0; + } else { + this.$store.dispatch("call", { + url: 'report/unread', + }).then(({data}) => { + this.reportUnreadNumber = data.total || 0; + }).catch(() => {}); + } }, typeof timeout === "number" ? timeout : 1000) }, diff --git a/resources/assets/js/store/actions.js b/resources/assets/js/store/actions.js index 5e09285f2..7f57866e7 100644 --- a/resources/assets/js/store/actions.js +++ b/resources/assets/js/store/actions.js @@ -33,6 +33,7 @@ export default { } // params.success = (result, status, xhr) => { + state.ajaxNetworkException = false; if (!$A.isJson(result)) { console.log(result, status, xhr); reject({ret: -1, data: {}, msg: "Return error"}) @@ -47,6 +48,7 @@ export default { dispatch("logout") } }); + reject(result) return; } if (ret === -2 && params.checkNick !== false) { @@ -75,8 +77,9 @@ export default { } }; params.error = (xhr, status) => { - if (window.navigator.onLine === false || (status === 0 && xhr.readyState === 4)) { - reject({ret: -1, data: {}, msg: $A.L('网络异常,请稍后再试!')}) + state.ajaxNetworkException = window.navigator.onLine === false || (status === 0 && xhr.readyState === 4); + if (state.ajaxNetworkException) { + reject({ret: -1001, data: {}, msg: "Network exception"}) } else { reject({ret: -1, data: {}, msg: "System error"}) } diff --git a/resources/assets/js/store/state.js b/resources/assets/js/store/state.js index 53a9eafc6..cec6666f6 100644 --- a/resources/assets/js/store/state.js +++ b/resources/assets/js/store/state.js @@ -37,6 +37,7 @@ const stateData = { // Ajax ajaxWsReady: false, ajaxWsListener: [], + ajaxNetworkException: false, // Websocket ws: null,