فهرست منبع

feat(app): add tray menu and update window functionality

AkiraBit 2 ماه پیش
والد
کامیت
c40db40427
3فایلهای تغییر یافته به همراه55 افزوده شده و 24 حذف شده
  1. 5 11
      apps/picsharp-app/src/i18n/locales/en-US.ts
  2. 5 11
      apps/picsharp-app/src/i18n/locales/zh-CN.ts
  3. 45 2
      apps/picsharp-app/src/utils/tray.ts

+ 5 - 11
apps/picsharp-app/src/i18n/locales/en-US.ts

@@ -144,6 +144,11 @@ const enUS = {
   'settings.about.feedback.title': 'Feedback',
   'settings.about.feedback.description':
     'Optimize suggestions, Bug feedback, Feature requests, etc.',
+  // Tray
+  'tray.open': 'Open',
+  'tray.settings': 'Settings',
+  'tray.check_update': 'Check Update',
+  'tray.quit': 'Quit',
   //
   'page.compression.process.actions.save': 'Save',
   'page.compression.process.actions.compress': 'Compress',
@@ -240,17 +245,6 @@ const enUS = {
   'page.compression.watch.guide.attention': 'Attention',
   'page.compression.watch.guide.attention_description':
     'Only recognize new images (new, copy, move) added to the directory, and do not compress images that already exist in the directory. If an image is replaced with an image that already exists in the directory and has the same name, it will be considered the same image and will not be compressed.',
-
-  // Features
-  'page.compression.classic.feature.batch.title': 'Efficient Batch Processing',
-  'page.compression.classic.feature.batch.description':
-    'Intelligent algorithms can process multiple image files simultaneously',
-  'page.compression.classic.feature.quality.title': 'Maintain Image Quality',
-  'page.compression.classic.feature.quality.description':
-    'The compression process intelligently balances file size and image quality, ensuring compressed images remain clear and usable.',
-  'page.compression.classic.feature.mode.title': 'Offline/Online Compression',
-  'page.compression.classic.feature.mode.description':
-    'Offline mode ensures images are processed locally, effectively protecting data security and privacy;',
 };
 
 export default enUS;

+ 5 - 11
apps/picsharp-app/src/i18n/locales/zh-CN.ts

@@ -142,6 +142,11 @@ export default {
   // Settings.About.Feedback
   'settings.about.feedback.title': '反馈',
   'settings.about.feedback.description': '优化建议、Bug反馈、功能需求等',
+  // Tray
+  'tray.open': '打开',
+  'tray.settings': '设置',
+  'tray.check_update': '检查更新',
+  'tray.quit': '退出',
   //
   'page.compression.process.actions.save': '保存',
   'page.compression.process.actions.compress': '压缩',
@@ -236,15 +241,4 @@ export default {
   'page.compression.watch.guide.attention': '注意事项',
   'page.compression.watch.guide.attention_description':
     '只识别新增(新建、复制、移入)的图片,对于目录中已存在的图片,不会进行压缩。如果图片被替换为目录中已存在且同名的图片,其会被认定为同一张图像,也不会进行压缩。',
-
-  // 功能特点
-  'page.compression.classic.feature.batch.title': '高效批量处理',
-  'page.compression.classic.feature.batch.description':
-    '智能算法可同时处理多个图像文件,自动优化压缩参数,高效完成批量任务。',
-  'page.compression.classic.feature.quality.title': '保持图像质量',
-  'page.compression.classic.feature.quality.description':
-    '压缩过程可智能平衡文件大小与图像质量,确保压缩后的图像仍然清晰可用。',
-  'page.compression.classic.feature.mode.title': '离线/在线压缩',
-  'page.compression.classic.feature.mode.description':
-    '离线模式确保图像完全在本地处理,有效保障数据安全与隐私;在线模式则利用Tinypng专业服务,为您提供更高压缩比和优质图像效果,满足不同场景需求。',
 };

+ 45 - 2
apps/picsharp-app/src/utils/tray.ts

@@ -5,6 +5,8 @@ import { t } from '../i18n';
 import { getCurrentWebviewWindow } from '@tauri-apps/api/webviewWindow';
 import { getCurrentWindow } from '@tauri-apps/api/window';
 import { isProd } from '.';
+import { createWebviewWindow } from './window';
+import checkForUpdate from './updater';
 
 declare global {
   interface Window {
@@ -15,9 +17,50 @@ declare global {
 export async function createTrayMenu() {
   const menu = await Menu.new({
     items: [
+      {
+        id: 'open',
+        text: t('tray.open'),
+        action: async () => {
+          await getCurrentWindow().show();
+          await getCurrentWindow().setFocus();
+        },
+        accelerator: 'CmdOrCtrl+O',
+      },
+      {
+        id: 'settings',
+        text: t('tray.settings'),
+        action: () => {
+          createWebviewWindow('settings', {
+            url: '/settings',
+            title: t('nav.settings'),
+            width: 724,
+            height: 450,
+            center: true,
+            resizable: true,
+            titleBarStyle: 'overlay',
+            hiddenTitle: true,
+            dragDropEnabled: true,
+            minimizable: true,
+            maximizable: true,
+          });
+        },
+        accelerator: 'CmdOrCtrl+S',
+      },
+      {
+        id: 'check_update',
+        text: t('tray.check_update'),
+        action: () => {
+          checkForUpdate();
+        },
+        accelerator: 'CmdOrCtrl+U',
+      },
       {
         id: 'quit',
-        text: t('quit'),
+        text: t('tray.quit'),
+        action: () => {
+          getCurrentWindow().destroy();
+        },
+        accelerator: 'CmdOrCtrl+Q',
       },
     ],
   });
@@ -49,6 +92,6 @@ export async function initTray() {
   window.__TRAY_INSTANCE = tray;
 }
 
-if (isProd) {
+if (!isProd) {
   initTray();
 }