From 2fb64f03ec75d037e6afedfc58222e88c66e8ed9 Mon Sep 17 00:00:00 2001 From: leejooy96 Date: Fri, 20 Jun 2025 18:15:47 +0900 Subject: [PATCH] chore: fix vue prettier rules (max-attributes-per-line), reformat all codes --- .prettierrc | 4 +- docs/src/.vitepress/config.mts | 8 +- .../en/installation-and-build/npm-scripts.md | 10 +- .../ko/installation-and-build/npm-scripts.md | 10 +- .../installation-and-build/npm-scripts.md | 36 +++--- eslint.config.ts | 11 ++ src/main/IPCs.ts | 36 +++--- src/main/index.ts | 6 +- src/main/tray.ts | 4 +- src/preload/index.ts | 21 +++- .../components/layout/HeaderLayout.vue | 5 +- src/renderer/index.html | 5 +- src/renderer/plugins/vuetify.ts | 14 ++- src/renderer/screens/MainScreen.vue | 103 ++++++++++++++---- src/renderer/screens/SecondScreen.vue | 18 ++- tests/fixtures.mts | 20 ++-- vite.config.mts | 6 +- 17 files changed, 227 insertions(+), 90 deletions(-) diff --git a/.prettierrc b/.prettierrc index 1eff382..dc5d405 100644 --- a/.prettierrc +++ b/.prettierrc @@ -12,6 +12,8 @@ "insertPragma": false, "requirePragma": false, "proseWrap": "never", + "singleAttributePerLine": true, "htmlWhitespaceSensitivity": "strict", - "endOfLine": "lf" + "endOfLine": "lf", + "printWidth": 80 } diff --git a/docs/src/.vitepress/config.mts b/docs/src/.vitepress/config.mts index 4f83867..cc3e077 100644 --- a/docs/src/.vitepress/config.mts +++ b/docs/src/.vitepress/config.mts @@ -5,7 +5,8 @@ import { withI18n } from 'vitepress-i18n' import type { VitePressSidebarOptions } from 'vitepress-sidebar/types' import type { VitePressI18nOptions } from 'vitepress-i18n/types' -const capitalizeFirst = (str: string): string => str.charAt(0).toUpperCase() + str.slice(1) +const capitalizeFirst = (str: string): string => + str.charAt(0).toUpperCase() + str.slice(1) const supportLocales = ['en', 'ko', 'zhHans'] const defaultLocale: string = supportLocales[0] @@ -96,5 +97,8 @@ const vitePressConfigs: UserConfig = { } export default defineConfig( - withSidebar(withI18n(vitePressConfigs, vitePressI18nConfigs), vitePressSidebarConfigs) + withSidebar( + withI18n(vitePressConfigs, vitePressI18nConfigs), + vitePressSidebarConfigs + ) ) diff --git a/docs/src/en/installation-and-build/npm-scripts.md b/docs/src/en/installation-and-build/npm-scripts.md index 7b7e4a5..091b840 100644 --- a/docs/src/en/installation-and-build/npm-scripts.md +++ b/docs/src/en/installation-and-build/npm-scripts.md @@ -32,8 +32,8 @@ order: 3 Used only for contributing to project documentation. Must be run from the `docs` directory location. -| Script Name | Description | -| ----------- | ------------------------------------------------------------------ | -| `dev` | Start the local document server. (For development) | -| `build` | Build a local document server. Used only for GitHub page builders. | -| `serve` | Start the local document server. | +| Script Name | Description | +| --- | --- | +| `dev` | Start the local document server. (For development) | +| `build` | Build a local document server. Used only for GitHub page builders. | +| `serve` | Start the local document server. | diff --git a/docs/src/ko/installation-and-build/npm-scripts.md b/docs/src/ko/installation-and-build/npm-scripts.md index 851d960..6f909e6 100644 --- a/docs/src/ko/installation-and-build/npm-scripts.md +++ b/docs/src/ko/installation-and-build/npm-scripts.md @@ -32,8 +32,8 @@ order: 3 프로젝트 문서에 기여하는 경우에만 사용됩니다. `docs` 디렉토리 위치에서 실행해야 합니다. -| Script Name | Description | -| ----------- | ------------------------------------------------------------------ | -| `dev` | Start the local document server. (For development) | -| `build` | Build a local document server. Used only for GitHub page builders. | -| `serve` | Start the local document server. | +| Script Name | Description | +| --- | --- | +| `dev` | Start the local document server. (For development) | +| `build` | Build a local document server. Used only for GitHub page builders. | +| `serve` | Start the local document server. | diff --git a/docs/src/zhHans/installation-and-build/npm-scripts.md b/docs/src/zhHans/installation-and-build/npm-scripts.md index 0c55d6a..b1e68f3 100644 --- a/docs/src/zhHans/installation-and-build/npm-scripts.md +++ b/docs/src/zhHans/installation-and-build/npm-scripts.md @@ -9,24 +9,24 @@ order: 3 ## 一般情况 -| 脚本名称 | 说明 | -| ----------------- | ---------------------------------------------------------- | -| `dev` | 启动电子作为开发环境 | -| `dev:debug` | 将 Electron 作为开发环境启动(使用 vite debug) | -| `dev:debug:force` | 以Electron作为开发环境启动(使用vite调试+清理vite缓存) | -| `build:pre` | 通常在编译时运行的命令。此脚本无需单独运行。 | -| `build` | 为当前操作系统打包。 | -| `build:all` | 为整个操作系统构建指定软件包(需要跨平台构建配置) | -| `build:dir` | `electron-builder`目录构建 | -| `build:mac` | 为macOS构建预配置软件包 | -| `build:linux` | 为Linux构建预配置软件包 | -| `build:win` | 为Windows构建预配置软件包 | -| `lint` | ESLint代码检查。它不会修改代码。 | -| `lint:fix` | ESLint代码检查。使用自动修复功能修复代码。 | -| `format` | 更漂亮的代码检查。它不会修改代码。 | -| `format:fix` | 更漂亮的代码检查。使用自动修复功能修复代码。 | -| `test` | 根据测试规范文件构建测试包并运行测试。 | -| `test:linux` | 根据测试规范文件构建测试包并运行测试。(仅适用于linux ci) | +| 脚本名称 | 说明 | +| --- | --- | +| `dev` | 启动电子作为开发环境 | +| `dev:debug` | 将 Electron 作为开发环境启动(使用 vite debug) | +| `dev:debug:force` | 以Electron作为开发环境启动(使用vite调试+清理vite缓存) | +| `build:pre` | 通常在编译时运行的命令。此脚本无需单独运行。 | +| `build` | 为当前操作系统打包。 | +| `build:all` | 为整个操作系统构建指定软件包(需要跨平台构建配置) | +| `build:dir` | `electron-builder`目录构建 | +| `build:mac` | 为macOS构建预配置软件包 | +| `build:linux` | 为Linux构建预配置软件包 | +| `build:win` | 为Windows构建预配置软件包 | +| `lint` | ESLint代码检查。它不会修改代码。 | +| `lint:fix` | ESLint代码检查。使用自动修复功能修复代码。 | +| `format` | 更漂亮的代码检查。它不会修改代码。 | +| `format:fix` | 更漂亮的代码检查。使用自动修复功能修复代码。 | +| `test` | 根据测试规范文件构建测试包并运行测试。 | +| `test:linux` | 根据测试规范文件构建测试包并运行测试。(仅适用于linux ci) | ## 文档 diff --git a/eslint.config.ts b/eslint.config.ts index 6c6a32d..9bc4b49 100644 --- a/eslint.config.ts +++ b/eslint.config.ts @@ -60,6 +60,17 @@ export default pluginTypeScriptESLint.config( 'vue/v-on-event-hyphenation': 'off', 'vue/no-v-text-v-html-on-component': 'off', 'vue/attribute-hyphenation': 'off', + 'vue/max-attributes-per-line': [ + 'error', + { + singleline: { + max: 1 + }, + multiline: { + max: 1 + } + } + ], '@typescript-eslint/no-explicit-any': 'off' } } diff --git a/src/main/IPCs.ts b/src/main/IPCs.ts index 03f1d45..a048f8d 100644 --- a/src/main/IPCs.ts +++ b/src/main/IPCs.ts @@ -12,23 +12,29 @@ export default class IPCs { }) // Open url via web browser - ipcMain.on('msgOpenExternalLink', async (event: IpcMainEvent, url: string) => { - await shell.openExternal(url) - }) + ipcMain.on( + 'msgOpenExternalLink', + async (event: IpcMainEvent, url: string) => { + await shell.openExternal(url) + } + ) // Open file - ipcMain.handle('msgOpenFile', async (event: IpcMainEvent, filter: string) => { - const filters = [] - if (filter === 'text') { - filters.push({ name: 'Text', extensions: ['txt', 'json'] }) - } else if (filter === 'zip') { - filters.push({ name: 'Zip', extensions: ['zip'] }) + ipcMain.handle( + 'msgOpenFile', + async (event: IpcMainEvent, filter: string) => { + const filters = [] + if (filter === 'text') { + filters.push({ name: 'Text', extensions: ['txt', 'json'] }) + } else if (filter === 'zip') { + filters.push({ name: 'Zip', extensions: ['zip'] }) + } + const dialogResult = await dialog.showOpenDialog({ + properties: ['openFile'], + filters + }) + return dialogResult } - const dialogResult = await dialog.showOpenDialog({ - properties: ['openFile'], - filters - }) - return dialogResult - }) + ) } } diff --git a/src/main/index.ts b/src/main/index.ts index b3a1666..041edb8 100644 --- a/src/main/index.ts +++ b/src/main/index.ts @@ -38,7 +38,11 @@ app.on('window-all-closed', () => { app.on( 'render-process-gone', - (event: Event, webContents: WebContents, details: RenderProcessGoneDetails) => { + ( + event: Event, + webContents: WebContents, + details: RenderProcessGoneDetails + ) => { errorWindow = createErrorWindow(errorWindow, mainWindow, details) } ) diff --git a/src/main/tray.ts b/src/main/tray.ts index 7093cfb..632d169 100644 --- a/src/main/tray.ts +++ b/src/main/tray.ts @@ -97,7 +97,9 @@ function calculateWindowPosition(b) { const screenBounds = screen.getPrimaryDisplay().size const trayBounds = tray.getBounds() const bottom = trayBounds.y > screenBounds.height / 2 - const x = Math.floor(trayBounds.x - b.width / 2 - margin.x + trayBounds.width / 2) + const x = Math.floor( + trayBounds.x - b.width / 2 - margin.x + trayBounds.width / 2 + ) const y = bottom ? Math.floor(trayBounds.y - b.height - margin.y + trayBounds.height / 2) : Math.floor(trayBounds.y + margin.y + trayBounds.height / 2) diff --git a/src/preload/index.ts b/src/preload/index.ts index 218ae9a..72eb47d 100644 --- a/src/preload/index.ts +++ b/src/preload/index.ts @@ -1,7 +1,11 @@ import { contextBridge, ipcRenderer, IpcRendererEvent } from 'electron' // Whitelist of valid channels used for IPC communication (Send message from Renderer to Main) -const mainAvailChannels: string[] = ['msgRequestGetVersion', 'msgOpenExternalLink', 'msgOpenFile'] +const mainAvailChannels: string[] = [ + 'msgRequestGetVersion', + 'msgOpenExternalLink', + 'msgOpenFile' +] const rendererAvailChannels: string[] = [] contextBridge.exposeInMainWorld('mainApi', { @@ -15,21 +19,30 @@ contextBridge.exposeInMainWorld('mainApi', { throw new Error(`Unknown ipc channel name: ${channel}`) } }, - on: (channel: string, listener: (event: IpcRendererEvent, ...args: any[]) => void): void => { + on: ( + channel: string, + listener: (event: IpcRendererEvent, ...args: any[]) => void + ): void => { if (rendererAvailChannels.includes(channel)) { ipcRenderer.on(channel, listener) } else { throw new Error(`Unknown ipc channel name: ${channel}`) } }, - once: (channel: string, listener: (event: IpcRendererEvent, ...args: any[]) => void): void => { + once: ( + channel: string, + listener: (event: IpcRendererEvent, ...args: any[]) => void + ): void => { if (rendererAvailChannels.includes(channel)) { ipcRenderer.once(channel, listener) } else { throw new Error(`Unknown ipc channel name: ${channel}`) } }, - off: (channel: string, listener: (event: IpcRendererEvent, ...args: any[]) => void): void => { + off: ( + channel: string, + listener: (event: IpcRendererEvent, ...args: any[]) => void + ): void => { if (rendererAvailChannels.includes(channel)) { ipcRenderer.off(channel, listener) } else { diff --git a/src/renderer/components/layout/HeaderLayout.vue b/src/renderer/components/layout/HeaderLayout.vue index 9adff3b..66aeae1 100644 --- a/src/renderer/components/layout/HeaderLayout.vue +++ b/src/renderer/components/layout/HeaderLayout.vue @@ -18,7 +18,10 @@ const isCurrentRoute = (path: string): boolean => { }