update document detail page

This commit is contained in:
AceDataCloud committed 2023-01-22 16:36:46 +08:00
1 parent 798de13a35
commit 1bc2068e7b
7 files changed
+71 -9

No files matched your search

+7 -2
View File
@@ -1,7 +1,7 @@
<template>
<div v-if="document" class="center">
<div v-if="document.type === 'TEXT'">
<markdown-renderer :content="document?.content" />
<markdown-renderer :content="document?.content" :loading="loading" />
</div>
<div v-else-if="document.type === 'API'">
<api-usage v-if="document.api" v-model:form="form" :loading="loading" :api="document.api" />
@@ -18,6 +18,7 @@ import ApiUsage from '@/components/api/Usage.vue';
import ApiTry from '@/components/api/Try.vue';
import { documentOperator, IDocument, IDocumentDetailResponse } from '@/operators';
import { IForm } from '@/operators/api/models';
import MarkdownRenderer from '@/components/common/MarkdownRenderer.vue';
export interface IData {
document: IDocument | undefined;
@@ -28,7 +29,8 @@ export interface IData {
export default defineComponent({
components: {
ApiUsage,
ApiTry
ApiTry,
MarkdownRenderer
},
data(): IData {
return {
@@ -76,6 +78,9 @@ export default defineComponent({
width: calc(100% - 760px);
height: 100%;
padding: 30px;
.markdown-body {
background: none;
}
}
.right {
+41 -3
View File
@@ -1,17 +1,55 @@
<template>
<div class="center">
<h2>{{ $t('common.title.documentIntroduction') }}</h2>
<el-skeleton />
<el-divider />
<el-skeleton />
</div>
</template>
<script lang="ts">
import { IDocument, IDocumentListResponse } from '@/operators/document/models';
import { documentOperator } from '@/operators/document/operator';
import { defineComponent } from 'vue';
interface IData {
documents: IDocument[];
}
export default defineComponent({
components: {},
data() {},
data(): IData {
return {
documents: []
};
},
computed: {},
mounted() {}
mounted() {
this.getDocuments(0, 1);
},
methods: {
getDocuments(offset: number, limit: number) {
documentOperator
.getAll({
offset,
limit,
ordering: 'rank'
})
.then(({ data: data }: { data: IDocumentListResponse }) => {
this.documents = data.items;
if (this.documents.length > 0) {
const firstDocument = this.documents[0];
this.$router.push({
name: 'document-detail',
params: {
id: firstDocument.id
}
});
}
})
.catch((error) => {
console.error(error);
});
}
}
});
</script>