add document page
This commit is contained in:
1 parent
f84ab30879
commit
2b32240fe0
8 files changed
+280
-1
No files matched your search
@@ -0,0 +1,54 @@
|
||||
<template>
|
||||
<div class="wrapper">
|
||||
<div v-if="apis">
|
||||
<api-list-item v-for="(api, apiIndex) in apis" :key="apiIndex" :api="api"></api-list-item>
|
||||
</div>
|
||||
</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;
|
||||
console.log('apis', this.apis);
|
||||
})
|
||||
.catch((error) => {
|
||||
console.error(error);
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped></style>
|
||||
@@ -0,0 +1,49 @@
|
||||
<template>
|
||||
<div class="item">
|
||||
<el-link type="primary" class="link" @click="onClick">
|
||||
<span class="name">{{ api.title }}</span>
|
||||
<span class="request-method">{{ api.requestMethod }}</span>
|
||||
</el-link>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script lang="ts">
|
||||
import { defineComponent } from 'vue';
|
||||
import { IApi } from '@/operators/api/models';
|
||||
export default defineComponent({
|
||||
name: 'ApiListItem',
|
||||
props: {
|
||||
api: {
|
||||
type: Object as () => IApi,
|
||||
required: true
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
onClick() {
|
||||
this.$router.push({
|
||||
name: 'document-detail',
|
||||
params: {
|
||||
id: this.api.id
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
<style lang="scss">
|
||||
.link {
|
||||
.name {
|
||||
display: flex;
|
||||
}
|
||||
.request-method {
|
||||
display: flex;
|
||||
padding-left: 0;
|
||||
padding-right: 0;
|
||||
width: 40px;
|
||||
flex-grow: 0;
|
||||
flex-shrink: 0;
|
||||
flex-basis: auto;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,49 @@
|
||||
<template>
|
||||
<div class="item">
|
||||
<el-link type="primary" class="link" @click="onClick">
|
||||
<span class="name">{{ api.title }}</span>
|
||||
<span class="request-method">{{ api.requestMethod }}</span>
|
||||
</el-link>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script lang="ts">
|
||||
import { defineComponent } from 'vue';
|
||||
import { IApi } from '@/operators/api/models';
|
||||
export default defineComponent({
|
||||
name: 'ApiListItem',
|
||||
props: {
|
||||
api: {
|
||||
type: Object as () => IApi,
|
||||
required: true
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
onClick() {
|
||||
this.$router.push({
|
||||
name: 'document-detail',
|
||||
params: {
|
||||
id: this.api.id
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
<style lang="scss">
|
||||
.link {
|
||||
.name {
|
||||
display: flex;
|
||||
}
|
||||
.request-method {
|
||||
display: flex;
|
||||
padding-left: 0;
|
||||
padding-right: 0;
|
||||
width: 40px;
|
||||
flex-grow: 0;
|
||||
flex-shrink: 0;
|
||||
flex-basis: auto;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
Reference in new issue
Block a user