🎨Optimize tips

This commit is contained in:
Aicirou 2020-07-04 23:29:55 +08:00
parent 1bdbf46020
commit adedafde03
5 changed files with 75 additions and 59 deletions

View File

@ -54,6 +54,7 @@
"tips": "New version detected, <a href='${url}'>Go to GitHub</a>" "tips": "New version detected, <a href='${url}'>Go to GitHub</a>"
}, },
"error": { "error": {
"shortcut_not_down": "Shortcut can't open/download" "shortcut_not_down": "Shortcut can't open/download",
"401": "Unauthorized, please login"
} }
} }

View File

@ -54,6 +54,7 @@
"tips": "检测到有新版本,<a href='${url}'>前往GitHub</a>" "tips": "检测到有新版本,<a href='${url}'>前往GitHub</a>"
}, },
"error": { "error": {
"shortcut_not_down": "快捷方式无法打开/下载" "shortcut_not_down": "快捷方式无法打开/下载",
"401": "未授权,请登录"
} }
} }

View File

@ -54,6 +54,7 @@
"tips": "檢測到有新版本,<a href='${url}'>前往GitHub</a>" "tips": "檢測到有新版本,<a href='${url}'>前往GitHub</a>"
}, },
"error": { "error": {
"shortcut_not_down": "快捷方式無法打開/下載" "shortcut_not_down": "快捷方式無法打開/下載",
"401": "未授權,請登錄"
} }
} }

View File

@ -1,6 +1,6 @@
import axios from "axios"; import axios from "axios";
import store from "@/store"; import store from "@/store";
import router from "@/router"; import notify from "@/components/notification";
// 创建一个 axios 实例 // 创建一个 axios 实例
const service = axios.create({ const service = axios.create({
@ -33,14 +33,19 @@ service.interceptors.response.use(
if (error && error.response) { if (error && error.response) {
switch (error.response.status) { switch (error.response.status) {
case 401: case 401:
error.message = "未授权,请登录"; error.message = "error.401";
notify({
title: "notify.title",
message: error.message,
type: "error",
duration: 5 * 1000,
});
break; break;
default: default:
console.log(error);
break; break;
} }
} }
console.log(error);
router.app.$router.go(-1);
return Promise.reject(error); return Promise.reject(error);
} }
); );

View File

@ -1,6 +1,10 @@
<template> <template>
<div> <div>
<headmd :option="headmd" v-if="renderHeadMD && headmd.display" style="margin:1rem 0;"></headmd> <headmd
:option="headmd"
v-if="renderHeadMD && headmd.display"
style="margin:1rem 0;"
></headmd>
<bread-crumb ref="breadcrumb"></bread-crumb> <bread-crumb ref="breadcrumb"></bread-crumb>
<div class="golist" v-loading="loading"> <div class="golist" v-loading="loading">
<list-view <list-view
@ -27,7 +31,10 @@
<div slot="no-more"></div> <div slot="no-more"></div>
<div slot="no-results"></div> <div slot="no-results"></div>
</infinite-loading> </infinite-loading>
<div v-show="files.length === 0" class="has-text-centered no-content"></div> <div
v-show="files.length === 0"
class="has-text-centered no-content"
></div>
</div> </div>
<div <div
class="is-divider" class="is-divider"
@ -35,7 +42,10 @@
$t('list.total') + ' ' + files.length + ' ' + $t('list.item') $t('list.total') + ' ' + files.length + ' ' + $t('list.item')
" "
></div> ></div>
<readmemd :option="readmemd" v-if="renderReadMeMD && readmemd.display"></readmemd> <readmemd
:option="readmemd"
v-if="renderReadMeMD && readmemd.display"
></readmemd>
<viewer <viewer
v-if="viewer && images && images.length > 0" v-if="viewer && images && images.length > 0"
@ -123,7 +133,7 @@ export default {
"image/bmp": "icon-img", "image/bmp": "icon-img",
"image/jpeg": "icon-img", "image/jpeg": "icon-img",
"image/png": "icon-img", "image/png": "icon-img",
"image/gif": "icon-img" "image/gif": "icon-img",
}, },
headmd: { display: false, file: {}, path: "" }, headmd: { display: false, file: {}, path: "" },
readmemd: { display: false, file: {}, path: "" }, readmemd: { display: false, file: {}, path: "" },
@ -132,9 +142,7 @@ export default {
computed: { computed: {
...mapState("acrou/view", ["mode"]), ...mapState("acrou/view", ["mode"]),
images() { images() {
return this.files.filter( return this.files.filter((file) => file.mimeType.startsWith("image/"));
(file) => file.mimeType.startsWith("image/")
);
}, },
renderHeadMD() { renderHeadMD() {
return window.themeOptions.render.head_md || false; return window.themeOptions.render.head_md || false;
@ -198,9 +206,8 @@ export default {
} }
this.loading = false; this.loading = false;
}) })
.catch((e) => { .catch(() => {
this.loading = false; this.loading = false;
console.log(e);
}); });
}, },
buildFiles(files) { buildFiles(files) {
@ -243,15 +250,16 @@ export default {
this.$copyText(path) this.$copyText(path)
.then(() => { .then(() => {
this.$notify({ this.$notify({
title: this.$t("notify.title"), title: "notify.title",
message: this.$t("copy.success"), message: "copy.success",
type: "success", type: "success",
}); });
}) })
.catch(() => { .catch(() => {
this.$notify.error({ this.$notify({
title: this.$t("notify.title"), title: "notify.title",
message: this.$t("copy.error"), message: "copy.error",
type: "error"
}); });
}); });
}, },
@ -265,8 +273,8 @@ export default {
// If it is a shortcut, the prompt cannot be downloaded // If it is a shortcut, the prompt cannot be downloaded
if (file.mimeType === "application/vnd.google-apps.shortcut") { if (file.mimeType === "application/vnd.google-apps.shortcut") {
this.$notify({ this.$notify({
title: this.$t("notify.title"), title: "notify.title",
message: this.$t("error.shortcut_not_down"), message: "error.shortcut_not_down",
type: "warning", type: "warning",
}); });
return; return;