update document integration

This commit is contained in:
AceDataCloud committed 2023-01-22 15:57:26 +08:00
1 parent c7fdcd0a4b
commit 798de13a35
14 files changed
+209 -151

No files matched your search

File renamed without changes.
File renamed without changes.
File renamed without changes.
@@ -38,8 +38,8 @@
<script lang="ts">
import { defineComponent } from 'vue';
import { IApi, IApiDetailResponse, IForm } from '@/operators/api/models';
import ApiForm from './ApiForm.vue';
import ApiResult from './ApiResult.vue';
import ApiForm from './Form.vue';
import ApiResult from './Result.vue';
import urlJoin from 'url-join';
export interface IData {
-55
View File
@@ -1,55 +0,0 @@
<template>
<div v-if="apis" class="wrapper">
<api-list-item v-for="(api, apiIndex) in apis" :key="apiIndex" :api="api"></api-list-item>
</div>
</template>
<script lang="ts">
import { defineComponent } from 'vue';
import { IApi, IApiListResponse } from '@/operators/api/models';
import { apiOperator } from '@/operators/api/operator';
import ApiListItem from './ApiListItem.vue';
interface IData {
apis: IApi[];
limit: number;
offset: number;
}
export default defineComponent({
name: 'ApiList',
components: {
ApiListItem
},
data(): IData {
return {
apis: [],
limit: 20,
offset: 0
};
},
mounted() {
this.getApis(this.offset, this.limit);
},
methods: {
getApis(offset: number, limit: number) {
apiOperator
.getAll({
offset,
limit
})
.then(({ data: data }: { data: IApiListResponse }) => {
this.apis = data.items;
})
.catch((error) => {
console.error(error);
});
}
}
});
</script>
<style lang="scss" scoped>
.wrapper {
padding: 20px 0;
}
</style>
+61
View File
@@ -0,0 +1,61 @@
<template>
<div v-if="documents" class="wrapper">
<document-list-item
v-for="(document, documentIndex) in documents"
:key="documentIndex"
:document="document"
></document-list-item>
</div>
</template>
<script lang="ts">
import { defineComponent } from 'vue';
import { IDocument, IDocumentListResponse } from '@/operators/document/models';
import DocumentListItem from './ListItem.vue';
import { documentOperator } from '@/operators/document';
interface IData {
documents: IDocument[];
limit: number;
offset: number;
}
export default defineComponent({
name: 'DocumentList',
components: {
DocumentListItem
},
data(): IData {
return {
documents: [],
limit: 20,
offset: 0
};
},
computed: {},
mounted() {
this.getDocuments(this.offset, this.limit);
},
methods: {
getDocuments(offset: number, limit: number) {
documentOperator
.getAll({
offset,
limit
})
.then(({ data: data }: { data: IDocumentListResponse }) => {
this.documents = data.items;
})
.catch((error) => {
console.error(error);
});
}
}
});
</script>
<style lang="scss" scoped>
.wrapper {
padding: 20px 0;
}
</style>
@@ -1,10 +1,15 @@
<template>
<div class="item" @click="onClick">
<div v-if="document.type === 'TEXT'" class="item" @click="onClick">
<el-link type="primary" class="link" :underline="false">
<span class="name">{{ api?.title }}</span>
<span class="name">{{ document?.title }}</span>
</el-link>
<el-tag v-if="api?.request?.method" type="primary" class="request-method" effect="dark">
{{ api?.request?.method }}
</div>
<div v-else-if="document.type === 'API'" class="item" @click="onClick">
<el-link type="primary" class="link" :underline="false">
<span class="name">{{ document?.api?.title }}</span>
</el-link>
<el-tag v-if="document?.api?.request?.method" type="primary" class="request-method" effect="dark">
{{ document?.api?.request?.method }}
</el-tag>
</div>
</template>
@@ -12,12 +17,13 @@
<script lang="ts">
import { defineComponent } from 'vue';
import { IApi } from '@/operators/api/models';
import { IDocument } from '@/operators/document/models';
export default defineComponent({
name: 'ApiListItem',
props: {
api: {
type: Object as () => IApi,
document: {
type: Object as () => IDocument,
required: true
}
},
@@ -26,7 +32,7 @@ export default defineComponent({
this.$router.push({
name: 'document-detail',
params: {
id: this.api.id
id: this.document.id
}
});
}