mirror of
https://github.com/tiddly-gittly/TidGi-Desktop.git
synced 2025-12-06 02:30:47 -08:00
refactor: move import electron related paths to other file
This commit is contained in:
parent
7dcf983aed
commit
48904d3b5c
6 changed files with 16 additions and 10 deletions
|
|
@ -49,6 +49,7 @@ module.exports = {
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
'unicorn/prefer-node-protocol': 'off',
|
'unicorn/prefer-node-protocol': 'off',
|
||||||
|
'unicorn/prefer-module': 'off',
|
||||||
'@typescript-eslint/no-empty-function': 'off',
|
'@typescript-eslint/no-empty-function': 'off',
|
||||||
'@typescript-eslint/method-signature-style': 'off',
|
'@typescript-eslint/method-signature-style': 'off',
|
||||||
'unicorn/no-array-reduce': 'off',
|
'unicorn/no-array-reduce': 'off',
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,7 @@
|
||||||
import path from 'path';
|
import path from 'path';
|
||||||
|
|
||||||
|
import { sourcePath } from '../../src/constants/paths';
|
||||||
import { developmentSettingFolderName, developmentWikiFolderName } from '../../src/constants/fileNames';
|
import { developmentSettingFolderName, developmentWikiFolderName } from '../../src/constants/fileNames';
|
||||||
|
|
||||||
export const sourcePath = path.resolve(__dirname, '..', '..');
|
|
||||||
|
|
||||||
export const temporarySettingPath = path.resolve(sourcePath, '..', developmentSettingFolderName);
|
export const temporarySettingPath = path.resolve(sourcePath, '..', developmentSettingFolderName);
|
||||||
export const mockWikiPath = path.resolve(sourcePath, '..', developmentWikiFolderName);
|
export const mockWikiPath = path.resolve(sourcePath, '..', developmentWikiFolderName);
|
||||||
|
|
|
||||||
9
src/constants/electronPaths.ts
Normal file
9
src/constants/electronPaths.ts
Normal file
|
|
@ -0,0 +1,9 @@
|
||||||
|
import { app } from 'electron';
|
||||||
|
import path from 'path';
|
||||||
|
import { isDevelopmentOrTest } from './environment';
|
||||||
|
import { developmentSettingFolderName } from './fileNames';
|
||||||
|
import { sourcePath } from './paths';
|
||||||
|
|
||||||
|
export const SETTINGS_FOLDER = isDevelopmentOrTest
|
||||||
|
? path.resolve(sourcePath, '..', developmentSettingFolderName)
|
||||||
|
: path.resolve(app.getPath('userData'), 'settings');
|
||||||
|
|
@ -1,13 +1,12 @@
|
||||||
import { app } from 'electron';
|
|
||||||
import path from 'path';
|
import path from 'path';
|
||||||
import os from 'os';
|
import os from 'os';
|
||||||
import { isDevelopmentOrTest } from './environment';
|
import { isDevelopmentOrTest } from './environment';
|
||||||
import { developmentSettingFolderName, developmentWikiFolderName, localizationFolderName } from './fileNames';
|
import { developmentWikiFolderName, localizationFolderName } from './fileNames';
|
||||||
|
|
||||||
const isMac = process.platform === 'darwin';
|
const isMac = process.platform === 'darwin';
|
||||||
|
|
||||||
/** src folder */
|
/** src folder */
|
||||||
const sourcePath = path.resolve(__dirname, '..');
|
export const sourcePath = path.resolve(__dirname, '..');
|
||||||
export const buildResourcePath = path.resolve(sourcePath, '..', 'build-resources');
|
export const buildResourcePath = path.resolve(sourcePath, '..', 'build-resources');
|
||||||
|
|
||||||
export const REACT_PATH = MAIN_WINDOW_WEBPACK_ENTRY;
|
export const REACT_PATH = MAIN_WINDOW_WEBPACK_ENTRY;
|
||||||
|
|
@ -25,9 +24,6 @@ export const LOG_FOLDER = isDevelopmentOrTest
|
||||||
: isMac
|
: isMac
|
||||||
? path.resolve(process.resourcesPath, '..', 'logs')
|
? path.resolve(process.resourcesPath, '..', 'logs')
|
||||||
: path.resolve(os.homedir(), '.tg-note', 'logs');
|
: path.resolve(os.homedir(), '.tg-note', 'logs');
|
||||||
export const SETTINGS_FOLDER = isDevelopmentOrTest
|
|
||||||
? path.resolve(sourcePath, '..', developmentSettingFolderName)
|
|
||||||
: path.resolve(app.getPath('userData'), 'settings');
|
|
||||||
export const LOCALIZATION_FOLDER = isDevelopmentOrTest
|
export const LOCALIZATION_FOLDER = isDevelopmentOrTest
|
||||||
? path.resolve(sourcePath, '..', localizationFolderName)
|
? path.resolve(sourcePath, '..', localizationFolderName)
|
||||||
: path.resolve(process.resourcesPath, localizationFolderName);
|
: path.resolve(process.resourcesPath, localizationFolderName);
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,7 @@ import { IPreferenceService } from './services/preferences/interface';
|
||||||
import { IWikiService } from './services/wiki/interface';
|
import { IWikiService } from './services/wiki/interface';
|
||||||
import { IWindowService } from './services/windows/interface';
|
import { IWindowService } from './services/windows/interface';
|
||||||
import { IWorkspaceViewService } from './services/workspacesView/interface';
|
import { IWorkspaceViewService } from './services/workspacesView/interface';
|
||||||
import { SETTINGS_FOLDER } from '@/constants/paths';
|
import { SETTINGS_FOLDER } from '@/constants/electronPaths';
|
||||||
|
|
||||||
const gotTheLock = app.requestSingleInstanceLock();
|
const gotTheLock = app.requestSingleInstanceLock();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -7,10 +7,11 @@ import { injectable } from 'inversify';
|
||||||
|
|
||||||
import { IContextService, IContext, IPaths, IConstants } from './interface';
|
import { IContextService, IContext, IPaths, IConstants } from './interface';
|
||||||
import * as paths from '@/constants/paths';
|
import * as paths from '@/constants/paths';
|
||||||
|
import * as electronPaths from '@/constants/electronPaths';
|
||||||
|
|
||||||
@injectable()
|
@injectable()
|
||||||
export class ContextService implements IContextService {
|
export class ContextService implements IContextService {
|
||||||
private readonly pathConstants: IPaths = paths;
|
private readonly pathConstants: IPaths = { ...paths, ...electronPaths };
|
||||||
private readonly constants: IConstants = {
|
private readonly constants: IConstants = {
|
||||||
isDevelopment: isElectronDevelopment,
|
isDevelopment: isElectronDevelopment,
|
||||||
platform: process.platform,
|
platform: process.platform,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue