47 lines
1.4 KiB
JavaScript
47 lines
1.4 KiB
JavaScript
import { getServerDatetimeRequest, removeBadLockRequest } from '../api'
|
|
import { Result } from '../constant'
|
|
import { getStorage, setStorage } from '../export'
|
|
|
|
/**
|
|
* 移除坏锁
|
|
* @param params
|
|
* @param {Number} [params.uid] 用户ID
|
|
* @param {List[int]} params.lockIds 锁Id列表
|
|
* @returns {Promise<Result>}
|
|
*/
|
|
export async function removeBadLock(params) {
|
|
const { lockIds } = params
|
|
// 设置执行账号
|
|
const result = await this.login(params.uid)
|
|
if (result.code !== Result.Success.code) {
|
|
return result
|
|
}
|
|
const { code, message } = await removeBadLockRequest({
|
|
lockIds: params.lockIds
|
|
})
|
|
if (code === Result.Success.code) {
|
|
const lockList = getStorage('starLockList')
|
|
if (lockList[this.accountInfo.uid]) {
|
|
lockIds.forEach(lockId => {
|
|
const index = lockList[this.accountInfo.uid].findIndex(item => item.lockId === lockId)
|
|
if (index !== -1) {
|
|
lockList[this.accountInfo.uid].splice(index, 1)
|
|
}
|
|
})
|
|
setStorage('starLockList', lockList)
|
|
}
|
|
}
|
|
|
|
return new Result(code, {}, message)
|
|
}
|
|
|
|
// 获取服务器时间
|
|
export async function getServerTimestamp() {
|
|
const { code, data, message } = await getServerDatetimeRequest({})
|
|
if (code === Result.Success.code) {
|
|
this.serverTimestamp = Math.ceil(data.date / 1000)
|
|
this.timeDifference = Math.ceil((data.date - new Date().getTime()) / 1000)
|
|
}
|
|
return new Result(code, data, message)
|
|
}
|