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>
|
||||
@@ -0,0 +1,33 @@
|
||||
<template>
|
||||
<el-container class="wrapper">
|
||||
<el-header class="header">
|
||||
<top-header />
|
||||
</el-header>
|
||||
<el-main class="main"> <router-view /> </el-main>
|
||||
<el-footer class="footer">
|
||||
<bottom-footer />
|
||||
</el-footer>
|
||||
</el-container>
|
||||
</template>
|
||||
|
||||
<script lang="ts">
|
||||
import { TopHeader } from '@/components/common/index';
|
||||
import BottomFooter from '@/components/common/BottomFooter.vue';
|
||||
export default {
|
||||
name: 'LayoutCourse',
|
||||
components: {
|
||||
TopHeader,
|
||||
BottomFooter
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.wrapper {
|
||||
min-height: 100vh;
|
||||
}
|
||||
|
||||
.header {
|
||||
padding: 0;
|
||||
}
|
||||
</style>
|
||||
@@ -6,6 +6,7 @@ export interface IApi {
|
||||
tags?: string[];
|
||||
endpoint?: string;
|
||||
isFree?: boolean;
|
||||
requestMethod?: boolean;
|
||||
swaggerConfiguration?: string;
|
||||
service?: string;
|
||||
createdAt?: string;
|
||||
|
||||
@@ -0,0 +1,76 @@
|
||||
<template>
|
||||
<el-row class="wrapper">
|
||||
<el-col :span="22" :offset="1">
|
||||
<div class="left">
|
||||
<api-list />
|
||||
</div>
|
||||
<div class="main">
|
||||
<api-usage v-if="api" :api="api" />
|
||||
</div>
|
||||
<div class="right"></div>
|
||||
</el-col>
|
||||
</el-row>
|
||||
</template>
|
||||
|
||||
<script lang="ts">
|
||||
import { defineComponent } from 'vue';
|
||||
import ApiList from '@/components/document/ApiList.vue';
|
||||
import ApiUsage from '@/components/document/ApiUsage.vue';
|
||||
import { apiOperator } from '@/operators/api/operator';
|
||||
import { IApi, IApiDetailResponse } from '@/operators/api/models';
|
||||
|
||||
export interface IData {
|
||||
api: IApi | undefined;
|
||||
}
|
||||
|
||||
export default defineComponent({
|
||||
components: {
|
||||
ApiList,
|
||||
ApiUsage
|
||||
},
|
||||
data(): IData {
|
||||
return {
|
||||
api: undefined
|
||||
};
|
||||
},
|
||||
methods: {
|
||||
getApi(id: string) {
|
||||
apiOperator
|
||||
.get(id)
|
||||
.then(({ data: data }: { data: IApiDetailResponse }) => {
|
||||
this.api = data;
|
||||
console.log('api', this.api);
|
||||
})
|
||||
.catch((error) => {
|
||||
console.error(error);
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.wrapper {
|
||||
width: 100%;
|
||||
height: 100vh;
|
||||
overflow: hidden;
|
||||
|
||||
.left {
|
||||
float: left;
|
||||
width: 280px;
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
.main {
|
||||
float: left;
|
||||
width: calc(100% - 760px);
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
.right {
|
||||
float: left;
|
||||
width: 480px;
|
||||
height: 100%;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,15 @@
|
||||
export default {
|
||||
path: '/documents',
|
||||
name: 'documents',
|
||||
meta: {
|
||||
auth: true
|
||||
},
|
||||
component: () => import('@/layouts/Document.vue'),
|
||||
children: [
|
||||
{
|
||||
path: ':id',
|
||||
name: 'document-detail',
|
||||
component: () => import('@/pages/document/Detail.vue')
|
||||
}
|
||||
]
|
||||
};
|
||||
+3
-1
@@ -2,6 +2,7 @@ import { createRouter, createWebHistory, createWebHashHistory } from 'vue-router
|
||||
import service from './service';
|
||||
import auth from './auth';
|
||||
import console from './console';
|
||||
import document from './document';
|
||||
import store from '@/store';
|
||||
|
||||
const routes = [
|
||||
@@ -12,7 +13,8 @@ const routes = [
|
||||
},
|
||||
service,
|
||||
auth,
|
||||
console
|
||||
console,
|
||||
document
|
||||
];
|
||||
|
||||
const router = createRouter({
|
||||
|
||||
Reference in new issue
Block a user