feat: add puzzle residence configuration and reflection progress logic
- Introduced `puzzleResidences.ts` to define puzzle residence configurations including properties like display name, position, and puzzle availability. - Added `reflectionProgress.ts` to manage badge unlocking logic based on place completion, including functions to determine unlocked badges and video sources for scenes.
This commit is contained in:
1 parent
e0fa47d21a
commit
f5f36f75b5
153 files changed
+3846
-2352
No files matched your search
@@ -12,6 +12,63 @@ const SENSITIVE_WORDS = [
|
||||
// 可以根据实际需求添加更多敏感词
|
||||
]
|
||||
|
||||
type FileSaveHandle = {
|
||||
createWritable: () => Promise<{
|
||||
write: (data: Blob) => Promise<void>
|
||||
close: () => Promise<void>
|
||||
}>
|
||||
}
|
||||
|
||||
type WindowWithFilePicker = Window & {
|
||||
showSaveFilePicker?: (options?: {
|
||||
suggestedName?: string
|
||||
types?: Array<{
|
||||
accept: Record<string, string[]>
|
||||
}>
|
||||
}) => Promise<FileSaveHandle>
|
||||
}
|
||||
|
||||
const isAbortError = (error: unknown) =>
|
||||
error instanceof DOMException && error.name === 'AbortError'
|
||||
|
||||
const triggerAnchorDownload = (blob: Blob, filename: string) => {
|
||||
const url = URL.createObjectURL(blob)
|
||||
const link = document.createElement('a')
|
||||
link.href = url
|
||||
link.download = filename
|
||||
link.rel = 'noopener'
|
||||
document.body.appendChild(link)
|
||||
link.click()
|
||||
document.body.removeChild(link)
|
||||
setTimeout(() => URL.revokeObjectURL(url), 1000)
|
||||
}
|
||||
|
||||
export async function downloadDataUrlImage(dataUrl: string, filename: string): Promise<void> {
|
||||
if (!dataUrl) return
|
||||
|
||||
const response = await fetch(dataUrl)
|
||||
const blob = await response.blob()
|
||||
const fileType = blob.type || 'image/png'
|
||||
|
||||
const picker = (window as WindowWithFilePicker).showSaveFilePicker
|
||||
if (picker) {
|
||||
try {
|
||||
const handle = await picker({
|
||||
suggestedName: filename,
|
||||
types: [{ accept: { [fileType]: ['.png'] } }],
|
||||
})
|
||||
const writable = await handle.createWritable()
|
||||
await writable.write(blob)
|
||||
await writable.close()
|
||||
return
|
||||
} catch (error) {
|
||||
if (isAbortError(error)) return
|
||||
}
|
||||
}
|
||||
|
||||
triggerAnchorDownload(blob, filename)
|
||||
}
|
||||
|
||||
/**
|
||||
* 检查文本中是否包含敏感词
|
||||
* @param text 待检查的文本
|
||||
|
||||
Reference in new issue
Block a user