mirror of
https://gh-proxy.org/https://github.com/klinsmaya/SQLBot.git
synced 2026-11-08 01:06:59 +08:00
perf: code style
This commit is contained in:
@@ -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,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 {
|
||||
|
||||
@@ -1,7 +1,3 @@
|
||||
/**
|
||||
* 配置浏览器本地存储的方式,可直接存储对象数组。
|
||||
*/
|
||||
|
||||
import WebStorageCache from 'web-storage-cache'
|
||||
|
||||
type CacheType = 'sessionStorage' | 'localStorage'
|
||||
|
||||
Reference in New Issue
Block a user