From adedafde038dcb591780b31a8c358b1d0853f1ff Mon Sep 17 00:00:00 2001 From: Aicirou <2643053021@qq.com> Date: Sat, 4 Jul 2020 23:29:55 +0800 Subject: [PATCH] :art:Optimize tips --- src/locales/en.json | 3 +- src/locales/zh-chs.json | 3 +- src/locales/zh-cht.json | 3 +- src/plugin/axios/index.js | 13 +++-- src/views/page/GoList.vue | 112 ++++++++++++++++++++------------------ 5 files changed, 75 insertions(+), 59 deletions(-) diff --git a/src/locales/en.json b/src/locales/en.json index d610770..10d20b9 100644 --- a/src/locales/en.json +++ b/src/locales/en.json @@ -54,6 +54,7 @@ "tips": "New version detected, Go to GitHub" }, "error": { - "shortcut_not_down": "Shortcut can't open/download" + "shortcut_not_down": "Shortcut can't open/download", + "401": "Unauthorized, please login" } } \ No newline at end of file diff --git a/src/locales/zh-chs.json b/src/locales/zh-chs.json index 241acb5..ed3659b 100644 --- a/src/locales/zh-chs.json +++ b/src/locales/zh-chs.json @@ -54,6 +54,7 @@ "tips": "检测到有新版本,前往GitHub" }, "error": { - "shortcut_not_down": "快捷方式无法打开/下载" + "shortcut_not_down": "快捷方式无法打开/下载", + "401": "未授权,请登录" } } diff --git a/src/locales/zh-cht.json b/src/locales/zh-cht.json index a95a35a..40e0ca5 100644 --- a/src/locales/zh-cht.json +++ b/src/locales/zh-cht.json @@ -54,6 +54,7 @@ "tips": "檢測到有新版本,前往GitHub" }, "error": { - "shortcut_not_down": "快捷方式無法打開/下載" + "shortcut_not_down": "快捷方式無法打開/下載", + "401": "未授權,請登錄" } } diff --git a/src/plugin/axios/index.js b/src/plugin/axios/index.js index 657e0a6..c3d60d8 100644 --- a/src/plugin/axios/index.js +++ b/src/plugin/axios/index.js @@ -1,6 +1,6 @@ import axios from "axios"; import store from "@/store"; -import router from "@/router"; +import notify from "@/components/notification"; // 创建一个 axios 实例 const service = axios.create({ @@ -33,14 +33,19 @@ service.interceptors.response.use( if (error && error.response) { switch (error.response.status) { case 401: - error.message = "未授权,请登录"; + error.message = "error.401"; + notify({ + title: "notify.title", + message: error.message, + type: "error", + duration: 5 * 1000, + }); break; default: + console.log(error); break; } } - console.log(error); - router.app.$router.go(-1); return Promise.reject(error); } ); diff --git a/src/views/page/GoList.vue b/src/views/page/GoList.vue index 493cf3a..e22dc93 100644 --- a/src/views/page/GoList.vue +++ b/src/views/page/GoList.vue @@ -1,6 +1,10 @@