Skip to content

Commit ae4678e

Browse files
committed
Fix error sometime not uniqid
1 parent 17ab3a5 commit ae4678e

File tree

1 file changed

+10
-12
lines changed

1 file changed

+10
-12
lines changed

view/base/web/js/grid-slider.js

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* @Author: Alex Dong
33
* @Date: 2020-07-29 13:21:07
44
* @Last Modified by: Alex Dong
5-
* @Last Modified time: 2022-05-07 15:41:28
5+
* @Last Modified time: 2022-06-09 09:11:22
66
*/
77

88
define([
@@ -23,17 +23,15 @@ define([
2323
this._initSlider();
2424
},
2525

26-
_uniqid: function (a = "", b = false) {
27-
const c = Date.now()/1000;
28-
let d = c.toString(16).split(".").join("");
29-
while(d.length < 14) d += "0";
30-
let e = "";
31-
if(b){
32-
e = ".";
33-
e += Math.round(Math.random()*100000000);
34-
}
35-
return a + d + e;
36-
},
26+
_.uniqid = function (length=10) {
27+
let result = '';
28+
const characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
29+
const charactersLength = characters.length;
30+
for ( let i = 0; i < length; i++ ) {
31+
result += characters.charAt(Math.floor(Math.random() * charactersLength));
32+
}
33+
return result;
34+
};
3735

3836
_initSlider: function () {
3937
var options = this.options;

0 commit comments

Comments
 (0)