+
{{ $t('application.message.notApplied') }}
@@ -26,7 +26,6 @@
v-model="value[itemKey?.toString()]"
:placeholder="$t('common.title.placeholderOfInput')"
class="inline-block w-4/5"
- @focus="$emit('refresh-applications')"
/>
@@ -81,7 +80,8 @@ 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 } from '@/constants/errorCode';
+import { ERROR_CODE_DUPLICATION, ERROR_CODE_UNVERIFIED } from '@/constants/errorCode';
+import { getVerificationUrl } from '@/utils';
interface IData {
value: {
@@ -112,6 +112,10 @@ export default defineComponent({
applications: {
type: Array as () => IApplication[],
required: true
+ },
+ applied: {
+ type: Boolean,
+ required: false
}
},
emits: ['update:form', 'refresh-applications'],
@@ -121,9 +125,6 @@ export default defineComponent({
};
},
computed: {
- isApplied() {
- return this.applications.filter((application) => application.api?.id === this.api?.id).length > 0;
- },
appliedApplication(): IApplication | undefined {
const applications = this.applications.filter((application) => application.api?.id === this.api?.id);
if (applications.length > 0) {
@@ -160,6 +161,17 @@ export default defineComponent({
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'
+ )}
${this.$t('application.message.goVerify')}`,
+ type: 'warning'
+ });
+ }
});
}
}
diff --git a/src/components/api/Usage.vue b/src/components/api/Usage.vue
index 81bea298..b1980b2c 100644
--- a/src/components/api/Usage.vue
+++ b/src/components/api/Usage.vue
@@ -8,6 +8,7 @@
v-model:form="formValue.queries"
:schema="api?.request?.queries"
:api="api"
+ :applied="applied"
:applications="applications"
@refresh-applications="getApplications"
/>
@@ -45,6 +46,7 @@ import ApiInfo from './Info.vue';
export interface IData {
formValue: IForm;
applications: IApplication[];
+ applied: boolean | undefined;
}
export default defineComponent({
@@ -69,7 +71,8 @@ export default defineComponent({
data(): IData {
return {
formValue: this.form || {},
- applications: []
+ applications: [],
+ applied: undefined
};
},
watch: {
@@ -89,6 +92,7 @@ export default defineComponent({
})
.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) => {});
}
diff --git a/src/constants/errorCode.ts b/src/constants/errorCode.ts
index 37ef5a28..98940a8b 100644
--- a/src/constants/errorCode.ts
+++ b/src/constants/errorCode.ts
@@ -1,2 +1,2 @@
-export const ERROR_CODE_UNVERIFIED = 'unverifed';
+export const ERROR_CODE_UNVERIFIED = 'unverified';
export const ERROR_CODE_DUPLICATION = 'duplication';
diff --git a/src/i18n/zh/application/message.ts b/src/i18n/zh/application/message.ts
index 6437637f..5467f5a0 100644
--- a/src/i18n/zh/application/message.ts
+++ b/src/i18n/zh/application/message.ts
@@ -2,5 +2,7 @@ export default {
alreadyApplied: '已经申请过该服务,请到控制台查看',
applySuccessfully: '申请成功,即将跳转到控制台',
notApplied: '你尚未申请过该服务,请先申请该服务之后使用',
- yourApplication: '你的申请'
+ yourApplication: '你的申请',
+ unverified: '您需要完成实名认证之后方可申请该服务',
+ goVerify: '去实名认证'
};
diff --git a/src/operators/auth/models.ts b/src/operators/auth/models.ts
new file mode 100644
index 00000000..8fc7d02c
--- /dev/null
+++ b/src/operators/auth/models.ts
@@ -0,0 +1,6 @@
+export interface IToken {
+ access?: string;
+ refresh?: string;
+}
+
+export interface ITokenResponse extends IToken {}
diff --git a/src/operators/auth/operator.ts b/src/operators/auth/operator.ts
new file mode 100644
index 00000000..deb25c00
--- /dev/null
+++ b/src/operators/auth/operator.ts
@@ -0,0 +1,11 @@
+import { AxiosResponse } from 'axios';
+import { httpClient } from '../instance';
+import { ITokenResponse, IToken } from './models';
+
+class AuthOperator {
+ async refreshToken(payload: IToken): Promise
> {
+ return httpClient.post('/token/refresh/', payload);
+ }
+}
+
+export const authOperator = new AuthOperator();
diff --git a/src/pages/service/Detail.vue b/src/pages/service/Detail.vue
index b7a50e33..8a53b5e0 100644
--- a/src/pages/service/Detail.vue
+++ b/src/pages/service/Detail.vue
@@ -85,7 +85,7 @@ import {
serviceOperator
} from '@/operators';
import { defineComponent } from 'vue';
-import { ERROR_CODE_DUPLICATION } from '@/constants';
+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';
@@ -94,6 +94,7 @@ import MarkdownRenderer from '@/components/common/MarkdownRenderer.vue';
import { ROUTE_CONSOLE_APPLICATION_LIST } from '@/router';
import { ElCol, ElRow, ElButton, ElCard, ElDivider, ElSkeleton, ElSkeletonItem } from 'element-plus';
import ApiInfo from '@/components/api/Info.vue';
+import { getVerificationUrl } from '@/utils';
interface IData {
service: IService | undefined;
@@ -191,6 +192,17 @@ export default defineComponent({
});
}, 2000);
}
+ if (error?.response?.data?.code === ERROR_CODE_UNVERIFIED) {
+ ElMessage({
+ dangerouslyUseHTMLString: true,
+ duration: 0,
+ showClose: true,
+ message: `${this.$t(
+ 'application.message.unverified'
+ )} ${this.$t('application.message.goVerify')}`,
+ type: 'warning'
+ });
+ }
});
}
}
diff --git a/src/utils/index.ts b/src/utils/index.ts
index 50d82f52..972cbe8b 100644
--- a/src/utils/index.ts
+++ b/src/utils/index.ts
@@ -1,3 +1,4 @@
export * from './baseUrl';
export * from './env';
export * from './mode';
+export * from './verification';
diff --git a/src/utils/verification.ts b/src/utils/verification.ts
new file mode 100644
index 00000000..7a114e3f
--- /dev/null
+++ b/src/utils/verification.ts
@@ -0,0 +1,12 @@
+/**
+ * Get verification url
+ * @returns
+ */
+
+import { getAuthBaseUrl } from './baseUrl';
+
+export const getVerificationUrl = () => {
+ const baseUrl = getAuthBaseUrl();
+ const targetUrl = `${baseUrl}/user/verify?redirect=` + window.location.href;
+ return targetUrl;
+};