remove unused
This commit is contained in:
1 parent
301dab1ca5
commit
ea1c3413a5
88 files changed
+29
-5766
No files matched your search
Binary file not shown.
|
Before Width: | Height: | Size: 97 KiB |
@@ -1,17 +0,0 @@
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
{{#body}}
|
||||
jsonObject.put("{{{key}}}", {{{value}}});
|
||||
{{/body}}
|
||||
MediaType mediaType = "application/json; charset=utf-8".toMediaType();
|
||||
RequestBody body = jsonObject.toString().toRequestBody(mediaType);
|
||||
Request request = new Request.Builder()
|
||||
.url("{{{url}}}")
|
||||
.{{{method}}}(body)
|
||||
{{#headers}}
|
||||
.addHeader("{{{key}}}", {{{value}}})
|
||||
{{/headers}}
|
||||
.build();
|
||||
|
||||
OkHttpClient client = new OkHttpClient();
|
||||
Response response = client.newCall(request).execute();
|
||||
System.out.print(response.body!!.string())
|
||||
@@ -1,18 +0,0 @@
|
||||
const options = {
|
||||
method: '{{{method}}}',
|
||||
headers: {
|
||||
{{#headers}}
|
||||
'{{{key}}}': {{{value}}}{{^last}},{{/last}}
|
||||
{{/headers}}
|
||||
},
|
||||
body: JSON.stringify({
|
||||
{{#body}}
|
||||
'{{{key}}}': {{{value}}}{{^last}},{{/last}}
|
||||
{{/body}}
|
||||
})
|
||||
};
|
||||
|
||||
fetch('{{{url}}}', options)
|
||||
.then(response => response.json())
|
||||
.then(response => console.log(response))
|
||||
.catch(err => console.error(err));
|
||||
@@ -1,19 +0,0 @@
|
||||
<?php
|
||||
require_once('vendor/autoload.php');
|
||||
|
||||
$client = new \GuzzleHttp\Client();
|
||||
|
||||
$response = $client->request('{{{method}}}', '{{{url}}}', [
|
||||
'body' => '{
|
||||
{{#body}}
|
||||
"{{{key}}}": {{{value}}}{{^last}},{{/last}}
|
||||
{{/body}}
|
||||
}',
|
||||
'headers' => [
|
||||
{{#headers}}
|
||||
'{{{key}}}': {{{value}}}{{^last}},{{/last}}
|
||||
{{/headers}}
|
||||
],
|
||||
]);
|
||||
|
||||
echo $response->getBody();
|
||||
@@ -1,18 +0,0 @@
|
||||
import requests
|
||||
|
||||
url = '{{{url}}}'
|
||||
|
||||
headers = {
|
||||
{{#headers}}
|
||||
'{{{key}}}': {{{value}}}{{^last}},{{/last}}
|
||||
{{/headers}}
|
||||
}
|
||||
|
||||
payload = {
|
||||
{{#body}}
|
||||
'{{{key}}}': {{{value}}}{{^last}},{{/last}}
|
||||
{{/body}}
|
||||
}
|
||||
|
||||
response = requests.{{{method}}}(url, json=payload, headers=headers)
|
||||
print(response.text)
|
||||
@@ -1,272 +0,0 @@
|
||||
<template>
|
||||
<div class="wrapper">
|
||||
<div class="options mb-2">
|
||||
<div
|
||||
v-for="(option, optionKey) in options"
|
||||
:key="optionKey"
|
||||
:class="{
|
||||
option: true,
|
||||
active: lang === option.name
|
||||
}"
|
||||
@click="lang = option.name"
|
||||
>
|
||||
<el-image :src="option.icon" class="icon" />
|
||||
<p class="name">{{ option.name }}</p>
|
||||
</div>
|
||||
</div>
|
||||
<div v-if="code" class="code">
|
||||
<code-snippet :code="code" :lang="lang" />
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script lang="ts">
|
||||
import { defineComponent } from 'vue';
|
||||
import javascript from 'programming-languages-logos/src/javascript/javascript.svg';
|
||||
import python from 'programming-languages-logos/src/python/python.svg';
|
||||
import java from 'programming-languages-logos/src/java/java.svg';
|
||||
import php from 'programming-languages-logos/src/php/php.svg';
|
||||
import { IApi, IForm, IRequest } from '@/operators/api/models';
|
||||
import urlJoin from 'url-join';
|
||||
import Mustache from 'mustache';
|
||||
import pythonTemplate from '@/assets/templates/python.tpl';
|
||||
import javascriptTemplate from '@/assets/templates/javascript.tpl';
|
||||
import phpTemplate from '@/assets/templates/php.tpl';
|
||||
import javaTemplate from '@/assets/templates/java.tpl';
|
||||
import CodeSnippet from '../common/CodeSnippet.vue';
|
||||
import queryString from 'query-string';
|
||||
import { ElImage } from 'element-plus';
|
||||
|
||||
interface IOption {
|
||||
name: ILang;
|
||||
icon: string;
|
||||
}
|
||||
|
||||
const LANG_PYTHON = 'Python';
|
||||
const LANG_JAVA = 'Java';
|
||||
const LANG_JAVASCRIPT = 'JavaScript';
|
||||
const LANG_PHP = 'PHP';
|
||||
|
||||
type ILang = typeof LANG_PYTHON | typeof LANG_JAVA | typeof LANG_JAVASCRIPT | typeof LANG_PHP;
|
||||
|
||||
interface IData {
|
||||
lang: ILang | undefined;
|
||||
options: IOption[];
|
||||
}
|
||||
|
||||
interface IRenderData {
|
||||
headers: {
|
||||
key: string;
|
||||
value: string;
|
||||
}[];
|
||||
body: {
|
||||
key: string;
|
||||
value: string | object | number | object[] | boolean;
|
||||
}[];
|
||||
method: IRequest['method'] | Lowercase<IRequest['method']> | Uppercase<IRequest['method']>;
|
||||
url: string;
|
||||
}
|
||||
|
||||
export default defineComponent({
|
||||
name: 'ApiCode',
|
||||
components: {
|
||||
CodeSnippet,
|
||||
ElImage
|
||||
},
|
||||
props: {
|
||||
api: {
|
||||
type: Object as () => IApi,
|
||||
required: true
|
||||
},
|
||||
form: {
|
||||
type: Object as () => IForm,
|
||||
required: true
|
||||
}
|
||||
},
|
||||
data(): IData {
|
||||
return {
|
||||
lang: undefined,
|
||||
options: [
|
||||
{
|
||||
name: LANG_PYTHON,
|
||||
icon: python
|
||||
},
|
||||
{
|
||||
name: LANG_JAVASCRIPT,
|
||||
icon: javascript
|
||||
},
|
||||
{
|
||||
name: LANG_JAVA,
|
||||
icon: java
|
||||
},
|
||||
{
|
||||
name: LANG_PHP,
|
||||
icon: php
|
||||
}
|
||||
]
|
||||
};
|
||||
},
|
||||
computed: {
|
||||
method() {
|
||||
return this.api.request.method;
|
||||
},
|
||||
url() {
|
||||
const getQueryString = () => {
|
||||
if (this.form.queries) {
|
||||
return `?${queryString.stringify(this.form?.queries)}`;
|
||||
}
|
||||
return '';
|
||||
};
|
||||
return urlJoin(this.api?.endpoint, this.api?.path, getQueryString());
|
||||
},
|
||||
headers() {
|
||||
let result = [];
|
||||
for (const key in this.form.headers) {
|
||||
result.push({
|
||||
key,
|
||||
value: this.form.headers[key]
|
||||
});
|
||||
}
|
||||
if (result.length > 0) {
|
||||
const last = result[result.length - 1];
|
||||
result[result.length - 1] = {
|
||||
...last,
|
||||
last: true
|
||||
};
|
||||
}
|
||||
return result;
|
||||
},
|
||||
body() {
|
||||
let result = [];
|
||||
for (const key in this.form.body) {
|
||||
const value = this.form.body[key];
|
||||
result.push({
|
||||
key,
|
||||
value
|
||||
});
|
||||
}
|
||||
if (result.length > 0) {
|
||||
const last = result[result.length - 1];
|
||||
result[result.length - 1] = {
|
||||
...last,
|
||||
last: true
|
||||
};
|
||||
}
|
||||
return result;
|
||||
},
|
||||
code(): string | undefined {
|
||||
let template = undefined;
|
||||
let renderData: IRenderData = JSON.parse(
|
||||
JSON.stringify({
|
||||
headers: this.headers,
|
||||
body: this.body,
|
||||
url: this.url,
|
||||
method: this.method
|
||||
})
|
||||
);
|
||||
if (this.lang === LANG_PYTHON) {
|
||||
template = pythonTemplate;
|
||||
for (const item of renderData.headers) {
|
||||
let value = item.value;
|
||||
item.value = `'${value}'`;
|
||||
}
|
||||
for (const item of renderData.body) {
|
||||
let value = item.value;
|
||||
if (value === true || value === false) {
|
||||
item.value = `${value.toString()[0].toUpperCase() + value.toString().substring(1)}`;
|
||||
} else if (typeof value === 'string') {
|
||||
item.value = `'${value}'`;
|
||||
}
|
||||
}
|
||||
renderData = {
|
||||
...renderData,
|
||||
method: renderData.method.toLowerCase() as Lowercase<IRenderData['method']>
|
||||
};
|
||||
} else if (this.lang === LANG_JAVASCRIPT) {
|
||||
template = javascriptTemplate;
|
||||
for (const item of renderData.headers) {
|
||||
let value = item.value;
|
||||
item.value = `'${value}'`;
|
||||
}
|
||||
for (const item of renderData.body) {
|
||||
let value = item.value;
|
||||
if (typeof value === 'string') {
|
||||
item.value = `'${value}'`;
|
||||
}
|
||||
}
|
||||
} else if (this.lang === LANG_PHP) {
|
||||
template = phpTemplate;
|
||||
for (const item of renderData.headers) {
|
||||
let value = item.value;
|
||||
item.value = `'${value}'`;
|
||||
}
|
||||
for (const item of renderData.body) {
|
||||
let value = item.value;
|
||||
if (typeof value === 'string') {
|
||||
item.value = `"${value}"`;
|
||||
}
|
||||
}
|
||||
} else if (this.lang === LANG_JAVA) {
|
||||
template = javaTemplate;
|
||||
for (const item of renderData.headers) {
|
||||
let value = item.value;
|
||||
item.value = `"${value}"`;
|
||||
}
|
||||
for (const item of renderData.body) {
|
||||
let value = item.value;
|
||||
if (typeof value === 'string') {
|
||||
item.value = `"${value}"`;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (template) return Mustache.render(template, renderData);
|
||||
return undefined;
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
this.lang = this.options[0].name;
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.wrapper {
|
||||
width: 100%;
|
||||
// padding: 15px;
|
||||
padding-bottom: 0;
|
||||
overflow-x: scroll;
|
||||
.options {
|
||||
width: fit-content;
|
||||
overflow: hidden;
|
||||
.option {
|
||||
margin: 0 5px;
|
||||
float: left;
|
||||
width: 70px;
|
||||
height: 70px;
|
||||
text-align: center;
|
||||
border: 1px solid transparent;
|
||||
padding: 10px;
|
||||
border-radius: 10px;
|
||||
display: inline-flex;
|
||||
flex-direction: column;
|
||||
text-align: center;
|
||||
align-items: center;
|
||||
&:hover,
|
||||
&.active {
|
||||
border-color: #ccc;
|
||||
cursor: pointer;
|
||||
}
|
||||
.icon {
|
||||
width: 30px;
|
||||
height: 30px;
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
.name {
|
||||
color: #666;
|
||||
font-size: 11px;
|
||||
font-weight: bold;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -1,296 +0,0 @@
|
||||
<template>
|
||||
<div v-if="schema" class="wrapper">
|
||||
<div v-for="(item, itemKey) in schema?.properties" :key="itemKey" class="item">
|
||||
<div class="left">
|
||||
<div class="info">
|
||||
<span class="key">{{ itemKey }}</span>
|
||||
<span class="type">{{ item?.type }}</span>
|
||||
<span v-if="!item?.optional" class="required">{{ $t('application.message.requiredParameter') }}</span>
|
||||
</div>
|
||||
<div class="description">
|
||||
{{ item?.title }}
|
||||
</div>
|
||||
</div>
|
||||
<div class="right">
|
||||
<div v-if="itemKey === 'token'">
|
||||
<div v-if="!applied === true">
|
||||
<application-confirm
|
||||
v-if="api"
|
||||
v-model.visible="confirming"
|
||||
:object="api"
|
||||
:type="applicationType.API"
|
||||
@apply="onApply"
|
||||
/>
|
||||
<el-popover placement="bottom" :width="200" :visible="applied === false">
|
||||
<p class="text-center mb-2">
|
||||
<small>{{ $t('application.message.notApplied') }}</small>
|
||||
</p>
|
||||
<p class="text-center">
|
||||
<el-button size="small" type="primary" @click="confirming = true">{{
|
||||
$t('common.button.apply')
|
||||
}}</el-button>
|
||||
</p>
|
||||
<template #reference>
|
||||
<el-input
|
||||
v-model="value[itemKey?.toString()]"
|
||||
:placeholder="$t('common.title.placeholderOfInput')"
|
||||
class="inline-block w-2/3"
|
||||
/>
|
||||
</template>
|
||||
</el-popover>
|
||||
<el-button type="primary" class="inline-block ml-2" size="small" @click="$emit('refresh-applications')">
|
||||
{{ $t('common.button.acquire') }}
|
||||
</el-button>
|
||||
</div>
|
||||
<el-select
|
||||
v-else
|
||||
v-model="value[itemKey?.toString()]"
|
||||
:clearable="true"
|
||||
:filterable="true"
|
||||
:allow-create="true"
|
||||
class="w-full"
|
||||
:placeholder="$t('common.title.placeholderOfSelect')"
|
||||
>
|
||||
<el-option
|
||||
v-if="appliedApplication?.credential?.token"
|
||||
:label="appliedApplication?.credential?.token"
|
||||
:value="appliedApplication?.credential?.token"
|
||||
class="select-option"
|
||||
>
|
||||
<span class="select-option-main">{{ appliedApplication?.credential?.token }}</span>
|
||||
<span class="select-option-description">{{ $t('application.message.yourApplication') }}</span>
|
||||
</el-option>
|
||||
</el-select>
|
||||
</div>
|
||||
<div v-else>
|
||||
<el-select
|
||||
v-if="item?.enum"
|
||||
v-model="value[itemKey?.toString()]"
|
||||
:default-first-option="item?.enum?.length === 1"
|
||||
clearable
|
||||
class="w-full"
|
||||
:placeholder="$t('common.title.placeholderOfSelect')"
|
||||
>
|
||||
<el-option v-for="e in item?.enum" :key="e" :label="e" :value="e" />
|
||||
</el-select>
|
||||
<el-select
|
||||
v-else-if="item?.type === 'boolean'"
|
||||
v-model="value[itemKey?.toString()]"
|
||||
clearable
|
||||
class="w-full"
|
||||
:placeholder="$t('common.title.placeholderOfSelect')"
|
||||
>
|
||||
<el-option key="true" :label="'true'" :value="true" />
|
||||
<el-option key="false" :label="'false'" :value="false" />
|
||||
</el-select>
|
||||
<div v-else-if="item?.example">
|
||||
<el-input
|
||||
v-model="value[itemKey?.toString()]"
|
||||
class="inline-block w-2/3"
|
||||
:placeholder="$t('common.title.placeholderOfInput')"
|
||||
/>
|
||||
<el-button
|
||||
type="primary"
|
||||
class="inline-block ml-2"
|
||||
size="small"
|
||||
@click="value[itemKey?.toString()] = item.example!"
|
||||
>
|
||||
{{ $t('common.button.fillExample') }}
|
||||
</el-button>
|
||||
</div>
|
||||
<el-input v-else v-model="value[itemKey?.toString()]" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script lang="ts">
|
||||
import { defineComponent } from 'vue';
|
||||
import { ISchema } from '@/operators/api/models';
|
||||
import { applicationOperator, IApi, IApplication, IApplicationType } from '@/operators';
|
||||
import { FontAwesomeIcon } from '@fortawesome/vue-fontawesome';
|
||||
import { ElPopover, ElInput, ElSelect, ElButton, ElTooltip, ElOption, ElMessage } from 'element-plus';
|
||||
import { ERROR_CODE_DUPLICATION, ERROR_CODE_UNVERIFIED } from '@/constants/errorCode';
|
||||
import { getVerificationUrl } from '@/utils';
|
||||
import ApplicationConfirm from '@/components/application/Confirm.vue';
|
||||
|
||||
interface IData {
|
||||
value: {
|
||||
[key: string]: string | number;
|
||||
};
|
||||
confirming: boolean;
|
||||
applicationType: typeof IApplicationType;
|
||||
}
|
||||
|
||||
export default defineComponent({
|
||||
name: 'ApiForm',
|
||||
components: {
|
||||
ElPopover,
|
||||
ElInput,
|
||||
ElSelect,
|
||||
ElButton,
|
||||
ElOption,
|
||||
ApplicationConfirm
|
||||
},
|
||||
props: {
|
||||
schema: {
|
||||
type: Object as () => ISchema | undefined,
|
||||
required: true
|
||||
},
|
||||
api: {
|
||||
type: Object as () => IApi | undefined,
|
||||
required: true
|
||||
},
|
||||
applications: {
|
||||
type: Array as () => IApplication[],
|
||||
required: true
|
||||
},
|
||||
applied: {
|
||||
type: Boolean,
|
||||
required: false
|
||||
}
|
||||
},
|
||||
emits: ['update:form', 'refresh-applications'],
|
||||
data(): IData {
|
||||
return {
|
||||
value: {},
|
||||
confirming: false,
|
||||
applicationType: IApplicationType
|
||||
};
|
||||
},
|
||||
computed: {
|
||||
appliedApplication(): IApplication | undefined {
|
||||
const applications = this.applications.filter((application) => application.api?.id === this.api?.id);
|
||||
if (applications.length > 0) {
|
||||
return applications[0];
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
value: {
|
||||
handler() {
|
||||
this.$emit('update:form', { ...this.value });
|
||||
},
|
||||
deep: true
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
onChange(key: string, val: string) {
|
||||
this.value[key] = val;
|
||||
},
|
||||
onRefreshApplications() {
|
||||
this.$emit('refresh-applications');
|
||||
},
|
||||
onApply() {
|
||||
this.confirming = false;
|
||||
applicationOperator
|
||||
.create({
|
||||
type: IApplicationType.API,
|
||||
api_id: this.api?.id
|
||||
})
|
||||
.then(() => {
|
||||
ElMessage.success(this.$t('application.message.applySuccessfully'));
|
||||
this.$emit('refresh-applications');
|
||||
})
|
||||
.catch((error) => {
|
||||
if (error?.response?.data?.code === ERROR_CODE_DUPLICATION) {
|
||||
ElMessage.error(this.$t('application.message.alreadyApplied'));
|
||||
}
|
||||
if (error?.response?.data?.code === ERROR_CODE_UNVERIFIED) {
|
||||
ElMessage({
|
||||
dangerouslyUseHTMLString: true,
|
||||
duration: 0,
|
||||
showClose: true,
|
||||
message: `${this.$t(
|
||||
'application.message.unverified'
|
||||
)} <a class="underline" href="${getVerificationUrl()}">${this.$t('application.message.goVerify')}</a>`,
|
||||
type: 'warning'
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.wrapper {
|
||||
overflow: hidden;
|
||||
|
||||
.item {
|
||||
display: block;
|
||||
overflow: hidden;
|
||||
background-color: rgb(248, 248, 248);
|
||||
padding: 10px;
|
||||
border-right: 1px solid rgba(0, 0, 0, 0.1);
|
||||
border-left: 1px solid rgba(0, 0, 0, 0.1);
|
||||
|
||||
&:first-child {
|
||||
border-top: 1px solid rgba(0, 0, 0, 0.1);
|
||||
border-top-left-radius: 10px;
|
||||
border-top-right-radius: 10px;
|
||||
}
|
||||
|
||||
&:not(:first-child):not(:last-child) {
|
||||
border-top: 1px solid rgba(0, 0, 0, 0.1);
|
||||
}
|
||||
|
||||
&:last-child {
|
||||
border-top: 1px solid rgba(0, 0, 0, 0.1);
|
||||
border-bottom: 1px solid rgba(0, 0, 0, 0.1);
|
||||
border-bottom-left-radius: 10px;
|
||||
border-bottom-right-radius: 10px;
|
||||
}
|
||||
|
||||
.left {
|
||||
width: 70%;
|
||||
float: left;
|
||||
.info {
|
||||
.key {
|
||||
font-size: 14px;
|
||||
font-weight: bold;
|
||||
display: inline-block;
|
||||
padding: 3px;
|
||||
padding-left: 0;
|
||||
}
|
||||
.type {
|
||||
font-size: 14px;
|
||||
display: inline-block;
|
||||
padding: 3px;
|
||||
}
|
||||
.required {
|
||||
font-size: 12px;
|
||||
color: #dd1e2e;
|
||||
display: inline-block;
|
||||
padding: 3px;
|
||||
}
|
||||
}
|
||||
.description {
|
||||
font-size: 12px;
|
||||
color: #666;
|
||||
}
|
||||
}
|
||||
.right {
|
||||
width: 30%;
|
||||
float: left;
|
||||
padding-top: 6px;
|
||||
}
|
||||
}
|
||||
}
|
||||
.el-select-dropdown {
|
||||
.select-option {
|
||||
.select-option-main {
|
||||
display: inline-block;
|
||||
font-size: 14px;
|
||||
}
|
||||
.select-option-description {
|
||||
display: inline-block;
|
||||
font-size: 12px;
|
||||
color: #999;
|
||||
margin-left: 20px;
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -1,61 +0,0 @@
|
||||
<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>
|
||||
@@ -1,158 +0,0 @@
|
||||
<template>
|
||||
<div class="title">
|
||||
<el-button type="primary" size="small" class="mb-1">{{ $t('application.field.api') }}</el-button>
|
||||
{{ api?.title }}
|
||||
</div>
|
||||
<div class="introduction">
|
||||
<p>{{ api?.introduction }}</p>
|
||||
</div>
|
||||
<div class="options">
|
||||
<el-button
|
||||
v-if="showFirstOption"
|
||||
ref="option"
|
||||
type="primary"
|
||||
:plain="activeOption !== 'first'"
|
||||
class="option"
|
||||
@click="activeOption = 'first'"
|
||||
>{{ $t('api.message.firstFree') }}</el-button
|
||||
>
|
||||
<el-button
|
||||
v-for="(pkg, pkgIndex) in api?.packages"
|
||||
ref="option"
|
||||
:key="pkgIndex"
|
||||
type="primary"
|
||||
:plain="!(activeOption == 'package' && activePackage?.id === pkg.id)"
|
||||
class="option"
|
||||
@click="
|
||||
activeOption = 'package';
|
||||
activePackage = pkg;
|
||||
"
|
||||
>
|
||||
{{ pkg.amount }}{{ $t(`api.unit.${api.unit}`) }}
|
||||
</el-button>
|
||||
<el-button
|
||||
v-if="showCustomOption"
|
||||
ref="option"
|
||||
type="primary"
|
||||
:plain="activeOption !== 'custom'"
|
||||
class="option"
|
||||
@click="activeOption = 'custom'"
|
||||
>{{ $t('api.message.custom') }}</el-button
|
||||
>
|
||||
</div>
|
||||
<div class="price">
|
||||
<span v-if="activeOption === 'first'" class="value">¥0</span>
|
||||
<span v-if="activeOption === 'first'" class="remark">
|
||||
({{ $t('api.message.present') + `${api.free_amount}` + $t(`api.unit.${api.unit}`) }})
|
||||
</span>
|
||||
<span v-if="activeOption === 'custom'" class="value">¥{{ api?.price }}</span>
|
||||
<span v-if="activeOption === 'custom'" class="remark">{{ '/' + $t(`api.unit.${api.unit}`) }}</span>
|
||||
<span v-if="activeOption === 'package'" class="value"> ¥{{ activePackage?.price }} </span>
|
||||
<span v-if="activeOption === 'package' && activePackage" class="remark">
|
||||
({{
|
||||
$t('api.message.around') +
|
||||
'¥' +
|
||||
(activePackage?.price / activePackage?.amount).toFixed(4) +
|
||||
'/' +
|
||||
$t(`api.unit.${api.unit}`)
|
||||
}})
|
||||
</span>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script lang="ts">
|
||||
import { IApi, IPackage } from '@/operators';
|
||||
import { defineComponent } from 'vue';
|
||||
import urlJoin from 'url-join';
|
||||
import { ElButton } from 'element-plus';
|
||||
|
||||
interface IData {
|
||||
activeOption: string | undefined;
|
||||
activePackage: IPackage | undefined;
|
||||
}
|
||||
|
||||
export default defineComponent({
|
||||
name: 'ApiPreview',
|
||||
components: {
|
||||
ElButton
|
||||
},
|
||||
props: {
|
||||
api: {
|
||||
type: Object as () => IApi,
|
||||
required: true
|
||||
}
|
||||
},
|
||||
data(): IData {
|
||||
return {
|
||||
activeOption: undefined,
|
||||
activePackage: undefined
|
||||
};
|
||||
},
|
||||
computed: {
|
||||
showFirstOption() {
|
||||
return this.api.free_amount !== 0;
|
||||
},
|
||||
showPackageOption() {
|
||||
return this.api && this.api.packages && this.api?.packages?.length > 0;
|
||||
},
|
||||
showCustomOption() {
|
||||
return this.api.price === 0 || this.api?.price;
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
if (this.showFirstOption) {
|
||||
this.activeOption = 'first';
|
||||
} else if (this.showPackageOption) {
|
||||
this.activeOption = 'package';
|
||||
// @ts-ignore
|
||||
this.activePackage = this.api.packages[0];
|
||||
} else if (this.showCustomOption) {
|
||||
this.activeOption = 'custom';
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
urlJoin,
|
||||
onSelect(option: string, pkg?: IPackage) {
|
||||
this.activeOption = option;
|
||||
this.activePackage = pkg;
|
||||
}
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.title {
|
||||
font-size: 26px;
|
||||
font-weight: 500;
|
||||
line-height: 1.2;
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
|
||||
.introduction {
|
||||
font-size: 14px;
|
||||
margin-bottom: 15px;
|
||||
color: #666;
|
||||
}
|
||||
|
||||
.options {
|
||||
.option {
|
||||
border-radius: 5px !important;
|
||||
}
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
|
||||
.price {
|
||||
.value {
|
||||
font-weight: bold;
|
||||
color: #ff5441;
|
||||
font-size: 24px;
|
||||
}
|
||||
|
||||
.remark {
|
||||
font-size: 14px;
|
||||
color: #999;
|
||||
display: inline-block;
|
||||
margin-left: 5px;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -1,86 +0,0 @@
|
||||
<template>
|
||||
<div v-if="schema" class="body">
|
||||
<div v-if="schema.items && schema.type === 'array'" class="items">
|
||||
<h2 class="title">{{ $t('api.entity.arrayOf') }}</h2>
|
||||
<div v-for="(item, itemKey) in schema.items" :key="itemKey" class="item">
|
||||
<response-body :schema="item" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="properties">
|
||||
<div v-for="(item, itemKey) in schema.properties" :key="itemKey" class="property">
|
||||
<div class="info">
|
||||
<span class="key">{{ itemKey }}</span>
|
||||
<span class="type">{{ item?.type }}</span>
|
||||
</div>
|
||||
<div class="description">
|
||||
{{ item?.title }}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script lang="ts">
|
||||
import { ISchema } from '@/operators';
|
||||
import { defineComponent } from 'vue';
|
||||
|
||||
export default defineComponent({
|
||||
name: 'ResponseBody',
|
||||
props: {
|
||||
schema: {
|
||||
type: Object as () => ISchema,
|
||||
required: true
|
||||
}
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
<style lang="scss">
|
||||
.items {
|
||||
padding: 10px;
|
||||
border-radius: 10px;
|
||||
border: 1px solid rgba(0, 0, 0, 0.1);
|
||||
.title {
|
||||
margin-bottom: 5px;
|
||||
}
|
||||
}
|
||||
.properties {
|
||||
margin-bottom: 10px;
|
||||
.property {
|
||||
padding: 10px;
|
||||
border-right: 1px solid rgba(0, 0, 0, 0.1);
|
||||
border-left: 1px solid rgba(0, 0, 0, 0.1);
|
||||
|
||||
&:first-of-type {
|
||||
border-top: 1px solid rgba(0, 0, 0, 0.1);
|
||||
border-top-left-radius: 10px;
|
||||
border-top-right-radius: 10px;
|
||||
}
|
||||
|
||||
&:not(:first-of-type):not(:last-of-type) {
|
||||
border-top: 1px solid rgba(0, 0, 0, 0.1);
|
||||
}
|
||||
|
||||
&:last-of-type {
|
||||
border-top: 1px solid rgba(0, 0, 0, 0.1);
|
||||
border-bottom: 1px solid rgba(0, 0, 0, 0.1);
|
||||
border-bottom-left-radius: 10px;
|
||||
border-bottom-right-radius: 10px;
|
||||
}
|
||||
.info {
|
||||
.key {
|
||||
font-size: 14px;
|
||||
font-weight: bold;
|
||||
display: inline-block;
|
||||
padding: 3px;
|
||||
padding-left: 0;
|
||||
}
|
||||
.type {
|
||||
font-size: 14px;
|
||||
display: inline-block;
|
||||
padding: 3px;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -1,185 +0,0 @@
|
||||
<template>
|
||||
<el-collapse v-if="responses" id="document-response-item" class="wrapper" accordion>
|
||||
<el-collapse-item v-for="(response, responseKey) in responses" :key="responseKey" class="item" :name="responseKey">
|
||||
<template #title>
|
||||
<span class="badge">
|
||||
<el-tag v-if="response?.is_success" class="ml-2" type="success">{{ $t('api.entity.success') }}</el-tag>
|
||||
<el-tag v-else class="ml-2" type="danger">{{ $t('api.entity.failure') }}</el-tag>
|
||||
</span>
|
||||
<span class="status-code">
|
||||
{{ response?.status_code }}
|
||||
</span>
|
||||
<span class="error-code">
|
||||
{{ response?.error_code }}
|
||||
</span>
|
||||
</template>
|
||||
<div class="item-body">
|
||||
<div>
|
||||
{{ response.description }}
|
||||
</div>
|
||||
<el-divider class="my-3" />
|
||||
<div v-if="response?.headers?.properties" class="headers">
|
||||
<h2 class="title">{{ $t('api.entity.responseHeaders') }}</h2>
|
||||
<div class="properties">
|
||||
<div v-for="(item, itemKey) in response?.headers?.properties" :key="itemKey" class="property">
|
||||
<div class="info">
|
||||
<span class="key">{{ itemKey }}</span>
|
||||
<span class="type">{{ item?.type }}</span>
|
||||
</div>
|
||||
<div class="description">
|
||||
{{ item?.title }}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div v-if="response?.body" class="body">
|
||||
<h2 class="title">{{ $t('api.entity.responseBody') }}</h2>
|
||||
<response-body :schema="response?.body" />
|
||||
</div>
|
||||
<div v-if="response?.example" class="example">
|
||||
<h2 class="title">{{ $t('api.entity.responseExample') }}</h2>
|
||||
<code-snippet :code="response?.example" />
|
||||
</div>
|
||||
</div>
|
||||
</el-collapse-item>
|
||||
</el-collapse>
|
||||
</template>
|
||||
|
||||
<script lang="ts">
|
||||
import { defineComponent } from 'vue';
|
||||
import { IResponse } from '@/operators/api/models';
|
||||
import CodeSnippet from '../common/CodeSnippet.vue';
|
||||
import { ElCollapse, ElCollapseItem, ElTag, ElDivider } from 'element-plus';
|
||||
import ResponseBody from './ResponseBody.vue';
|
||||
|
||||
interface IData {
|
||||
value: {
|
||||
[key: string]: string | number;
|
||||
};
|
||||
}
|
||||
|
||||
export default defineComponent({
|
||||
name: 'ApiResult',
|
||||
components: {
|
||||
CodeSnippet,
|
||||
ElCollapse,
|
||||
ElCollapseItem,
|
||||
ElTag,
|
||||
ResponseBody,
|
||||
ElDivider
|
||||
},
|
||||
props: {
|
||||
responses: {
|
||||
type: Object as () => IResponse[] | [],
|
||||
required: true
|
||||
}
|
||||
},
|
||||
data(): IData {
|
||||
return {
|
||||
value: {}
|
||||
};
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.wrapper {
|
||||
overflow: hidden;
|
||||
border: none;
|
||||
|
||||
.item {
|
||||
display: block;
|
||||
overflow: hidden;
|
||||
background-color: #f8f8f8;
|
||||
border-right: 1px solid rgba(0, 0, 0, 0.1);
|
||||
border-left: 1px solid rgba(0, 0, 0, 0.1);
|
||||
.status-code,
|
||||
.error-code {
|
||||
display: inline-block;
|
||||
padding-left: 5px;
|
||||
}
|
||||
|
||||
&.el-collapse-item:last-child {
|
||||
margin-bottom: 0;
|
||||
}
|
||||
|
||||
&:first-child {
|
||||
border-top: 1px solid rgba(0, 0, 0, 0.1);
|
||||
border-top-left-radius: 10px;
|
||||
border-top-right-radius: 10px;
|
||||
}
|
||||
|
||||
&:not(:first-child):not(:last-child) {
|
||||
border-top: 1px solid rgba(0, 0, 0, 0.1);
|
||||
}
|
||||
|
||||
&:last-child {
|
||||
border-top: 1px solid rgba(0, 0, 0, 0.1);
|
||||
border-bottom: 1px solid rgba(0, 0, 0, 0.1);
|
||||
border-bottom-left-radius: 10px;
|
||||
border-bottom-right-radius: 10px;
|
||||
}
|
||||
|
||||
.item-body {
|
||||
padding: 15px;
|
||||
.body,
|
||||
.headers,
|
||||
.example {
|
||||
.title {
|
||||
font-size: 12px;
|
||||
font-weight: bold;
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
.properties {
|
||||
margin-bottom: 10px;
|
||||
.property {
|
||||
padding: 10px;
|
||||
border-right: 1px solid rgba(0, 0, 0, 0.1);
|
||||
border-left: 1px solid rgba(0, 0, 0, 0.1);
|
||||
|
||||
&:first-of-type {
|
||||
border-top: 1px solid rgba(0, 0, 0, 0.1);
|
||||
border-top-left-radius: 10px;
|
||||
border-top-right-radius: 10px;
|
||||
}
|
||||
|
||||
&:not(:first-of-type):not(:last-of-type) {
|
||||
border-top: 1px solid rgba(0, 0, 0, 0.1);
|
||||
}
|
||||
|
||||
&:last-of-type {
|
||||
border-top: 1px solid rgba(0, 0, 0, 0.1);
|
||||
border-bottom: 1px solid rgba(0, 0, 0, 0.1);
|
||||
border-bottom-left-radius: 10px;
|
||||
border-bottom-right-radius: 10px;
|
||||
}
|
||||
.info {
|
||||
.key {
|
||||
font-size: 14px;
|
||||
font-weight: bold;
|
||||
display: inline-block;
|
||||
padding: 3px;
|
||||
padding-left: 0;
|
||||
}
|
||||
.type {
|
||||
font-size: 14px;
|
||||
display: inline-block;
|
||||
padding: 3px;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
||||
<style lang="scss">
|
||||
#document-response-item {
|
||||
.el-collapse-item__header {
|
||||
border: none;
|
||||
background: none;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -1,93 +0,0 @@
|
||||
<template>
|
||||
<div class="wrapper">
|
||||
<div class="operation mb-2">
|
||||
<el-button class="btn-try" type="primary" :loading="loading" @click="onTry">{{
|
||||
$t('common.button.try')
|
||||
}}</el-button>
|
||||
</div>
|
||||
<div v-if="responseData" class="result">
|
||||
<div class="title">{{ $t('api.entity.response') }}</div>
|
||||
<code-snippet :code="responseData" />
|
||||
</div>
|
||||
<div v-if="loading">
|
||||
<el-skeleton animated />
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script lang="ts">
|
||||
import { IApi, IForm } from '@/operators/api/models';
|
||||
import { defineComponent } from 'vue';
|
||||
import axios, { Method } from 'axios';
|
||||
import urlJoin from 'url-join';
|
||||
import CodeSnippet from '../common/CodeSnippet.vue';
|
||||
import { ElButton, ElSkeleton } from 'element-plus';
|
||||
|
||||
export default defineComponent({
|
||||
name: 'ApiTry',
|
||||
components: {
|
||||
CodeSnippet,
|
||||
ElButton,
|
||||
ElSkeleton
|
||||
},
|
||||
props: {
|
||||
api: {
|
||||
type: Object as () => IApi,
|
||||
required: true
|
||||
},
|
||||
form: {
|
||||
type: Object as () => IForm,
|
||||
required: true
|
||||
}
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
apiKeyValue: this.apiKey,
|
||||
responseData: '',
|
||||
loading: false
|
||||
};
|
||||
},
|
||||
methods: {
|
||||
onTry() {
|
||||
this.loading = true;
|
||||
this.responseData = '';
|
||||
const config = {
|
||||
method: this.api?.request?.method as Method,
|
||||
url: urlJoin(this.api?.endpoint, this.api?.path),
|
||||
params: { ...this.form.queries },
|
||||
data: { ...this.form.body }
|
||||
};
|
||||
axios(config)
|
||||
.then((response) => {
|
||||
this.loading = false;
|
||||
this.responseData = JSON.stringify(response?.data, null, ' ');
|
||||
})
|
||||
.catch((error) => {
|
||||
this.loading = false;
|
||||
this.responseData = JSON.stringify(error?.response?.data, null, ' ');
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.wrapper {
|
||||
margin-top: 15px;
|
||||
padding-bottom: 0;
|
||||
.operation {
|
||||
margin-bottom: 10px;
|
||||
.btn-try {
|
||||
width: 100%;
|
||||
}
|
||||
}
|
||||
|
||||
.result {
|
||||
margin-bottom: 10px;
|
||||
.title {
|
||||
font-size: 12px;
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -1,132 +0,0 @@
|
||||
<template>
|
||||
<div class="item">
|
||||
<div v-if="api?.request?.queries" class="queries">
|
||||
<h2 class="title">{{ $t('api.entity.requestQueries') }}</h2>
|
||||
<api-form
|
||||
v-model:form="formValue.queries"
|
||||
:schema="api?.request?.queries"
|
||||
:api="api"
|
||||
:applied="applied"
|
||||
:applications="applications"
|
||||
@refresh-applications="getApplications"
|
||||
/>
|
||||
</div>
|
||||
<div v-if="api?.request?.headers" class="headers">
|
||||
<h2 class="title">{{ $t('api.entity.requestHeaders') }}</h2>
|
||||
<api-form
|
||||
v-model:form="formValue.headers"
|
||||
:schema="api?.request?.headers"
|
||||
:api="api"
|
||||
:applications="applications"
|
||||
/>
|
||||
</div>
|
||||
<div v-if="api?.request?.body" class="body">
|
||||
<h2 class="title">{{ $t('api.entity.requestBody') }}</h2>
|
||||
<api-form v-model:form="formValue.body" :schema="api?.request?.body" :api="api" :applications="applications" />
|
||||
</div>
|
||||
<div v-if="api?.responses" class="responses">
|
||||
<h2 class="title">{{ $t('api.entity.response') }}</h2>
|
||||
<api-responses :responses="api?.responses" />
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script lang="ts">
|
||||
import { defineComponent } from 'vue';
|
||||
import { IApi, IForm } from '@/operators/api/models';
|
||||
import ApiForm from './Form.vue';
|
||||
import ApiResponses from './Responses.vue';
|
||||
import { applicationOperator } from '@/operators/application/operator';
|
||||
import { IApplication, IApplicationListResponse } from '@/operators/application/models';
|
||||
|
||||
export interface IData {
|
||||
formValue: IForm;
|
||||
applications: IApplication[];
|
||||
applied: boolean | undefined;
|
||||
}
|
||||
|
||||
export default defineComponent({
|
||||
name: 'ApiUsage',
|
||||
components: {
|
||||
ApiForm,
|
||||
ApiResponses
|
||||
},
|
||||
props: {
|
||||
api: {
|
||||
type: Object as () => IApi,
|
||||
required: true
|
||||
},
|
||||
form: {
|
||||
type: Object as () => IForm,
|
||||
required: true
|
||||
}
|
||||
},
|
||||
emits: ['update:form'],
|
||||
data(): IData {
|
||||
return {
|
||||
formValue: this.form || {},
|
||||
applications: [],
|
||||
applied: undefined
|
||||
};
|
||||
},
|
||||
watch: {
|
||||
formValue: {
|
||||
handler(val) {
|
||||
this.$emit('update:form', { ...val });
|
||||
},
|
||||
deep: true
|
||||
}
|
||||
},
|
||||
mounted() {},
|
||||
methods: {
|
||||
getApplications() {
|
||||
applicationOperator
|
||||
.getAll({
|
||||
user_id: this.$store.getters.user?.id,
|
||||
api_id: this.api.id
|
||||
})
|
||||
.then(({ data: data }: { data: IApplicationListResponse }) => {
|
||||
this.applications = data.items;
|
||||
this.applied = this.applications.filter((item) => item?.api?.id === this.api.id).length > 0;
|
||||
})
|
||||
.catch((error) => {});
|
||||
}
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.item {
|
||||
.queries {
|
||||
margin-bottom: 10px;
|
||||
.title {
|
||||
font-size: 12px;
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
}
|
||||
|
||||
.headers {
|
||||
margin-bottom: 10px;
|
||||
.title {
|
||||
font-size: 12px;
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
}
|
||||
|
||||
.body {
|
||||
margin-bottom: 10px;
|
||||
.title {
|
||||
font-size: 12px;
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
}
|
||||
|
||||
.responses {
|
||||
margin-bottom: 10px;
|
||||
.title {
|
||||
font-size: 12px;
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -12,9 +12,6 @@
|
||||
<span>
|
||||
{{ $t('application.field.api') }}
|
||||
</span>
|
||||
<span v-if="type === applicationType.PROXY">
|
||||
{{ $t('application.field.proxy') }}
|
||||
</span>
|
||||
</el-descriptions-item>
|
||||
<el-descriptions-item :label="$t('application.field.name')">
|
||||
{{ object?.title }}
|
||||
@@ -23,9 +20,6 @@
|
||||
<span v-if="type === applicationType.API">
|
||||
{{ object?.free_amount }}{{ $t(`api.unit.${object?.unit}`) }}
|
||||
</span>
|
||||
<span v-if="type === applicationType.PROXY">
|
||||
{{ object?.free_amount }}{{ $t(`proxy.unit.${object?.unit}`) }}
|
||||
</span>
|
||||
</el-descriptions-item>
|
||||
</el-descriptions>
|
||||
<el-divider class="my-2" />
|
||||
@@ -43,7 +37,7 @@
|
||||
<script lang="ts">
|
||||
import { defineComponent } from 'vue';
|
||||
import { ElDialog, ElDescriptions, ElDescriptionsItem, ElDivider, ElCheckbox, ElButton, ElMessage } from 'element-plus';
|
||||
import { IApi, IApplicationType, IProxy } from '@/operators';
|
||||
import { IApi, IApplicationType } from '@/operators';
|
||||
import ApplicationPolicy from './Policy.vue';
|
||||
|
||||
interface IData {
|
||||
@@ -65,7 +59,7 @@ export default defineComponent({
|
||||
},
|
||||
props: {
|
||||
object: {
|
||||
type: Object as () => IApi | IProxy,
|
||||
type: Object as () => IApi,
|
||||
required: true
|
||||
},
|
||||
type: {
|
||||
|
||||
@@ -1,46 +0,0 @@
|
||||
<template>
|
||||
<el-tooltip effect="dark" :content="$t('application.message.rotateCredential')" placement="top-start">
|
||||
<el-popconfirm
|
||||
:title="$t('application.message.rotateCredentialConfirm')"
|
||||
:confirm-button-text="$t('common.button.confirm')"
|
||||
:cancel-button-text="$t('common.button.cancel')"
|
||||
:width="290"
|
||||
@confirm="onConfirm"
|
||||
>
|
||||
<template #reference>
|
||||
<font-awesome-icon icon="fa-solid fa-arrows-rotate" class="icon-rotate" />
|
||||
</template>
|
||||
</el-popconfirm>
|
||||
</el-tooltip>
|
||||
</template>
|
||||
|
||||
<script lang="ts">
|
||||
import { defineComponent } from 'vue';
|
||||
import { FontAwesomeIcon } from '@fortawesome/vue-fontawesome';
|
||||
import { ElTooltip, ElPopconfirm } from 'element-plus';
|
||||
|
||||
export default defineComponent({
|
||||
name: 'RotateCredential',
|
||||
components: {
|
||||
FontAwesomeIcon,
|
||||
ElTooltip,
|
||||
ElPopconfirm
|
||||
},
|
||||
emits: ['rotate'],
|
||||
data() {
|
||||
return {};
|
||||
},
|
||||
methods: {
|
||||
onConfirm() {
|
||||
this.$emit('rotate');
|
||||
}
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.icon-rotate {
|
||||
cursor: pointer;
|
||||
margin-left: 5px;
|
||||
}
|
||||
</style>
|
||||
@@ -1,78 +0,0 @@
|
||||
<template>
|
||||
<el-pagination
|
||||
class="mt-3 mb-3"
|
||||
background
|
||||
:hide-on-single-page="false"
|
||||
layout="prev, pager, next"
|
||||
:current-page="currentPage"
|
||||
:total="total"
|
||||
:page-size="pageSize"
|
||||
@current-change="onPageChange"
|
||||
>
|
||||
</el-pagination>
|
||||
</template>
|
||||
|
||||
<script lang="ts">
|
||||
import { defineComponent } from 'vue';
|
||||
import { ElPagination } from 'element-plus';
|
||||
|
||||
interface IData {
|
||||
loaded: boolean;
|
||||
}
|
||||
|
||||
export default defineComponent({
|
||||
name: 'Pagination',
|
||||
components: {
|
||||
ElPagination
|
||||
},
|
||||
props: {
|
||||
total: {
|
||||
type: Number,
|
||||
required: false,
|
||||
default: undefined
|
||||
},
|
||||
currentPage: {
|
||||
type: Number,
|
||||
required: true
|
||||
},
|
||||
pageSize: {
|
||||
type: Number,
|
||||
required: true
|
||||
}
|
||||
},
|
||||
emits: ['change'],
|
||||
data(): IData {
|
||||
return {
|
||||
loaded: false
|
||||
};
|
||||
},
|
||||
mounted() {
|
||||
setTimeout(() => {
|
||||
// use this flag to fix the bug of el-pagination,
|
||||
// always emit page 1 when load first time.
|
||||
this.loaded = true;
|
||||
}, 1000);
|
||||
},
|
||||
methods: {
|
||||
onPageChange(val: number): void {
|
||||
// if not finished loading, ignore the wrong emit event
|
||||
if (!this.loaded) {
|
||||
return;
|
||||
}
|
||||
this.$emit('change', val);
|
||||
}
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
<style lang="scss">
|
||||
.el-pagination {
|
||||
button {
|
||||
border-radius: 50% !important;
|
||||
}
|
||||
li {
|
||||
border-radius: 50% !important;
|
||||
outline: none !important;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -1,57 +0,0 @@
|
||||
<template>
|
||||
<div class="price-text">
|
||||
<span v-if="price > 0" class="unfree"
|
||||
>¥{{ price }} {{ unit ? `/ ${unit}` : '' }}{{ start ? $t('common.message.startPrice') : '' }}</span
|
||||
>
|
||||
<span v-else class="free">
|
||||
{{ $t('common.message.free') }}
|
||||
</span>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { defineComponent } from 'vue';
|
||||
export default defineComponent({
|
||||
name: 'ApiPrice',
|
||||
props: {
|
||||
price: {
|
||||
type: Number,
|
||||
required: false,
|
||||
default: 0
|
||||
},
|
||||
unit: {
|
||||
type: String,
|
||||
required: false,
|
||||
default: undefined
|
||||
},
|
||||
start: {
|
||||
type: Boolean,
|
||||
required: false,
|
||||
default: false
|
||||
}
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.price-text {
|
||||
display: inline-block;
|
||||
margin: 0;
|
||||
.unfree {
|
||||
color: #ff5441;
|
||||
|
||||
.value {
|
||||
font-weight: bold;
|
||||
color: #ff5441;
|
||||
font-size: 30px;
|
||||
}
|
||||
|
||||
.unit {
|
||||
color: #666;
|
||||
}
|
||||
}
|
||||
.free {
|
||||
color: #29c287;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -1,163 +0,0 @@
|
||||
<template>
|
||||
<el-row class="header">
|
||||
<el-col :md="4" :xs="24">
|
||||
<img src="@/assets/images/logo.svg" class="logo" @click="onHome" />
|
||||
</el-col>
|
||||
<el-col :md="16" :xs="12">
|
||||
<el-menu :default-active="active" class="el-menu-demo" mode="horizontal" @select="onSelect">
|
||||
<el-menu-item v-t="'common.nav.service'" index="/services"></el-menu-item>
|
||||
<el-menu-item v-t="'common.nav.document'" index="/documents"></el-menu-item>
|
||||
</el-menu>
|
||||
</el-col>
|
||||
<el-col :md="4" :xs="12">
|
||||
<div v-if="!$store.getters.authenticated" class="mt-4 pr-10">
|
||||
<el-button type="primary" class="float-right" size="small" round @click="onLogin">{{
|
||||
$t('common.button.login')
|
||||
}}</el-button>
|
||||
</div>
|
||||
<div v-else class="float-right">
|
||||
<div class="console" @click="onConsole">
|
||||
{{ $t('common.button.console') }}
|
||||
</div>
|
||||
<el-dropdown trigger="click">
|
||||
<img :src="user?.avatar || defaultAvatar" class="avatar" />
|
||||
<template #dropdown>
|
||||
<el-dropdown-menu>
|
||||
<el-dropdown-item @click="onProfile">{{ $t('common.button.profile') }}</el-dropdown-item>
|
||||
<el-dropdown-item @click="onVerify">{{ $t('common.button.verify') }}</el-dropdown-item>
|
||||
<el-dropdown-item @click="onLogout">{{ $t('common.button.logout') }}</el-dropdown-item>
|
||||
</el-dropdown-menu>
|
||||
</template>
|
||||
</el-dropdown>
|
||||
</div>
|
||||
</el-col>
|
||||
</el-row>
|
||||
</template>
|
||||
|
||||
<script lang="ts">
|
||||
import { defineComponent } from 'vue';
|
||||
import defaultAvatar from '@/assets/images/avatar.png';
|
||||
import { getAuthBaseUrl } from '@/utils';
|
||||
import { ROUTE_AUTH_LOGIN, ROUTE_CONSOLE_ROOT, ROUTE_INDEX } from '@/router';
|
||||
import {
|
||||
ElContainer,
|
||||
ElAside,
|
||||
ElMain,
|
||||
ElCol,
|
||||
ElRow,
|
||||
ElDropdown,
|
||||
ElMenu,
|
||||
ElMenuItem,
|
||||
ElDropdownItem,
|
||||
ElButton
|
||||
} from 'element-plus';
|
||||
export default defineComponent({
|
||||
name: 'TopHeader',
|
||||
components: {
|
||||
ElCol,
|
||||
ElRow,
|
||||
ElDropdown,
|
||||
ElMenu,
|
||||
ElMenuItem,
|
||||
ElDropdownItem,
|
||||
ElButton
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
defaultAvatar
|
||||
// defaultAvatar: new URL('@/assets/images/avatar.png', import.meta.url).href
|
||||
};
|
||||
},
|
||||
computed: {
|
||||
active() {
|
||||
return this.$route.matched[0].path;
|
||||
},
|
||||
user() {
|
||||
return this.$store.getters.user;
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
onSelect(val: string) {
|
||||
this.$router.push(val);
|
||||
},
|
||||
onHome() {
|
||||
this.$router.push({
|
||||
name: ROUTE_INDEX
|
||||
});
|
||||
},
|
||||
onLogin() {
|
||||
this.$router.push({
|
||||
name: ROUTE_AUTH_LOGIN
|
||||
});
|
||||
},
|
||||
onProfile() {
|
||||
const authBaseUrl = getAuthBaseUrl();
|
||||
window.open(`${authBaseUrl}/user/profile`, '_blank');
|
||||
},
|
||||
onVerify() {
|
||||
const authBaseUrl = getAuthBaseUrl();
|
||||
window.open(`${authBaseUrl}/user/verify`, '_blank');
|
||||
},
|
||||
onConsole() {
|
||||
this.$router.push({
|
||||
name: ROUTE_CONSOLE_ROOT
|
||||
});
|
||||
},
|
||||
onLogout() {
|
||||
this.$store.dispatch('resetAuth');
|
||||
this.$router.push({
|
||||
name: ROUTE_INDEX
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
<style lang="scss">
|
||||
$height: 60px;
|
||||
.header {
|
||||
z-index: 999;
|
||||
width: 100%;
|
||||
background: radial-gradient(circle at 0 2%, #111827, #1a125d 99%);
|
||||
.logo {
|
||||
height: $height - 5px;
|
||||
width: 100%;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.el-menu {
|
||||
--el-menu-hover-bg-color: rgba(255, 255, 255, 0);
|
||||
--el-menu-active-color: white;
|
||||
background: none;
|
||||
border: none;
|
||||
.el-menu-item {
|
||||
height: $height;
|
||||
color: white;
|
||||
&.is-active {
|
||||
border-bottom: 3px solid var(--el-menu-active-color);
|
||||
}
|
||||
&:hover {
|
||||
border-bottom: 3px solid var(--el-color-primary);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.avatar {
|
||||
height: 40px;
|
||||
border-radius: 50%;
|
||||
cursor: pointer;
|
||||
margin-top: 10px;
|
||||
margin-right: 20px;
|
||||
margin-left: 10px;
|
||||
}
|
||||
.console {
|
||||
color: white;
|
||||
height: 60px;
|
||||
line-height: 60px;
|
||||
margin: 0 10px;
|
||||
font-size: 14px;
|
||||
display: inline-block;
|
||||
cursor: pointer;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -1,197 +0,0 @@
|
||||
<template>
|
||||
<el-row class="mb-10">
|
||||
<el-col :span="24">
|
||||
<img src="@/assets/images/logo2.svg" class="logo" @click="onHome" />
|
||||
</el-col>
|
||||
</el-row>
|
||||
<el-row>
|
||||
<el-col :span="24">
|
||||
<div class="links">
|
||||
<a
|
||||
v-for="(link, linkIndex) in links"
|
||||
:key="linkIndex"
|
||||
:class="{ link: true, active: $route.name === link.name }"
|
||||
@click="onNavigate(link)"
|
||||
>
|
||||
<span class="icon">
|
||||
<font-awesome-icon :icon="link.icon" class="text-sm" />
|
||||
</span>
|
||||
<span class="text">{{ link.text }}</span>
|
||||
<span class="outer">
|
||||
<font-awesome-icon
|
||||
v-if="!link.name && link.href"
|
||||
icon="fa-solid fa-up-right-from-square"
|
||||
class="text-sm ml-2"
|
||||
/>
|
||||
</span>
|
||||
<span class="suffix"> </span>
|
||||
</a>
|
||||
</div>
|
||||
</el-col>
|
||||
</el-row>
|
||||
</template>
|
||||
|
||||
<script lang="ts">
|
||||
import { defineComponent } from 'vue';
|
||||
import {
|
||||
ROUTE_CONSOLE_ADMIN_APPLICATION,
|
||||
ROUTE_CONSOLE_APPLICATION_LIST,
|
||||
ROUTE_CONSOLE_ORDER_LIST,
|
||||
ROUTE_INDEX
|
||||
} from '@/router';
|
||||
import { ElRow, ElCol } from 'element-plus';
|
||||
import { FontAwesomeIcon } from '@fortawesome/vue-fontawesome';
|
||||
import { getAuthBaseUrl } from '@/utils';
|
||||
|
||||
interface ILink {
|
||||
key: string;
|
||||
text: string;
|
||||
name?: string;
|
||||
href?: string;
|
||||
icon: string;
|
||||
admin?: boolean;
|
||||
}
|
||||
|
||||
export default defineComponent({
|
||||
name: 'Navigator',
|
||||
components: {
|
||||
ElRow,
|
||||
ElCol,
|
||||
FontAwesomeIcon
|
||||
},
|
||||
computed: {
|
||||
active() {
|
||||
return this.$route.matched[0].path;
|
||||
},
|
||||
user() {
|
||||
return this.$store.getters.user;
|
||||
},
|
||||
links(): ILink[] {
|
||||
let commonLinks: ILink[] = [
|
||||
{
|
||||
key: 'profile',
|
||||
text: this.$t('console.menu.userProfile'),
|
||||
href: `${getAuthBaseUrl()}/user/profile`,
|
||||
icon: 'fa-regular fa-user'
|
||||
},
|
||||
{
|
||||
key: 'verify',
|
||||
text: this.$t('console.menu.idVerify'),
|
||||
href: `${getAuthBaseUrl()}/user/verify`,
|
||||
icon: 'fa-regular fa-id-card'
|
||||
},
|
||||
{
|
||||
key: 'application-list',
|
||||
text: this.$t('console.menu.applicationList'),
|
||||
name: ROUTE_CONSOLE_APPLICATION_LIST,
|
||||
icon: 'fa-solid fa-cube'
|
||||
},
|
||||
{
|
||||
key: 'order-list',
|
||||
text: this.$t('console.menu.orderList'),
|
||||
name: ROUTE_CONSOLE_ORDER_LIST,
|
||||
icon: 'fa-solid fa-store'
|
||||
}
|
||||
];
|
||||
let adminLinks: ILink[] = [
|
||||
{
|
||||
key: 'admin-application',
|
||||
text: this.$t('console.menu.manageApplication'),
|
||||
name: ROUTE_CONSOLE_ADMIN_APPLICATION,
|
||||
icon: 'fa-solid fa-cubes'
|
||||
}
|
||||
];
|
||||
if (this.user.is_superuser) {
|
||||
return [...commonLinks, ...adminLinks];
|
||||
}
|
||||
return commonLinks;
|
||||
}
|
||||
},
|
||||
mounted() {},
|
||||
methods: {
|
||||
onHome() {
|
||||
this.$router.push({
|
||||
name: ROUTE_INDEX
|
||||
});
|
||||
},
|
||||
onNavigate(link: ILink) {
|
||||
if (link.name) {
|
||||
this.$router.push({
|
||||
name: link.name
|
||||
});
|
||||
} else if (link.href) {
|
||||
window.open(link.href, '_blank');
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.logo {
|
||||
width: 100%;
|
||||
height: 60px;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.avatar {
|
||||
display: block;
|
||||
margin: 30px auto 20px auto;
|
||||
}
|
||||
|
||||
.nickname {
|
||||
display: block;
|
||||
margin: auto;
|
||||
margin-bottom: 20px;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.links {
|
||||
width: 100%;
|
||||
.link {
|
||||
$height: 40px;
|
||||
height: $height;
|
||||
display: block;
|
||||
// padding: 5px 8px;
|
||||
width: 100%;
|
||||
border-radius: 6px;
|
||||
cursor: pointer;
|
||||
margin-bottom: 5px;
|
||||
position: relative;
|
||||
color: #444;
|
||||
line-height: $height;
|
||||
padding-left: 10px;
|
||||
.suffix {
|
||||
width: 3px;
|
||||
height: $height;
|
||||
// position: relative;
|
||||
// top: 2px;
|
||||
position: absolute;
|
||||
right: -20px;
|
||||
margin-right: 5px;
|
||||
border-radius: 3px;
|
||||
display: inline-block;
|
||||
}
|
||||
.icon {
|
||||
width: 16px;
|
||||
height: 16px;
|
||||
display: inline-block;
|
||||
position: relative;
|
||||
margin-right: 10px;
|
||||
// top: -1px;
|
||||
transform: translateY(-2%);
|
||||
}
|
||||
.text {
|
||||
font-size: 14px;
|
||||
}
|
||||
&.active {
|
||||
.suffix {
|
||||
background-color: var(--el-color-primary);
|
||||
}
|
||||
}
|
||||
&:hover {
|
||||
background-color: #ebedf1;
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -1,67 +0,0 @@
|
||||
<template>
|
||||
<div v-if="loading">
|
||||
<el-skeleton animated />
|
||||
</div>
|
||||
<div v-else-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';
|
||||
import { ElSkeleton } from 'element-plus';
|
||||
|
||||
interface IData {
|
||||
documents: IDocument[];
|
||||
limit: number;
|
||||
offset: number;
|
||||
loading: boolean;
|
||||
}
|
||||
|
||||
export default defineComponent({
|
||||
name: 'DocumentList',
|
||||
components: {
|
||||
DocumentListItem,
|
||||
ElSkeleton
|
||||
},
|
||||
data(): IData {
|
||||
return {
|
||||
documents: [],
|
||||
limit: 20,
|
||||
offset: 0,
|
||||
loading: false
|
||||
};
|
||||
},
|
||||
computed: {},
|
||||
mounted() {
|
||||
this.getDocuments(this.offset, this.limit);
|
||||
},
|
||||
methods: {
|
||||
getDocuments(offset: number, limit: number) {
|
||||
this.loading = true;
|
||||
documentOperator
|
||||
.getAll({
|
||||
offset,
|
||||
limit,
|
||||
ordering: 'rank',
|
||||
private: false
|
||||
})
|
||||
.then(({ data: data }: { data: IDocumentListResponse }) => {
|
||||
this.loading = false;
|
||||
this.documents = data.items;
|
||||
})
|
||||
.catch((error) => {
|
||||
this.loading = false;
|
||||
console.error(error);
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
</script>
|
||||
@@ -1,110 +0,0 @@
|
||||
<template>
|
||||
<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: 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>
|
||||
<el-tag class="type" effect="dark">
|
||||
{{ documentType.API.toUpperCase() }}
|
||||
</el-tag>
|
||||
</div>
|
||||
<div
|
||||
v-else-if="document.type === documentType.PROXY"
|
||||
:class="{ item: true, active: id === document?.id }"
|
||||
@click="onClick"
|
||||
>
|
||||
<el-link type="primary" class="link" :underline="false">
|
||||
<span class="name">{{ document?.title || document?.proxy?.title }}</span>
|
||||
</el-link>
|
||||
<el-tag class="type" effect="dark">
|
||||
{{ documentType.PROXY.toUpperCase() }}
|
||||
</el-tag>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script lang="ts">
|
||||
import { defineComponent } from 'vue';
|
||||
import { IDocument, IDocumentType } from '@/operators/document/models';
|
||||
import { ROUTE_DOCUMENT_DETAIL } from '@/router';
|
||||
import { ElLink, ElTag } from 'element-plus';
|
||||
|
||||
export default defineComponent({
|
||||
name: 'ApiListItem',
|
||||
components: {
|
||||
ElLink,
|
||||
ElTag
|
||||
},
|
||||
props: {
|
||||
document: {
|
||||
type: Object as () => IDocument,
|
||||
required: true
|
||||
}
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
documentType: IDocumentType
|
||||
};
|
||||
},
|
||||
computed: {
|
||||
id() {
|
||||
return this.$route.params?.id?.toString();
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
onClick() {
|
||||
this.$router.push({
|
||||
name: ROUTE_DOCUMENT_DETAIL,
|
||||
params: {
|
||||
id: this.document.id
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
$height: 35px;
|
||||
.item {
|
||||
height: $height;
|
||||
line-height: $height;
|
||||
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 {
|
||||
display: flex;
|
||||
}
|
||||
}
|
||||
.type {
|
||||
display: none;
|
||||
position: absolute;
|
||||
right: 5px;
|
||||
top: 5px;
|
||||
border-radius: 10px;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -1,208 +0,0 @@
|
||||
<template>
|
||||
<el-form label-width="100px">
|
||||
<el-form-item :label="$t('application.field.service')">
|
||||
<span v-if="application.type === applicationType.API">
|
||||
{{ application?.api?.title }}
|
||||
</span>
|
||||
<span v-if="application.type === applicationType.PROXY">
|
||||
{{ application?.proxy?.title }}
|
||||
</span>
|
||||
</el-form-item>
|
||||
<el-form-item :label="$t('application.field.package')">
|
||||
<el-radio-group v-if="application.type === applicationType.API" v-model="form.packageId">
|
||||
<el-radio-button v-for="(pkg, pkgIndex) in application?.api?.packages" :key="pkgIndex" :label="pkg.id">
|
||||
{{ pkg.amount }}{{ $t(`api.unit.${application?.api?.unit}`) }}
|
||||
</el-radio-button>
|
||||
<el-radio-button label="custom">
|
||||
{{ $t('application.button.custom') }}
|
||||
</el-radio-button>
|
||||
</el-radio-group>
|
||||
<el-radio-group v-else-if="application.type === applicationType.PROXY" v-model="form.packageId">
|
||||
<el-radio-button v-for="(pkg, pkgIndex) in application?.proxy?.packages" :key="pkgIndex" :label="pkg.id">
|
||||
{{ pkg.amount }}{{ $t(`proxy.unit.${application?.proxy?.unit}`) }}
|
||||
</el-radio-button>
|
||||
</el-radio-group>
|
||||
</el-form-item>
|
||||
<el-form-item v-if="form.packageId === 'custom'" :label="$t('application.field.amount')">
|
||||
<el-input-number v-model="form.amount" :min="1" :max="10000" controls-position="right" />
|
||||
</el-form-item>
|
||||
<el-form-item :label="$t('service.field.price')">
|
||||
<div v-if="application.type === applicationType.API">
|
||||
<price
|
||||
v-if="form.packageId === 'custom'"
|
||||
:price="application?.api?.price"
|
||||
:unit="$t(`api.unit.${application?.api?.unit}`)"
|
||||
/>
|
||||
<price v-else :price="package?.price" />
|
||||
</div>
|
||||
<div v-if="application.type === applicationType.PROXY">
|
||||
<price :price="package?.price" />
|
||||
</div>
|
||||
</el-form-item>
|
||||
<el-divider border-style="dashed" />
|
||||
<el-form-item :label="$t('application.field.shouldPayPrice')">
|
||||
<span v-if="form.packageId === 'custom'" :class="{ price: true, unfree: price > 0, free: price === 0 }">
|
||||
¥{{ price.toFixed(2) }}
|
||||
</span>
|
||||
<span v-else-if="package" :class="{ price: true, unfree: package?.price > 0, free: package?.price === 0 }">
|
||||
¥{{ package?.price?.toFixed(2) }}
|
||||
</span>
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-button type="primary" size="large" class="btn-create" :loading="creating" @click="onCreateOrder">
|
||||
{{ $t('application.button.createOrder') }}
|
||||
</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
</template>
|
||||
|
||||
<script lang="ts">
|
||||
import { IApplication, IApplicationType, IOrderDetailResponse, IPackage, orderOperator } from '@/operators';
|
||||
import { defineComponent } from 'vue';
|
||||
import { ElMessage } from 'element-plus';
|
||||
import { ROUTE_CONSOLE_ORDER_DETAIL } from '@/router';
|
||||
import { ElForm, ElFormItem, ElButton, ElInputNumber, ElDivider, ElRadioGroup, ElRadioButton } from 'element-plus';
|
||||
import Price from '@/components/common/Price.vue';
|
||||
|
||||
interface IData {
|
||||
form: {
|
||||
amount: number;
|
||||
packageId: string | undefined;
|
||||
};
|
||||
creating: boolean;
|
||||
applicationType: typeof IApplicationType;
|
||||
}
|
||||
|
||||
export default defineComponent({
|
||||
name: 'CreateOrderDialog',
|
||||
components: {
|
||||
ElForm,
|
||||
ElFormItem,
|
||||
ElInputNumber,
|
||||
ElButton,
|
||||
ElDivider,
|
||||
ElRadioGroup,
|
||||
ElRadioButton,
|
||||
Price
|
||||
},
|
||||
props: {
|
||||
application: {
|
||||
type: Object as () => IApplication,
|
||||
required: true
|
||||
}
|
||||
},
|
||||
data(): IData {
|
||||
return {
|
||||
form: {
|
||||
amount: 1000,
|
||||
packageId: undefined
|
||||
},
|
||||
creating: false,
|
||||
applicationType: IApplicationType
|
||||
};
|
||||
},
|
||||
computed: {
|
||||
price() {
|
||||
if (this.application?.type === IApplicationType.API) {
|
||||
if (this.application.api?.price && this.form.amount) {
|
||||
return this.form.amount * this.application.api?.price;
|
||||
}
|
||||
}
|
||||
if (this.application?.type === IApplicationType.PROXY) {
|
||||
if (this.application.proxy?.price && this.form.amount) {
|
||||
return this.form.amount * this.application.proxy?.price;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
},
|
||||
package() {
|
||||
if (this.application?.type === IApplicationType.API) {
|
||||
if (this.application.api?.packages && this.form.packageId) {
|
||||
const filterPackages = this.application.api?.packages.filter((item) => item.id === this.form.packageId);
|
||||
if (filterPackages.length > 0) {
|
||||
return filterPackages[0];
|
||||
}
|
||||
}
|
||||
}
|
||||
if (this.application?.type === IApplicationType.PROXY) {
|
||||
if (this.application.proxy?.packages && this.form.packageId) {
|
||||
const filterPackages = this.application.proxy?.packages.filter((item) => item.id === this.form.packageId);
|
||||
if (filterPackages.length > 0) {
|
||||
return filterPackages[0];
|
||||
}
|
||||
}
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
this.onInit();
|
||||
},
|
||||
methods: {
|
||||
onInit() {
|
||||
if (this.application.type === IApplicationType.API) {
|
||||
if (this.application?.api?.packages && this.application?.api?.packages.length > 0) {
|
||||
this.form.packageId = this.application?.api?.packages[0].id;
|
||||
} else {
|
||||
this.form.packageId = 'custom';
|
||||
}
|
||||
}
|
||||
if (this.application.type === IApplicationType.PROXY) {
|
||||
if (this.application?.proxy?.packages && this.application?.proxy?.packages.length > 0) {
|
||||
this.form.packageId = this.application?.proxy?.packages[0].id;
|
||||
}
|
||||
}
|
||||
},
|
||||
onChangePackage(pkg: IPackage) {
|
||||
console.log('pkg', pkg);
|
||||
},
|
||||
onCreateOrder() {
|
||||
if (!this.application?.id) {
|
||||
return;
|
||||
}
|
||||
this.creating = true;
|
||||
orderOperator
|
||||
.create({
|
||||
application_id: this.application?.id,
|
||||
amount: this.form.amount,
|
||||
...(this.form.packageId !== 'custom' && this.package
|
||||
? {
|
||||
package_id: this.package.id
|
||||
}
|
||||
: {})
|
||||
})
|
||||
.then(({ data: data }: { data: IOrderDetailResponse }) => {
|
||||
this.creating = false;
|
||||
const order = data;
|
||||
this.$router.push({
|
||||
name: ROUTE_CONSOLE_ORDER_DETAIL,
|
||||
params: {
|
||||
id: order.id
|
||||
}
|
||||
});
|
||||
})
|
||||
.catch(() => {
|
||||
ElMessage.error(this.$t('order.message.createFailed'));
|
||||
this.creating = false;
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.price {
|
||||
font-size: 20px;
|
||||
font-weight: bold;
|
||||
&.unfree {
|
||||
color: #ff5441;
|
||||
}
|
||||
&.free {
|
||||
color: #29c287;
|
||||
}
|
||||
}
|
||||
|
||||
.btn-create {
|
||||
width: 150px;
|
||||
}
|
||||
</style>
|
||||
@@ -1,111 +0,0 @@
|
||||
<template>
|
||||
<el-dialog :model-value="visible" :title="$t('application.title.buyService')" width="500px" center>
|
||||
<el-row class="paycodes">
|
||||
<el-col :span="12">
|
||||
<div class="paycode wechat">
|
||||
<qr-code v-if="modelValue?.wechatpay_url" :value="modelValue?.wechatpay_url" :size="200" class="m-auto" />
|
||||
<p class="help-text">{{ $t('order.message.wechatPayHelp') }}</p>
|
||||
</div>
|
||||
</el-col>
|
||||
<el-col :span="12">
|
||||
<div class="help-img">
|
||||
<img src="https://midas.gtimg.cn/enterprise/images/ep_sys_wx_tip.jpg" />
|
||||
</div>
|
||||
</el-col>
|
||||
</el-row>
|
||||
</el-dialog>
|
||||
</template>
|
||||
|
||||
<script lang="ts">
|
||||
import { IOrder, IOrderDetailResponse, orderOperator, OrderState } from '@/operators';
|
||||
import { defineComponent } from 'vue';
|
||||
import { ElDialog, ElRow, ElCol } from 'element-plus';
|
||||
import QrCode from 'qrcode.vue';
|
||||
|
||||
interface IData {
|
||||
refreshTimer: number | undefined;
|
||||
}
|
||||
|
||||
export default defineComponent({
|
||||
name: 'PayOrderDialog',
|
||||
components: {
|
||||
ElDialog,
|
||||
QrCode,
|
||||
ElRow,
|
||||
ElCol
|
||||
},
|
||||
props: {
|
||||
modelValue: {
|
||||
type: Object as () => IOrder,
|
||||
required: true
|
||||
},
|
||||
visible: {
|
||||
type: Boolean,
|
||||
required: false,
|
||||
default: false
|
||||
}
|
||||
},
|
||||
emits: ['hide', 'update:modelValue'],
|
||||
data(): IData {
|
||||
return {
|
||||
refreshTimer: undefined
|
||||
};
|
||||
},
|
||||
mounted() {
|
||||
this.onRefresh();
|
||||
},
|
||||
unmounted() {
|
||||
if (this.refreshTimer) {
|
||||
clearTimeout(this.refreshTimer);
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
onRefresh() {
|
||||
if (!this.modelValue.id) {
|
||||
console.error('id does not exist');
|
||||
return;
|
||||
}
|
||||
orderOperator
|
||||
.refresh(this.modelValue.id)
|
||||
.then(({ data: data }: { data: IOrderDetailResponse }) => {
|
||||
// if not paid, check for next loop
|
||||
if (data.state !== OrderState.PAID) {
|
||||
setTimeout(() => {
|
||||
this.onRefresh();
|
||||
}, 2000);
|
||||
} else {
|
||||
// paid, just notify parent, and hide the dialog
|
||||
this.$emit('hide');
|
||||
}
|
||||
this.$emit('update:modelValue', data);
|
||||
})
|
||||
.catch(() => {
|
||||
setTimeout(() => {
|
||||
this.onRefresh();
|
||||
}, 2000);
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.paycodes {
|
||||
padding: 30px 0;
|
||||
width: 500px;
|
||||
margin: auto;
|
||||
.wechat {
|
||||
.help-text {
|
||||
display: block;
|
||||
background-color: #00c800;
|
||||
color: white;
|
||||
font-size: 14px;
|
||||
height: 35px;
|
||||
width: 240px;
|
||||
text-align: center;
|
||||
line-height: 35px;
|
||||
margin: 10px auto 0 auto;
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -1,58 +0,0 @@
|
||||
<template>
|
||||
<div class="title">
|
||||
{{ proxy?.title }}
|
||||
</div>
|
||||
<div class="url">
|
||||
<span v-if="proxy?.endpoint" class="endpoint">{{ proxy?.endpoint }}</span>
|
||||
</div>
|
||||
<div class="introduction">
|
||||
<p>{{ proxy?.introduction }}</p>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script lang="ts">
|
||||
import { IProxy } from '@/operators';
|
||||
import { defineComponent } from 'vue';
|
||||
import urlJoin from 'url-join';
|
||||
|
||||
export default defineComponent({
|
||||
name: 'ProxyInfo',
|
||||
components: {},
|
||||
props: {
|
||||
proxy: {
|
||||
type: Object as () => IProxy,
|
||||
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 0px;
|
||||
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>
|
||||
@@ -1,158 +0,0 @@
|
||||
<template>
|
||||
<div class="title">
|
||||
<el-button type="primary" size="small">{{ $t('application.field.proxy') }}</el-button>
|
||||
{{ proxy?.title }}
|
||||
</div>
|
||||
<div class="introduction">
|
||||
<p>{{ proxy?.introduction }}</p>
|
||||
</div>
|
||||
<div class="options">
|
||||
<el-button
|
||||
v-if="showFirstOption"
|
||||
ref="option"
|
||||
type="primary"
|
||||
:plain="activeOption !== 'first'"
|
||||
class="option"
|
||||
@click="activeOption = 'first'"
|
||||
>{{ $t('proxy.message.firstFree') }}</el-button
|
||||
>
|
||||
<el-button
|
||||
v-for="(pkg, pkgIndex) in proxy?.packages"
|
||||
ref="option"
|
||||
:key="pkgIndex"
|
||||
type="primary"
|
||||
:plain="!(activeOption == 'package' && activePackage?.id === pkg.id)"
|
||||
class="option"
|
||||
@click="
|
||||
activeOption = 'package';
|
||||
activePackage = pkg;
|
||||
"
|
||||
>
|
||||
{{ pkg.amount }}{{ $t(`proxy.unit.${proxy.unit}`) }}
|
||||
</el-button>
|
||||
<el-button
|
||||
v-if="showCustomOption"
|
||||
ref="option"
|
||||
type="primary"
|
||||
:plain="activeOption !== 'custom'"
|
||||
class="option"
|
||||
@click="activeOption = 'custom'"
|
||||
>{{ $t('proxy.message.custom') }}</el-button
|
||||
>
|
||||
</div>
|
||||
<div class="price">
|
||||
<span v-if="activeOption === 'first'" class="value">¥0</span>
|
||||
<span v-if="activeOption === 'first'" class="remark">
|
||||
({{ $t('proxy.message.present') + `${proxy.free_amount}` + $t(`proxy.unit.${proxy.unit}`) }})
|
||||
</span>
|
||||
<span v-if="activeOption === 'custom'" class="value">¥{{ proxy?.price }}</span>
|
||||
<span v-if="activeOption === 'custom'" class="remark">{{ '/' + $t(`proxy.unit.${proxy.unit}`) }}</span>
|
||||
<span v-if="activeOption === 'package'" class="value"> ¥{{ activePackage?.price }} </span>
|
||||
<span v-if="activeOption === 'package' && activePackage" class="remark">
|
||||
({{
|
||||
$t('proxy.message.around') +
|
||||
'¥' +
|
||||
(activePackage?.price / activePackage?.amount).toFixed(2) +
|
||||
'/' +
|
||||
$t(`proxy.unit.${proxy.unit}`)
|
||||
}})
|
||||
</span>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script lang="ts">
|
||||
import { IProxy, IPackage } from '@/operators';
|
||||
import { defineComponent } from 'vue';
|
||||
import urlJoin from 'url-join';
|
||||
import { ElButton } from 'element-plus';
|
||||
|
||||
interface IData {
|
||||
activeOption: string | undefined;
|
||||
activePackage: IPackage | undefined;
|
||||
}
|
||||
|
||||
export default defineComponent({
|
||||
name: 'ProxyPreview',
|
||||
components: {
|
||||
ElButton
|
||||
},
|
||||
props: {
|
||||
proxy: {
|
||||
type: Object as () => IProxy,
|
||||
required: true
|
||||
}
|
||||
},
|
||||
data(): IData {
|
||||
return {
|
||||
activeOption: undefined,
|
||||
activePackage: undefined
|
||||
};
|
||||
},
|
||||
computed: {
|
||||
showFirstOption() {
|
||||
return this.proxy.free_amount !== 0;
|
||||
},
|
||||
showPackageOption() {
|
||||
return this.proxy && this.proxy.packages && this.proxy?.packages?.length > 0;
|
||||
},
|
||||
showCustomOption() {
|
||||
return this.proxy.price === 0 || this.proxy?.price;
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
if (this.showFirstOption) {
|
||||
this.activeOption = 'first';
|
||||
} else if (this.showPackageOption) {
|
||||
this.activeOption = 'package';
|
||||
// @ts-ignore
|
||||
this.activePackage = this.proxy.packages[0];
|
||||
} else if (this.showCustomOption) {
|
||||
this.activeOption = 'custom';
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
urlJoin,
|
||||
onSelect(option: string, pkg?: IPackage) {
|
||||
this.activeOption = option;
|
||||
this.activePackage = pkg;
|
||||
}
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.title {
|
||||
font-size: 26px;
|
||||
font-weight: 500;
|
||||
line-height: 1.2;
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
|
||||
.introduction {
|
||||
font-size: 14px;
|
||||
margin-bottom: 15px;
|
||||
color: #666;
|
||||
}
|
||||
|
||||
.options {
|
||||
.option {
|
||||
border-radius: 5px !important;
|
||||
}
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
|
||||
.price {
|
||||
.value {
|
||||
font-weight: bold;
|
||||
color: #ff5441;
|
||||
font-size: 24px;
|
||||
}
|
||||
|
||||
.remark {
|
||||
font-size: 14px;
|
||||
color: #999;
|
||||
display: inline-block;
|
||||
margin-left: 5px;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -1,15 +0,0 @@
|
||||
export default {
|
||||
requestQueries: 'URL参数',
|
||||
requestBody: '请求体',
|
||||
responseBody: '响应体',
|
||||
requestHeaders: '请求头',
|
||||
requestHeader: '请求头',
|
||||
responseHeaders: '响应头',
|
||||
response: '响应',
|
||||
success: '成功',
|
||||
failure: '失败',
|
||||
responseExample: '样例',
|
||||
authentication: '认证',
|
||||
arrayOf: '列表',
|
||||
apiKey: 'API Key'
|
||||
};
|
||||
@@ -1,9 +0,0 @@
|
||||
import entity from './entity';
|
||||
import unit from './unit';
|
||||
import message from './message';
|
||||
|
||||
export default {
|
||||
entity,
|
||||
unit,
|
||||
message
|
||||
};
|
||||
@@ -1,8 +0,0 @@
|
||||
export default {
|
||||
free: '免费',
|
||||
appliedCount: '申请次数',
|
||||
firstFree: '首次送',
|
||||
custom: '指定次数',
|
||||
present: '赠送',
|
||||
around: '约'
|
||||
};
|
||||
@@ -1,3 +0,0 @@
|
||||
export default {
|
||||
Count: '次'
|
||||
};
|
||||
@@ -1,7 +0,0 @@
|
||||
export default {
|
||||
goDocument: '查看文档',
|
||||
buyMore: '购买更多',
|
||||
createOrder: '创建订单',
|
||||
custom: '自定义',
|
||||
query: '查询'
|
||||
};
|
||||
@@ -1,18 +0,0 @@
|
||||
export default {
|
||||
id: '申请ID',
|
||||
remainingAmount: '剩余量',
|
||||
usedAmount: '使用量',
|
||||
apiKey: 'API Key',
|
||||
service: '服务',
|
||||
operation: '操作',
|
||||
amount: '数量',
|
||||
shouldPayPrice: '应付金额',
|
||||
api: 'API',
|
||||
proxy: '代理',
|
||||
credential: '密钥',
|
||||
name: '名称',
|
||||
package: '套餐',
|
||||
type: '类型',
|
||||
freeAmount: '免费赠送',
|
||||
extraPrice: '价格'
|
||||
};
|
||||
@@ -1,11 +0,0 @@
|
||||
import field from './field';
|
||||
import button from './button';
|
||||
import message from './message';
|
||||
import title from './title';
|
||||
|
||||
export default {
|
||||
field,
|
||||
button,
|
||||
message,
|
||||
title
|
||||
};
|
||||
@@ -1,21 +0,0 @@
|
||||
export default {
|
||||
alreadyApplied: '已经申请过该服务',
|
||||
applySuccessfully: '申请成功',
|
||||
notApplied: '你尚未申请过该服务,请先申请该服务之后使用',
|
||||
yourApplication: '你的申请',
|
||||
unverified: '您需要完成实名认证之后方可申请该服务',
|
||||
goVerify: '去实名认证',
|
||||
requiredParameter: '必填参数',
|
||||
example: '样例',
|
||||
readPolicy: '我已阅读并同意',
|
||||
policy: '《数据技术服务使用协议》',
|
||||
notAgreePolicy: '您尚未同意《数据技术服务使用协议》',
|
||||
confirmApplying: '申请服务确认',
|
||||
rotateCredential: '重置密钥',
|
||||
rotateCredentialConfirm: '你确定要重置密钥吗?重置后不可恢复',
|
||||
idDoesNotExist: '申请不存在',
|
||||
rotateCredentialSuccessfully: '密钥重置成功',
|
||||
rotateCredentialFailed: '密钥重置失败,请联系处理',
|
||||
updateFailed: '修改失败',
|
||||
updateSuccessfully: '修改成功'
|
||||
};
|
||||
@@ -1,5 +0,0 @@
|
||||
export default {
|
||||
buyService: '购买服务',
|
||||
applicationRemainingCount: '次数修改',
|
||||
manageApplication: '申请管理'
|
||||
};
|
||||
@@ -1,5 +0,0 @@
|
||||
import menu from './menu';
|
||||
|
||||
export default {
|
||||
menu
|
||||
};
|
||||
@@ -1,7 +0,0 @@
|
||||
export default {
|
||||
orderList: '订单列表',
|
||||
applicationList: '申请列表',
|
||||
userProfile: '个人信息',
|
||||
idVerify: '实名认证',
|
||||
manageApplication: '申请管理'
|
||||
};
|
||||
+1
-13
@@ -1,21 +1,9 @@
|
||||
import common from './common';
|
||||
import auth from './auth';
|
||||
import service from './service';
|
||||
import console from './console';
|
||||
import application from './application';
|
||||
import api from './api';
|
||||
import order from './order';
|
||||
import proxy from './proxy';
|
||||
import conversation from './conversation';
|
||||
|
||||
export default {
|
||||
common,
|
||||
conversation,
|
||||
auth,
|
||||
service,
|
||||
console,
|
||||
application,
|
||||
api,
|
||||
order,
|
||||
proxy
|
||||
auth
|
||||
};
|
||||
@@ -1,5 +0,0 @@
|
||||
export default {
|
||||
pay: '支付',
|
||||
continuePay: '继续支付',
|
||||
checkDetail: '查看详情'
|
||||
};
|
||||
@@ -1,12 +0,0 @@
|
||||
export default {
|
||||
id: '订单号',
|
||||
amount: '数量',
|
||||
price: '金额',
|
||||
description: '订单描述',
|
||||
state: '状态',
|
||||
createdAt: '创建时间',
|
||||
service: '服务名称',
|
||||
payWay: '支付方式',
|
||||
api: 'API',
|
||||
proxy: '代理'
|
||||
};
|
||||
@@ -1,13 +0,0 @@
|
||||
import field from './field';
|
||||
import button from './button';
|
||||
import message from './message';
|
||||
import state from './state';
|
||||
import title from './title';
|
||||
|
||||
export default {
|
||||
field,
|
||||
button,
|
||||
message,
|
||||
state,
|
||||
title
|
||||
};
|
||||
@@ -1,6 +0,0 @@
|
||||
export default {
|
||||
paidSuccessfully: '支付成功',
|
||||
createFailed: '创建失败',
|
||||
wechatPayHelp: '请打开手机微信,扫一扫完成支付',
|
||||
free: '免费'
|
||||
};
|
||||
@@ -1,6 +0,0 @@
|
||||
export default {
|
||||
pending: '待支付',
|
||||
paid: '已支付',
|
||||
expired: '支付超时',
|
||||
failed: '支付失败'
|
||||
};
|
||||
@@ -1,5 +0,0 @@
|
||||
export default {
|
||||
info: '订单信息',
|
||||
wechatPay: '微信支付',
|
||||
aliPay: '支付宝'
|
||||
};
|
||||
@@ -1,13 +0,0 @@
|
||||
export default {
|
||||
requestQueries: 'URL参数',
|
||||
requestBody: '请求体',
|
||||
responseBody: '响应体',
|
||||
requestHeaders: '请求头',
|
||||
requestHeader: '请求头',
|
||||
responseHeaders: '响应头',
|
||||
response: '响应',
|
||||
success: '成功',
|
||||
failure: '失败',
|
||||
responseExample: '样例',
|
||||
authentication: '认证'
|
||||
};
|
||||
@@ -1,9 +0,0 @@
|
||||
import entity from './entity';
|
||||
import unit from './unit';
|
||||
import message from './message';
|
||||
|
||||
export default {
|
||||
entity,
|
||||
unit,
|
||||
message
|
||||
};
|
||||
@@ -1,8 +0,0 @@
|
||||
export default {
|
||||
free: '免费',
|
||||
appliedCount: '申请次数',
|
||||
firstFree: '首次送',
|
||||
custom: '指定量',
|
||||
present: '赠送',
|
||||
around: '约'
|
||||
};
|
||||
@@ -1,5 +0,0 @@
|
||||
export default {
|
||||
MB: 'MB',
|
||||
KB: 'KB',
|
||||
B: 'B'
|
||||
};
|
||||
@@ -1,6 +0,0 @@
|
||||
export default {
|
||||
learnMore: '了解更多',
|
||||
apply: '立即申请',
|
||||
introduction: '服务介绍',
|
||||
apis: '接口说明'
|
||||
};
|
||||
@@ -1,5 +0,0 @@
|
||||
export default {
|
||||
price: '价格',
|
||||
introduction: '介绍',
|
||||
apis: 'API'
|
||||
};
|
||||
@@ -1,11 +0,0 @@
|
||||
import message from './message';
|
||||
import unit from './unit';
|
||||
import button from './button';
|
||||
import field from './field';
|
||||
|
||||
export default {
|
||||
message,
|
||||
unit,
|
||||
button,
|
||||
field
|
||||
};
|
||||
@@ -1,7 +0,0 @@
|
||||
export default {
|
||||
free: '免费',
|
||||
appliedCount: '申请次数',
|
||||
indexTitle: '数字化服务的智慧之选',
|
||||
indexSubtitle: '用一个个标准化服务,助力你工作与生活的方方面面。',
|
||||
fromPrice: '起'
|
||||
};
|
||||
@@ -1,5 +0,0 @@
|
||||
export default {
|
||||
count: '次',
|
||||
Count: '次',
|
||||
MB: 'MB'
|
||||
};
|
||||
@@ -1,78 +0,0 @@
|
||||
<template>
|
||||
<div class="container">
|
||||
<el-aside class="aside">
|
||||
<navigator />
|
||||
</el-aside>
|
||||
<el-main class="main"> <router-view /> </el-main>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script lang="ts">
|
||||
import { defineComponent } from 'vue';
|
||||
import Navigator from '@/components/console/Navigator.vue';
|
||||
import { ElMain, ElAside } from 'element-plus';
|
||||
|
||||
export default defineComponent({
|
||||
name: 'LayoutConsole',
|
||||
components: {
|
||||
Navigator,
|
||||
ElMain,
|
||||
ElAside
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.container {
|
||||
display: flex;
|
||||
height: 100vh;
|
||||
width: 100%;
|
||||
max-width: initial;
|
||||
}
|
||||
|
||||
.header {
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
$width: 300px;
|
||||
.aside {
|
||||
width: $width;
|
||||
height: 100%;
|
||||
background-color: white;
|
||||
padding: 15px;
|
||||
padding-top: 50px;
|
||||
}
|
||||
|
||||
.header {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.main {
|
||||
width: calc(100% - $width);
|
||||
background-color: #f3f5f6;
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
@media (max-width: 800px) {
|
||||
.container {
|
||||
display: block;
|
||||
}
|
||||
.aside {
|
||||
display: none;
|
||||
}
|
||||
.header {
|
||||
display: block;
|
||||
background: white;
|
||||
padding: 15px;
|
||||
padding-top: 50px;
|
||||
height: fit-content;
|
||||
overflow: hidden;
|
||||
.logo {
|
||||
width: 100%;
|
||||
}
|
||||
}
|
||||
.main {
|
||||
width: 100%;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -1,79 +0,0 @@
|
||||
<template>
|
||||
<el-container class="wrapper">
|
||||
<el-header class="header">
|
||||
<top-header />
|
||||
</el-header>
|
||||
<el-main class="main">
|
||||
<el-row>
|
||||
<el-col :span="22" :offset="1">
|
||||
<div class="left">
|
||||
<document-list />
|
||||
</div>
|
||||
<router-view />
|
||||
</el-col>
|
||||
</el-row>
|
||||
</el-main>
|
||||
<help-entry class="help" />
|
||||
<el-footer class="footer">
|
||||
<bottom-footer />
|
||||
</el-footer>
|
||||
</el-container>
|
||||
</template>
|
||||
|
||||
<script lang="ts">
|
||||
import TopHeader from '@/components/common/TopHeader.vue';
|
||||
import BottomFooter from '@/components/common/BottomFooter.vue';
|
||||
import DocumentList from '@/components/document/List.vue';
|
||||
import { ElContainer, ElMain, ElFooter, ElHeader, ElRow, ElCol } from 'element-plus';
|
||||
import HelpEntry from '@/components/common/HelpEntry.vue';
|
||||
|
||||
export default {
|
||||
name: 'LayoutCourse',
|
||||
components: {
|
||||
TopHeader,
|
||||
BottomFooter,
|
||||
DocumentList,
|
||||
ElContainer,
|
||||
ElMain,
|
||||
ElFooter,
|
||||
ElHeader,
|
||||
ElRow,
|
||||
ElCol,
|
||||
HelpEntry
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.wrapper {
|
||||
min-height: 100vh;
|
||||
}
|
||||
|
||||
.header {
|
||||
padding: 0;
|
||||
height: initial;
|
||||
}
|
||||
|
||||
.main {
|
||||
// max-width: 2000px;
|
||||
// margin: auto;
|
||||
.left {
|
||||
float: left;
|
||||
width: 280px;
|
||||
height: 100%;
|
||||
padding: 30px;
|
||||
box-shadow: 1px 0 0 #eee;
|
||||
}
|
||||
@media (max-width: 1200px) {
|
||||
.left {
|
||||
display: none;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.help {
|
||||
position: fixed;
|
||||
right: 40px;
|
||||
bottom: 40px;
|
||||
}
|
||||
</style>
|
||||
@@ -1,49 +0,0 @@
|
||||
<template>
|
||||
<el-container class="wrapper">
|
||||
<el-header class="header">
|
||||
<top-header />
|
||||
</el-header>
|
||||
<el-main class="main"> <router-view /> </el-main>
|
||||
<help-entry class="help" />
|
||||
<el-footer class="footer">
|
||||
<bottom-footer />
|
||||
</el-footer>
|
||||
</el-container>
|
||||
</template>
|
||||
|
||||
<script lang="ts">
|
||||
import TopHeader from '@/components/common/TopHeader.vue';
|
||||
import BottomFooter from '@/components/common/BottomFooter.vue';
|
||||
import { ElContainer, ElMain, ElFooter, ElHeader } from 'element-plus';
|
||||
import HelpEntry from '@/components/common/HelpEntry.vue';
|
||||
|
||||
export default {
|
||||
name: 'LayoutService',
|
||||
components: {
|
||||
TopHeader,
|
||||
BottomFooter,
|
||||
ElContainer,
|
||||
ElMain,
|
||||
ElFooter,
|
||||
ElHeader,
|
||||
HelpEntry
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.wrapper {
|
||||
min-height: 100vh;
|
||||
}
|
||||
|
||||
.header {
|
||||
padding: 0;
|
||||
height: initial;
|
||||
}
|
||||
|
||||
.help {
|
||||
position: fixed;
|
||||
right: 40px;
|
||||
bottom: 40px;
|
||||
}
|
||||
</style>
|
||||
@@ -1,6 +1,3 @@
|
||||
import { IDocument } from '../document';
|
||||
import { IService } from '../service';
|
||||
|
||||
export interface IForm {
|
||||
queries?: {
|
||||
[key: string]: string;
|
||||
@@ -73,9 +70,7 @@ export interface IApi {
|
||||
request_id: string;
|
||||
responses: IResponse[];
|
||||
response_ids: string[];
|
||||
document?: IDocument;
|
||||
document_id?: string;
|
||||
service?: IService;
|
||||
packages?: IPackage[];
|
||||
service_id?: string;
|
||||
created_at?: string;
|
||||
|
||||
@@ -1,9 +1,7 @@
|
||||
import { IApi } from '../api';
|
||||
import { IProxy } from '../proxy';
|
||||
|
||||
export enum IApplicationType {
|
||||
API = 'Api',
|
||||
PROXY = 'Proxy'
|
||||
API = 'Api'
|
||||
}
|
||||
|
||||
export enum ICredentialType {
|
||||
@@ -24,7 +22,6 @@ export interface ICredential {
|
||||
export interface IApplication {
|
||||
id?: string;
|
||||
api?: IApi;
|
||||
proxy?: IProxy;
|
||||
type?: IApplicationType;
|
||||
api_id?: string;
|
||||
proxy_id?: string;
|
||||
|
||||
@@ -1,2 +0,0 @@
|
||||
export * from './models';
|
||||
export * from './operator';
|
||||
@@ -1,30 +0,0 @@
|
||||
import { IApi } from '../api/models';
|
||||
import { IProxy } from '../proxy';
|
||||
|
||||
export enum IDocumentType {
|
||||
API = 'Api',
|
||||
TEXT = 'Text',
|
||||
PROXY = 'Proxy'
|
||||
}
|
||||
|
||||
export interface IDocument {
|
||||
id?: string;
|
||||
name?: string;
|
||||
type: IDocumentType;
|
||||
title?: string;
|
||||
content?: string;
|
||||
rank?: number;
|
||||
api?: IApi;
|
||||
proxy?: IProxy;
|
||||
api_id?: string;
|
||||
proxy_id?: string;
|
||||
created_at?: string;
|
||||
updated_at?: string;
|
||||
}
|
||||
|
||||
export interface IDocumentListResponse {
|
||||
count: number;
|
||||
items: IDocument[];
|
||||
}
|
||||
|
||||
export type IDocumentDetailResponse = IDocument;
|
||||
@@ -1,43 +0,0 @@
|
||||
import { AxiosRequestConfig, AxiosResponse } from 'axios';
|
||||
import { httpClient } from '../instance';
|
||||
import { IDocument, IDocumentDetailResponse, IDocumentListResponse } from './models';
|
||||
|
||||
export interface IDocumentQuery {
|
||||
limit: number;
|
||||
offset: number;
|
||||
ordering: string;
|
||||
private: boolean;
|
||||
}
|
||||
|
||||
class DocumentOperator {
|
||||
key = 'documents';
|
||||
|
||||
async getAll(query: IDocumentQuery, config?: AxiosRequestConfig): Promise<AxiosResponse<IDocumentListResponse>> {
|
||||
return await httpClient.get(`/${this.key}/`, {
|
||||
...config,
|
||||
params: query
|
||||
});
|
||||
}
|
||||
|
||||
async get(id: string, config?: AxiosRequestConfig): Promise<AxiosResponse<IDocumentDetailResponse>> {
|
||||
return await httpClient.get(`/${this.key}/${id}`, config);
|
||||
}
|
||||
|
||||
async create(data: IDocument, config?: AxiosRequestConfig): Promise<AxiosResponse<IDocumentDetailResponse>> {
|
||||
return await httpClient.post(`/${this.key}/`, data, config);
|
||||
}
|
||||
|
||||
async update(
|
||||
id: string,
|
||||
data: IDocument,
|
||||
config?: AxiosRequestConfig
|
||||
): Promise<AxiosResponse<IDocumentDetailResponse>> {
|
||||
return await httpClient.put(`/${this.key}/${id}`, data, config);
|
||||
}
|
||||
|
||||
async delete(id: string, config?: AxiosRequestConfig): Promise<AxiosResponse<null>> {
|
||||
return await httpClient.delete(`/${this.key}/${id}`, config);
|
||||
}
|
||||
}
|
||||
|
||||
export const documentOperator = new DocumentOperator();
|
||||
@@ -1,8 +1,4 @@
|
||||
export * from './instance';
|
||||
export * from './application';
|
||||
export * from './service';
|
||||
export * from './user';
|
||||
export * from './api';
|
||||
export * from './document';
|
||||
export * from './order';
|
||||
export * from './proxy';
|
||||
@@ -1,2 +0,0 @@
|
||||
export * from './models';
|
||||
export * from './operator';
|
||||
@@ -1,31 +0,0 @@
|
||||
import { IApplication } from '../application';
|
||||
|
||||
export enum OrderState {
|
||||
PENDING = 'Pending',
|
||||
PAID = 'Paid',
|
||||
EXPIRED = 'Expired',
|
||||
FAILED = 'Failed'
|
||||
}
|
||||
|
||||
export interface IOrder {
|
||||
id?: string;
|
||||
description?: string;
|
||||
state?: OrderState;
|
||||
price?: number;
|
||||
amount?: number;
|
||||
user_id?: number;
|
||||
created_at?: string;
|
||||
updated_at?: string;
|
||||
application?: IApplication;
|
||||
application_id?: string;
|
||||
wechatpay_url?: string;
|
||||
alipay_url?: string;
|
||||
pay_way?: string;
|
||||
}
|
||||
|
||||
export interface IOrderListResponse {
|
||||
count: number;
|
||||
items: IOrder[];
|
||||
}
|
||||
|
||||
export type IOrderDetailResponse = IOrder;
|
||||
@@ -1,47 +0,0 @@
|
||||
import { AxiosResponse } from 'axios';
|
||||
import { httpClient } from '../instance';
|
||||
import { IOrder, IOrderDetailResponse, IOrderListResponse } from './models';
|
||||
|
||||
export interface IOrderQuery {
|
||||
user_id?: string;
|
||||
package_id?: string;
|
||||
offset?: number;
|
||||
limit?: number;
|
||||
ordering: string;
|
||||
}
|
||||
|
||||
class OrderService {
|
||||
key = 'orders';
|
||||
|
||||
async getAll(query: IOrderQuery): Promise<AxiosResponse<IOrderListResponse>> {
|
||||
return await httpClient.get(`/${this.key}/`, {
|
||||
params: query
|
||||
});
|
||||
}
|
||||
|
||||
async get(id: string): Promise<AxiosResponse<IOrderDetailResponse>> {
|
||||
return await httpClient.get(`/${this.key}/${id}`);
|
||||
}
|
||||
|
||||
async create(data: IOrder): Promise<AxiosResponse<IOrderDetailResponse>> {
|
||||
return await httpClient.post(`/${this.key}/`, data);
|
||||
}
|
||||
|
||||
async update(id: string, data: IOrder): Promise<AxiosResponse<IOrderDetailResponse>> {
|
||||
return await httpClient.put(`/${this.key}/${id}`, data);
|
||||
}
|
||||
|
||||
async refresh(id: string): Promise<AxiosResponse<IOrderDetailResponse>> {
|
||||
return await httpClient.post(`/${this.key}/${id}/refresh/`);
|
||||
}
|
||||
|
||||
async pay(id: string, data: IOrder): Promise<AxiosResponse<IOrderDetailResponse>> {
|
||||
return await httpClient.post(`/${this.key}/${id}/pay/`, data);
|
||||
}
|
||||
|
||||
async delete(id: string): Promise<AxiosResponse<null>> {
|
||||
return await httpClient.delete(`/${this.key}/${id}`);
|
||||
}
|
||||
}
|
||||
|
||||
export const orderOperator = new OrderService();
|
||||
@@ -1,2 +0,0 @@
|
||||
export * from './models';
|
||||
export * from './operator';
|
||||
@@ -1,36 +0,0 @@
|
||||
import { IPackage } from '../api';
|
||||
import { IDocument } from '../document';
|
||||
import { IService } from '../service';
|
||||
|
||||
export enum IProxyUnit {
|
||||
MB = 'MB'
|
||||
}
|
||||
|
||||
export interface IProxy {
|
||||
id: string;
|
||||
path: string;
|
||||
endpoint: string;
|
||||
unit?: IProxyUnit;
|
||||
price?: number;
|
||||
title?: string;
|
||||
introduction?: string;
|
||||
applied_count?: number;
|
||||
free_amount?: number;
|
||||
applied?: boolean;
|
||||
application_id?: string;
|
||||
tags?: string[];
|
||||
document?: IDocument;
|
||||
document_id?: string;
|
||||
service?: IService;
|
||||
packages?: IPackage[];
|
||||
service_id?: string;
|
||||
created_at?: string;
|
||||
updated_at?: string;
|
||||
}
|
||||
|
||||
export interface IProxyListResponse {
|
||||
count: number;
|
||||
items: IProxy[];
|
||||
}
|
||||
|
||||
export type IProxyDetailResponse = IProxy;
|
||||
@@ -1,43 +0,0 @@
|
||||
import { AxiosResponse } from 'axios';
|
||||
import { httpClient } from '../instance';
|
||||
import { IProxy, IProxyDetailResponse, IProxyListResponse } from '../proxy/models';
|
||||
|
||||
export interface IProxyQuery {
|
||||
limit?: number;
|
||||
offset?: number;
|
||||
ordering?: string;
|
||||
}
|
||||
|
||||
class ProxyOperator {
|
||||
key = 'proxies';
|
||||
|
||||
async getAll(query: IProxyQuery): Promise<AxiosResponse<IProxyListResponse>> {
|
||||
return await httpClient.get(`/${this.key}/`, {
|
||||
params: query
|
||||
});
|
||||
}
|
||||
|
||||
async get(id: string): Promise<AxiosResponse<IProxyDetailResponse>> {
|
||||
return await httpClient.get(`/${this.key}/${id}`);
|
||||
}
|
||||
|
||||
async create(data: IProxy): Promise<AxiosResponse<IProxyDetailResponse>> {
|
||||
return await httpClient.post(`/${this.key}/`, data);
|
||||
}
|
||||
|
||||
async update(id: string, data: IProxy): Promise<AxiosResponse<IProxyDetailResponse>> {
|
||||
return await httpClient.put(`/${this.key}/${id}`, data);
|
||||
}
|
||||
|
||||
async delete(id: string): Promise<AxiosResponse<null>> {
|
||||
return await httpClient.delete(`/${this.key}/${id}`);
|
||||
}
|
||||
|
||||
async getAllForService(serviceId: string, query: IProxyQuery): Promise<AxiosResponse<IProxyListResponse>> {
|
||||
return await httpClient.get(`/services/${serviceId}/${this.key}/`, {
|
||||
params: query
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
export const proxyOperator = new ProxyOperator();
|
||||
@@ -1,2 +0,0 @@
|
||||
export * from './models';
|
||||
export * from './operator';
|
||||
@@ -1,23 +0,0 @@
|
||||
import { IApi } from '../api/models';
|
||||
|
||||
export interface IService {
|
||||
id: string;
|
||||
title: string;
|
||||
unit?: string;
|
||||
price?: number;
|
||||
description?: string;
|
||||
tags?: string[];
|
||||
thumbnail?: string;
|
||||
introduction?: string;
|
||||
api_ids?: string[];
|
||||
apis?: IApi[];
|
||||
created_at?: string;
|
||||
updated_at?: string;
|
||||
}
|
||||
|
||||
export interface IServiceListResponse {
|
||||
count: number;
|
||||
items: IService[];
|
||||
}
|
||||
|
||||
export type IServiceDetailResponse = IService;
|
||||
@@ -1,38 +0,0 @@
|
||||
import { AxiosResponse } from 'axios';
|
||||
import { httpClient } from '../instance';
|
||||
import { IService, IServiceDetailResponse, IServiceListResponse } from './models';
|
||||
|
||||
export interface IServiceQuery {
|
||||
limit: number;
|
||||
offset: number;
|
||||
ordering: string;
|
||||
private: boolean;
|
||||
}
|
||||
|
||||
class ServiceOperator {
|
||||
key = 'services';
|
||||
|
||||
async getAll(query: IServiceQuery): Promise<AxiosResponse<IServiceListResponse>> {
|
||||
return await httpClient.get(`/${this.key}/`, {
|
||||
params: query
|
||||
});
|
||||
}
|
||||
|
||||
async get(id: string): Promise<AxiosResponse<IServiceDetailResponse>> {
|
||||
return await httpClient.get(`/${this.key}/${id}`);
|
||||
}
|
||||
|
||||
async create(data: IService): Promise<AxiosResponse<IServiceDetailResponse>> {
|
||||
return await httpClient.post(`/${this.key}/`, data);
|
||||
}
|
||||
|
||||
async update(id: string, data: IService): Promise<AxiosResponse<IServiceDetailResponse>> {
|
||||
return await httpClient.put(`/${this.key}/${id}`, data);
|
||||
}
|
||||
|
||||
async delete(id: string): Promise<AxiosResponse<null>> {
|
||||
return await httpClient.delete(`/${this.key}/${id}`);
|
||||
}
|
||||
}
|
||||
|
||||
export const serviceOperator = new ServiceOperator();
|
||||
@@ -1,7 +1,7 @@
|
||||
<script lang="ts">
|
||||
import { defineComponent } from 'vue';
|
||||
import { getCookie, removeCookie } from 'typescript-cookie';
|
||||
import { getAuthBaseUrl, getDataBaseUrl } from '@/utils';
|
||||
import { getCookie } from 'typescript-cookie';
|
||||
import { getAuthBaseUrl, getChatBaseUrl } from '@/utils';
|
||||
import { removeCookies } from '@/utils/cookie';
|
||||
|
||||
interface IData {
|
||||
@@ -37,10 +37,10 @@ export default defineComponent({
|
||||
}
|
||||
} else {
|
||||
console.debug('access token and refresh token not found, try to re-auth again');
|
||||
const dataBaseUrl = getDataBaseUrl();
|
||||
const chatBaseUrl = getChatBaseUrl();
|
||||
const authBaseUrl = getAuthBaseUrl();
|
||||
// callback url used to init access token and then redirect back of `redirect`
|
||||
const callbackUrl = `${dataBaseUrl}/auth/callback?redirect=${this.redirect}`;
|
||||
const callbackUrl = `${chatBaseUrl}/auth/callback?redirect=${this.redirect}`;
|
||||
// redirect to auth service to get access token then redirect back
|
||||
const targetUrl = `${authBaseUrl}/auth/login?redirect=${callbackUrl}`;
|
||||
window.location.href = targetUrl;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<script lang="ts">
|
||||
import { getAuthBaseUrl, getDataBaseUrl } from '@/utils';
|
||||
import { getAuthBaseUrl, getChatBaseUrl } from '@/utils';
|
||||
import { defineComponent } from 'vue';
|
||||
|
||||
interface IData {
|
||||
@@ -14,10 +14,10 @@ export default defineComponent({
|
||||
};
|
||||
},
|
||||
async mounted() {
|
||||
const dataBaseUrl = getDataBaseUrl();
|
||||
const chatBaseUrl = getChatBaseUrl();
|
||||
const authBaseUrl = getAuthBaseUrl();
|
||||
// callback url used to init access token and then redirect back of `redirect`
|
||||
const callbackUrl = `${dataBaseUrl}/auth/callback?redirect=${this.redirect}`;
|
||||
const callbackUrl = `${chatBaseUrl}/auth/callback?redirect=${this.redirect}`;
|
||||
// redirect to auth service to get access token then redirect back
|
||||
const targetUrl = `${authBaseUrl}/auth/login?redirect=${callbackUrl}`;
|
||||
window.location.href = targetUrl;
|
||||
|
||||
@@ -1,142 +0,0 @@
|
||||
<template>
|
||||
<el-row class="panel">
|
||||
<el-col :span="24">
|
||||
<el-row>
|
||||
<el-col :span="24">
|
||||
<h2 class="title">{{ $t('application.title.manageApplication') }}</h2>
|
||||
</el-col>
|
||||
</el-row>
|
||||
<el-row>
|
||||
<el-col :span="24">
|
||||
<el-card shadow="hover">
|
||||
<el-row>
|
||||
<el-col :span="12" :offset="6">
|
||||
<el-form :inline="true" label-width="120px">
|
||||
<el-form-item :label="$t('application.field.id')">
|
||||
<el-input v-model="id" />
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-button type="primary" :loading="loading" @click="onQuery">
|
||||
{{ $t('application.button.query') }}
|
||||
</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<el-divider border-style="dashed" />
|
||||
<el-form v-if="application" :inline="true" label-width="120px">
|
||||
<el-form-item :label="$t('application.field.remainingAmount')">
|
||||
<el-input v-model="application.remaining_amount" />
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-button type="primary" :loading="updating" @click="onUpdateRemainingAmount">
|
||||
{{ $t('common.button.update') }}
|
||||
</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
</el-col>
|
||||
</el-row>
|
||||
</el-card>
|
||||
</el-col>
|
||||
</el-row>
|
||||
</el-col>
|
||||
</el-row>
|
||||
</template>
|
||||
|
||||
<script lang="ts">
|
||||
import { defineComponent } from 'vue';
|
||||
import { applicationOperator, IApplication, IApplicationDetailResponse } from '@/operators';
|
||||
import { ElRow, ElCol, ElCard, ElForm, ElFormItem, ElInput, ElButton, ElDivider, ElMessage } from 'element-plus';
|
||||
|
||||
interface IData {
|
||||
application: IApplication | undefined;
|
||||
loading: boolean;
|
||||
updating: boolean;
|
||||
|
||||
id: string | undefined;
|
||||
}
|
||||
|
||||
export default defineComponent({
|
||||
name: 'ConsoleApplication',
|
||||
components: {
|
||||
ElRow,
|
||||
ElCol,
|
||||
ElCard,
|
||||
ElForm,
|
||||
ElFormItem,
|
||||
ElInput,
|
||||
ElButton,
|
||||
ElDivider
|
||||
},
|
||||
data(): IData {
|
||||
return {
|
||||
application: undefined,
|
||||
id: undefined,
|
||||
loading: false,
|
||||
updating: false
|
||||
};
|
||||
},
|
||||
computed: {},
|
||||
methods: {
|
||||
onQuery() {
|
||||
if (!this.id) {
|
||||
return;
|
||||
}
|
||||
this.loading = true;
|
||||
applicationOperator
|
||||
.get(this.id)
|
||||
.then(({ data: data }: { data: IApplicationDetailResponse }) => {
|
||||
this.application = data;
|
||||
this.loading = false;
|
||||
})
|
||||
.catch(() => {
|
||||
this.loading = false;
|
||||
});
|
||||
},
|
||||
onUpdateRemainingAmount() {
|
||||
if (!this.id) {
|
||||
return;
|
||||
}
|
||||
this.updating = true;
|
||||
applicationOperator
|
||||
.updateRemainingAmount(this.id, {
|
||||
remaining_amount: this.application?.remaining_amount
|
||||
})
|
||||
.then(({ data: data }: { data: IApplicationDetailResponse }) => {
|
||||
this.application = data;
|
||||
this.updating = false;
|
||||
ElMessage.success(this.$t('application.message.updateSuccessfully'));
|
||||
})
|
||||
.catch(() => {
|
||||
this.updating = false;
|
||||
ElMessage.error(this.$t('application.message.updateFailed'));
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.title {
|
||||
font-size: 26px;
|
||||
font-weight: bold;
|
||||
margin-bottom: 20px;
|
||||
color: #333;
|
||||
}
|
||||
|
||||
.el-card {
|
||||
min-height: 500px;
|
||||
padding-top: 50px;
|
||||
}
|
||||
|
||||
.panel {
|
||||
padding: 30px;
|
||||
.credential {
|
||||
.copy {
|
||||
cursor: pointer;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.pagination {
|
||||
float: right;
|
||||
}
|
||||
</style>
|
||||
@@ -1,102 +0,0 @@
|
||||
<template>
|
||||
<el-row class="panel">
|
||||
<el-col :span="24">
|
||||
<el-row>
|
||||
<el-col :span="24">
|
||||
<h2 class="title">{{ $t('common.title.buyMore') }}</h2>
|
||||
</el-col>
|
||||
</el-row>
|
||||
<el-row>
|
||||
<el-col :span="24">
|
||||
<el-card shadow="hover">
|
||||
<el-row>
|
||||
<el-col :span="12" :offset="6">
|
||||
<el-skeleton v-if="loading" />
|
||||
<create-order v-else-if="application" :application="application" />
|
||||
</el-col>
|
||||
</el-row>
|
||||
</el-card>
|
||||
</el-col>
|
||||
</el-row>
|
||||
</el-col>
|
||||
</el-row>
|
||||
</template>
|
||||
|
||||
<script lang="ts">
|
||||
import { defineComponent } from 'vue';
|
||||
import { applicationOperator, IApplication, IApplicationDetailResponse } from '@/operators';
|
||||
import CreateOrder from '@/components/order/Create.vue';
|
||||
import { ElRow, ElCol, ElCard, ElSkeleton } from 'element-plus';
|
||||
|
||||
interface IData {
|
||||
application: IApplication | undefined;
|
||||
loading: boolean;
|
||||
}
|
||||
|
||||
export default defineComponent({
|
||||
name: 'ConsoleApplicationBuy',
|
||||
components: {
|
||||
CreateOrder,
|
||||
ElSkeleton,
|
||||
ElRow,
|
||||
ElCol,
|
||||
ElCard
|
||||
},
|
||||
data(): IData {
|
||||
return {
|
||||
application: undefined,
|
||||
loading: false
|
||||
};
|
||||
},
|
||||
computed: {
|
||||
id() {
|
||||
return this.$route.params?.id?.toString();
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
console.log('this', this.id);
|
||||
this.onFetchData();
|
||||
},
|
||||
methods: {
|
||||
onFetchData() {
|
||||
this.loading = true;
|
||||
applicationOperator
|
||||
.get(this.id)
|
||||
.then(({ data: data }: { data: IApplicationDetailResponse }) => {
|
||||
this.application = data;
|
||||
this.loading = false;
|
||||
})
|
||||
.catch(() => {
|
||||
this.loading = false;
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.title {
|
||||
font-size: 26px;
|
||||
font-weight: bold;
|
||||
margin-bottom: 20px;
|
||||
color: #333;
|
||||
}
|
||||
|
||||
.el-card {
|
||||
min-height: 500px;
|
||||
padding-top: 50px;
|
||||
}
|
||||
|
||||
.panel {
|
||||
padding: 30px;
|
||||
.credential {
|
||||
.copy {
|
||||
cursor: pointer;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.pagination {
|
||||
float: right;
|
||||
}
|
||||
</style>
|
||||
@@ -1,327 +0,0 @@
|
||||
<template>
|
||||
<el-row class="panel">
|
||||
<el-col :span="24">
|
||||
<el-row>
|
||||
<el-col :span="24">
|
||||
<h2 class="title">{{ $t('common.title.allApplications') }}</h2>
|
||||
</el-col>
|
||||
</el-row>
|
||||
<el-row>
|
||||
<el-col :span="24">
|
||||
<el-card shadow="hover">
|
||||
<el-menu :default-active="type" class="mb-4" mode="horizontal" @select="onFilterType">
|
||||
<el-menu-item :index="applicationType.API">{{ $t('application.field.api') }}</el-menu-item>
|
||||
<el-menu-item :index="applicationType.PROXY">{{ $t('application.field.proxy') }}</el-menu-item>
|
||||
</el-menu>
|
||||
<el-table v-loading="loading" :data="applications" stripe table-layout="fixed">
|
||||
<el-table-column prop="id" :label="$t('application.field.id')" width="350px" class-name="text-center">
|
||||
<template #default="scope">
|
||||
<span>{{ scope.row.id }}</span>
|
||||
<span class="copy">
|
||||
<copy-to-clipboard :content="scope?.row?.id" />
|
||||
</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column :label="$t('application.field.name')" width="220px">
|
||||
<template #default="scope">
|
||||
<span v-if="scope.row.type === applicationType.API">{{ scope.row?.api?.title }}</span>
|
||||
<span v-if="scope.row.type === applicationType.PROXY">{{ scope.row?.proxy?.title }}</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column
|
||||
prop="remaining_amount"
|
||||
:label="$t('application.field.remainingAmount')"
|
||||
width="120px"
|
||||
class-name="text-center"
|
||||
>
|
||||
<template #default="scope">
|
||||
<span>{{ getRemainingAmount(scope.row) }}</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column
|
||||
prop="used_amount"
|
||||
:label="$t('application.field.usedAmount')"
|
||||
width="120px"
|
||||
class-name="text-center"
|
||||
>
|
||||
<template #default="scope">
|
||||
<span>{{ getUsedAmount(scope.row) }}</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column :label="$t('application.field.credential')" class-name="credential" width="380px">
|
||||
<template #default="scope">
|
||||
<div v-if="scope?.row?.credential?.type === credentialType.TOKEN">
|
||||
<span class="key">{{ scope?.row?.credential?.token }}</span>
|
||||
<span class="copy">
|
||||
<copy-to-clipboard :content="scope?.row?.credential?.token" />
|
||||
</span>
|
||||
<span class="rotate">
|
||||
<rotate-credential @rotate="onRotateCredential(scope.row)" />
|
||||
</span>
|
||||
</div>
|
||||
<div v-if="scope?.row?.credential?.type === credentialType.IDENTITY">
|
||||
<span class="key"
|
||||
>{{ scope?.row?.credential?.username }}:{{ scope?.row?.credential?.password }}</span
|
||||
>
|
||||
<span class="copy">
|
||||
<copy-to-clipboard
|
||||
:content="`${scope?.row?.credential?.username}:${scope?.row?.credential?.password}`"
|
||||
/>
|
||||
</span>
|
||||
</div>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column fixed="right" width="220px">
|
||||
<template #default="scope">
|
||||
<div class="float-right">
|
||||
<el-button v-if="scope.row?.api?.document_id" @click="onGoDocument(scope?.row)">
|
||||
{{ $t('application.button.goDocument') }}
|
||||
</el-button>
|
||||
<el-button type="primary" @click="onBuyMore(scope?.row)">
|
||||
{{ $t('application.button.buyMore') }}
|
||||
</el-button>
|
||||
</div>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
</el-card>
|
||||
</el-col>
|
||||
</el-row>
|
||||
<el-row>
|
||||
<el-col :span="10" :offset="14">
|
||||
<div class="pagination m-v-lg">
|
||||
<pagination :current-page="page" :page-size="limit" :total="total" @change="onPageChange"> </pagination>
|
||||
</div>
|
||||
</el-col>
|
||||
</el-row>
|
||||
</el-col>
|
||||
</el-row>
|
||||
<create-order v-if="active.application" :visible="buying" :application="active.application" @hide="buying = false" />
|
||||
</template>
|
||||
|
||||
<script lang="ts">
|
||||
import { defineComponent } from 'vue';
|
||||
import {
|
||||
applicationOperator,
|
||||
IApplication,
|
||||
IApplicationDetailResponse,
|
||||
IApplicationListResponse,
|
||||
IApplicationType,
|
||||
ICredentialType,
|
||||
IService
|
||||
} from '@/operators';
|
||||
import Pagination from '@/components/common/Pagination.vue';
|
||||
import CopyToClipboard from '@/components/common/CopyToClipboard.vue';
|
||||
import RotateCredential from '@/components/application/RotateCredential.vue';
|
||||
import CreateOrder from '@/components/order/Create.vue';
|
||||
import { ElTable, ElRow, ElCol, ElTableColumn, ElButton, ElCard, ElMenu, ElMenuItem, ElMessage } from 'element-plus';
|
||||
import { ROUTE_CONSOLE_APPLICATION_BUY, ROUTE_DOCUMENT_DETAIL } from '@/router/constants';
|
||||
|
||||
interface IData {
|
||||
applications: IApplication[];
|
||||
loading: boolean;
|
||||
total: number | undefined;
|
||||
limit: number;
|
||||
buying: boolean;
|
||||
form: {
|
||||
amount: number | undefined;
|
||||
};
|
||||
active: {
|
||||
service: IService | undefined;
|
||||
application: IApplication | undefined;
|
||||
};
|
||||
applicationType: typeof IApplicationType;
|
||||
credentialType: typeof ICredentialType;
|
||||
}
|
||||
|
||||
export default defineComponent({
|
||||
name: 'ConsoleApplicationList',
|
||||
components: {
|
||||
Pagination,
|
||||
CopyToClipboard,
|
||||
RotateCredential,
|
||||
CreateOrder,
|
||||
ElTable,
|
||||
ElRow,
|
||||
ElCol,
|
||||
ElTableColumn,
|
||||
ElButton,
|
||||
ElCard,
|
||||
ElMenu,
|
||||
ElMenuItem
|
||||
},
|
||||
data(): IData {
|
||||
return {
|
||||
credentialType: ICredentialType,
|
||||
applicationType: IApplicationType,
|
||||
applications: [],
|
||||
loading: false,
|
||||
total: undefined,
|
||||
buying: false,
|
||||
limit: 10,
|
||||
form: {
|
||||
amount: 1
|
||||
},
|
||||
active: {
|
||||
service: undefined,
|
||||
application: undefined
|
||||
}
|
||||
};
|
||||
},
|
||||
computed: {
|
||||
redirect() {
|
||||
return this.$route.query?.redirect;
|
||||
},
|
||||
page() {
|
||||
return parseInt(this.$route.query.page?.toString() || '1');
|
||||
},
|
||||
type() {
|
||||
return (this.$route.query.type?.toString() || IApplicationType.API) as IApplicationType;
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
page: {
|
||||
handler() {
|
||||
this.onFetchData();
|
||||
}
|
||||
},
|
||||
type: {
|
||||
handler() {
|
||||
this.onFetchData();
|
||||
}
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
this.onFetchData();
|
||||
},
|
||||
methods: {
|
||||
onFilterType(type: string) {
|
||||
if (type === this.type) {
|
||||
return;
|
||||
}
|
||||
this.$router.push({
|
||||
...this.$route,
|
||||
query: {
|
||||
...this.$route.query,
|
||||
page: 1,
|
||||
type
|
||||
}
|
||||
});
|
||||
},
|
||||
onRotateCredential(application: IApplication) {
|
||||
const id = application.id;
|
||||
if (!id) {
|
||||
ElMessage.error(this.$t('application.message.idDoesNotExist'));
|
||||
return;
|
||||
}
|
||||
applicationOperator
|
||||
.rotateCredential(id)
|
||||
.then(({ data: data }: { data: IApplicationDetailResponse }) => {
|
||||
console.log('rotate successfully');
|
||||
ElMessage.success(this.$t('application.message.rotateCredentialSuccessfully'));
|
||||
application.credential = data.credential;
|
||||
})
|
||||
.catch(() => {
|
||||
ElMessage.error(this.$t('application.message.rotateCredentialFailed'));
|
||||
});
|
||||
},
|
||||
onGoDocument(application: IApplication) {
|
||||
const documentId = application?.api?.document_id;
|
||||
this.$router.push({
|
||||
name: ROUTE_DOCUMENT_DETAIL,
|
||||
params: {
|
||||
id: documentId
|
||||
}
|
||||
});
|
||||
},
|
||||
onBuyMore(application: IApplication) {
|
||||
// this.active.application = application;
|
||||
// this.buying = true;
|
||||
this.$router.push({
|
||||
name: ROUTE_CONSOLE_APPLICATION_BUY,
|
||||
params: {
|
||||
id: application.id
|
||||
}
|
||||
});
|
||||
},
|
||||
onPageChange(page: number) {
|
||||
this.$router.push({
|
||||
name: this.$route.name?.toString(),
|
||||
query: {
|
||||
...this.$route.query,
|
||||
page: page
|
||||
}
|
||||
});
|
||||
},
|
||||
onFetchData() {
|
||||
this.loading = true;
|
||||
applicationOperator
|
||||
.getAll({
|
||||
limit: this.limit,
|
||||
offset: (this.page - 1) * this.limit,
|
||||
user_id: this.$store.getters.user.id,
|
||||
type: this.type,
|
||||
ordering: '-created_at'
|
||||
})
|
||||
.then(({ data: data }: { data: IApplicationListResponse }) => {
|
||||
this.applications = data.items;
|
||||
this.loading = false;
|
||||
this.total = data.count;
|
||||
})
|
||||
.catch(() => {
|
||||
this.loading = false;
|
||||
});
|
||||
},
|
||||
getRemainingAmount(application: IApplication) {
|
||||
if (application.type === IApplicationType.API) {
|
||||
const unit = this.$t(`api.unit.${application?.api?.unit}`);
|
||||
return `${application.remaining_amount}${unit}`;
|
||||
}
|
||||
if (application.type === IApplicationType.PROXY) {
|
||||
const unit = this.$t(`proxy.unit.${application?.proxy?.unit}`);
|
||||
if (unit === 'MB') {
|
||||
return `${(application.remaining_amount || 0).toFixed(2)}${unit}`;
|
||||
}
|
||||
}
|
||||
},
|
||||
getUsedAmount(application: IApplication) {
|
||||
if (application.type === IApplicationType.API) {
|
||||
const unit = this.$t(`api.unit.${application?.api?.unit}`);
|
||||
return `${application.used_amount}${unit}`;
|
||||
}
|
||||
if (application.type === IApplicationType.PROXY) {
|
||||
const unit = this.$t(`proxy.unit.${application?.proxy?.unit}`);
|
||||
if (unit === 'MB') {
|
||||
return `${((application.used_amount || 0) / 1024 / 1024).toFixed(2)}${unit}`;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.title {
|
||||
font-size: 26px;
|
||||
font-weight: bold;
|
||||
margin-bottom: 20px;
|
||||
color: #333;
|
||||
}
|
||||
.el-table {
|
||||
min-height: calc(100vh - 350px);
|
||||
margin-bottom: 50px;
|
||||
}
|
||||
|
||||
.panel {
|
||||
padding: 30px;
|
||||
.credential {
|
||||
.copy {
|
||||
cursor: pointer;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.pagination {
|
||||
float: right;
|
||||
}
|
||||
</style>
|
||||
@@ -1,307 +0,0 @@
|
||||
<template>
|
||||
<el-row class="wrapper">
|
||||
<el-col :span="24">
|
||||
<el-row>
|
||||
<el-col :span="24">
|
||||
<h2 class="title">{{ $t('order.title.info') }}</h2>
|
||||
</el-col>
|
||||
</el-row>
|
||||
<el-row class="panel">
|
||||
<el-col :span="24">
|
||||
<el-card shadow="hover">
|
||||
<el-row>
|
||||
<el-col :span="12" :offset="6">
|
||||
<div v-if="loading" class="pt-5">
|
||||
<el-skeleton animated />
|
||||
</div>
|
||||
<div v-else class="order">
|
||||
<el-descriptions :column="1">
|
||||
<el-descriptions-item :label="$t('order.field.id')">{{ order?.id }}</el-descriptions-item>
|
||||
<el-descriptions-item :label="$t('order.field.description')">
|
||||
{{ order?.description }}
|
||||
</el-descriptions-item>
|
||||
<el-descriptions-item
|
||||
v-if="order?.application?.type === applicationType.API"
|
||||
:label="$t('order.field.api')"
|
||||
>
|
||||
{{ order?.application?.api?.title }}
|
||||
</el-descriptions-item>
|
||||
<el-descriptions-item
|
||||
v-if="order?.application?.type === applicationType.PROXY"
|
||||
:label="$t('order.field.proxy')"
|
||||
>
|
||||
{{ order?.application?.proxy?.title }}
|
||||
</el-descriptions-item>
|
||||
<el-descriptions-item :label="$t('order.field.amount')">
|
||||
<span v-if="order?.application?.type === applicationType.API">
|
||||
{{ order?.amount }}{{ $t(`api.unit.${order?.application?.api?.unit}`) }}
|
||||
</span>
|
||||
<span v-if="order?.application?.type === applicationType.PROXY">
|
||||
{{ order?.amount }}{{ $t(`proxy.unit.${order?.application?.proxy?.unit}`) }}
|
||||
</span>
|
||||
</el-descriptions-item>
|
||||
<el-descriptions-item :label="$t('order.field.createdAt')">
|
||||
{{ $dayjs.format(order?.created_at) }}
|
||||
</el-descriptions-item>
|
||||
<el-descriptions-item :label="$t('order.field.price')">
|
||||
<span v-if="order?.price && order?.price > 0" class="price unfree">
|
||||
¥{{ order?.price?.toFixed(2) }}
|
||||
</span>
|
||||
<span v-else class="price free"> {{ $t('order.message.free') }} </span>
|
||||
</el-descriptions-item>
|
||||
<el-descriptions-item v-if="order?.pay_way" :label="$t('order.field.payWay')">
|
||||
<span v-if="order?.pay_way === PayWay.WechatPay">
|
||||
{{ $t('order.title.wechatPay') }}
|
||||
</span>
|
||||
<span v-if="order?.pay_way === PayWay.AliPay">
|
||||
{{ $t('order.title.aliPay') }}
|
||||
</span>
|
||||
</el-descriptions-item>
|
||||
</el-descriptions>
|
||||
</div>
|
||||
</el-col>
|
||||
</el-row>
|
||||
<el-row v-if="order?.state === OrderState.PAID" class="mb-5">
|
||||
<el-col :span="12" :offset="6">
|
||||
<el-divider border-style="dashed" />
|
||||
<el-alert :title="$t('order.message.paidSuccessfully')" type="success" show-icon :closable="false" />
|
||||
</el-col>
|
||||
</el-row>
|
||||
<el-row v-if="order?.state === OrderState.PENDING || order?.state === OrderState.FAILED">
|
||||
<el-col :span="12" :offset="6">
|
||||
<el-divider border-style="dashed" />
|
||||
<div v-if="order.price && order.price > 0 && !order.pay_way" class="payways mb-4">
|
||||
<div
|
||||
:class="{
|
||||
payway: true,
|
||||
wechatpay: true,
|
||||
active: payWay === PayWay.WechatPay
|
||||
}"
|
||||
@click="payWay = PayWay.WechatPay"
|
||||
>
|
||||
<span class="payicon wechatpay"></span>
|
||||
{{ $t('order.title.wechatPay') }}
|
||||
</div>
|
||||
<div
|
||||
v-if="false"
|
||||
:class="{
|
||||
payway: true,
|
||||
alipay: true,
|
||||
active: payWay === PayWay.AliPay
|
||||
}"
|
||||
@click="payWay = PayWay.AliPay"
|
||||
>
|
||||
<span class="payicon alipay"></span>
|
||||
{{ $t('order.title.aliPay') }}
|
||||
</div>
|
||||
</div>
|
||||
<div v-if="!order?.pay_way">
|
||||
<el-button :loading="prepaying" type="primary" size="large" class="btn-pay" @click="onPay">{{
|
||||
$t('common.button.pay')
|
||||
}}</el-button>
|
||||
</div>
|
||||
<div v-else>
|
||||
<el-button type="primary" size="large" class="btn-repay" @click="onRepay">{{
|
||||
$t('common.button.repay')
|
||||
}}</el-button>
|
||||
</div>
|
||||
</el-col>
|
||||
</el-row>
|
||||
</el-card>
|
||||
</el-col>
|
||||
</el-row>
|
||||
</el-col>
|
||||
</el-row>
|
||||
<pay-order v-if="order" v-model="order" :visible="paying" @hide="paying = false" />
|
||||
</template>
|
||||
|
||||
<script lang="ts">
|
||||
import { defineComponent } from 'vue';
|
||||
import { IOrder, IOrderDetailResponse, orderOperator, OrderState } from '@/operators/order';
|
||||
import {
|
||||
ElRow,
|
||||
ElCol,
|
||||
ElCard,
|
||||
ElSkeleton,
|
||||
ElDivider,
|
||||
ElAlert,
|
||||
ElDescriptions,
|
||||
ElDescriptionsItem,
|
||||
ElButton
|
||||
} from 'element-plus';
|
||||
import PayOrder from '@/components/order/Pay.vue';
|
||||
import { IApplicationType } from '@/operators';
|
||||
|
||||
enum PayWay {
|
||||
WechatPay = 'WechatPay',
|
||||
AliPay = 'AliPay'
|
||||
}
|
||||
|
||||
interface IData {
|
||||
PayWay: typeof PayWay;
|
||||
OrderState: typeof OrderState;
|
||||
payWay: PayWay | undefined;
|
||||
order: IOrder | undefined;
|
||||
loading: boolean;
|
||||
paying: boolean;
|
||||
prepaying: boolean;
|
||||
applicationType: typeof IApplicationType;
|
||||
}
|
||||
|
||||
export default defineComponent({
|
||||
name: 'ConsoleOrderDetail',
|
||||
components: {
|
||||
ElButton,
|
||||
ElRow,
|
||||
ElCol,
|
||||
ElCard,
|
||||
ElSkeleton,
|
||||
ElDivider,
|
||||
ElAlert,
|
||||
ElDescriptions,
|
||||
ElDescriptionsItem,
|
||||
PayOrder
|
||||
},
|
||||
data(): IData {
|
||||
return {
|
||||
PayWay: PayWay,
|
||||
payWay: PayWay.WechatPay,
|
||||
OrderState: OrderState,
|
||||
order: undefined,
|
||||
loading: false,
|
||||
paying: false,
|
||||
prepaying: false,
|
||||
applicationType: IApplicationType
|
||||
};
|
||||
},
|
||||
computed: {
|
||||
id() {
|
||||
return this.$route.params?.id?.toString();
|
||||
},
|
||||
redirect() {
|
||||
return this.$route.query?.redirect;
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
order: {
|
||||
handler(val) {
|
||||
if (val?.state === OrderState.PAID) {
|
||||
setTimeout(() => {
|
||||
if (this.redirect) {
|
||||
window.location.replace(this.redirect?.toString());
|
||||
}
|
||||
}, 2000);
|
||||
return;
|
||||
}
|
||||
},
|
||||
deep: true
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
this.onFetchData();
|
||||
},
|
||||
methods: {
|
||||
onFetchData() {
|
||||
this.loading = true;
|
||||
orderOperator
|
||||
.refresh(this.id)
|
||||
.then(({ data: data }: { data: IOrderDetailResponse }) => {
|
||||
this.order = data;
|
||||
this.loading = false;
|
||||
})
|
||||
.catch(() => {
|
||||
this.loading = false;
|
||||
});
|
||||
},
|
||||
onRepay() {
|
||||
this.paying = true;
|
||||
},
|
||||
onPay() {
|
||||
this.prepaying = true;
|
||||
orderOperator
|
||||
.pay(this.id, {
|
||||
pay_way: this.payWay
|
||||
})
|
||||
.then(({ data: data }: { data: IOrderDetailResponse }) => {
|
||||
this.prepaying = false;
|
||||
this.order = data;
|
||||
if (this.order.price && this.order.price > 0) {
|
||||
this.paying = true;
|
||||
}
|
||||
})
|
||||
.catch(() => {
|
||||
this.prepaying = false;
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.title {
|
||||
font-size: 26px;
|
||||
font-weight: bold;
|
||||
margin-bottom: 20px;
|
||||
color: #333;
|
||||
}
|
||||
|
||||
.wrapper {
|
||||
padding: 30px;
|
||||
|
||||
.panel {
|
||||
.el-card {
|
||||
min-height: 500px;
|
||||
}
|
||||
.order {
|
||||
padding-top: 50px;
|
||||
.price {
|
||||
font-size: 20px;
|
||||
font-weight: bold;
|
||||
&.unfree {
|
||||
color: #ff5441;
|
||||
}
|
||||
&.free {
|
||||
color: #29c287;
|
||||
}
|
||||
}
|
||||
}
|
||||
.payways {
|
||||
overflow: hidden;
|
||||
.payway {
|
||||
cursor: pointer;
|
||||
font-size: 14px;
|
||||
float: left;
|
||||
width: 120px;
|
||||
line-height: 40px;
|
||||
text-align: center;
|
||||
height: 40px;
|
||||
border: 1px solid #eee;
|
||||
&.active {
|
||||
border: 1px solid #3879d1;
|
||||
}
|
||||
}
|
||||
|
||||
.payicon {
|
||||
width: 20px;
|
||||
height: 20px;
|
||||
margin-top: 2px;
|
||||
display: inline-block;
|
||||
&.wechatpay {
|
||||
position: relative;
|
||||
top: 3px;
|
||||
width: 22px;
|
||||
height: 19px;
|
||||
background-image: url(//midas.gtimg.cn/enterprise/images/ep_new_sprites@2x.png);
|
||||
background-repeat: no-repeat;
|
||||
background-size: 60px 250px;
|
||||
background-position: 0 -50px;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.btn-pay {
|
||||
width: 150px;
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -1,211 +0,0 @@
|
||||
<template>
|
||||
<el-row class="wrapper">
|
||||
<el-col :span="24">
|
||||
<el-row>
|
||||
<el-col :span="24">
|
||||
<h2 class="title">{{ $t('common.title.allOrders') }}</h2>
|
||||
</el-col>
|
||||
</el-row>
|
||||
<el-row class="panel">
|
||||
<el-col :span="24">
|
||||
<el-card shadow="hover">
|
||||
<el-table v-loading="loading" :data="orders" stripe>
|
||||
<el-table-column prop="id" :label="$t('order.field.id')" class-name="text-center" width="350px">
|
||||
<template #default="scope">
|
||||
<span class="key">{{ scope.row.id }}</span>
|
||||
<span class="copy">
|
||||
<copy-to-clipboard :content="scope.row.id" />
|
||||
</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column :label="$t('order.field.price')" width="100px">
|
||||
<template #default="scope">
|
||||
<span class="price">¥{{ scope.row?.price?.toFixed(2) }}</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column :label="$t('order.field.createdAt')" width="250px">
|
||||
<template #default="scope">
|
||||
<span class="created-at">{{ $dayjs.format(scope.row.created_at) }}</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column :label="$t('order.field.description')">
|
||||
<template #default="scope">
|
||||
<span class="description">{{ scope.row.description }}</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="state" :label="$t('order.field.state')" class-name="text-center" width="100px">
|
||||
<template #default="scope">
|
||||
<span v-if="scope.row.state === OrderState?.PENDING">
|
||||
<el-tag type="info" class="mx-1" effect="dark">{{ $t('order.state.pending') }}</el-tag>
|
||||
</span>
|
||||
<span v-else-if="scope.row.state === OrderState?.PAID" class="state state-paid">
|
||||
<el-tag type="success" class="mx-1" effect="dark">{{ $t('order.state.paid') }}</el-tag>
|
||||
</span>
|
||||
<span v-else-if="scope.row.state === OrderState?.EXPIRED" class="state state-expired">
|
||||
<el-tag type="warning" class="mx-1" effect="dark">{{ $t('order.state.expired') }}</el-tag>
|
||||
</span>
|
||||
<span v-else-if="scope.row.state === OrderState?.FAILED" class="state state-failed">
|
||||
<el-tag type="danger" class="mx-1" effect="dark"> {{ $t('order.state.failed') }}</el-tag>
|
||||
</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column min-width="300px">
|
||||
<template #default="scope">
|
||||
<div class="float-right">
|
||||
<el-button
|
||||
v-if="scope.row.state !== OrderState.PAID"
|
||||
type="primary"
|
||||
@click="
|
||||
$router.push({
|
||||
name: 'console-order-detail',
|
||||
params: {
|
||||
id: scope.row.id
|
||||
}
|
||||
})
|
||||
"
|
||||
>
|
||||
{{ $t('order.button.continuePay') }}
|
||||
</el-button>
|
||||
<el-button
|
||||
v-else
|
||||
@click="
|
||||
$router.push({
|
||||
name: 'console-order-detail',
|
||||
params: {
|
||||
id: scope.row.id
|
||||
}
|
||||
})
|
||||
"
|
||||
>
|
||||
{{ $t('order.button.checkDetail') }}
|
||||
</el-button>
|
||||
</div>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
</el-card>
|
||||
</el-col>
|
||||
</el-row>
|
||||
<el-row>
|
||||
<el-col :span="10" :offset="14">
|
||||
<div class="pagination m-v-lg">
|
||||
<pagination :current-page="page" :page-size="limit" :total="total" @change="onPageChange"> </pagination>
|
||||
</div>
|
||||
</el-col>
|
||||
</el-row>
|
||||
</el-col>
|
||||
</el-row>
|
||||
</template>
|
||||
|
||||
<script lang="ts">
|
||||
import { defineComponent } from 'vue';
|
||||
import { IOrder, IOrderListResponse, orderOperator, OrderState } from '@/operators/order';
|
||||
import Pagination from '@/components/common/Pagination.vue';
|
||||
import CopyToClipboard from '@/components/common/CopyToClipboard.vue';
|
||||
import { ElRow, ElCol, ElTable, ElTableColumn, ElButton, ElTag, ElCard } from 'element-plus';
|
||||
|
||||
interface IData {
|
||||
orders: IOrder[];
|
||||
loading: boolean;
|
||||
total: number | undefined;
|
||||
limit: number;
|
||||
OrderState: typeof OrderState;
|
||||
}
|
||||
|
||||
export default defineComponent({
|
||||
name: 'ConsoleOrderList',
|
||||
components: {
|
||||
Pagination,
|
||||
CopyToClipboard,
|
||||
ElRow,
|
||||
ElCol,
|
||||
ElTable,
|
||||
ElTableColumn,
|
||||
ElButton,
|
||||
ElTag,
|
||||
ElCard
|
||||
},
|
||||
data(): IData {
|
||||
return {
|
||||
OrderState: OrderState,
|
||||
orders: [],
|
||||
loading: false,
|
||||
total: undefined,
|
||||
limit: 10
|
||||
};
|
||||
},
|
||||
computed: {
|
||||
redirect() {
|
||||
return this.$route.query.redirect;
|
||||
},
|
||||
page() {
|
||||
return parseInt(this.$route.query.page?.toString() || '1');
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
page: {
|
||||
handler() {
|
||||
this.onFetchData();
|
||||
}
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
this.onFetchData();
|
||||
},
|
||||
methods: {
|
||||
onPageChange(page: number) {
|
||||
this.$router.push({
|
||||
name: this.$route.name?.toString(),
|
||||
query: {
|
||||
page: page
|
||||
}
|
||||
});
|
||||
},
|
||||
onFetchData() {
|
||||
this.loading = true;
|
||||
orderOperator
|
||||
.getAll({
|
||||
ordering: '-created_at',
|
||||
limit: this.limit,
|
||||
offset: (this.page - 1) * this.limit,
|
||||
user_id: this.$store.getters.user.id
|
||||
})
|
||||
.then(({ data: data }: { data: IOrderListResponse }) => {
|
||||
this.orders = data.items;
|
||||
this.loading = false;
|
||||
this.total = data.count;
|
||||
})
|
||||
.catch(() => {
|
||||
this.loading = false;
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.title {
|
||||
font-size: 26px;
|
||||
font-weight: bold;
|
||||
margin-bottom: 20px;
|
||||
color: #333;
|
||||
}
|
||||
.el-table {
|
||||
min-height: calc(100vh - 300px);
|
||||
margin-bottom: 50px;
|
||||
}
|
||||
|
||||
.wrapper {
|
||||
padding: 30px;
|
||||
.api-key {
|
||||
.copy {
|
||||
cursor: pointer;
|
||||
margin: 0 10px;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.pagination {
|
||||
float: right;
|
||||
}
|
||||
</style>
|
||||
@@ -1,168 +0,0 @@
|
||||
<template>
|
||||
<!-- center part -->
|
||||
<div class="center">
|
||||
<div v-if="loading">
|
||||
<el-skeleton animated />
|
||||
</div>
|
||||
<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-info v-if="document.api" :api="document.api" />
|
||||
<el-divider />
|
||||
<api-usage v-if="document.api" v-model:form="form" :api="document.api" />
|
||||
<markdown-renderer :content="document?.content" />
|
||||
</div>
|
||||
<div v-else-if="document.type === documentType.PROXY">
|
||||
<proxy-info v-if="document.proxy" :proxy="document.proxy" />
|
||||
<el-divider />
|
||||
<markdown-renderer :content="document?.content" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- end center part -->
|
||||
<!-- right part -->
|
||||
<div class="right">
|
||||
<div v-if="loading">
|
||||
<el-skeleton />
|
||||
</div>
|
||||
<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">
|
||||
import { defineComponent } from 'vue';
|
||||
import ApiUsage from '@/components/api/Usage.vue';
|
||||
import ApiTry from '@/components/api/Try.vue';
|
||||
import ApiInfo from '@/components/api/Info.vue';
|
||||
import ProxyInfo from '@/components/proxy/Info.vue';
|
||||
import ApiCode from '@/components/api/Code.vue';
|
||||
import { documentOperator, IDocument, IDocumentDetailResponse, IDocumentType } from '@/operators';
|
||||
import { IForm } from '@/operators/api/models';
|
||||
import MarkdownRenderer from '@/components/common/MarkdownRenderer.vue';
|
||||
import { ElSkeleton, ElDivider } from 'element-plus';
|
||||
import axios from 'axios';
|
||||
|
||||
export interface IData {
|
||||
document: IDocument | undefined;
|
||||
loading: boolean;
|
||||
form: IForm;
|
||||
documentType: typeof IDocumentType;
|
||||
canceler: AbortController | undefined;
|
||||
}
|
||||
|
||||
export default defineComponent({
|
||||
name: 'DocumentDetail',
|
||||
components: {
|
||||
ApiUsage,
|
||||
ApiTry,
|
||||
ApiCode,
|
||||
ApiInfo,
|
||||
ProxyInfo,
|
||||
ElSkeleton,
|
||||
ElDivider,
|
||||
MarkdownRenderer
|
||||
},
|
||||
data(): IData {
|
||||
return {
|
||||
document: undefined,
|
||||
loading: false,
|
||||
form: {},
|
||||
documentType: IDocumentType,
|
||||
canceler: undefined
|
||||
};
|
||||
},
|
||||
computed: {
|
||||
id() {
|
||||
return this.$route.params?.id?.toString();
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
id: {
|
||||
handler(val) {
|
||||
if (val) this.getDocument(val);
|
||||
}
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
this.getDocument(this.id);
|
||||
},
|
||||
methods: {
|
||||
getDocument(id: string) {
|
||||
this.loading = true;
|
||||
this.form = {};
|
||||
// cancel existing pending request
|
||||
if (this.canceler) {
|
||||
this.canceler.abort();
|
||||
}
|
||||
this.canceler = new AbortController();
|
||||
documentOperator
|
||||
.get(id, {
|
||||
signal: this.canceler.signal
|
||||
})
|
||||
.then(({ data: data }: { data: IDocumentDetailResponse }) => {
|
||||
this.loading = false;
|
||||
this.document = data;
|
||||
})
|
||||
.catch((error) => {
|
||||
if (axios.isCancel(error)) {
|
||||
return;
|
||||
}
|
||||
this.loading = false;
|
||||
console.error(error);
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.center {
|
||||
float: left;
|
||||
width: calc(100% - 760px);
|
||||
height: 100%;
|
||||
padding: 30px;
|
||||
.markdown-body {
|
||||
background: none;
|
||||
}
|
||||
}
|
||||
|
||||
.right {
|
||||
float: left;
|
||||
width: 480px;
|
||||
height: 100%;
|
||||
padding: 30px;
|
||||
box-shadow: -1px 0 0 #eee;
|
||||
}
|
||||
|
||||
@media (max-width: 1199px) and (min-width: 900px) {
|
||||
.center {
|
||||
width: calc(100% - 400px);
|
||||
height: fit-content;
|
||||
}
|
||||
.right {
|
||||
width: 400px;
|
||||
height: fit-content;
|
||||
}
|
||||
}
|
||||
|
||||
@media (max-width: 899px) {
|
||||
.center {
|
||||
width: 100%;
|
||||
height: fit-content;
|
||||
}
|
||||
|
||||
.right {
|
||||
width: 100%;
|
||||
display: block;
|
||||
height: fit-content;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -1,76 +0,0 @@
|
||||
<template>
|
||||
<div class="center">
|
||||
<el-skeleton animated />
|
||||
<el-divider />
|
||||
<el-skeleton animated />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script lang="ts">
|
||||
import { IDocument, IDocumentListResponse } from '@/operators/document/models';
|
||||
import { documentOperator } from '@/operators/document/operator';
|
||||
import { ROUTE_DOCUMENT_DETAIL } from '@/router';
|
||||
import { defineComponent } from 'vue';
|
||||
import { ElSkeleton, ElDivider } from 'element-plus';
|
||||
|
||||
interface IData {
|
||||
documents: IDocument[];
|
||||
}
|
||||
export default defineComponent({
|
||||
name: 'DocumentIndex',
|
||||
components: {
|
||||
ElSkeleton,
|
||||
ElDivider
|
||||
},
|
||||
data(): IData {
|
||||
return {
|
||||
documents: []
|
||||
};
|
||||
},
|
||||
mounted() {
|
||||
this.getDocuments(0, 1);
|
||||
},
|
||||
methods: {
|
||||
getDocuments(offset: number, limit: number) {
|
||||
documentOperator
|
||||
.getAll({
|
||||
offset,
|
||||
limit,
|
||||
ordering: 'rank',
|
||||
private: false
|
||||
})
|
||||
.then(({ data: data }: { data: IDocumentListResponse }) => {
|
||||
this.documents = data.items;
|
||||
if (this.documents.length > 0) {
|
||||
const firstDocument = this.documents[0];
|
||||
this.$router.push({
|
||||
name: ROUTE_DOCUMENT_DETAIL,
|
||||
params: {
|
||||
id: firstDocument.id
|
||||
}
|
||||
});
|
||||
}
|
||||
})
|
||||
.catch((error) => {
|
||||
console.error(error);
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.center {
|
||||
float: left;
|
||||
width: calc(100% - 760px);
|
||||
height: 100%;
|
||||
padding: 30px;
|
||||
}
|
||||
|
||||
.right {
|
||||
float: left;
|
||||
width: 480px;
|
||||
height: 100%;
|
||||
box-shadow: -1px 0 0 #eee;
|
||||
}
|
||||
</style>
|
||||
@@ -1,583 +0,0 @@
|
||||
<template>
|
||||
<el-row class="banner">
|
||||
<el-col :span="24">
|
||||
<el-row>
|
||||
<el-col :md="10" :offset="2" :sm="24" :xs="24" class="left">
|
||||
<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>
|
||||
<p>
|
||||
{{ service.description }}
|
||||
</p>
|
||||
<div class="price">
|
||||
<p v-if="service && service.price && service.price > 0" class="unfree">
|
||||
<span class="value">¥{{ service.price }}</span>
|
||||
<span class="unit"> / {{ $t(`service.unit.${service.unit}`) }}</span>
|
||||
<span class="from">
|
||||
{{ $t('service.message.fromPrice') }}
|
||||
</span>
|
||||
</p>
|
||||
<p v-else class="free">
|
||||
{{ $t('service.message.free') }}
|
||||
</p>
|
||||
</div>
|
||||
<div class="operations">
|
||||
<el-button type="danger" class="btn-apply" @click="onToApis">
|
||||
{{ $t('service.button.apply') }}
|
||||
</el-button>
|
||||
</div>
|
||||
</div>
|
||||
</el-col>
|
||||
<el-col :md="10" :sm="0" :xs="0" class="right">
|
||||
<div class="demo">
|
||||
<img src="@/assets/images/illustration.png" />
|
||||
</div>
|
||||
</el-col>
|
||||
</el-row>
|
||||
</el-col>
|
||||
</el-row>
|
||||
<el-row v-if="service && service.introduction" class="introduction">
|
||||
<el-col :span="20" :offset="2">
|
||||
<el-card shadow="hover" :body-style="{ padding: '50px' }">
|
||||
<markdown-renderer :content="service?.introduction" />
|
||||
</el-card>
|
||||
</el-col>
|
||||
</el-row>
|
||||
<el-row v-if="service && apis?.length > 0" 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-preview :api="api" />
|
||||
</el-col>
|
||||
<el-col :span="4" class="operations">
|
||||
<div v-if="!api.applied">
|
||||
<el-button type="primary" @click="onConfirm(api, applicationType.API)">
|
||||
{{ $t('common.button.apply') }}
|
||||
</el-button>
|
||||
</div>
|
||||
<div v-else>
|
||||
<el-button v-if="api?.document_id" @click="onGoDocument(api?.document_id!)">
|
||||
{{ $t('application.button.goDocument') }}
|
||||
</el-button>
|
||||
<el-button v-if="api?.application_id" type="primary" @click="onBuyMore(api?.application_id!)">
|
||||
{{ $t('application.button.buyMore') }}
|
||||
</el-button>
|
||||
</div>
|
||||
</el-col>
|
||||
</el-row>
|
||||
<el-divider v-if="apiIndex < apis.length - 1" border-style="dashed" />
|
||||
</div>
|
||||
</el-card>
|
||||
</el-col>
|
||||
</el-row>
|
||||
<el-row v-if="service && proxies?.length > 0" id="proxies" class="proxies">
|
||||
<el-col :span="20" :offset="2">
|
||||
<el-card shadow="hover" :body-style="{ padding: '50px' }">
|
||||
<div v-for="(proxy, proxyIndex) in proxies" :key="proxyIndex">
|
||||
<el-row>
|
||||
<el-col :span="20">
|
||||
<proxy-preview :proxy="proxy" />
|
||||
</el-col>
|
||||
<el-col :span="4" class="operations">
|
||||
<div v-if="!proxy.applied">
|
||||
<el-button type="primary" @click="onConfirm(proxy, applicationType.PROXY)">
|
||||
{{ $t('common.button.apply') }}
|
||||
</el-button>
|
||||
</div>
|
||||
<div v-else>
|
||||
<el-button v-if="proxy?.document_id" @click="onGoDocument(proxy?.document_id!)">
|
||||
{{ $t('application.button.goDocument') }}
|
||||
</el-button>
|
||||
<el-button v-if="proxy?.application_id" type="primary" @click="onBuyMore(proxy?.application_id!)">
|
||||
{{ $t('application.button.buyMore') }}
|
||||
</el-button>
|
||||
</div>
|
||||
</el-col>
|
||||
</el-row>
|
||||
<el-divider v-if="proxyIndex < apis.length - 1" />
|
||||
</div>
|
||||
</el-card>
|
||||
</el-col>
|
||||
</el-row>
|
||||
<application-confirm
|
||||
v-if="confirm.object && confirm.type"
|
||||
v-model.visible="confirming"
|
||||
:object="confirm.object"
|
||||
:type="confirm.type"
|
||||
@apply="onApply(confirm.object!, confirm.type!)"
|
||||
/>
|
||||
</template>
|
||||
|
||||
<script lang="ts">
|
||||
import {
|
||||
applicationOperator,
|
||||
IApplication,
|
||||
IApplicationDetailResponse,
|
||||
IProxy,
|
||||
IProxyListResponse,
|
||||
IService,
|
||||
IServiceDetailResponse,
|
||||
proxyOperator,
|
||||
serviceOperator
|
||||
} from '@/operators';
|
||||
import { defineComponent } from 'vue';
|
||||
import { ERROR_CODE_DUPLICATION, ERROR_CODE_UNVERIFIED } from '@/constants';
|
||||
import { ElMessage } from 'element-plus';
|
||||
import { apiOperator } from '@/operators/api/operator';
|
||||
import { IApi, IApiListResponse } from '@/operators/api/models';
|
||||
import { IApplicationType } from '@/operators/application/models';
|
||||
import MarkdownRenderer from '@/components/common/MarkdownRenderer.vue';
|
||||
import {
|
||||
ROUTE_AUTH_LOGIN,
|
||||
ROUTE_CONSOLE_APPLICATION_BUY,
|
||||
ROUTE_CONSOLE_APPLICATION_LIST,
|
||||
ROUTE_DOCUMENT_DETAIL
|
||||
} from '@/router';
|
||||
import { ElCol, ElRow, ElButton, ElCard, ElDivider, ElSkeleton, ElSkeletonItem } from 'element-plus';
|
||||
import ApiPreview from '@/components/api/Preview.vue';
|
||||
import ProxyPreview from '@/components/proxy/Preview.vue';
|
||||
import ApplicationConfirm from '@/components/application/Confirm.vue';
|
||||
import { getVerificationUrl } from '@/utils';
|
||||
|
||||
interface IData {
|
||||
service: IService | undefined;
|
||||
apis: IApi[];
|
||||
proxies: IProxy[];
|
||||
application: IApplication | undefined;
|
||||
loading: boolean;
|
||||
loadingApis: boolean;
|
||||
loadingProxies: boolean;
|
||||
activeTab: string;
|
||||
applicationType: typeof IApplicationType;
|
||||
confirming: boolean;
|
||||
confirm: {
|
||||
type: IApplicationType | undefined;
|
||||
object: IApi | IProxy | undefined;
|
||||
};
|
||||
}
|
||||
|
||||
export default defineComponent({
|
||||
name: 'ServiceDetail',
|
||||
components: {
|
||||
MarkdownRenderer,
|
||||
ElCol,
|
||||
ElRow,
|
||||
ElButton,
|
||||
ElCard,
|
||||
ElDivider,
|
||||
ApiPreview,
|
||||
ApplicationConfirm,
|
||||
ProxyPreview,
|
||||
ElSkeleton,
|
||||
ElSkeletonItem
|
||||
},
|
||||
data(): IData {
|
||||
return {
|
||||
service: undefined,
|
||||
apis: [],
|
||||
proxies: [],
|
||||
application: undefined,
|
||||
loading: false,
|
||||
loadingApis: false,
|
||||
loadingProxies: false,
|
||||
activeTab: 'introduction',
|
||||
applicationType: IApplicationType,
|
||||
confirming: false,
|
||||
confirm: {
|
||||
object: undefined,
|
||||
type: undefined
|
||||
}
|
||||
};
|
||||
},
|
||||
computed: {
|
||||
id() {
|
||||
return this.$route.params.id.toString();
|
||||
}
|
||||
},
|
||||
async mounted() {
|
||||
this.onFetchService();
|
||||
this.onFetchApis();
|
||||
this.onFetchProxies();
|
||||
},
|
||||
methods: {
|
||||
onShowApiPolicy() {},
|
||||
onFetchService() {
|
||||
this.loading = true;
|
||||
serviceOperator.get(this.id).then(({ data: data }: { data: IServiceDetailResponse }) => {
|
||||
this.service = data;
|
||||
this.loading = false;
|
||||
});
|
||||
},
|
||||
onFetchApis() {
|
||||
this.loadingApis = true;
|
||||
apiOperator
|
||||
.getAllForService(this.id, {
|
||||
ordering: 'rank'
|
||||
})
|
||||
.then(({ data: data }: { data: IApiListResponse }) => {
|
||||
this.apis = data.items;
|
||||
this.loadingApis = false;
|
||||
})
|
||||
.catch(() => {
|
||||
this.loadingApis = false;
|
||||
});
|
||||
},
|
||||
onFetchProxies() {
|
||||
this.loadingProxies = true;
|
||||
proxyOperator
|
||||
.getAllForService(this.id, {
|
||||
ordering: 'rank'
|
||||
})
|
||||
.then(({ data: data }: { data: IProxyListResponse }) => {
|
||||
this.proxies = data.items;
|
||||
})
|
||||
.catch(() => {
|
||||
this.loadingProxies = false;
|
||||
});
|
||||
},
|
||||
onToApis() {
|
||||
window.scrollTo({
|
||||
top: document.getElementById('apis')?.offsetTop,
|
||||
left: 0,
|
||||
behavior: 'smooth'
|
||||
});
|
||||
},
|
||||
onBuyMore(id: string) {
|
||||
this.$router.push({
|
||||
name: ROUTE_CONSOLE_APPLICATION_BUY,
|
||||
params: {
|
||||
id
|
||||
}
|
||||
});
|
||||
},
|
||||
onConfirm(obj: IApi | IProxy, type: IApplicationType) {
|
||||
if (!this.$store.getters.authenticated) {
|
||||
this.$router.push({
|
||||
name: ROUTE_AUTH_LOGIN,
|
||||
query: { redirect: this.$route.fullPath }
|
||||
});
|
||||
}
|
||||
this.confirming = true;
|
||||
this.confirm.object = obj;
|
||||
this.confirm.type = type;
|
||||
},
|
||||
onGoDocument(documentId: string) {
|
||||
this.$router.push({
|
||||
name: ROUTE_DOCUMENT_DETAIL,
|
||||
params: {
|
||||
id: documentId
|
||||
}
|
||||
});
|
||||
},
|
||||
onApply(obj: IApi | IProxy, type: IApplicationType) {
|
||||
applicationOperator
|
||||
.create({
|
||||
type,
|
||||
...(type === IApplicationType.API
|
||||
? {
|
||||
api_id: obj.id
|
||||
}
|
||||
: {}),
|
||||
...(type === IApplicationType.PROXY
|
||||
? {
|
||||
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({
|
||||
name: ROUTE_CONSOLE_APPLICATION_LIST
|
||||
});
|
||||
}, 2000);
|
||||
})
|
||||
.catch((error) => {
|
||||
if (error?.response?.data?.code === ERROR_CODE_DUPLICATION) {
|
||||
ElMessage.error(this.$t('application.message.alreadyApplied'));
|
||||
setTimeout(() => {
|
||||
this.$router.push({
|
||||
name: ROUTE_CONSOLE_APPLICATION_LIST
|
||||
});
|
||||
}, 2000);
|
||||
}
|
||||
if (error?.response?.data?.code === ERROR_CODE_UNVERIFIED) {
|
||||
ElMessage({
|
||||
dangerouslyUseHTMLString: true,
|
||||
duration: 0,
|
||||
showClose: true,
|
||||
message: `${this.$t(
|
||||
'application.message.unverified'
|
||||
)} <a class="underline" href="${getVerificationUrl()}">${this.$t('application.message.goVerify')}</a>`,
|
||||
type: 'warning'
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.banner {
|
||||
$height: calc(100vh - 60px);
|
||||
$min-height: 600px;
|
||||
background-color: #111827;
|
||||
background-image: url('@/assets/images/bg.png');
|
||||
background-position: 50% 50%;
|
||||
background-size: cover;
|
||||
background-repeat: no-repeat;
|
||||
position: relative;
|
||||
z-index: 1;
|
||||
height: $height;
|
||||
min-height: $min-height;
|
||||
margin-bottom: 30px;
|
||||
|
||||
.left {
|
||||
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;
|
||||
color: #fff;
|
||||
font-size: 56px;
|
||||
line-height: 64px;
|
||||
}
|
||||
|
||||
p {
|
||||
max-width: 650px;
|
||||
margin-bottom: 56px;
|
||||
color: #d1d5db;
|
||||
font-size: 24px;
|
||||
line-height: 32px;
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
.price {
|
||||
margin: 0;
|
||||
.unfree {
|
||||
.value {
|
||||
font-weight: bold;
|
||||
color: #ff5441;
|
||||
font-size: 40px;
|
||||
}
|
||||
|
||||
.unit {
|
||||
color: white;
|
||||
}
|
||||
|
||||
.from {
|
||||
color: white;
|
||||
}
|
||||
}
|
||||
.free {
|
||||
color: #29c287;
|
||||
}
|
||||
}
|
||||
|
||||
.operations {
|
||||
.btn-apply {
|
||||
margin: 0 auto 40px;
|
||||
padding: 25px 62px;
|
||||
color: #fff;
|
||||
font-size: 20px;
|
||||
line-height: 20px;
|
||||
font-weight: 700;
|
||||
text-align: center;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.right {
|
||||
position: relative;
|
||||
height: $height;
|
||||
min-height: $min-height;
|
||||
padding: 50px;
|
||||
overflow: hidden;
|
||||
.demo {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
position: relative;
|
||||
img {
|
||||
max-width: 100%;
|
||||
max-height: 100%;
|
||||
position: absolute;
|
||||
top: 50%;
|
||||
transform: translateY(-50%);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.preview {
|
||||
overflow: hidden;
|
||||
$left-width: 320px;
|
||||
$left-height: 290px;
|
||||
margin: 15px 0;
|
||||
|
||||
.body {
|
||||
display: flex;
|
||||
.left {
|
||||
float: left;
|
||||
position: relative;
|
||||
border: 1px solid #e8e8e8;
|
||||
border-radius: 8px;
|
||||
width: $left-width;
|
||||
height: $left-height;
|
||||
text-align: center;
|
||||
box-sizing: border-box;
|
||||
box-shadow: none;
|
||||
padding-top: 50px;
|
||||
.icon {
|
||||
width: 150px;
|
||||
height: 150px;
|
||||
margin: 0 auto;
|
||||
font-size: 80px;
|
||||
}
|
||||
.icon-placeholder {
|
||||
display: flex;
|
||||
width: 80px;
|
||||
height: 80px;
|
||||
text-align: center;
|
||||
margin: 30px auto 10px auto;
|
||||
}
|
||||
|
||||
.count {
|
||||
color: #999;
|
||||
}
|
||||
}
|
||||
|
||||
.right {
|
||||
position: relative;
|
||||
padding: 15px;
|
||||
float: left;
|
||||
width: calc(100% - $left-width);
|
||||
.title {
|
||||
font-size: 18px;
|
||||
color: #000;
|
||||
line-height: 26px;
|
||||
padding-right: 8px;
|
||||
}
|
||||
.title-placeholder {
|
||||
width: 100px;
|
||||
height: 30px;
|
||||
display: block;
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
.description {
|
||||
line-height: 22px;
|
||||
color: #303030;
|
||||
padding: 15px 0;
|
||||
font-size: 14px;
|
||||
}
|
||||
.description-placeholder {
|
||||
width: 300px;
|
||||
height: 20px;
|
||||
display: block;
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
.price {
|
||||
margin: 0;
|
||||
.unfree {
|
||||
.value {
|
||||
font-weight: bold;
|
||||
color: #ff5441;
|
||||
font-size: 30px;
|
||||
}
|
||||
|
||||
.unit {
|
||||
color: #666;
|
||||
}
|
||||
}
|
||||
.free {
|
||||
color: #29c287;
|
||||
}
|
||||
}
|
||||
.price-placeholder {
|
||||
width: 100px;
|
||||
height: 30px;
|
||||
}
|
||||
.operations {
|
||||
position: absolute;
|
||||
left: 15px;
|
||||
bottom: 10px;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.introduction {
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
|
||||
.apis {
|
||||
margin-bottom: 40px;
|
||||
.operations {
|
||||
align-items: center;
|
||||
justify-items: center;
|
||||
display: flex;
|
||||
}
|
||||
}
|
||||
|
||||
.proxies {
|
||||
margin-bottom: 40px;
|
||||
.operations {
|
||||
align-items: center;
|
||||
justify-items: center;
|
||||
display: flex;
|
||||
}
|
||||
}
|
||||
|
||||
.dialog-confirm {
|
||||
.title {
|
||||
font-size: 14px;
|
||||
font-weight: bold;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -1,356 +0,0 @@
|
||||
<template>
|
||||
<el-row class="banner">
|
||||
<el-col :span="24" class="main">
|
||||
<div class="info">
|
||||
<h1 class="title">
|
||||
{{ $t('service.message.indexTitle') }}
|
||||
</h1>
|
||||
<h3 class="subtitle">
|
||||
{{ $t('service.message.indexSubtitle') }}
|
||||
</h3>
|
||||
<div class="operations">
|
||||
<el-button type="danger" class="btn-apply" @click="onApply">
|
||||
{{ $t('common.button.startForFree') }}
|
||||
</el-button>
|
||||
</div>
|
||||
</div>
|
||||
</el-col>
|
||||
</el-row>
|
||||
<el-row id="services">
|
||||
<el-col :span="20" :offset="2">
|
||||
<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 animated>
|
||||
<template #template>
|
||||
<el-skeleton-item variant="image" class="icon-placeholder" />
|
||||
<el-skeleton-item variant="p" class="title-placeholder" />
|
||||
<el-skeleton-item variant="p" class="price-placeholder" />
|
||||
</template>
|
||||
</el-skeleton>
|
||||
</el-card>
|
||||
</el-col>
|
||||
</el-row>
|
||||
<el-row v-else :gutter="15" class="services">
|
||||
<el-col v-for="(service, serviceIndex) in services" :key="serviceIndex" :lg="6" :md="8" :sm="12" :xs="24">
|
||||
<router-link
|
||||
:to="{
|
||||
name: 'service-detail',
|
||||
params: {
|
||||
id: service.id
|
||||
}
|
||||
}"
|
||||
>
|
||||
<el-card shadow="hover" class="service" :body-style="{ padding: 0 }">
|
||||
<el-image class="thumb" :src="service?.thumbnail" />
|
||||
<div class="title">{{ service.title }}</div>
|
||||
<div class="price">
|
||||
<service-price :price="service?.price" :unit="$t(`service.unit.${service.unit}`)" />
|
||||
</div>
|
||||
<div class="description">
|
||||
<p>
|
||||
{{ service.description }}
|
||||
</p>
|
||||
</div>
|
||||
</el-card>
|
||||
</router-link>
|
||||
</el-col>
|
||||
</el-row>
|
||||
<el-row>
|
||||
<el-col :span="10" :offset="14">
|
||||
<div class="pagination m-v-lg">
|
||||
<pagination :current-page="page" :page-size="limit" :total="total" @change="onPageChange" />
|
||||
</div>
|
||||
</el-col>
|
||||
</el-row>
|
||||
</el-col>
|
||||
</el-row>
|
||||
</template>
|
||||
|
||||
<script lang="ts">
|
||||
import { serviceOperator, IService, IServiceListResponse } from '@/operators';
|
||||
import { defineComponent } from 'vue';
|
||||
import Pagination from '@/components/common/Pagination.vue';
|
||||
import { ElRow, ElCol, ElButton, ElCard, ElSkeleton, ElImage, ElSkeletonItem } from 'element-plus';
|
||||
import ServicePrice from '@/components/common/Price.vue';
|
||||
|
||||
interface IData {
|
||||
services: IService[];
|
||||
loading: boolean;
|
||||
total: number | undefined;
|
||||
limit: number;
|
||||
}
|
||||
export default defineComponent({
|
||||
name: 'ServiceList',
|
||||
components: {
|
||||
Pagination,
|
||||
ElRow,
|
||||
ElCol,
|
||||
ElButton,
|
||||
ElCard,
|
||||
ElSkeleton,
|
||||
ElImage,
|
||||
ElSkeletonItem,
|
||||
ServicePrice
|
||||
},
|
||||
data(): IData {
|
||||
return {
|
||||
services: [],
|
||||
loading: true,
|
||||
total: undefined,
|
||||
limit: 8
|
||||
};
|
||||
},
|
||||
computed: {
|
||||
page() {
|
||||
return parseInt(this.$route.query.page?.toString() || '1');
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
page: {
|
||||
handler() {
|
||||
this.onFetchData();
|
||||
}
|
||||
}
|
||||
},
|
||||
async mounted() {
|
||||
this.onFetchData();
|
||||
},
|
||||
methods: {
|
||||
onApply() {
|
||||
window.scrollTo({
|
||||
top: document.getElementById('services')?.offsetTop,
|
||||
left: 0,
|
||||
behavior: 'smooth'
|
||||
});
|
||||
},
|
||||
onPageChange(page: number) {
|
||||
this.$router.push({
|
||||
name: this.$route.name?.toString(),
|
||||
query: {
|
||||
page: page
|
||||
}
|
||||
});
|
||||
},
|
||||
onFetchData() {
|
||||
this.loading = true;
|
||||
console.debug('start to load all services');
|
||||
serviceOperator
|
||||
.getAll({
|
||||
limit: this.limit,
|
||||
offset: (this.page - 1) * this.limit,
|
||||
ordering: 'rank',
|
||||
private: false
|
||||
})
|
||||
.then(({ data: data }: { data: IServiceListResponse }) => {
|
||||
this.services = data.items;
|
||||
this.total = data.count;
|
||||
this.loading = false;
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.banner {
|
||||
// display: none;
|
||||
height: calc(100vh - 60px);
|
||||
background-color: #111827;
|
||||
width: 100%;
|
||||
background-image: url('https://zhishuyun-1256437459.cos.ap-beijing.myqcloud.com/background-lines.png');
|
||||
background-position: 50% 50%;
|
||||
background-size: cover;
|
||||
background-repeat: no-repeat;
|
||||
position: relative;
|
||||
z-index: 1;
|
||||
|
||||
.main {
|
||||
position: relative;
|
||||
.info {
|
||||
position: absolute;
|
||||
top: 50%;
|
||||
width: 100%;
|
||||
left: 0;
|
||||
right: 0;
|
||||
transform: translateY(-50%);
|
||||
h1.title {
|
||||
display: inline-block;
|
||||
color: #fff;
|
||||
font-size: 80px;
|
||||
line-height: 84px;
|
||||
position: relative;
|
||||
left: 50%;
|
||||
transform: translateX(-50%);
|
||||
text-align: center;
|
||||
margin-bottom: 50px;
|
||||
-webkit-text-fill-color: transparent;
|
||||
-webkit-background-clip: text;
|
||||
background-clip: text;
|
||||
background-image: linear-gradient(
|
||||
90deg,
|
||||
#fb60d7,
|
||||
#eb69dc 15%,
|
||||
#dc5cff 30%,
|
||||
#c555fe 45%,
|
||||
#a02fff 60%,
|
||||
#7752ff 75%,
|
||||
#5f98fa 90%,
|
||||
#44beff
|
||||
);
|
||||
}
|
||||
h3.subtitle {
|
||||
color: hsla(0, 0%, 100%, 0.7);
|
||||
font-size: 24px;
|
||||
line-height: 32px;
|
||||
text-align: center;
|
||||
margin-bottom: 70px;
|
||||
}
|
||||
.operations {
|
||||
width: 100%;
|
||||
text-align: center;
|
||||
.btn-apply {
|
||||
margin: 0 auto 40px auto;
|
||||
padding: 25px 62px;
|
||||
color: #fff;
|
||||
font-size: 20px;
|
||||
line-height: 20px;
|
||||
font-weight: 700;
|
||||
text-align: center;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$transition-duration: 0.5s;
|
||||
|
||||
@media (min-width: 1400px) {
|
||||
.services {
|
||||
width: 1300px;
|
||||
margin: auto !important;
|
||||
}
|
||||
}
|
||||
|
||||
.services {
|
||||
padding: 50px 0;
|
||||
.service {
|
||||
$hover-offset: 50px;
|
||||
width: 100%;
|
||||
height: 250px;
|
||||
margin-bottom: 15px;
|
||||
border-radius: 30px !important;
|
||||
position: relative;
|
||||
transition: all $transition-duration;
|
||||
|
||||
.icon-placeholder {
|
||||
display: flex;
|
||||
width: 80px;
|
||||
height: 80px;
|
||||
margin: 0 auto 15px auto;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.title-placeholder {
|
||||
display: block;
|
||||
width: 80px;
|
||||
height: 20px;
|
||||
margin: 0 auto 10px auto;
|
||||
}
|
||||
|
||||
.price-placeholder {
|
||||
display: block;
|
||||
width: 100px;
|
||||
height: 16px;
|
||||
margin: 0 auto 10px auto;
|
||||
}
|
||||
|
||||
.icon {
|
||||
font-size: 60px;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.thumb {
|
||||
position: relative;
|
||||
text-align: center;
|
||||
width: 100%;
|
||||
height: 150px;
|
||||
top: 0px;
|
||||
opacity: 1;
|
||||
transition: all $transition-duration;
|
||||
}
|
||||
|
||||
.title {
|
||||
color: #666;
|
||||
font-size: 16px;
|
||||
text-align: center;
|
||||
margin-top: 10px;
|
||||
margin-bottom: 8px;
|
||||
padding: 0 20px;
|
||||
font-weight: bold;
|
||||
transition: all $transition-duration;
|
||||
position: relative;
|
||||
top: 0;
|
||||
}
|
||||
|
||||
.price {
|
||||
position: relative;
|
||||
top: 0;
|
||||
font-size: 16px;
|
||||
font-weight: bold;
|
||||
text-align: center;
|
||||
margin: 0;
|
||||
.unfree {
|
||||
color: #ff5441;
|
||||
}
|
||||
.free {
|
||||
color: #29c287;
|
||||
}
|
||||
transition: all $transition-duration;
|
||||
}
|
||||
|
||||
.description {
|
||||
padding: 5px 15px;
|
||||
text-align: center;
|
||||
margin: 0 auto;
|
||||
overflow: hidden;
|
||||
display: -webkit-box;
|
||||
-webkit-box-orient: vertical;
|
||||
-webkit-line-clamp: 2;
|
||||
text-overflow: ellipsis;
|
||||
color: #9f9f9f;
|
||||
font-size: 12px;
|
||||
opacity: 0;
|
||||
position: absolute;
|
||||
bottom: 30px;
|
||||
word-break: break-all;
|
||||
transition: all $transition-duration;
|
||||
text-overflow: ellipsis;
|
||||
height: 42px;
|
||||
}
|
||||
|
||||
&:hover {
|
||||
.thumb {
|
||||
top: -$hover-offset;
|
||||
opacity: 0.5;
|
||||
}
|
||||
.title {
|
||||
top: -$hover-offset;
|
||||
}
|
||||
.price {
|
||||
top: -$hover-offset;
|
||||
}
|
||||
.description {
|
||||
opacity: 1;
|
||||
}
|
||||
.operations {
|
||||
opacity: 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
.pagination {
|
||||
padding-bottom: 50px;
|
||||
float: right;
|
||||
}
|
||||
</style>
|
||||
@@ -2,7 +2,6 @@ import { library } from '@fortawesome/fontawesome-svg-core';
|
||||
import {
|
||||
faCopy as faRegularCopy,
|
||||
faUser as faRegularUser,
|
||||
faIdCard as faRegularIdCard,
|
||||
faPaperPlane as faRegularPaperPlane,
|
||||
faComment as faRegularComment,
|
||||
faSun as faRegularSun
|
||||
@@ -11,9 +10,6 @@ import {
|
||||
faRotateRight as faSolidRotateRight,
|
||||
faCheck as faSolidCheck,
|
||||
faPlus as faSolidPlus,
|
||||
faCube as faSolidCube,
|
||||
faCubes as faSolidCubes,
|
||||
faStore as faSolidStore,
|
||||
faBolt as faSolidBolt,
|
||||
faQuestion as faSolidQuestion,
|
||||
faTrash as faSolidTrash,
|
||||
@@ -26,12 +22,8 @@ library.add(faRegularCopy);
|
||||
library.add(faSolidRotateRight);
|
||||
library.add(faSolidCheck);
|
||||
library.add(faRegularUser);
|
||||
library.add(faRegularIdCard);
|
||||
library.add(faRegularSun);
|
||||
library.add(faSolidBolt);
|
||||
library.add(faSolidCube);
|
||||
library.add(faSolidCubes);
|
||||
library.add(faSolidStore);
|
||||
library.add(faSolidPlus);
|
||||
library.add(faSolidQuestion);
|
||||
library.add(faSolidTriangleExclamation);
|
||||
|
||||
@@ -1,50 +0,0 @@
|
||||
import {
|
||||
ROUTE_CONSOLE_ADMIN_APPLICATION,
|
||||
ROUTE_CONSOLE_APPLICATION_BUY,
|
||||
ROUTE_CONSOLE_APPLICATION_LIST,
|
||||
ROUTE_CONSOLE_ORDER_DETAIL,
|
||||
ROUTE_CONSOLE_ORDER_LIST,
|
||||
ROUTE_CONSOLE_ROOT
|
||||
} from './constants';
|
||||
|
||||
export default {
|
||||
path: '/console',
|
||||
meta: {
|
||||
auth: true
|
||||
},
|
||||
component: () => import('@/layouts/Console.vue'),
|
||||
children: [
|
||||
{
|
||||
path: '',
|
||||
name: ROUTE_CONSOLE_ROOT,
|
||||
redirect: {
|
||||
name: ROUTE_CONSOLE_APPLICATION_LIST
|
||||
}
|
||||
},
|
||||
{
|
||||
path: 'orders',
|
||||
name: ROUTE_CONSOLE_ORDER_LIST,
|
||||
component: () => import('@/pages/console/order/List.vue')
|
||||
},
|
||||
{
|
||||
path: 'orders/:id',
|
||||
name: ROUTE_CONSOLE_ORDER_DETAIL,
|
||||
component: () => import('@/pages/console/order/Detail.vue')
|
||||
},
|
||||
{
|
||||
path: 'applications',
|
||||
name: ROUTE_CONSOLE_APPLICATION_LIST,
|
||||
component: () => import('@/pages/console/application/List.vue')
|
||||
},
|
||||
{
|
||||
path: 'applications/:id/buy',
|
||||
name: ROUTE_CONSOLE_APPLICATION_BUY,
|
||||
component: () => import('@/pages/console/application/Buy.vue')
|
||||
},
|
||||
{
|
||||
path: 'admin/application',
|
||||
name: ROUTE_CONSOLE_ADMIN_APPLICATION,
|
||||
component: () => import('@/pages/console/admin/Application.vue')
|
||||
}
|
||||
]
|
||||
};
|
||||
@@ -3,17 +3,5 @@ export const ROUTE_INDEX = 'index';
|
||||
export const ROUTE_AUTH_LOGIN = 'auth-login';
|
||||
export const ROUTE_AUTH_CALLBACK = 'auth-callback';
|
||||
|
||||
export const ROUTE_CONSOLE_ROOT = 'console-root';
|
||||
export const ROUTE_CONSOLE_ORDER_LIST = 'console-order-list';
|
||||
export const ROUTE_CONSOLE_ORDER_DETAIL = 'console-order-detail';
|
||||
export const ROUTE_CONSOLE_APPLICATION_LIST = 'console-application-list';
|
||||
export const ROUTE_CONSOLE_APPLICATION_BUY = 'console-application-buy';
|
||||
export const ROUTE_CONSOLE_ADMIN_APPLICATION = 'console-application-admin-application';
|
||||
|
||||
export const ROUTE_DOCUMENT_LIST = 'document-list';
|
||||
export const ROUTE_DOCUMENT_DETAIL = 'document-detail';
|
||||
export const ROUTE_CONVERSATION_NEW = 'conversation-new';
|
||||
export const ROUTE_CONVERSATION_DETAIL = 'conversation-detail';
|
||||
|
||||
export const ROUTE_SERVICE_LIST = 'service-list';
|
||||
export const ROUTE_SERVICE_DETAIL = 'service-detail';
|
||||
@@ -1,18 +0,0 @@
|
||||
import { ROUTE_DOCUMENT_DETAIL, ROUTE_DOCUMENT_LIST } from './constants';
|
||||
|
||||
export default {
|
||||
path: '/documents',
|
||||
component: () => import('@/layouts/Document.vue'),
|
||||
children: [
|
||||
{
|
||||
path: '',
|
||||
name: ROUTE_DOCUMENT_LIST,
|
||||
component: () => import('@/pages/document/List.vue')
|
||||
},
|
||||
{
|
||||
path: ':id',
|
||||
name: ROUTE_DOCUMENT_DETAIL,
|
||||
component: () => import('@/pages/document/Detail.vue')
|
||||
}
|
||||
]
|
||||
};
|
||||
+2
-8
@@ -1,24 +1,18 @@
|
||||
import { createRouter, createWebHistory } from 'vue-router';
|
||||
import service from './service';
|
||||
import auth from './auth';
|
||||
import console from './console';
|
||||
import conversation from './conversation';
|
||||
import document from './document';
|
||||
import store from '@/store';
|
||||
import { ROUTE_AUTH_LOGIN, ROUTE_INDEX, ROUTE_SERVICE_LIST } from './constants';
|
||||
import { ROUTE_AUTH_LOGIN, ROUTE_CONVERSATION_NEW, ROUTE_INDEX } from './constants';
|
||||
|
||||
const routes = [
|
||||
{
|
||||
path: '/',
|
||||
name: ROUTE_INDEX,
|
||||
redirect: {
|
||||
name: ROUTE_SERVICE_LIST
|
||||
name: ROUTE_CONVERSATION_NEW
|
||||
}
|
||||
},
|
||||
service,
|
||||
auth,
|
||||
console,
|
||||
document,
|
||||
conversation
|
||||
];
|
||||
|
||||
|
||||
@@ -1,18 +0,0 @@
|
||||
import { ROUTE_SERVICE_DETAIL, ROUTE_SERVICE_LIST } from './constants';
|
||||
|
||||
export default {
|
||||
path: '/services',
|
||||
component: () => import('@/layouts/Service.vue'),
|
||||
children: [
|
||||
{
|
||||
path: '',
|
||||
name: ROUTE_SERVICE_LIST,
|
||||
component: () => import('@/pages/service/List.vue')
|
||||
},
|
||||
{
|
||||
path: ':id',
|
||||
name: ROUTE_SERVICE_DETAIL,
|
||||
component: () => import('@/pages/service/Detail.vue')
|
||||
}
|
||||
]
|
||||
};
|
||||
+16
-1
@@ -8,7 +8,7 @@ import { getEnv } from './env';
|
||||
export const getDataBaseUrl = () => {
|
||||
const env = getEnv();
|
||||
if (env === ENV_LOCAL) {
|
||||
return 'https://chat.local.zhishuyun.com';
|
||||
return 'https://data.local.zhishuyun.com';
|
||||
} else if (env === ENV_TEST) {
|
||||
return 'https://data.test.zhishuyun.com';
|
||||
} else {
|
||||
@@ -16,6 +16,21 @@ export const getDataBaseUrl = () => {
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Get base url of app
|
||||
* @returns
|
||||
*/
|
||||
export const getChatBaseUrl = () => {
|
||||
const env = getEnv();
|
||||
if (env === ENV_LOCAL) {
|
||||
return 'https://chat.local.zhishuyun.com';
|
||||
} else if (env === ENV_TEST) {
|
||||
return 'https://chat.test.zhishuyun.com';
|
||||
} else {
|
||||
return 'https://chat.zhishuyun.com';
|
||||
}
|
||||
};
|
||||
|
||||
export const getAuthBaseUrl = () => {
|
||||
const env = getEnv();
|
||||
if (env === ENV_LOCAL) {
|
||||
|
||||
Reference in new issue
Block a user