优化性能

This commit is contained in:
Aicirou 2020-05-13 05:19:42 +08:00
parent 293f05bb72
commit 84690b2e6e
20 changed files with 320 additions and 173 deletions

1
.gitignore vendored
View File

@ -1,6 +1,7 @@
.DS_Store .DS_Store
node_modules node_modules
/dist /dist
src/test
# local env files # local env files
.env.local .env.local

View File

@ -17,5 +17,5 @@ module.exports = [
{ name: '', library: '', js: '', css: 'https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.13.0/css/all.min.css' }, { name: '', library: '', js: '', css: 'https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.13.0/css/all.min.css' },
{ name: '', library: '', js: '', css: 'https://cdn.jsdelivr.net/npm/font-awesome@latest/css/font-awesome.min.css' }, { name: '', library: '', js: '', css: 'https://cdn.jsdelivr.net/npm/font-awesome@latest/css/font-awesome.min.css' },
{ name: '', library: '', js: '', css: 'https://cdn.jsdelivr.net/npm/font-awesome-animation@0.2.1/dist/font-awesome-animation.min.css' }, { name: '', library: '', js: '', css: 'https://cdn.jsdelivr.net/npm/font-awesome-animation@0.2.1/dist/font-awesome-animation.min.css' },
{ name: '', library: '', js: '', css: 'https://cdn.jsdelivr.net/npm/bulma-pageloader@0.3.0/dist/css/bulma-pageloader.min.css' }, // { name: '', library: '', js: '', css: 'https://cdn.jsdelivr.net/npm/bulma-pageloader@0.3.0/dist/css/bulma-pageloader.min.css' },
] ]

51
package-lock.json generated
View File

@ -2692,6 +2692,11 @@
"resolved": "https://registry.npm.taobao.org/bulma/download/bulma-0.8.2.tgz", "resolved": "https://registry.npm.taobao.org/bulma/download/bulma-0.8.2.tgz",
"integrity": "sha1-XZKPFu1KhFScKHP5XJLDjGnGMac=" "integrity": "sha1-XZKPFu1KhFScKHP5XJLDjGnGMac="
}, },
"bulma-pageloader": {
"version": "0.3.0",
"resolved": "https://registry.npm.taobao.org/bulma-pageloader/download/bulma-pageloader-0.3.0.tgz",
"integrity": "sha1-lKT/fZEpy+AdvFyuTmRQjhNWPPE="
},
"bytes": { "bytes": {
"version": "3.1.0", "version": "3.1.0",
"resolved": "https://registry.npm.taobao.org/bytes/download/bytes-3.1.0.tgz?cache=0&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fbytes%2Fdownload%2Fbytes-3.1.0.tgz", "resolved": "https://registry.npm.taobao.org/bytes/download/bytes-3.1.0.tgz?cache=0&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fbytes%2Fdownload%2Fbytes-3.1.0.tgz",
@ -3180,10 +3185,15 @@
"integrity": "sha1-sEM9C06chH7xiGik7xb9X8gnHEg=", "integrity": "sha1-sEM9C06chH7xiGik7xb9X8gnHEg=",
"dev": true "dev": true
}, },
"clipboard-polyfill": { "clipboard": {
"version": "2.8.6", "version": "2.0.6",
"resolved": "https://registry.npm.taobao.org/clipboard-polyfill/download/clipboard-polyfill-2.8.6.tgz", "resolved": "https://registry.npm.taobao.org/clipboard/download/clipboard-2.0.6.tgz?cache=0&sync_timestamp=1583389652647&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fclipboard%2Fdownload%2Fclipboard-2.0.6.tgz",
"integrity": "sha1-GdJyg/EfKTO7GHNyY7mLjJW1oPc=" "integrity": "sha1-UpISlu7A/fd+rRdJQhshyWhkc3Y=",
"requires": {
"good-listener": "^1.2.2",
"select": "^1.1.2",
"tiny-emitter": "^2.0.0"
}
}, },
"clipboardy": { "clipboardy": {
"version": "2.3.0", "version": "2.3.0",
@ -4177,6 +4187,11 @@
"resolved": "http://registry.npm.taobao.org/delayed-stream/download/delayed-stream-1.0.0.tgz", "resolved": "http://registry.npm.taobao.org/delayed-stream/download/delayed-stream-1.0.0.tgz",
"integrity": "sha1-3zrhmayt+31ECqrgsp4icrJOxhk=" "integrity": "sha1-3zrhmayt+31ECqrgsp4icrJOxhk="
}, },
"delegate": {
"version": "3.2.0",
"resolved": "https://registry.npm.taobao.org/delegate/download/delegate-3.2.0.tgz",
"integrity": "sha1-tmtxwxWFIuirV0T3INjKDCr1kWY="
},
"delegates": { "delegates": {
"version": "1.0.0", "version": "1.0.0",
"resolved": "http://registry.npm.taobao.org/delegates/download/delegates-1.0.0.tgz", "resolved": "http://registry.npm.taobao.org/delegates/download/delegates-1.0.0.tgz",
@ -6132,6 +6147,14 @@
"minimatch": "~3.0.2" "minimatch": "~3.0.2"
} }
}, },
"good-listener": {
"version": "1.2.2",
"resolved": "https://registry.npm.taobao.org/good-listener/download/good-listener-1.2.2.tgz",
"integrity": "sha1-1TswzfkxPf+33JoNR3CWqm0UXFA=",
"requires": {
"delegate": "^3.1.2"
}
},
"graceful-fs": { "graceful-fs": {
"version": "4.2.3", "version": "4.2.3",
"resolved": "https://registry.npm.taobao.org/graceful-fs/download/graceful-fs-4.2.3.tgz", "resolved": "https://registry.npm.taobao.org/graceful-fs/download/graceful-fs-4.2.3.tgz",
@ -10411,6 +10434,11 @@
} }
} }
}, },
"select": {
"version": "1.1.2",
"resolved": "https://registry.npm.taobao.org/select/download/select-1.1.2.tgz",
"integrity": "sha1-DnNQrN7ICxEIUoeG7B1EGNEbOW0="
},
"select-hose": { "select-hose": {
"version": "2.0.0", "version": "2.0.0",
"resolved": "http://registry.npm.taobao.org/select-hose/download/select-hose-2.0.0.tgz", "resolved": "http://registry.npm.taobao.org/select-hose/download/select-hose-2.0.0.tgz",
@ -11476,6 +11504,11 @@
"integrity": "sha1-QFQRqOfmM5/mTbmiNN4R3DHgK9Q=", "integrity": "sha1-QFQRqOfmM5/mTbmiNN4R3DHgK9Q=",
"dev": true "dev": true
}, },
"tiny-emitter": {
"version": "2.1.0",
"resolved": "https://registry.npm.taobao.org/tiny-emitter/download/tiny-emitter-2.1.0.tgz",
"integrity": "sha1-HRpW7fxRxD6GPLtTgqcjMONVVCM="
},
"tmp": { "tmp": {
"version": "0.0.33", "version": "0.0.33",
"resolved": "https://registry.npm.taobao.org/tmp/download/tmp-0.0.33.tgz", "resolved": "https://registry.npm.taobao.org/tmp/download/tmp-0.0.33.tgz",
@ -12006,6 +12039,14 @@
} }
} }
}, },
"vue-clipboard2": {
"version": "0.3.1",
"resolved": "https://registry.npm.taobao.org/vue-clipboard2/download/vue-clipboard2-0.3.1.tgz",
"integrity": "sha1-blUft704SImyiw2jsSKJ7WvKSJQ=",
"requires": {
"clipboard": "^2.0.0"
}
},
"vue-eslint-parser": { "vue-eslint-parser": {
"version": "7.0.0", "version": "7.0.0",
"resolved": "https://registry.npm.taobao.org/vue-eslint-parser/download/vue-eslint-parser-7.0.0.tgz", "resolved": "https://registry.npm.taobao.org/vue-eslint-parser/download/vue-eslint-parser-7.0.0.tgz",
@ -12327,7 +12368,7 @@
}, },
"webpack-bundle-analyzer": { "webpack-bundle-analyzer": {
"version": "3.7.0", "version": "3.7.0",
"resolved": "https://registry.npm.taobao.org/webpack-bundle-analyzer/download/webpack-bundle-analyzer-3.7.0.tgz?cache=0&sync_timestamp=1586846559504&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fwebpack-bundle-analyzer%2Fdownload%2Fwebpack-bundle-analyzer-3.7.0.tgz", "resolved": "https://registry.npm.taobao.org/webpack-bundle-analyzer/download/webpack-bundle-analyzer-3.7.0.tgz?cache=0&sync_timestamp=1586846510646&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fwebpack-bundle-analyzer%2Fdownload%2Fwebpack-bundle-analyzer-3.7.0.tgz",
"integrity": "sha1-hNpDTolEKJm4hNmtOORm0NsCpW8=", "integrity": "sha1-hNpDTolEKJm4hNmtOORm0NsCpW8=",
"dev": true, "dev": true,
"requires": { "requires": {

View File

@ -12,7 +12,7 @@
"dependencies": { "dependencies": {
"axios": "^0.19.2", "axios": "^0.19.2",
"bulma": "^0.8.2", "bulma": "^0.8.2",
"clipboard-polyfill": "^2.8.6", "bulma-pageloader": "^0.3.0",
"core-js": "^3.6.4", "core-js": "^3.6.4",
"element-ui": "^2.13.1", "element-ui": "^2.13.1",
"js-base64": "^2.5.2", "js-base64": "^2.5.2",
@ -22,6 +22,7 @@
"sass-loader": "^8.0.2", "sass-loader": "^8.0.2",
"vue": "^2.6.11", "vue": "^2.6.11",
"vue-axios": "^2.1.5", "vue-axios": "^2.1.5",
"vue-clipboard2": "^0.3.1",
"vue-i18n": "^8.17.3", "vue-i18n": "^8.17.3",
"vue-router": "^3.1.6", "vue-router": "^3.1.6",
"vue2-ace-editor": "0.0.15" "vue2-ace-editor": "0.0.15"

View File

@ -51,6 +51,12 @@ body {
cursor: pointer; cursor: pointer;
} }
} }
td span {
vertical-align: middle;
}
td .g2-file-desc{
font-size:12px;
}
} }
.footer { .footer {

View File

@ -1,2 +1,3 @@
@import 'bulma'; @import 'bulma';
// @import 'bulma-pageloader';
@import '~@/assets/style/theme/acrou/index.scss'; @import '~@/assets/style/theme/acrou/index.scss';

View File

@ -2,6 +2,14 @@
"_name": "English", "_name": "English",
"languages": "Languages", "languages": "Languages",
"index": "Index", "index": "Index",
"folder": "Folder",
"notify": {
"title": "Notify"
},
"copy": {
"success": "Copy successful",
"error": "Copy failed"
},
"list": { "list": {
"auth": "Directory encryption, please enter password", "auth": "Directory encryption, please enter password",
"title": { "title": {
@ -21,6 +29,11 @@
"placeholder": "Search or jump to…" "placeholder": "Search or jump to…"
}, },
"page": { "page": {
"video": {
"play": "Play",
"download": "Download",
"link": "Download link"
},
"text": { "text": {
"loading": "Loading..." "loading": "Loading..."
} }

View File

@ -2,6 +2,14 @@
"_name": "简体中文", "_name": "简体中文",
"languages": "选择语言", "languages": "选择语言",
"index": "首页", "index": "首页",
"folder": "文件夹",
"notify": {
"title": "提示"
},
"copy": {
"success": "复制成功",
"error": "复制失败"
},
"list": { "list": {
"auth": "目录加密,请输入密码", "auth": "目录加密,请输入密码",
"title": { "title": {
@ -21,6 +29,11 @@
"placeholder": "搜索..." "placeholder": "搜索..."
}, },
"page": { "page": {
"video": {
"play": "播放",
"download": "下载",
"link": "下载地址"
},
"text": { "text": {
"loading": "加载中..." "loading": "加载中..."
} }

View File

@ -2,6 +2,14 @@
"_name": "繁体中文", "_name": "繁体中文",
"languages": "選擇語言", "languages": "選擇語言",
"index": "首頁", "index": "首頁",
"folder": "文件夾",
"notify": {
"title": "提示"
},
"copy": {
"success": "復制成功",
"error": "復制失敗"
},
"list": { "list": {
"auth": "目錄加密,請輸入密碼", "auth": "目錄加密,請輸入密碼",
"title": { "title": {
@ -21,6 +29,11 @@
"placeholder": "搜索..." "placeholder": "搜索..."
}, },
"page": { "page": {
"video": {
"play": "播放",
"download": "下載",
"link": "下載地址"
},
"text": { "text": {
"loading": "加載中..." "loading": "加載中..."
} }

View File

@ -4,15 +4,19 @@ import ElementUI from 'element-ui'
import 'element-ui/lib/theme-chalk/color-picker.css' import 'element-ui/lib/theme-chalk/color-picker.css'
import 'element-ui/lib/theme-chalk/base.css' import 'element-ui/lib/theme-chalk/base.css'
import 'element-ui/lib/theme-chalk/button.css' import 'element-ui/lib/theme-chalk/button.css'
import 'element-ui/lib/theme-chalk/notification.css'
import 'element-ui/lib/theme-chalk/loading.css'
import axios from '@utils/axios' import axios from '@utils/axios'
import VueAxios from 'vue-axios' import VueAxios from 'vue-axios'
import router from './router' import router from './router'
import i18n from './i18n' import i18n from './i18n'
import VueClipboard from 'vue-clipboard2'
import "@/assets/style/theme/register.scss" import "@/assets/style/theme/register.scss"
Vue.config.productionTip = false Vue.config.productionTip = false
Vue.use(ElementUI) Vue.use(ElementUI)
Vue.use(VueAxios,axios) Vue.use(VueAxios,axios)
Vue.use(VueClipboard)
new Vue({ new Vue({
router, router,

View File

@ -29,14 +29,18 @@ const router = new VueRouter({
* 权限验证 * 权限验证
*/ */
router.beforeEach(async (to, from, next) => { router.beforeEach(async (to, from, next) => {
if (process.env.NODE_ENV === "development") {
console.log("before:"); console.log("before:");
console.log(to,from); console.log(to, from);
}
next(); next();
}); });
router.afterEach((to) => { router.afterEach((to) => {
if (process.env.NODE_ENV === "development") {
console.log("after:"); console.log("after:");
console.log(to); console.log(to);
}
}); });
export default router; export default router;

View File

@ -6,7 +6,7 @@ const meta = {
} }
const frameIn = [{ const frameIn = [{
path: "/:id:(text)/:path", path: "/:id::cmd(text)/:path",
component: _import("page/GoText"), component: _import("page/GoText"),
meta: { meta: {
...meta, ...meta,
@ -14,7 +14,7 @@ const frameIn = [{
} }
}, },
{ {
path: "/:id:(pdf)/:path", path: "/:id::cmd(pdf)/:path",
component: _import("page/GoPdf"), component: _import("page/GoPdf"),
meta: { meta: {
...meta, ...meta,
@ -22,7 +22,7 @@ const frameIn = [{
} }
}, },
{ {
path: "/:id:(video)/:path", path: "/:id::cmd(video)/:path",
component: _import("page/GoVideo"), component: _import("page/GoVideo"),
meta: { meta: {
...meta, ...meta,
@ -30,7 +30,7 @@ const frameIn = [{
} }
}, },
{ {
path: "/:id:(image)/:path", path: "/:id::cmd(image)/:path",
component: _import("page/GoImg"), component: _import("page/GoImg"),
meta: { meta: {
...meta, ...meta,
@ -38,7 +38,15 @@ const frameIn = [{
} }
}, },
{ {
path: "/:id::cmd?(/?/??.*)", path: "/:id::cmd(search)(/?q=)*",
component: _import("page/GoList"),
meta: {
...meta,
view: 'list'
}
},
{
path: "/:id:/:path*",
component: _import("page/GoList"), component: _import("page/GoList"),
meta: { meta: {
...meta, ...meta,

View File

@ -38,7 +38,8 @@ export const checkView = (path) => {
.split(".") .split(".")
.pop() .pop()
.toLowerCase(); .toLowerCase();
let base64Path = Base64.encode(path); console.log(path)
let base64Path = encode64(path);
if ("|html|php|css|go|java|js|json|txt|sh|md|".indexOf(`|${ext}|`) >= 0) { if ("|html|php|css|go|java|js|json|txt|sh|md|".indexOf(`|${ext}|`) >= 0) {
path = path.replace(/\/(\d+:)\/.*/, (p1, p2) => { path = path.replace(/\/(\d+:)\/.*/, (p1, p2) => {
return `/${p2}text/${base64Path}`; return `/${p2}text/${base64Path}`;
@ -88,7 +89,7 @@ export const getURLParameters = (url) =>
//console.log(getQueryString("/Movies/xx.mp4?a=view&y=123", "y")); //console.log(getQueryString("/Movies/xx.mp4?a=view&y=123", "y"));
export const encode64 = (str) => { export const encode64 = (str) => {
return Base64.encode(str); return Base64.encodeURI(str);
}; };
export const decode64 = (str) => { export const decode64 = (str) => {

View File

@ -40,14 +40,16 @@ export default {
}, },
render() { render() {
this.index = this.$route.params.id; this.index = this.$route.params.id;
let path = this.$route.params.path let cmd = this.$route.params.cmd
? decode64(this.$route.params.path)
: this.$route.path;
// //
if (path.match("/[0-9]+:search")) { if (cmd === 'search') {
this.navs = []; this.navs = [];
return; return;
} }
let path = this.$route.path
if(cmd){
path = decode64(this.$route.params.path)
}
var arr = path.trim("/").split("/"); var arr = path.trim("/").split("/");
var p = "/"; var p = "/";
if (arr.length > 0) { if (arr.length > 0) {

View File

@ -14,6 +14,9 @@ export default {
this.render(); this.render();
} }
}, },
mounted() {
this.render();
},
data: function() { data: function() {
return { return {
content: '' content: ''
@ -34,9 +37,6 @@ export default {
render() { render() {
this.content = this.defaultContent this.content = this.defaultContent
const md = new MarkdownIt(); const md = new MarkdownIt();
// if (window.md == undefined) {
// window.md = window.markdownit();
// }
get_file(this.option, data => { get_file(this.option, data => {
this.content = md.render(data); this.content = md.render(data);
}); });

View File

@ -3,11 +3,11 @@
<div class="container"> <div class="container">
<div class="navbar-brand"> <div class="navbar-brand">
<a class="navbar-item" :href="currgd.id"> <a class="navbar-item" :href="currgd.id">
<h3 class="title is-3 has-text-white">{{siteName}}</h3> <h3 class="title is-3 has-text-white">{{ siteName }}</h3>
</a> </a>
<a <a
role="button" role="button"
:class="'navbar-burger burger '+(isActive?'is-active':'')" :class="'navbar-burger burger ' + (isActive ? 'is-active' : '')"
aria-label="menu" aria-label="menu"
aria-expanded="false" aria-expanded="false"
data-target="navbarBasicExample" data-target="navbarBasicExample"
@ -18,20 +18,24 @@
<span aria-hidden="true"></span> <span aria-hidden="true"></span>
</a> </a>
</div> </div>
<div id="navbarBasicExample" :class="'navbar-menu '+(isActive?'is-active':'')"> <div
id="navbarBasicExample"
:class="'navbar-menu ' + (isActive ? 'is-active' : '')"
>
<div class="navbar-start"> <div class="navbar-start">
<div <div
class="navbar-item has-dropdown is-hoverable" class="navbar-item has-dropdown is-hoverable"
v-if="gds.length>0 && getCurrGD.length>0" v-if="gds.length > 0 && getCurrGD.length > 0"
> >
<a class="navbar-link">{{this.currgd.name}}</a> <a class="navbar-link">{{ this.currgd.name }}</a>
<div class="navbar-dropdown is-boxed"> <div class="navbar-dropdown is-boxed">
<a <a
class="navbar-item" class="navbar-item"
@click="changeItem(item)" @click="changeItem(item)"
v-for="(item,index) in getCurrGD" v-for="(item, index) in getCurrGD"
v-bind:key="index" v-bind:key="index"
>{{item.name}}</a> >{{ item.name }}</a
>
</div> </div>
</div> </div>
</div> </div>
@ -57,7 +61,7 @@
<!-- <header-search /> --> <!-- <header-search /> -->
<header-locales /> <header-locales />
<div class="navbar-item"> <div class="navbar-item">
<header-color/> <header-color />
</div> </div>
<a <a
class="navbar-item" class="navbar-item"
@ -75,66 +79,70 @@
</template> </template>
<script> <script>
import headerSearch from '@/layout/header-aside/components/header-search' import headerSearch from "@/layout/header-aside/components/header-search";
import headerLocales from "@/layout/header-aside/components/header-locales"; import headerLocales from "@/layout/header-aside/components/header-locales";
import headerColor from '@/layout/header-aside/components/header-color' import headerColor from "@/layout/header-aside/components/header-color";
export default { export default {
components: { components: {
headerSearch, headerSearch,
headerLocales, headerLocales,
headerColor headerColor,
}, },
created() { created() {
this.siteName = document.getElementsByTagName("title")[0].innerText;
if (window.gds && window.gds.length > 0) { if (window.gds && window.gds.length > 0) {
this.gds = window.gds.map((item, index) => { this.gds = window.gds.map((item, index) => {
return { return {
name: item, name: item,
id: "/" + index + ":/" id: "/" + index + ":/",
}; };
}); });
this.currgd = localStorage.getItem("currgd") this.chooseGD();
? JSON.parse(localStorage.getItem("currgd"))
: this.gds[0];
} }
if (window.MODEL) { if (window.MODEL) {
this.param = window.MODEL.q ? window.MODEL.q : ""; this.param = window.MODEL.q ? window.MODEL.q : "";
} }
}, },
mounted() {
this.siteName = document.getElementsByTagName("title")[0].innerText;
},
data: function() { data: function() {
return { return {
siteName: "", siteName: "",
param: "", param: "",
currgd: {}, currgd: {},
gds: [], gds: [],
isActive: false isActive: false,
}; };
}, },
methods: { methods: {
chooseGD() {
let index = this.$route.params.id;
if (this.gds && this.gds.length >= index) {
this.currgd = this.gds[index];
}
},
changeItem(item) { changeItem(item) {
this.currgd = item; this.currgd = item;
localStorage.setItem("currgd", JSON.stringify(item));
this.$router.push({ this.$router.push({
path: item.id path: item.id,
}); });
}, },
query() { query() {
if (this.param) { if (this.param) {
this.$router.push({ this.$router.push({
path: this.currgd.id.match("/[0-9]+:") + "search?q=" + this.param path: this.currgd.id.match("/[0-9]+:") + "search?q=" + this.param,
}); });
} }
}, },
burgerClick() { burgerClick() {
this.isActive = !this.isActive; this.isActive = !this.isActive;
} },
}, },
computed: { computed: {
getCurrGD() { getCurrGD() {
return this.gds.filter(item => item.name !== this.currgd.name); return this.gds.filter((item) => item.name !== this.currgd.name);
} },
} },
watch: {
"$route.params.id": "chooseGD",
},
}; };
</script> </script>

View File

@ -29,7 +29,7 @@ export default {
return '' return ''
} }
}, },
created() { activated() {
this.render(); this.render();
}, },
methods: { methods: {

View File

@ -1,17 +1,17 @@
<template> <template>
<div> <div>
<headmd :option="headmd" v-if="headmd.display"></headmd> <headmd :option="headmd" v-if="headmd.display"></headmd>
<div class="golist"> <div class="golist" v-loading="loading">
<table class="table is-hoverable"> <table class="table is-hoverable">
<thead> <thead>
<tr> <tr>
<th <th
v-for="(column,index) in columns" v-for="(column, index) in columns"
v-bind:key="index" v-bind:key="index"
:class="column.class" :class="column.class"
:style="column.style" :style="column.style"
> >
{{column.name}} {{ column.name }}
<span class="caret-wrapper"> <span class="caret-wrapper">
<i class="sort-caret ascending"></i> <i class="sort-caret ascending"></i>
<i class="sort-caret descending"></i> <i class="sort-caret descending"></i>
@ -20,8 +20,17 @@
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
<tr v-for="(file,index) in files" v-bind:key="index"> <tr v-for="(file, index) in buildFiles" v-bind:key="index">
<td @click="go(file, file.mimeType!=='application/vnd.google-apps.folder'?'view':'')"> <td
@click="
go(
file,
file.mimeType !== 'application/vnd.google-apps.folder'
? 'view'
: ''
)
"
>
<svg class="iconfont" aria-hidden="true"> <svg class="iconfont" aria-hidden="true">
<use :xlink:href="getIcon(file.mimeType)" /> <use :xlink:href="getIcon(file.mimeType)" />
</svg> </svg>
@ -30,14 +39,14 @@
<img :src="file.thumbnailLink" /> <img :src="file.thumbnailLink" />
</figure> </figure>
</span>--> </span>-->
{{file.name}} {{ file.name }}
<span class="has-text-grey g2-file-desc">{{ file.description }}</span>
</td> </td>
<td class="is-hidden-mobile is-hidden-touch">{{file.modifiedTime}}</td> <td class="is-hidden-mobile is-hidden-touch">
<td class="is-hidden-mobile is-hidden-touch">{{file.size}}</td> {{ file.modifiedTime }}
<td </td>
class="is-hidden-mobile is-hidden-touch" <td class="is-hidden-mobile is-hidden-touch">{{ file.size }}</td>
v-if="file.mimeType!=='application/vnd.google-apps.folder'" <td class="is-hidden-mobile is-hidden-touch">
>
<span class="icon" @click.stop="copy(file.path)"> <span class="icon" @click.stop="copy(file.path)">
<i <i
class="fa fa-copy faa-shake animated-hover" class="fa fa-copy faa-shake animated-hover"
@ -45,14 +54,18 @@
aria-hidden="true" aria-hidden="true"
></i> ></i>
</span> </span>
<span class="icon" @click.stop="go(file,'_blank')"> <span class="icon" @click.stop="go(file, '_blank')">
<i <i
class="fa fa-external-link faa-shake animated-hover" class="fa fa-external-link faa-shake animated-hover"
:title="$t('list.opt.newTab')" :title="$t('list.opt.newTab')"
aria-hidden="true" aria-hidden="true"
></i> ></i>
</span> </span>
<span class="icon" @click.stop="go(file,'down')"> <span
class="icon"
@click.stop="go(file, 'down')"
v-if="file.mimeType !== 'application/vnd.google-apps.folder'"
>
<i <i
class="fa fa-download faa-shake animated-hover" class="fa fa-download faa-shake animated-hover"
aria-hidden="true" aria-hidden="true"
@ -63,10 +76,13 @@
</tr> </tr>
</tbody> </tbody>
</table> </table>
<div v-show="files.length==0" class="has-text-centered no-content"></div> <div
<div v-show="loading" class="pageloader is-active"> v-show="files.length == 0"
<span class="title">{{$t('list.loading')}}</span> class="has-text-centered no-content"
</div> ></div>
<!-- <div v-show="loading" class="pageloader is-active">
<span class="title">{{ $t("list.loading") }}</span>
</div> -->
</div> </div>
<hr /> <hr />
<readmemd :option="readmemd" v-if="readmemd.display"></readmemd> <readmemd :option="readmemd" v-if="readmemd.display"></readmemd>
@ -78,22 +94,21 @@ import {
formatDate, formatDate,
formatFileSize, formatFileSize,
checkoutPath, checkoutPath,
checkView checkView,
} from "@utils/AcrouUtil"; } from "@utils/AcrouUtil";
import axios from "@/utils/axios"; import axios from "@/utils/axios";
import Markdown from "../common/Markdown"; import Markdown from "../common/Markdown";
import * as clipboard from "clipboard-polyfill";
export default { export default {
name: "GoList", name: "GoList",
components: { components: {
Headmd: Markdown, Headmd: Markdown,
Readmemd: Markdown Readmemd: Markdown,
}, },
data: function () { data: function() {
return { return {
page: { page: {
page_token: null, page_token: null,
page_index: 0 page_index: 0,
}, },
files: [], files: [],
loading: true, loading: true,
@ -121,57 +136,68 @@ export default {
"icon-word", "icon-word",
"image/bmp": "icon-img", "image/bmp": "icon-img",
"image/jpeg": "icon-img", "image/jpeg": "icon-img",
"image/png": "icon-img" "image/png": "icon-img",
}, },
headmd: { display: false, file: {}, path: "" }, headmd: { display: false, file: {}, path: "" },
readmemd: { display: false, file: {}, path: "" } readmemd: { display: false, file: {}, path: "" },
}; };
}, },
computed: { computed: {
columns () { columns() {
return [ return [
{ name: this.$t("list.title.file"), style: "" }, { name: this.$t("list.title.file"), style: "" },
{ {
name: this.$t("list.title.moditime"), name: this.$t("list.title.moditime"),
style: "width:20%", style: "width:20%",
class: "is-hidden-mobile is-hidden-touch" class: "is-hidden-mobile is-hidden-touch",
}, },
{ {
name: this.$t("list.title.size"), name: this.$t("list.title.size"),
style: "width:10.5%", style: "width:10.5%",
class: "is-hidden-mobile is-hidden-touch" class: "is-hidden-mobile is-hidden-touch",
}, },
{ {
name: this.$t("list.title.operation"), name: this.$t("list.title.operation"),
style: "width:13.5%", style: "width:13.5%",
class: "is-hidden-mobile is-hidden-touch" class: "is-hidden-mobile is-hidden-touch",
}
];
}
}, },
mounted () { ];
},
buildFiles() {
var path = this.$route.path;
return this.files.map((item) => {
var p = path + checkoutPath(item.name, item);
let isFolder = item.mimeType === "application/vnd.google-apps.folder";
let size = isFolder ? this.$t("folder") : formatFileSize(item.size);
return {
path: p,
...item,
modifiedTime: formatDate(item.modifiedTime),
size: size,
isFolder: isFolder,
};
});
},
},
created() {
this.render(); this.render();
}, },
methods: { methods: {
cellClass (row) { render() {
if (row.columnIndex != 0) { this.headmd = { display: false, file: {}, path: "" };
return "is-hidden-mobile is-hidden-touch has-text-drak"; this.readmemd = { display: false, file: {}, path: "" };
} var path = this.$route.path;
},
render () {
let path = window.location.pathname;
this.loading = true; this.loading = true;
var password = localStorage.getItem("password" + path); var password = localStorage.getItem("password" + path);
// var param = window.location.search;
let q = this.$route.query.q; let q = this.$route.query.q;
var p = { var p = {
q: q ? decodeURIComponent(q) : "", q: q ? decodeURIComponent(q) : "",
password: password || null, password: password || null,
...this.page ...this.page,
}; };
this.axios this.axios
.post(path, p) .post(path, p)
.then(res => { .then((res) => {
var body = res.data; var body = res.data;
if (body) { if (body) {
// //
@ -179,42 +205,15 @@ export default {
this.checkPassword(path); this.checkPassword(path);
return; return;
} }
let data = body.data; var data = body.data;
if (!data) return; if (!data) return;
this.page = { this.page = {
page_token: body.nextPageToken, page_token: body.nextPageToken,
page_index: body.curPageIndex page_index: body.curPageIndex,
}; };
try { try {
this.files = data.files.map(item => { this.files = data.files;
var p = this.renderMd(data.files, path);
path.replace("search", "search/") +
checkoutPath(item.name, item);
if (!path.match("/[0-9]+:search")) {
// HEAD.md
if (item.name === "HEAD.md") {
this.headmd = {
display: true,
file: item,
path: path + item.name
};
}
// REDEME.md
if (item.name === "README.md") {
this.readmemd = {
display: true,
file: item,
path: path + item.name
};
}
}
return {
path: p,
...item,
modifiedTime: formatDate(item.modifiedTime),
size: formatFileSize(item.size)
};
});
} catch (e) { } catch (e) {
console.log(e); console.log(e);
} }
@ -223,55 +222,94 @@ export default {
}) })
.catch(() => { .catch(() => {
this.loading = false; this.loading = false;
this.$router.go(-1);
}); });
}, },
checkPassword (path) { checkPassword(path) {
var pass = prompt(this.$t("list.auth"), ""); var pass = prompt(this.$t("list.auth"), "");
localStorage.setItem("password" + path, pass); localStorage.setItem("password" + path, pass);
if (pass != null && pass != "") { if (pass != null && pass != "") {
this.render(path); this.render(path);
} else { } else {
history.go(-1); this.$router.go(-1);
} }
}, },
copy (path) { copy(path) {
let origin = window.location.origin; let origin = window.location.origin;
path = origin + path; path = origin + path;
clipboard.writeText(path); this.$copyText(path)
.then(() => {
this.$notify({
title: this.$t("notify.title"),
message: this.$t("copy.success"),
type: "success",
});
})
.catch(() => {
this.$notify.error({
title: this.$t("notify.title"),
message: this.$t("copy.error"),
});
});
}, },
go (file, target) { go(file, target) {
let path = file.path; let path = file.path;
if (path.match("/[0-9]+:search/")) { let cmd = this.$route.params.cmd;
if (cmd && cmd === "search") {
this.goSearchResult(file, target); this.goSearchResult(file, target);
return; return;
} }
if (target === "_blank") {
window.open(path);
return;
}
if (target === "down") { if (target === "down") {
location.href = path; location.href = path;
return; return;
} }
if (target === "view") { if (target === "view") {
this.$router.push({ this.$router.push({
path: checkView(path) path: checkView(path),
}); });
return; return;
} }
if (file.mimeType === "application/vnd.google-apps.folder") { if (file.mimeType === "application/vnd.google-apps.folder") {
this.$router.push({ this.$router.push({
path: path path: path,
}); });
return; return;
} }
if (target === "_blank") { },
window.open(path); renderMd(files, path) {
var cmd = this.$route.params.cmd;
if (cmd) {
return; return;
} }
files.forEach((item) => {
// HEAD.md
if (item.name === "HEAD.md") {
this.headmd = {
display: true,
file: item,
path: path + item.name,
};
}
// REDEME.md
if (item.name === "README.md") {
this.readmemd = {
display: true,
file: item,
path: path + item.name,
};
}
});
}, },
goSearchResult (file, target) { goSearchResult(file, target) {
this.loading = true; this.loading = true;
let cur = window.current_drive_order; let cur = window.current_drive_order;
axios axios
.post(`/${cur}:id2path`, { id: file.id }) .post(`/${cur}:id2path`, { id: file.id })
.then(res => { .then((res) => {
this.loading = false; this.loading = false;
let data = res.data; let data = res.data;
if (data) { if (data) {
@ -281,35 +319,33 @@ export default {
window.open(href); window.open(href);
} else { } else {
this.$router.push({ this.$router.push({
path: href path: href,
}); });
} }
} }
}) })
.catch(e => { .catch((e) => {
this.loading = false; this.loading = false;
console.log(e); console.log(e);
}); });
}, },
getIcon (type) { getIcon(type) {
return "#" + (this.icon[type] ? this.icon[type] : "icon-weizhi"); return "#" + (this.icon[type] ? this.icon[type] : "icon-weizhi");
} },
}, },
watch: { watch: {
$route (to, from) { $route(to, from) {
// 退page_token // 退page_token
if (to.path.length < from.path.length) { if (to.path.length < from.path.length) {
this.page.page_token = null; this.page.page_token = null;
} }
if ((to.path.indexOf(':search') > 0) || (to.path.substr(-1) === '/' && from.meta.view === "list")) { if (
to.path.indexOf(":search") > 0 ||
(to.path.substr(-1) === "/" && from.meta.view === "list")
) {
this.render(); this.render();
} }
}
}, },
// beforeRouteUpdate (to, from, next) { },
// this.headmd = { display: false, file: {}, path: "" },
// this.readmemd = { display: false, file: {}, path: "" }
// next()
// },
}; };
</script> </script>

View File

@ -21,12 +21,7 @@ export default {
content: "" content: ""
}; };
}, },
watch: { activated () {
$route (to, from) {
this.render();
}
},
created () {
this.render(); this.render();
}, },
computed: { computed: {

View File

@ -20,17 +20,17 @@
<span class="icon"> <span class="icon">
<i class="fa fa-play-circle" aria-hidden="true"></i> <i class="fa fa-play-circle" aria-hidden="true"></i>
</span> </span>
播放 / {{$t('page.video.play')}} /
<span class="icon"> <span class="icon">
<i class="fa fa-download" aria-hidden="true"></i> <i class="fa fa-download" aria-hidden="true"></i>
</span> </span>
下载 {{$t('page.video.download')}}
</p> </p>
</header> </header>
<div class="card-content"> <div class="card-content">
<div class="content"> <div class="content">
<div class="field"> <div class="field">
<label class="label">下载地址</label> <label class="label">{{$t('page.video.link')}}</label>
<div class="control"> <div class="control">
<input class="input" type="text" :value="decodeURIComponent(videourl)" /> <input class="input" type="text" :value="decodeURIComponent(videourl)" />
</div> </div>
@ -102,7 +102,7 @@ export default {
"https://api.jsonpop.cn/demo/blplyaer/?url=" + this.videourl; "https://api.jsonpop.cn/demo/blplyaer/?url=" + this.videourl;
} }
}, },
created () { activated () {
this.render(); this.render();
}, },
computed: { computed: {