migrate new model
This commit is contained in:
1 parent
5dae704649
commit
e2e17eef96
19 files changed
+202
-108
No files matched your search
@@ -0,0 +1,61 @@
|
|||||||
|
<template>
|
||||||
|
<div class="title">
|
||||||
|
{{ api?.title }}
|
||||||
|
</div>
|
||||||
|
<div class="url">
|
||||||
|
<el-tag class="method" effect="dark">{{ api?.request?.method }}</el-tag>
|
||||||
|
<span v-if="api?.endpoint && api?.path" class="endpoint">{{ urlJoin(api?.endpoint, api?.path) }}</span>
|
||||||
|
</div>
|
||||||
|
<div class="introduction">
|
||||||
|
<p>{{ api?.introduction }}</p>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script lang="ts">
|
||||||
|
import { IApi } from '@/operators';
|
||||||
|
import { defineComponent } from 'vue';
|
||||||
|
import urlJoin from 'url-join';
|
||||||
|
import { ElTag } from 'element-plus';
|
||||||
|
export default defineComponent({
|
||||||
|
name: 'ApiInfo',
|
||||||
|
components: {
|
||||||
|
ElTag
|
||||||
|
},
|
||||||
|
props: {
|
||||||
|
api: {
|
||||||
|
type: Object as () => IApi,
|
||||||
|
required: true
|
||||||
|
}
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
urlJoin
|
||||||
|
}
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style lang="scss" scoped>
|
||||||
|
.title {
|
||||||
|
font-size: 26px;
|
||||||
|
font-weight: 500;
|
||||||
|
line-height: 1.2;
|
||||||
|
margin-bottom: 10px;
|
||||||
|
}
|
||||||
|
.url {
|
||||||
|
margin-bottom: 10px;
|
||||||
|
.method {
|
||||||
|
border-radius: 10px;
|
||||||
|
padding: 1px 8px;
|
||||||
|
font-size: 10px;
|
||||||
|
transform: scale(0.8);
|
||||||
|
transform-origin: left;
|
||||||
|
}
|
||||||
|
.endpoint {
|
||||||
|
font-size: 12px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
.introduction {
|
||||||
|
font-size: 16px;
|
||||||
|
font-weight: bold;
|
||||||
|
margin-bottom: 10px;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
@@ -5,16 +5,7 @@
|
|||||||
<el-skeleton />
|
<el-skeleton />
|
||||||
</div>
|
</div>
|
||||||
<div v-else class="item">
|
<div v-else class="item">
|
||||||
<div class="title">
|
<api-info v-if="api" :api="api" />
|
||||||
{{ api?.title }}
|
|
||||||
</div>
|
|
||||||
<div class="url">
|
|
||||||
<el-tag class="method" effect="dark">{{ api?.request?.method }}</el-tag>
|
|
||||||
<span v-if="api?.endpoint && api?.path" class="endpoint">{{ urlJoin(api?.endpoint, api?.path) }}</span>
|
|
||||||
</div>
|
|
||||||
<div class="introduction">
|
|
||||||
<p>{{ api?.introduction }}</p>
|
|
||||||
</div>
|
|
||||||
<el-divider />
|
<el-divider />
|
||||||
<div class="queries">
|
<div class="queries">
|
||||||
<h2 class="title">{{ $t('api.entity.requestQueries') }}</h2>
|
<h2 class="title">{{ $t('api.entity.requestQueries') }}</h2>
|
||||||
@@ -56,10 +47,10 @@ import { defineComponent } from 'vue';
|
|||||||
import { IApi, IForm } from '@/operators/api/models';
|
import { IApi, IForm } from '@/operators/api/models';
|
||||||
import ApiForm from './Form.vue';
|
import ApiForm from './Form.vue';
|
||||||
import ApiResult from './Result.vue';
|
import ApiResult from './Result.vue';
|
||||||
import urlJoin from 'url-join';
|
|
||||||
import { applicationOperator } from '@/operators/application/operator';
|
import { applicationOperator } from '@/operators/application/operator';
|
||||||
import { IApplication, IApplicationListResponse } from '@/operators/application/models';
|
import { IApplication, IApplicationListResponse } from '@/operators/application/models';
|
||||||
import { ElSkeleton, ElDivider, ElTag } from 'element-plus';
|
import { ElSkeleton, ElDivider, ElTag } from 'element-plus';
|
||||||
|
import ApiInfo from './Info.vue';
|
||||||
|
|
||||||
export interface IData {
|
export interface IData {
|
||||||
formValue: IForm;
|
formValue: IForm;
|
||||||
@@ -73,7 +64,7 @@ export default defineComponent({
|
|||||||
ApiResult,
|
ApiResult,
|
||||||
ElSkeleton,
|
ElSkeleton,
|
||||||
ElDivider,
|
ElDivider,
|
||||||
ElTag
|
ApiInfo
|
||||||
},
|
},
|
||||||
props: {
|
props: {
|
||||||
api: {
|
api: {
|
||||||
@@ -106,7 +97,6 @@ export default defineComponent({
|
|||||||
},
|
},
|
||||||
mounted() {},
|
mounted() {},
|
||||||
methods: {
|
methods: {
|
||||||
urlJoin,
|
|
||||||
getApplications() {
|
getApplications() {
|
||||||
applicationOperator
|
applicationOperator
|
||||||
.getAll({
|
.getAll({
|
||||||
@@ -123,30 +113,6 @@ export default defineComponent({
|
|||||||
|
|
||||||
<style lang="scss" scoped>
|
<style lang="scss" scoped>
|
||||||
.item {
|
.item {
|
||||||
.title {
|
|
||||||
font-size: 26px;
|
|
||||||
font-weight: 500;
|
|
||||||
line-height: 1.2;
|
|
||||||
margin-bottom: 10px;
|
|
||||||
}
|
|
||||||
.url {
|
|
||||||
margin-bottom: 10px;
|
|
||||||
.method {
|
|
||||||
border-radius: 10px;
|
|
||||||
padding: 1px 8px;
|
|
||||||
font-size: 10px;
|
|
||||||
transform: scale(0.8);
|
|
||||||
}
|
|
||||||
.endpoint {
|
|
||||||
font-size: 12px;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
.introduction {
|
|
||||||
font-size: 16px;
|
|
||||||
font-weight: bold;
|
|
||||||
margin-bottom: 10px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.queries {
|
.queries {
|
||||||
margin-bottom: 10px;
|
margin-bottom: 10px;
|
||||||
.title {
|
.title {
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
<template>
|
<template>
|
||||||
<div v-if="document.type === 'TEXT'" class="item" @click="onClick">
|
<div v-if="document.type === documentType.TEXT" class="item" @click="onClick">
|
||||||
<el-link type="primary" class="link" :underline="false">
|
<el-link type="primary" class="link" :underline="false">
|
||||||
<span class="name">{{ document?.title }}</span>
|
<span class="name">{{ document?.title }}</span>
|
||||||
</el-link>
|
</el-link>
|
||||||
</div>
|
</div>
|
||||||
<div v-else-if="document.type === 'API'" class="item" @click="onClick">
|
<div v-else-if="document.type === documentType.API" class="item" @click="onClick">
|
||||||
<el-link type="primary" class="link" :underline="false">
|
<el-link type="primary" class="link" :underline="false">
|
||||||
<span class="name">{{ document?.title || document?.api?.title }}</span>
|
<span class="name">{{ document?.title || document?.api?.title }}</span>
|
||||||
</el-link>
|
</el-link>
|
||||||
@@ -16,7 +16,7 @@
|
|||||||
|
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { defineComponent } from 'vue';
|
import { defineComponent } from 'vue';
|
||||||
import { IDocument } from '@/operators/document/models';
|
import { IDocument, IDocumentType } from '@/operators/document/models';
|
||||||
import { ROUTE_DOCUMENT_DETAIL } from '@/router';
|
import { ROUTE_DOCUMENT_DETAIL } from '@/router';
|
||||||
import { ElLink, ElTag } from 'element-plus';
|
import { ElLink, ElTag } from 'element-plus';
|
||||||
|
|
||||||
@@ -32,6 +32,11 @@ export default defineComponent({
|
|||||||
required: true
|
required: true
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
documentType: IDocumentType
|
||||||
|
};
|
||||||
|
},
|
||||||
methods: {
|
methods: {
|
||||||
onClick() {
|
onClick() {
|
||||||
this.$router.push({
|
this.$router.push({
|
||||||
|
|||||||
@@ -1,14 +1,14 @@
|
|||||||
<template>
|
<template>
|
||||||
<el-dialog :model-value="visible" :title="$t('application.title.buyService')" width="60%" center>
|
<el-dialog :model-value="visible" :title="$t('application.title.buyService')" width="60%" center>
|
||||||
<el-form label-width="120px">
|
<el-form label-width="120px">
|
||||||
<el-form-item v-if="application?.service?.title" :label="$t('application.field.service')">
|
<el-form-item v-if="application?.api?.title" :label="$t('application.field.service')">
|
||||||
{{ application?.service?.title }}
|
{{ application?.api?.title }}
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item :label="$t('application.field.amount')">
|
<el-form-item :label="$t('application.field.amount')">
|
||||||
<el-input-number v-model="form.amount" :min="1" :max="10000" controls-position="right" />
|
<el-input-number v-model="form.amount" :min="1" :max="10000" controls-position="right" />
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item :label="$t('service.field.price')">
|
<el-form-item :label="$t('service.field.price')">
|
||||||
<service-price :price="application?.service?.price" />
|
<service-price :price="application?.api?.price" />
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-divider />
|
<el-divider />
|
||||||
<el-form-item :label="$t('application.field.shouldPayPrice')">
|
<el-form-item :label="$t('application.field.shouldPayPrice')">
|
||||||
@@ -67,8 +67,9 @@ export default defineComponent({
|
|||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
price() {
|
price() {
|
||||||
if (this.application.service?.price && this.form.amount)
|
if (this.application.api?.price && this.form.amount) {
|
||||||
return this.form.amount * this.application.service?.price;
|
return this.form.amount * this.application.api?.price;
|
||||||
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -5,5 +5,6 @@ export default {
|
|||||||
service: '服务',
|
service: '服务',
|
||||||
operation: '操作',
|
operation: '操作',
|
||||||
amount: '数量',
|
amount: '数量',
|
||||||
shouldPayPrice: '应付金额'
|
shouldPayPrice: '应付金额',
|
||||||
|
api: 'API'
|
||||||
};
|
};
|
||||||
@@ -6,5 +6,6 @@ export default {
|
|||||||
state: '状态',
|
state: '状态',
|
||||||
createdAt: '创建时间',
|
createdAt: '创建时间',
|
||||||
service: '服务名称',
|
service: '服务名称',
|
||||||
payWay: '支付方式'
|
payWay: '支付方式',
|
||||||
|
api: 'API'
|
||||||
};
|
};
|
||||||
@@ -1,3 +1,5 @@
|
|||||||
export default {
|
export default {
|
||||||
price: '价格'
|
price: '价格',
|
||||||
|
introduction: '介绍',
|
||||||
|
apis: 'API'
|
||||||
};
|
};
|
||||||
-20
@@ -8,32 +8,12 @@ import './assets/css/tailwind.css';
|
|||||||
import dayjs from './plugins/dayjs';
|
import dayjs from './plugins/dayjs';
|
||||||
import './plugins/font-awesome';
|
import './plugins/font-awesome';
|
||||||
import { vLoading } from 'element-plus';
|
import { vLoading } from 'element-plus';
|
||||||
import * as Sentry from '@sentry/vue';
|
|
||||||
import { BrowserTracing } from '@sentry/tracing';
|
|
||||||
import { getEnv } from './utils';
|
|
||||||
|
|
||||||
console.debug('start to create app');
|
console.debug('start to create app');
|
||||||
const app = createApp(App);
|
const app = createApp(App);
|
||||||
|
|
||||||
Sentry.init({
|
|
||||||
app,
|
|
||||||
dsn: 'https://d9f92cc082b248ff9f4bea99de18483f@o191066.ingest.sentry.io/1291454',
|
|
||||||
integrations: [
|
|
||||||
new BrowserTracing({
|
|
||||||
routingInstrumentation: Sentry.vueRouterInstrumentation(router),
|
|
||||||
tracePropagationTargets: ['data.local.zhishuyun.com', 'data.test.zhishuyun.com', 'data.zhishuyun.com']
|
|
||||||
})
|
|
||||||
],
|
|
||||||
environment: getEnv(),
|
|
||||||
// Set tracesSampleRate to 1.0 to capture 100%
|
|
||||||
// of transactions for performance monitoring.
|
|
||||||
// We recommend adjusting this value in production
|
|
||||||
tracesSampleRate: 1.0
|
|
||||||
});
|
|
||||||
|
|
||||||
app.use(router);
|
app.use(router);
|
||||||
app.use(store);
|
app.use(store);
|
||||||
// app.use(ElementPlus);
|
|
||||||
app.use(i18n);
|
app.use(i18n);
|
||||||
app.use(dayjs, {
|
app.use(dayjs, {
|
||||||
formatString: 'YYYY-MM-DD HH:mm:ss'
|
formatString: 'YYYY-MM-DD HH:mm:ss'
|
||||||
|
|||||||
@@ -1,2 +1,2 @@
|
|||||||
export * from '../service/models';
|
export * from './models';
|
||||||
export * from '../service/operator';
|
export * from './operator';
|
||||||
@@ -1,3 +1,4 @@
|
|||||||
|
import { IDocument } from '../document';
|
||||||
import { IService } from '../service';
|
import { IService } from '../service';
|
||||||
|
|
||||||
export interface IForm {
|
export interface IForm {
|
||||||
@@ -47,15 +48,18 @@ export interface IApi {
|
|||||||
id: string;
|
id: string;
|
||||||
path: string;
|
path: string;
|
||||||
endpoint: string;
|
endpoint: string;
|
||||||
alias: string;
|
price?: number;
|
||||||
title?: string;
|
title?: string;
|
||||||
introduction?: string;
|
introduction?: string;
|
||||||
|
apply_count?: number;
|
||||||
|
free_count?: number;
|
||||||
tags?: string[];
|
tags?: string[];
|
||||||
request: IRequest;
|
request: IRequest;
|
||||||
request_id: string;
|
request_id: string;
|
||||||
responses: IResponse[];
|
responses: IResponse[];
|
||||||
response_ids: string[];
|
response_ids: string[];
|
||||||
is_free?: boolean;
|
document?: IDocument;
|
||||||
|
document_id?: string;
|
||||||
service?: IService;
|
service?: IService;
|
||||||
service_id?: string;
|
service_id?: string;
|
||||||
created_at?: string;
|
created_at?: string;
|
||||||
|
|||||||
@@ -1,9 +1,16 @@
|
|||||||
import { IService } from '../service';
|
import { IApi } from '../api';
|
||||||
|
|
||||||
|
export enum IApplicationType {
|
||||||
|
API = 'Api',
|
||||||
|
PROXY = 'Proxy'
|
||||||
|
}
|
||||||
|
|
||||||
export interface IApplication {
|
export interface IApplication {
|
||||||
id?: string;
|
id?: string;
|
||||||
service?: IService;
|
api?: IApi;
|
||||||
service_id?: string;
|
type?: IApplicationType;
|
||||||
|
api_id?: string;
|
||||||
|
proxy_id?: string;
|
||||||
api_key?: string;
|
api_key?: string;
|
||||||
user_id?: string;
|
user_id?: string;
|
||||||
remaining_count?: number;
|
remaining_count?: number;
|
||||||
|
|||||||
@@ -1,9 +1,14 @@
|
|||||||
import { IApi } from '../api/models';
|
import { IApi } from '../api/models';
|
||||||
|
|
||||||
|
export enum IDocumentType {
|
||||||
|
API = 'Api',
|
||||||
|
TEXT = 'Text'
|
||||||
|
}
|
||||||
|
|
||||||
export interface IDocument {
|
export interface IDocument {
|
||||||
id?: string;
|
id?: string;
|
||||||
name?: string;
|
name?: string;
|
||||||
type: 'API' | 'TEXT';
|
type: IDocumentType;
|
||||||
title?: string;
|
title?: string;
|
||||||
content?: string;
|
content?: string;
|
||||||
rank?: number;
|
rank?: number;
|
||||||
|
|||||||
@@ -3,12 +3,10 @@ import { IApi } from '../api/models';
|
|||||||
export interface IService {
|
export interface IService {
|
||||||
id: string;
|
id: string;
|
||||||
title: string;
|
title: string;
|
||||||
|
price?: number;
|
||||||
description?: string;
|
description?: string;
|
||||||
tags?: string[];
|
tags?: string[];
|
||||||
thumbnail?: string;
|
thumbnail?: string;
|
||||||
icon?: string;
|
|
||||||
price?: number;
|
|
||||||
applied_count?: number;
|
|
||||||
introduction?: string;
|
introduction?: string;
|
||||||
api_ids?: string[];
|
api_ids?: string[];
|
||||||
apis?: IApi[];
|
apis?: IApi[];
|
||||||
|
|||||||
@@ -10,9 +10,9 @@
|
|||||||
<el-col :span="24">
|
<el-col :span="24">
|
||||||
<el-card shadow="hover">
|
<el-card shadow="hover">
|
||||||
<el-table v-loading="loading" :data="applications" stripe>
|
<el-table v-loading="loading" :data="applications" stripe>
|
||||||
<el-table-column :label="$t('application.field.service')" width="200px">
|
<el-table-column :label="$t('application.field.api')" width="200px">
|
||||||
<template #default="scope">
|
<template #default="scope">
|
||||||
<span>{{ scope.row?.service?.title }}</span>
|
<span>{{ scope.row?.api?.title }}</span>
|
||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
<el-table-column
|
<el-table-column
|
||||||
@@ -38,7 +38,7 @@
|
|||||||
<el-table-column>
|
<el-table-column>
|
||||||
<template #default="scope">
|
<template #default="scope">
|
||||||
<div class="float-right">
|
<div class="float-right">
|
||||||
<el-button v-if="false" @click="onGoDocument(scope?.row)">
|
<el-button v-if="scope.row?.api?.document_id" @click="onGoDocument(scope?.row)">
|
||||||
{{ $t('application.button.goDocument') }}
|
{{ $t('application.button.goDocument') }}
|
||||||
</el-button>
|
</el-button>
|
||||||
<el-button type="primary" @click="onBuyMore(scope?.row)">
|
<el-button type="primary" @click="onBuyMore(scope?.row)">
|
||||||
@@ -70,6 +70,7 @@ import Pagination from '@/components/common/Pagination.vue';
|
|||||||
import CopyToClipboard from '@/components/common/CopyToClipboard.vue';
|
import CopyToClipboard from '@/components/common/CopyToClipboard.vue';
|
||||||
import CreateOrder from '@/components/order/Create.vue';
|
import CreateOrder from '@/components/order/Create.vue';
|
||||||
import { ElTable, ElRow, ElCol, ElTableColumn, ElButton, ElCard } from 'element-plus';
|
import { ElTable, ElRow, ElCol, ElTableColumn, ElButton, ElCard } from 'element-plus';
|
||||||
|
import { ROUTE_DOCUMENT_DETAIL } from '@/router/constants';
|
||||||
|
|
||||||
interface IData {
|
interface IData {
|
||||||
applications: IApplication[];
|
applications: IApplication[];
|
||||||
@@ -134,7 +135,15 @@ export default defineComponent({
|
|||||||
this.onFetchData();
|
this.onFetchData();
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
onGoDocument(application: IApplication) {},
|
onGoDocument(application: IApplication) {
|
||||||
|
const documentId = application?.api?.document_id;
|
||||||
|
this.$router.push({
|
||||||
|
name: ROUTE_DOCUMENT_DETAIL,
|
||||||
|
params: {
|
||||||
|
id: documentId
|
||||||
|
}
|
||||||
|
});
|
||||||
|
},
|
||||||
onBuyMore(application: IApplication) {
|
onBuyMore(application: IApplication) {
|
||||||
this.active.application = application;
|
this.active.application = application;
|
||||||
this.buying = true;
|
this.buying = true;
|
||||||
|
|||||||
@@ -20,8 +20,8 @@
|
|||||||
<el-descriptions-item :label="$t('order.field.description')">
|
<el-descriptions-item :label="$t('order.field.description')">
|
||||||
{{ order?.description }}
|
{{ order?.description }}
|
||||||
</el-descriptions-item>
|
</el-descriptions-item>
|
||||||
<el-descriptions-item :label="$t('order.field.service')">
|
<el-descriptions-item :label="$t('order.field.api')">
|
||||||
{{ order?.application?.service?.title }}
|
{{ order?.application?.api?.title }}
|
||||||
</el-descriptions-item>
|
</el-descriptions-item>
|
||||||
<el-descriptions-item :label="$t('order.field.amount')">
|
<el-descriptions-item :label="$t('order.field.amount')">
|
||||||
{{ order?.amount }}
|
{{ order?.amount }}
|
||||||
@@ -56,7 +56,7 @@
|
|||||||
<el-row v-if="order?.state === OrderState.PENDING || order?.state === OrderState.FAILED">
|
<el-row v-if="order?.state === OrderState.PENDING || order?.state === OrderState.FAILED">
|
||||||
<el-col :span="12" :offset="6">
|
<el-col :span="12" :offset="6">
|
||||||
<el-divider border-style="dashed" />
|
<el-divider border-style="dashed" />
|
||||||
<div v-if="order.price && order.price > 0 && order.pay_way === undefined" class="payways mb-4">
|
<div v-if="order.price && order.price > 0 && !order.pay_way" class="payways mb-4">
|
||||||
<div
|
<div
|
||||||
:class="{
|
:class="{
|
||||||
payway: true,
|
payway: true,
|
||||||
|
|||||||
@@ -1,13 +1,13 @@
|
|||||||
<template>
|
<template>
|
||||||
<div v-if="document" class="center">
|
<div v-if="document" class="center">
|
||||||
<div v-if="document.type === 'TEXT'">
|
<div v-if="document.type === documentType.TEXT">
|
||||||
<markdown-renderer :content="document?.content" :loading="loading" />
|
<markdown-renderer :content="document?.content" :loading="loading" />
|
||||||
</div>
|
</div>
|
||||||
<div v-else-if="document.type === 'API'">
|
<div v-else-if="document.type === documentType.API">
|
||||||
<api-usage v-if="document.api" v-model:form="form" :loading="loading" :api="document.api" />
|
<api-usage v-if="document.api" v-model:form="form" :loading="loading" :api="document.api" />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div v-if="document?.type === 'API' && document?.api" class="right">
|
<div v-if="document?.type === documentType.API && document?.api" class="right">
|
||||||
<div v-if="loading" class="p-5">
|
<div v-if="loading" class="p-5">
|
||||||
<el-skeleton />
|
<el-skeleton />
|
||||||
</div>
|
</div>
|
||||||
@@ -23,7 +23,7 @@ import { defineComponent } from 'vue';
|
|||||||
import ApiUsage from '@/components/api/Usage.vue';
|
import ApiUsage from '@/components/api/Usage.vue';
|
||||||
import ApiTry from '@/components/api/Try.vue';
|
import ApiTry from '@/components/api/Try.vue';
|
||||||
import ApiCode from '@/components/api/Code.vue';
|
import ApiCode from '@/components/api/Code.vue';
|
||||||
import { documentOperator, IDocument, IDocumentDetailResponse } from '@/operators';
|
import { documentOperator, IDocument, IDocumentDetailResponse, IDocumentType } from '@/operators';
|
||||||
import { IForm } from '@/operators/api/models';
|
import { IForm } from '@/operators/api/models';
|
||||||
import MarkdownRenderer from '@/components/common/MarkdownRenderer.vue';
|
import MarkdownRenderer from '@/components/common/MarkdownRenderer.vue';
|
||||||
import { ElSkeleton } from 'element-plus';
|
import { ElSkeleton } from 'element-plus';
|
||||||
@@ -32,6 +32,7 @@ export interface IData {
|
|||||||
document: IDocument | undefined;
|
document: IDocument | undefined;
|
||||||
loading: boolean;
|
loading: boolean;
|
||||||
form: IForm;
|
form: IForm;
|
||||||
|
documentType: typeof IDocumentType;
|
||||||
}
|
}
|
||||||
|
|
||||||
export default defineComponent({
|
export default defineComponent({
|
||||||
@@ -47,7 +48,8 @@ export default defineComponent({
|
|||||||
return {
|
return {
|
||||||
document: undefined,
|
document: undefined,
|
||||||
loading: false,
|
loading: false,
|
||||||
form: {}
|
form: {},
|
||||||
|
documentType: IDocumentType
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
|
|||||||
@@ -20,7 +20,7 @@
|
|||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
<div class="operations">
|
<div class="operations">
|
||||||
<el-button type="danger" class="btn-apply" @click="onApply">
|
<el-button type="danger" class="btn-apply" @click="onToApis">
|
||||||
{{ $t('service.button.apply') }}
|
{{ $t('service.button.apply') }}
|
||||||
</el-button>
|
</el-button>
|
||||||
</div>
|
</div>
|
||||||
@@ -34,14 +34,32 @@
|
|||||||
</el-row>
|
</el-row>
|
||||||
</el-col>
|
</el-col>
|
||||||
</el-row>
|
</el-row>
|
||||||
|
<el-row v-if="service && service.introduction" class="introduction">
|
||||||
<el-row v-if="service" class="detail">
|
|
||||||
<el-col :span="20" :offset="2">
|
<el-col :span="20" :offset="2">
|
||||||
<el-card shadow="hover">
|
<el-card shadow="hover" :body-style="{ padding: '50px' }">
|
||||||
<markdown-renderer :content="service?.introduction" />
|
<markdown-renderer :content="service?.introduction" />
|
||||||
</el-card>
|
</el-card>
|
||||||
</el-col>
|
</el-col>
|
||||||
</el-row>
|
</el-row>
|
||||||
|
<el-row v-if="service" id="apis" class="apis">
|
||||||
|
<el-col :span="20" :offset="2">
|
||||||
|
<el-card shadow="hover" :body-style="{ padding: '50px' }">
|
||||||
|
<div v-for="(api, apiIndex) in apis" :key="apiIndex">
|
||||||
|
<el-row>
|
||||||
|
<el-col :span="20">
|
||||||
|
<api-info :api="api" />
|
||||||
|
</el-col>
|
||||||
|
<el-col :span="4" class="operations">
|
||||||
|
<el-button type="primary" @click="onApply(api.id, applicationType.API)">
|
||||||
|
{{ $t('common.button.apply') }}
|
||||||
|
</el-button>
|
||||||
|
</el-col>
|
||||||
|
</el-row>
|
||||||
|
<el-divider v-if="apiIndex < apis.length - 1" />
|
||||||
|
</div>
|
||||||
|
</el-card>
|
||||||
|
</el-col>
|
||||||
|
</el-row>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
@@ -58,9 +76,11 @@ import { ERROR_CODE_DUPLICATION } from '@/constants';
|
|||||||
import { ElMessage } from 'element-plus';
|
import { ElMessage } from 'element-plus';
|
||||||
import { apiOperator } from '@/operators/api/operator';
|
import { apiOperator } from '@/operators/api/operator';
|
||||||
import { IApi, IApiListResponse } from '@/operators/api/models';
|
import { IApi, IApiListResponse } from '@/operators/api/models';
|
||||||
|
import { IApplicationType } from '@/operators/application/models';
|
||||||
import MarkdownRenderer from '@/components/common/MarkdownRenderer.vue';
|
import MarkdownRenderer from '@/components/common/MarkdownRenderer.vue';
|
||||||
import { ROUTE_CONSOLE_APPLICATION_LIST } from '@/router';
|
import { ROUTE_CONSOLE_APPLICATION_LIST } from '@/router';
|
||||||
import { ElCol, ElRow, ElButton, ElCard } from 'element-plus';
|
import { ElCol, ElRow, ElButton, ElCard, ElDivider } from 'element-plus';
|
||||||
|
import ApiInfo from '@/components/api/Info.vue';
|
||||||
|
|
||||||
interface IData {
|
interface IData {
|
||||||
service: IService | undefined;
|
service: IService | undefined;
|
||||||
@@ -68,6 +88,7 @@ interface IData {
|
|||||||
application: IApplication | undefined;
|
application: IApplication | undefined;
|
||||||
loading: boolean;
|
loading: boolean;
|
||||||
activeTab: string;
|
activeTab: string;
|
||||||
|
applicationType: typeof IApplicationType;
|
||||||
}
|
}
|
||||||
|
|
||||||
export default defineComponent({
|
export default defineComponent({
|
||||||
@@ -77,7 +98,9 @@ export default defineComponent({
|
|||||||
ElCol,
|
ElCol,
|
||||||
ElRow,
|
ElRow,
|
||||||
ElButton,
|
ElButton,
|
||||||
ElCard
|
ElCard,
|
||||||
|
ElDivider,
|
||||||
|
ApiInfo
|
||||||
},
|
},
|
||||||
data(): IData {
|
data(): IData {
|
||||||
return {
|
return {
|
||||||
@@ -85,7 +108,8 @@ export default defineComponent({
|
|||||||
apis: [],
|
apis: [],
|
||||||
application: undefined,
|
application: undefined,
|
||||||
loading: false,
|
loading: false,
|
||||||
activeTab: 'introduction'
|
activeTab: 'introduction',
|
||||||
|
applicationType: IApplicationType
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
@@ -111,10 +135,27 @@ export default defineComponent({
|
|||||||
this.apis = data.items;
|
this.apis = data.items;
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
onApply() {
|
onToApis() {
|
||||||
|
window.scrollTo({
|
||||||
|
top: document.getElementById('apis')?.offsetTop,
|
||||||
|
left: 0,
|
||||||
|
behavior: 'smooth'
|
||||||
|
});
|
||||||
|
},
|
||||||
|
onApply(id: string, type: IApplicationType) {
|
||||||
applicationOperator
|
applicationOperator
|
||||||
.create({
|
.create({
|
||||||
service_id: this.id
|
type,
|
||||||
|
...(type === IApplicationType.API
|
||||||
|
? {
|
||||||
|
api_id: id
|
||||||
|
}
|
||||||
|
: {}),
|
||||||
|
...(type === IApplicationType.PROXY
|
||||||
|
? {
|
||||||
|
proxy_id: id
|
||||||
|
}
|
||||||
|
: {})
|
||||||
})
|
})
|
||||||
.then(({ data: data }: { data: IApplicationDetailResponse }) => {
|
.then(({ data: data }: { data: IApplicationDetailResponse }) => {
|
||||||
this.application = data;
|
this.application = data;
|
||||||
@@ -324,13 +365,16 @@ export default defineComponent({
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.detail {
|
.introduction {
|
||||||
font-size: 14px;
|
margin-bottom: 20px;
|
||||||
margin-bottom: 30px;
|
}
|
||||||
.introduction {
|
|
||||||
padding: 10px 0;
|
.apis {
|
||||||
color: #999;
|
margin-bottom: 40px;
|
||||||
font-weight: 400;
|
.operations {
|
||||||
|
align-items: center;
|
||||||
|
justify-items: center;
|
||||||
|
display: flex;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
@@ -223,6 +223,14 @@ export default defineComponent({
|
|||||||
}
|
}
|
||||||
|
|
||||||
$transition-duration: 0.5s;
|
$transition-duration: 0.5s;
|
||||||
|
|
||||||
|
@media (min-width: 1400px) {
|
||||||
|
.services {
|
||||||
|
width: 1300px;
|
||||||
|
margin: auto !important;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
.services {
|
.services {
|
||||||
padding: 50px 0;
|
padding: 50px 0;
|
||||||
.service {
|
.service {
|
||||||
|
|||||||
+1
-1
@@ -20,7 +20,7 @@ const getAuthEndpoint = () => {
|
|||||||
const getDataEndpoint = () => {
|
const getDataEndpoint = () => {
|
||||||
switch (process.env.NODE_ENV) {
|
switch (process.env.NODE_ENV) {
|
||||||
case 'local':
|
case 'local':
|
||||||
return 'http://localhost:8007';
|
return 'http://127.0.0.1:8007';
|
||||||
case 'test':
|
case 'test':
|
||||||
return 'https://data.test.zhishuyun.com';
|
return 'https://data.test.zhishuyun.com';
|
||||||
case 'production':
|
case 'production':
|
||||||
|
|||||||
Reference in new issue
Block a user