Skip to content

Commit becde51

Browse files
perf: code style
1 parent ddbe612 commit becde51

File tree

3 files changed

+2
-11
lines changed

3 files changed

+2
-11
lines changed

backend/common/core/pagination.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ async def paginate(
4040
stmt = stmt.offset(offset).limit(size)
4141

4242
result = self.session.exec(stmt)
43-
items = result.all() # 移除 scalars() 调用,直接使用 all()
43+
items = result.all()
4444

4545
return items, total
4646

frontend/src/router/watch.ts

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,23 @@
11
import { ElMessage } from 'element-plus'
22
import { useCache } from '@/utils/useCache'
33
const { wsCache } = useCache()
4-
// 不需要验证token的白名单路由
54
const whiteList = ['/login']
65
export const watchRouter = (router: any) => {
76
router.beforeEach(async (to: any, from: any, next: any) => {
8-
// 获取token
97
const token = wsCache.get('user.token')
10-
// 如果没有token
118
if (!token) {
129
if (whiteList.includes(to.path)) {
1310
next()
1411
} else {
15-
ElMessage.error('请先登录')
12+
ElMessage.error('Please login first')
1613
next('/login')
1714
}
1815
return
1916
}
20-
// 处理根路径重定向
2117
if (to.path === '/') {
2218
next('/chat')
2319
return
2420
}
25-
// 已有token和用户信息,允许访问
2621
if (to.path === '/login') {
2722
next('/chat')
2823
} else {

frontend/src/utils/useCache.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,3 @@
1-
/**
2-
* 配置浏览器本地存储的方式,可直接存储对象数组。
3-
*/
4-
51
import WebStorageCache from 'web-storage-cache'
62

73
type CacheType = 'sessionStorage' | 'localStorage'

0 commit comments

Comments
 (0)