mirror of
https://github.com/fmhy/edit.git
synced 2025-07-29 23:32:17 +10:00
feat: feedback v2
This commit is contained in:
parent
d17887ca75
commit
9faa251c86
26 changed files with 1042 additions and 419 deletions
|
@ -5,12 +5,33 @@ import {
|
|||
} from '../../docs/.vitepress/types/Feedback'
|
||||
|
||||
export default defineEventHandler(async (event) => {
|
||||
const { message, page, type } = await readValidatedBody(
|
||||
const { message, page, type, heading } = await readValidatedBody(
|
||||
event,
|
||||
FeedbackSchema.parseAsync
|
||||
)
|
||||
const env = useRuntimeConfig(event)
|
||||
|
||||
const fields = [
|
||||
{
|
||||
name: 'Page',
|
||||
value: page,
|
||||
inline: true
|
||||
},
|
||||
{
|
||||
name: 'Message',
|
||||
value: message,
|
||||
inline: false
|
||||
}
|
||||
]
|
||||
|
||||
if (heading) {
|
||||
fields.push({
|
||||
name: 'Section',
|
||||
value: heading,
|
||||
inline: true
|
||||
})
|
||||
}
|
||||
|
||||
// FIXME: somehow this is not working, but it worked before
|
||||
// const path = 'feedback'
|
||||
//
|
||||
|
@ -21,9 +42,6 @@ export default defineEventHandler(async (event) => {
|
|||
// })
|
||||
// }
|
||||
|
||||
let description = `${message}\n\n`
|
||||
if (page) description += `**Page:** \`${page}\``
|
||||
|
||||
await fetcher()
|
||||
.post(env.WEBHOOK_URL, {
|
||||
username: 'Feedback',
|
||||
|
@ -33,7 +51,7 @@ export default defineEventHandler(async (event) => {
|
|||
{
|
||||
color: 3447003,
|
||||
title: getFeedbackOption(type).label,
|
||||
description
|
||||
fields
|
||||
}
|
||||
]
|
||||
})
|
||||
|
|
3
api/tsconfig.json
Normal file
3
api/tsconfig.json
Normal file
|
@ -0,0 +1,3 @@
|
|||
{
|
||||
"extends": "../.nitro/types/tsconfig.json"
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue