feat(detection): 添加检测锁机制防止多用户同时操作
- 新增 detectionLock store 管理检测锁状态 - 实现检测锁相关的弹窗提示功能 - 添加 DETECTION_BUSY 错误码处理多人竞争逻辑 - 在 websocket 中集成检测锁超时处理 - 修改程序源控制接口以同步锁状态 - 更新项目标题和图标配置 - 添加 docs 目录到忽略列表
This commit is contained in:
33
frontend/src/stores/modules/detectionLock.ts
Normal file
33
frontend/src/stores/modules/detectionLock.ts
Normal file
@@ -0,0 +1,33 @@
|
||||
import { defineStore } from 'pinia'
|
||||
import { DETECTION_LOCK_STORE_KEY } from '@/stores/constant'
|
||||
|
||||
export interface DetectionLockHolder {
|
||||
holderUserId: string
|
||||
holderUserName: string
|
||||
acquireTime: string
|
||||
expireAt: string
|
||||
}
|
||||
|
||||
export const useDetectionLockStore = defineStore(DETECTION_LOCK_STORE_KEY, {
|
||||
state: () => ({
|
||||
iAmHolder: false,
|
||||
holder: null as DetectionLockHolder | null
|
||||
}),
|
||||
actions: {
|
||||
setAsHolder(holder?: Partial<DetectionLockHolder> | null) {
|
||||
this.iAmHolder = true
|
||||
if (holder) {
|
||||
this.holder = {
|
||||
holderUserId: holder.holderUserId ?? '',
|
||||
holderUserName: holder.holderUserName ?? '',
|
||||
acquireTime: holder.acquireTime ?? '',
|
||||
expireAt: holder.expireAt ?? ''
|
||||
}
|
||||
}
|
||||
},
|
||||
clearHolder() {
|
||||
this.iAmHolder = false
|
||||
this.holder = null
|
||||
}
|
||||
}
|
||||
})
|
||||
Reference in New Issue
Block a user