refactor: move images to buildResources

This commit is contained in:
tiddlygit-test 2020-12-31 22:28:19 +08:00
parent 1b19a62efb
commit f17fefab20
17 changed files with 7 additions and 5 deletions

View file

Before

Width:  |  Height:  |  Size: 5.5 KiB

After

Width:  |  Height:  |  Size: 5.5 KiB

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 4.6 KiB

After

Width:  |  Height:  |  Size: 4.6 KiB

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 12 KiB

After

Width:  |  Height:  |  Size: 12 KiB

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 54 KiB

After

Width:  |  Height:  |  Size: 54 KiB

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 1.6 KiB

After

Width:  |  Height:  |  Size: 1.6 KiB

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 2.3 KiB

After

Width:  |  Height:  |  Size: 2.3 KiB

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 1.6 KiB

After

Width:  |  Height:  |  Size: 1.6 KiB

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 2.3 KiB

After

Width:  |  Height:  |  Size: 2.3 KiB

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 405 B

After

Width:  |  Height:  |  Size: 405 B

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 737 B

After

Width:  |  Height:  |  Size: 737 B

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 1 KiB

After

Width:  |  Height:  |  Size: 1 KiB

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 1.3 KiB

After

Width:  |  Height:  |  Size: 1.3 KiB

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 1.8 KiB

After

Width:  |  Height:  |  Size: 1.8 KiB

Before After
Before After

View file

@ -5,13 +5,14 @@ import os from 'os';
const isMac = process.platform === 'darwin';
const sourcePath = path.resolve(__dirname, '..', '..');
export const buildResourcePath = path.resolve(sourcePath, '..', 'build-resources');
// FIXME: change to electron forge path
const REACT_PATH = isDev ? 'http://localhost:3000' : `file://${path.resolve(__dirname, '..', '..', 'build', 'index.html')}`;
// .app/Contents/Resources/wiki/
const TIDDLYWIKI_TEMPLATE_FOLDER_PATH = isDev ? path.resolve(sourcePath, '..', 'template', 'wiki') : path.resolve(process.resourcesPath, '..', 'wiki');
const TIDDLERS_PATH = 'tiddlers';
const ICON_PATH = isDev ? path.resolve(sourcePath, 'icon.png') : `file://${path.resolve(__dirname, '..', 'icon.png')}`;
const ICON_PATH = isDev ? path.resolve(buildResourcePath, 'icon.png') : `file://${path.resolve(__dirname, '..', 'icon.png')}`;
const CHROME_ERROR_PATH = 'chrome-error://chromewebdata/';
const DESKTOP_PATH = path.join(os.homedir(), 'Desktop');
const LOG_FOLDER = isDev

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.6 KiB

View file

@ -2,6 +2,7 @@
import { BrowserView, BrowserWindow, app, session, shell, dialog, ipcMain } from 'electron';
import path from 'path';
import fsExtra from 'fs-extra';
import { buildResourcePath } from '@/services/constants/paths';
import index18n from './i18n';
import wikiStartup from './wiki/wiki-startup';
import { getPreferences, getPreference } from './preferences';
@ -517,7 +518,7 @@ export const addView = async (browserWindow: any, workspace: any) => {
app.badgeCount = count;
if (process.platform === 'win32') {
if (count > 0) {
browserWindow.setOverlayIcon(path.resolve(__dirname, '..', 'overlay-icon.png'), `You have ${count} new messages.`);
browserWindow.setOverlayIcon(path.resolve(buildResourcePath, 'overlay-icon.png'), `You have ${count} new messages.`);
} else {
browserWindow.setOverlayIcon(null, '');
}

View file

@ -3,7 +3,7 @@ import windowStateKeeper from 'electron-window-state';
import { menubar, Menubar } from 'menubar';
import path from 'path';
import { REACT_PATH, isDev as isDevelopment } from '../constants/paths';
import { REACT_PATH, isDev as isDevelopment, buildResourcePath } from '@/services/constants/paths';
import { getPreference } from '../libs/preferences';
import formatBytes from '../libs/format-bytes';
@ -32,7 +32,7 @@ export const createAsync = async (): Promise<void> =>
// https://github.com/atomery/translatium/issues/164
const tray = new Tray(nativeImage.createEmpty());
// icon template is not supported on Windows & Linux
const iconPath = path.resolve(__dirname, '..', process.platform === 'darwin' ? 'menubarTemplate.png' : 'menubar.png');
const iconPath = path.resolve(buildResourcePath, process.platform === 'darwin' ? 'menubarTemplate.png' : 'menubar.png');
tray.setImage(iconPath);
menuBar = menubar({
@ -159,7 +159,7 @@ export const createAsync = async (): Promise<void> =>
show: false,
// manually set dock icon for AppImage
// Snap icon is set correct already so no need to intervene
icon: process.platform === 'linux' && process.env.SNAP == undefined ? path.resolve(__dirname, '..', 'icon.png') : undefined,
icon: process.platform === 'linux' && process.env.SNAP == undefined ? path.resolve(buildResourcePath, 'icon.png') : undefined,
webPreferences: {
nodeIntegration: false,
enableRemoteModule: true,