update document detail page
This commit is contained in:
1 parent
798de13a35
commit
1bc2068e7b
7 files changed
+71
-9
No files matched your search
@@ -7,6 +7,9 @@
|
||||
<div class="title">{{ $t('api.entity.response') }}</div>
|
||||
<code-snippet :code="responseData" />
|
||||
</div>
|
||||
<div v-if="loading">
|
||||
<el-skeleton />
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
@@ -35,11 +38,14 @@ export default defineComponent({
|
||||
data() {
|
||||
return {
|
||||
apiKeyValue: this.apiKey,
|
||||
responseData: ''
|
||||
responseData: '',
|
||||
loading: false
|
||||
};
|
||||
},
|
||||
methods: {
|
||||
onTry() {
|
||||
this.loading = true;
|
||||
this.responseData = '';
|
||||
const config = {
|
||||
method: this.api?.request?.method as Method,
|
||||
url: urlJoin(this.api?.endpoint, this.api?.path),
|
||||
@@ -49,9 +55,11 @@ export default defineComponent({
|
||||
console.debug('config of testing', config);
|
||||
axios(config)
|
||||
.then((response) => {
|
||||
this.loading = false;
|
||||
this.responseData = JSON.stringify(response?.data, null, ' ');
|
||||
})
|
||||
.catch((error) => {
|
||||
this.loading = false;
|
||||
this.responseData = JSON.stringify(error?.response?.data, null, ' ');
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1,5 +1,10 @@
|
||||
<template>
|
||||
<vue-markdown :source="content" class="markdown-body" />
|
||||
<div v-if="loading">
|
||||
<el-skeleton />
|
||||
<el-divider />
|
||||
<el-skeleton />
|
||||
</div>
|
||||
<vue-markdown v-else :source="content" class="markdown-body" />
|
||||
</template>
|
||||
|
||||
<script lang="ts">
|
||||
@@ -15,6 +20,11 @@ export default defineComponent({
|
||||
content: {
|
||||
type: String,
|
||||
required: true
|
||||
},
|
||||
loading: {
|
||||
type: Boolean,
|
||||
required: false,
|
||||
default: false
|
||||
}
|
||||
},
|
||||
data() {},
|
||||
|
||||
@@ -41,7 +41,8 @@ export default defineComponent({
|
||||
documentOperator
|
||||
.getAll({
|
||||
offset,
|
||||
limit
|
||||
limit,
|
||||
ordering: 'rank'
|
||||
})
|
||||
.then(({ data: data }: { data: IDocumentListResponse }) => {
|
||||
this.documents = data.items;
|
||||
|
||||
@@ -16,7 +16,6 @@
|
||||
|
||||
<script lang="ts">
|
||||
import { defineComponent } from 'vue';
|
||||
import { IApi } from '@/operators/api/models';
|
||||
import { IDocument } from '@/operators/document/models';
|
||||
|
||||
export default defineComponent({
|
||||
|
||||
@@ -5,6 +5,7 @@ import { IDocument, IDocumentDetailResponse, IDocumentListResponse } from './mod
|
||||
export interface IDocumentQuery {
|
||||
limit: number;
|
||||
offset: number;
|
||||
ordering: string;
|
||||
}
|
||||
|
||||
class DocumentOperator {
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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>
|
||||
|
||||
|
||||
Reference in new issue
Block a user