dsh-config-manager 0.8.2 → 0.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/adapters/mcp.js +51 -15
- package/lib/adapters/messages.d.ts +1 -0
- package/lib/adapters/messages.js +2 -0
- package/lib/adapters/patch-key-guard.d.ts +23 -0
- package/lib/adapters/patch-key-guard.js +13 -0
- package/lib/adapters/plugin-data.d.ts +19 -5
- package/lib/adapters/plugin-data.js +76 -22
- package/lib/adapters/plugins.d.ts +14 -1
- package/lib/adapters/plugins.js +204 -6
- package/lib/adapters/prompts.js +15 -4
- package/lib/adapters/test-helpers.d.ts +15 -1
- package/lib/adapters/test-helpers.js +11 -0
- package/lib/cli/actions.d.ts +7 -105
- package/lib/cli/actions.js +16 -172
- package/lib/cli/control-state.d.ts +54 -0
- package/lib/cli/control-state.js +107 -0
- package/lib/cli/help.d.ts +1 -1
- package/lib/cli/help.js +21 -14
- package/lib/cli/index.js +132 -104
- package/lib/cli/sessions-repair.js +58 -22
- package/lib/cli/web/client-script.d.ts +1 -1
- package/lib/cli/web/client-script.js +71 -5
- package/lib/cli/web/page.d.ts +9 -19
- package/lib/cli/web/page.js +277 -173
- package/lib/cli/web/routes.js +85 -25
- package/lib/cli/write-gates.d.ts +61 -0
- package/lib/cli/write-gates.js +110 -0
- package/lib/client.d.ts +196 -75
- package/lib/client.js +8139 -7487
- package/lib/core/backup.d.ts +0 -4
- package/lib/core/backup.js +21 -4
- package/lib/core/boot-rescue.d.ts +1 -1
- package/lib/core/boot-rescue.js +12 -1
- package/lib/core/boot-safety.js +37 -2
- package/lib/core/conflict-decisions.js +2 -1
- package/lib/core/exporter.js +22 -1
- package/lib/core/journal.d.ts +54 -4
- package/lib/core/journal.js +158 -35
- package/lib/core/local-plugin-host.d.ts +29 -0
- package/lib/core/local-plugin-host.js +55 -48
- package/lib/core/messages.d.ts +17 -0
- package/lib/core/messages.js +34 -0
- package/lib/core/migration-history.js +16 -9
- package/lib/core/model-tools.d.ts +2 -2
- package/lib/core/model-tools.js +20 -2
- package/lib/core/patch-chain.d.ts +65 -0
- package/lib/core/patch-chain.js +100 -0
- package/lib/core/patch-document.d.ts +32 -4
- package/lib/core/patch-document.js +48 -17
- package/lib/core/patch-secret-guard.d.ts +49 -0
- package/lib/core/patch-secret-guard.js +164 -0
- package/lib/core/reconcile.d.ts +8 -0
- package/lib/core/reconcile.js +18 -3
- package/lib/core/reinstall.d.ts +2 -0
- package/lib/core/reinstall.js +6 -2
- package/lib/core/restore.js +31 -6
- package/lib/core/section-sanitize.d.ts +32 -0
- package/lib/core/section-sanitize.js +13 -0
- package/lib/core/snapshot-diff.d.ts +30 -0
- package/lib/core/snapshot-diff.js +56 -20
- package/lib/core/startup-barrier.js +8 -2
- package/lib/core/types.d.ts +38 -1
- package/lib/core/update-check.js +51 -2
- package/lib/foreign/kernel.js +9 -2
- package/lib/foreign/read-claude-plugins.js +29 -11
- package/lib/foreign/read-dsh.js +31 -2
- package/lib/foreign/session-ir.js +50 -9
- package/lib/foreign/session-read.d.ts +8 -0
- package/lib/foreign/session-read.js +26 -0
- package/lib/index.d.ts +9 -4
- package/lib/index.js +42 -47
- package/lib/profiles/dsh-profile-io.d.ts +20 -0
- package/lib/profiles/dsh-profile-io.js +27 -0
- package/lib/profiles/dsh-profile-manager.d.ts +27 -0
- package/lib/profiles/dsh-profile-manager.js +45 -4
- package/lib/profiles/dsh-profile-runtime.d.ts +5 -1
- package/lib/profiles/dsh-profile-runtime.js +16 -3
- package/lib/profiles/process-control.d.ts +18 -1
- package/lib/profiles/process-control.js +25 -1
- package/lib/routes/profiles.js +2 -1
- package/lib/routes/sync.js +19 -1
- package/lib/schema/types.d.ts +11 -0
- package/lib/security/redaction.js +22 -6
- package/lib/sync/autosync-repeat.d.ts +27 -0
- package/lib/sync/autosync-repeat.js +23 -0
- package/lib/sync/autosync-scheduler.d.ts +47 -2
- package/lib/sync/autosync-scheduler.js +217 -53
- package/lib/sync/baseline-heal.js +7 -0
- package/lib/sync/baseline-record.d.ts +67 -0
- package/lib/sync/baseline-record.js +74 -0
- package/lib/sync/blob-store.js +13 -0
- package/lib/sync/content-diff.d.ts +39 -0
- package/lib/sync/content-diff.js +46 -0
- package/lib/sync/git/git-transport.d.ts +32 -1
- package/lib/sync/git/git-transport.js +146 -26
- package/lib/sync/github-auth.d.ts +17 -1
- package/lib/sync/github-auth.js +37 -1
- package/lib/sync/local-changes.d.ts +15 -0
- package/lib/sync/local-changes.js +39 -0
- package/lib/sync/merge-apply-plan.d.ts +38 -0
- package/lib/sync/merge-apply-plan.js +76 -0
- package/lib/sync/merge-keyed.d.ts +68 -0
- package/lib/sync/merge-keyed.js +124 -0
- package/lib/sync/messages.d.ts +1 -0
- package/lib/sync/messages.js +2 -0
- package/lib/sync/patch-line-identity.d.ts +19 -0
- package/lib/sync/patch-line-identity.js +99 -0
- package/lib/sync/pending-merge.d.ts +41 -0
- package/lib/sync/pending-merge.js +61 -0
- package/lib/sync/plugin-removals.d.ts +15 -15
- package/lib/sync/plugin-removals.js +134 -83
- package/lib/sync/push-skip.d.ts +55 -0
- package/lib/sync/push-skip.js +70 -0
- package/lib/sync/s3/s3-transport.d.ts +14 -2
- package/lib/sync/s3/s3-transport.js +72 -48
- package/lib/sync/sync-engine.d.ts +44 -51
- package/lib/sync/sync-engine.js +160 -194
- package/lib/sync/sync-history.d.ts +7 -0
- package/lib/sync/sync-state.d.ts +28 -0
- package/lib/sync/sync-state.js +20 -0
- package/lib/sync/transport.d.ts +12 -3
- package/lib/sync/transport.js +13 -4
- package/lib/sync/webdav/webdav-transport.d.ts +19 -2
- package/lib/sync/webdav/webdav-transport.js +81 -40
- package/lib/sync/workspace-merge.d.ts +8 -2
- package/lib/ui/artifact-view.d.ts +1 -1
- package/lib/ui/commands.js +5 -11
- package/lib/ui/dsh-profiles-view.d.ts +8 -3
- package/lib/ui/dsh-profiles-view.js +9 -5
- package/lib/ui/foreign-view.d.ts +14 -0
- package/lib/ui/foreign-view.js +34 -0
- package/lib/ui/i18n.d.ts +7 -1
- package/lib/ui/i18n.js +15 -2
- package/lib/ui/menu-placement.js +1 -1
- package/lib/ui/migration-consult-view.d.ts +11 -0
- package/lib/ui/migration-consult-view.js +15 -0
- package/lib/ui/overview-view.d.ts +7 -0
- package/lib/ui/overview-view.js +3 -0
- package/lib/ui/report.d.ts +9 -0
- package/lib/ui/report.js +17 -4
- package/lib/ui/selection-model.d.ts +10 -2
- package/lib/ui/selection-model.js +23 -3
- package/lib/utils/async-once.d.ts +11 -0
- package/lib/utils/async-once.js +15 -0
- package/lib/utils/patch-chain-read.d.ts +51 -0
- package/lib/utils/patch-chain-read.js +240 -0
- package/lib/utils/patch-yaml.d.ts +39 -1
- package/lib/utils/patch-yaml.js +82 -2
- package/lib/utils/paths.d.ts +13 -0
- package/lib/utils/paths.js +35 -0
- package/lib/utils/workdir-lock.js +18 -3
- package/package.json +3 -2
- package/src/adapters/mcp.test.ts +29 -0
- package/src/adapters/mcp.ts +52 -14
- package/src/adapters/messages.ts +2 -0
- package/src/adapters/patch-key-guard.ts +29 -0
- package/src/adapters/plugin-data.test.ts +126 -0
- package/src/adapters/plugin-data.ts +97 -26
- package/src/adapters/plugins.test.ts +403 -0
- package/src/adapters/plugins.ts +198 -8
- package/src/adapters/prompts.ts +15 -4
- package/src/adapters/test-helpers.ts +15 -1
- package/src/cli/actions.test.ts +74 -1
- package/src/cli/actions.ts +27 -246
- package/src/cli/control-state.ts +143 -0
- package/src/cli/help.ts +21 -14
- package/src/cli/index.ts +123 -107
- package/src/cli/sessions-repair.ts +55 -22
- package/src/cli/web/client-script.ts +71 -5
- package/src/cli/web/page.ts +327 -208
- package/src/cli/web/routes.ts +85 -25
- package/src/cli/web/web.test.ts +65 -0
- package/src/cli/write-gates.ts +149 -0
- package/src/client/ConfigManagerSection.tsx +8 -4
- package/src/client/about/AboutPanel.tsx +9 -12
- package/src/client/about/release-notes-view.test.ts +17 -0
- package/src/client/about/release-notes-view.ts +49 -24
- package/src/client/api.ts +2 -1
- package/src/client/chat/ChatEntryView.tsx +2 -2
- package/src/client/chat/rollback-entry-view.ts +6 -1
- package/src/client/common/CommandPalette.tsx +6 -3
- package/src/client/common/ConfirmDialog.tsx +29 -12
- package/src/client/common/ContentPicker.tsx +24 -24
- package/src/client/common/Modal.tsx +12 -5
- package/src/client/common/MoreMenu.tsx +4 -1
- package/src/client/common/RunsCenter.tsx +103 -32
- package/src/client/common/Select.tsx +2 -2
- package/src/client/common/floating-bounds.ts +1 -1
- package/src/client/common/floating-units.test.ts +1 -2
- package/src/client/common/plan-text-redaction.test.ts +190 -5
- package/src/client/common/runs-center-guard.test.ts +60 -0
- package/src/client/common/runs-center-view.test.ts +128 -0
- package/src/client/common/runs-center-view.ts +96 -0
- package/src/client/common/section-title-action.test.ts +66 -0
- package/src/client/common/ui.tsx +93 -30
- package/src/client/config-manager.module.css +1515 -270
- package/src/client/consult/ConsultCard.tsx +7 -6
- package/src/client/environment/EnvironmentPanel.tsx +22 -25
- package/src/client/environment/maintenance/DiskUsageCard.tsx +69 -96
- package/src/client/environment/profiles-incomplete-ui.test.ts +8 -8
- package/src/client/export/ExportView.tsx +7 -16
- package/src/client/history/HistoryPanel.tsx +88 -28
- package/src/client/history/history-locales.ts +3 -3
- package/src/client/home/BackupScheduleCard.tsx +77 -69
- package/src/client/home/HomePanel.tsx +47 -12
- package/src/client/import/ConflictList.tsx +13 -13
- package/src/client/import/ForeignImportView.tsx +67 -9
- package/src/client/import/ImportWizardView.tsx +4 -4
- package/src/client/import/PathMappingForm.tsx +36 -9
- package/src/client/import/PathPickerDialog.tsx +2 -1
- package/src/client/import/import-wizard-split.test.ts +1 -1
- package/src/client/import/import-wizard-steps.tsx +51 -39
- package/src/client/import/use-import-wizard-controller.test.ts +129 -0
- package/src/client/import/use-import-wizard-controller.ts +116 -22
- package/src/client/library/ArtifactRow.tsx +2 -2
- package/src/client/library/BackupInspectView.tsx +21 -15
- package/src/client/library/LibraryActions.tsx +116 -28
- package/src/client/library/LibraryPanel.tsx +14 -15
- package/src/client/library/RestorePlanView.tsx +13 -8
- package/src/client/locales/about.ts +0 -2
- package/src/client/locales/backup.ts +15 -12
- package/src/client/locales/common.ts +2 -0
- package/src/client/locales/export.ts +5 -12
- package/src/client/locales/foreign.ts +4 -2
- package/src/client/locales/import.ts +5 -2
- package/src/client/locales/overview.ts +4 -0
- package/src/client/locales/profiles.ts +32 -4
- package/src/client/locales/restore.ts +2 -2
- package/src/client/locales/sessions.ts +0 -2
- package/src/client/locales/shell.ts +2 -2
- package/src/client/market/MarketImportReview.tsx +4 -4
- package/src/client/market/MarketPanel.tsx +58 -56
- package/src/client/market/MyConfigsList.tsx +34 -32
- package/src/client/market/MyConfigsLoginCard.tsx +12 -15
- package/src/client/market/MyConfigsView.tsx +8 -15
- package/src/client/market/MyConfigsWizard.tsx +7 -12
- package/src/client/market/market-locales.ts +0 -6
- package/src/client/market/my-configs-split.test.ts +2 -1
- package/src/client/nav-menu-clip-guard.test.ts +52 -0
- package/src/client/recovery/IncompleteCopiesSection.tsx +1 -3
- package/src/client/recovery/RecoveryPanel.tsx +35 -22
- package/src/client/recovery/RollbackCard.tsx +132 -75
- package/src/client/recovery/RollbackFileChanges.tsx +40 -27
- package/src/client/recovery/SessionHealthCard.tsx +2 -2
- package/src/client/recovery/SessionHealthDialog.tsx +5 -7
- package/src/client/recovery/SessionLayoutSection.tsx +3 -5
- package/src/client/recovery/recovery-locales.ts +12 -8
- package/src/client/recovery/rollback-enabled.ts +29 -0
- package/src/client/recovery/use-recovery-write.ts +5 -0
- package/src/client/run-store.test.ts +30 -0
- package/src/client/run-store.ts +21 -1
- package/src/client/sync/AddChannelCard.tsx +65 -0
- package/src/client/sync/AutosyncCard.tsx +184 -108
- package/src/client/sync/ChannelClearConfirmDialog.tsx +5 -1
- package/src/client/sync/ChannelConfigDialog.tsx +27 -48
- package/src/client/sync/MergePreviewView.tsx +5 -7
- package/src/client/sync/PushPreviewCard.tsx +2 -1
- package/src/client/sync/PushReportSections.tsx +35 -0
- package/src/client/sync/SyncChannelEntryCard.tsx +33 -24
- package/src/client/sync/SyncConfirmView.tsx +130 -133
- package/src/client/sync/SyncLogList.tsx +29 -14
- package/src/client/sync/SyncPanel.tsx +188 -185
- package/src/client/sync/SyncProbeRow.tsx +5 -7
- package/src/client/sync/SyncRepositoryPicker.tsx +17 -4
- package/src/client/sync/SyncSecuritySection.tsx +157 -0
- package/src/client/sync/SyncSettingsDialog.tsx +293 -0
- package/src/client/sync/SyncSettingsView.test.ts +26 -8
- package/src/client/sync/WorkDirCard.tsx +2 -4
- package/src/client/sync/config-clear-guard.test.ts +94 -0
- package/src/client/sync/config-clear-guard.ts +98 -0
- package/src/client/sync/config-dirty.test.ts +91 -0
- package/src/client/sync/config-dirty.ts +88 -0
- package/src/client/sync/history-model.test.ts +2 -0
- package/src/client/sync/history-model.ts +5 -0
- package/src/client/sync/merge-request.ts +20 -0
- package/src/client/sync/sync-api.ts +13 -1
- package/src/client/sync/sync-locales.ts +95 -47
- package/src/client/sync/sync-panel-clear.test.ts +44 -0
- package/src/client/sync/sync-push-preview.test.ts +9 -0
- package/src/client/sync/sync-view.test.ts +20 -0
- package/src/client/sync/sync-view.ts +76 -4
- package/src/core/backup.test.ts +61 -1
- package/src/core/backup.ts +21 -4
- package/src/core/boot-rescue.test.ts +35 -0
- package/src/core/boot-rescue.ts +13 -2
- package/src/core/boot-safety.test.ts +25 -0
- package/src/core/boot-safety.ts +37 -2
- package/src/core/conflict-decisions.ts +2 -1
- package/src/core/exporter.ts +21 -1
- package/src/core/journal.test.ts +183 -0
- package/src/core/journal.ts +163 -25
- package/src/core/local-plugin-host.test.ts +68 -2
- package/src/core/local-plugin-host.ts +31 -4
- package/src/core/messages.ts +34 -0
- package/src/core/migration-history.test.ts +27 -0
- package/src/core/migration-history.ts +12 -4
- package/src/core/model-tools.test.ts +67 -0
- package/src/core/model-tools.ts +22 -4
- package/src/core/patch-chain.test.ts +83 -0
- package/src/core/patch-chain.ts +150 -0
- package/src/core/patch-document.test.ts +48 -1
- package/src/core/patch-document.ts +66 -15
- package/src/core/patch-layers.test.ts +1 -1
- package/src/core/patch-secret-guard.test.ts +110 -0
- package/src/core/patch-secret-guard.ts +176 -0
- package/src/core/reconcile.ts +32 -4
- package/src/core/reinstall.ts +8 -2
- package/src/core/restore.ts +32 -7
- package/src/core/section-sanitize.ts +37 -0
- package/src/core/smoke.test.ts +2 -1
- package/src/core/snapshot-diff.test.ts +73 -1
- package/src/core/snapshot-diff.ts +66 -21
- package/src/core/startup-barrier.test.ts +64 -0
- package/src/core/startup-barrier.ts +8 -2
- package/src/core/types.ts +43 -2
- package/src/core/update-check.test.ts +40 -0
- package/src/core/update-check.ts +53 -2
- package/src/foreign/claude-code.test.ts +5 -0
- package/src/foreign/claude-plugins.test.ts +57 -0
- package/src/foreign/claude-sessions-bytes.test.ts +7 -1
- package/src/foreign/dsh.test.ts +23 -0
- package/src/foreign/kernel.ts +9 -2
- package/src/foreign/read-claude-plugins.ts +32 -11
- package/src/foreign/read-dsh.ts +33 -2
- package/src/foreign/session-ir.test.ts +67 -0
- package/src/foreign/session-ir.ts +54 -14
- package/src/foreign/session-read.ts +23 -0
- package/src/index.facade.test.ts +186 -6
- package/src/index.ts +53 -47
- package/src/profiles/dsh-profile-copy-rollback.test.ts +58 -4
- package/src/profiles/dsh-profile-io.ts +29 -0
- package/src/profiles/dsh-profile-manager.test.ts +30 -0
- package/src/profiles/dsh-profile-manager.ts +53 -5
- package/src/profiles/dsh-profile-runtime.test.ts +29 -7
- package/src/profiles/dsh-profile-runtime.ts +17 -3
- package/src/profiles/process-control.test.ts +97 -0
- package/src/profiles/process-control.ts +28 -1
- package/src/routes/profiles.ts +2 -1
- package/src/routes/sync.ts +19 -1
- package/src/schema/types.ts +16 -1
- package/src/security/redaction.test.ts +31 -0
- package/src/security/redaction.ts +23 -6
- package/src/security/security.test.ts +1 -1
- package/src/sync/autosync-repeat.test.ts +58 -0
- package/src/sync/autosync-repeat.ts +55 -0
- package/src/sync/autosync-scheduler.test.ts +515 -0
- package/src/sync/autosync-scheduler.ts +225 -51
- package/src/sync/baseline-heal.ts +6 -0
- package/src/sync/baseline-record.ts +135 -0
- package/src/sync/blob-store.test.ts +16 -0
- package/src/sync/blob-store.ts +13 -0
- package/src/sync/content-diff.test.ts +95 -0
- package/src/sync/content-diff.ts +79 -0
- package/src/sync/git/git-transport.test.ts +151 -4
- package/src/sync/git/git-transport.ts +143 -27
- package/src/sync/github-auth.test.ts +26 -1
- package/src/sync/github-auth.ts +37 -1
- package/src/sync/local-changes.ts +40 -0
- package/src/sync/merge-apply-plan.ts +117 -0
- package/src/sync/merge-keyed.test.ts +167 -0
- package/src/sync/merge-keyed.ts +160 -0
- package/src/sync/messages.ts +3 -0
- package/src/sync/patch-line-identity.test.ts +73 -0
- package/src/sync/patch-line-identity.ts +105 -0
- package/src/sync/pending-merge.test.ts +41 -0
- package/src/sync/pending-merge.ts +85 -0
- package/src/sync/plugin-removals.test.ts +199 -39
- package/src/sync/plugin-removals.ts +150 -64
- package/src/sync/push-skip.test.ts +326 -0
- package/src/sync/push-skip.ts +102 -0
- package/src/sync/s3/s3-delete-and-blob-index.test.ts +249 -0
- package/src/sync/s3/s3-transport.ts +76 -42
- package/src/sync/sync-config.test.ts +39 -12
- package/src/sync/sync-device-identity.test.ts +3 -0
- package/src/sync/sync-engine.test.ts +465 -12
- package/src/sync/sync-engine.ts +189 -193
- package/src/sync/sync-history.ts +7 -0
- package/src/sync/sync-state.ts +48 -0
- package/src/sync/transport.test.ts +13 -1
- package/src/sync/transport.ts +12 -4
- package/src/sync/webdav/webdav-delete-and-blob-index.test.ts +249 -0
- package/src/sync/webdav/webdav-transport.ts +86 -34
- package/src/sync/workspace-merge.ts +9 -2
- package/src/ui/artifact-view.ts +1 -1
- package/src/ui/commands.test.ts +11 -0
- package/src/ui/commands.ts +5 -14
- package/src/ui/dsh-profiles-view.test.ts +16 -0
- package/src/ui/dsh-profiles-view.ts +11 -5
- package/src/ui/foreign-view.test.ts +49 -0
- package/src/ui/foreign-view.ts +47 -0
- package/src/ui/i18n.ts +15 -2
- package/src/ui/menu-placement.ts +1 -1
- package/src/ui/migration-consult-view.test.ts +20 -1
- package/src/ui/migration-consult-view.ts +17 -0
- package/src/ui/overview-view.ts +10 -0
- package/src/ui/report.test.ts +25 -1
- package/src/ui/report.ts +15 -4
- package/src/ui/selection-model.test.ts +29 -1
- package/src/ui/selection-model.ts +25 -4
- package/src/utils/async-once.ts +14 -0
- package/src/utils/js-yaml4.d.ts +35 -0
- package/src/utils/patch-chain-read.test.ts +171 -0
- package/src/utils/patch-chain-read.ts +259 -0
- package/src/utils/patch-yaml.test.ts +215 -3
- package/src/utils/patch-yaml.ts +98 -2
- package/src/utils/paths.test.ts +14 -1
- package/src/utils/paths.ts +35 -0
- package/src/utils/workdir-lock.test.ts +69 -0
- package/src/utils/workdir-lock.ts +17 -3
- package/lib/ui/path-mapping.d.ts +0 -38
- package/lib/ui/path-mapping.js +0 -75
- package/src/client/common/InfoHint.tsx +0 -289
- package/src/client/common/info-hint-guard.test.ts +0 -1119
- package/src/client/sync/DecryptPasswordCard.tsx +0 -48
- package/src/client/sync/SecurityOptionsCard.tsx +0 -97
- package/src/client/sync/SyncSectionPickerDialog.tsx +0 -213
- package/src/ui/path-mapping.test.ts +0 -67
- package/src/ui/path-mapping.ts +0 -103
package/src/cli/web/page.ts
CHANGED
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* 离线救急台页面 —— **服务端直出 HTML
|
|
2
|
+
* 离线救急台页面 —— **服务端直出 HTML + 渐进增强内联脚本**。
|
|
3
3
|
*
|
|
4
4
|
* 为什么不用客户端框架:救急台的场景是「DSH 都起不来了」,页面依赖越少越好 —— 因此这里直出
|
|
5
|
-
* HTML
|
|
6
|
-
* 样式内联在 <style> 里(独立于插件 UI 的 CSS Modules
|
|
7
|
-
*
|
|
8
|
-
* docs/architecture/cli-rescue-console.md —— 改 STYLE 前先读它,改完跑 web.test.ts 的 R3-02。
|
|
5
|
+
* HTML:**零构建、零外部资源、零第三方库**,配合 http.ts 里 sha256 钉死的 CSP。
|
|
6
|
+
* 样式内联在 <style> 里(独立于插件 UI 的 CSS Modules;契约与出处见 DESIGN.md §14 与
|
|
7
|
+
* docs/architecture/cli-rescue-console.md —— 改 STYLE 前先读它,改完跑 web.test.ts 的 R3-02)。
|
|
9
8
|
*
|
|
10
9
|
* 呈现纪律:每个数字都要能回答「你怎么知道的」—— 离线拿不到的(结构化分区/凭据/同步令牌)
|
|
11
|
-
* 一律显式列出并说明原因,绝不显示为 0
|
|
10
|
+
* 一律显式列出并说明原因,绝不显示为 0 或留空;展示文本一律先 redact() 再转义。
|
|
12
11
|
*/
|
|
13
12
|
import { DEFAULT_BACKUP_SECTIONS, OFFLINE_UNAVAILABLE_SECTIONS } from '../../core/backup-plan.ts'
|
|
14
13
|
import type { BackupVerifyResult } from '../../core/backup-verify.ts'
|
|
@@ -30,138 +29,156 @@ export interface PageChrome {
|
|
|
30
29
|
active: 'home' | 'disk' | 'sessions' | 'profiles' | 'unlock' | 'restore' | 'export' | 'reinstall'
|
|
31
30
|
}
|
|
32
31
|
|
|
32
|
+
// 13 色 token + 2 圆角 token(--radius / --radius-sm 只定义在亮色 :root,暗色不重复)
|
|
33
|
+
// 实测对比度(对 --card)均 >= 4.5:1 AA,见 docs/architecture/cli-rescue-console.md & web.test.ts R3-02
|
|
34
|
+
const LIGHT_TOKENS = '--fg:#111318;--muted:#5a606b;--bg:#f7f7f9;--card:#ffffff;--surface:#eef0f4;--line:#e3e5ea;--accent:#4b58e0;--accent-hover:#3a46c9;--on-accent:#ffffff;--ok:#157a53;--warn:#8a5d00;--bad:#c72a34;--scrim:rgba(15,17,22,.42);--radius:8px;--radius-sm:6px'
|
|
35
|
+
const DARK_TOKENS = '--fg:#f0f1f4;--muted:#8d929c;--bg:#08090b;--card:#101114;--surface:#17181c;--line:#23252b;--accent:#7b88ff;--accent-hover:#96a0ff;--on-accent:#0a0b12;--ok:#4ed6a4;--warn:#f0bf6a;--bad:#ff7b7b;--scrim:rgba(0,0,0,.62)'
|
|
36
|
+
|
|
33
37
|
const STYLE = [
|
|
34
|
-
// ---- 设计 token
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
':root{color-scheme:
|
|
39
|
-
'
|
|
40
|
-
|
|
41
|
-
'
|
|
42
|
-
//
|
|
43
|
-
':
|
|
44
|
-
':
|
|
45
|
-
'
|
|
46
|
-
'
|
|
47
|
-
|
|
48
|
-
'
|
|
49
|
-
|
|
50
|
-
'.
|
|
51
|
-
|
|
52
|
-
'.
|
|
53
|
-
'.
|
|
54
|
-
'
|
|
55
|
-
|
|
56
|
-
'.
|
|
57
|
-
'.
|
|
58
|
-
'.
|
|
59
|
-
'
|
|
60
|
-
'
|
|
61
|
-
'
|
|
62
|
-
'.
|
|
63
|
-
'
|
|
64
|
-
'
|
|
65
|
-
|
|
66
|
-
'
|
|
67
|
-
'
|
|
68
|
-
'
|
|
69
|
-
'
|
|
70
|
-
'
|
|
71
|
-
|
|
72
|
-
'.
|
|
73
|
-
'.
|
|
74
|
-
'.
|
|
75
|
-
'.
|
|
76
|
-
'.
|
|
77
|
-
'.
|
|
78
|
-
'.
|
|
79
|
-
'.
|
|
80
|
-
'.
|
|
81
|
-
'
|
|
82
|
-
'
|
|
83
|
-
'
|
|
84
|
-
'
|
|
85
|
-
'
|
|
86
|
-
'.
|
|
87
|
-
'.
|
|
88
|
-
'.
|
|
89
|
-
'.
|
|
90
|
-
'.
|
|
91
|
-
'.
|
|
92
|
-
'.
|
|
93
|
-
'.
|
|
94
|
-
'.
|
|
95
|
-
'.
|
|
96
|
-
'.
|
|
97
|
-
|
|
98
|
-
'.
|
|
99
|
-
'.
|
|
100
|
-
'
|
|
101
|
-
'
|
|
102
|
-
'
|
|
103
|
-
'.
|
|
104
|
-
'.
|
|
105
|
-
'.
|
|
106
|
-
'.
|
|
107
|
-
|
|
108
|
-
'.
|
|
109
|
-
'.
|
|
110
|
-
'.
|
|
111
|
-
'.
|
|
112
|
-
'.
|
|
113
|
-
'.
|
|
114
|
-
'.
|
|
115
|
-
'.
|
|
116
|
-
'.
|
|
117
|
-
'
|
|
118
|
-
|
|
119
|
-
'
|
|
120
|
-
'.
|
|
121
|
-
'.
|
|
122
|
-
'.
|
|
123
|
-
|
|
124
|
-
'.
|
|
125
|
-
'.
|
|
126
|
-
'.
|
|
127
|
-
'.
|
|
128
|
-
|
|
129
|
-
'
|
|
130
|
-
'
|
|
131
|
-
'
|
|
132
|
-
'
|
|
133
|
-
'
|
|
134
|
-
'
|
|
135
|
-
'
|
|
136
|
-
'.
|
|
137
|
-
'.
|
|
138
|
-
'.
|
|
139
|
-
'.
|
|
140
|
-
'
|
|
141
|
-
'
|
|
142
|
-
|
|
143
|
-
'
|
|
144
|
-
'
|
|
145
|
-
|
|
146
|
-
'.
|
|
147
|
-
'.
|
|
148
|
-
'.
|
|
149
|
-
'
|
|
150
|
-
'
|
|
38
|
+
// ---- 设计 token(明暗阶梯 + AA 语义色,R3-02 钉死 @media 与 [data-theme="dark"] 逐字相等) ----
|
|
39
|
+
':root{color-scheme:light dark;--font:system-ui,-apple-system,"Segoe UI",Roboto,"PingFang SC","Hiragino Sans GB","Microsoft YaHei","Noto Sans SC",sans-serif;--mono:ui-monospace,SFMono-Regular,Menlo,Consolas,"Liberation Mono",monospace;' + LIGHT_TOKENS + '}',
|
|
40
|
+
'@media (prefers-color-scheme:dark){:root:not([data-theme="light"]){' + DARK_TOKENS + '}}',
|
|
41
|
+
':root[data-theme="dark"]{' + DARK_TOKENS + '}',
|
|
42
|
+
':root[data-theme="dark"]{color-scheme:dark}',
|
|
43
|
+
':root[data-theme="light"]{color-scheme:light}',
|
|
44
|
+
'@view-transition{navigation:auto}',
|
|
45
|
+
'*{box-sizing:border-box}',
|
|
46
|
+
// 字号收敛到 4 档:12px / 13px / 15px / 20px;间距 6 档:4 / 8 / 12 / 16 / 24 / 32px
|
|
47
|
+
'body{margin:0;background:var(--bg);color:var(--fg);font-family:var(--font);font-size:13px;line-height:1.55}',
|
|
48
|
+
':focus-visible{outline:2px solid var(--accent);outline-offset:2px}',
|
|
49
|
+
'header.top{position:sticky;top:0;z-index:4;background:var(--card);border-bottom:1px solid var(--line);padding:12px 24px}',
|
|
50
|
+
'.brandRow{display:flex;align-items:center;justify-content:space-between;gap:12px;flex-wrap:wrap}',
|
|
51
|
+
'.brand{font-size:20px;line-height:1.5;font-weight:600;margin:0}',
|
|
52
|
+
'.brand .ver{font-size:12px;color:var(--muted);font-weight:400;margin-left:8px}',
|
|
53
|
+
// 配色开关:纯 surface 阶梯(无边框);无脚本时整组隐藏并回落跟随系统
|
|
54
|
+
'.themeSwitch{display:none;align-items:center;gap:4px;font-size:12px;color:var(--muted);background:var(--surface);padding:4px;border-radius:var(--radius-sm)}',
|
|
55
|
+
':root[data-dcm-js="1"] .themeSwitch{display:inline-flex}',
|
|
56
|
+
'.themeBtn{font:inherit;font-size:12px;height:24px;padding:0 8px;border:0;border-radius:var(--radius-sm);background:transparent;color:var(--muted);cursor:pointer;transition:background-color .15s ease,color .15s ease}',
|
|
57
|
+
'.themeBtn:hover{color:var(--fg)}',
|
|
58
|
+
'.themeBtn[aria-pressed="true"]{background:var(--card);color:var(--fg);font-weight:600}',
|
|
59
|
+
// 处境分组导航(3 个顶层组:状态 / 救援动作 / 检查)
|
|
60
|
+
'nav.sitNav{margin-top:8px;display:flex;align-items:center;gap:8px 12px;flex-wrap:wrap}',
|
|
61
|
+
'.navGroup{position:relative}',
|
|
62
|
+
'.navGroup>summary{list-style:none;cursor:pointer}',
|
|
63
|
+
'.navGroup>summary::-webkit-details-marker{display:none}',
|
|
64
|
+
'.navItem{display:inline-flex;align-items:center;gap:4px;height:32px;padding:0 12px;font-size:13px;font-weight:500;color:var(--muted);text-decoration:none;border-radius:var(--radius-sm);transition:background-color .15s ease,color .15s ease}',
|
|
65
|
+
'.navItem:hover{background:var(--surface);color:var(--fg)}',
|
|
66
|
+
'.navItem.active{background:color-mix(in srgb,var(--accent) 14%,var(--surface));color:var(--accent);font-weight:600}',
|
|
67
|
+
'.navDrop{position:absolute;top:calc(100% + 4px);left:0;min-width:220px;background:var(--card);border-radius:var(--radius);padding:8px;box-shadow:0 12px 32px var(--scrim);z-index:10;display:flex;flex-direction:column;gap:4px}',
|
|
68
|
+
'.navDrop a{display:flex;justify-content:space-between;align-items:center;padding:8px 12px;border-radius:var(--radius-sm);font-size:13px;color:var(--fg);text-decoration:none;transition:background-color .15s ease}',
|
|
69
|
+
'.navDrop a:hover{background:var(--surface)}',
|
|
70
|
+
'.navDrop a.active{background:color-mix(in srgb,var(--accent) 14%,var(--surface));color:var(--accent);font-weight:600}',
|
|
71
|
+
'.sub{color:var(--muted);font-size:12px;margin-top:8px;word-break:break-all}',
|
|
72
|
+
'main{padding:24px;max-width:1120px;margin:0 auto}',
|
|
73
|
+
'h2{font-size:15px;line-height:1.5;font-weight:600;margin:24px 0 12px}',
|
|
74
|
+
'h3{font-size:13px;line-height:1.5;font-weight:600;margin:16px 0 8px}',
|
|
75
|
+
// 层次靠表面阶梯(--bg -> --card -> --surface)与留白,去掉外边框
|
|
76
|
+
'section.card,.verdictCard,.foldCard{background:var(--card);border-radius:var(--radius);padding:16px 24px;margin-bottom:16px}',
|
|
77
|
+
'.verdictCard{padding:24px;margin-bottom:24px}',
|
|
78
|
+
'.verdictHead{display:flex;align-items:center;gap:12px;flex-wrap:wrap;margin-bottom:8px}',
|
|
79
|
+
'.verdictTitle{font-size:20px;line-height:1.5;font-weight:600;margin:0}',
|
|
80
|
+
'.verdictSub{font-size:13px;color:var(--muted);margin:0 0 16px}',
|
|
81
|
+
'.statGrid{display:grid;grid-template-columns:repeat(auto-fit,minmax(180px,1fr));gap:12px}',
|
|
82
|
+
'.statCell{background:var(--surface);border-radius:var(--radius-sm);padding:12px 16px}',
|
|
83
|
+
'.statLabel{font-size:12px;color:var(--muted);display:block;margin-bottom:4px}',
|
|
84
|
+
'.statValue{font-size:15px;font-weight:600}',
|
|
85
|
+
'table{border-collapse:collapse;width:100%;font-size:13px}',
|
|
86
|
+
'th,td{text-align:left;padding:8px 12px;border-bottom:1px solid var(--line);vertical-align:top}',
|
|
87
|
+
'th{color:var(--muted);font-size:12px;font-weight:600;white-space:nowrap} tr:last-child td{border-bottom:none}',
|
|
88
|
+
'td.num{text-align:right;white-space:nowrap;font-variant-numeric:tabular-nums}',
|
|
89
|
+
'code,.monoMeta{font-family:var(--mono);font-size:12px;color:var(--muted);word-break:break-all}',
|
|
90
|
+
'.muted{color:var(--muted)}',
|
|
91
|
+
'.banner{padding:12px 16px;border-radius:var(--radius);margin-bottom:16px;background:var(--card);box-shadow:inset 4px 0 0 var(--line)}',
|
|
92
|
+
'.banner.ok{box-shadow:inset 4px 0 0 var(--ok);background:color-mix(in srgb,var(--ok) 10%,var(--card))}',
|
|
93
|
+
'.banner.info{box-shadow:inset 4px 0 0 var(--accent);background:color-mix(in srgb,var(--accent) 8%,var(--card))}',
|
|
94
|
+
'.banner.warn{box-shadow:inset 4px 0 0 var(--warn);background:color-mix(in srgb,var(--warn) 10%,var(--card))}',
|
|
95
|
+
'.banner.bad{box-shadow:inset 4px 0 0 var(--bad);background:color-mix(in srgb,var(--bad) 12%,var(--card))}',
|
|
96
|
+
'.banner b{display:block;font-size:15px;margin-bottom:4px}',
|
|
97
|
+
'.chip,.pillOk,.pillWarn,.pillBad{display:inline-block;padding:2px 8px;border-radius:var(--radius-sm);background:var(--surface);font-size:12px;font-weight:600;margin-right:8px}',
|
|
98
|
+
'.pillOk{background:color-mix(in srgb,var(--ok) 14%,var(--card));color:var(--ok)}',
|
|
99
|
+
'.pillWarn{background:color-mix(in srgb,var(--warn) 16%,var(--card));color:var(--warn)}',
|
|
100
|
+
'.pillBad{background:color-mix(in srgb,var(--bad) 16%,var(--card));color:var(--bad)}',
|
|
101
|
+
'.grid{display:grid;grid-template-columns:repeat(auto-fit,minmax(280px,1fr));gap:8px 24px}',
|
|
102
|
+
'.kv{display:flex;gap:8px;align-items:baseline;font-size:12px} .kv .k{color:var(--muted);min-width:96px;flex:none}',
|
|
103
|
+
'.kv .v{display:flex;align-items:center;gap:8px;flex-wrap:wrap;word-break:break-all}',
|
|
104
|
+
'footer{color:var(--muted);font-size:12px;padding:16px 24px 32px;max-width:1120px;margin:24px auto 0;background:var(--card);border-radius:var(--radius)}',
|
|
105
|
+
'footer ul{margin:8px 0 0;padding-left:16px} footer li{margin:4px 0}',
|
|
106
|
+
'a{color:var(--accent)} a:hover{color:var(--accent-hover)}',
|
|
107
|
+
'.sev{font-weight:600} .sev.blocksStartup,.sev.unloadable{color:var(--bad)} .sev.nextRequestFails,.sev.invisible{color:var(--warn)} .sev.ok{color:var(--ok)}',
|
|
108
|
+
'.actions{display:grid;grid-template-columns:repeat(auto-fit,minmax(260px,1fr));gap:16px;margin-bottom:24px}',
|
|
109
|
+
'.actionCard{display:flex;flex-direction:column;justify-content:space-between;gap:12px;padding:16px;border-radius:var(--radius);background:var(--card);transition:background-color .15s ease,transform .15s ease}',
|
|
110
|
+
'.actionCard:hover{background:color-mix(in srgb,var(--accent) 4%,var(--card))}',
|
|
111
|
+
'.actionTitle{font-size:15px;font-weight:600;margin:0 0 4px}',
|
|
112
|
+
'.actionDesc{margin:0;font-size:13px;color:var(--muted)}',
|
|
113
|
+
'.whenLine{margin:8px 0 0;padding:8px 12px;background:var(--surface);border-radius:var(--radius-sm);font-size:12px;color:var(--fg)}',
|
|
114
|
+
'.foldCard>summary{cursor:pointer;list-style:none;font-size:15px;font-weight:600;display:flex;align-items:center;justify-content:space-between;gap:8px}',
|
|
115
|
+
'.foldCard>summary::-webkit-details-marker{display:none}',
|
|
116
|
+
'.foldBody{margin-top:16px;animation:dcmFadeUp .18s ease-out both}',
|
|
117
|
+
'.flowSteps{display:flex;gap:8px;list-style:none;padding:0;margin:0 0 16px;flex-wrap:wrap}',
|
|
118
|
+
'.flowStep{font-size:12px;padding:4px 12px;border-radius:var(--radius-sm);background:var(--surface);color:var(--muted)}',
|
|
119
|
+
'.flowStep.active{background:color-mix(in srgb,var(--accent) 14%,var(--card));color:var(--accent);font-weight:600}',
|
|
120
|
+
'.flowStep.doneOk{background:color-mix(in srgb,var(--ok) 14%,var(--card));color:var(--ok);font-weight:600}',
|
|
121
|
+
'.flowStep.doneBad{background:color-mix(in srgb,var(--bad) 14%,var(--card));color:var(--bad);font-weight:600}',
|
|
122
|
+
'.confirmForm{margin-top:8px}',
|
|
123
|
+
'.checkList{display:flex;flex-direction:column;gap:8px;margin:8px 0}',
|
|
124
|
+
'.checkRow{display:flex;gap:12px;align-items:flex-start;font-size:13px}',
|
|
125
|
+
'.checkRow input{margin-top:4px}',
|
|
126
|
+
'.consequence{background:var(--surface);border-radius:var(--radius-sm);padding:12px 16px;margin:12px 0;font-size:13px}',
|
|
127
|
+
// 按钮:唯一主色用于主动作;危险描边、次要透明、统一圆角 6px
|
|
128
|
+
'.btnPrimary,.btnDanger,.btnPlain{display:inline-flex;align-items:center;justify-content:center;gap:8px;font:inherit;font-size:13px;font-weight:600;height:40px;padding:0 16px;border-radius:var(--radius-sm);cursor:pointer;text-decoration:none;transition:background-color .15s ease,border-color .15s ease,color .15s ease}',
|
|
129
|
+
'.btnPrimary{border:0;background:var(--accent);color:var(--on-accent)}',
|
|
130
|
+
'.btnPrimary:hover{background:var(--accent-hover);color:var(--on-accent)}',
|
|
131
|
+
'.btnDanger{border:1px solid var(--bad);background:transparent;color:var(--bad)}',
|
|
132
|
+
'.btnDanger:hover{background:color-mix(in srgb,var(--bad) 12%,transparent)}',
|
|
133
|
+
'.btnPlain{border:1px solid var(--line);background:transparent;color:var(--fg)}',
|
|
134
|
+
'.btnPlain:hover{background:var(--surface);color:var(--fg)}',
|
|
135
|
+
'.copyBtn{display:none;align-items:center;font:inherit;font-size:12px;height:24px;padding:0 8px;border:1px solid var(--line);border-radius:var(--radius-sm);background:transparent;color:var(--muted);cursor:pointer;transition:background-color .15s ease,color .15s ease}',
|
|
136
|
+
':root[data-dcm-js="1"] .copyBtn{display:inline-flex}',
|
|
137
|
+
'.copyBtn:hover{background:var(--surface);color:var(--fg)}',
|
|
138
|
+
'.copyBtn[data-copied="1"]{color:var(--ok)}',
|
|
139
|
+
'.btnSpinner{display:inline-block;width:12px;height:12px;border:2px solid color-mix(in srgb,currentColor 28%,transparent);border-top-color:currentColor;border-radius:50%;animation:dcmSpin .7s linear infinite}',
|
|
140
|
+
'.resultList{margin:0;padding-left:16px} .resultList li{margin:4px 0;word-break:break-all}',
|
|
141
|
+
'.gapTable{margin-top:12px}',
|
|
142
|
+
'.inputText,.repairForm select{font:inherit;font-size:13px;height:40px;padding:0 12px;border:0;border-bottom:1px solid var(--muted);border-radius:var(--radius-sm);background:var(--surface);color:var(--fg)}',
|
|
143
|
+
'.inputText{min-width:240px} .repairForm select{max-width:420px}',
|
|
144
|
+
'.inputText:focus-visible,.repairForm select:focus-visible{outline-offset:-2px}',
|
|
145
|
+
'.repairForm{display:flex;gap:8px;align-items:center;flex-wrap:wrap;margin:8px 0}',
|
|
146
|
+
'.confirmWrap{margin-top:8px}',
|
|
147
|
+
'.confirmWrap>summary{cursor:pointer;list-style:none}',
|
|
148
|
+
'.confirmWrap>summary::-webkit-details-marker{display:none}',
|
|
149
|
+
'.confirmTitle{font-size:15px;margin:0 0 8px}',
|
|
150
|
+
'.confirmBody{margin-top:12px}',
|
|
151
|
+
'dialog.dcmDialog{border:0;border-radius:var(--radius);padding:24px;background:var(--card);color:var(--fg);width:min(680px,92vw);max-height:86vh;overflow:auto;box-shadow:0 16px 32px var(--scrim);animation:dcmFadeUp .18s ease-out both}',
|
|
152
|
+
'dialog.dcmDialog::backdrop{background:var(--scrim);animation:dcmFadeUp .18s ease-out both}',
|
|
153
|
+
'.dialogFooter{display:flex;gap:12px;margin-top:16px}',
|
|
154
|
+
'.backRow{margin-top:16px}',
|
|
155
|
+
'.gateCard{background:color-mix(in srgb,var(--warn) 10%,var(--card));box-shadow:inset 4px 0 0 var(--warn);border-radius:var(--radius);padding:12px 16px;margin:12px 0}',
|
|
156
|
+
'.gateCard b{display:block;margin-bottom:8px}',
|
|
157
|
+
'.gateCard ul{margin:8px 0 0;padding-left:16px} .gateCard li{margin:4px 0;word-break:break-all}',
|
|
158
|
+
'.gatePath{font-size:12px;color:var(--muted)}',
|
|
159
|
+
'.cov{display:inline-block;padding:2px 8px;border-radius:var(--radius-sm);background:var(--surface);font-size:12px;margin-left:8px}',
|
|
160
|
+
'.cov.warn{background:color-mix(in srgb,var(--warn) 18%,var(--surface))}',
|
|
161
|
+
// ---- 动效、加载态与 390px 窄屏适配(尊重 prefers-reduced-motion) ----
|
|
162
|
+
'@keyframes dcmFadeUp{from{opacity:0;transform:translateY(4px)}to{opacity:1;transform:none}}',
|
|
163
|
+
'@keyframes dcmShimmer{from{background-position:-320px 0}to{background-position:320px 0}}',
|
|
164
|
+
'@keyframes dcmSpin{to{transform:rotate(360deg)}}',
|
|
165
|
+
'@keyframes dcmSweep{from{opacity:.25;transform:translateX(-40%)}to{opacity:.85;transform:translateX(40%)}}',
|
|
166
|
+
'@keyframes dcmSkeletonOut{to{opacity:0;visibility:hidden}}',
|
|
167
|
+
'main>*{animation:dcmFadeUp .18s ease-out both}',
|
|
168
|
+
'body::before{content:"";position:fixed;top:0;left:0;height:2px;width:100%;z-index:9;background:linear-gradient(90deg,transparent,var(--accent),transparent);animation:dcmSweep 1.1s linear infinite}',
|
|
169
|
+
'.skeleton{position:fixed;inset:0;z-index:8;background:var(--bg);padding:24px;animation:dcmSkeletonOut 0s linear 2.4s forwards}',
|
|
170
|
+
'.skeletonBar{height:12px;margin-bottom:12px;border-radius:var(--radius-sm);background:linear-gradient(90deg,var(--surface) 0%,color-mix(in srgb,var(--surface) 45%,var(--card)) 50%,var(--surface) 100%);background-size:320px 100%;animation:dcmShimmer 1.2s linear infinite}',
|
|
171
|
+
'.skeletonCard{height:96px;border-radius:var(--radius);background:var(--card);margin-bottom:16px;overflow:hidden}',
|
|
172
|
+
'@media (max-width:480px){header.top,main,footer{padding-left:16px;padding-right:16px}.navDrop{position:static;box-shadow:none;background:var(--surface);margin-top:4px;min-width:0}table{display:block;overflow-x:auto}.inputText{min-width:0;width:100%}}',
|
|
173
|
+
'@media (prefers-reduced-motion:reduce){*,*::before,*::after{animation:none!important;transition-duration:.001s!important;transform:none!important}}',
|
|
151
174
|
].join('\n')
|
|
152
175
|
|
|
153
176
|
/**
|
|
154
|
-
* 加载骨架:**纯 HTML + CSS 的"瞬态层"
|
|
155
|
-
*
|
|
156
|
-
* 为什么这样做而不是用 JS 显隐:救急台的渐进增强承诺是「禁用 JS 时功能与今天完全一致」。
|
|
157
|
-
* 这一层在 HTML 解析到它时就已经在屏幕上了(浏览器还没渲染完后续内容 = 真正在加载),
|
|
158
|
-
* 用 `animation-delay` 在 2.4s 后自动淡出并 `visibility:hidden`;它 `position:fixed` 覆盖视口、
|
|
159
|
-
* `pointer-events` 不拦交互(z-index 低于顶部进度条)。页面加载完成那一刻其实早已不可见,
|
|
160
|
-
* 所以不存在「卡住不消失」的风险 —— 这是无脚本约束下唯一诚实的做法。
|
|
177
|
+
* 加载骨架:**纯 HTML + CSS 的"瞬态层"**,禁用 JS 时在 2.4s 后自动淡出;开 reduced-motion 时零闪烁。
|
|
161
178
|
*/
|
|
162
179
|
const SKELETON = '<div class="skeleton" aria-hidden="true">'
|
|
163
180
|
+ '<div class="skeletonBar" style="width:34%"></div>'
|
|
164
|
-
+ '<div class="skeletonBar" style="width:58%;height:
|
|
181
|
+
+ '<div class="skeletonBar" style="width:58%;height:12px"></div>'
|
|
165
182
|
+ '<div class="skeletonCard"></div><div class="skeletonCard" style="height:132px"></div>'
|
|
166
183
|
+ '<div class="skeletonCard" style="height:72px"></div>'
|
|
167
184
|
+ '</div>'
|
|
@@ -172,8 +189,7 @@ const SKELETON = '<div class="skeleton" aria-hidden="true">'
|
|
|
172
189
|
* HTML 转义 + **脱敏**(唯一出口)。
|
|
173
190
|
*
|
|
174
191
|
* 两件事必须一起做,且顺序固定:先 `redact()` 再转义 —— 救急台会把磁盘上的路径、日志尾部、
|
|
175
|
-
* 失败原因直接渲染出来,里面可能夹带形如 `"apiKey": "…"` / `?token=…` 的内容(§7
|
|
176
|
-
* 展示文本渲染前一律过 `redact()`,插件 UI 与 CLI 都遵守,这里不能例外)。
|
|
192
|
+
* 失败原因直接渲染出来,里面可能夹带形如 `"apiKey": "…"` / `?token=…` 的内容(§7 纪律)。
|
|
177
193
|
*/
|
|
178
194
|
function escapeHtml(value: string): string {
|
|
179
195
|
return value
|
|
@@ -188,14 +204,7 @@ export function esc(value: string): string {
|
|
|
188
204
|
}
|
|
189
205
|
|
|
190
206
|
/**
|
|
191
|
-
* **只转义、不脱敏**的展示出口:唯一用途是救急台**有意**回传给终端用户的「能力 URL
|
|
192
|
-
* (启动器从子进程日志抓到的带 token 的认证 URL)。
|
|
193
|
-
*
|
|
194
|
-
* 为什么必须与 esc() 分开(cli-F1):esc() 先过安全侧 redact(),而 redact 的 URL_QUERY_RE
|
|
195
|
-
* 会把 `?token=…` 的值抹成 ***REDACTED*** —— 那正是认证 URL 的形态,于是页面给出一条必然
|
|
196
|
-
* 401 的死链(/profiles 的「打开实例」入口 + 启动结果页)。这些 URL 与终端里打印的 bootstrap
|
|
197
|
-
* URL 同一性质:只给拿到会话 cookie 的人,本来就该原样可见。
|
|
198
|
-
* 纪律:**只允许**用于本层自己签发/抓取的能力 URL;其余一切文本仍走 esc()。
|
|
207
|
+
* **只转义、不脱敏**的展示出口:唯一用途是救急台**有意**回传给终端用户的「能力 URL」。
|
|
199
208
|
*/
|
|
200
209
|
export function escCapability(value: string): string {
|
|
201
210
|
return escapeHtml(value)
|
|
@@ -220,6 +229,11 @@ function cellHtml(value: Cell): string {
|
|
|
220
229
|
return typeof value === 'string' ? esc(value) : value.html
|
|
221
230
|
}
|
|
222
231
|
|
|
232
|
+
function copyButton(raw: string, ariaLabel: string): string {
|
|
233
|
+
const safe = esc(raw)
|
|
234
|
+
return '<button type="button" class="copyBtn" data-dcm-copy="' + safe + '" aria-label="' + esc(ariaLabel) + '">复制</button>'
|
|
235
|
+
}
|
|
236
|
+
|
|
223
237
|
function renderTable(headers: readonly string[], rows: readonly Cell[][]): string {
|
|
224
238
|
if (rows.length === 0) return '<p class="muted">(无)</p>'
|
|
225
239
|
const head = headers.map((h) => '<th>' + esc(h) + '</th>').join('')
|
|
@@ -233,9 +247,10 @@ function banner(kind: 'ok' | 'info' | 'warn' | 'bad', title: string, text: strin
|
|
|
233
247
|
return '<div class="banner ' + kind + '"><b>' + esc(title) + '</b>' + esc(text) + '</div>'
|
|
234
248
|
}
|
|
235
249
|
|
|
236
|
-
function kv(pairs: ReadonlyArray<[string, string]
|
|
250
|
+
function kv(pairs: ReadonlyArray<[string, string]>, withCopy = false): string {
|
|
237
251
|
return '<div class="grid">' + pairs
|
|
238
|
-
.map(([k, v]) => '<div class="kv"><span class="k">' + esc(k) + '</span><span class="v"><code>' + esc(v) + '</code
|
|
252
|
+
.map(([k, v]) => '<div class="kv"><span class="k">' + esc(k) + '</span><span class="v"><code>' + esc(v) + '</code>'
|
|
253
|
+
+ (withCopy && v !== '' && v !== '—' ? copyButton(v, '复制 ' + k) : '') + '</span></div>')
|
|
239
254
|
.join('') + '</div>'
|
|
240
255
|
}
|
|
241
256
|
|
|
@@ -243,29 +258,50 @@ function section(title: string, body: string): string {
|
|
|
243
258
|
return '<h2>' + esc(title) + '</h2><section class="card">' + body + '</section>'
|
|
244
259
|
}
|
|
245
260
|
|
|
261
|
+
function foldSection(persistId: string, title: string, body: string): string {
|
|
262
|
+
return '<details class="foldCard" data-dcm-persist="' + esc(persistId) + '">'
|
|
263
|
+
+ '<summary><span>' + esc(title) + '</span><span class="monoMeta">展开 / 收起 ▾</span></summary>'
|
|
264
|
+
+ '<div class="foldBody">' + body + '</div></details>'
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
function renderFlowSteps(stage: 1 | 2 | 3, outcome?: 'ok' | 'bad'): string {
|
|
268
|
+
const steps: Array<{ n: 1 | 2 | 3; label: string }> = [
|
|
269
|
+
{ n: 1, label: '① 预览与前置检查' },
|
|
270
|
+
{ n: 2, label: '② 显式确认' },
|
|
271
|
+
{ n: 3, label: outcome === 'ok' ? '③ 已执行(成功)' : outcome === 'bad' ? '③ 已终止(失败或拒绝)' : '③ 执行结果' },
|
|
272
|
+
]
|
|
273
|
+
return '<ol class="flowSteps" aria-label="操作三阶段">' + steps.map((s) => {
|
|
274
|
+
let cls = 'flowStep'
|
|
275
|
+
if (stage === 3 && s.n === 3) cls += outcome === 'ok' ? ' doneOk' : ' doneBad'
|
|
276
|
+
else if (s.n === stage) cls += ' active'
|
|
277
|
+
return '<li class="' + cls + '"' + (s.n === stage ? ' aria-current="step"' : '') + '>' + esc(s.label) + '</li>'
|
|
278
|
+
}).join('') + '</ol>'
|
|
279
|
+
}
|
|
280
|
+
|
|
246
281
|
/* ------------------------------------------------------------ 布局 */
|
|
247
282
|
|
|
248
|
-
/**
|
|
249
|
-
* 救急台是**多页**的(首页 / 会话 / 恢复 / 磁盘 …),所以「本页」这个词必须能落地:
|
|
250
|
-
* 要么指向**本页内真实存在**的入口,要么**点名到页**(C1d 口径,captain 裁决)。
|
|
251
|
-
* 页面名在这里只定义一次,导航与跨页指引共用,免得两处说法漂移。
|
|
252
|
-
*/
|
|
253
283
|
const RESTORE_PAGE_LABEL = '恢复'
|
|
254
284
|
|
|
285
|
+
export type NavGroupId = 'status' | 'rescue' | 'inspect'
|
|
286
|
+
|
|
255
287
|
/**
|
|
256
|
-
*
|
|
257
|
-
* 全部由它派生 ——
|
|
258
|
-
* 又漏掉 `/restore` / `/export`)。`/healthz` 是 JSON 自述、不是页面,故不在表内。
|
|
288
|
+
* 救急台的**页面导航表(唯一事实源)**:处境分组导航与 404 / 405 / 错误页的「可用页面」清单
|
|
289
|
+
* 全部由它派生 —— 绝不另建第二份页面清单。
|
|
259
290
|
*/
|
|
260
|
-
export const CONSOLE_PAGE_NAV: ReadonlyArray<{
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
{ key: '
|
|
267
|
-
{ key: '
|
|
268
|
-
{ key: '
|
|
291
|
+
export const CONSOLE_PAGE_NAV: ReadonlyArray<{
|
|
292
|
+
key: PageChrome['active']
|
|
293
|
+
href: string
|
|
294
|
+
label: string
|
|
295
|
+
groups: readonly NavGroupId[]
|
|
296
|
+
}> = [
|
|
297
|
+
{ key: 'home', href: '/', label: '状态总览', groups: ['status'] },
|
|
298
|
+
{ key: 'restore', href: '/restore', label: RESTORE_PAGE_LABEL, groups: ['rescue'] },
|
|
299
|
+
{ key: 'unlock', href: '/unlock', label: '解锁', groups: ['rescue'] },
|
|
300
|
+
{ key: 'export', href: '/export', label: '导出', groups: ['rescue'] },
|
|
301
|
+
{ key: 'reinstall', href: '/reinstall', label: '重装', groups: ['rescue'] },
|
|
302
|
+
{ key: 'sessions', href: '/sessions', label: '会话体检与修复', groups: ['inspect', 'rescue'] },
|
|
303
|
+
{ key: 'disk', href: '/disk', label: '磁盘占用与清理', groups: ['inspect', 'rescue'] },
|
|
304
|
+
{ key: 'profiles', href: '/profiles', label: '档案与实例', groups: ['inspect'] },
|
|
269
305
|
]
|
|
270
306
|
|
|
271
307
|
/** 「可用页面」提示行(404 / 405 / 错误页共用这一份派生结果,不再各写一份)。 */
|
|
@@ -274,9 +310,21 @@ export function consolePagesHint(): string {
|
|
|
274
310
|
}
|
|
275
311
|
|
|
276
312
|
function renderHeader(chrome: PageChrome, subtitle: string): string {
|
|
277
|
-
const
|
|
278
|
-
|
|
279
|
-
|
|
313
|
+
const statusItem = CONSOLE_PAGE_NAV.find((item) => item.groups.includes('status'))!
|
|
314
|
+
const rescueItems = CONSOLE_PAGE_NAV.filter((item) => item.groups.includes('rescue'))
|
|
315
|
+
const inspectItems = CONSOLE_PAGE_NAV.filter((item) => item.groups.includes('inspect'))
|
|
316
|
+
const renderMenu = (title: string, items: typeof CONSOLE_PAGE_NAV): string => {
|
|
317
|
+
const anyActive = items.some((it) => it.key === chrome.active)
|
|
318
|
+
const drop = items
|
|
319
|
+
.map((it) => '<a href="' + it.href + '"' + (chrome.active === it.key ? ' class="active"' : '') + '>' + esc(it.label) + '</a>')
|
|
320
|
+
.join('')
|
|
321
|
+
return '<details class="navGroup" data-dcm-nav-group><summary class="navItem' + (anyActive ? ' active' : '') + '">'
|
|
322
|
+
+ esc(title) + ' ▾</summary><div class="navDrop">' + drop + '</div></details>'
|
|
323
|
+
}
|
|
324
|
+
// 顶层入口 3 组(<= 5):状态 / 救援动作 / 检查,全部从 CONSOLE_PAGE_NAV 派生
|
|
325
|
+
const nav = '<a href="' + statusItem.href + '" class="navItem' + (chrome.active === statusItem.key ? ' active' : '') + '">' + esc(statusItem.label) + '</a>'
|
|
326
|
+
+ renderMenu('救援动作', rescueItems)
|
|
327
|
+
+ renderMenu('检查', inspectItems)
|
|
280
328
|
const themeSwitch = '<div class="themeSwitch" role="group" aria-label="配色"><span>配色</span>'
|
|
281
329
|
+ [['auto', '自动'], ['light', '浅色'], ['dark', '深色']]
|
|
282
330
|
.map(([mode, label]) => '<button type="button" class="themeBtn" data-dcm-theme="' + mode + '" aria-pressed="false">' + label + '</button>')
|
|
@@ -285,7 +333,7 @@ function renderHeader(chrome: PageChrome, subtitle: string): string {
|
|
|
285
333
|
return '<header class="top"><div class="brandRow"><div class="brand">DCM 离线救急台'
|
|
286
334
|
+ '<span class="ver">v' + esc(chrome.version) + ' · 默认只读 / 写动作需确认</span></div>'
|
|
287
335
|
+ themeSwitch + '</div>'
|
|
288
|
-
+ '<nav>' +
|
|
336
|
+
+ '<nav class="sitNav" aria-label="处境导航">' + nav + '</nav>'
|
|
289
337
|
+ '<div class="sub">' + esc(subtitle) + '</div></header>'
|
|
290
338
|
}
|
|
291
339
|
|
|
@@ -300,7 +348,7 @@ function renderFooter(): string {
|
|
|
300
348
|
['dsh-config-manager recover-stale-lock', '回收残留环境锁(本页按同一实现执行)'],
|
|
301
349
|
]
|
|
302
350
|
return '<footer><div>本页默认<strong>只读</strong>;写动作(会话归位 / 清理缓存 / 回收残留锁)只在你点开对应页面并显式提交时才执行,执行前会先给计划与副作用说明。</div><ul>'
|
|
303
|
-
+ lines.map(([cmd, desc]) => '<li><code>' + esc(cmd) + '</code> — ' + esc(desc) + '</li>').join('')
|
|
351
|
+
+ lines.map(([cmd, desc]) => '<li><code>' + esc(cmd) + '</code> ' + copyButton(cmd, '复制命令') + ' — ' + esc(desc) + '</li>').join('')
|
|
304
352
|
+ '</ul></footer>'
|
|
305
353
|
}
|
|
306
354
|
|
|
@@ -308,8 +356,6 @@ export function renderLayout(chrome: PageChrome, body: string, subtitle = ''): s
|
|
|
308
356
|
return '<!doctype html>\n<html lang="zh-CN">\n<head>\n<meta charset="utf-8">\n'
|
|
309
357
|
+ '<meta name="viewport" content="width=device-width, initial-scale=1">\n'
|
|
310
358
|
+ '<title>DCM 离线救急台</title>\n<style>' + STYLE + '</style>\n'
|
|
311
|
-
// 脚本放 <head>:主题要在**首帧之前**落到 <html> 上(放 body 末尾会先闪一下强制主题)。
|
|
312
|
-
// 脚本自己的 DOM 操作全部等在 DOMContentLoaded,所以放 head 不会读到半个 DOM。
|
|
313
359
|
+ '<script>' + CONSOLE_SCRIPT + '</script>\n</head>\n<body>\n'
|
|
314
360
|
+ renderHeader(chrome, subtitle) + '\n' + SKELETON + '\n<main>\n' + body + '\n</main>\n' + renderFooter()
|
|
315
361
|
+ '\n</body>\n</html>\n'
|
|
@@ -328,6 +374,49 @@ export function renderMessagePage(title: string, message: string, hint = ''): st
|
|
|
328
374
|
|
|
329
375
|
export interface HomePageInput { status: RescueStatus; version: string; actions?: readonly ActionCard[] }
|
|
330
376
|
|
|
377
|
+
function renderVerdictCard(s: RescueStatus): string {
|
|
378
|
+
const blocked = s.safeMode.filter((r) => r.state === 'blocked')
|
|
379
|
+
const unknown = s.safeMode.filter((r) => r.state === 'unknown')
|
|
380
|
+
const established = s.safeMode.filter((r) => r.established)
|
|
381
|
+
const staleLock = s.lock.present && s.lock.state === 'STALE_LOCK_DETECTED'
|
|
382
|
+
let pillCls = 'pillOk'
|
|
383
|
+
let pillText = '可正常启动'
|
|
384
|
+
let title = 'DSH 现在可以启动(无阻断门)'
|
|
385
|
+
let summary = '未检测到 SAFE MODE 阻断与残留环境锁;若仍遇到异常,可按下方当前症状优先级处理。'
|
|
386
|
+
if (blocked.length > 0) {
|
|
387
|
+
pillCls = 'pillBad'
|
|
388
|
+
pillText = '受阻 · SAFE MODE'
|
|
389
|
+
title = 'DSH 写动作受阻:SAFE MODE 已激活'
|
|
390
|
+
summary = '存在未结案的配置 transaction(先在运行中 DSH 的「事故恢复」处理,或进「恢复」页查看快照方案)。'
|
|
391
|
+
} else if (staleLock || unknown.length > 0 || s.errors.length > 0) {
|
|
392
|
+
pillCls = 'pillWarn'
|
|
393
|
+
pillText = '需先处理异常'
|
|
394
|
+
title = staleLock ? 'DSH 可能被环境锁卡住' : 'DSH 存在待排查状态'
|
|
395
|
+
summary = staleLock
|
|
396
|
+
? '锁目录发现可回收的残留 ownership 文件;请进入「环境锁 / 回收残留锁」检查并回收。'
|
|
397
|
+
: '部分安全状态或目录读不出来,建议先展开下方详情核对错误信息与目录权限。'
|
|
398
|
+
} else if (s.instances.length > 0) {
|
|
399
|
+
pillCls = 'pillOk'
|
|
400
|
+
pillText = '已在运行'
|
|
401
|
+
title = 'DSH 正在运行(' + String(s.instances.length) + ' 个实例活跃)'
|
|
402
|
+
summary = '实例心跳正常;若需执行会话修复、恢复快照或卸载重装,请先手动停掉在跑实例。'
|
|
403
|
+
}
|
|
404
|
+
const safeValue = blocked.length > 0 ? '已激活(阻断)'
|
|
405
|
+
: unknown.length > 0 ? '状态未知'
|
|
406
|
+
: established.length === 0 ? '未建控制面' : '正常'
|
|
407
|
+
const lockValue = !s.lock.present ? '无残留锁' : (staleLock ? '残留锁(可回收)' : s.lock.state)
|
|
408
|
+
return '<section class="verdictCard">'
|
|
409
|
+
+ '<div class="verdictHead"><span class="' + pillCls + '">' + esc(pillText) + '</span>'
|
|
410
|
+
+ '<h2 class="verdictTitle">' + esc(title) + '</h2></div>'
|
|
411
|
+
+ '<p class="verdictSub">' + esc(summary) + '</p>'
|
|
412
|
+
+ '<div class="statGrid">'
|
|
413
|
+
+ '<div class="statCell"><span class="statLabel">SAFE MODE</span><span class="statValue">' + esc(safeValue) + '</span></div>'
|
|
414
|
+
+ '<div class="statCell"><span class="statLabel">环境锁</span><span class="statValue">' + esc(lockValue) + '</span></div>'
|
|
415
|
+
+ '<div class="statCell"><span class="statLabel">运行中实例</span><span class="statValue">' + String(s.instances.length) + ' 个</span></div>'
|
|
416
|
+
+ '<div class="statCell"><span class="statLabel">快照 / 导出备份</span><span class="statValue">' + String(s.snapshots.length) + ' / ' + String(s.backups.length) + '</span></div>'
|
|
417
|
+
+ '</div></section>'
|
|
418
|
+
}
|
|
419
|
+
|
|
331
420
|
export function renderHomePage(input: HomePageInput): string {
|
|
332
421
|
const s = input.status
|
|
333
422
|
const chrome: PageChrome = { version: input.version, paths: s.paths, active: 'home' }
|
|
@@ -335,18 +424,42 @@ export function renderHomePage(input: HomePageInput): string {
|
|
|
335
424
|
for (const error of s.errors) {
|
|
336
425
|
parts.push(banner('bad', '有一项读不出来', error + ' —— 下面的列表可能不完整,请先处理这条。'))
|
|
337
426
|
}
|
|
338
|
-
|
|
339
|
-
parts.push(
|
|
340
|
-
|
|
341
|
-
|
|
427
|
+
// 第一屏:只回答「DSH 现在能不能起」 + 按症状排序的前 <=3 个建议动作
|
|
428
|
+
parts.push(renderVerdictCard(s))
|
|
429
|
+
const allActions = input.actions ?? []
|
|
430
|
+
const topActions = allActions.slice(0, 3)
|
|
431
|
+
if (topActions.length > 0) {
|
|
432
|
+
parts.push('<h2>建议动作(按当前症状排序)</h2>' + actionCards(topActions))
|
|
433
|
+
}
|
|
434
|
+
// 第二屏:全量入口、快照/备份产物、环境明细、能力边界按需展开,避免首屏过载
|
|
342
435
|
const unreadableList = new Set(s.errors)
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
436
|
+
const navRows: Cell[][] = CONSOLE_PAGE_NAV.map((item) => {
|
|
437
|
+
const matched = allActions.find((a) => a.href === item.href)
|
|
438
|
+
return [
|
|
439
|
+
{ html: '<a href="' + item.href + '">' + esc(item.label) + '</a>' },
|
|
440
|
+
{ html: '<code>' + esc(item.href) + '</code>' },
|
|
441
|
+
matched?.when ?? matched?.description ?? '按处境进入对应诊断或写操作页',
|
|
442
|
+
]
|
|
443
|
+
})
|
|
444
|
+
const lockRow: Cell[][] = allActions.some((a) => a.href === '/lock')
|
|
445
|
+
? [[{ html: '<a href="/lock">环境锁 / 回收残留锁</a>' }, { html: '<code>/lock</code>' }, allActions.find((a) => a.href === '/lock')?.when ?? '启动或写入报环境锁冲突时点它']]
|
|
446
|
+
: []
|
|
447
|
+
parts.push('<h2>更多诊断与详细清单(按需展开)</h2>')
|
|
448
|
+
parts.push(foldSection('home-all-actions', '全部 8 个救援与检查入口',
|
|
449
|
+
renderTable(['入口', '路径', '适用场景'], [...navRows, ...lockRow])))
|
|
450
|
+
parts.push(foldSection('home-artifacts',
|
|
451
|
+
'快照与备份产物(' + String(s.snapshots.length) + ' 个快照 · ' + String(s.backups.length) + ' 个备份)',
|
|
452
|
+
'<h3>快照(导入前备份)</h3>'
|
|
453
|
+
+ snapshotsBody(s.snapshots, [...unreadableList].some((e) => e.includes('快照目录读不出来')))
|
|
454
|
+
+ '<h3>备份产物(导出目录)</h3>'
|
|
455
|
+
+ backupsBody(s.backups, [...unreadableList].some((e) => e.includes('导出目录读不出来')))))
|
|
456
|
+
parts.push(foldSection('home-env', '环境明细:SAFE MODE、路径、心跳与环境锁',
|
|
457
|
+
safeModeBanner(s.safeMode)
|
|
458
|
+
+ '<h3>路径与口径</h3>' + pathsBody(s.paths, s.generatedAt)
|
|
459
|
+
+ '<h3>运行中的 DSH 实例(心跳)</h3>' + instancesBody(s.instances)
|
|
460
|
+
+ '<h3>环境锁</h3>' + lockBody(s.lock)))
|
|
461
|
+
parts.push(foldSection('home-capability', '能力边界与重装说明(能做什么 / 不能做什么)',
|
|
462
|
+
capabilityBody() + '<h3>离线看不到什么</h3>' + offlineBody()))
|
|
350
463
|
const subtitle = s.paths.homeDir + ' · profile ' + s.paths.profile + ' · 生成于 ' + s.generatedAt
|
|
351
464
|
return renderLayout(chrome, parts.join('\n'), subtitle)
|
|
352
465
|
}
|
|
@@ -395,7 +508,7 @@ function pathsBody(paths: RescuePaths, generatedAt: string): string {
|
|
|
395
508
|
['锁目录', paths.locksDir],
|
|
396
509
|
['profile', paths.profile],
|
|
397
510
|
['生成时间', generatedAt],
|
|
398
|
-
])
|
|
511
|
+
], true)
|
|
399
512
|
}
|
|
400
513
|
|
|
401
514
|
function safeModeBanner(reports: readonly SafeModeReport[]): string {
|
|
@@ -540,12 +653,13 @@ export function renderDiskPage(
|
|
|
540
653
|
+ unreadableAreas.map((area) => '<code>' + esc(area) + '</code>').join('、') + '。</p>')
|
|
541
654
|
const retention = '<p class="muted">定时备份保留最近 ' + String(report.backupRetention.keepLast)
|
|
542
655
|
+ ' 个(最新一份 ' + esc(formatBytes(report.backupRetention.latestBackupBytes)) + ','
|
|
543
|
-
// C1d:清理的写入口**就在本页下一张卡**(/disk/cleanup,见 :DISK_CLEANUP_SECTION_TITLE),
|
|
544
|
-
// 旧文案「本页不提供」与它自相矛盾。按裁决 (a) 指向本页真实存在的入口。
|
|
545
656
|
+ esc(formatIso(report.backupRetention.latestBackupAt)) + ')。清理是写动作,就在本页下方「'
|
|
546
657
|
+ DISK_CLEANUP_SECTION_TITLE + '」卡里执行(需显式确认)。</p>'
|
|
547
|
-
const parts = [
|
|
548
|
-
|
|
658
|
+
const parts = [
|
|
659
|
+
renderFlowSteps(2),
|
|
660
|
+
section('磁盘占用(只读体检)', summary + renderTable(
|
|
661
|
+
['子区', '体积', '文件数', '回收策略', '已超期'], rows) + retention),
|
|
662
|
+
]
|
|
549
663
|
if (done === 'cleaned') parts.unshift(banner('ok', '清理已完成', '结果见下方逐条明细(本次操作的回执)。'))
|
|
550
664
|
const cleanable = report.reclaimableBytes + report.expiredBytes
|
|
551
665
|
parts.push(section(DISK_CLEANUP_SECTION_TITLE, renderConfirmForm({
|
|
@@ -737,7 +851,7 @@ export function renderSessionsPage(
|
|
|
737
851
|
if (result === null) {
|
|
738
852
|
return renderLayout(chrome, banner('bad', '会话体检失败', error ?? '未知原因'), paths.homeDir + ' · 只读')
|
|
739
853
|
}
|
|
740
|
-
const parts: string[] = []
|
|
854
|
+
const parts: string[] = [renderFlowSteps(2)]
|
|
741
855
|
if (!result.sessionsDirExists) {
|
|
742
856
|
parts.push(banner('warn', '这台机器上没有会话数据', '会话根不存在:' + result.sessionsDir))
|
|
743
857
|
}
|
|
@@ -812,6 +926,8 @@ export interface ActionCard {
|
|
|
812
926
|
id: string
|
|
813
927
|
title: string
|
|
814
928
|
description: string
|
|
929
|
+
/** 什么情况下点它(首页建议卡必现一行) */
|
|
930
|
+
when?: string
|
|
815
931
|
href: string
|
|
816
932
|
disabled: boolean
|
|
817
933
|
disabledReason?: string
|
|
@@ -819,23 +935,17 @@ export interface ActionCard {
|
|
|
819
935
|
|
|
820
936
|
function actionCards(cards: readonly ActionCard[]): string {
|
|
821
937
|
if (cards.length === 0) return ''
|
|
822
|
-
return '<div class="actions">' + cards.map((c) => {
|
|
823
|
-
const
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
+ '</
|
|
938
|
+
return '<div class="actions">' + cards.map((c, index) => {
|
|
939
|
+
const ctaCls = index === 0 && !c.disabled ? 'btnPrimary' : 'btnPlain'
|
|
940
|
+
const btn = '<a class="' + ctaCls + '" href="' + esc(c.href) + '">' + esc(c.title) + ' →</a>'
|
|
941
|
+
const whenHtml = c.when === undefined ? '' : '<p class="whenLine"><b>什么情况下点它:</b>' + esc(c.when) + '</p>'
|
|
942
|
+
return '<div class="actionCard"><div><div class="actionTitle">' + esc(c.title) + '</div>'
|
|
943
|
+
+ (c.disabled ? '<p class="actionDesc">' + esc(c.disabledReason ?? '当前不可用。') + '</p>'
|
|
944
|
+
: '<p class="actionDesc">' + esc(c.description) + '</p>' + whenHtml)
|
|
945
|
+
+ '</div><div>' + btn + '</div></div>'
|
|
828
946
|
}).join('') + '</div>'
|
|
829
947
|
}
|
|
830
948
|
|
|
831
|
-
/**
|
|
832
|
-
* 「确认后执行」表单:放宽的是**展示层**,不是提交语义。
|
|
833
|
-
*
|
|
834
|
-
* 服务端直出的是 `<details open>` + 原始 `<form method="post">`(一次性 token、副作用说明、勾选项
|
|
835
|
-
* 全都在表单里):禁用 JS 时它就是今天那份可直接提交的纯 HTML。有 JS 且浏览器支持 showModal 时,
|
|
836
|
-
* 客户端脚本才把 details 升级成原生 `<dialog>` —— 提交仍然 POST 到同一个 action、带同一个 token,
|
|
837
|
-
* token 校验顺序(token → 安全门)在服务端一字未改。客户端校验/弹窗只算 UX,不构成任何边界。
|
|
838
|
-
*/
|
|
839
949
|
export function renderConfirmForm(options: {
|
|
840
950
|
action: string
|
|
841
951
|
token: string
|
|
@@ -843,6 +953,8 @@ export function renderConfirmForm(options: {
|
|
|
843
953
|
consequence: string
|
|
844
954
|
submitLabel: string
|
|
845
955
|
danger: boolean
|
|
956
|
+
/** 列表页同屏多个非危险按钮时,除首个外设 true 退为中性次要样式,保单屏唯一主色 */
|
|
957
|
+
neutral?: boolean
|
|
846
958
|
checklist?: ReadonlyArray<{ name: string; label: string; description: string; checked: boolean }>
|
|
847
959
|
/** 固定随表单提交的隐藏字段(如档案名)—— 表单是唯一参数载体,不依赖客户端脚本 */
|
|
848
960
|
hidden?: Record<string, string>
|
|
@@ -852,6 +964,7 @@ export function renderConfirmForm(options: {
|
|
|
852
964
|
versionField?: string
|
|
853
965
|
note?: string
|
|
854
966
|
}): string {
|
|
967
|
+
const btnCls = options.danger ? 'btnDanger' : (options.neutral === true ? 'btnPlain' : 'btnPrimary')
|
|
855
968
|
const boxes = (options.checklist ?? []).map((item) =>
|
|
856
969
|
'<label class="checkRow"><input type="checkbox" name="' + esc(item.name) + '"' + (item.checked ? ' checked' : '') + '>'
|
|
857
970
|
+ '<span><b>' + esc(item.label) + '</b><br><span class="muted">' + esc(item.description) + '</span></span></label>',
|
|
@@ -868,10 +981,10 @@ export function renderConfirmForm(options: {
|
|
|
868
981
|
+ (boxes === '' ? '' : '<div class="checkList">' + boxes + '</div>')
|
|
869
982
|
+ '<p class="consequence">' + esc(options.consequence) + '</p>'
|
|
870
983
|
+ (options.note === undefined ? '' : '<p class="muted">' + esc(options.note) + '</p>')
|
|
871
|
-
+ '<button class="' +
|
|
984
|
+
+ '<button class="' + btnCls + '" type="submit">' + esc(options.submitLabel) + '</button>'
|
|
872
985
|
+ '</form>'
|
|
873
986
|
return '<details class="confirmWrap" data-dcm-confirm open>'
|
|
874
|
-
+ '<summary class="' +
|
|
987
|
+
+ '<summary class="' + btnCls + '">' + esc(options.submitLabel) + '</summary>'
|
|
875
988
|
+ '<div class="confirmBody"><h3 class="confirmTitle">' + esc(options.title) + '</h3>' + form + '</div>'
|
|
876
989
|
+ '</details>'
|
|
877
990
|
}
|
|
@@ -889,7 +1002,9 @@ export function renderResultPage(
|
|
|
889
1002
|
): string {
|
|
890
1003
|
const chrome: PageChrome = { version, paths, active: 'home' }
|
|
891
1004
|
const tone = kind === 'ok' ? 'ok' : kind === 'bad' ? 'bad' : 'warn'
|
|
892
|
-
const
|
|
1005
|
+
const outcome: 'ok' | 'bad' = kind === 'ok' ? 'ok' : 'bad'
|
|
1006
|
+
const body = renderFlowSteps(3, outcome)
|
|
1007
|
+
+ banner(tone, title, lines.length === 0 ? '(无更多信息)' : '')
|
|
893
1008
|
+ section('逐条结果', '<ul class="resultList">' + lines.map((l) => '<li>' + cellHtml(l) + '</li>').join('') + '</ul>')
|
|
894
1009
|
+ '<p class="backRow"><a href="' + esc(backHref) + '" data-dcm-back>← 返回上一页并恢复原位置</a>'
|
|
895
1010
|
+ ' · <a href="/">返回首页</a> · <a href="/sessions">会话体检</a> · <a href="/disk">磁盘占用</a></p>'
|
|
@@ -905,7 +1020,7 @@ export function renderLockPage(
|
|
|
905
1020
|
done: string,
|
|
906
1021
|
): string {
|
|
907
1022
|
const chrome: PageChrome = { version, paths, active: 'home' }
|
|
908
|
-
const parts: string[] = []
|
|
1023
|
+
const parts: string[] = [renderFlowSteps(2)]
|
|
909
1024
|
if (done === 'recovered') parts.push(banner('ok', '残留锁已回收', '现在可以重新尝试之前被拒绝的操作。'))
|
|
910
1025
|
if (!lock.present) {
|
|
911
1026
|
parts.push(banner('info', '当前没有残留锁', '锁目录里没有 ownership 文件:' + lock.locksDir))
|
|
@@ -957,7 +1072,7 @@ export function renderUnlockPage(
|
|
|
957
1072
|
done: string,
|
|
958
1073
|
): string {
|
|
959
1074
|
const chrome: PageChrome = { version, paths, active: 'unlock' }
|
|
960
|
-
const parts: string[] = []
|
|
1075
|
+
const parts: string[] = [renderFlowSteps(2)]
|
|
961
1076
|
if (done === 'ok') parts.push(banner('ok', '解锁成功', '清单已在上一步给出;明文只在内存里解出,没有落盘。'))
|
|
962
1077
|
parts.push(section('什么是加密容器',
|
|
963
1078
|
'<p>勾了「加密」导出的备份,整份 ZIP 被密码包住(DCA1 容器,文件名仍是 .zip)。'
|
|
@@ -972,7 +1087,7 @@ export function renderUnlockPage(
|
|
|
972
1087
|
{ html: '<a href="#unlock-' + esc(verifyIdOf(b.name)) + '">解锁</a>' },
|
|
973
1088
|
])
|
|
974
1089
|
if (rows2.length > 0) parts.push(section('加密备份(' + String(rows2.length) + ')', renderTable(['文件', '大小', '修改时间', ''], rows2)))
|
|
975
|
-
|
|
1090
|
+
encrypted.forEach((b, idx) => {
|
|
976
1091
|
parts.push(section('解锁 ' + b.name, renderConfirmForm({
|
|
977
1092
|
action: '/unlock/run',
|
|
978
1093
|
token: actionToken,
|
|
@@ -981,11 +1096,12 @@ export function renderUnlockPage(
|
|
|
981
1096
|
consequence: '会在内存中解出明文 ZIP 并列出条目清单;不写盘、不回传内容、不自动导入。密码区分大小写,忘记无法找回。',
|
|
982
1097
|
submitLabel: '解锁并列出清单',
|
|
983
1098
|
danger: false,
|
|
1099
|
+
neutral: idx > 0,
|
|
984
1100
|
hidden: { id: verifyIdOf(b.name) },
|
|
985
1101
|
passwordField: 'password',
|
|
986
1102
|
note: '等价命令:先在 GUI 的导入向导里走「解锁加密备份」;命令行暂无解锁子命令。',
|
|
987
1103
|
})))
|
|
988
|
-
}
|
|
1104
|
+
})
|
|
989
1105
|
return renderLayout(chrome, parts.join('\n'), paths.exportsDir + ' · 密码只走本次请求')
|
|
990
1106
|
}
|
|
991
1107
|
|
|
@@ -998,7 +1114,7 @@ export function renderRestorePage(
|
|
|
998
1114
|
actionToken: string,
|
|
999
1115
|
): string {
|
|
1000
1116
|
const chrome: PageChrome = { version, paths, active: 'restore' }
|
|
1001
|
-
const parts: string[] = []
|
|
1117
|
+
const parts: string[] = [renderFlowSteps(plan !== null && plan.ok ? 2 : 1)]
|
|
1002
1118
|
parts.push(banner('warn', '恢复是危险动作',
|
|
1003
1119
|
'它会覆盖 $DSH_HOME 下的文件、删除导入后新增的文件、并卸载插件。执行前三道门必须通过(SAFE MODE 未激活 / 无残留锁 / DSH 已停止);每次覆盖前 core 会把当前文件复制到 <快照>/pre-restore/,可人工反悔。'))
|
|
1004
1120
|
const rows2: Cell[][] = snapshots.map((s) => [
|
|
@@ -1086,7 +1202,7 @@ export function renderExportPage(
|
|
|
1086
1202
|
checklist,
|
|
1087
1203
|
note: '等价命令:dsh-config-manager backup --sections <a,b,c>',
|
|
1088
1204
|
})
|
|
1089
|
-
return renderLayout(chrome, section('离线导出', body), paths.exportsDir)
|
|
1205
|
+
return renderLayout(chrome, renderFlowSteps(2) + section('离线导出', body), paths.exportsDir)
|
|
1090
1206
|
}
|
|
1091
1207
|
|
|
1092
1208
|
/** 重装:计划 + 终端确认码。 */
|
|
@@ -1118,7 +1234,7 @@ export function renderReinstallPage(
|
|
|
1118
1234
|
versionField: 'version',
|
|
1119
1235
|
note: '等价命令:dsh-config-manager reinstall --dry-run',
|
|
1120
1236
|
})
|
|
1121
|
-
return renderLayout(chrome, section('重装 DSH', body), paths.homeDir + ' · 需终端确认码')
|
|
1237
|
+
return renderLayout(chrome, renderFlowSteps(1) + section('重装 DSH', body), paths.homeDir + ' · 需终端确认码')
|
|
1122
1238
|
}
|
|
1123
1239
|
/* ------------------------------------------------------------ 备份自检 */
|
|
1124
1240
|
|
|
@@ -1182,6 +1298,7 @@ export function renderProfilesPage(
|
|
|
1182
1298
|
if (outcome.rows.length === 0) {
|
|
1183
1299
|
parts.push(banner('info', '本机还没有任何档案', 'DSH 首次启动时会按模板建一个;这里没什么可启停的。'))
|
|
1184
1300
|
}
|
|
1301
|
+
let primaryLaunchUsed = false
|
|
1185
1302
|
for (const row of outcome.rows) {
|
|
1186
1303
|
if (row.launchable) {
|
|
1187
1304
|
parts.push(section('启动 ' + row.name, renderConfirmForm({
|
|
@@ -1191,9 +1308,11 @@ export function renderProfilesPage(
|
|
|
1191
1308
|
consequence: '会在后台拉起一个独立的 DSH 实例(自动挑空闲端口),就绪后给出带 token 的认证 URL。它独立于当前任何实例;要关掉它请回本页点「停止」。',
|
|
1192
1309
|
submitLabel: '启动实例',
|
|
1193
1310
|
danger: false,
|
|
1311
|
+
neutral: primaryLaunchUsed,
|
|
1194
1312
|
hidden: { name: row.name },
|
|
1195
1313
|
note: '等价命令:dsh --profile ' + row.name,
|
|
1196
1314
|
})))
|
|
1315
|
+
primaryLaunchUsed = true
|
|
1197
1316
|
} else if (row.running) {
|
|
1198
1317
|
parts.push(section('停止 ' + row.name, renderConfirmForm({
|
|
1199
1318
|
action: '/profiles/stop',
|