fix loading and apply issue
This commit is contained in:
1 parent
b55ace7c8e
commit
64678264bb
14 files changed
+104
-62
No files matched your search
@@ -187,7 +187,7 @@ export default defineComponent({
|
||||
<style lang="scss" scoped>
|
||||
.wrapper {
|
||||
width: 100%;
|
||||
padding: 15px;
|
||||
// padding: 15px;
|
||||
padding-bottom: 0;
|
||||
overflow-x: scroll;
|
||||
.options {
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
<code-snippet :code="responseData" />
|
||||
</div>
|
||||
<div v-if="loading">
|
||||
<el-skeleton />
|
||||
<el-skeleton animated />
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
@@ -1,10 +1,5 @@
|
||||
<template>
|
||||
<div v-if="loading">
|
||||
<el-skeleton />
|
||||
<el-divider />
|
||||
<el-skeleton />
|
||||
</div>
|
||||
<div v-else class="item">
|
||||
<div class="item">
|
||||
<api-info v-if="api" :api="api" />
|
||||
<el-divider />
|
||||
<div class="queries">
|
||||
@@ -44,7 +39,7 @@ import ApiForm from './Form.vue';
|
||||
import ApiResult from './Result.vue';
|
||||
import { applicationOperator } from '@/operators/application/operator';
|
||||
import { IApplication, IApplicationListResponse } from '@/operators/application/models';
|
||||
import { ElSkeleton, ElDivider, ElTag } from 'element-plus';
|
||||
import { ElDivider } from 'element-plus';
|
||||
import ApiInfo from './Info.vue';
|
||||
|
||||
export interface IData {
|
||||
@@ -57,7 +52,6 @@ export default defineComponent({
|
||||
components: {
|
||||
ApiForm,
|
||||
ApiResult,
|
||||
ElSkeleton,
|
||||
ElDivider,
|
||||
ApiInfo
|
||||
},
|
||||
@@ -66,10 +60,6 @@ export default defineComponent({
|
||||
type: Object as () => IApi,
|
||||
required: true
|
||||
},
|
||||
loading: {
|
||||
type: Boolean,
|
||||
required: true
|
||||
},
|
||||
form: {
|
||||
type: Object as () => IForm,
|
||||
required: true
|
||||
|
||||
@@ -1,34 +1,21 @@
|
||||
<template>
|
||||
<div v-if="loading">
|
||||
<el-skeleton />
|
||||
<el-divider />
|
||||
<el-skeleton />
|
||||
</div>
|
||||
<vue-markdown v-else :source="content" class="markdown-body" />
|
||||
<vue-markdown :source="content" class="markdown-body" />
|
||||
</template>
|
||||
|
||||
<script lang="ts">
|
||||
import { defineComponent } from 'vue';
|
||||
import VueMarkdown from './VueMarkdown.vue';
|
||||
import { ElDivider, ElSkeleton } from 'element-plus';
|
||||
|
||||
export default defineComponent({
|
||||
name: 'ApiCode',
|
||||
components: {
|
||||
VueMarkdown,
|
||||
ElDivider,
|
||||
ElSkeleton
|
||||
VueMarkdown
|
||||
},
|
||||
props: {
|
||||
content: {
|
||||
type: String,
|
||||
required: false,
|
||||
default: ''
|
||||
},
|
||||
loading: {
|
||||
type: Boolean,
|
||||
required: false,
|
||||
default: false
|
||||
}
|
||||
},
|
||||
data() {},
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<template>
|
||||
<div v-if="loading">
|
||||
<el-skeleton />
|
||||
<el-skeleton animated />
|
||||
</div>
|
||||
<div v-else-if="documents" class="wrapper">
|
||||
<document-list-item
|
||||
@@ -64,9 +64,3 @@ export default defineComponent({
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.wrapper {
|
||||
padding: 20px 0;
|
||||
}
|
||||
</style>
|
||||
@@ -1,10 +1,14 @@
|
||||
<template>
|
||||
<div v-if="document.type === documentType.TEXT" class="item" @click="onClick">
|
||||
<div v-if="document.type === documentType.TEXT" :class="{ item: true, active: id === document?.id }" @click="onClick">
|
||||
<el-link type="primary" class="link" :underline="false">
|
||||
<span class="name">{{ document?.title }}</span>
|
||||
</el-link>
|
||||
</div>
|
||||
<div v-else-if="document.type === documentType.API" class="item" @click="onClick">
|
||||
<div
|
||||
v-else-if="document.type === documentType.API"
|
||||
:class="{ item: true, active: id === document?.id }"
|
||||
@click="onClick"
|
||||
>
|
||||
<el-link type="primary" class="link" :underline="false">
|
||||
<span class="name">{{ document?.title || document?.api?.title }}</span>
|
||||
</el-link>
|
||||
@@ -37,6 +41,11 @@ export default defineComponent({
|
||||
documentType: IDocumentType
|
||||
};
|
||||
},
|
||||
computed: {
|
||||
id() {
|
||||
return this.$route.params?.id?.toString();
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
onClick() {
|
||||
this.$router.push({
|
||||
@@ -55,16 +64,23 @@ $height: 35px;
|
||||
.item {
|
||||
height: $height;
|
||||
line-height: $height;
|
||||
padding-left: 5px;
|
||||
padding-left: 10px;
|
||||
cursor: pointer;
|
||||
border-radius: 5px;
|
||||
border-top-left-radius: 0;
|
||||
border-bottom-left-radius: 0;
|
||||
overflow: hidden;
|
||||
position: relative;
|
||||
border-left: 3px solid transparent;
|
||||
|
||||
&:hover {
|
||||
background-color: rgba(0, 0, 0, 0.1);
|
||||
}
|
||||
|
||||
&.active {
|
||||
border-left: 3px solid var(--el-color-primary);
|
||||
}
|
||||
|
||||
.link {
|
||||
color: #333;
|
||||
.name {
|
||||
|
||||
@@ -21,5 +21,6 @@ export default {
|
||||
apply: '申请',
|
||||
refresh: '刷新',
|
||||
pay: '支付',
|
||||
repay: '继续支付'
|
||||
repay: '继续支付',
|
||||
applied: '已申请'
|
||||
};
|
||||
@@ -55,6 +55,7 @@ export default {
|
||||
float: left;
|
||||
width: 280px;
|
||||
height: 100%;
|
||||
padding: 30px;
|
||||
box-shadow: 1px 0 0 #eee;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -53,6 +53,7 @@ export interface IApi {
|
||||
introduction?: string;
|
||||
apply_count?: number;
|
||||
free_count?: number;
|
||||
applied?: boolean;
|
||||
tags?: string[];
|
||||
request: IRequest;
|
||||
request_id: string;
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
<el-row>
|
||||
<el-col :span="12" :offset="6">
|
||||
<div v-if="loading" class="pt-5">
|
||||
<el-skeleton />
|
||||
<el-skeleton animated />
|
||||
</div>
|
||||
<div v-else class="order">
|
||||
<el-descriptions :column="1">
|
||||
|
||||
@@ -1,21 +1,33 @@
|
||||
<template>
|
||||
<div v-if="document" class="center">
|
||||
<div v-if="document.type === documentType.TEXT">
|
||||
<markdown-renderer :content="document?.content" :loading="loading" />
|
||||
<!-- center part -->
|
||||
<div class="center">
|
||||
<div v-if="loading">
|
||||
<el-skeleton animated />
|
||||
</div>
|
||||
<div v-else-if="document.type === documentType.API">
|
||||
<api-usage v-if="document.api" v-model:form="form" :loading="loading" :api="document.api" />
|
||||
<div v-else-if="document">
|
||||
<div v-if="document.type === documentType.TEXT">
|
||||
<markdown-renderer :content="document?.content" />
|
||||
</div>
|
||||
<div v-else-if="document.type === documentType.API">
|
||||
<api-usage v-if="document.api" v-model:form="form" :api="document.api" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div v-if="document?.type === documentType.API && document?.api" class="right">
|
||||
<div v-if="loading" class="p-5">
|
||||
<!-- end center part -->
|
||||
<!-- right part -->
|
||||
<div class="right">
|
||||
<div v-if="loading">
|
||||
<el-skeleton />
|
||||
</div>
|
||||
<div v-else>
|
||||
<api-code :form="form" :api="document?.api" />
|
||||
<api-try :form="form" :api="document?.api" />
|
||||
<div v-else-if="document">
|
||||
<div v-if="document?.type === documentType.API && document?.api">
|
||||
<api-code :form="form" :api="document?.api" />
|
||||
<api-try :form="form" :api="document?.api" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- end right part -->
|
||||
</template>
|
||||
|
||||
<script lang="ts">
|
||||
@@ -101,6 +113,7 @@ export default defineComponent({
|
||||
float: left;
|
||||
width: 480px;
|
||||
height: 100%;
|
||||
padding: 30px;
|
||||
box-shadow: -1px 0 0 #eee;
|
||||
}
|
||||
</style>
|
||||
@@ -1,8 +1,8 @@
|
||||
<template>
|
||||
<div class="center">
|
||||
<el-skeleton />
|
||||
<el-skeleton animated />
|
||||
<el-divider />
|
||||
<el-skeleton />
|
||||
<el-skeleton animated />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
|
||||
@@ -1,9 +1,19 @@
|
||||
<template>
|
||||
<el-row v-if="service" class="banner">
|
||||
<el-row class="banner">
|
||||
<el-col :span="24">
|
||||
<el-row>
|
||||
<el-col :span="10" :offset="2" class="left">
|
||||
<div class="info">
|
||||
<div v-if="loading" class="info">
|
||||
<el-skeleton animated>
|
||||
<template #template>
|
||||
<el-skeleton-item variant="p" class="title-placeholder" />
|
||||
<el-skeleton-item variant="p" class="description-placeholder" />
|
||||
<el-skeleton-item variant="p" class="price-placeholder" />
|
||||
<el-skeleton-item variant="p" class="operations-placeholder" />
|
||||
</template>
|
||||
</el-skeleton>
|
||||
</div>
|
||||
<div v-if="service" class="info">
|
||||
<h1>
|
||||
{{ service.title }}
|
||||
</h1>
|
||||
@@ -50,9 +60,12 @@
|
||||
<api-info :api="api" />
|
||||
</el-col>
|
||||
<el-col :span="4" class="operations">
|
||||
<el-button type="primary" @click="onApply(api.id, applicationType.API)">
|
||||
<el-button v-if="!api.applied" type="primary" @click="onApply(api, applicationType.API)">
|
||||
{{ $t('common.button.apply') }}
|
||||
</el-button>
|
||||
<el-button v-else disabled type="primary">
|
||||
{{ $t('common.button.applied') }}
|
||||
</el-button>
|
||||
</el-col>
|
||||
</el-row>
|
||||
<el-divider v-if="apiIndex < apis.length - 1" />
|
||||
@@ -79,7 +92,7 @@ import { IApi, IApiListResponse } from '@/operators/api/models';
|
||||
import { IApplicationType } from '@/operators/application/models';
|
||||
import MarkdownRenderer from '@/components/common/MarkdownRenderer.vue';
|
||||
import { ROUTE_CONSOLE_APPLICATION_LIST } from '@/router';
|
||||
import { ElCol, ElRow, ElButton, ElCard, ElDivider } from 'element-plus';
|
||||
import { ElCol, ElRow, ElButton, ElCard, ElDivider, ElSkeleton, ElSkeletonItem } from 'element-plus';
|
||||
import ApiInfo from '@/components/api/Info.vue';
|
||||
|
||||
interface IData {
|
||||
@@ -100,7 +113,9 @@ export default defineComponent({
|
||||
ElButton,
|
||||
ElCard,
|
||||
ElDivider,
|
||||
ApiInfo
|
||||
ApiInfo,
|
||||
ElSkeleton,
|
||||
ElSkeletonItem
|
||||
},
|
||||
data(): IData {
|
||||
return {
|
||||
@@ -142,23 +157,24 @@ export default defineComponent({
|
||||
behavior: 'smooth'
|
||||
});
|
||||
},
|
||||
onApply(id: string, type: IApplicationType) {
|
||||
onApply(obj: IApi, type: IApplicationType) {
|
||||
applicationOperator
|
||||
.create({
|
||||
type,
|
||||
...(type === IApplicationType.API
|
||||
? {
|
||||
api_id: id
|
||||
api_id: obj.id
|
||||
}
|
||||
: {}),
|
||||
...(type === IApplicationType.PROXY
|
||||
? {
|
||||
proxy_id: id
|
||||
proxy_id: obj.id
|
||||
}
|
||||
: {})
|
||||
})
|
||||
.then(({ data: data }: { data: IApplicationDetailResponse }) => {
|
||||
this.application = data;
|
||||
obj.applied = true;
|
||||
ElMessage.success(this.$t('application.message.applySuccessfully'));
|
||||
setTimeout(() => {
|
||||
this.$router.push({
|
||||
@@ -200,12 +216,35 @@ export default defineComponent({
|
||||
position: relative;
|
||||
height: $height;
|
||||
min-height: $min-height;
|
||||
|
||||
.info {
|
||||
position: absolute;
|
||||
left: 0;
|
||||
width: 100%;
|
||||
top: 50%;
|
||||
transform: translateY(-50%);
|
||||
.title-placeholder {
|
||||
height: 64px;
|
||||
width: 200px;
|
||||
margin-bottom: 24px;
|
||||
}
|
||||
|
||||
.description-placeholder {
|
||||
height: 50px;
|
||||
margin-bottom: 56px;
|
||||
}
|
||||
|
||||
.price-placeholder {
|
||||
height: 32px;
|
||||
margin-bottom: 56px;
|
||||
}
|
||||
|
||||
.operations-placeholder {
|
||||
height: 52px;
|
||||
margin-bottom: 40px;
|
||||
visibility: hidden;
|
||||
}
|
||||
|
||||
h1 {
|
||||
max-width: 1064px;
|
||||
margin-bottom: 24px;
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
<el-row v-if="loading" :gutter="15" class="services">
|
||||
<el-col v-for="_ in 8" :key="_" :lg="6" :md="8" :sm="12" :xs="24">
|
||||
<el-card shadow="hover" class="service">
|
||||
<el-skeleton>
|
||||
<el-skeleton animated>
|
||||
<template #template>
|
||||
<el-skeleton-item variant="image" class="icon-placeholder" />
|
||||
<el-skeleton-item variant="p" class="title-placeholder" />
|
||||
|
||||
Reference in new issue
Block a user