解决v2.0.0公测版大家反馈的问题

This commit is contained in:
Aicirou 2020-05-20 02:11:53 +08:00
parent 78ab2ed495
commit 6a63ea8e85
8 changed files with 932 additions and 820 deletions

File diff suppressed because it is too large Load Diff

2
package-lock.json generated
View File

@ -12677,7 +12677,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

@ -14,7 +14,7 @@
<title><%= htmlWebpackPlugin.options.title %></title> <title><%= htmlWebpackPlugin.options.title %></title>
<script> <script>
var authConfig = { var authConfig = {
version: '1.0.0', version: '1.1.0',
roots: [ roots: [
{ {
id: "0AEofxddwF4bAUk9PVA", id: "0AEofxddwF4bAUk9PVA",
@ -26,18 +26,31 @@
name: "PriveDrive", name: "PriveDrive",
pass: "", pass: "",
}, },
{
id: "1ZUli0boWXTpAedKDzE_IF9CWT10G6V86",
name: "folder1",
pass: "",
}
], ],
}; };
var themeOptions = { var themeOptions = {
// en/zh-chs/zh-cht // en/zh-chs/zh-cht
languages: 'en' languages: 'en',
render: {
head_md: false,
readme_md: false,
// 是否显示文件/文件夹描述(默认不显示)
// Show file/folder description or not (not shown by default)
desc: false,
}
} }
window.gdconfig = JSON.parse(JSON.stringify({ version: authConfig.version, themeOptions: themeOptions })); window.gdconfig = JSON.parse(JSON.stringify({ version: authConfig.version, themeOptions: themeOptions }));
window.themeOptions = themeOptions;
window.gds = JSON.parse( window.gds = JSON.parse(
JSON.stringify(authConfig.roots.map((it) => it.name)) JSON.stringify(authConfig.roots.map((it) => it.name))
); );
window.current_drive_order = 0; window.current_drive_order = 0;
// window.MODEL = { q: "the" }; // window.MODEL = { q: "the",root_type: 1 };
</script> </script>
<!-- 使用 CDN 加速的 JS 文件,配置在 vue.config.js 下 --> <!-- 使用 CDN 加速的 JS 文件,配置在 vue.config.js 下 -->
<% for (var i in htmlWebpackPlugin.options.cdn&&htmlWebpackPlugin.options.cdn.js) { %> <% for (var i in htmlWebpackPlugin.options.cdn&&htmlWebpackPlugin.options.cdn.js) { %>

View File

@ -1,37 +1,34 @@
import axios from "@utils/axios"; import axios from "@utils/axios";
let Base64 = require("js-base64").Base64; let Base64 = require("js-base64").Base64;
// const exts = [ const text_exts = [
// "html", "html",
// "php", "php",
// "css", "css",
// "go", "go",
// "java", "java",
// "js", "js",
// "json", "json",
// "py", "txt",
// "txt", "sh",
// "sh", "md",
// "md", ];
// "mp4", const video_exts = ["mp4", "webm", "mkv", "m3u8"];
// "webm", const image_exts = ["bmp", "jpg", "jpeg", "png", "gif"];
// "mkv", const pdf_exts = ["pdf"];
// "bmp",
// "jpg",
// "jpeg",
// "png",
// "gif",
// ];
export const encodePath = (path) => { export const encodePath = (path) => {
return path.replace(/(.*)/, (p1, p2) => { return path.replace(/(.*)/, (p1, p2) => {
return p2.replace().replace(/\//g, "%2F").replace(/#/g, "%23") return p2
}) .replace()
.replace(/\//g, "%2F")
.replace(/#/g, "%23");
});
//return path.replace().replace("/", "%2F").replace("#", "%23") //return path.replace().replace("/", "%2F").replace("#", "%23")
} };
export const checkoutPath = (path, file) => { export const checkoutPath = (path, file) => {
path = encodePath(path) path = encodePath(path);
if (file.mimeType === "application/vnd.google-apps.folder") { if (file.mimeType === "application/vnd.google-apps.folder") {
if (path.substr(-1) !== "/") { if (path.substr(-1) !== "/") {
path += "/"; path += "/";
@ -47,25 +44,25 @@ export const checkView = (path) => {
.pop() .pop()
.toLowerCase(); .toLowerCase();
let base64Path = encode64(path); let base64Path = encode64(path);
if ("|html|php|css|go|java|js|json|txt|sh|md|".indexOf(`|${ext}|`) >= 0) { if (text_exts.indexOf(`${ext}`) != -1) {
path = path.replace(/\/(\d+:)\/.*/, (p1, p2) => { path = path.replace(/\/(\d+:)\/.*/, (p1, p2) => {
return `/${p2}text/${base64Path}`; return `/${p2}text/${base64Path}`;
}); });
} }
if ("|pdf|".indexOf(`|${ext}|`) >= 0) { if (pdf_exts.indexOf(`${ext}`) != -1) {
path = path.replace(/\/(\d+:)\/.*/, (p1, p2) => { path = path.replace(/\/(\d+:)\/.*/, (p1, p2) => {
return `/${p2}pdf/${base64Path}`; return `/${p2}pdf/${base64Path}`;
}); });
} }
if ("|mp4|webm|mkv|".indexOf(`|${ext}|`) >= 0) { if (video_exts.indexOf(`${ext}`) != -1) {
path = path.replace(/\/(\d+:)\/.*/, (p1, p2) => { path = path.replace(/\/(\d+:)\/.*/, (p1, p2) => {
return `/${p2}video/${base64Path}`; return `/${p2}video/${base64Path}`;
}); });
} }
if ("|bmp|jpg|jpeg|png|gif|".indexOf(`|${ext}|`) >= 0) { if (image_exts.indexOf(`${ext}`) != -1) {
path = path.replace(/\/(\d+:)\/.*/, (p1, p2) => { path = path.replace(/\/(\d+:)\/.*/, (p1, p2) => {
return `/${p2}image/${base64Path}`; return `/${p2}image/${base64Path}`;
}); });
@ -73,27 +70,16 @@ export const checkView = (path) => {
return path; return path;
}; };
export const getQueryString = (path, param) => { export const checkExtends = (path) => {
if (!path) { let name = path.split("/").pop();
return ""; let ext = name
} .split(".")
var args = getURLParameters(path); .pop()
return args[param] ? args[param] : ""; .toLowerCase();
let exts = text_exts.concat(...video_exts,...image_exts,...pdf_exts);
return exts.indexOf(`${ext}`) != -1;
}; };
export const getURLParameters = (url) =>
url
.match(/([^?=&]+)(=([^&]*))/g)
.reduce(
(a, v) => (
(a[v.slice(0, v.indexOf("="))] = v.slice(v.indexOf("=") + 1)), a
), {}
);
// console.log(getURLParameters("/Movies/xx.mp4?a=view&y=123"));
//console.log(getQueryString("/Movies/xx.mp4?a=view&y=123", "y"));
export const encode64 = (str) => { export const encode64 = (str) => {
return Base64.encodeURI(str); return Base64.encodeURI(str);
}; };
@ -182,7 +168,6 @@ export function formatFileSize(bytes) {
return bytes; return bytes;
} }
/** /**
* @param {Number String Date} * @param {Number String Date}
* @param {String} 'YYYY-MM-DD HH:mm:ss EEE' (Y)(M)(D)12小时(h)24小时(H)(m)(s)毫秒(S)(E)季度(q) * @param {String} 'YYYY-MM-DD HH:mm:ss EEE' (Y)(M)(D)12小时(h)24小时(H)(m)(s)毫秒(S)(E)季度(q)
@ -190,42 +175,55 @@ export function formatFileSize(bytes) {
* @example XDate.format(new Date(), "YYYY-MM-DD") ==> 2017-08-23 * @example XDate.format(new Date(), "YYYY-MM-DD") ==> 2017-08-23
*/ */
export function formatDate(date, fmt) { export function formatDate(date, fmt) {
fmt = fmt || 'YYYY-MM-DD HH:mm:ss'; fmt = fmt || "YYYY-MM-DD HH:mm:ss";
if (typeof date === 'string') { if (typeof date === "string") {
// date = new Date(date.replace(/-/g, '/')) // date = new Date(date.replace(/-/g, '/'))
date = new Date(date) date = new Date(date);
} }
if (typeof date === 'number') { if (typeof date === "number") {
date = new Date(date) date = new Date(date);
} }
var o = { var o = {
'M+': date.getMonth() + 1, "M+": date.getMonth() + 1,
'D+': date.getDate(), "D+": date.getDate(),
'h+': date.getHours() % 12 === 0 ? 12 : date.getHours() % 12, "h+": date.getHours() % 12 === 0 ? 12 : date.getHours() % 12,
'H+': date.getHours(), "H+": date.getHours(),
'm+': date.getMinutes(), "m+": date.getMinutes(),
's+': date.getSeconds(), "s+": date.getSeconds(),
'q+': Math.floor((date.getMonth() + 3) / 3), "q+": Math.floor((date.getMonth() + 3) / 3),
'S': date.getMilliseconds() S: date.getMilliseconds(),
} };
var week = { var week = {
'0': '\u65e5', "0": "\u65e5",
'1': '\u4e00', "1": "\u4e00",
'2': '\u4e8c', "2": "\u4e8c",
'3': '\u4e09', "3": "\u4e09",
'4': '\u56db', "4": "\u56db",
'5': '\u4e94', "5": "\u4e94",
'6': '\u516d' "6": "\u516d",
} };
if (/(Y+)/.test(fmt)) { if (/(Y+)/.test(fmt)) {
fmt = fmt.replace(RegExp.$1, (date.getFullYear() + '').substr(4 - RegExp.$1.length)) fmt = fmt.replace(
RegExp.$1,
(date.getFullYear() + "").substr(4 - RegExp.$1.length)
);
} }
if (/(E+)/.test(fmt)) { if (/(E+)/.test(fmt)) {
fmt = fmt.replace(RegExp.$1, ((RegExp.$1.length > 1) ? (RegExp.$1.length > 2 ? '\u661f\u671f' : '\u5468') : '') + week[date.getDay() + '']) fmt = fmt.replace(
RegExp.$1,
(RegExp.$1.length > 1
? RegExp.$1.length > 2
? "\u661f\u671f"
: "\u5468"
: "") + week[date.getDay() + ""]
);
} }
for (var k in o) { for (var k in o) {
if (new RegExp('(' + k + ')').test(fmt)) { if (new RegExp("(" + k + ")").test(fmt)) {
fmt = fmt.replace(RegExp.$1, (RegExp.$1.length === 1) ? (o[k]) : (('00' + o[k]).substr(('' + o[k]).length))) fmt = fmt.replace(
RegExp.$1,
RegExp.$1.length === 1 ? o[k] : ("00" + o[k]).substr(("" + o[k]).length)
);
} }
} }
return fmt; return fmt;

View File

@ -108,6 +108,13 @@ export default {
// height: 100%; // height: 100%;
padding: 10px 0.75em; padding: 10px 0.75em;
} }
.level-left {
width: 95%;
.level-item {
display: initial;
width: 100%;
}
}
.level-right { .level-right {
.level-item { .level-item {
// border-radius: 50%; // border-radius: 50%;

View File

@ -42,7 +42,7 @@
<div class="navbar-end"> <div class="navbar-end">
<!-- is-hidden-desktop --> <!-- is-hidden-desktop -->
<div class="navbar-item"> <div class="navbar-item" v-show="showSearch">
<div class="field is-grouped"> <div class="field is-grouped">
<p class="control has-icons-left is-dark" style="width:100%;"> <p class="control has-icons-left is-dark" style="width:100%;">
<input <input
@ -71,8 +71,11 @@
<i class="fab fa-github"></i> <i class="fab fa-github"></i>
</a> </a>
<header-setting /> <header-setting />
<a class="navbar-item is-hidden-desktop" @click.stop="$refs.viewMode.toggleMode"> <a
<view-mode ref="viewMode"/> class="navbar-item is-hidden-desktop"
@click.stop="$refs.viewMode.toggleMode"
>
<view-mode ref="viewMode" />
</a> </a>
</div> </div>
</div> </div>
@ -144,6 +147,10 @@ export default {
getCurrGD() { getCurrGD() {
return this.gds.filter((item) => item.name !== this.currgd.name); return this.gds.filter((item) => item.name !== this.currgd.name);
}, },
showSearch() {
//
return window.MODEL ? window.MODEL.root_type < 2 : true
},
}, },
watch: { watch: {
"$route.params.id": "chooseGD", "$route.params.id": "chooseGD",

View File

@ -1,6 +1,6 @@
<template> <template>
<div> <div>
<headmd :option="headmd" v-if="headmd.display"></headmd> <headmd :option="headmd" v-if="renderHeadMD && headmd.display"></headmd>
<div <div
class="golist" class="golist"
v-loading="loading" v-loading="loading"
@ -8,7 +8,13 @@
infinite-scroll-disabled="busy" infinite-scroll-disabled="busy"
infinite-scroll-distance="10" infinite-scroll-distance="10"
> >
<list-view :data="buildFiles" v-if="mode === 'list'" :icons="getIcon" :go="go" :copy="copy" /> <list-view
:data="buildFiles"
v-if="mode === 'list'"
:icons="getIcon"
:go="go"
:copy="copy"
/>
<grid-view <grid-view
class="g2-content" class="g2-content"
:data="buildFiles" :data="buildFiles"
@ -17,7 +23,10 @@
:go="go" :go="go"
:thum="thum" :thum="thum"
/> />
<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>
<center> <center>
<div :class="!busy ? 'is-hidden' : ''"> <div :class="!busy ? 'is-hidden' : ''">
<i class="fa fa-spinner fa-pulse fa-2x fa-fw"></i> <i class="fa fa-spinner fa-pulse fa-2x fa-fw"></i>
@ -28,8 +37,13 @@
</span>--> </span>-->
</center> </center>
</div> </div>
<div class="is-divider" :data-content="$t('list.total')+' '+files.length+' ' + $t('list.item')"></div> <div
<readmemd :option="readmemd" v-if="readmemd.display"></readmemd> class="is-divider"
:data-content="
$t('list.total') + ' ' + files.length + ' ' + $t('list.item')
"
></div>
<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"
@ -57,6 +71,7 @@ import {
formatFileSize, formatFileSize,
checkoutPath, checkoutPath,
checkView, checkView,
checkExtends,
} from "@utils/AcrouUtil"; } from "@utils/AcrouUtil";
import axios from "@/utils/axios"; import axios from "@/utils/axios";
import { mapState } from "vuex"; import { mapState } from "vuex";
@ -71,7 +86,7 @@ export default {
Headmd: Markdown, Headmd: Markdown,
Readmemd: Markdown, Readmemd: Markdown,
}, },
data: function () { data: function() {
return { return {
busy: false, busy: false,
page: { page: {
@ -112,7 +127,7 @@ export default {
}, },
computed: { computed: {
...mapState("acrou/view", ["mode"]), ...mapState("acrou/view", ["mode"]),
buildFiles () { buildFiles() {
var path = this.$route.path; var path = this.$route.path;
return this.files return this.files
.map((item) => { .map((item) => {
@ -134,22 +149,28 @@ export default {
return a.isFolder ? -1 : 1; return a.isFolder ? -1 : 1;
}); });
}, },
images () { images() {
return this.buildFiles.filter( return this.buildFiles.filter(
(file) => file.mimeType.indexOf("image") != -1 (file) => file.mimeType.indexOf("image") != -1
); );
}, },
renderHeadMD() {
return window.themeOptions.render.head_md || false;
},
renderReadMeMD() {
return window.themeOptions.render.readme_md || false;
},
}, },
created () { created() {
this.render(); this.render();
}, },
methods: { methods: {
pageLoad () { pageLoad() {
if (!this.page.page_token) return; if (!this.page.page_token) return;
this.page.page_index++; this.page.page_index++;
this.render("scroll"); this.render("scroll");
}, },
render (scroll) { render(scroll) {
if (scroll) { if (scroll) {
this.busy = true; this.busy = true;
} else { } else {
@ -201,7 +222,7 @@ export default {
this.$router.go(-1); 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 != "") {
@ -210,7 +231,7 @@ export default {
this.$router.go(-1); this.$router.go(-1);
} }
}, },
copy (path) { copy(path) {
let origin = window.location.origin; let origin = window.location.origin;
path = origin + encodeURI(path); path = origin + encodeURI(path);
this.$copyText(path) this.$copyText(path)
@ -228,17 +249,17 @@ export default {
}); });
}); });
}, },
thum (url) { thum(url) {
return url ? `/${this.$route.params.id}:view?url=${url}` : ""; return url ? `/${this.$route.params.id}:view?url=${url}` : "";
}, },
inited (viewer) { inited(viewer) {
this.$viewer = viewer; this.$viewer = viewer;
}, },
go (file, target) { go(file, target) {
if (file.mimeType.indexOf("image") != -1) { if (file.mimeType.indexOf("image") != -1) {
this.viewer = true; this.viewer = true;
this.$nextTick(() => { this.$nextTick(() => {
let index = this.images.findIndex(item => item.path === file.path) let index = this.images.findIndex((item) => item.path === file.path);
this.$viewer.view(index); this.$viewer.view(index);
}); });
return; return;
@ -253,7 +274,7 @@ export default {
window.open(path); window.open(path);
return; return;
} }
if (target === "down") { if (target === "down" || (!checkExtends(path) && !file.isFolder)) {
let temp_path = this.$route.params.path ? this.$route.params.path : ""; let temp_path = this.$route.params.path ? this.$route.params.path : "";
location.href = `/${this.$route.params.id}:down/${temp_path}/${file.name}`; location.href = `/${this.$route.params.id}:down/${temp_path}/${file.name}`;
return; return;
@ -271,7 +292,7 @@ export default {
return; return;
} }
}, },
renderMd (files, path) { renderMd(files, path) {
var cmd = this.$route.params.cmd; var cmd = this.$route.params.cmd;
if (cmd) { if (cmd) {
return; return;
@ -295,7 +316,7 @@ export default {
} }
}); });
}, },
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
@ -320,7 +341,7 @@ export default {
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");
}, },
}, },

View File

@ -32,7 +32,11 @@
<use :xlink:href="icons(file.mimeType)" /> <use :xlink:href="icons(file.mimeType)" />
</svg> </svg>
{{ file.name }} {{ file.name }}
<span class="has-text-grey g2-file-desc" v-html="file.description"></span> <span
class="has-text-grey g2-file-desc"
v-if="isShowDesc"
v-html="file.description"
></span>
</td> </td>
<td class="is-hidden-mobile is-hidden-touch"> <td class="is-hidden-mobile is-hidden-touch">
{{ file.modifiedTime }} {{ file.modifiedTime }}
@ -107,6 +111,9 @@ export default {
}, },
]; ];
}, },
isShowDesc() {
return window.themeOptions.render.desc || false;
},
}, },
}; };
</script> </script>