DataFront/server/api/tools/qqazk/details.ts

40 lines
787 B
TypeScript
Raw Normal View History

2023-08-27 16:30:58 +00:00
import {readFile} from "fs";
interface Word{
bsm:string
hz:string
pyJs:string[]
id:number
}
interface Ret{
data:Word
message:string
haveMess:boolean
}
let words:Word[]
readFile("./word.json",'utf-8',(err, data)=>{
if (err)console.error(err)
words=JSON.parse(data)
})
export default defineEventHandler((event):Ret=>{
const query = getQuery(event)
if (query.id=="错误"){
return {
data:words[0],
message:"参数错误",
haveMess:true
}
}
if (query.id>=words.length){
return {
data:words[0],
message:"参数越界",
haveMess:true
}
}
return {
data:words[query.id],
message:"",
haveMess:false
}
})