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

View File

@@ -17,16 +17,15 @@ function onChange(markdownValue) {
const appStyle = computed(() => {
const style = {}
if (settings.backgroundType === 'warm') {
style.background = '#fdfaf3ff' // Very light warm yellow
style.background = '#fdfaf3ff'
style.color = '#5d4037'
} else if (settings.backgroundType === 'reading') {
style.background = '#f5f0e1' // Slightly deeper warm paper color
style.background = '#f5f0e1'
style.color = '#333333'
} else if (settings.backgroundType === 'default') {
style.background = 'var(--app-bg)'
style.color = 'var(--app-text)'
} else if (settings.backgroundType === 'image') {
// For image background, we might want a solid base color underlying it
style.background = settings.theme === 'dark' ? '#000000' : '#ffffff'
}
return style
@@ -69,7 +68,7 @@ const backgroundStyle = computed(() => {
background: var(--app-bg);
color: var(--app-text);
transition: background 0.3s, color 0.3s;
isolation: isolate; /* Create new stacking context */
isolation: isolate;
}
.editor-container {

View File

@@ -244,13 +244,12 @@ const scheduleMarkdownSync = () => {
hasGhostSuggestion = Boolean(state?.suggestion && state.from < state.to)
})
// Ghost text is transient UI state and should not leak to emitted markdown.
if (hasGhostSuggestion) return
const markdown = await crepe.getMarkdown()
emit('update:markdown', markdown)
} catch (e) {
// sync error, ignore
} catch {
// Ignore sync errors
}
}, 120)
}
@@ -357,8 +356,8 @@ const performOCR = async (file, cacheKey, imageHash = '') => {
setOcrByHash(imageHash, data.text)
}
}
} catch (e) {
console.error('[OCR] Error:', e)
} catch {
// OCR error, ignore
}
}
reader.readAsDataURL(file)
@@ -446,7 +445,6 @@ onMounted(async () => {
}))
})
// Watch for debounce changes
watch(() => settings.debounceMs, (newVal) => {
if (!crepe) return
crepe.editor.action((ctx) => {
@@ -538,8 +536,8 @@ const handleFileUpload = async (event) => {
if (crepe && crepe.editor) {
crepe.editor.action(replaceAll(text))
}
} catch (e) {
console.error('[Error] Upload failed:', e)
} catch {
// File upload error, ignore
}
input.value = ''

View File

@@ -113,7 +113,6 @@ const appearanceMode = computed({
}
})
// Background Image Handling
const handleImageUpload = (event) => {
const file = event.target.files[0]
if (file) {
@@ -126,7 +125,6 @@ const handleImageUpload = (event) => {
}
}
// Helper to translate
const t = (key) => store.t[key]
</script>

View File

@@ -12,8 +12,8 @@ app.mount('#app')
if (import.meta.env.PROD && 'serviceWorker' in navigator) {
window.addEventListener('load', () => {
navigator.serviceWorker.register('/sw.js').catch((error) => {
console.error('Service worker registration failed:', error)
navigator.serviceWorker.register('/sw.js').catch(() => {
// Service worker registration failed, silently ignore
})
})
}

View File

@@ -176,7 +176,7 @@ function normalizeSuggestionText(raw: string): string {
text = parsed.replace(/\r\n?/g, '\n')
}
} 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
if (!markType) {
console.error('[Copilot] copilot_ghost mark not found in schema')
return
}
@@ -210,7 +209,6 @@ async function insertGhostText(view: EditorView, suggestion: string, from: numbe
const insertedRange = insertParsedMarkdownSlice(tr, from, parsedDoc)
if (!insertedRange) {
console.warn('[Copilot] parsed markdown insertion failed, falling back to plain text')
insertPlainText(view, suggestion, from, markType)
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.setMeta(COPILOT_PLUGIN_KEY, { from: insertedRange.from, to: insertedRange.to, suggestion })
view.dispatch(tr)
} catch (e) {
console.error('[Copilot] Parser error:', e)
} catch {
insertPlainText(view, suggestion, from, markType)
}
}
@@ -320,7 +317,7 @@ function doFetchSuggestion(
})
.catch((e: any) => {
if (e?.name !== 'AbortError') {
console.error('[Copilot] Error:', e)
// Log error silently
}
})
.finally(() => {
@@ -351,8 +348,7 @@ function scheduleFetch(view: EditorView, runtime: CopilotRuntime, pos: number) {
if (!suffixMarkdown) {
suffixMarkdown = doc.textBetween(pos, doc.content.size, '\n', '\n')
}
} catch (e) {
console.error('[Copilot] Serializer error:', e)
} catch {
prefixMarkdown = doc.textBetween(0, pos, '\n', '\n')
suffixMarkdown = doc.textBetween(pos, doc.content.size, '\n', '\n')
}

View File

@@ -66,8 +66,8 @@ export const useSettingsStore = defineStore('settings', () => {
if (data.backgroundImage) backgroundImage.value = data.backgroundImage
if (data.backgroundOpacity) backgroundOpacity.value = data.backgroundOpacity
}
} catch (e) {
console.error('Failed to load settings', e)
} catch {
// Failed to load settings, use defaults
}
}
@@ -86,8 +86,8 @@ export const useSettingsStore = defineStore('settings', () => {
backgroundOpacity: backgroundOpacity.value,
}
localStorage.setItem('llm-in-text-settings', JSON.stringify(data))
} catch (e) {
console.error('Failed to save settings', e)
} catch {
// Failed to save settings
}
}

View File

@@ -41,8 +41,8 @@ async function sendCancelRequest(cancelUrl, requestId, reason) {
reason,
}),
})
} catch (e) {
console.debug('[Copilot] cancel request failed', e)
} catch {
// Cancel request failed silently
}
}