fix mine
This commit is contained in:
parent
17a02ea47e
commit
70e7a113e6
22 changed files with 967 additions and 285 deletions
|
@ -7,7 +7,7 @@ Page({
|
|||
*/
|
||||
data: {
|
||||
issuer: '',
|
||||
remark: '',
|
||||
account: '',
|
||||
secret: '',
|
||||
type: '',
|
||||
counter: 0,
|
||||
|
@ -64,14 +64,18 @@ Page({
|
|||
return
|
||||
}
|
||||
|
||||
const type = (targetToken.type || 'totp').toLowerCase();
|
||||
const isHotp = type === 'hotp';
|
||||
|
||||
self.setData({
|
||||
tokens: tokens,
|
||||
issuer: targetToken.issuer || '',
|
||||
remark: targetToken.remark || '',
|
||||
account: targetToken.account || '',
|
||||
secret: targetToken.secret || '',
|
||||
type: targetToken.type || 'totp',
|
||||
counter: targetToken.counter || 0,
|
||||
isHotp: targetToken.type === 'hotp',
|
||||
type: type,
|
||||
// 只有HOTP类型才设置counter
|
||||
counter: isHotp ? (targetToken.counter || 0) : undefined,
|
||||
isHotp: isHotp,
|
||||
hasLoaded: true
|
||||
})
|
||||
},
|
||||
|
@ -160,18 +164,28 @@ Page({
|
|||
}
|
||||
|
||||
// 更新令牌数据
|
||||
updatedTokens[tokenIndex] = {
|
||||
const type = this.data.type.toLowerCase();
|
||||
const isHotp = type === 'hotp';
|
||||
|
||||
// 创建基本的更新对象
|
||||
const updatedToken = {
|
||||
...updatedTokens[tokenIndex],
|
||||
issuer: values.issuer.trim(),
|
||||
remark: (values.remark || '').trim(),
|
||||
account: (values.account || '').trim(),
|
||||
secret: this.data.secret, // 使用已加载的secret,而不是从表单获取
|
||||
type: this.data.type
|
||||
}
|
||||
type: type
|
||||
};
|
||||
|
||||
// 如果是HOTP类型,更新计数器值
|
||||
if (this.data.isHotp && values.counter !== undefined) {
|
||||
updatedTokens[tokenIndex].counter = parseInt(values.counter)
|
||||
if (isHotp && values.counter !== undefined) {
|
||||
updatedToken.counter = parseInt(values.counter);
|
||||
} else if (!isHotp) {
|
||||
// 如果是TOTP类型,删除counter字段
|
||||
delete updatedToken.counter;
|
||||
}
|
||||
|
||||
// 更新令牌数组
|
||||
updatedTokens[tokenIndex] = updatedToken;
|
||||
|
||||
wx.setStorage({
|
||||
key: 'tokens',
|
||||
|
@ -223,7 +237,7 @@ Page({
|
|||
hasLoaded: false,
|
||||
isSubmitting: false,
|
||||
issuer: '',
|
||||
remark: '',
|
||||
account: '',
|
||||
secret: '',
|
||||
type: '',
|
||||
counter: 0,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue