Skip to content

Commit

Permalink
feat: 更新图标
Browse files Browse the repository at this point in the history
  • Loading branch information
yxw007 committed Mar 6, 2024
1 parent c5fab8b commit 4ae702c
Show file tree
Hide file tree
Showing 19 changed files with 43 additions and 74 deletions.
14 changes: 11 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,24 +33,32 @@ $ yarn build:mac
$ yarn build:linux
```

## Feature
- 截图识别二维码
- 上传识别二维码
- 根据字符生成二维码

## Effect
![](./docs/effect-1.gif)
![截图识别二维码](./docs/截图识别二维码.gif)
![上传识别二维码](./docs/上传识别二维码.gif)
![根据字符生成二维码](./docs/根据字符生成二维码.gif)

## TODO
- [x] 支持多屏截图
- [x] 支持截图识别二维码
- [x] 根据内容生成二维码
- [x] 支持上传图片识别二维码
- [ ] 支持修改快捷键操作
- [x] 支持修改快捷键操作
- [x] 支持自动检测更新
- [x] 更换图标

## 截图实现流程
![](./docs/截图过程.png)


## 使用说明
- 快捷键
- 截图:Ctrl + Alt + C
- 截图:Ctrl + Alt + C (默认快捷键)
- 退出:Esc
- 完成截图:鼠标双击

12 changes: 0 additions & 12 deletions build/entitlements.mac.plist

This file was deleted.

Binary file removed build/icon.icns
Binary file not shown.
Binary file removed build/icon.ico
Binary file not shown.
Binary file removed build/icon.png
Binary file not shown.
44 changes: 0 additions & 44 deletions build/main/main.js

This file was deleted.

6 changes: 0 additions & 6 deletions build/main/preload.js

This file was deleted.

Empty file removed build/main/static/.gitkeep
Empty file.
Binary file removed docs/effect-1.gif
Binary file not shown.
Binary file added docs/上传识别二维码.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/截图识别二维码.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/根据字符生成二维码.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added resources/icon-b.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions resources/icon-b.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified resources/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added resources/qrcode.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion src/main/autoUpdater.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ function run(onMessage) {
const optionIdx = dialog.showMessageBoxSync({
type: 'info',
title: 'Update',
message: '发现新版本,点击确认Ok更新',
message: '发现新版本,点击确认更新',
buttons: ['OK']
})
if (optionIdx == 0) {
Expand Down
8 changes: 7 additions & 1 deletion src/main/index.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import { app, BrowserWindow, screen, globalShortcut, ipcMain } from 'electron'
import { app, BrowserWindow, screen, globalShortcut, ipcMain, Tray, nativeImage } from 'electron'
import { electronApp, optimizer } from '@electron-toolkit/utils'
import log from 'electron-log/main'
import run from './autoUpdater'
import { useMainWin, useCutWin, useShortcutWin } from './window'
import { shortcutKeys, bridgeEvent } from './constant'
import { useStore } from './store'
import appIconB from "../../resources/icon-b.png?asset";

const { createMainWin, showMainWin } = useMainWin()
const { createCutWin } = useCutWin()
Expand Down Expand Up @@ -45,6 +46,11 @@ app.whenReady().then(() => {
ipcMain.on(bridgeEvent.UPDATE_SHORTCUT_KEY, updateShortcutKey);
globalShortcut.register(store.get(shortcutKeys.shortcut_snapshot), enterScreenCut)

//! 创建一个图标托盘
let tray = new Tray(nativeImage.createFromPath(appIconB))
tray.setToolTip("qrcode-tools");
tray.on('click', showMainWin)

app.on('activate', function () {
if (BrowserWindow.getAllWindows().length === 0) {
mainWin = createMainWin()
Expand Down
30 changes: 23 additions & 7 deletions src/main/window.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,22 @@ import {
screen,
desktopCapturer,
globalShortcut,
Menu
Menu,
nativeImage
} from 'electron'
import { is } from '@electron-toolkit/utils'
import log from 'electron-log/main'
import defaultMenu from './appMenu'
import { join } from 'path'
import Logger from './logger'
import { bridgeEvent } from './constant'
import appIcon from "../../resources/icon.png?asset"
import fs from "fs";
import { default as path, dirname, join } from "path"
import { fileURLToPath } from "url"

const __dirname = dirname(fileURLToPath(import.meta.url));
const packagePath = path.join(__dirname, '../../package.json')
const packageData = JSON.parse(fs.readFileSync(packagePath, 'utf-8'))

let logger = new Logger(log, 'main process')

Expand All @@ -25,6 +33,12 @@ function getSize(currentScreen) {
}
}

function preventUpdateWinTitle(win) {
win.on('page-title-updated', function (e) {
e.preventDefault()
});
}

export function useMainWin() {
let mainWindow = null

Expand All @@ -34,13 +48,14 @@ export function useMainWin() {
height: 600,
show: true,
autoHideMenuBar: false,
...(process.platform === 'linux' ? { icon } : {}),
icon: nativeImage.createFromPath(appIcon),
title: packageData.name,
webPreferences: {
preload: join(__dirname, '../preload/index.js'),
sandbox: false
}
})

preventUpdateWinTitle(mainWindow);
const menuTemplate = defaultMenu(app, shell)
const menu = Menu.buildFromTemplate(menuTemplate)
Menu.setApplicationMenu(menu)
Expand Down Expand Up @@ -126,6 +141,7 @@ export function useCutWin() {
simpleFullscreen: true,
alwaysOnTop: false,
parent: parent,
icon: nativeImage.createFromPath(appIcon),
webPreferences: {
preload: join(__dirname, '../preload/index.js'),
nodeIntegration: true,
Expand Down Expand Up @@ -231,12 +247,15 @@ export function useShortcutWin() {
resizable: false,
minimizable: false,
title: '修改快捷键',
icon: nativeImage.createFromPath(appIcon),
webPreferences: {
preload: join(__dirname, '../preload/index.js'),
nodeIntegration: true,
contextIsolation: false
}
})
//! 阻止页面标题名替换窗口标题名
preventUpdateWinTitle(shortcutWin);
if (is.dev && process.env['ELECTRON_RENDERER_URL']) {
let url = process.env['ELECTRON_RENDERER_URL'] + '/#/shortcut'
shortcutWin.loadURL(url)
Expand All @@ -249,9 +268,6 @@ export function useShortcutWin() {
logger.info('openShortcutWin: loadFile=', url)
}
}
shortcutWin.on('ready-to-show', () => {
shortcutWin.show()
})
shortcutWin.on('closed', closeShortcutWin)
}

Expand Down

0 comments on commit 4ae702c

Please sign in to comment.