调整为vue-router模式

This commit is contained in:
Aicirou 2020-05-02 01:25:28 +08:00
parent aa24cefccd
commit 5892b79b38
25 changed files with 429 additions and 387 deletions

View File

@ -1,5 +1,6 @@
module.exports = [ module.exports = [
{ name: 'vue', library: 'Vue', js: 'https://cdn.jsdelivr.net/npm/vue@2.6.11/dist/vue.min.js', css: '' }, { name: 'vue', library: 'Vue', js: 'https://cdn.jsdelivr.net/npm/vue@2.6.11/dist/vue.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: 'axios', library: 'axios', js: 'https://cdn.jsdelivr.net/npm/axios@0.19.2/dist/axios.min.js', css: '' },
// { name: 'brace', library: 'ace', js: 'https://cdn.jsdelivr.net/npm/brace@0.11.1/index.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: '' }, // { name: 'brace/ext/language_tools', library: 'language_tools', js: ' https://cdn.jsdelivr.net/npm/brace@0.11.1/ext/language_tools.js', css: '' },

5
package-lock.json generated
View File

@ -11823,6 +11823,11 @@
} }
} }
}, },
"vue-router": {
"version": "3.1.6",
"resolved": "https://registry.npm.taobao.org/vue-router/download/vue-router-3.1.6.tgz?cache=0&sync_timestamp=1588196200689&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fvue-router%2Fdownload%2Fvue-router-3.1.6.tgz",
"integrity": "sha1-RfWjo4Q+MXAsBh3YKTk1VOQyj4k="
},
"vue-style-loader": { "vue-style-loader": {
"version": "4.1.2", "version": "4.1.2",
"resolved": "http://registry.npm.taobao.org/vue-style-loader/download/vue-style-loader-4.1.2.tgz", "resolved": "http://registry.npm.taobao.org/vue-style-loader/download/vue-style-loader-4.1.2.tgz",

View File

@ -17,6 +17,7 @@
"sass-loader": "^8.0.2", "sass-loader": "^8.0.2",
"vue": "^2.6.11", "vue": "^2.6.11",
"vue-axios": "^2.1.5", "vue-axios": "^2.1.5",
"vue-router": "^3.1.6",
"vue2-ace-editor": "0.0.15" "vue2-ace-editor": "0.0.15"
}, },
"devDependencies": { "devDependencies": {

View File

@ -5,7 +5,7 @@
</template> </template>
<script> <script>
import Layout from "./view/Layout"; import Layout from "./views/Layout";
export default { export default {
name: "App", name: "App",
@ -34,7 +34,7 @@ export default {
this.config.path = path; this.config.path = path;
this.config.siteName = document.getElementsByTagName("title")[0].innerText; this.config.siteName = document.getElementsByTagName("title")[0].innerText;
this.config.title = this.siteName + "-" + decodeURI(path); this.config.title = this.siteName + "-" + decodeURI(path);
this.$refs.layout.render(this.config); // this.$refs.layout.render(this.config);
} }
}; };
</script> </script>

View File

@ -10,10 +10,10 @@ body {
max-width: 980px; max-width: 980px;
} }
.icon { .iconfont {
width: 2em; width: 2em;
height: 2em; height: 2em;
vertical-align: middle; vertical-align: -0.5em;
fill: currentColor; fill: currentColor;
overflow: hidden; overflow: hidden;
} }
@ -45,8 +45,15 @@ body {
text-overflow: ellipsis; text-overflow: ellipsis;
white-space: nowrap; white-space: nowrap;
vertical-align: middle; vertical-align: middle;
&:hover,& .icon{
cursor: pointer;
} }
} }
}
.footer {
background-color: transparent;
}
.no-content { .no-content {
background: url(https://s1.hdslb.com/bfs/static/jinkela/search/asserts/no-data.png) no-repeat 50% 50%; background: url(https://s1.hdslb.com/bfs/static/jinkela/search/asserts/no-data.png) no-repeat 50% 50%;
@ -55,3 +62,26 @@ body {
text-align: center; text-align: center;
margin-top: 20px; margin-top: 20px;
} }
.golist {
min-height: 240px;
position: relative;
.pageloader:not(.is-bottom-to-top) {
-webkit-transform: initial;
transform: initial;
}
.pageloader{
position: absolute;
padding-top: 0;
background: hsla(0,0%,100%,.6);
will-change: initial;
.title {
color: hsl(0, 0%, 4%);
}
}
.pageloader::after {
border: 0 solid black;
}
}

View File

@ -0,0 +1 @@
module.exports = file => require('@/views/' + file).default

View File

@ -0,0 +1 @@
module.exports = file => () => import('@/views/' + file)

View File

@ -2,11 +2,15 @@ import Vue from 'vue'
import App from './App.vue' import App from './App.vue'
import axios from '@utils/axios' import axios from '@utils/axios'
import VueAxios from 'vue-axios' import VueAxios from 'vue-axios'
import router from './router'
var styles = [ var styles = [
// 'https://cdn.jsdelivr.net/npm/bulma@0.8.1/css/bulma.min.css', // 'https://cdn.jsdelivr.net/npm/bulma@0.8.1/css/bulma.min.css',
// 'https://cdn.jsdelivr.net/npm/bulma-tooltip@3.0.2/dist/css/bulma-tooltip.min.css', // 'https://cdn.jsdelivr.net/npm/bulma-tooltip@3.0.2/dist/css/bulma-tooltip.min.css',
'https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.13.0/css/all.min.css', 'https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.13.0/css/all.min.css',
'https://cdn.jsdelivr.net/npm/font-awesome@latest/css/font-awesome.min.css',
'https://cdn.jsdelivr.net/npm/font-awesome-animation@0.2.1/dist/font-awesome-animation.min.css',
'https://cdn.jsdelivr.net/npm/bulma-pageloader@0.3.0/dist/css/bulma-pageloader.min.css'
] ]
styles.forEach(item=>{ styles.forEach(item=>{
document.write(`<link rel="stylesheet" href="${item}">`); document.write(`<link rel="stylesheet" href="${item}">`);
@ -18,5 +22,6 @@ Vue.config.productionTip = false
Vue.use(VueAxios,axios) Vue.use(VueAxios,axios)
new Vue({ new Vue({
router,
render: h => h(App), render: h => h(App),
}).$mount('#app') }).$mount('#app')

44
src/router/index.js Executable file
View File

@ -0,0 +1,44 @@
import Vue from 'vue'
import VueRouter from 'vue-router'
// 路由数据
import routes from './routes'
// fix vue-router NavigationDuplicated
const VueRouterPush = VueRouter.prototype.push
VueRouter.prototype.push = function push (location) {
return VueRouterPush.call(this, location).catch(err => err)
}
const VueRouterReplace = VueRouter.prototype.replace
VueRouter.prototype.replace = function replace (location) {
return VueRouterReplace.call(this, location).catch(err => err)
}
Vue.use(VueRouter)
// 导出路由 在 main.js 里使用
const router = new VueRouter({
mode: 'history',
/* scrollBehavior(to,from,savePosition){
if(savePosition) {
return savePosition;
}else{
return {x:0,y:0}
}
}, */
routes
})
/**
* 路由拦截
* 权限验证
*/
router.beforeEach(async (to, from, next) => {
console.log(to)
next()
})
router.afterEach(to => {
console.log(to)
})
export default router

11
src/router/routes.js Normal file
View File

@ -0,0 +1,11 @@
// 由于懒加载页面太多的话会造成webpack热更新太慢所以开发环境不使用懒加载只有生产环境使用懒加载
const _import = require('@/libs/util.import.' + process.env.NODE_ENV)
const frameIn = [
{ path: '/:id:/*.(html|php|css|go|java|py|js|json|txt|sh|md)', component: _import('page/GoText') },
{ path: '/:id:/*.(mp4|webm|mkv)\\?a=view', component: _import('page/GoVideo') },
{ path: '/:id:/*.(bmp|jpg|jpeg|png|gif)\\?a=view', component: _import('page/GoImg') },
{ path: '/:id::cmd?(/??.*)', component: _import('page/GoList') },
]
export default frameIn

View File

@ -1,101 +0,0 @@
<template>
<div>
<Navbar ref="navbar"></Navbar>
<section class="section">
<div class="container">
<go-headmd :option="headmd" v-show="headmd.display"></go-headmd>
<bread-crumb ref="breadcrumb"></bread-crumb>
<go-list
ref="list"
v-on:headmd="setHeadmd"
v-on:readmemd="setReadmemd"
v-show="show=='list'"
></go-list>
<hr />
<go-readmemd :option="readmemd" v-show="readmemd.display"></go-readmemd>
<go-video ref="govideo" v-show="show=='video'"></go-video>
<go-text :option="text" v-show="show=='text'"></go-text>
<go-img ref="goimg" v-show="show=='img'"></go-img>
<Footer></Footer>
</div>
</section>
</div>
</template>
<script>
import Navbar from "./common/Navbar"
import BreadCrumb from "./common/BreadCrumb"
import GoVideo from "./page/GoVideo"
import Markdown from "./common/Markdown"
import GoList from "./page/GoList"
import GoText from "./page/GoText"
import GoImg from "./page/GoImg"
import Footer from "./common/Footer"
import { getQueryString } from "@utils/AcrouUtil"
export default {
data: function () {
return {
path: "",
show: "list",
text: { file: {}, path: "" },
headmd: { display: false, file: {}, path: "" },
readmemd: { display: false, file: {}, path: "" },
};
},
components: {
Navbar: Navbar,
BreadCrumb: BreadCrumb,
GoHeadmd: Markdown,
GoReadmemd: Markdown,
GoList: GoList,
GoVideo: GoVideo,
GoText: GoText,
GoImg: GoImg,
Footer: Footer,
},
methods: {
render (config) {
let path = config.path;
this.$refs.navbar.siteName = config.siteName;
this.$refs.breadcrumb.render(path);
var param = window.location.search;
var reg = /\/\d+:$/g;
if (path.match(reg) || param.indexOf("?a=view") < 0) {
this.show = "list";
this.$refs.list.render(path, getQueryString(param, "q"));
} else {
var name = path.split("/").pop();
var ext = name.split(".").pop().toLowerCase();
if (
"|html|php|css|go|java|py|js|json|txt|sh|md|".indexOf(`|${ext}|`) >= 0
) {
this.show = "text";
this.text = {
path: path,
file: {},
};
}
if ("|mp4|webm|mkv|".indexOf(`|${ext}|`) >= 0) {
this.show = "video";
this.$refs.govideo.render(path);
}
if ("|bmp|jpg|jpeg|png|gif|".indexOf(`|${ext}|`) >= 0) {
this.show = "img";
this.$refs.goimg.render(path);
}
}
},
setHeadmd (val) {
this.headmd = val;
},
setReadmemd (val) {
this.readmemd = val;
}
}
}
</script>
<style lang="scss">
@import "~@/assets/style/theme/register.scss";
</style>

View File

@ -1,53 +0,0 @@
<template>
<div class="content">
<editor
ref="myEditor"
v-model="content"
@init="editorInit"
lang="html"
theme="chrome"
width="100%"
height="600"
></editor>
</div>
</template>
<script>
import { get_file } from "@utils/AcrouUtil"
export default {
props: {
option: {
path: "",
file: {},
},
},
watch: {
option () {
this.content = "加载中...";
get_file(this.option, (data) => {
this.content = data;
});
},
},
data: function () {
return {
content: "",
};
},
components: {
editor: import('@/components/ace-editor'),
},
methods: {
editorInit (editor) {
editor.setFontSize(18)
editor.session.setUseWrapMode(false);
import("brace/ext/language_tools"); //language extension prerequsite...
import("brace/mode/html");
import("brace/mode/javascript"); //language
import("brace/mode/less");
import("brace/theme/chrome");
import("brace/snippets/javascript"); //snippet
},
}
}
</script>

47
src/views/Layout.vue Normal file
View File

@ -0,0 +1,47 @@
<template>
<div>
<Head></Head>
<section class="section">
<div class="container">
<bread-crumb ref="breadcrumb"></bread-crumb>
<!-- <keep-alive> -->
<router-view></router-view>
<!-- </keep-alive> -->
<Footer></Footer>
</div>
</section>
</div>
</template>
<script>
import Head from "./common/Head"
import BreadCrumb from "./common/BreadCrumb";
import Footer from "./common/Footer"
export default {
data: function () {
return {
path: "",
show: "list",
text: { file: {}, path: "" },
headmd: { display: false, file: {}, path: "" },
readmemd: { display: false, file: {}, path: "" },
};
},
components: {
Head,
BreadCrumb,
Footer: Footer,
},
methods: {
setHeadmd (val) {
this.headmd = val;
},
setReadmemd (val) {
this.readmemd = val;
}
}
}
</script>
<style lang="scss">
@import "~@/assets/style/theme/register.scss";
</style>

View File

@ -7,7 +7,7 @@
v-bind:key="index" v-bind:key="index"
> >
<a v-if="(index+1)==navs.length" aria-current="page" href="#">{{item.title}}</a> <a v-if="(index+1)==navs.length" aria-current="page" href="#">{{item.title}}</a>
<a v-else :href="item.path">{{item.title}}</a> <a v-else @click="go(item.path)">{{item.title}}</a>
</li> </li>
</ul> </ul>
</nav> </nav>
@ -21,8 +21,22 @@ export default {
index: "/" index: "/"
}; };
}, },
mounted() {
this.render();
},
watch: {
$route(to, from) {
this.render();
}
},
methods: { methods: {
render(path) { go(path) {
this.$router.push({
path: path
});
},
render() {
let path = window.location.pathname;
// //
if (path.match("/[0-9]+:search")) { if (path.match("/[0-9]+:search")) {
return; return;

View File

@ -1,5 +1,5 @@
<template> <template>
<div class="content has-text-centered is-fixed-bottom"> <footer class="footer">
<div class="columns is-mobile is-centered"> <div class="columns is-mobile is-centered">
<div class="field is-grouped is-grouped-multiline"> <div class="field is-grouped is-grouped-multiline">
<div class="control"> <div class="control">
@ -16,23 +16,19 @@
</div> </div>
</div> </div>
</div> </div>
</div> </footer>
</template> </template>
<script> <script>
export default { export default {
props: { props: {},
}, watch: {},
watch: {
},
data: function() { data: function() {
return { return {
content: "", content: ""
}; };
}, },
components: { components: {},
}, methods: {}
methods: { };
}
}
</script> </script>

19
src/views/common/Head.vue Normal file
View File

@ -0,0 +1,19 @@
<template>
<div>
<Navbar ref="navbar"></Navbar>
</div>
</template>
<script>
import Navbar from "./Navbar";
export default {
data: function() {
return {};
},
methods: {},
components: {
Navbar
}
};
</script>

View File

@ -3,38 +3,44 @@
</template> </template>
<script> <script>
import { get_file } from "@utils/AcrouUtil" import { get_file } from "@utils/AcrouUtil";
import MarkdownIt from 'markdown-it' import MarkdownIt from "markdown-it";
export default { export default {
props: { props: {
option: {}, option: {}
}, },
watch: { watch: {
option() { option() {
this.render() this.render();
}, }
}, },
data: function() { data: function() {
return { return {
content: ` content: ''
};
},
computed: {
defaultContent() {
return `
<center> <center>
<i class="fa fa-spinner fa-pulse fa-2x fa-fw"></i> <i class="fa fa-spinner fa-pulse fa-2x fa-fw"></i>
<span class="sr-only">Loading...</span> <span class="sr-only">Loading...</span>
</center> </center>
`, `
}; }
}, },
components: {}, components: {},
methods: { methods: {
render() { render() {
const md = new MarkdownIt() this.content = this.defaultContent
const md = new MarkdownIt();
// if (window.md == undefined) { // if (window.md == undefined) {
// window.md = window.markdownit(); // window.md = window.markdownit();
// } // }
get_file(this.option, (data) => { get_file(this.option, data => {
this.content = md.render(data); this.content = md.render(data);
}); });
},
} }
} }
};
</script> </script>

View File

@ -86,6 +86,9 @@ export default {
this.param = window.MODEL.q ? window.MODEL.q : ""; this.param = window.MODEL.q ? window.MODEL.q : "";
} }
}, },
mounted() {
this.siteName = document.getElementsByTagName("title")[0].innerText;
},
data: function() { data: function() {
return { return {
siteName: "", siteName: "",
@ -103,8 +106,11 @@ export default {
}, },
query() { query() {
if (this.param) { if (this.param) {
location.href = this.$router.push({
this.currgd.id.match("/[0-9]+:") + "search?q=" + this.param; path: this.currgd.id.match("/[0-9]+:") + "search?q=" + this.param
});
// location.href =
// this.currgd.id.match("/[0-9]+:") + "search?q=" + this.param;
} }
}, },
burgerClick() { burgerClick() {

View File

@ -18,13 +18,19 @@ export default {
display: false display: false
}; };
}, },
methods: { mounted() {
render(path) { let path = window.location.pathname;
// 便
path = process.env.NODE_ENV === "development" ? "/api" + path : "";
this.imgurl = path; this.imgurl = path;
}, },
methods: {
// render(path) {
// this.imgurl = path;
// },
loading(event) { loading(event) {
if (event.target.complete == true) { if (event.target.complete == true) {
this.display = true this.display = true;
} }
} }
} }

View File

@ -1,11 +1,7 @@
<template> <template>
<div> <div>
<progress <headmd :option="headmd" v-show="headmd.display"></headmd>
v-if="loading" <div class="golist">
class="progress is-small is-primary"
style="height: .25rem;"
max="100"
>15%</progress>
<table class="table is-hoverable"> <table class="table is-hoverable">
<thead> <thead>
<tr> <tr>
@ -19,8 +15,8 @@
</thead> </thead>
<tbody> <tbody>
<tr v-for="(file,index) in files" v-bind:key="index"> <tr v-for="(file,index) in files" v-bind:key="index">
<td @click="go(file.path)"> <td @click="go(file)">
<svg class="icon" aria-hidden="true"> <svg class="iconfont" aria-hidden="true">
<use :xlink:href="getIcon(file.mimeType)" /> <use :xlink:href="getIcon(file.mimeType)" />
</svg> </svg>
{{file.name}} {{file.name}}
@ -34,19 +30,33 @@
<!-- <span class="icon" @click="copy(file.path)"> <!-- <span class="icon" @click="copy(file.path)">
<i class="fa fa-copy" title="copy link" aria-hidden="true"></i> <i class="fa fa-copy" title="copy link" aria-hidden="true"></i>
</span>--> </span>-->
<span class="icon" @click.stop="go(file,'_blank')">
<i class="fa fa-external-link" title="Open a new tab" aria-hidden="true"></i>
</span>
<span class="icon"> <span class="icon">
<i class="fa fa-download" title="Download" @click="go(file.path,'down')"></i> <i
class="fa fa-download faa-shake animated-hover"
title="Download"
@click="go(file,'down')"
></i>
</span> </span>
</td> </td>
</tr> </tr>
</tbody> </tbody>
</table> </table>
<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>
<div v-show="loading" class="pageloader is-active">
<span class="title">Loading...</span>
</div>
</div>
<hr />
<readmemd :option="readmemd" v-show="readmemd.display"></readmemd>
</div> </div>
</template> </template>
<script> <script>
import { utc2beijing, formatFileSize } from "@utils/AcrouUtil"; import { utc2beijing, formatFileSize } from "@utils/AcrouUtil";
import Markdown from "../common/Markdown";
export default { export default {
data: function() { data: function() {
return { return {
@ -55,7 +65,7 @@ export default {
page_index: 0 page_index: 0
}, },
files: [], files: [],
loading: false, loading: true,
columns: [ columns: [
{ name: "文件", style: "" }, { name: "文件", style: "" },
{ {
@ -70,7 +80,7 @@ export default {
}, },
{ {
name: "下载", name: "下载",
style: "width:6%", style: "width:10%",
class: "is-hidden-mobile is-hidden-touch" class: "is-hidden-mobile is-hidden-touch"
} }
], ],
@ -93,19 +103,32 @@ export default {
"application/pdf": "icon-pdf", "application/pdf": "icon-pdf",
"application/json": "icon-JSON1", "application/json": "icon-JSON1",
"application/x-yaml": "icon-YML", "application/x-yaml": "icon-YML",
"application/vnd.openxmlformats-officedocument.wordprocessingml.document": "icon-word", "application/vnd.openxmlformats-officedocument.wordprocessingml.document":
"icon-word",
"image/bmp": "icon-img", "image/bmp": "icon-img",
"image/jpeg": "icon-img", "image/jpeg": "icon-img",
"image/png": "icon-img" "image/png": "icon-img"
} },
headmd: { display: false, file: {}, path: "" },
readmemd: { display: false, file: {}, path: "" }
}; };
}, },
components: {
Headmd: Markdown,
Readmemd: Markdown
},
mounted() {
this.render();
},
methods: { methods: {
render(path, param) { render() {
let path = window.location.pathname;
this.loading = true; this.loading = true;
var password = localStorage.getItem("password" + path); var password = localStorage.getItem("password" + path);
// var param = window.location.search;
let q = this.$route.query.q;
var p = { var p = {
q: param, q: q ? decodeURIComponent(q) : "",
password: password || null, password: password || null,
...this.page ...this.page
}; };
@ -151,19 +174,19 @@ export default {
var p = path + item.name; var p = path + item.name;
// HEAD.md // HEAD.md
if (item.name === "HEAD.md") { if (item.name === "HEAD.md") {
this.$emit("headmd", { this.headmd = {
display: true, display: true,
file: item, file: item,
path: p path: p
}); };
} }
// REDEME.md // REDEME.md
if (item.name === "README.md") { if (item.name === "README.md") {
this.$emit("readmemd", { this.readmemd = {
display: true, display: true,
file: item, file: item,
path: p path: p
}); };
} }
var ext = p.split(".").pop(); var ext = p.split(".").pop();
@ -204,15 +227,38 @@ export default {
// path = path.replace("?a=view", ""); // path = path.replace("?a=view", "");
// // TODO // // TODO
// }, // },
go(path, type = "view") { go(file, target) {
if (type === "down") { let path = file.path;
path = path.replace("?a=view", ""); let cmd = this.$route.params.cmd || "";
if (cmd === "search") {
this.$refs.goSearchResult.go(file, target);
return;
}
if (target === "down") {
path = path.replace("?a=view", "");
window.open(path)
return;
}
if(target === '_blank'){
window.open(path)
}else{
this.$router.push({
path: path
});
} }
location.href = path;
}, },
getIcon(type) { getIcon(type) {
return "#" + (this.icon[type] ? this.icon[type] : "icon-weizhi"); return "#" + (this.icon[type] ? this.icon[type] : "icon-weizhi");
} }
},
watch: {
$route(to, from) {
// 退page_token
if (to.path.length < from.path.length) {
this.page.page_token = null;
}
this.render();
}
} }
}; };
</script> </script>

View File

@ -0,0 +1,11 @@
<template>
<div class="card">324567</div>
</template>
<script>
export default {
data () {
return {
}
}
}
</script>

72
src/views/page/GoText.vue Normal file
View File

@ -0,0 +1,72 @@
<template>
<div class="content">
<editor
ref="myEditor"
v-model="content"
@init="editorInit"
lang="html"
theme="chrome"
width="100%"
height="600"
></editor>
</div>
</template>
<script>
import { get_file } from "@utils/AcrouUtil"
export default {
// props: {
// option: {
// path: "",
// file: {},
// },
// },
// watch: {
// option () {
// this.content = "...";
// get_file(this.option, (data) => {
// this.content = data;
// });
// },
// },
data: function () {
return {
path: "",
content: ""
};
},
// watch: {
// '$route' (to, from) {
// this.content = "...";
// get_file({path: to.replace('?a=view','/'),file: {}}, (data) => {
// this.content = data;
// });
// }
// },
created() {
this.render()
},
components: {
editor: require('@/components/ace-editor'),
},
methods: {
render() {
let path = window.location.pathname
this.content = "加载中...";
get_file({path: path.replace('?a=view','/'),file: {}}, (data) => {
this.content = data;
});
},
editorInit (editor) {
editor.setFontSize(18)
editor.session.setUseWrapMode(false);
require("brace/ext/language_tools"); //language extension prerequsite...
require("brace/mode/html");
require("brace/mode/javascript"); //language
require("brace/mode/less");
require("brace/theme/chrome");
require("brace/snippets/javascript"); //snippet
},
}
}
</script>

View File

@ -76,11 +76,16 @@ export default {
}; };
}, },
methods: { methods: {
render (path) { // render (path) {
this.videourl = window.location.origin + path; // this.videourl = window.location.origin + path;
this.apiurl = // this.apiurl =
"https://api.jsonpop.cn/demo/blplyaer/?url=" + this.videourl; // "https://api.jsonpop.cn/demo/blplyaer/?url=" + this.videourl;
// },
}, },
mounted() {
// 便
this.videourl = window.location.origin + window.location.pathname;
this.apiurl = "https://api.jsonpop.cn/demo/blplyaer/?url=" + this.videourl;
}, },
computed: { computed: {
getThunder () { getThunder () {

View File

@ -1,5 +1,4 @@
const path = require("path"); const path = require("path");
const fs = require('fs')
const cdnDependencies = require('./dependencies-cdn') const cdnDependencies = require('./dependencies-cdn')
function resolve(dir) { function resolve(dir) {
@ -25,136 +24,6 @@ module.exports = {
const configNew = {} const configNew = {}
if (process.env.NODE_ENV === 'production') { if (process.env.NODE_ENV === 'production') {
configNew.externals = externals configNew.externals = externals
config.plugins.push({
apply: (compiler) => {
compiler.hooks.done.tap('JSWebpackPluginHooks', compilation => {
// console.log(compilation.assetsInfo)
const chunkOnlyConfig = {
assets: false,
cached: false,
children: false,
chunks: true,
chunkModules: false,
chunkOrigins: false,
errorDetails: false,
hash: false,
modules: false,
reasons: false,
source: false,
timings: false,
version: false
};
const allChunks = compilation.toJson(chunkOnlyConfig).chunks;
// console.log(JSON.stringify(allChunks))
let chunks = filterChunks(allChunks, 'all', []);
const assets = htmlWebpackPluginAssets(compilation, chunks);
function filterChunks (chunks, includedChunks, excludedChunks) {
return chunks.filter(chunk => {
const chunkName = chunk.names[0];
// This chunk doesn't have a name. This script can't handled it.
if (chunkName === undefined) {
return false;
}
// Skip if the chunk should be lazy loaded
if (typeof chunk.isInitial === 'function') {
if (!chunk.isInitial()) {
return false;
}
} else if (!chunk.initial) {
return false;
}
// Skip if the chunks should be filtered and the given chunk was not added explicity
if (Array.isArray(includedChunks) && includedChunks.indexOf(chunkName) === -1) {
return false;
}
// Skip if the chunks should be filtered and the given chunk was excluded explicity
if (Array.isArray(excludedChunks) && excludedChunks.indexOf(chunkName) !== -1) {
return false;
}
// Add otherwise
return true;
});
}
function htmlWebpackPluginAssets (compilation, chunks) {
const self = this;
const compilationHash = compilation.hash;
// Use the configured public path or build a relative path
let publicPath = typeof compilation.options.output.publicPath !== 'undefined'
// If a hard coded public path exists use it
? compilation.mainTemplate.getPublicPath({hash: compilationHash})
// If no public path was set get a relative url path
: path.relative(path.resolve(compilation.options.output.path, path.dirname(self.childCompilationOutputName)), compilation.options.output.path)
.split(path.sep).join('/');
if (publicPath.length && publicPath.substr(-1, 1) !== '/') {
publicPath += '/';
}
const assets = {
// The public path
publicPath: publicPath,
// Will contain all js & css files by chunk
chunks: {},
// Will contain all js files
js: [],
// Will contain all css files
css: [],
// Will contain the html5 appcache manifest files if it exists
manifest: Object.keys(compilation.assets).filter(assetFile => path.extname(assetFile) === '.appcache')[0]
};
// Append a hash for cache busting
if (this.options.hash) {
assets.manifest = self.appendHash(assets.manifest, compilationHash);
assets.favicon = self.appendHash(assets.favicon, compilationHash);
}
for (let i = 0; i < chunks.length; i++) {
const chunk = chunks[i];
const chunkName = chunk.names[0];
assets.chunks[chunkName] = {};
// Prepend the public path to all chunk files
let chunkFiles = [].concat(chunk.files).map(chunkFile => publicPath + chunkFile);
// Append a hash for cache busting
if (this.options.hash) {
chunkFiles = chunkFiles.map(chunkFile => self.appendHash(chunkFile, compilationHash));
}
// Webpack outputs an array for each chunk when using sourcemaps
// or when one chunk hosts js and css simultaneously
const js = chunkFiles.find(chunkFile => /.js($|\?)/.test(chunkFile));
if (js) {
assets.chunks[chunkName].size = chunk.size;
assets.chunks[chunkName].entry = js;
assets.chunks[chunkName].hash = chunk.hash;
assets.js.push(js);
}
// Gather all css files
const css = chunkFiles.filter(chunkFile => /.css($|\?)/.test(chunkFile));
assets.chunks[chunkName].css = css;
assets.css = assets.css.concat(css);
}
// Duplicate css assets can occur on occasion if more than one chunk
// requires the same css.
assets.css = _.uniq(assets.css);
return assets;
}
fs.writeFile(path.resolve('dist/app.js'),JSON.stringify(assets),function(err){
if(err){
return console.log(err)
}
console.log("Success")
})
});
}
})
} }
return configNew return configNew
}, },