feat: 更新依赖版本,修复路由 ID 字段,优化获取 mark 详情逻辑

This commit is contained in:
xiongxiao
2026-03-23 18:44:52 +08:00
committed by cnb
parent dfd4aacf1c
commit afa5802ef2
4 changed files with 22 additions and 23 deletions

View File

@@ -35,7 +35,7 @@ export const addAuth = (app: App) => {
app
.route({
path: 'auth',
id: 'auth',
rid: 'auth',
description: '验证token必须成功, 错误返回401正确赋值到ctx.state.tokenUser',
})
.define(async (ctx) => {
@@ -71,7 +71,7 @@ export const addAuth = (app: App) => {
.route({
path: 'auth',
key: 'can',
id: 'auth-can',
rid: 'auth-can',
description: '验证token可以不成功错误不返回401正确赋值到ctx.state.tokenUser失败赋值null',
})
.define(async (ctx) => {
@@ -107,7 +107,7 @@ app
.route({
path: 'auth',
key: 'admin',
id: 'auth-admin',
rid: 'auth-admin',
isDebug: true,
middleware: ['auth'],
description: '验证token必须是admin用户, 错误返回403正确赋值到ctx.state.tokenAdmin',
@@ -154,7 +154,7 @@ app
.route({
path: 'auth-check',
key: 'admin',
id: 'check-auth-admin',
rid: 'check-auth-admin',
middleware: ['auth'],
})
.define(async (ctx) => {

View File

@@ -73,7 +73,6 @@ app
description: '获取mark详情',
metadata: {
args: {
id: z.string().describe('mark id'),
}
},
@@ -106,8 +105,8 @@ app
isDebug: true,
metadata: {
args: {
id: z.string().describe('mark id'),
data: z.object({
id: z.string().describe('mark id'),
title: z.string().default(''),
tags: z.any().default([]),
link: z.string().default(''),
@@ -179,8 +178,9 @@ app
.define(async (ctx) => {
const tokenUser = ctx.state.tokenUser;
const operate = ctx.query.operate || 'update';
const markId = ctx.query.id;
const { id, node } = ctx.query.data || {};
const marks = await db.select().from(schema.microMark).where(eq(schema.microMark.id, id)).limit(1);
const marks = await db.select().from(schema.microMark).where(eq(schema.microMark.id, markId)).limit(1);
const markModel = marks[0];
if (!markModel) {
ctx.throw(404, 'mark not found');
@@ -210,7 +210,7 @@ app
version,
updatedAt: new Date().toISOString(),
})
.where(eq(schema.microMark.id, id))
.where(eq(schema.microMark.id, markId))
.returning();
ctx.body = updated[0];
})
@@ -233,7 +233,7 @@ app
})
.define(async (ctx) => {
const tokenUser = ctx.state.tokenUser;
const { id, nodeOperateList } = ctx.query.data || {};
const { id, nodeOperateList } = ctx.query || {};
const marks = await db.select().from(schema.microMark).where(eq(schema.microMark.id, id)).limit(1);
const markModel = marks[0];
if (!markModel) {