From f9b84f213b447cb25fa62e988b4327added9bdd7 Mon Sep 17 00:00:00 2001 From: qxz Date: Sun, 17 May 2020 13:29:48 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A7=A3=E5=86=B3=E5=B7=B2=E7=9F=A5=E7=BC=96?= =?UTF-8?q?=E7=A0=81=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/utils/AcrouUtil.js | 69 +++++++++++++----------- src/views/common/BreadCrumb.vue | 4 +- src/views/page/components/list/index.vue | 4 +- 3 files changed, 42 insertions(+), 35 deletions(-) diff --git a/src/utils/AcrouUtil.js b/src/utils/AcrouUtil.js index 0c1accb..6f028cb 100644 --- a/src/utils/AcrouUtil.js +++ b/src/utils/AcrouUtil.js @@ -23,7 +23,15 @@ let Base64 = require("js-base64").Base64; // "gif", // ]; +export const encodePath = (path) => { + return path.replace(/(.*)/, (p1, p2) => { + return p2.replace().replace(/\//g, "%2F").replace(/#/g, "%23") + }) + //return path.replace().replace("/", "%2F").replace("#", "%23") +} + export const checkoutPath = (path, file) => { + path = encodePath(path) if (file.mimeType === "application/vnd.google-apps.folder") { if (path.substr(-1) !== "/") { path += "/"; @@ -75,13 +83,12 @@ export const getQueryString = (path, param) => { export const getURLParameters = (url) => url - .match(/([^?=&]+)(=([^&]*))/g) - .reduce( - (a, v) => ( - (a[v.slice(0, v.indexOf("="))] = v.slice(v.indexOf("=") + 1)), a - ), - {} - ); + .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")); @@ -176,7 +183,7 @@ export function formatFileSize(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) * @return {String} @@ -185,41 +192,41 @@ export function formatFileSize(bytes) { export function formatDate(date, fmt) { 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.replace(/-/g, '/')) + date = new Date(date) } if (typeof date === 'number') { - date = new Date(date) + 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; } \ No newline at end of file diff --git a/src/views/common/BreadCrumb.vue b/src/views/common/BreadCrumb.vue index c811a6f..76ffe3d 100644 --- a/src/views/common/BreadCrumb.vue +++ b/src/views/common/BreadCrumb.vue @@ -83,8 +83,8 @@ export default { if (n == "") { continue; } - n = decodeURI(n); - p += n + "/"; + n = decodeURIComponent(n); + p += arr[i] + "/"; // if (p.match("/[0-9]+:/")[0] === p) { // n = this.$t('index'); // } diff --git a/src/views/page/components/list/index.vue b/src/views/page/components/list/index.vue index c2b8478..194e9fe 100644 --- a/src/views/page/components/list/index.vue +++ b/src/views/page/components/list/index.vue @@ -19,7 +19,7 @@ {{ file.name }} - {{ file.description }} + {{ file.modifiedTime }}