feat: 添加应用列表和分类功能,支持搜索和过滤
This commit is contained in:
8
packages/distribute/server/api/apps.get.ts
Normal file
8
packages/distribute/server/api/apps.get.ts
Normal file
@@ -0,0 +1,8 @@
|
||||
import { getAllApps, categories } from '~/data/apps'
|
||||
|
||||
export default defineEventHandler(() => {
|
||||
return {
|
||||
apps: getAllApps(),
|
||||
categories,
|
||||
}
|
||||
})
|
||||
23
packages/distribute/server/api/apps/[id].get.ts
Normal file
23
packages/distribute/server/api/apps/[id].get.ts
Normal file
@@ -0,0 +1,23 @@
|
||||
import { getAppById } from '~/data/apps'
|
||||
|
||||
export default defineEventHandler((event) => {
|
||||
const id = getRouterParam(event, 'id')
|
||||
|
||||
if (!id) {
|
||||
throw createError({
|
||||
statusCode: 400,
|
||||
message: 'App ID is required',
|
||||
})
|
||||
}
|
||||
|
||||
const app = getAppById(id)
|
||||
|
||||
if (!app) {
|
||||
throw createError({
|
||||
statusCode: 404,
|
||||
message: 'App not found',
|
||||
})
|
||||
}
|
||||
|
||||
return app
|
||||
})
|
||||
@@ -1,5 +1,7 @@
|
||||
export default defineEventHandler(async (event) => {
|
||||
const platform = getRouterParam(event, 'platform') as 'ios' | 'android' | 'h5'
|
||||
const body = await readBody(event)
|
||||
const appId = body?.appId
|
||||
|
||||
if (!['ios', 'android', 'h5'].includes(platform)) {
|
||||
throw createError({
|
||||
@@ -10,5 +12,5 @@ export default defineEventHandler(async (event) => {
|
||||
|
||||
await trackDownload(platform)
|
||||
|
||||
return { success: true }
|
||||
return { success: true, appId, platform }
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user