更新版本至0.1.13,添加随机ID生成函数,并在KvLogin类中使用

This commit is contained in:
2026-02-04 13:44:04 +08:00
parent a7829ba5e6
commit 2759ac42aa
3 changed files with 22 additions and 26 deletions

View File

@@ -6,6 +6,10 @@ import { useCreateLoginQRCode } from '../modules/wx-mp/qr.ts';
import { eventEmitter } from '../modules/mitt.ts';
import { useContextKey } from '@kevisual/context'
const randomId = (num: number = 6) => {
return 'id-' + Math.random().toString(36).slice(2, num + 2);
}
export const loginEmitter = useContextKey('login-emitter', eventEmitter);
export const WX_MP_APP_ID = "wxff97d569b1db16b6";
interface LoginMethod {
@@ -85,7 +89,7 @@ class KvLogin extends HTMLElement {
const method = this.getAttribute('method');
let id = this.id;
if (!id) {
id = `${Math.random().toString(36).substring(2, 9)}`;
id = randomId(6);
this.id = id;
}
let methodSetFlag = false;