Skip to content

Commit

Permalink
feat: 优化随机id
Browse files Browse the repository at this point in the history
  • Loading branch information
rayhomie committed May 13, 2024
1 parent 66b6231 commit 8686da1
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
4 changes: 3 additions & 1 deletion compiled/alipay/src/ImageUpload/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,9 @@ Component(
// 使用 Date.now() 与 useId 作为前缀,防止每次前缀都相同
this.count = (this.count || 0) + 1;
// 使用 Date.now() 与 useId 作为前缀,防止每次前缀都相同
const prefix = Math.random() + '-' + Date.now();
let id = this.id;
id = this.$id;
const prefix = id + '-' + Date.now();
return `${prefix}-${this.count}`;
},
},
Expand Down
3 changes: 2 additions & 1 deletion compiled/wechat/src/ImageUpload/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,8 @@ Component(UploaderDefaultProps, {
// 使用 Date.now() 与 useId 作为前缀,防止每次前缀都相同
this.count = (this.count || 0) + 1;
// 使用 Date.now() 与 useId 作为前缀,防止每次前缀都相同
var prefix = Math.random() + '-' + Date.now();
var id = this.id;
var prefix = id + '-' + Date.now();
return "".concat(prefix, "-").concat(this.count);
},
}, null, [
Expand Down
6 changes: 5 additions & 1 deletion src/ImageUpload/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,11 @@ Component(
// 使用 Date.now() 与 useId 作为前缀,防止每次前缀都相同
this.count = (this.count || 0) + 1;
// 使用 Date.now() 与 useId 作为前缀,防止每次前缀都相同
const prefix = Math.random() + '-' + Date.now();
let id = this.id;
/// #if ALIPAY
id = this.$id;
/// #endif
const prefix = id + '-' + Date.now();
return `${prefix}-${this.count}`;
},
},
Expand Down

0 comments on commit 8686da1

Please sign in to comment.