Skip to content

[optimize] uuid compatibility && [bug] fix img dom not find #8

Merged
hjdhnx merged 3 commits intohjdhnx:mainfrom
Hiram-Wong:main
Dec 22, 2024
Merged

[optimize] uuid compatibility && [bug] fix img dom not find #8
hjdhnx merged 3 commits intohjdhnx:mainfrom
Hiram-Wong:main

Conversation

@Hiram-Wong
Copy link
Contributor

  1. 修复产生错误时没有找到 imgdom 元素
  2. 兼容不同环境下 uuid 生成方式, 优先级 crypto.randomUUID -> crypto.getRandomValues -> Math.random
static generateUUID() {
        if (crypto && typeof crypto.randomUUID === 'function') {
            return crypto.randomUUID();
        } else if (crypto && typeof crypto.getRandomValues === 'function') {
            return "10000000-1000-4000-8000-100000000000".replace(/[018]/g, c =>
                (+c ^ crypto.getRandomValues(new Uint8Array(1))[0] & 15 >> +c / 4).toString(16)
            );
        } else {
            return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {
                const r = (Math.random() * 16) | 0,
                  v = c == 'x' ? r : (r & 0x3) | 0x8;
                return v.toString(16);
              });
        }
    }

@vercel
Copy link

vercel bot commented Dec 22, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
drpy-node ✅ Ready (Inspect) Visit Preview 💬 Add feedback Dec 22, 2024 2:08am

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants