From 04ea495bd95af9d4a9e70c23f98895cd8e9966d3 Mon Sep 17 00:00:00 2001 From: token <239573049@qq.com> Date: Fri, 12 Apr 2024 01:09:47 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A7=A3=E5=86=B3=E5=BC=82=E5=B8=B8=E7=BC=96?= =?UTF-8?q?=E8=AF=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- web/src/userWorker.ts | 37 ------------------------------ web/src/utils/IndexedDBWrapper.ts | 38 +++++++++++++++---------------- 2 files changed, 19 insertions(+), 56 deletions(-) diff --git a/web/src/userWorker.ts b/web/src/userWorker.ts index eb922feb..5429c9c4 100644 --- a/web/src/userWorker.ts +++ b/web/src/userWorker.ts @@ -25,43 +25,6 @@ self.MonacoEnvironment = { } }; -monaco.languages.register({ id: 'javascript' }); - -monaco.languages.setLanguageConfiguration('javascript', { - indentationRules: { - increaseIndentPattern: /^(.*\bcase\b\s*.*|.*\bdefault\b\s*.*)$/, - decreaseIndentPattern: /^\s*[\}\]].*$/, - }, - folding: { - markers: { - start: new RegExp('^\\s*//\\s*#?region\\b'), - end: new RegExp('^\\s*//\\s*#?endregion\\b'), - }, - }, - brackets: [ - ['{', '}'], - ['[', ']'], - ['(', ')'], - ], - wordPattern: /(-?\d*\.\d\w*)|([^`~!@#%^&*()=+[{\]}\\|;:'",.<>\/?\s]+)/g, -}); -const formatCommand = { - id: 'format-command', - label: 'Format', - keybindings: [ - monaco.KeyMod.chord(monaco.KeyMod.CtrlCmd | monaco.KeyCode.KeyK, monaco.KeyCode.KeyF) // 绑定到 Ctrl + K, Ctrl + F - ], - run: function (editor: any) { - // 格式化代码逻辑 - const model = editor.getModel(); - const range = model.getFullModelRange(); - editor.executeEdits('format-command', [{ - range: range, - text: '格式化代码' - }]); - } -}; - monaco.languages.typescript.javascriptDefaults.setCompilerOptions({ target: monaco.languages.typescript.ScriptTarget.ES2015, allowNonTsExtensions: true diff --git a/web/src/utils/IndexedDBWrapper.ts b/web/src/utils/IndexedDBWrapper.ts index 6fce06b1..9dfa26b7 100644 --- a/web/src/utils/IndexedDBWrapper.ts +++ b/web/src/utils/IndexedDBWrapper.ts @@ -15,19 +15,19 @@ class IndexedDBWrapper { return new Promise((resolve, reject) => { const request = indexedDB.open(this.dbName, this.dbVersion); - request.onupgradeneeded = (event: IDBVersionChangeEvent) => { + request.onupgradeneeded = () => { this.db = request.result; if (!this.db.objectStoreNames.contains(this.storeName)) { this.db.createObjectStore(this.storeName, { keyPath: 'id', autoIncrement: true }); } }; - request.onsuccess = (event: Event) => { + request.onsuccess = () => { this.db = request.result; resolve(this.db); }; - request.onerror = (event: Event) => { + request.onerror = () => { reject(request.error); }; }); @@ -44,11 +44,11 @@ class IndexedDBWrapper { const store = transaction.objectStore(this.storeName); const request = store.add(data); - request.onsuccess = (event: Event) => { + request.onsuccess = () => { resolve(request.result as number); }; - request.onerror = (event: Event) => { + request.onerror = () => { reject(request.error); }; }); @@ -60,11 +60,11 @@ class IndexedDBWrapper { const store = transaction.objectStore(this.storeName); const request = store.get(id); - request.onsuccess = (event: Event) => { + request.onsuccess = () => { resolve(request.result as T); }; - request.onerror = (event: Event) => { + request.onerror = () => { reject(request.error); }; }); @@ -76,11 +76,11 @@ class IndexedDBWrapper { const store = transaction.objectStore(this.storeName); const request = store.getAll(); - request.onsuccess = (event: Event) => { + request.onsuccess = () => { resolve(request.result as T[]); }; - request.onerror = (event: Event) => { + request.onerror = () => { reject(request.error); }; }); @@ -92,11 +92,11 @@ class IndexedDBWrapper { const store = transaction.objectStore(this.storeName); const request = store.put(data, id); - request.onsuccess = (event: Event) => { + request.onsuccess = () => { resolve(); }; - request.onerror = (event: Event) => { + request.onerror = () => { reject(request.error); }; }); @@ -109,21 +109,21 @@ class IndexedDBWrapper { const store = transaction.objectStore(this.storeName); const request = store.get(id); - request.onsuccess = (event: Event) => { + request.onsuccess = () => { const oldData = request.result; const newData = { ...oldData, ...data }; const requestUpdate = store.put(newData, id); - requestUpdate.onsuccess = (event: Event) => { + requestUpdate.onsuccess = () => { resolve(); }; - requestUpdate.onerror = (event: Event) => { + requestUpdate.onerror = () => { reject(requestUpdate.error); }; }; - request.onerror = (event: Event) => { + request.onerror = () => { reject(request.error); }; }); @@ -136,11 +136,11 @@ class IndexedDBWrapper { const store = transaction.objectStore(this.storeName); const request = store.delete(id); - request.onsuccess = (event: Event) => { + request.onsuccess = () => { resolve(); }; - request.onerror = (event: Event) => { + request.onerror = () => { reject(request.error); }; }); @@ -152,11 +152,11 @@ class IndexedDBWrapper { const store = transaction.objectStore(this.storeName); const request = store.delete(id); - request.onsuccess = (event: Event) => { + request.onsuccess = () => { resolve(); }; - request.onerror = (event: Event) => { + request.onerror = () => { reject(request.error); }; });