Skip to content

Commit

Permalink
bump
Browse files Browse the repository at this point in the history
  • Loading branch information
eiriksgata committed Apr 17, 2024
1 parent 676d824 commit 401dc3c
Show file tree
Hide file tree
Showing 6 changed files with 2,268 additions and 1,932 deletions.
2 changes: 2 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
{
"cSpell.words": [
"eircbctool",
"eirctool",
"Nuxt",
"toastify",
"trpg"
Expand Down
10 changes: 10 additions & 0 deletions models/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,3 +64,13 @@ type EircbcToolTokenGenerateVo = {
issuedAt: Date;
expireDate: Date;
}

type EircbcToolToken = {
id: number;
code: string;
createdAt: Date;
updatedAt: Date;
issuedAt: Date;
expireDate: Date;
description: string;
}
1 change: 1 addition & 0 deletions pages/dashboard.vue
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
<v-list-item prepend-icon="mdi-robot" title="机器人" @click="$router.push('/dashboard/robot')"></v-list-item>

<v-list-item prepend-icon="mdi-lock-check-outline" title="弹幕工具授权" @click="$router.push('/dashboard/eirctool')"></v-list-item>
<v-list-item prepend-icon="mdi-lock-check-outline" title="工具在线授权" @click="$router.push('/dashboard/eirctool/token')"></v-list-item>


</v-list>
Expand Down
182 changes: 182 additions & 0 deletions pages/dashboard/eirctool/token/index.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,182 @@
<template>
<v-data-table :headers="headers" :items="desserts" :sort-by="[{ key: 'calories', order: 'asc' }]">
<template v-slot:top>
<v-toolbar flat>
<v-toolbar-title>在线授权列表</v-toolbar-title>
<v-divider class="mx-4" inset vertical></v-divider>
<v-spacer></v-spacer>
<v-dialog v-model="dialog" max-width="500px">
<template v-slot:activator="{ props }">
<v-btn color="primary" variant="flat" rounded="2" class="mb-2" v-bind="props">
新建授权
</v-btn>
</template>
<v-card>
<v-card-title>
<span class="text-h5">{{ formTitle }}</span>
</v-card-title>

<v-card-text>
<v-container>
<v-row>

<v-col cols="12" sm="12">
<v-text-field v-model="editedItem.code" label="设备序列号" variant="solo-filled"></v-text-field>
<v-text-field v-model="editedItem.description" label="描述" variant="solo-filled"></v-text-field>
<vuetify-time-picker v-model="editedItem.issuedAt" label="起始时间" />
<vuetify-time-picker v-model="editedItem.expireDate" label="过期时间" />
</v-col>

</v-row>
</v-container>
</v-card-text>

<v-card-actions>
<v-spacer></v-spacer>
<v-btn color="blue-darken-1" variant="text" @click="close">
Cancel
</v-btn>
<v-btn color="blue-darken-1" variant="text" @click="save">
Save
</v-btn>
</v-card-actions>
</v-card>
</v-dialog>
<v-dialog v-model="dialogDelete" max-width="500px">
<v-card>
<v-card-title class="text-h5">Are you sure you want to delete this item?</v-card-title>
<v-card-actions>
<v-spacer></v-spacer>
<v-btn color="blue-darken-1" variant="text" @click="closeDelete">Cancel</v-btn>
<v-btn color="blue-darken-1" variant="text" @click="deleteItemConfirm">OK</v-btn>
<v-spacer></v-spacer>
</v-card-actions>
</v-card>
</v-dialog>
</v-toolbar>
</template>
<template v-slot:item.actions="{ item }">
<v-icon size="small" class="me-2" @click="editItem(item)">
mdi-pencil
</v-icon>
<v-icon size="small" @click="deleteItem(item)">
mdi-delete
</v-icon>
</template>

<template v-slot:item.issuedAt="{ item }">
{{ Moment(item.issuedAt).format("YYYY-MM-DD HH:mm:ss") }}
</template>

<template v-slot:item.expireDate="{ item }">
{{ Moment(item.expireDate).format("YYYY-MM-DD HH:mm:ss") }}
</template>

</v-data-table>
</template>


<style scoped></style>
<script lang="ts" setup>
import { computed, nextTick, ref, watch } from 'vue'
import Moment from 'moment';
import { getTokenList, deleteById, tokenSave } from '~/server/api/eirctool';
const dialog = ref(false)
const dialogDelete = ref(false)
const headers = ref<any>([
{
title: 'ID',
align: 'start',
key: 'id'
},
{ title: '设备序列号', key: 'code' },
{ title: '描述', key: 'description' },
{ title: '起始时间', key: 'issuedAt' },
{ title: '过期时间', key: 'expireDate' },
{ title: 'Actions', key: 'actions', sortable: false },
])
const desserts = ref<Array<EircbcToolToken>>([]);
const editedItem = ref<EircbcToolToken>({
id: -1,
description: '',
code: '',
expireDate: new Date(),
createdAt: new Date(),
updatedAt: new Date(),
issuedAt: new Date()
})
const defaultItem = ref<EircbcToolToken>({
id: -1,
description: '',
code: '',
expireDate: new Date(),
createdAt: new Date(),
updatedAt: new Date(),
issuedAt: new Date()
});
const formTitle = computed(() => {
return editedItem.value.id === -1 ? '新建用户' : '编辑用户'
})
async function initialize() {
const result: ServerResponse<Array<EircbcToolToken>> = await getTokenList();
desserts.value = result.data;
}
function editItem(item: EircbcToolToken) {
editedItem.value = Object.assign({}, item)
dialog.value = true
}
function deleteItem(item: EircbcToolToken) {
editedItem.value = Object.assign({}, item)
dialogDelete.value = true
}
async function deleteItemConfirm() {
const result = await deleteById(editedItem.value.id);
initialize();
closeDelete()
}
function close() {
dialog.value = false
nextTick(() => {
editedItem.value = Object.assign({}, defaultItem.value)
editedItem.value.id = -1
})
}
function closeDelete() {
dialogDelete.value = false
nextTick(() => {
editedItem.value = Object.assign({}, defaultItem.value)
editedItem.value.id = -1
})
}
async function save() {
const result = await tokenSave(editedItem.value);
initialize();
close()
}
watch(dialog, val => {
val || close()
})
watch(dialogDelete, val => {
val || closeDelete()
})
onMounted(async () => {
initialize();
})
</script>
29 changes: 25 additions & 4 deletions server/api/eirctool.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,31 @@
import restUtil from "~/service";

const tokenGenerate = (robot: EircbcToolTokenGenerateVo): Promise<ServerResponse<string>> => {
const tokenGenerate = (requestVo: EircbcToolTokenGenerateVo): Promise<ServerResponse<string>> => {
return restUtil.put<ServerResponse<string>>(
"/api/v1/eircbctool/token/generate",
robot
`/api/v1/eircbctool/token/generate`,
requestVo
);
};

export { tokenGenerate };
const getTokenList = (): Promise<ServerResponse<Array<EircbcToolToken>>> => {
return restUtil.get<ServerResponse<Array<EircbcToolToken>>>(
`/api/v1/eircbctool/token`
);
};

const tokenSave = (requestVo: EircbcToolToken): Promise<ServerResponse<null>> => {
return restUtil.put<ServerResponse<null>>(
`/api/v1/eircbctool/token`,
requestVo
);
};

const deleteById = (id: number): Promise<ServerResponse<null>> => {
return restUtil.delete<ServerResponse<null>>(
`/api/v1/eircbctool/token/${id}`
);
}



export { tokenGenerate, tokenSave, getTokenList, deleteById };
Loading

0 comments on commit 401dc3c

Please sign in to comment.