diff --git a/app/common/vue_lib/src/h/ParamsHelper.d.ts b/app/common/vue_lib/src/h/ParamsHelper.d.ts index 512c5c2..6b25798 100644 --- a/app/common/vue_lib/src/h/ParamsHelper.d.ts +++ b/app/common/vue_lib/src/h/ParamsHelper.d.ts @@ -25,6 +25,7 @@ export interface TauriVM { downloadPath: string | undefined; hostname: string | undefined; settingsOpen: boolean; + new_version: string | null; enable: () => Promise; disable: () => Promise; invoke: (cmd: string, args?: InvokeArgs) => Promise diff --git a/app/common/vue_lib/src/index.ts b/app/common/vue_lib/src/index.ts index f6de44e..6703cbe 100644 --- a/app/common/vue_lib/src/index.ts +++ b/app/common/vue_lib/src/index.ts @@ -170,4 +170,22 @@ export async function setDownloadPath(vm: TauriVM, dest: string) { export async function getDownloadPath(vm: TauriVM) { vm.downloadPath = await vm.store.get(downloadPathKey) ?? undefined; +} + +export async function getLatestVersion(vm: TauriVM, gt: (a: string, b: string) => boolean) { + try { + const response = await fetch('https://api.github.com/repos/martichou/rquickshare/releases/latest'); + if (!response.ok) { + throw new Error(`Error: ${response.status} ${response.statusText}`); + } + const data = await response.json(); + const new_version = data.tag_name.substring(1); + console.log(`Latest version: ${vm.version} vs ${new_version}`); + + if (vm.version && gt(new_version, vm.version)) { + vm.new_version = new_version; + } + } catch (err) { + console.error(err); + } } \ No newline at end of file diff --git a/app/legacy/package.json b/app/legacy/package.json index 2d054e7..5cc9c4d 100644 --- a/app/legacy/package.json +++ b/app/legacy/package.json @@ -19,6 +19,7 @@ "dependencies": { "@martichou/core_lib": "link:../../core_lib", "@tauri-apps/api": "1.5.6", + "semver": "^7.6.2", "tauri-plugin-autostart-api": "github:tauri-apps/tauri-plugin-autostart#v1", "tauri-plugin-store-api": "github:tauri-apps/tauri-plugin-store#v1", "vue": "3.4.27", @@ -29,6 +30,7 @@ "@tailwindcss/typography": "^0.5.13", "@tauri-apps/cli": "1.5.14", "@types/node": "^20.14.2", + "@types/semver": "^7.5.8", "@vitejs/plugin-vue": "^5.0.5", "@vue/devtools": "^7.3.4", "@vue/eslint-config-typescript": "13.0.0", diff --git a/app/legacy/pnpm-lock.yaml b/app/legacy/pnpm-lock.yaml index 8b4abfe..aae111b 100644 --- a/app/legacy/pnpm-lock.yaml +++ b/app/legacy/pnpm-lock.yaml @@ -14,6 +14,9 @@ importers: '@tauri-apps/api': specifier: 1.5.6 version: 1.5.6 + semver: + specifier: ^7.6.2 + version: 7.6.2 tauri-plugin-autostart-api: specifier: github:tauri-apps/tauri-plugin-autostart#v1 version: https://codeload.github.com/tauri-apps/tauri-plugin-autostart/tar.gz/95dbee4b9e1209cbbea17c77d197b267fa7fe8d9 @@ -39,6 +42,9 @@ importers: '@types/node': specifier: ^20.14.2 version: 20.14.2 + '@types/semver': + specifier: ^7.5.8 + version: 7.5.8 '@vitejs/plugin-vue': specifier: ^5.0.5 version: 5.0.5(vite@5.2.13(@types/node@20.14.2))(vue@3.4.27(typescript@5.4.5)) @@ -591,6 +597,9 @@ packages: '@types/responselike@1.0.3': resolution: {integrity: sha512-H/+L+UkTV33uf49PH5pCAUBVPNj2nDBXTN+qS1dOwyyg24l3CcicicCA7ca+HMvJBZcFgl5r8e+RR6elsb4Lyw==} + '@types/semver@7.5.8': + resolution: {integrity: sha512-I8EUhyrgfLrcTkzV3TSsGyl1tSuPrEDzr0yd5m90UgNxQkyDXULk3b6MlQqTCpZpNtWe1K0hzclnZkTcLBe2UQ==} + '@types/yauzl@2.10.3': resolution: {integrity: sha512-oJoftv0LSuaDZE3Le4DbKX+KS9G36NzOeSap90UIK0yMA/NhKJhqlSGtNDORNRaIbQfzjXDrQa0ytJ6mNRGz/Q==} @@ -2699,6 +2708,8 @@ snapshots: dependencies: '@types/node': 20.14.2 + '@types/semver@7.5.8': {} + '@types/yauzl@2.10.3': dependencies: '@types/node': 20.14.2 diff --git a/app/legacy/src/components/HomePage.vue b/app/legacy/src/components/HomePage.vue index 9f03164..cb2ba9b 100644 --- a/app/legacy/src/components/HomePage.vue +++ b/app/legacy/src/components/HomePage.vue @@ -46,9 +46,21 @@
-

- v{{ version }} -

+
+ Update available +

+ v{{ version }} +

+

+ 🡒 +

+

+ v{{ new_version }} +

+
-

- v{{ version }} -

+
+ Update available +

+ v{{ version }} +

+

+ 🡒 +

+

+ v{{ new_version }} +

+