-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
74018d7
commit 33ac9a7
Showing
10 changed files
with
200 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 7 additions & 0 deletions
7
app/backend/src/modules/application/dto/create-application.dto.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import { TakeType } from '@miaooo/nestjs-take-type' | ||
import { Application } from '../entity/application.entity' | ||
|
||
|
||
export class CreateApplicationDTO extends TakeType(Application, ['code'], ['title']) { | ||
|
||
} |
14 changes: 14 additions & 0 deletions
14
app/frontend/api/backend/components/schemas/create_application_dto.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
/** | ||
* @interface CreateApplicationDTO | ||
* @export | ||
*/ | ||
export interface CreateApplicationDTO { | ||
/** | ||
* 应用名称 | ||
*/ | ||
"title"?: string | ||
/** | ||
* 唯一应用编码 | ||
*/ | ||
"code": string | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import { Keq } from 'keq' | ||
import { request } from 'keq' | ||
import { Application } from "./components/schemas/application" | ||
import { CreateApplicationDTO } from "./components/schemas/create_application_dto" | ||
|
||
|
||
interface ResponseMap { | ||
"201": Application | ||
"500": unknown | ||
} | ||
|
||
|
||
interface QueryArg { | ||
} | ||
|
||
interface ParamArg { | ||
} | ||
|
||
interface HeaderArg { | ||
} | ||
|
||
|
||
export function createApplication<STATUS extends keyof ResponseMap>(arg?: QueryArg & ParamArg & HeaderArg & (CreateApplicationDTO)): Keq<ResponseMap[STATUS]> { | ||
const req = request.post<ResponseMap[STATUS]> | ||
("/api/application") | ||
.option('module', { | ||
name: "backend", | ||
pathname: "/api/application", | ||
}) | ||
|
||
if (arg && "title" in arg) req.send({ "title": arg["title"] }) | ||
if (arg && "code" in arg) req.send({ "code": arg["code"] }) | ||
|
||
return req | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
<script setup lang="ts"> | ||
import { createApplication } from '~/api/backend/create_application.js' | ||
const show = defineModel<boolean>('show', { | ||
default: false, | ||
}) | ||
const emit = defineEmits<{ | ||
'created:application': [applicationId: string] | ||
}>() | ||
const title = ref('') | ||
const code = ref('') | ||
const creating = ref(false) | ||
async function create (): Promise<void> { | ||
creating.value = true | ||
try { | ||
const application = await createApplication<'201'>({ | ||
code: code.value, | ||
title: title.value, | ||
}) | ||
show.value = false | ||
emit('created:application', application.id) | ||
} finally { | ||
creating.value = false | ||
} | ||
} | ||
</script> | ||
|
||
<template> | ||
<Teleport to="body"> | ||
<dialog class="d-modal" :class="show && 'd-modal-open'"> | ||
<div class="d-modal-box font-sans !border-[#5b6078]"> | ||
<div class="flex flex-col space-y-4"> | ||
<div class="form-control w-full max-w-md"> | ||
<div class="d-label"> | ||
<span class="d-label-text">应用名/Title</span> | ||
</div> | ||
|
||
<input | ||
v-model="title" | ||
class="d-input d-input-bordered w-full" | ||
> | ||
</div> | ||
|
||
<div class="form-control w-full max-w-md"> | ||
<div class="d-label"> | ||
<span class="d-label-text">应用编码/Code</span> | ||
<span class="d-label-alt text-base-content/40">创建后无法修改</span> | ||
</div> | ||
|
||
<input | ||
v-model="code" | ||
class="d-input d-input-bordered w-full" | ||
placeholder="只允许小写字母、数字和中线" | ||
> | ||
</div> | ||
</div> | ||
|
||
<div class="d-modal-action flex-0 space-x-6"> | ||
<button class="d-btn" @click="show = false"> | ||
取消 | ||
</button> | ||
|
||
<button class="d-btn d-btn-primary" @click="create"> | ||
创建 | ||
</button> | ||
</div> | ||
</div> | ||
</dialog> | ||
</Teleport> | ||
</template> | ||
|
||
<style scoped lang="postcss"> | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters