feat: 支持文档模板

This commit is contained in:
muwoo
2021-06-08 18:04:36 +08:00
parent 02d9c30bc9
commit 1d7c2f592c
8 changed files with 276 additions and 18 deletions

41
static/index.js Normal file
View File

@@ -0,0 +1,41 @@
import doc from './doc.js';
function getQueryVariable(variable) {
var query = window.location.search.substring(1);
var vars = query.split("&");
console.log(vars);
for (var i=0;i<vars.length;i++) {
var pair = vars[i].split("=");
if(pair[0] == variable){return pair[1];}
}
return(false);
}
const routes = [
{ path: '/doc', name: 'doc', component: doc },
]
const router = new VueRouter({
routes // (缩写) 相当于 routes: routes
})
const app = new Vue({
el: '#app',
data: {
config: window.exports,
code: '',
current: {}
},
mounted() {
this.code = getQueryVariable('code');
this.current = this.config[this.code];
this.$router.push({
name: this.current.mode,
query: {
args: JSON.stringify(this.current.args),
rootPath: getQueryVariable('targetFile').replace('index.html', '')
},
})
},
router,
})