From b26c5aa6931ebd69072b88515f436a0731cacaff Mon Sep 17 00:00:00 2001 From: eezd Date: Sat, 17 Oct 2026 14:56:23 +0800 Subject: [PATCH] Revert "Add client-side note encryption" This reverts commit 5cf5a45682490f97d4fa86da99d3291e055bc31c. --- web/src/app/EditorPane.vue | 14 +- web/src/app/Icon.vue | 1 - web/src/app/KeyDialog.vue | 86 ----------- web/src/app/QuickSwitcher.vue | 10 +- web/src/app/TabBar.vue | 3 +- web/src/app/TrashDialog.vue | 2 +- web/src/app/TreeNode.vue | 7 +- web/src/app/Workspace.vue | 3 - web/src/app/api.ts | 35 ----- web/src/app/app.css | 4 - web/src/app/crypto.test.ts | 108 -------------- web/src/app/crypto.ts | 200 -------------------------- web/src/app/encryption.ts | 100 ------------- web/src/app/paths.ts | 33 +---- web/src/app/workspace.ts | 256 +++------------------------------ web/src/editor/index.ts | 5 +- web/src/editor/livepreview.ts | 7 +- web/src/editor/widgets.ts | 5 +- web/src/markdown/links.test.ts | 22 --- web/src/markdown/links.ts | 37 ----- 20 files changed, 39 insertions(+), 899 deletions(-) delete mode 100644 web/src/app/KeyDialog.vue delete mode 100644 web/src/app/crypto.test.ts delete mode 100644 web/src/app/crypto.ts delete mode 100644 web/src/app/encryption.ts delete mode 100644 web/src/markdown/links.test.ts delete mode 100644 web/src/markdown/links.ts diff --git a/web/src/app/EditorPane.vue b/web/src/app/EditorPane.vue index 01e5aa9..b548114 100644 --- a/web/src/app/EditorPane.vue +++ b/web/src/app/EditorPane.vue @@ -3,8 +3,7 @@ import { EditorState, type StateEffect, type Text } from '@codemirror/state' import type { EditorView } from '@codemirror/view' import { computed, onBeforeUnmount, onMounted, ref, watch } from 'vue' import { createEditorView } from '../editor' -import { keyState } from './encryption' -import { activeTab, attachView, editorStateOf, noteRefOf, revealPending, storeViewState, unlockNotes, ws } from './workspace' +import { activeTab, attachView, editorStateOf, noteRefOf, revealPending, storeViewState, ws } from './workspace' const host = ref() const tab = computed(activeTab) @@ -29,8 +28,6 @@ function show() { scrollPositions.set(shown, { doc: view.state.doc, snapshot: view.scrollSnapshot(), top: view.scrollDOM.scrollTop }) } if (!ref || !state) { - // 锁定后视图中不能留下已解密的内容 - if (shown) view.setState(EditorState.create()) shown = undefined return } @@ -63,17 +60,10 @@ watch(() => [ws.active, tab.value?.status], show, { flush: 'post' }) diff --git a/web/src/app/Icon.vue b/web/src/app/Icon.vue index e5173d6..2712354 100644 --- a/web/src/app/Icon.vue +++ b/web/src/app/Icon.vue @@ -14,7 +14,6 @@ const paths = { restore: 'M3 12a9 9 0 1 0 3-6.7L3 8M3 3v5h5', edit: 'M12 20h9M16.5 3.5a2.1 2.1 0 0 1 3 3L7 19l-4 1 1-4z', search: 'M11 18a7 7 0 1 0 0-14 7 7 0 0 0 0 14zM21 21l-4.35-4.35', - lock: 'M5 11h14v10H5zM8 11V7a4 4 0 0 1 8 0v4', command: 'M18 3a3 3 0 0 0-3 3v12a3 3 0 1 0 3-3H6a3 3 0 1 0 3 3V6a3 3 0 1 0-3 3h12a3 3 0 0 0 0-6z', } defineProps<{ name: keyof typeof paths; size?: number }>() diff --git a/web/src/app/KeyDialog.vue b/web/src/app/KeyDialog.vue deleted file mode 100644 index 4b2f707..0000000 --- a/web/src/app/KeyDialog.vue +++ /dev/null @@ -1,86 +0,0 @@ - - - diff --git a/web/src/app/QuickSwitcher.vue b/web/src/app/QuickSwitcher.vue index 662c068..da90c83 100644 --- a/web/src/app/QuickSwitcher.vue +++ b/web/src/app/QuickSwitcher.vue @@ -3,7 +3,7 @@ import { computed, onMounted, ref, watch } from 'vue' import { availableCommands, formatKeys } from './commands' import { fuzzyMatch } from './fuzzy' import Icon from './Icon.vue' -import { dirname, ENCRYPTED_EXT, isEncrypted, NOTE_EXT, noteTitle } from './paths' +import { dirname, NOTE_EXT, noteTitle } from './paths' import { createNoteAt, openAt, ws } from './workspace' const MAX_ITEMS = 50 @@ -12,7 +12,7 @@ const RECENT_COMMANDS_MAX = 10 interface Item { key: string - icon: 'note' | 'lock' | 'noteAdd' | 'command' + icon: 'note' | 'noteAdd' | 'command' title: string // 笔记为所在目录,命令为快捷键 detail: string @@ -59,7 +59,7 @@ function noteItems(q: string): Item[] { const offset = dir ? dir.length + 1 : 0 return { key: path, - icon: isEncrypted(path) ? 'lock' : 'note', + icon: 'note', title: noteTitle(path), detail: dir, titleHits: new Set(positions.filter((p) => p >= offset).map((p) => p - offset)), @@ -80,7 +80,7 @@ function noteItems(q: string): Item[] { } const scored: { path: string; score: number; positions: number[] }[] = [] for (const e of notes) { - const target = e.path.replace(/\.md(\.enc)?$/, '') + const target = e.path.slice(0, -NOTE_EXT.length) const m = fuzzyMatch(q, target, target.lastIndexOf('/') + 1) if (m) scored.push({ path: e.path, ...m }) } @@ -93,7 +93,7 @@ function noteItems(q: string): Item[] { const path = name + NOTE_EXT if ( name.split('/').every((seg) => seg.trim() && !seg.startsWith('.')) && - !ws.entries.some((e) => [path, name + ENCRYPTED_EXT].some((p) => e.path.toLowerCase() === p.toLowerCase())) + !ws.entries.some((e) => e.path.toLowerCase() === path.toLowerCase()) ) { items.push({ key: '\0create', diff --git a/web/src/app/TabBar.vue b/web/src/app/TabBar.vue index ded70c1..3c6f1d0 100644 --- a/web/src/app/TabBar.vue +++ b/web/src/app/TabBar.vue @@ -1,6 +1,6 @@ @@ -17,7 +17,6 @@ import { closeTab, ws } from './workspace' @click="ws.active = tab.path" @auxclick.prevent="$event.button === 1 && closeTab(tab.path)" > - {{ noteTitle(tab.path) }} diff --git a/web/src/app/TreeNode.vue b/web/src/app/TreeNode.vue index 6566295..6eecde5 100644 --- a/web/src/app/TreeNode.vue +++ b/web/src/app/TreeNode.vue @@ -1,7 +1,7 @@