fix(auth): 长任务活跃期间续期会话
This commit is contained in:
@@ -12,6 +12,10 @@ const confirmDialogPath = path.resolve(scriptDir, '../src/components/AppConfirmD
|
||||
const layoutPath = path.resolve(scriptDir, '../src/layouts/MainLayout.vue')
|
||||
const apiPath = path.resolve(scriptDir, '../src/api/modules/dataProcess.ts')
|
||||
const contractTypesPath = path.resolve(scriptDir, '../src/types/dataProcess.ts')
|
||||
const requestPath = path.resolve(scriptDir, '../src/api/request.ts')
|
||||
const authStorePath = path.resolve(scriptDir, '../src/stores/auth.ts')
|
||||
const routerPath = path.resolve(scriptDir, '../src/router/index.ts')
|
||||
const sessionActivityPath = path.resolve(scriptDir, '../src/utils/sessionActivity.ts')
|
||||
const sourceUploadWorkerPath = path.join(createDir, 'useDataProcessSourceUpload.ts')
|
||||
const viewSource = await readFile(viewPath, 'utf8')
|
||||
const layoutSource = await readFile(layoutPath, 'utf8')
|
||||
@@ -25,6 +29,18 @@ const [stateSource, generationSource, previewBuildSource, sourceUploadWorkerSour
|
||||
readFile(contractTypesPath, 'utf8'),
|
||||
])
|
||||
const implementationSource = [viewSource, stateSource, generationSource, previewBuildSource, sourceUploadWorkerSource].join('\n')
|
||||
const [requestSource, authStoreSource, routerSource, sessionActivitySource] = await Promise.all([
|
||||
readFile(requestPath, 'utf8'),
|
||||
readFile(authStorePath, 'utf8'),
|
||||
readFile(routerPath, 'utf8'),
|
||||
readFile(sessionActivityPath, 'utf8'),
|
||||
])
|
||||
|
||||
assert.match(requestSource, /if \(res\.code === 0\) \{[\s\S]*?touchSessionActivity\(\)/, '成功 API 请求没有刷新会话活跃时间')
|
||||
assert.match(authStoreSource, /const loginTime = sessionActivityTime/, '认证状态没有共享请求层的会话活跃时间')
|
||||
assert.match(authStoreSource, /if \(currentUser\.value\) touchSessionActivity\(\)/, '会话续期仍可能在长任务结束后失效')
|
||||
assert.match(routerSource, /const auth = useAuthStore\(\)[\s\S]*?auth\.syncSession\(\)[\s\S]*?if \(!auth\.isLoggedIn\)/, '路由守卫没有在登录判断前同步 API 活跃时间')
|
||||
assert.match(sessionActivitySource, /export function touchSessionActivity\(\)/, '缺少统一会话活跃续期函数')
|
||||
|
||||
assert.ok(existsSync(confirmDialogPath), '缺少公共确认弹窗组件 AppConfirmDialog')
|
||||
const confirmDialogSource = await readFile(confirmDialogPath, 'utf8')
|
||||
|
||||
Reference in New Issue
Block a user