🎨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>"
},
"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>"
},
"error": {
"shortcut_not_down": "快捷方式无法打开/下载"
"shortcut_not_down": "快捷方式无法打开/下载",
"401": "未授权,请登录"
}
}

View File

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

View File

@ -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);
}
);

View File

@ -1,6 +1,10 @@
<template>
<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>
<div class="golist" v-loading="loading">
<list-view
@ -27,7 +31,10 @@
<div slot="no-more"></div>
<div slot="no-results"></div>
</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
class="is-divider"
@ -35,7 +42,10 @@
$t('list.total') + ' ' + files.length + ' ' + $t('list.item')
"
></div>
<readmemd :option="readmemd" v-if="renderReadMeMD && readmemd.display"></readmemd>
<readmemd
:option="readmemd"
v-if="renderReadMeMD && readmemd.display"
></readmemd>
<viewer
v-if="viewer && images && images.length > 0"
@ -81,7 +91,7 @@ export default {
Readmemd: Markdown,
InfiniteLoading,
},
data: function () {
data: function() {
return {
infiniteId: +new Date(),
loading: true,
@ -123,7 +133,7 @@ export default {
"image/bmp": "icon-img",
"image/jpeg": "icon-img",
"image/png": "icon-img",
"image/gif": "icon-img"
"image/gif": "icon-img",
},
headmd: { display: false, file: {}, path: "" },
readmemd: { display: false, file: {}, path: "" },
@ -131,23 +141,21 @@ export default {
},
computed: {
...mapState("acrou/view", ["mode"]),
images () {
return this.files.filter(
(file) => file.mimeType.startsWith("image/")
);
images() {
return this.files.filter((file) => file.mimeType.startsWith("image/"));
},
renderHeadMD () {
renderHeadMD() {
return window.themeOptions.render.head_md || false;
},
renderReadMeMD () {
renderReadMeMD() {
return window.themeOptions.render.readme_md || false;
},
},
created () {
created() {
this.render();
},
methods: {
infiniteHandler ($state) {
infiniteHandler($state) {
//
if (!this.page.page_token) {
return;
@ -155,7 +163,7 @@ export default {
this.page.page_index++;
this.render($state);
},
render ($state) {
render($state) {
this.headmd = { display: false, file: {}, path: "" };
this.readmemd = { display: false, file: {}, path: "" };
var path = this.$route.path;
@ -198,12 +206,11 @@ export default {
}
this.loading = false;
})
.catch((e) => {
.catch(() => {
this.loading = false;
console.log(e);
});
},
buildFiles (files) {
buildFiles(files) {
var path = this.$route.path;
return !files
? []
@ -228,7 +235,7 @@ export default {
return a.isFolder ? -1 : 1;
});
},
checkPassword (path) {
checkPassword(path) {
var pass = prompt(this.$t("list.auth"), "");
localStorage.setItem("password" + path, pass);
if (pass != null && pass != "") {
@ -237,36 +244,37 @@ export default {
this.$router.go(-1);
}
},
copy (path) {
copy(path) {
let origin = window.location.origin;
path = origin + encodeURI(path);
this.$copyText(path)
.then(() => {
this.$notify({
title: this.$t("notify.title"),
message: this.$t("copy.success"),
title: "notify.title",
message: "copy.success",
type: "success",
});
})
.catch(() => {
this.$notify.error({
title: this.$t("notify.title"),
message: this.$t("copy.error"),
this.$notify({
title: "notify.title",
message: "copy.error",
type: "error"
});
});
},
thum (url) {
thum(url) {
return url ? `/${this.$route.params.id}:view?url=${url}` : "";
},
inited (viewer) {
inited(viewer) {
this.$viewer = viewer;
},
action (file, target) {
action(file, target) {
// If it is a shortcut, the prompt cannot be downloaded
if (file.mimeType === "application/vnd.google-apps.shortcut") {
this.$notify({
title: this.$t("notify.title"),
message: this.$t("error.shortcut_not_down"),
title: "notify.title",
message: "error.shortcut_not_down",
type: "warning",
});
return;
@ -286,7 +294,7 @@ export default {
}
this.target(file, target);
},
target (file, target) {
target(file, target) {
let path = file.path;
if (target === "_blank") {
window.open(path);
@ -313,7 +321,7 @@ export default {
return;
}
},
renderMd (files, path) {
renderMd(files, path) {
var cmd = this.$route.params.cmd;
if (cmd) {
return;
@ -337,7 +345,7 @@ export default {
}
});
},
goSearchResult (file, target) {
goSearchResult(file, target) {
this.loading = true;
let id = this.$route.params.id;
this.axios
@ -355,7 +363,7 @@ export default {
console.log(e);
});
},
getIcon (type) {
getIcon(type) {
return "#" + (this.icon[type] ? this.icon[type] : "icon-file");
},
},