update 完善了部分开发文档
This commit is contained in:
@@ -3,10 +3,15 @@
|
||||
<container>
|
||||
<a-row :gutter="16" type="flex">
|
||||
<a-col flex="auto">
|
||||
<container mode="container">
|
||||
<section :id="`doc-${index}`" :key="index" v-for="(doc, index) in docs">
|
||||
<container
|
||||
:id="`doc-${index}`"
|
||||
:key="index"
|
||||
mode="container"
|
||||
v-for="(doc, index) in docs"
|
||||
>
|
||||
<section>
|
||||
<h1>{{ doc.title }}</h1>
|
||||
<component :codes="codes" :is="doc.component" v-if="doc.name" />
|
||||
<component :codes="codes" :is="doc.component" v-if="doc.path" />
|
||||
<template v-if="doc.children">
|
||||
<section
|
||||
:id="`doc-${index}-${_index}`"
|
||||
@@ -14,10 +19,11 @@
|
||||
v-for="(_doc, _index) in doc.children"
|
||||
>
|
||||
<h3>{{ _doc.title }}</h3>
|
||||
<component :codes="codes" :is="_doc.component" v-if="_doc.name" />
|
||||
<component :codes="codes" :is="_doc.component" v-if="_doc.path" />
|
||||
</section>
|
||||
</template>
|
||||
</section>
|
||||
<a-divider v-if="index < docs.length - 1" />
|
||||
</container>
|
||||
</a-col>
|
||||
<a-col flex="240px">
|
||||
@@ -48,59 +54,126 @@
|
||||
</a-card>
|
||||
</template>
|
||||
<script>
|
||||
const docs = [
|
||||
{
|
||||
title: '数据库',
|
||||
path: '/database',
|
||||
children: [
|
||||
{
|
||||
title: '实体(N)',
|
||||
},
|
||||
{
|
||||
title: '迁移',
|
||||
path: '/database/migrations',
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
title: '数据传输对象',
|
||||
},
|
||||
{
|
||||
title: '窗口',
|
||||
path: '/window',
|
||||
children: [
|
||||
{
|
||||
title: '打开窗口',
|
||||
path: '/window/open',
|
||||
},
|
||||
{
|
||||
title: '关闭窗口',
|
||||
path: '/window/close',
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
title: '全局函数',
|
||||
path: '/functions',
|
||||
},
|
||||
{
|
||||
title: '接口',
|
||||
path: '/api',
|
||||
children: [
|
||||
{
|
||||
title: '配置',
|
||||
path: '/api/setting',
|
||||
},
|
||||
{
|
||||
title: '调用',
|
||||
path: '/api/usage',
|
||||
},
|
||||
{
|
||||
title: '队列',
|
||||
path: '/api/queue',
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
title: '权限渲染',
|
||||
path: '/auth',
|
||||
},
|
||||
{
|
||||
title: '种子',
|
||||
path: '/seed',
|
||||
children: [
|
||||
{
|
||||
title: '查询表格',
|
||||
path: '/seed/query',
|
||||
},
|
||||
{
|
||||
title: '编辑窗口',
|
||||
path: '/seed/form',
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
title: '全局用户信息',
|
||||
path: '/globalinfo',
|
||||
},
|
||||
{
|
||||
title: '内置组件(N)',
|
||||
},
|
||||
{
|
||||
title: '本地存储(N)',
|
||||
path: '/storage',
|
||||
},
|
||||
{
|
||||
title: '工具(N)',
|
||||
},
|
||||
];
|
||||
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
docs: [
|
||||
{
|
||||
title: '开始使用',
|
||||
name: '/usage',
|
||||
},
|
||||
{
|
||||
title: '窗口',
|
||||
},
|
||||
{
|
||||
title: '种子',
|
||||
name: '/seed',
|
||||
children: [
|
||||
{
|
||||
title: '查询表格',
|
||||
name: '/seed/query',
|
||||
},
|
||||
{
|
||||
title: '编辑窗口',
|
||||
name: '/seed/form',
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
docs: null,
|
||||
|
||||
codes: {},
|
||||
};
|
||||
},
|
||||
mounted() {
|
||||
this.docs.forEach((doc) => {
|
||||
if (doc.name) {
|
||||
this.$set(doc, 'component', () => import(`.${doc.name}`));
|
||||
docs.forEach((doc) => {
|
||||
if (doc.path) {
|
||||
doc.component = () => import(`.${doc.path}`);
|
||||
}
|
||||
if (doc.children) {
|
||||
doc.children.forEach((_doc) => {
|
||||
this.$set(_doc, 'component', () => import(`.${_doc.name}`));
|
||||
_doc.component = () => import(`.${_doc.path}`);
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
this.docs = docs;
|
||||
|
||||
// 读取doc-code下所有文件内容
|
||||
const files = require.context('@/../public/doc-code', true, /\.(js|html|vue|css|less|json)(\?.*)?$/);
|
||||
const files = require.context('@/../public/doc-code', true, /\.(js|jsx|html|vue|css|less|json|cs)(\?.*)?$/);
|
||||
const codes = {};
|
||||
files.keys().forEach((p) => {
|
||||
const fileName = p.slice(1);
|
||||
const filepath = p.slice(1);
|
||||
const xhr = new XMLHttpRequest();
|
||||
xhr.open('GET', `./doc-code${fileName}`, false);
|
||||
xhr.open('GET', `./doc-code${filepath}`, false);
|
||||
xhr.overrideMimeType('text/plain;charset=utf-8');
|
||||
xhr.send(null);
|
||||
codes[fileName] = xhr.responseText;
|
||||
codes[filepath] = xhr.responseText;
|
||||
});
|
||||
console.log(codes);
|
||||
this.codes = codes;
|
||||
},
|
||||
methods: {
|
||||
|
||||
Reference in New Issue
Block a user