diff --git a/.github/scripts/check-jdbc-plugin-version.mjs b/.github/scripts/check-jdbc-plugin-version.mjs index 266930d5e..538b2015b 100644 --- a/.github/scripts/check-jdbc-plugin-version.mjs +++ b/.github/scripts/check-jdbc-plugin-version.mjs @@ -13,10 +13,7 @@ function manifestVersion(manifestJson) { return JSON.parse(manifestJson).version ?? ""; } -export function evaluateJdbcPluginVersionChange({ - headPomVersion, - headManifestVersion, -}) { +export function evaluateJdbcPluginVersionChange({ headPomVersion, headManifestVersion }) { const errors = []; if (headPomVersion !== headManifestVersion) { errors.push(`JDBC plugin version mismatch: pom.xml is ${headPomVersion} but manifest.json is ${headManifestVersion}.`); diff --git a/.github/scripts/sync-changelog.mjs b/.github/scripts/sync-changelog.mjs index b42bbea43..801164172 100644 --- a/.github/scripts/sync-changelog.mjs +++ b/.github/scripts/sync-changelog.mjs @@ -1,38 +1,35 @@ #!/usr/bin/env node -import { createHash } from 'node:crypto'; -import { writeFileSync } from 'node:fs'; -import { resolve } from 'node:path'; -import { fileURLToPath } from 'node:url'; +import { createHash } from "node:crypto"; +import { writeFileSync } from "node:fs"; +import { resolve } from "node:path"; +import { fileURLToPath } from "node:url"; -const REPO = 't8y2/dbx'; -const GITHUB_TOKEN = process.env.GITHUB_TOKEN || ''; -const DEEPSEEK_API_KEY = process.env.DEEPSEEK_API_KEY || ''; -const OUT_CN = 'releases-cn.json'; -const OUT_EN = 'releases-en.json'; -const EN_CACHE_URL = process.env.CHANGELOG_EN_CACHE_URL || 'https://dl.dbxio.com/changelog/releases-en.json'; +const REPO = "t8y2/dbx"; +const GITHUB_TOKEN = process.env.GITHUB_TOKEN || ""; +const DEEPSEEK_API_KEY = process.env.DEEPSEEK_API_KEY || ""; +const OUT_CN = "releases-cn.json"; +const OUT_EN = "releases-en.json"; +const EN_CACHE_URL = process.env.CHANGELOG_EN_CACHE_URL || "https://dl.dbxio.com/changelog/releases-en.json"; const SECTION_MAP = { - '新功能': 'added', - 'Added': 'added', - '改进': 'improved', - 'Improved': 'improved', - '修复': 'fixed', - 'Fixed': 'fixed', - '变更': 'changed', - 'Changed': 'changed', - '移除': 'removed', - 'Removed': 'removed', + 新功能: "added", + Added: "added", + 改进: "improved", + Improved: "improved", + 修复: "fixed", + Fixed: "fixed", + 变更: "changed", + Changed: "changed", + 移除: "removed", + Removed: "removed", }; export async function fetchAllReleases() { const releases = []; let page = 1; while (true) { - const res = await fetch( - `https://api.github.com/repos/${REPO}/releases?per_page=100&page=${page}`, - { headers: { Authorization: `token ${GITHUB_TOKEN}`, Accept: 'application/vnd.github+json' } }, - ); + const res = await fetch(`https://api.github.com/repos/${REPO}/releases?per_page=100&page=${page}`, { headers: { Authorization: `token ${GITHUB_TOKEN}`, Accept: "application/vnd.github+json" } }); if (!res.ok) throw new Error(`GitHub API ${res.status}: ${await res.text()}`); const data = await res.json(); if (data.length === 0) break; @@ -43,7 +40,7 @@ export async function fetchAllReleases() { } export function stripDownloadSection(body) { - const markers = ['### 下载安装', '### Download', '### 系统要求', '### System Requirements']; + const markers = ["### 下载安装", "### Download", "### 系统要求", "### System Requirements"]; let idx = body.length; for (const m of markers) { const i = body.indexOf(m); @@ -57,11 +54,11 @@ export function parseBody(body) { const sections = []; let current = null; - for (const line of cleaned.split('\n')) { + for (const line of cleaned.split("\n")) { const headerMatch = line.match(/^###\s+(.+)/); if (headerMatch) { const title = headerMatch[1].trim(); - const type = SECTION_MAP[title] || 'other'; + const type = SECTION_MAP[title] || "other"; current = { type, title, items: [] }; sections.push(current); continue; @@ -77,7 +74,7 @@ export function parseBody(body) { const plainMatch = line.match(/^-\s+(.+)/); if (plainMatch) { - current.items.push({ title: plainMatch[1].trim(), desc: '' }); + current.items.push({ title: plainMatch[1].trim(), desc: "" }); } } @@ -85,16 +82,16 @@ export function parseBody(body) { } export function buildReleaseSourceHash(release) { - return createHash('sha256') + return createHash("sha256") .update( JSON.stringify({ tag: release.tag_name, name: release.name || release.tag_name, - publishedAt: release.published_at || '', - body: release.body || '', + publishedAt: release.published_at || "", + body: release.body || "", }), ) - .digest('hex'); + .digest("hex"); } export function buildReleasesJson(releases, now = new Date()) { @@ -108,7 +105,7 @@ export function buildReleasesJson(releases, now = new Date()) { name: r.name || r.tag_name, date: r.published_at.slice(0, 10), _sourceHash: buildReleaseSourceHash(r), - sections: parseBody(r.body || ''), + sections: parseBody(r.body || ""), })), }; } @@ -116,18 +113,15 @@ export function buildReleasesJson(releases, now = new Date()) { function releaseToMarkdown(release) { return release.sections .map((s) => { - const items = s.items.map((i) => (i.desc ? `- **${i.title}** — ${i.desc}` : `- ${i.title}`)).join('\n'); + const items = s.items.map((i) => (i.desc ? `- **${i.title}** — ${i.desc}` : `- ${i.title}`)).join("\n"); return `### ${s.title}\n${items}`; }) - .join('\n\n'); + .join("\n\n"); } -export async function fetchCachedEnglish({ - cacheUrl = EN_CACHE_URL, - fetchImpl = fetch, -} = {}) { +export async function fetchCachedEnglish({ cacheUrl = EN_CACHE_URL, fetchImpl = fetch } = {}) { try { - const res = await fetchImpl(cacheUrl, { headers: { Accept: 'application/json' } }); + const res = await fetchImpl(cacheUrl, { headers: { Accept: "application/json" } }); if (!res.ok) { console.warn(`English changelog cache unavailable: ${res.status}`); return null; @@ -139,17 +133,9 @@ export async function fetchCachedEnglish({ } } -export async function translateToEnglish( - cnJson, - { - cachedEnJson = null, - deepseekApiKey = DEEPSEEK_API_KEY, - fetchImpl = fetch, - sleep = (ms) => new Promise((r) => setTimeout(r, ms)), - } = {}, -) { +export async function translateToEnglish(cnJson, { cachedEnJson = null, deepseekApiKey = DEEPSEEK_API_KEY, fetchImpl = fetch, sleep = (ms) => new Promise((r) => setTimeout(r, ms)) } = {}) { if (!deepseekApiKey) { - console.warn('DEEPSEEK_API_KEY not set, skipping translation'); + console.warn("DEEPSEEK_API_KEY not set, skipping translation"); return null; } @@ -178,18 +164,18 @@ export async function translateToEnglish( continue; } - const res = await fetchImpl('https://api.deepseek.com/chat/completions', { - method: 'POST', - headers: { 'Content-Type': 'application/json', Authorization: `Bearer ${deepseekApiKey}` }, + const res = await fetchImpl("https://api.deepseek.com/chat/completions", { + method: "POST", + headers: { "Content-Type": "application/json", Authorization: `Bearer ${deepseekApiKey}` }, body: JSON.stringify({ - model: 'deepseek-chat', + model: "deepseek-chat", messages: [ { - role: 'system', + role: "system", content: - 'You are a technical translator. Translate the following Chinese software changelog to English. Keep the exact markdown format (### headers, - bullet points, **bold** titles, — dashes). Only translate, do not add or remove content. Keep technical terms, product names, and contributor names unchanged.', + "You are a technical translator. Translate the following Chinese software changelog to English. Keep the exact markdown format (### headers, - bullet points, **bold** titles, — dashes). Only translate, do not add or remove content. Keep technical terms, product names, and contributor names unchanged.", }, - { role: 'user', content: sectionsText }, + { role: "user", content: sectionsText }, ], temperature: 0.1, }), @@ -202,7 +188,7 @@ export async function translateToEnglish( } const data = await res.json(); - const translated = data.choices?.[0]?.message?.content || ''; + const translated = data.choices?.[0]?.message?.content || ""; const enSections = parseBody(translated); enReleases.push({ ...release, sections: enSections.length > 0 ? enSections : release.sections }); translatedCount++; @@ -215,7 +201,7 @@ export async function translateToEnglish( } async function main() { - console.log('Fetching releases from GitHub...'); + console.log("Fetching releases from GitHub..."); const releases = await fetchAllReleases(); console.log(`Found ${releases.length} releases`); @@ -225,17 +211,17 @@ async function main() { writeFileSync(OUT_CN, JSON.stringify(cnJson, null, 2)); console.log(`Wrote ${OUT_CN}`); - console.log('Fetching cached English changelog...'); + console.log("Fetching cached English changelog..."); const cachedEnJson = await fetchCachedEnglish(); - console.log('Translating to English...'); + console.log("Translating to English..."); const enJson = await translateToEnglish(cnJson, { cachedEnJson }); if (enJson) { writeFileSync(OUT_EN, JSON.stringify(enJson, null, 2)); console.log(`Wrote ${OUT_EN}`); } - console.log('Done!'); + console.log("Done!"); } if (process.argv[1] && fileURLToPath(import.meta.url) === resolve(process.argv[1])) { diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 969a06083..74eb283b4 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -66,7 +66,7 @@ jobs: - name: Rust cache uses: swatinem/rust-cache@v2 with: - workspaces: './ -> target' + workspaces: "./ -> target" shared-key: ci-x86_64-unknown-linux-gnu - name: Cargo fmt check @@ -89,7 +89,7 @@ jobs: uses: actions/setup-java@v4 with: distribution: temurin - java-version: '17' + java-version: "17" cache: maven - name: JDBC plugin version guard diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml index 45dfa9df9..c23e88cef 100644 --- a/.github/workflows/docs.yml +++ b/.github/workflows/docs.yml @@ -3,9 +3,9 @@ name: Deploy Docs on: push: branches: [main] - paths: ['docs/**'] + paths: ["docs/**"] workflow_run: - workflows: ['Publish Packages'] + workflows: ["Publish Packages"] types: [completed] workflow_dispatch: diff --git a/.github/workflows/publish-packages.yml b/.github/workflows/publish-packages.yml index 3dcb32893..522fc3423 100644 --- a/.github/workflows/publish-packages.yml +++ b/.github/workflows/publish-packages.yml @@ -4,7 +4,7 @@ on: workflow_dispatch: inputs: tag: - description: 'Release tag (e.g. v0.3.10)' + description: "Release tag (e.g. v0.3.10)" required: true permissions: diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index d3c98f87d..f89ce602f 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -3,7 +3,7 @@ name: Release on: push: tags: - - 'v*' + - "v*" permissions: contents: write @@ -107,7 +107,7 @@ jobs: - name: Rust cache uses: swatinem/rust-cache@v2 with: - workspaces: './ -> target' + workspaces: "./ -> target" shared-key: release-${{ matrix.target }}-${{ steps.deps-hash.outputs.hash }} add-rust-environment-hash-key: false cache-on-failure: true @@ -173,7 +173,7 @@ jobs: APPLE_TEAM_ID: ${{ startsWith(matrix.platform, 'macos') && secrets.APPLE_TEAM_ID || '' }} with: tagName: ${{ github.ref_name }} - releaseName: 'DBX ${{ github.ref_name }}' + releaseName: "DBX ${{ github.ref_name }}" releaseBody: ${{ steps.release-notes.outputs.body }} releaseDraft: true prerelease: false @@ -246,7 +246,7 @@ jobs: uses: actions/setup-java@v4 with: distribution: temurin - java-version: '17' + java-version: "17" cache: maven - name: Apply automatic JDBC plugin version bump @@ -302,7 +302,6 @@ jobs: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: gh release edit ${{ github.ref_name }} --repo ${{ github.repository }} --draft=false --prerelease - docker: runs-on: ubuntu-latest strategy: diff --git a/.github/workflows/sync-changelog.yml b/.github/workflows/sync-changelog.yml index 833e554f2..8f7f17334 100644 --- a/.github/workflows/sync-changelog.yml +++ b/.github/workflows/sync-changelog.yml @@ -2,7 +2,7 @@ name: Sync Changelog to R2 on: workflow_run: - workflows: ['Publish Packages'] + workflows: ["Publish Packages"] types: [completed] workflow_dispatch: diff --git a/.oxfmtrc.json b/.oxfmtrc.json index 98e1cc043..660b096c3 100644 --- a/.oxfmtrc.json +++ b/.oxfmtrc.json @@ -1,6 +1,6 @@ { "$schema": "./node_modules/oxfmt/configuration_schema.json", - "printWidth": 120, + "printWidth": 300, "tabWidth": 2, "singleQuote": false, "trailingComma": "all", diff --git a/README.zh-CN.md b/README.zh-CN.md index 04d03284c..2018a9a4a 100644 --- a/README.zh-CN.md +++ b/README.zh-CN.md @@ -258,13 +258,13 @@ pnpm tauri build ## 技术栈 -| 层级 | 技术 | -|------|------| -| 框架 | [Tauri 2](https://tauri.app/) | -| 前端 | [Vue 3](https://vuejs.org/) + TypeScript | -| UI | [shadcn-vue](https://www.shadcn-vue.com/) + Tailwind CSS | -| 编辑器 | [CodeMirror 6](https://codemirror.net/) | -| 后端 | Rust + [sqlx](https://github.com/launchbadge/sqlx) / [tiberius](https://github.com/prisma/tiberius) / [redis-rs](https://github.com/redis-rs/redis-rs) / [mongodb](https://github.com/mongodb/mongo-rust-driver) | +| 层级 | 技术 | +| ------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| 框架 | [Tauri 2](https://tauri.app/) | +| 前端 | [Vue 3](https://vuejs.org/) + TypeScript | +| UI | [shadcn-vue](https://www.shadcn-vue.com/) + Tailwind CSS | +| 编辑器 | [CodeMirror 6](https://codemirror.net/) | +| 后端 | Rust + [sqlx](https://github.com/launchbadge/sqlx) / [tiberius](https://github.com/prisma/tiberius) / [redis-rs](https://github.com/redis-rs/redis-rs) / [mongodb](https://github.com/mongodb/mongo-rust-driver) | ## 社区 diff --git a/apps/desktop/src/App.vue b/apps/desktop/src/App.vue index b56c3aae6..30540d9db 100644 --- a/apps/desktop/src/App.vue +++ b/apps/desktop/src/App.vue @@ -86,21 +86,7 @@ const settingsStore = useSettingsStore(); const savedSqlStore = useSavedSqlStore(); const { message: toastMessage, visible: toastVisible, toast } = useToast(); const { isDark, themeMode, applyTheme, setThemeMode } = useTheme(); -const { - checkingUpdates, - updateInfo, - updateCheckMessage, - showUpdateDialog, - isDownloadingUpdate, - downloadProgress, - updateReady, - hasUpdateAvailable, - openUrl, - checkUpdates, - openLatestRelease, - downloadAndInstallUpdate, - restartApp, -} = useAppUpdater(); +const { checkingUpdates, updateInfo, updateCheckMessage, showUpdateDialog, isDownloadingUpdate, downloadProgress, updateReady, hasUpdateAvailable, openUrl, checkUpdates, openLatestRelease, downloadAndInstallUpdate, restartApp } = useAppUpdater(); const { setupFileDrop } = useFileDrop(); const isDesktop = isTauriRuntime(); @@ -120,16 +106,7 @@ const showAiPanel = ref(safeLocalStorageGet("dbx-ai-panel-open") === "true"); const showSqlLibraryPanel = ref(safeLocalStorageGet("dbx-sql-library-open") === "true"); const sidebarOpen = ref(safeLocalStorageGet("dbx-sidebar-open") !== "false"); const aiPanelReady = ref(false); -const { - sidebarWidth, - aiPanelWidth, - historyWidth, - sqlLibraryWidth, - startSidebarResize, - startAiPanelResize, - startHistoryResize, - startSqlLibraryResize, -} = usePanelResize(); +const { sidebarWidth, aiPanelWidth, historyWidth, sqlLibraryWidth, startSidebarResize, startAiPanelResize, startHistoryResize, startSqlLibraryResize } = usePanelResize(); const aiAssistantRef = ref(null); const appSidebarRef = ref | null>(null); const contentAreaRef = ref | null>(null); @@ -206,18 +183,7 @@ async function resolveActiveExecutableSql() { : ""; } -const { - dangerSql, - pendingDangerSql, - showDangerDialog, - suppressDangerConfirm, - tryExecute, - doExecute, - cancelActiveExecution, - tryExplain, - onDangerConfirm, - explainMode, -} = useSqlExecution({ +const { dangerSql, pendingDangerSql, showDangerDialog, suppressDangerConfirm, tryExecute, doExecute, cancelActiveExecution, tryExplain, onDangerConfirm, explainMode } = useSqlExecution({ activeTab, activeConnection, executableSql, @@ -227,8 +193,7 @@ const { const dialogs = useDialogSources(); const { getDatabaseOptions } = useDatabaseOptions(); -const { openLineageTarget, openDatabaseSearchTarget, onStructureEditorSaved, openTableTarget } = - useNavigationTargets(dialogs); +const { openLineageTarget, openDatabaseSearchTarget, onStructureEditorSaved, openTableTarget } = useNavigationTargets(dialogs); const { onExecuteSql, onReloadData, onPaginate, onSort } = useDataGridActions(activeTab); const { setupTauriListeners, cleanupTauriListeners } = useTauriEvents({ openTableTarget, @@ -241,13 +206,9 @@ useVisibilityChange(); const appVersion = ref(""); const isClassicLayout = computed(() => settingsStore.editorSettings.appLayout === "classic"); const updateNotificationsEnabled = computed(() => settingsStore.editorSettings.updateNotificationsEnabled); -const toolbarAgentDriverUpdateCount = computed(() => - updateNotificationsEnabled.value ? agentDriverUpdateCount.value : 0, -); +const toolbarAgentDriverUpdateCount = computed(() => (updateNotificationsEnabled.value ? agentDriverUpdateCount.value : 0)); const toolbarHasUpdateAvailable = computed(() => updateNotificationsEnabled.value && hasUpdateAvailable.value); -const hasSqlFileConnections = computed(() => - connectionStore.connections.some((c) => supportsSqlFileExecution(c.db_type)), -); +const hasSqlFileConnections = computed(() => connectionStore.connections.some((c) => supportsSqlFileExecution(c.db_type))); const connectionStats = computed(() => ({ total: connectionStore.connections.length, connected: connectionStore.connectedIds.size, @@ -290,11 +251,7 @@ function isGlobalUiZoomTarget(target: EventTarget | null): target is Element { if (target.closest("[data-query-editor-root], [data-cell-detail-editor-root], [data-object-source-editor]")) { return true; } - if ( - target instanceof HTMLInputElement || - target instanceof HTMLTextAreaElement || - (target instanceof HTMLElement && target.isContentEditable) - ) { + if (target instanceof HTMLInputElement || target instanceof HTMLTextAreaElement || (target instanceof HTMLElement && target.isContentEditable)) { return false; } return !target.closest("[contenteditable='true']"); @@ -503,8 +460,7 @@ async function openSqlFilePath(path: string) { if (!isTauriRuntime()) return; try { const content = await api.readExternalSqlFile(path); - const connectionId = - connectionStore.activeConnectionId || activeTab.value?.connectionId || connectionStore.connections[0]?.id || ""; + const connectionId = connectionStore.activeConnectionId || activeTab.value?.connectionId || connectionStore.connections[0]?.id || ""; const connection = connectionId ? connectionStore.getConfig(connectionId) : undefined; const database = activeTab.value?.database || (connection ? resolveDefaultDatabase(connection, []) : ""); const tabId = queryStore.createTab(connectionId, database, sqlFileTitleFromPath(path), "query"); @@ -828,12 +784,7 @@ function handleKeydown(e: KeyboardEvent) { void openSaveSqlDialog(); return; } - if ( - activeTab.value?.mode === "query" && - isExecuteSqlShortcut(e, shortcuts) && - e.target instanceof Element && - e.target.closest("[data-query-editor-root]") - ) { + if (activeTab.value?.mode === "query" && isExecuteSqlShortcut(e, shortcuts) && e.target instanceof Element && e.target.closest("[data-query-editor-root]")) { e.preventDefault(); e.stopPropagation(); tryExecute(); @@ -1009,16 +960,10 @@ onUnmounted(() => {