优化性能

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
node_modules
/dist
src/test
# local env files
.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://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/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",
"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": {
"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",
@ -3180,10 +3185,15 @@
"integrity": "sha1-sEM9C06chH7xiGik7xb9X8gnHEg=",
"dev": true
},
"clipboard-polyfill": {
"version": "2.8.6",
"resolved": "https://registry.npm.taobao.org/clipboard-polyfill/download/clipboard-polyfill-2.8.6.tgz",
"integrity": "sha1-GdJyg/EfKTO7GHNyY7mLjJW1oPc="
"clipboard": {
"version": "2.0.6",
"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-UpISlu7A/fd+rRdJQhshyWhkc3Y=",
"requires": {
"good-listener": "^1.2.2",
"select": "^1.1.2",
"tiny-emitter": "^2.0.0"
}
},
"clipboardy": {
"version": "2.3.0",
@ -4177,6 +4187,11 @@
"resolved": "http://registry.npm.taobao.org/delayed-stream/download/delayed-stream-1.0.0.tgz",
"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": {
"version": "1.0.0",
"resolved": "http://registry.npm.taobao.org/delegates/download/delegates-1.0.0.tgz",
@ -6132,6 +6147,14 @@
"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": {
"version": "4.2.3",
"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": {
"version": "2.0.0",
"resolved": "http://registry.npm.taobao.org/select-hose/download/select-hose-2.0.0.tgz",
@ -11476,6 +11504,11 @@
"integrity": "sha1-QFQRqOfmM5/mTbmiNN4R3DHgK9Q=",
"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": {
"version": "0.0.33",
"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": {
"version": "7.0.0",
"resolved": "https://registry.npm.taobao.org/vue-eslint-parser/download/vue-eslint-parser-7.0.0.tgz",
@ -12327,7 +12368,7 @@
},
"webpack-bundle-analyzer": {
"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=",
"dev": true,
"requires": {

View File

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

View File

@ -51,6 +51,12 @@ body {
cursor: pointer;
}
}
td span {
vertical-align: middle;
}
td .g2-file-desc{
font-size:12px;
}
}
.footer {
@ -137,4 +143,4 @@ body {
border: 5px solid transparent;
position: absolute;
left: 7px;
}
}

View File

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

View File

@ -2,27 +2,40 @@
"_name": "English",
"languages": "Languages",
"index": "Index",
"folder": "Folder",
"notify": {
"title": "Notify"
},
"copy": {
"success": "Copy successful",
"error": "Copy failed"
},
"list": {
"auth": "Directory encryption, please enter password",
"title": {
"file": "File",
"moditime": "Modified Time",
"size": "Size",
"operation": "Operation"
"file": "File",
"moditime": "Modified Time",
"size": "Size",
"operation": "Operation"
},
"loading": "Loading...",
"opt": {
"copy": "Copy link",
"newTab": "Open a new tab",
"download": "Download"
"copy": "Copy link",
"newTab": "Open a new tab",
"download": "Download"
}
},
"search": {
"placeholder": "Search or jump to…"
"placeholder": "Search or jump to…"
},
"page": {
"text": {
"loading": "Loading..."
}
"video": {
"play": "Play",
"download": "Download",
"link": "Download link"
},
"text": {
"loading": "Loading..."
}
}
}
}

View File

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

View File

@ -2,6 +2,14 @@
"_name": "繁体中文",
"languages": "選擇語言",
"index": "首頁",
"folder": "文件夾",
"notify": {
"title": "提示"
},
"copy": {
"success": "復制成功",
"error": "復制失敗"
},
"list": {
"auth": "目錄加密,請輸入密碼",
"title": {
@ -21,6 +29,11 @@
"placeholder": "搜索..."
},
"page": {
"video": {
"play": "播放",
"download": "下載",
"link": "下載地址"
},
"text": {
"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/base.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 VueAxios from 'vue-axios'
import router from './router'
import i18n from './i18n'
import VueClipboard from 'vue-clipboard2'
import "@/assets/style/theme/register.scss"
Vue.config.productionTip = false
Vue.use(ElementUI)
Vue.use(VueAxios,axios)
Vue.use(VueClipboard)
new Vue({
router,

View File

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

View File

@ -6,7 +6,7 @@ const meta = {
}
const frameIn = [{
path: "/:id:(text)/:path",
path: "/:id::cmd(text)/:path",
component: _import("page/GoText"),
meta: {
...meta,
@ -14,7 +14,7 @@ const frameIn = [{
}
},
{
path: "/:id:(pdf)/:path",
path: "/:id::cmd(pdf)/:path",
component: _import("page/GoPdf"),
meta: {
...meta,
@ -22,7 +22,7 @@ const frameIn = [{
}
},
{
path: "/:id:(video)/:path",
path: "/:id::cmd(video)/:path",
component: _import("page/GoVideo"),
meta: {
...meta,
@ -30,7 +30,7 @@ const frameIn = [{
}
},
{
path: "/:id:(image)/:path",
path: "/:id::cmd(image)/:path",
component: _import("page/GoImg"),
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"),
meta: {
...meta,

View File

@ -38,7 +38,8 @@ export const checkView = (path) => {
.split(".")
.pop()
.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) {
path = path.replace(/\/(\d+:)\/.*/, (p1, p2) => {
return `/${p2}text/${base64Path}`;
@ -88,7 +89,7 @@ export const getURLParameters = (url) =>
//console.log(getQueryString("/Movies/xx.mp4?a=view&y=123", "y"));
export const encode64 = (str) => {
return Base64.encode(str);
return Base64.encodeURI(str);
};
export const decode64 = (str) => {

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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