diff --git a/backend/common/core/pagination.py b/backend/common/core/pagination.py index 3561cbc1..dbd95fa7 100644 --- a/backend/common/core/pagination.py +++ b/backend/common/core/pagination.py @@ -40,7 +40,7 @@ class Paginator: stmt = stmt.offset(offset).limit(size) result = self.session.exec(stmt) - items = result.all() # 移除 scalars() 调用,直接使用 all() + items = result.all() return items, total diff --git a/frontend/src/router/watch.ts b/frontend/src/router/watch.ts index d8fb0027..6b38e84d 100644 --- a/frontend/src/router/watch.ts +++ b/frontend/src/router/watch.ts @@ -1,28 +1,23 @@ import { ElMessage } from 'element-plus' import { useCache } from '@/utils/useCache' const { wsCache } = useCache() -// 不需要验证token的白名单路由 const whiteList = ['/login'] export const watchRouter = (router: any) => { router.beforeEach(async (to: any, from: any, next: any) => { - // 获取token const token = wsCache.get('user.token') - // 如果没有token if (!token) { if (whiteList.includes(to.path)) { next() } else { - ElMessage.error('请先登录') + ElMessage.error('Please login first') next('/login') } return } - // 处理根路径重定向 if (to.path === '/') { next('/chat') return } - // 已有token和用户信息,允许访问 if (to.path === '/login') { next('/chat') } else { diff --git a/frontend/src/utils/useCache.ts b/frontend/src/utils/useCache.ts index a762baf5..dac774ae 100644 --- a/frontend/src/utils/useCache.ts +++ b/frontend/src/utils/useCache.ts @@ -1,7 +1,3 @@ -/** - * 配置浏览器本地存储的方式,可直接存储对象数组。 - */ - import WebStorageCache from 'web-storage-cache' type CacheType = 'sessionStorage' | 'localStorage'