部署优化

This commit is contained in:
andy
2026-08-03 22:31:54 +08:00
parent a9348b8d3e
commit 2f5bd13b4d
3 changed files with 69 additions and 2 deletions

21
app.js
View File

@@ -796,6 +796,25 @@ const I18N = {
const $ = (selector, root = document) => root.querySelector(selector);
const $$ = (selector, root = document) => [...root.querySelectorAll(selector)];
function createUuid() {
if (typeof window.crypto?.randomUUID === "function") {
return window.crypto.randomUUID();
}
const bytes = new Uint8Array(16);
if (typeof window.crypto?.getRandomValues === "function") {
window.crypto.getRandomValues(bytes);
} else {
for (let index = 0; index < bytes.length; index += 1) {
bytes[index] = Math.floor(Math.random() * 256);
}
}
bytes[6] = (bytes[6] & 0x0f) | 0x40;
bytes[8] = (bytes[8] & 0x3f) | 0x80;
const hex = [...bytes].map(byte => byte.toString(16).padStart(2, "0")).join("");
return `${hex.slice(0, 8)}-${hex.slice(8, 12)}-${hex.slice(12, 16)}-${hex.slice(16, 20)}-${hex.slice(20)}`;
}
function mapApiOwner(record) {
return {
id: record.id,
@@ -1654,7 +1673,7 @@ function calculateForm() {
function resetStayForm(ownerId = owners[0]?.id || "") {
$("#stayForm").reset();
stayIdempotencyKey = IS_API_MODE ? window.crypto.randomUUID() : null;
stayIdempotencyKey = IS_API_MODE ? createUuid() : null;
$("#ownerSelect").value = String(ownerId);
$("#confirmationInput").value = "";
$("#checkinInput").value = "2026-08-01";