perf: code style

This commit is contained in:
fit2cloud-chenyw
2025-04-27 10:39:16 +08:00
parent ddbe612fb6
commit becde51f06
3 changed files with 2 additions and 11 deletions
+1 -1
View File
@@ -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
+1 -6
View File
@@ -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 {
-4
View File
@@ -1,7 +1,3 @@
/**
* 配置浏览器本地存储的方式,可直接存储对象数组。
*/
import WebStorageCache from 'web-storage-cache'
type CacheType = 'sessionStorage' | 'localStorage'