From 8bcf0138225230ab091ae6ffc39a9e6b7e9e55be Mon Sep 17 00:00:00 2001 From: Chris Ondrovic Date: Thu, 30 Oct 2025 13:14:34 -0400 Subject: [PATCH 1/3] feat(preferences): add api port to preference option --- .github/workflows/build-sponsored.yml | 2 -- .github/workflows/release.yml | 2 -- CONTRIBUTING.md | 2 +- scripts/api-generate.js | 5 ++- src/renderer/components/preferences/API.vue | 39 +++++++++++++++++++++ src/renderer/router/index.ts | 6 ++++ src/renderer/services/api/index.ts | 5 ++- src/renderer/views/Preferences.vue | 4 +++ 8 files changed, 58 insertions(+), 7 deletions(-) create mode 100644 src/renderer/components/preferences/API.vue diff --git a/.github/workflows/build-sponsored.yml b/.github/workflows/build-sponsored.yml index 12fe0115..b6d2a4eb 100644 --- a/.github/workflows/build-sponsored.yml +++ b/.github/workflows/build-sponsored.yml @@ -76,5 +76,3 @@ jobs: dist/*.snap if-no-files-found: warn retention-days: 30 - - diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 0b4d3448..8f73b020 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -118,5 +118,3 @@ jobs: append_body: true env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 4938e225..e6cd0c75 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -31,4 +31,4 @@ fix #123 It's ok to have multiple commits in a single PR, you don't need to rebase or force push for your changes as we will use Squash and Merge to squash the commits into one commit when merging. -And of course please test your code before PR. \ No newline at end of file +And of course please test your code before PR. diff --git a/scripts/api-generate.js b/scripts/api-generate.js index 5f19cd0f..9b429634 100644 --- a/scripts/api-generate.js +++ b/scripts/api-generate.js @@ -1,7 +1,10 @@ const child_process = require('node:child_process') const { styleText } = require('node:util') +const Store = require('electron-store') -const url = `http://localhost:4321/swagger/json` +const store = new Store({ name: 'preferences', cwd: 'v2' }) +const apiPort = store.get('apiPort', 4321) +const url = `http://localhost:${apiPort}/swagger/json` async function generateApi() { try { diff --git a/src/renderer/components/preferences/API.vue b/src/renderer/components/preferences/API.vue new file mode 100644 index 00000000..2cd2d7e3 --- /dev/null +++ b/src/renderer/components/preferences/API.vue @@ -0,0 +1,39 @@ + + + diff --git a/src/renderer/router/index.ts b/src/renderer/router/index.ts index 6e4683d5..e79d32c1 100644 --- a/src/renderer/router/index.ts +++ b/src/renderer/router/index.ts @@ -7,6 +7,7 @@ export const RouterName = { preferencesLanguage: 'preferences/language', preferencesAppearance: 'preferences/appearance', preferencesEditor: 'preferences/editor', + preferencesAPI: 'preferences/api', markdownPresentation: 'markdown-presentation', devtools: 'devtools', devtoolsCaseConverter: 'devtools/case-converter', @@ -57,6 +58,11 @@ const routes = [ name: RouterName.preferencesEditor, component: () => import('@/components/preferences/Editor.vue'), }, + { + path: 'api', + name: RouterName.preferencesAPI, + component: () => import('@/components/preferences/API.vue'), + }, ], }, { diff --git a/src/renderer/services/api/index.ts b/src/renderer/services/api/index.ts index 4d28210b..38a5c0bc 100644 --- a/src/renderer/services/api/index.ts +++ b/src/renderer/services/api/index.ts @@ -1,7 +1,10 @@ +import { store } from '@/electron' import ky from 'ky' import { Api } from './generated' +const apiPort = store.preferences.get('apiPort') + export const api = new Api({ - baseUrl: 'http://localhost:4321', + baseUrl: `http://localhost:${apiPort}`, customFetch: ky, }) diff --git a/src/renderer/views/Preferences.vue b/src/renderer/views/Preferences.vue index 8c289fc9..478da1bb 100644 --- a/src/renderer/views/Preferences.vue +++ b/src/renderer/views/Preferences.vue @@ -30,6 +30,10 @@ const nav = [ label: i18n.t('preferences:appearance.label'), name: RouterName.preferencesAppearance, }, + { + label: 'API Port', + name: RouterName.preferencesAPI, + }, ] provide(preferencesKeys, { From fe99fe0d0897359865a08afd398f9eb096397b54 Mon Sep 17 00:00:00 2001 From: Chris Ondrovic Date: Fri, 31 Oct 2025 09:30:41 -0400 Subject: [PATCH 2/3] revert(non rleated files): workflow and contributing --- .github/workflows/build-sponsored.yml | 2 ++ .github/workflows/release.yml | 2 ++ CONTRIBUTING.md | 2 +- 3 files changed, 5 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build-sponsored.yml b/.github/workflows/build-sponsored.yml index b6d2a4eb..12fe0115 100644 --- a/.github/workflows/build-sponsored.yml +++ b/.github/workflows/build-sponsored.yml @@ -76,3 +76,5 @@ jobs: dist/*.snap if-no-files-found: warn retention-days: 30 + + diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 8f73b020..0b4d3448 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -118,3 +118,5 @@ jobs: append_body: true env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index e6cd0c75..4938e225 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -31,4 +31,4 @@ fix #123 It's ok to have multiple commits in a single PR, you don't need to rebase or force push for your changes as we will use Squash and Merge to squash the commits into one commit when merging. -And of course please test your code before PR. +And of course please test your code before PR. \ No newline at end of file From 79e31cab8a86438edab055d22e511b128e963cec Mon Sep 17 00:00:00 2001 From: Chris Ondrovic Date: Fri, 31 Oct 2025 09:46:33 -0400 Subject: [PATCH 3/3] fix(localizations): properly setup and use localizations --- src/main/i18n/locales/cs_CZ/preferences.json | 7 +++++++ src/main/i18n/locales/de_DE/preferences.json | 7 +++++++ src/main/i18n/locales/el_GR/preferences.json | 7 +++++++ src/main/i18n/locales/en_US/preferences.json | 7 +++++++ src/main/i18n/locales/es_ES/preferences.json | 7 +++++++ src/main/i18n/locales/fa_IR/preferences.json | 7 +++++++ src/main/i18n/locales/fr_FR/preferences.json | 7 +++++++ src/main/i18n/locales/ja_JP/preferences.json | 7 +++++++ src/main/i18n/locales/pl_PL/preferences.json | 7 +++++++ src/main/i18n/locales/pt_BR/preferences.json | 7 +++++++ src/main/i18n/locales/ro_RO/preferences.json | 7 +++++++ src/main/i18n/locales/ru_RU/preferences.json | 7 +++++++ src/main/i18n/locales/tr_TR/preferences.json | 7 +++++++ src/main/i18n/locales/uk_UA/preferences.json | 7 +++++++ src/main/i18n/locales/zh_CN/preferences.json | 7 +++++++ src/main/i18n/locales/zh_HK/preferences.json | 7 +++++++ src/main/i18n/locales/zh_TW/preferences.json | 7 +++++++ src/renderer/components/preferences/API.vue | 5 ++--- src/renderer/views/Preferences.vue | 2 +- 19 files changed, 122 insertions(+), 4 deletions(-) diff --git a/src/main/i18n/locales/cs_CZ/preferences.json b/src/main/i18n/locales/cs_CZ/preferences.json index 51d96100..5dc8fe9b 100644 --- a/src/main/i18n/locales/cs_CZ/preferences.json +++ b/src/main/i18n/locales/cs_CZ/preferences.json @@ -46,5 +46,12 @@ "markdown": { "label": "Markdown", "codeRenderer": "Renderer kódových bloků" + }, + "api": { + "label": "API Port", + "port": { + "label": "API Port", + "description": "Číslo portu pro API server (vyžaduje restart aplikace). Platný rozsah: 1024-65535." + } } } diff --git a/src/main/i18n/locales/de_DE/preferences.json b/src/main/i18n/locales/de_DE/preferences.json index 16ac0c56..733ffbb3 100644 --- a/src/main/i18n/locales/de_DE/preferences.json +++ b/src/main/i18n/locales/de_DE/preferences.json @@ -46,5 +46,12 @@ "markdown": { "label": "Markdown", "codeRenderer": "Code-Block Renderer" + }, + "api": { + "label": "API-Port", + "port": { + "label": "API-Port", + "description": "Portnummer für den API-Server (erfordert Neustart der App). Gültiger Bereich: 1024-65535." + } } } diff --git a/src/main/i18n/locales/el_GR/preferences.json b/src/main/i18n/locales/el_GR/preferences.json index a43a047f..af3c1851 100644 --- a/src/main/i18n/locales/el_GR/preferences.json +++ b/src/main/i18n/locales/el_GR/preferences.json @@ -46,5 +46,12 @@ "markdown": { "label": "Markdown", "codeRenderer": "Code block Renderer" + }, + "api": { + "label": "Θύρα API", + "port": { + "label": "Θύρα API", + "description": "Αριθμός θύρας για τον διακομιστή API (απαιτείται επανεκκίνηση της εφαρμογής). Έγκυρο εύρος: 1024-65535." + } } } diff --git a/src/main/i18n/locales/en_US/preferences.json b/src/main/i18n/locales/en_US/preferences.json index ebc93ebb..6218c98d 100644 --- a/src/main/i18n/locales/en_US/preferences.json +++ b/src/main/i18n/locales/en_US/preferences.json @@ -68,5 +68,12 @@ "markdown": { "label": "Markdown", "codeRenderer": "Code block Renderer" + }, + "api": { + "label": "API Port", + "port": { + "label": "API Port", + "description": "Port number for the API server (requires app restart to take effect). Valid range: 1024-65535." + } } } diff --git a/src/main/i18n/locales/es_ES/preferences.json b/src/main/i18n/locales/es_ES/preferences.json index 798dc065..f29b4fed 100644 --- a/src/main/i18n/locales/es_ES/preferences.json +++ b/src/main/i18n/locales/es_ES/preferences.json @@ -46,5 +46,12 @@ "markdown": { "label": "Markdown", "codeRenderer": "Renderizador de Bloques de Código" + }, + "api": { + "label": "Puerto API", + "port": { + "label": "Puerto API", + "description": "Número de puerto para el servidor API (requiere reiniciar la aplicación). Rango válido: 1024-65535." + } } } diff --git a/src/main/i18n/locales/fa_IR/preferences.json b/src/main/i18n/locales/fa_IR/preferences.json index 83a97da8..38a99fbf 100644 --- a/src/main/i18n/locales/fa_IR/preferences.json +++ b/src/main/i18n/locales/fa_IR/preferences.json @@ -46,5 +46,12 @@ "markdown": { "label": "Markdown", "codeRenderer": "رندرکننده بلوک کد" + }, + "api": { + "label": "پورت API", + "port": { + "label": "پورت API", + "description": "شماره پورت برای سرور API (نیاز به راه‌اندازی مجدد برنامه دارد). محدوده معتبر: 1024-65535." + } } } diff --git a/src/main/i18n/locales/fr_FR/preferences.json b/src/main/i18n/locales/fr_FR/preferences.json index 3b10d4cd..4ec2bdde 100644 --- a/src/main/i18n/locales/fr_FR/preferences.json +++ b/src/main/i18n/locales/fr_FR/preferences.json @@ -46,5 +46,12 @@ "markdown": { "label": "Markdown", "codeRenderer": "Rendu des blocs de code" + }, + "api": { + "label": "Port API", + "port": { + "label": "Port API", + "description": "Numéro de port pour le serveur API (nécessite un redémarrage de l'application). Plage valide: 1024-65535." + } } } diff --git a/src/main/i18n/locales/ja_JP/preferences.json b/src/main/i18n/locales/ja_JP/preferences.json index ea397cac..cde89163 100644 --- a/src/main/i18n/locales/ja_JP/preferences.json +++ b/src/main/i18n/locales/ja_JP/preferences.json @@ -46,5 +46,12 @@ "markdown": { "label": "Markdown", "codeRenderer": "コードブロックレンダラー" + }, + "api": { + "label": "APIポート", + "port": { + "label": "APIポート", + "description": "APIサーバーのポート番号(アプリの再起動が必要です)。有効範囲:1024-65535。" + } } } diff --git a/src/main/i18n/locales/pl_PL/preferences.json b/src/main/i18n/locales/pl_PL/preferences.json index 5e3b6a42..ae0eb32b 100644 --- a/src/main/i18n/locales/pl_PL/preferences.json +++ b/src/main/i18n/locales/pl_PL/preferences.json @@ -46,5 +46,12 @@ "markdown": { "label": "Markdown", "codeRenderer": "Renderer bloków kodu" + }, + "api": { + "label": "Port API", + "port": { + "label": "Port API", + "description": "Numer portu dla serwera API (wymaga ponownego uruchomienia aplikacji). Prawidłowy zakres: 1024-65535." + } } } diff --git a/src/main/i18n/locales/pt_BR/preferences.json b/src/main/i18n/locales/pt_BR/preferences.json index 50ad615b..38b98290 100644 --- a/src/main/i18n/locales/pt_BR/preferences.json +++ b/src/main/i18n/locales/pt_BR/preferences.json @@ -46,5 +46,12 @@ "markdown": { "label": "Markdown", "codeRenderer": "Renderizador de Bloco de Código" + }, + "api": { + "label": "Porta API", + "port": { + "label": "Porta API", + "description": "Número da porta para o servidor API (requer reinicialização do aplicativo). Faixa válida: 1024-65535." + } } } diff --git a/src/main/i18n/locales/ro_RO/preferences.json b/src/main/i18n/locales/ro_RO/preferences.json index 785d53e4..36b0ea0c 100644 --- a/src/main/i18n/locales/ro_RO/preferences.json +++ b/src/main/i18n/locales/ro_RO/preferences.json @@ -46,5 +46,12 @@ "markdown": { "label": "Markdown", "codeRenderer": "Renderer Bloc de Cod" + }, + "api": { + "label": "Port API", + "port": { + "label": "Port API", + "description": "Numărul portului pentru serverul API (necesită repornirea aplicației). Interval valid: 1024-65535." + } } } diff --git a/src/main/i18n/locales/ru_RU/preferences.json b/src/main/i18n/locales/ru_RU/preferences.json index a40be6a3..0b457dc7 100644 --- a/src/main/i18n/locales/ru_RU/preferences.json +++ b/src/main/i18n/locales/ru_RU/preferences.json @@ -46,5 +46,12 @@ "markdown": { "label": "Markdown", "codeRenderer": "Рендер блоков кода" + }, + "api": { + "label": "Порт API", + "port": { + "label": "Порт API", + "description": "Номер порта для API-сервера (требуется перезапуск приложения). Допустимый диапазон: 1024-65535." + } } } diff --git a/src/main/i18n/locales/tr_TR/preferences.json b/src/main/i18n/locales/tr_TR/preferences.json index c65dd6ed..143fb6bd 100644 --- a/src/main/i18n/locales/tr_TR/preferences.json +++ b/src/main/i18n/locales/tr_TR/preferences.json @@ -46,5 +46,12 @@ "markdown": { "label": "Markdown", "codeRenderer": "Kod Bloğu Görüntüleyici" + }, + "api": { + "label": "API Portu", + "port": { + "label": "API Portu", + "description": "API sunucusu için port numarası (uygulamayı yeniden başlatmak gerekir). Geçerli aralık: 1024-65535." + } } } diff --git a/src/main/i18n/locales/uk_UA/preferences.json b/src/main/i18n/locales/uk_UA/preferences.json index cb226bba..298ded43 100644 --- a/src/main/i18n/locales/uk_UA/preferences.json +++ b/src/main/i18n/locales/uk_UA/preferences.json @@ -46,5 +46,12 @@ "markdown": { "label": "Markdown", "codeRenderer": "Відображення блоків коду" + }, + "api": { + "label": "Порт API", + "port": { + "label": "Порт API", + "description": "Номер порту для API-сервера (потребує перезапуску додатку). Допустимий діапазон: 1024-65535." + } } } diff --git a/src/main/i18n/locales/zh_CN/preferences.json b/src/main/i18n/locales/zh_CN/preferences.json index 5d121521..c85e6834 100644 --- a/src/main/i18n/locales/zh_CN/preferences.json +++ b/src/main/i18n/locales/zh_CN/preferences.json @@ -46,5 +46,12 @@ "markdown": { "label": "Markdown", "codeRenderer": "代码块渲染器" + }, + "api": { + "label": "API 端口", + "port": { + "label": "API 端口", + "description": "API 服务器的端口号(需要重启应用程序才能生效)。有效范围:1024-65535。" + } } } diff --git a/src/main/i18n/locales/zh_HK/preferences.json b/src/main/i18n/locales/zh_HK/preferences.json index fe22f8ad..122740f6 100644 --- a/src/main/i18n/locales/zh_HK/preferences.json +++ b/src/main/i18n/locales/zh_HK/preferences.json @@ -46,5 +46,12 @@ "markdown": { "label": "Markdown", "codeRenderer": "程式碼區塊渲染器" + }, + "api": { + "label": "API 端口", + "port": { + "label": "API 端口", + "description": "API 伺服器的端口號(需要重新啟動應用程式)。有效範圍:1024-65535。" + } } } diff --git a/src/main/i18n/locales/zh_TW/preferences.json b/src/main/i18n/locales/zh_TW/preferences.json index bbdf04d6..0465d77e 100644 --- a/src/main/i18n/locales/zh_TW/preferences.json +++ b/src/main/i18n/locales/zh_TW/preferences.json @@ -46,5 +46,12 @@ "markdown": { "label": "Markdown", "codeRenderer": "代碼塊渲染器" + }, + "api": { + "label": "API 連接埠", + "port": { + "label": "API 連接埠", + "description": "API 伺服器的連接埠號碼(需要重新啟動應用程式)。有效範圍:1024-65535。" + } } } diff --git a/src/renderer/components/preferences/API.vue b/src/renderer/components/preferences/API.vue index 2cd2d7e3..e50b101c 100644 --- a/src/renderer/components/preferences/API.vue +++ b/src/renderer/components/preferences/API.vue @@ -13,7 +13,7 @@ watch(apiPort, (value) => {