update 一系列功能

This commit is contained in:
2021-04-27 14:13:28 +08:00
parent 62e32bb8fd
commit 2945ecb3b8
16 changed files with 230 additions and 35 deletions

View File

@@ -1,3 +0,0 @@
<template>
<div></div>
</template>

View File

@@ -0,0 +1,16 @@
export default {
props: {
code: {
type: String
}
},
render() {
const props = {
...this.$props,
...this.$attrs
}
return props.code && <highlightjs {...{ props }} />
}
}

View File

@@ -0,0 +1,53 @@
<template>
<container>
<template v-for="(doc, index) in docs">
<component :codes="codes" :is="doc.component" :key="index" />
</template>
<a-anchor>
<a-anchor-link href="#components-anchor-demo-basic" title="Basic demo" />
<a-anchor-link href="#components-anchor-demo-static" title="Static demo" />
<a-anchor-link
href="#components-anchor-demo-basic"
target="_blank"
title="Basic demo with Target"
/>
<a-anchor-link href="#API" title="API">
<a-anchor-link href="#Anchor-Props" title="Anchor Props" />
<a-anchor-link href="#Link-Props" title="Link Props" />
</a-anchor-link>
</a-anchor>
</container>
</template>
<script>
export default {
data() {
return {
docs: [
{
title: '开始使用',
name: 'use',
},
],
codes: {},
};
},
mounted() {
this.docs.forEach((doc) => {
this.$set(doc, 'component', () => import(`./${doc.name}`));
});
const files = require.context('@/../public/doc-part', true, /\.(js|html|vue|css|less)(\?.*)?$/);
const codes = {};
files.keys().forEach((p) => {
const fileName = p.slice(1);
const xhr = new XMLHttpRequest();
xhr.open('GET', `./doc-part${fileName}`, false);
xhr.overrideMimeType('text/plain;charset=utf-8');
xhr.send(null);
codes[fileName] = xhr.responseText;
});
console.log(codes);
this.codes = codes;
},
};
</script>

View File

@@ -0,0 +1,21 @@
<template>
<section>
<h3>开始使用</h3>
<Highlight :code="codes['/use/a.js'] || ''" language="javascript" />
<Highlight :code="codes['/use/test.vue'] || ''" language="javascript" />
</section>
</template>
<script>
import Highlight from './highlight';
export default {
components: {
Highlight,
},
props: {
codes: {
type: Object,
},
},
};
</script>

View File

@@ -260,6 +260,9 @@ export default {
} else {
this.$message.error(message);
}
})
.finally(() => {
record.statusChanging = false;
});
},