From 27f6d858a3c650580784de7a3cd21eb13fef85f9 Mon Sep 17 00:00:00 2001 From: seven Date: Mon, 1 Apr 2024 23:58:33 +0800 Subject: [PATCH] feat: auto detect if there is new version avialable (#43) #40 Signed-off-by: seven --- components.d.ts | 1 + package-lock.json | 4 +- package.json | 2 +- src/App.vue | 2 + src/components/VersionDetect.vue | 119 ++++++++++++++++++ src/electron/preload.ts | 5 +- src/lang/enUS.ts | 7 ++ src/lang/zhCN.ts | 7 ++ src/store/appStore.ts | 2 + .../connect/components/connect-dialog.vue | 2 +- src/vite-env.d.ts | 7 ++ tsconfig.json | 5 +- 12 files changed, 154 insertions(+), 9 deletions(-) create mode 100644 src/components/VersionDetect.vue diff --git a/components.d.ts b/components.d.ts index 82a73b07..f1bc830f 100644 --- a/components.d.ts +++ b/components.d.ts @@ -39,5 +39,6 @@ declare module 'vue' { RouterLink: typeof import('vue-router')['RouterLink'] RouterMain: typeof import('./src/components/RouterMain.vue')['default'] RouterView: typeof import('vue-router')['RouterView'] + VersionDetect: typeof import('./src/components/VersionDetect.vue')['default'] } } diff --git a/package-lock.json b/package-lock.json index cb4dc58f..28385aef 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "DocKit", - "version": "0.2.5", + "version": "0.2.6", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "DocKit", - "version": "0.2.5", + "version": "0.2.6", "license": "Apache-2.0", "dependencies": { "buffer": "^6.0.3", diff --git a/package.json b/package.json index a702a916..474380e3 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "DocKit", "productName": "DocKit", "private": true, - "version": "0.2.5", + "version": "0.2.6", "description": "A faster, better and more stable NoSQL desktop tools", "author": "geekfun ", "license": "Apache-2.0", diff --git a/src/App.vue b/src/App.vue index 156f0503..f5e3f5e6 100644 --- a/src/App.vue +++ b/src/App.vue @@ -1,10 +1,12 @@ diff --git a/src/components/VersionDetect.vue b/src/components/VersionDetect.vue new file mode 100644 index 00000000..2ea04f23 --- /dev/null +++ b/src/components/VersionDetect.vue @@ -0,0 +1,119 @@ + + + + + diff --git a/src/electron/preload.ts b/src/electron/preload.ts index 732fb2a5..d1004a8f 100644 --- a/src/electron/preload.ts +++ b/src/electron/preload.ts @@ -2,13 +2,10 @@ // https://www.electronjs.org/docs/latest/tutorial/process-model#preload-scripts import { contextBridge, ipcRenderer } from 'electron'; -contextBridge.exposeInMainWorld('browserWindow', { - versions: () => ipcRenderer.invoke('versions'), -}); - contextBridge.exposeInMainWorld('electronAPI', { openGitHub: () => ipcRenderer.send('open-github'), openLink: (link: string) => ipcRenderer.send('open-link', link), + versions: () => ipcRenderer.invoke('versions'), }); contextBridge.exposeInMainWorld('storeAPI', { diff --git a/src/lang/enUS.ts b/src/lang/enUS.ts index b2a69bad..eead176f 100644 --- a/src/lang/enUS.ts +++ b/src/lang/enUS.ts @@ -58,4 +58,11 @@ export const enUS = { empty: 'No history yet', emptyDesc: 'History of queries will appear here as you execute Scans and Queries', }, + version: { + newVersion: 'New version available', + message: 'A new version is available, download it now', + download: 'Download', + skip: 'Skip this version', + later: 'Later', + }, }; diff --git a/src/lang/zhCN.ts b/src/lang/zhCN.ts index 83d41ef6..c1c0fd90 100644 --- a/src/lang/zhCN.ts +++ b/src/lang/zhCN.ts @@ -58,4 +58,11 @@ export const zhCN = { empty: '无历史记录', emptyDesc: '执行扫描和查询时,查询历史记录将显示在此处', }, + version: { + newVersion: '发现新版本', + message: '发现新版本,是否立即下载', + skip: '跳过该版本', + download: '下载', + later: '忽略', + }, }; diff --git a/src/store/appStore.ts b/src/store/appStore.ts index 6d276b02..b7f1a1c4 100644 --- a/src/store/appStore.ts +++ b/src/store/appStore.ts @@ -15,12 +15,14 @@ export const useAppStore = defineStore('app', { languageType: LanguageType; connectPanel: boolean; uiThemeType: Exclude; + skipVersion: string; } => { return { themeType: ThemeType.AUTO, languageType: LanguageType.AUTO, connectPanel: true, // uiThemeType: ThemeType.LIGHT, + skipVersion: '', }; }, persist: true, diff --git a/src/views/connect/components/connect-dialog.vue b/src/views/connect/components/connect-dialog.vue index da7206dd..1dc17d1a 100644 --- a/src/views/connect/components/connect-dialog.vue +++ b/src/views/connect/components/connect-dialog.vue @@ -137,7 +137,7 @@