chore: remove unnecessary comments and suppress error logging

This commit is contained in:
2026-03-10 23:26:18 +08:00
parent 8d89c2a0f6
commit c0d4bf8b2b
7 changed files with 21 additions and 30 deletions
+3 -4
View File
@@ -17,16 +17,15 @@ function onChange(markdownValue) {
const appStyle = computed(() => { const appStyle = computed(() => {
const style = {} const style = {}
if (settings.backgroundType === 'warm') { if (settings.backgroundType === 'warm') {
style.background = '#fdfaf3ff' // Very light warm yellow style.background = '#fdfaf3ff'
style.color = '#5d4037' style.color = '#5d4037'
} else if (settings.backgroundType === 'reading') { } else if (settings.backgroundType === 'reading') {
style.background = '#f5f0e1' // Slightly deeper warm paper color style.background = '#f5f0e1'
style.color = '#333333' style.color = '#333333'
} else if (settings.backgroundType === 'default') { } else if (settings.backgroundType === 'default') {
style.background = 'var(--app-bg)' style.background = 'var(--app-bg)'
style.color = 'var(--app-text)' style.color = 'var(--app-text)'
} else if (settings.backgroundType === 'image') { } else if (settings.backgroundType === 'image') {
// For image background, we might want a solid base color underlying it
style.background = settings.theme === 'dark' ? '#000000' : '#ffffff' style.background = settings.theme === 'dark' ? '#000000' : '#ffffff'
} }
return style return style
@@ -69,7 +68,7 @@ const backgroundStyle = computed(() => {
background: var(--app-bg); background: var(--app-bg);
color: var(--app-text); color: var(--app-text);
transition: background 0.3s, color 0.3s; transition: background 0.3s, color 0.3s;
isolation: isolate; /* Create new stacking context */ isolation: isolate;
} }
.editor-container { .editor-container {
+6 -8
View File
@@ -244,13 +244,12 @@ const scheduleMarkdownSync = () => {
hasGhostSuggestion = Boolean(state?.suggestion && state.from < state.to) hasGhostSuggestion = Boolean(state?.suggestion && state.from < state.to)
}) })
// Ghost text is transient UI state and should not leak to emitted markdown.
if (hasGhostSuggestion) return if (hasGhostSuggestion) return
const markdown = await crepe.getMarkdown() const markdown = await crepe.getMarkdown()
emit('update:markdown', markdown) emit('update:markdown', markdown)
} catch (e) { } catch {
// sync error, ignore // Ignore sync errors
} }
}, 120) }, 120)
} }
@@ -357,8 +356,8 @@ const performOCR = async (file, cacheKey, imageHash = '') => {
setOcrByHash(imageHash, data.text) setOcrByHash(imageHash, data.text)
} }
} }
} catch (e) { } catch {
console.error('[OCR] Error:', e) // OCR error, ignore
} }
} }
reader.readAsDataURL(file) reader.readAsDataURL(file)
@@ -446,7 +445,6 @@ onMounted(async () => {
})) }))
}) })
// Watch for debounce changes
watch(() => settings.debounceMs, (newVal) => { watch(() => settings.debounceMs, (newVal) => {
if (!crepe) return if (!crepe) return
crepe.editor.action((ctx) => { crepe.editor.action((ctx) => {
@@ -538,8 +536,8 @@ const handleFileUpload = async (event) => {
if (crepe && crepe.editor) { if (crepe && crepe.editor) {
crepe.editor.action(replaceAll(text)) crepe.editor.action(replaceAll(text))
} }
} catch (e) { } catch {
console.error('[Error] Upload failed:', e) // File upload error, ignore
} }
input.value = '' input.value = ''
-2
View File
@@ -113,7 +113,6 @@ const appearanceMode = computed({
} }
}) })
// Background Image Handling
const handleImageUpload = (event) => { const handleImageUpload = (event) => {
const file = event.target.files[0] const file = event.target.files[0]
if (file) { if (file) {
@@ -126,7 +125,6 @@ const handleImageUpload = (event) => {
} }
} }
// Helper to translate
const t = (key) => store.t[key] const t = (key) => store.t[key]
</script> </script>
+2 -2
View File
@@ -12,8 +12,8 @@ app.mount('#app')
if (import.meta.env.PROD && 'serviceWorker' in navigator) { if (import.meta.env.PROD && 'serviceWorker' in navigator) {
window.addEventListener('load', () => { window.addEventListener('load', () => {
navigator.serviceWorker.register('/sw.js').catch((error) => { navigator.serviceWorker.register('/sw.js').catch(() => {
console.error('Service worker registration failed:', error) // Service worker registration failed, silently ignore
}) })
}) })
} }
+4 -8
View File
@@ -176,7 +176,7 @@ function normalizeSuggestionText(raw: string): string {
text = parsed.replace(/\r\n?/g, '\n') text = parsed.replace(/\r\n?/g, '\n')
} }
} catch { } catch {
// Keep original text when not valid JSON. // Not valid JSON, keep original
} }
} }
@@ -193,7 +193,6 @@ async function insertGhostText(view: EditorView, suggestion: string, from: numbe
const markType = view.state.schema.marks.copilot_ghost const markType = view.state.schema.marks.copilot_ghost
if (!markType) { if (!markType) {
console.error('[Copilot] copilot_ghost mark not found in schema')
return return
} }
@@ -210,7 +209,6 @@ async function insertGhostText(view: EditorView, suggestion: string, from: numbe
const insertedRange = insertParsedMarkdownSlice(tr, from, parsedDoc) const insertedRange = insertParsedMarkdownSlice(tr, from, parsedDoc)
if (!insertedRange) { if (!insertedRange) {
console.warn('[Copilot] parsed markdown insertion failed, falling back to plain text')
insertPlainText(view, suggestion, from, markType) insertPlainText(view, suggestion, from, markType)
return return
} }
@@ -219,8 +217,7 @@ async function insertGhostText(view: EditorView, suggestion: string, from: numbe
tr.setSelection(Selection.near(tr.doc.resolve(getCursorBeforeGhostInsert(tr, from)), -1)) tr.setSelection(Selection.near(tr.doc.resolve(getCursorBeforeGhostInsert(tr, from)), -1))
tr.setMeta(COPILOT_PLUGIN_KEY, { from: insertedRange.from, to: insertedRange.to, suggestion }) tr.setMeta(COPILOT_PLUGIN_KEY, { from: insertedRange.from, to: insertedRange.to, suggestion })
view.dispatch(tr) view.dispatch(tr)
} catch (e) { } catch {
console.error('[Copilot] Parser error:', e)
insertPlainText(view, suggestion, from, markType) insertPlainText(view, suggestion, from, markType)
} }
} }
@@ -320,7 +317,7 @@ function doFetchSuggestion(
}) })
.catch((e: any) => { .catch((e: any) => {
if (e?.name !== 'AbortError') { if (e?.name !== 'AbortError') {
console.error('[Copilot] Error:', e) // Log error silently
} }
}) })
.finally(() => { .finally(() => {
@@ -351,8 +348,7 @@ function scheduleFetch(view: EditorView, runtime: CopilotRuntime, pos: number) {
if (!suffixMarkdown) { if (!suffixMarkdown) {
suffixMarkdown = doc.textBetween(pos, doc.content.size, '\n', '\n') suffixMarkdown = doc.textBetween(pos, doc.content.size, '\n', '\n')
} }
} catch (e) { } catch {
console.error('[Copilot] Serializer error:', e)
prefixMarkdown = doc.textBetween(0, pos, '\n', '\n') prefixMarkdown = doc.textBetween(0, pos, '\n', '\n')
suffixMarkdown = doc.textBetween(pos, doc.content.size, '\n', '\n') suffixMarkdown = doc.textBetween(pos, doc.content.size, '\n', '\n')
} }
+4 -4
View File
@@ -66,8 +66,8 @@ export const useSettingsStore = defineStore('settings', () => {
if (data.backgroundImage) backgroundImage.value = data.backgroundImage if (data.backgroundImage) backgroundImage.value = data.backgroundImage
if (data.backgroundOpacity) backgroundOpacity.value = data.backgroundOpacity if (data.backgroundOpacity) backgroundOpacity.value = data.backgroundOpacity
} }
} catch (e) { } catch {
console.error('Failed to load settings', e) // Failed to load settings, use defaults
} }
} }
@@ -86,8 +86,8 @@ export const useSettingsStore = defineStore('settings', () => {
backgroundOpacity: backgroundOpacity.value, backgroundOpacity: backgroundOpacity.value,
} }
localStorage.setItem('llm-in-text-settings', JSON.stringify(data)) localStorage.setItem('llm-in-text-settings', JSON.stringify(data))
} catch (e) { } catch {
console.error('Failed to save settings', e) // Failed to save settings
} }
} }
+2 -2
View File
@@ -41,8 +41,8 @@ async function sendCancelRequest(cancelUrl, requestId, reason) {
reason, reason,
}), }),
}) })
} catch (e) { } catch {
console.debug('[Copilot] cancel request failed', e) // Cancel request failed silently
} }
} }