Skip to content

Commit

Permalink
🌈 style: application icon
Browse files Browse the repository at this point in the history
🌈 style: electron install config
  • Loading branch information
xing403 committed Oct 18, 2023
1 parent 833016d commit 0a12f31
Show file tree
Hide file tree
Showing 10 changed files with 15 additions and 18 deletions.
2 changes: 1 addition & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="icon" href="/favicon.svg" type="image/svg+xml">
<link rel="icon" href="/favicon.ico">
<title>Schedule</title>
<meta name="description" content="Opinionated Vite Starter Template">
</head>
Expand Down
13 changes: 11 additions & 2 deletions plugins/electron.build.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable no-template-curly-in-string */
/* eslint-disable @typescript-eslint/no-require-imports */
/* eslint-disable @typescript-eslint/no-var-requires */
// Electron production environment
Expand Down Expand Up @@ -43,11 +44,19 @@ export default function ElectronBuildPlugin(): Plugin {
output: path.resolve(process.cwd(), 'release'),
app: path.resolve(process.cwd(), 'dist'),
},
// 安装界面图标
icon: path.relative(process.cwd(), 'dist/256x256.ico'),
target: 'nsis',
files: ['**/*'],
asar: true,
nsis: {
oneClick: false, // 取消一键安装操作
allowToChangeInstallationDirectory: true, // 允许用户自定义安装目录
oneClick: false,
allowToChangeInstallationDirectory: true,
installerHeaderIcon: path.relative(process.cwd(), 'dist/256x256.ico'),
installerIcon: path.relative(process.cwd(), 'dist/256x256.ico'),
uninstallerIcon: path.relative(process.cwd(), 'dist/256x256.ico'),
shortcutName: 'schedule',
artifactName: '${productName} ${version}.${ext}',
},
},
})
Expand Down
Binary file added public/256x256.ico
Binary file not shown.
Binary file added public/256x256.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 public/favicon.ico
Binary file not shown.
Binary file removed public/favicon.jpg
Binary file not shown.
13 changes: 0 additions & 13 deletions public/favicon.svg

This file was deleted.

2 changes: 1 addition & 1 deletion src/composables/application.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export const patform = useStorageAsync<'electron' | 'web'>('patform', userAgent.
export const { isLoading, progress } = useNProgress()
export const loadingToggle = useToggle(isLoading)

export const favicon_path = path.join('favicon.svg')
export const favicon_path = path.join('favicon.ico')

export const menuCollapse = ref(false)
export const menuCollapseToggle = useToggle(menuCollapse)
1 change: 1 addition & 0 deletions src/electron/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ export function createWindow(config?: BrowserWindowConstructorOptions) {
const win = new BrowserWindow({
width: config?.width ?? 1440,
height: config?.height ?? 1200,
icon: path.join(__dirname, '256x256.png'),
...config,
webPreferences: {
sandbox: false,
Expand Down
2 changes: 1 addition & 1 deletion src/electron/tray.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { Menu, Tray, nativeImage } from 'electron'
import { createWindow } from '.'

export function createTray(windowMap: WindowMap) {
const tray = new Tray(nativeImage.createFromPath(path.join(__dirname, 'favicon.jpg')))
const tray = new Tray(nativeImage.createFromPath(path.join(__dirname, '256x256.png')))
const contextMenu = Menu.buildFromTemplate([
{
label: '关于',
Expand Down

0 comments on commit 0a12f31

Please sign in to comment.