fix(ui): 页内确认框替代阻塞式 window.confirm(设置/备份/诊断 6 处);打包前强制 lint(防未定义变量再溜进包)
Verify (Gitea) / gate (build · unit · facts) (push) Successful in 1m29s

This commit is contained in:
qiqi committed 2026-11-17 13:06:57 +08:00
1 parent a625faab17
commit dd15a7d45f
11 files changed
+108 -18

No files matched your search

+13 -4
View File
@@ -11,6 +11,15 @@
*/
;(function (global) {
'use strict'
function askConfirm (text, opts) {
const D = (typeof window !== 'undefined') ? window.IWBDesktop : null
const native = !!(D && D.isTauri && D.isTauri())
const C = (typeof window !== 'undefined') ? window.IWBUIConfirm : null
if (native && C && typeof C.ask === 'function') return C.ask(Object.assign({ text: text }, opts || {}))
return Promise.resolve(window.confirm(text))
}
// 存储入口收敛(2026-11-06):统一走 IWBStorageLocal 门面,配额/异常集中处理
const _lstore = () => (typeof window !== 'undefined' && window.IWBStorageLocal && typeof window.IWBStorageLocal.getStore === 'function') ? window.IWBStorageLocal.getStore() : null
const React = global.React || {}
@@ -170,7 +179,7 @@ function BackupModal(props) {
const needConfirm = estMB >= 20 || imgMeta.length >= 20
const sizeText = estMB >= 1 ? ('约 ' + estMB.toFixed(0) + ' MB') : '未记录(按张数估算偏大)'
if (needConfirm && typeof window !== 'undefined' && typeof window.confirm === 'function') {
const okGo = window.confirm('本次备份包含 ' + imgMeta.length + ' 张图片,预计体积 ' + sizeText + '。\n导出期间浏览器内存占用会明显上升,图库很大时页面会变慢。\n确定继续导出吗?')
const okGo = await askConfirm('本次备份包含 ' + imgMeta.length + ' 张图片,预计体积 ' + sizeText + '。\n导出期间内存占用会明显上升,图库很大时页面会变慢。\n确定继续导出吗?', { title: '导出备份', okText: '继续导出' })
if (!okGo) {
setBkMsg({ type: 'err', text: '已取消导出(' + imgMeta.length + ' 张图片 / ' + sizeText + ')' })
return
@@ -322,7 +331,7 @@ function BackupModal(props) {
const items = restoreData.items
const want = Object.keys(restoreSel).filter((k) => restoreSel[k])
if (!want.length) { setRstMsg({ type: 'err', text: '请至少勾选一项要恢复的数据' }); return }
if (!window.confirm((restoreMerge ? '将以「合并」方式导入(追加去重,不覆盖已有):' : '将用备份覆盖当前数据:') + want.map((k) => ({ config: '设置', prompts: '提示词库', nodeGroups: '节点组', workspaces: '画布工作台', outputs: '图库(含缩略图+原图)' })[k]).join('、') + '。确定恢复?')) return
if (!(await askConfirm((restoreMerge ? '将以「合并」方式导入(追加去重,不覆盖已有):' : '将用备份覆盖当前数据:') + want.map((k) => ({ config: '设置', prompts: '提示词库', nodeGroups: '节点组', workspaces: '画布工作台', outputs: '图库(含缩略图+原图)' })[k]).join('、') + '。确定恢复?', { title: '恢复备份', okText: '开始恢复' }))) return
setRstBusy(true); setRstMsg(null)
try {
props.onSaveNow && props.onSaveNow() // 导入前保存当前画布(避免导入后丢失未保存改动)
@@ -398,7 +407,7 @@ function BackupModal(props) {
for (const m of keepMiss) { const t = (m && (m.label || m.path)) || '密钥'; if (uniqLabel.indexOf(t) === -1) uniqLabel.push(t) }
keepWarn = '⚠︎ 有 ' + keepMiss.length + ' 个密钥字段在备份里是「保留本机原值」(__KEEP__),但本机没有对应值,已保持为空:' + uniqLabel.slice(0, 3).join('、') + (uniqLabel.length > 3 ? ' 等 ' + uniqLabel.length + ' 类' : '') + '。请到「服务与 Key 设置」里补填。'
wLog('restore', 'KEEP-MISS:' + keepMiss.map((m) => m && m.path).join(', '))
try { window.confirm(keepWarn + '\n\n点「确定」继续(恢复已完成,随后刷新页面生效)。') } catch (e) { /* ignore */ }
try { await askConfirm(keepWarn + '\n\n点「确定」继续(恢复已完成,随后刷新页面生效)。', { title: '恢复提示', okText: '知道了', cancelText: '关闭' }) } catch (e) { /* ignore */ }
}
setRstMsg({
type: (imgBad.length || keepWarn) ? 'err' : 'ok',
@@ -428,7 +437,7 @@ function BackupModal(props) {
)
// 清理本地数据:清空 localStorage(iwb_*) + IndexedDB(iwb_web),不可撤销
const doClear = async () => {
if (!window.confirm('确定清空本机的全部本地数据吗?\n\n将删除:设置、提示词库、节点组、画布工作台、图库索引与本机图片(IndexedDB)。\n此操作不可撤销。\n\n建议先「导出备份」再清理。')) return
if (!(await askConfirm('确定清空本机的全部本地数据吗?\n\n将删除:设置、提示词库、节点组、画布工作台、图库索引与本机图片。\n此操作不可撤销。\n\n建议先「导出备份」再清理。', { title: '清空本地数据', okText: '全部清空' }))) return
setClearBusy(true); setClearMsg(null)
try {
const st = _lstore()