add console application
This commit is contained in:
1 parent
6aebeba477
commit
7f3a50e787
21 files changed
+503
-51
No files matched your search
@@ -0,0 +1,145 @@
|
||||
<template>
|
||||
<el-card v-if="application && service" shadow="hover">
|
||||
<div class="item">
|
||||
<div class="icon">
|
||||
<font-awesome-icon :icon="'fa-regular fa-' + service.icon" />
|
||||
</div>
|
||||
<div class="main">
|
||||
<div class="title">
|
||||
{{ service.title }}
|
||||
</div>
|
||||
<div class="key">
|
||||
<span class="label">{{ $t('application.field.apiKey') }}</span>
|
||||
<span class="value">{{ application.apiKey }}</span>
|
||||
<span class="copy">
|
||||
<font-awesome-icon icon="fa-regular fa-copy" />
|
||||
</span>
|
||||
</div>
|
||||
<div class="remaining-count">
|
||||
<span class="label">{{ $t('application.field.remainingCount') }}</span>
|
||||
<span class="value">{{ application.remainingCount }}</span>
|
||||
</div>
|
||||
<div class="operations">
|
||||
<div class="operation">
|
||||
<font-awesome-icon icon="fa-regular fa-file-lines" class="label" />
|
||||
<span class="link">{{ $t('application.button.document') }}</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</el-card>
|
||||
</template>
|
||||
|
||||
<script lang="ts">
|
||||
import { FontAwesomeIcon } from '@fortawesome/vue-fontawesome';
|
||||
import {
|
||||
applicationOperator,
|
||||
IApplication,
|
||||
IApplicationDetailResponse,
|
||||
IService,
|
||||
IServiceDetailResponse,
|
||||
serviceOperator
|
||||
} from '@/operators';
|
||||
import { defineComponent } from 'vue';
|
||||
|
||||
interface IData {
|
||||
loading: boolean;
|
||||
service: IService | undefined;
|
||||
}
|
||||
|
||||
export default defineComponent({
|
||||
name: 'ApplicationPreviewCard',
|
||||
components: {
|
||||
FontAwesomeIcon
|
||||
},
|
||||
props: {
|
||||
application: {
|
||||
type: Object as () => IApplication,
|
||||
required: true
|
||||
}
|
||||
},
|
||||
data(): IData {
|
||||
return {
|
||||
loading: false,
|
||||
service: undefined
|
||||
};
|
||||
},
|
||||
mounted() {
|
||||
serviceOperator.get(this.application.service).then(({ data: data }: { data: IServiceDetailResponse }) => {
|
||||
this.service = data;
|
||||
this.loading = false;
|
||||
});
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.item {
|
||||
height: 200px;
|
||||
display: flex;
|
||||
$icon-size: 150px;
|
||||
$icon-font-size: 50px;
|
||||
.icon {
|
||||
width: $icon-size;
|
||||
height: $icon-size;
|
||||
line-height: $icon-size;
|
||||
font-size: $icon-font-size;
|
||||
text-align: center;
|
||||
margin: auto 0;
|
||||
color: var(--el-color-primary);
|
||||
}
|
||||
.main {
|
||||
padding: 0 15px;
|
||||
position: relative;
|
||||
.title {
|
||||
font-size: 20px;
|
||||
font-weight: 500;
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
.key {
|
||||
font-size: 14px;
|
||||
margin-bottom: 5px;
|
||||
.label {
|
||||
font-weight: 600;
|
||||
}
|
||||
.value {
|
||||
display: inline-block;
|
||||
margin-left: 5px;
|
||||
}
|
||||
.copy {
|
||||
display: inline-block;
|
||||
margin-left: 5px;
|
||||
color: #666;
|
||||
cursor: pointer;
|
||||
}
|
||||
}
|
||||
.remaining-count {
|
||||
font-size: 14px;
|
||||
margin-bottom: 5px;
|
||||
.label {
|
||||
font-weight: 600;
|
||||
}
|
||||
.value {
|
||||
display: inline-block;
|
||||
margin-left: 5px;
|
||||
}
|
||||
}
|
||||
.operations {
|
||||
position: absolute;
|
||||
bottom: 5px;
|
||||
left: 20px;
|
||||
.operation {
|
||||
color: #666;
|
||||
.label {
|
||||
color: var(--el-color-primary);
|
||||
}
|
||||
.link {
|
||||
cursor: pointer;
|
||||
display: inline-block;
|
||||
margin-left: 5px;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,146 @@
|
||||
<template>
|
||||
<el-row>
|
||||
<el-col :span="24">
|
||||
<div class="links">
|
||||
<a
|
||||
v-for="link in links"
|
||||
:key="link.key"
|
||||
:class="{ link: true, active: $route.path == link.href }"
|
||||
@click="onClick(link.href)"
|
||||
>
|
||||
<span class="icon">
|
||||
<el-icon class="icon">
|
||||
<clock v-if="link.icon === 'clock'" />
|
||||
<user v-if="link.icon === 'user'" />
|
||||
<postcard v-if="link.icon === 'postcard'" />
|
||||
</el-icon>
|
||||
</span>
|
||||
<span class="text">{{ link.text }}</span>
|
||||
<span class="suffix"></span>
|
||||
</a>
|
||||
</div>
|
||||
</el-col>
|
||||
</el-row>
|
||||
</template>
|
||||
|
||||
<script lang="ts">
|
||||
import { defineComponent } from 'vue';
|
||||
import { Clock, MagicStick, Collection, VideoPlay, Goods, Loading, User, Postcard } from '@element-plus/icons-vue';
|
||||
|
||||
interface ILink {
|
||||
key: string;
|
||||
text: string;
|
||||
href: string;
|
||||
icon: string;
|
||||
}
|
||||
|
||||
interface IData {
|
||||
links: ILink[];
|
||||
}
|
||||
|
||||
export default defineComponent({
|
||||
name: 'Navigator',
|
||||
components: {
|
||||
Clock,
|
||||
Collection,
|
||||
MagicStick,
|
||||
VideoPlay,
|
||||
Goods,
|
||||
Loading,
|
||||
Postcard,
|
||||
User
|
||||
},
|
||||
data(): IData {
|
||||
return {
|
||||
links: [
|
||||
{
|
||||
key: 'profile',
|
||||
text: this.$t('console.menu.orderList'),
|
||||
href: '/console/orders',
|
||||
icon: 'user'
|
||||
},
|
||||
{
|
||||
key: 'verify',
|
||||
text: this.$t('console.menu.applicationList'),
|
||||
href: '/console/applications',
|
||||
icon: 'postcard'
|
||||
}
|
||||
]
|
||||
};
|
||||
},
|
||||
computed: {
|
||||
active() {
|
||||
return this.$route.matched[0].path;
|
||||
}
|
||||
},
|
||||
mounted() {},
|
||||
methods: {
|
||||
onClick(link: string) {
|
||||
window.location.href = link;
|
||||
}
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.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>
|
||||
@@ -0,0 +1,3 @@
|
||||
export default {
|
||||
document: '文档'
|
||||
};
|
||||
@@ -0,0 +1,4 @@
|
||||
export default {
|
||||
remainingCount: '剩余次数',
|
||||
apiKey: 'API Key'
|
||||
};
|
||||
@@ -0,0 +1,7 @@
|
||||
import field from './field';
|
||||
import button from './button';
|
||||
|
||||
export default {
|
||||
field,
|
||||
button
|
||||
};
|
||||
@@ -0,0 +1,5 @@
|
||||
import menu from './menu';
|
||||
|
||||
export default {
|
||||
menu
|
||||
};
|
||||
@@ -0,0 +1,4 @@
|
||||
export default {
|
||||
orderList: '订单列表',
|
||||
applicationList: '申请列表'
|
||||
};
|
||||
@@ -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
|
||||
};
|
||||
@@ -0,0 +1,44 @@
|
||||
<template>
|
||||
<el-container class="container">
|
||||
<el-aside class="aside">
|
||||
<navigator />
|
||||
</el-aside>
|
||||
<el-main class="main"> <router-view /> </el-main>
|
||||
</el-container>
|
||||
</template>
|
||||
|
||||
<script lang="ts">
|
||||
import { defineComponent } from 'vue';
|
||||
import Navigator from '@/components/console/Navigator.vue';
|
||||
|
||||
export default defineComponent({
|
||||
name: 'LayoutConsole',
|
||||
components: {
|
||||
Navigator
|
||||
},
|
||||
data() {
|
||||
return {};
|
||||
},
|
||||
computed: {},
|
||||
methods: {}
|
||||
});
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.container {
|
||||
height: 100vh;
|
||||
}
|
||||
$width: 300px;
|
||||
.aside {
|
||||
width: $width;
|
||||
height: 100%;
|
||||
background-color: white;
|
||||
padding: 15px;
|
||||
padding-top: 50px;
|
||||
}
|
||||
.main {
|
||||
width: calc(100% - $width);
|
||||
background-color: #f3f5f6;
|
||||
height: 100%;
|
||||
}
|
||||
</style>
|
||||
@@ -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;
|
||||
@@ -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<AxiosResponse<IApiListResponse>> {
|
||||
return await httpClient.get(`/${this.key}/`);
|
||||
}
|
||||
|
||||
async get(id: number): Promise<AxiosResponse<IApiDetailResponse>> {
|
||||
return await httpClient.get(`/${this.key}/${id}`);
|
||||
}
|
||||
|
||||
async create(data: IApi): Promise<AxiosResponse<IApiDetailResponse>> {
|
||||
return await httpClient.post(`/${this.key}/`, data);
|
||||
}
|
||||
|
||||
async update(id: number, data: IApi): Promise<AxiosResponse<IApiDetailResponse>> {
|
||||
return await httpClient.put(`/${this.key}/${id}`, data);
|
||||
}
|
||||
|
||||
async delete(id: number): Promise<AxiosResponse<null>> {
|
||||
return await httpClient.delete(`/${this.key}/${id}`);
|
||||
}
|
||||
}
|
||||
|
||||
export const apiOperator = new ApiOperator();
|
||||
File renamed without changes.
@@ -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;
|
||||
@@ -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<AxiosResponse<IApplicationListResponse>> {
|
||||
return await httpClient.get(`/${this.key}/`, {
|
||||
params: decamelizeKeys(query)
|
||||
});
|
||||
}
|
||||
|
||||
async get(id: string): Promise<AxiosResponse<IApplicationDetailResponse>> {
|
||||
return await httpClient.get(`/${this.key}/${id}`);
|
||||
}
|
||||
|
||||
async create(data: IApplication): Promise<AxiosResponse<IApplicationDetailResponse>> {
|
||||
return await httpClient.post(`/${this.key}/`, data);
|
||||
}
|
||||
|
||||
async update(id: string, data: IApplication): Promise<AxiosResponse<IApplicationDetailResponse>> {
|
||||
return await httpClient.put(`/${this.key}/${id}`, data);
|
||||
}
|
||||
|
||||
async delete(id: string): Promise<AxiosResponse<null>> {
|
||||
return await httpClient.delete(`/${this.key}/${id}`);
|
||||
}
|
||||
}
|
||||
|
||||
export const applicationOperator = new ApplicationOperator();
|
||||
@@ -1,5 +1,5 @@
|
||||
export * from './instance';
|
||||
export * from './api';
|
||||
export * from './application';
|
||||
export * from './auth';
|
||||
export * from './service';
|
||||
export * from './user';
|
||||
@@ -9,7 +9,7 @@ class ServiceOperator {
|
||||
return await httpClient.get(`/${this.key}/`);
|
||||
}
|
||||
|
||||
async get(id: number): Promise<AxiosResponse<IServiceDetailResponse>> {
|
||||
async get(id: string): Promise<AxiosResponse<IServiceDetailResponse>> {
|
||||
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<AxiosResponse<IServiceDetailResponse>> {
|
||||
async update(id: string, data: IService): Promise<AxiosResponse<IServiceDetailResponse>> {
|
||||
return await httpClient.put(`/${this.key}/${id}`, data);
|
||||
}
|
||||
|
||||
async delete(id: number): Promise<AxiosResponse<null>> {
|
||||
async delete(id: string): Promise<AxiosResponse<null>> {
|
||||
return await httpClient.delete(`/${this.key}/${id}`);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,59 @@
|
||||
<template>
|
||||
<el-row class="panel">
|
||||
<el-col :span="24">
|
||||
<el-row v-for="(application, applicationId) in applications" :key="applicationId">
|
||||
<el-col :span="24">
|
||||
<application-preview-card :application="application" />
|
||||
</el-col>
|
||||
</el-row>
|
||||
</el-col>
|
||||
</el-row>
|
||||
</template>
|
||||
<script lang="ts">
|
||||
import { defineComponent } from 'vue';
|
||||
import { ElForm, ElMessage } from 'element-plus';
|
||||
import { applicationOperator, IApplication, IApplicationListResponse } from '@/operators';
|
||||
import ApplicationPreviewCard from '@/components/application/PreviewCard.vue';
|
||||
|
||||
interface IData {
|
||||
applications: IApplication[];
|
||||
loading: boolean;
|
||||
}
|
||||
|
||||
export default defineComponent({
|
||||
name: 'ApplicationList',
|
||||
components: {
|
||||
ApplicationPreviewCard
|
||||
},
|
||||
data(): IData {
|
||||
return {
|
||||
applications: [],
|
||||
loading: false
|
||||
};
|
||||
},
|
||||
computed: {
|
||||
redirect() {
|
||||
return this.$route.query.redirect;
|
||||
}
|
||||
},
|
||||
watch: {},
|
||||
mounted() {
|
||||
this.loading = true;
|
||||
applicationOperator
|
||||
.getAll({
|
||||
userId: this.$store.getters.user.id
|
||||
})
|
||||
.then(({ data: data }: { data: IApplicationListResponse }) => {
|
||||
this.applications = data.items;
|
||||
this.loading = false;
|
||||
});
|
||||
},
|
||||
methods: {}
|
||||
});
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.panel {
|
||||
padding: 30px;
|
||||
}
|
||||
</style>
|
||||
Whitespace-only changes.
@@ -90,7 +90,7 @@ export default defineComponent({
|
||||
},
|
||||
computed: {
|
||||
id() {
|
||||
return parseInt(this.$route.params.id.toString());
|
||||
return this.$route.params.id;
|
||||
}
|
||||
},
|
||||
async mounted() {
|
||||
|
||||
@@ -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')
|
||||
}
|
||||
]
|
||||
};
|
||||
+3
-1
@@ -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({
|
||||
|
||||
Reference in new issue
Block a user