解决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": {
"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

@ -14,7 +14,7 @@
<title><%= htmlWebpackPlugin.options.title %></title>
<script>
var authConfig = {
version: '1.0.0',
version: '1.1.0',
roots: [
{
id: "0AEofxddwF4bAUk9PVA",
@ -26,18 +26,31 @@
name: "PriveDrive",
pass: "",
},
{
id: "1ZUli0boWXTpAedKDzE_IF9CWT10G6V86",
name: "folder1",
pass: "",
}
],
};
var themeOptions = {
// 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.themeOptions = themeOptions;
window.gds = JSON.parse(
JSON.stringify(authConfig.roots.map((it) => it.name))
);
window.current_drive_order = 0;
// window.MODEL = { q: "the" };
// window.MODEL = { q: "the",root_type: 1 };
</script>
<!-- 使用 CDN 加速的 JS 文件,配置在 vue.config.js 下 -->
<% for (var i in htmlWebpackPlugin.options.cdn&&htmlWebpackPlugin.options.cdn.js) { %>

View File

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

View File

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

View File

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

View File

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

View File

@ -32,7 +32,11 @@
<use :xlink:href="icons(file.mimeType)" />
</svg>
{{ 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 class="is-hidden-mobile is-hidden-touch">
{{ file.modifiedTime }}
@ -107,6 +111,9 @@ export default {
},
];
},
isShowDesc() {
return window.themeOptions.render.desc || false;
},
},
};
</script>