From 7f3a50e7875a71eca58706b7e9313f711f755e5c Mon Sep 17 00:00:00 2001 From: AceDataCloud Date: Sat, 31 Dec 2022 18:50:50 +0800 Subject: [PATCH] add console application --- src/components/application/PreviewCard.vue | 145 +++++++++++++++++++ src/components/console/Navigator.vue | 146 ++++++++++++++++++++ src/i18n/zh/application/button.ts | 3 + src/i18n/zh/application/field.ts | 4 + src/i18n/zh/application/index.ts | 7 + src/i18n/zh/console/index.ts | 5 + src/i18n/zh/console/menu.ts | 4 + src/i18n/zh/index.ts | 6 +- src/layouts/Console.vue | 44 ++++++ src/operators/api/models.ts | 15 -- src/operators/api/operator.ts | 29 ---- src/operators/{api => application}/index.ts | 0 src/operators/application/models.ts | 17 +++ src/operators/application/operator.ts | 36 +++++ src/operators/index.ts | 2 +- src/operators/service/operator.ts | 6 +- src/pages/console/application/List.vue | 59 ++++++++ src/pages/console/order/List.vue | 0 src/pages/service/Detail.vue | 2 +- src/router/console.ts | 20 +++ src/router/index.ts | 4 +- 21 files changed, 503 insertions(+), 51 deletions(-) create mode 100644 src/components/application/PreviewCard.vue create mode 100644 src/components/console/Navigator.vue create mode 100644 src/i18n/zh/application/button.ts create mode 100644 src/i18n/zh/application/field.ts create mode 100644 src/i18n/zh/application/index.ts create mode 100644 src/i18n/zh/console/index.ts create mode 100644 src/i18n/zh/console/menu.ts create mode 100644 src/layouts/Console.vue delete mode 100644 src/operators/api/models.ts delete mode 100644 src/operators/api/operator.ts rename src/operators/{api => application}/index.ts (100%) create mode 100644 src/operators/application/models.ts create mode 100644 src/operators/application/operator.ts create mode 100644 src/pages/console/application/List.vue create mode 100644 src/pages/console/order/List.vue create mode 100644 src/router/console.ts diff --git a/src/components/application/PreviewCard.vue b/src/components/application/PreviewCard.vue new file mode 100644 index 00000000..c4cc8555 --- /dev/null +++ b/src/components/application/PreviewCard.vue @@ -0,0 +1,145 @@ + + + + + diff --git a/src/components/console/Navigator.vue b/src/components/console/Navigator.vue new file mode 100644 index 00000000..90258828 --- /dev/null +++ b/src/components/console/Navigator.vue @@ -0,0 +1,146 @@ + + + + + diff --git a/src/i18n/zh/application/button.ts b/src/i18n/zh/application/button.ts new file mode 100644 index 00000000..e329a9cc --- /dev/null +++ b/src/i18n/zh/application/button.ts @@ -0,0 +1,3 @@ +export default { + document: '文档' +}; diff --git a/src/i18n/zh/application/field.ts b/src/i18n/zh/application/field.ts new file mode 100644 index 00000000..8c446e84 --- /dev/null +++ b/src/i18n/zh/application/field.ts @@ -0,0 +1,4 @@ +export default { + remainingCount: '剩余次数', + apiKey: 'API Key' +}; diff --git a/src/i18n/zh/application/index.ts b/src/i18n/zh/application/index.ts new file mode 100644 index 00000000..c61ce3af --- /dev/null +++ b/src/i18n/zh/application/index.ts @@ -0,0 +1,7 @@ +import field from './field'; +import button from './button'; + +export default { + field, + button +}; diff --git a/src/i18n/zh/console/index.ts b/src/i18n/zh/console/index.ts new file mode 100644 index 00000000..5234bac5 --- /dev/null +++ b/src/i18n/zh/console/index.ts @@ -0,0 +1,5 @@ +import menu from './menu'; + +export default { + menu +}; diff --git a/src/i18n/zh/console/menu.ts b/src/i18n/zh/console/menu.ts new file mode 100644 index 00000000..c101dac8 --- /dev/null +++ b/src/i18n/zh/console/menu.ts @@ -0,0 +1,4 @@ +export default { + orderList: '订单列表', + applicationList: '申请列表' +}; diff --git a/src/i18n/zh/index.ts b/src/i18n/zh/index.ts index 4ee1f52e..2e22ec64 100644 --- a/src/i18n/zh/index.ts +++ b/src/i18n/zh/index.ts @@ -2,10 +2,14 @@ import common from './common/index'; import auth from './auth/index'; import course from './course/index'; import service from './service/index'; +import console from './console/index'; +import application from './application'; export default { common, auth, course, - service + service, + console, + application }; diff --git a/src/layouts/Console.vue b/src/layouts/Console.vue new file mode 100644 index 00000000..e67d1ffb --- /dev/null +++ b/src/layouts/Console.vue @@ -0,0 +1,44 @@ + + + + + diff --git a/src/operators/api/models.ts b/src/operators/api/models.ts deleted file mode 100644 index d755959a..00000000 --- a/src/operators/api/models.ts +++ /dev/null @@ -1,15 +0,0 @@ -export interface IApi { - id: number; - name: string; - endpoint: string; - requestMethod: string; - createdAt?: string; - updatedAt?: string; -} - -export interface IApiListResponse { - count: number; - items: IApi[]; -} - -export type IApiDetailResponse = IApi; diff --git a/src/operators/api/operator.ts b/src/operators/api/operator.ts deleted file mode 100644 index 751b48be..00000000 --- a/src/operators/api/operator.ts +++ /dev/null @@ -1,29 +0,0 @@ -import { AxiosResponse } from 'axios'; -import { httpClient } from '../instance'; -import { IApi, IApiDetailResponse, IApiListResponse } from './models'; - -class ApiOperator { - key = 'apis'; - - async getAll(): Promise> { - return await httpClient.get(`/${this.key}/`); - } - - async get(id: number): Promise> { - return await httpClient.get(`/${this.key}/${id}`); - } - - async create(data: IApi): Promise> { - return await httpClient.post(`/${this.key}/`, data); - } - - async update(id: number, data: IApi): Promise> { - return await httpClient.put(`/${this.key}/${id}`, data); - } - - async delete(id: number): Promise> { - return await httpClient.delete(`/${this.key}/${id}`); - } -} - -export const apiOperator = new ApiOperator(); diff --git a/src/operators/api/index.ts b/src/operators/application/index.ts similarity index 100% rename from src/operators/api/index.ts rename to src/operators/application/index.ts diff --git a/src/operators/application/models.ts b/src/operators/application/models.ts new file mode 100644 index 00000000..77be6ff6 --- /dev/null +++ b/src/operators/application/models.ts @@ -0,0 +1,17 @@ +export interface IApplication { + id: string; + service: string; + apiKey: string; + userId: string; + remainingCount: number; + usedCount: number; + createdAt?: string; + updatedAt?: string; +} + +export interface IApplicationListResponse { + count: number; + items: IApplication[]; +} + +export type IApplicationDetailResponse = IApplication; diff --git a/src/operators/application/operator.ts b/src/operators/application/operator.ts new file mode 100644 index 00000000..738eb76a --- /dev/null +++ b/src/operators/application/operator.ts @@ -0,0 +1,36 @@ +import { AxiosResponse } from 'axios'; +import { httpClient } from '../instance'; +import { IApplication, IApplicationDetailResponse, IApplicationListResponse } from './models'; +import { camelizeKeys, decamelizeKeys } from 'humps'; + +export interface IApplicationQuery { + userId: string; +} + +class ApplicationOperator { + key = 'applications'; + + async getAll(query: IApplicationQuery): Promise> { + return await httpClient.get(`/${this.key}/`, { + params: decamelizeKeys(query) + }); + } + + async get(id: string): Promise> { + return await httpClient.get(`/${this.key}/${id}`); + } + + async create(data: IApplication): Promise> { + return await httpClient.post(`/${this.key}/`, data); + } + + async update(id: string, data: IApplication): Promise> { + return await httpClient.put(`/${this.key}/${id}`, data); + } + + async delete(id: string): Promise> { + return await httpClient.delete(`/${this.key}/${id}`); + } +} + +export const applicationOperator = new ApplicationOperator(); diff --git a/src/operators/index.ts b/src/operators/index.ts index d769bbae..a4c8bf29 100644 --- a/src/operators/index.ts +++ b/src/operators/index.ts @@ -1,5 +1,5 @@ export * from './instance'; -export * from './api'; +export * from './application'; export * from './auth'; export * from './service'; export * from './user'; diff --git a/src/operators/service/operator.ts b/src/operators/service/operator.ts index ab2c2d4a..4bbdb269 100644 --- a/src/operators/service/operator.ts +++ b/src/operators/service/operator.ts @@ -9,7 +9,7 @@ class ServiceOperator { return await httpClient.get(`/${this.key}/`); } - async get(id: number): Promise> { + async get(id: string): Promise> { return await httpClient.get(`/${this.key}/${id}`); } @@ -17,11 +17,11 @@ class ServiceOperator { return await httpClient.post(`/${this.key}/`, data); } - async update(id: number, data: IService): Promise> { + async update(id: string, data: IService): Promise> { return await httpClient.put(`/${this.key}/${id}`, data); } - async delete(id: number): Promise> { + async delete(id: string): Promise> { return await httpClient.delete(`/${this.key}/${id}`); } } diff --git a/src/pages/console/application/List.vue b/src/pages/console/application/List.vue new file mode 100644 index 00000000..4d800795 --- /dev/null +++ b/src/pages/console/application/List.vue @@ -0,0 +1,59 @@ + + + + diff --git a/src/pages/console/order/List.vue b/src/pages/console/order/List.vue new file mode 100644 index 00000000..e69de29b diff --git a/src/pages/service/Detail.vue b/src/pages/service/Detail.vue index 6bac291f..8a1568f2 100644 --- a/src/pages/service/Detail.vue +++ b/src/pages/service/Detail.vue @@ -90,7 +90,7 @@ export default defineComponent({ }, computed: { id() { - return parseInt(this.$route.params.id.toString()); + return this.$route.params.id; } }, async mounted() { diff --git a/src/router/console.ts b/src/router/console.ts new file mode 100644 index 00000000..ff084b71 --- /dev/null +++ b/src/router/console.ts @@ -0,0 +1,20 @@ +export default { + path: '/console', + name: 'console', + meta: { + auth: true + }, + component: () => import('@/layouts/Console.vue'), + children: [ + { + path: 'orders', + name: 'console-order-list', + component: () => import('@/pages/console/order/List.vue') + }, + { + path: 'applications', + name: 'console-application-list', + component: () => import('@/pages/console/application/List.vue') + } + ] +}; diff --git a/src/router/index.ts b/src/router/index.ts index e59571d3..617c4cb7 100644 --- a/src/router/index.ts +++ b/src/router/index.ts @@ -1,6 +1,7 @@ import { createRouter, createWebHistory, createWebHashHistory } from 'vue-router'; import service from './service'; import auth from './auth'; +import console from './console'; import store from '@/store'; const routes = [ @@ -10,7 +11,8 @@ const routes = [ redirect: '/services' }, service, - auth + auth, + console ]; const router = createRouter({