From a9cae08aa25434cfe675b1a79281f25c9651b1d7 Mon Sep 17 00:00:00 2001
From: Aicirou <2643053021@qq.com>
Date: Thu, 7 May 2020 03:29:32 +0800
Subject: [PATCH] =?UTF-8?q?=E8=B0=83=E6=95=B4=E8=B7=AF=E7=94=B1=E9=85=8D?=
=?UTF-8?q?=E7=BD=AE=EF=BC=8C=E4=BC=98=E5=8C=96=E9=A1=B5=E9=9D=A2?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
dependencies-cdn.js | 2 +-
package-lock.json | 65 ++++++++++-
package.json | 2 +
.../components/header-color/index.vue | 45 ++++++++
src/main.js | 5 +
src/router/routes.js | 15 +--
src/utils/AcrouUtil.js | 105 ++++++++++++++++--
src/views/Layout.vue | 4 +-
src/views/common/BreadCrumb.vue | 14 ++-
src/views/common/Footer.vue | 2 +-
src/views/common/Navbar.vue | 7 +-
src/views/page/GoImg.vue | 11 +-
src/views/page/GoList.vue | 52 +++++----
src/views/page/GoPdf.vue | 31 ++++--
src/views/page/GoText.vue | 16 +--
src/views/page/GoVideo.vue | 13 +--
16 files changed, 306 insertions(+), 83 deletions(-)
create mode 100644 src/layout/header-aside/components/header-color/index.vue
diff --git a/dependencies-cdn.js b/dependencies-cdn.js
index d46e4d6..1bcd3fa 100644
--- a/dependencies-cdn.js
+++ b/dependencies-cdn.js
@@ -3,7 +3,7 @@ module.exports = [
{ name: 'vue-i18n', library: 'VueI18n', js: 'https://cdn.jsdelivr.net/npm/vue-i18n@8.17.3/dist/vue-i18n.min.js', css: '' },
{ name: 'vue-router', library: 'VueRouter', js: 'https://cdn.jsdelivr.net/npm/vue-router@3.1.6/dist/vue-router.min.js', css: '' },
{ name: 'axios', library: 'axios', js: 'https://cdn.jsdelivr.net/npm/axios@0.19.2/dist/axios.min.js', css: '' },
- // { name: 'element-ui', library: 'ELEMENT', js: 'https://cdn.jsdelivr.net/npm/element-ui@2.13.1/lib/index.js', css: 'https://cdn.jsdelivr.net/npm/element-ui@2.13.1/lib/theme-chalk/index.css' },
+ { name: 'element-ui', library: 'ELEMENT', js: 'https://cdn.jsdelivr.net/npm/element-ui@2.13.1/lib/index.js', css: 'https://cdn.jsdelivr.net/npm/element-ui@2.13.1/lib/theme-chalk/index.css' },
{ name: 'js-cookie', library: 'Cookies', js: 'https://cdn.jsdelivr.net/npm/js-cookie@2.2.1/src/js.cookie.min.js', css: '' },
// { name: 'brace', library: 'ace', js: 'https://cdn.jsdelivr.net/npm/brace@0.11.1/index.min.js', css: '' },
// { name: 'brace/ext/language_tools', library: 'language_tools', js: ' https://cdn.jsdelivr.net/npm/brace@0.11.1/ext/language_tools.js', css: '' },
diff --git a/package-lock.json b/package-lock.json
index ca3750b..21eb9b2 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -2143,6 +2143,14 @@
"integrity": "sha1-3TeelPDbgxCwgpH51kwyCXZmF/0=",
"dev": true
},
+ "async-validator": {
+ "version": "1.8.5",
+ "resolved": "https://registry.npm.taobao.org/async-validator/download/async-validator-1.8.5.tgz",
+ "integrity": "sha1-3D4I7B/Q3dtn5ghC8CwM0c7G1/A=",
+ "requires": {
+ "babel-runtime": "6.x"
+ }
+ },
"asynckit": {
"version": "0.4.0",
"resolved": "http://registry.npm.taobao.org/asynckit/download/asynckit-0.4.0.tgz",
@@ -2224,6 +2232,11 @@
"resolve": "^1.12.0"
}
},
+ "babel-helper-vue-jsx-merge-props": {
+ "version": "2.0.3",
+ "resolved": "https://registry.npm.taobao.org/babel-helper-vue-jsx-merge-props/download/babel-helper-vue-jsx-merge-props-2.0.3.tgz",
+ "integrity": "sha1-Iq69OzOQIyjlEyk6jkmSs4T58bY="
+ },
"babel-loader": {
"version": "8.1.0",
"resolved": "https://registry.npm.taobao.org/babel-loader/download/babel-loader-8.1.0.tgz?cache=0&sync_timestamp=1584717315701&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fbabel-loader%2Fdownload%2Fbabel-loader-8.1.0.tgz",
@@ -2278,6 +2291,27 @@
"object.assign": "^4.1.0"
}
},
+ "babel-runtime": {
+ "version": "6.26.0",
+ "resolved": "https://registry.npm.taobao.org/babel-runtime/download/babel-runtime-6.26.0.tgz",
+ "integrity": "sha1-llxwWGaOgrVde/4E/yM3vItWR/4=",
+ "requires": {
+ "core-js": "^2.4.0",
+ "regenerator-runtime": "^0.11.0"
+ },
+ "dependencies": {
+ "core-js": {
+ "version": "2.6.11",
+ "resolved": "https://registry.npm.taobao.org/core-js/download/core-js-2.6.11.tgz?cache=0&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fcore-js%2Fdownload%2Fcore-js-2.6.11.tgz",
+ "integrity": "sha1-OIMUafmSK97Y7iHJ3EaYXgOZMIw="
+ },
+ "regenerator-runtime": {
+ "version": "0.11.1",
+ "resolved": "https://registry.npm.taobao.org/regenerator-runtime/download/regenerator-runtime-0.11.1.tgz?cache=0&sync_timestamp=1584052392667&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fregenerator-runtime%2Fdownload%2Fregenerator-runtime-0.11.1.tgz",
+ "integrity": "sha1-vgWtf5v30i4Fb5cmzuUBf78Z4uk="
+ }
+ }
+ },
"balanced-match": {
"version": "1.0.0",
"resolved": "http://registry.npm.taobao.org/balanced-match/download/balanced-match-1.0.0.tgz",
@@ -3918,8 +3952,7 @@
"deepmerge": {
"version": "1.5.2",
"resolved": "https://registry.npm.taobao.org/deepmerge/download/deepmerge-1.5.2.tgz",
- "integrity": "sha1-EEmdhohEza1P7ghC34x/bwyVp1M=",
- "dev": true
+ "integrity": "sha1-EEmdhohEza1P7ghC34x/bwyVp1M="
},
"default-gateway": {
"version": "5.0.5",
@@ -4371,6 +4404,19 @@
"integrity": "sha1-nQqS3v79p8wc+IlQWLiSeV3da0E=",
"dev": true
},
+ "element-ui": {
+ "version": "2.13.1",
+ "resolved": "https://registry.npm.taobao.org/element-ui/download/element-ui-2.13.1.tgz",
+ "integrity": "sha1-DLGkXPJ6phxgHe++GSdArFy533w=",
+ "requires": {
+ "async-validator": "~1.8.1",
+ "babel-helper-vue-jsx-merge-props": "^2.0.0",
+ "deepmerge": "^1.2.0",
+ "normalize-wheel": "^1.0.1",
+ "resize-observer-polyfill": "^1.5.0",
+ "throttle-debounce": "^1.0.1"
+ }
+ },
"elliptic": {
"version": "6.5.2",
"resolved": "https://registry.npm.taobao.org/elliptic/download/elliptic-6.5.2.tgz",
@@ -8214,6 +8260,11 @@
"integrity": "sha1-suHE3E98bVd0PfczpPWXjRhlBVk=",
"dev": true
},
+ "normalize-wheel": {
+ "version": "1.0.1",
+ "resolved": "https://registry.npm.taobao.org/normalize-wheel/download/normalize-wheel-1.0.1.tgz",
+ "integrity": "sha1-rsiGr/2wRQcNhWRH32Ls+GFG7EU="
+ },
"npm-run-path": {
"version": "2.0.2",
"resolved": "https://registry.npm.taobao.org/npm-run-path/download/npm-run-path-2.0.2.tgz?cache=0&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fnpm-run-path%2Fdownload%2Fnpm-run-path-2.0.2.tgz",
@@ -10038,6 +10089,11 @@
"integrity": "sha1-kl0mAdOaxIXgkc8NpcbmlNw9yv8=",
"dev": true
},
+ "resize-observer-polyfill": {
+ "version": "1.5.1",
+ "resolved": "https://registry.npm.taobao.org/resize-observer-polyfill/download/resize-observer-polyfill-1.5.1.tgz",
+ "integrity": "sha1-DpAg3T0hAkRY1OvSfiPkAmmBBGQ="
+ },
"resolve": {
"version": "1.17.0",
"resolved": "https://registry.npm.taobao.org/resolve/download/resolve-1.17.0.tgz?cache=0&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fresolve%2Fdownload%2Fresolve-1.17.0.tgz",
@@ -11378,6 +11434,11 @@
"neo-async": "^2.6.0"
}
},
+ "throttle-debounce": {
+ "version": "1.1.0",
+ "resolved": "https://registry.npm.taobao.org/throttle-debounce/download/throttle-debounce-1.1.0.tgz",
+ "integrity": "sha1-UYU9o3vmihVctugns1FKPEIuic0="
+ },
"through": {
"version": "2.3.8",
"resolved": "http://registry.npm.taobao.org/through/download/through-2.3.8.tgz",
diff --git a/package.json b/package.json
index a903cdc..4890874 100644
--- a/package.json
+++ b/package.json
@@ -14,6 +14,8 @@
"bulma": "^0.8.2",
"clipboard-polyfill": "^2.8.6",
"core-js": "^3.6.4",
+ "element-ui": "^2.13.1",
+ "js-base64": "^2.5.2",
"js-cookie": "^2.2.1",
"markdown-it": "^10.0.0",
"node-sass": "^4.14.0",
diff --git a/src/layout/header-aside/components/header-color/index.vue b/src/layout/header-aside/components/header-color/index.vue
new file mode 100644
index 0000000..ff28b47
--- /dev/null
+++ b/src/layout/header-aside/components/header-color/index.vue
@@ -0,0 +1,45 @@
+
+
+
+
+
diff --git a/src/main.js b/src/main.js
index ba03521..66c5022 100644
--- a/src/main.js
+++ b/src/main.js
@@ -1,5 +1,9 @@
import Vue from 'vue'
import App from './App.vue'
+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 axios from '@utils/axios'
import VueAxios from 'vue-axios'
import router from './router'
@@ -7,6 +11,7 @@ import i18n from './i18n'
import "@/assets/style/theme/register.scss"
Vue.config.productionTip = false
+Vue.use(ElementUI)
Vue.use(VueAxios,axios)
new Vue({
diff --git a/src/router/routes.js b/src/router/routes.js
index 3de7bd9..ee69890 100644
--- a/src/router/routes.js
+++ b/src/router/routes.js
@@ -1,11 +1,12 @@
// 由于懒加载页面太多的话会造成webpack热更新太慢,所以开发环境不使用懒加载,只有生产环境使用懒加载
-const _import = require('@/libs/util.import.' + process.env.NODE_ENV)
+const _import = require("@/libs/util.import." + process.env.NODE_ENV);
const frameIn = [
- { path: '/:id:(text/.*\\.)(html|php|css|go|java|py|js|json|txt|sh|md)', component: _import('page/GoText') },
- { path: '/:id:(video/.*\\.)(mp4|webm|mkv)', component: _import('page/GoVideo') },
- { path: '/:id:(image/.*\\.)(bmp|jpg|jpeg|png|gif)', component: _import('page/GoImg') },
- { path: '/:id::cmd?(/?/??.*/)', component: _import('page/GoList') },
-]
+ { path: "/:id:(text)/:path", component: _import("page/GoText"), props: true },
+ { path: "/:id:(pdf)/:path", component: _import("page/GoPdf"), props: true },
+ { path: "/:id:(video)/:path", component: _import("page/GoVideo") },
+ { path: "/:id:(image)/:path", component: _import("page/GoImg") },
+ { path: "/:id::cmd?(/?/??.*/)", component: _import("page/GoList") },
+];
-export default frameIn
+export default frameIn;
diff --git a/src/utils/AcrouUtil.js b/src/utils/AcrouUtil.js
index acbfb7c..fa2fc23 100644
--- a/src/utils/AcrouUtil.js
+++ b/src/utils/AcrouUtil.js
@@ -1,4 +1,5 @@
import axios from "@utils/axios";
+let Base64 = require("js-base64").Base64;
const exts = [
"html",
@@ -23,17 +24,44 @@ const exts = [
];
export const checkoutPath = (path, file) => {
- // 解决/css这种也会匹配的问题
- // var ext = path.split(".").length > 1 ? path.split(".").pop() : "";
- // if (exts.indexOf(`${ext}`) >= 0) {
- // path += "?a=view";
- // } else {
- if (file.mimeType === "application/vnd.google-apps.folder") {
- if (path.substr(-1) !== "/") {
- path += "/";
- }
+ if (file.mimeType === "application/vnd.google-apps.folder") {
+ if (path.substr(-1) !== "/") {
+ path += "/";
}
- // }
+ }
+ return path;
+};
+
+export const checkView = (path) => {
+ let name = path.split("/").pop();
+ let ext = name
+ .split(".")
+ .pop()
+ .toLowerCase();
+ let base64Path = Base64.encode(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}`;
+ });
+ }
+
+ if ("|pdf|".indexOf(`|${ext}|`) >= 0) {
+ path = path.replace(/\/(\d+:)\/.*/, (p1, p2) => {
+ return `/${p2}pdf/${base64Path}`;
+ });
+ }
+
+ if ("|mp4|webm|mkv|".indexOf(`|${ext}|`) >= 0) {
+ path = path.replace(/\/(\d+:)\/.*/, (p1, p2) => {
+ return `/${p2}video/${base64Path}`;
+ });
+ }
+
+ if ("|bmp|jpg|jpeg|png|gif|".indexOf(`|${ext}|`) >= 0) {
+ path = path.replace(/\/(\d+:)\/.*/, (p1, p2) => {
+ return `/${p2}image/${base64Path}`;
+ });
+ }
return path;
};
@@ -59,6 +87,14 @@ export const getURLParameters = (url) =>
//console.log(getQueryString("/Movies/xx.mp4?a=view&y=123", "y"));
+export const encode64 = (str) => {
+ return Base64.encode(str);
+};
+
+export const decode64 = (str) => {
+ return Base64.decode(str);
+};
+
export function get_file(option, callback) {
var path = option.path;
var modifiedTime = option.file.modifiedTime;
@@ -139,3 +175,52 @@ 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)
+ * @return {String}
+ * @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') {
+ // date = new Date(date.replace(/-/g, '/'))
+ 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()
+ }
+ var week = {
+ '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))
+ }
+ if (/(E+)/.test(fmt)) {
+ 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)))
+ }
+ }
+ return fmt;
+}
\ No newline at end of file
diff --git a/src/views/Layout.vue b/src/views/Layout.vue
index 3a36d0e..c54e5ea 100644
--- a/src/views/Layout.vue
+++ b/src/views/Layout.vue
@@ -4,9 +4,9 @@
diff --git a/src/views/common/BreadCrumb.vue b/src/views/common/BreadCrumb.vue
index c883dbd..ad29f0a 100644
--- a/src/views/common/BreadCrumb.vue
+++ b/src/views/common/BreadCrumb.vue
@@ -2,7 +2,7 @@