mirror of
https://github.com/tiddly-gittly/TidGi-Desktop.git
synced 2025-12-06 10:41:02 -08:00
fix: type errors
This commit is contained in:
parent
d646d3c372
commit
66a1512c6c
24 changed files with 98 additions and 102 deletions
|
|
@ -1,4 +1,7 @@
|
|||
const tsEslintConfig = require('./tsconfig.eslint.json');
|
||||
|
||||
module.exports = {
|
||||
ignorePatterns: tsEslintConfig.exclude,
|
||||
parser: '@typescript-eslint/parser',
|
||||
parserOptions: {
|
||||
project: './tsconfig.eslint.json',
|
||||
|
|
|
|||
1
.vscode/settings.json
vendored
1
.vscode/settings.json
vendored
|
|
@ -10,6 +10,7 @@
|
|||
"submenu",
|
||||
"subwiki",
|
||||
"subwiki's",
|
||||
"tiddlygit",
|
||||
"tiddlywiki's"
|
||||
],
|
||||
"i18n-ally.sourceLanguage": "zh",
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ const InfoContainer = styled.div`
|
|||
padding: 0 12px;
|
||||
`;
|
||||
|
||||
export default function FindInPage(): JSX.Element | null {
|
||||
export default function FindInPage(): JSX.Element | undefined {
|
||||
const [open, openSetter] = useState(false);
|
||||
const [text, textSetter] = useState('');
|
||||
const [activeMatch, activeMatchSetter] = useState(0);
|
||||
|
|
@ -48,9 +48,9 @@ export default function FindInPage(): JSX.Element | null {
|
|||
window.remote.unregisterOpenFindInPage(handleOpenFindInPage);
|
||||
window.remote.unregisterUpdateFindInPageMatches(updateFindInPageMatches);
|
||||
};
|
||||
}, [handleOpenFindInPage]);
|
||||
}, [handleOpenFindInPage, updateFindInPageMatches]);
|
||||
if (!open) {
|
||||
return null;
|
||||
return;
|
||||
}
|
||||
return (
|
||||
<Root>
|
||||
|
|
@ -69,8 +69,8 @@ export default function FindInPage(): JSX.Element | null {
|
|||
placeholder="Find"
|
||||
value={text}
|
||||
margin="dense"
|
||||
onChange={(e) => {
|
||||
const value = e.target.value;
|
||||
onChange={(event: React.ChangeEvent<HTMLInputElement | HTMLTextAreaElement>) => {
|
||||
const value = event.target.value;
|
||||
textSetter(value);
|
||||
if (value.length > 0) {
|
||||
void window.service.window.findInPage(value, true);
|
||||
|
|
|
|||
|
|
@ -41,6 +41,13 @@ export enum ViewChannel {
|
|||
}
|
||||
export enum WikiChannel {
|
||||
name = 'WikiChannel',
|
||||
addTiddler = 'wiki-add-tiddler',
|
||||
addTiddlerDone = 'wiki-add-tiddler-done',
|
||||
getTiddlerText = 'wiki-get-tiddler-text',
|
||||
getTiddlerTextDone = 'wiki-get-tiddler-text-done',
|
||||
syncProgress = 'wiki-sync-progress',
|
||||
openTiddler = 'wiki-open-tiddler',
|
||||
sendActionMessage = 'wiki-send-action-message',
|
||||
}
|
||||
export enum WikiGitWorkspaceChannel {
|
||||
name = 'WikiGitWorkspaceChannel',
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import { useEffect, useState, useCallback, Dispatch } from 'react';
|
||||
import { useEffect, useState, useCallback } from 'react';
|
||||
import { AsyncReturnType } from 'type-fest';
|
||||
import { useDebouncedFn } from 'beautiful-react-hooks';
|
||||
|
||||
|
|
@ -19,6 +19,7 @@ export function usePromiseValue<T, DefaultValueType = T | undefined>(
|
|||
void (async () => {
|
||||
valueSetter(await asyncValue());
|
||||
})();
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, dependency);
|
||||
|
||||
return value;
|
||||
|
|
|
|||
|
|
@ -1,14 +0,0 @@
|
|||
import { ipcRenderer } from 'electron';
|
||||
|
||||
export function loadListeners(store: any): void {
|
||||
ipcRenderer.on('log', (_event: Electron.IpcRendererEvent, message: any) => {
|
||||
if (message) console.log(message); // eslint-disable-line no-console
|
||||
});
|
||||
|
||||
// send back a request with text
|
||||
ipcRenderer.on('request-back-find-in-page', (_event: Electron.IpcRendererEvent, forward: any) => {
|
||||
const { open, text } = store.getState().findInPage;
|
||||
if (!open) return;
|
||||
void window.service.window.findInPage(text, forward);
|
||||
});
|
||||
}
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
/* eslint-disable @typescript-eslint/strict-boolean-expressions */
|
||||
import React from 'react';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { Typography, TextField, FormHelperText, MenuItem } from '@material-ui/core';
|
||||
import { Typography, MenuItem } from '@material-ui/core';
|
||||
import { Folder as FolderIcon } from '@material-ui/icons';
|
||||
|
||||
import {
|
||||
|
|
|
|||
|
|
@ -65,7 +65,7 @@ export function SortableWorkspaceSelector({ index, workspace }: ISortableItemPro
|
|||
});
|
||||
}
|
||||
|
||||
window.remote.popContextMenu(template, { x: event.clientX, y: event.clientY, editFlags: { canCopy: false } });
|
||||
void window.remote.popContextMenu(template, { x: event.clientX, y: event.clientY, editFlags: { canCopy: false } });
|
||||
}}>
|
||||
<WorkspaceSelector
|
||||
active={active}
|
||||
|
|
|
|||
|
|
@ -613,7 +613,7 @@ export default function Preferences(): JSX.Element {
|
|||
await window.service.preference.set('downloadPath', filePaths[0]);
|
||||
}
|
||||
})
|
||||
.catch((error: any) => {
|
||||
.catch((error: Error) => {
|
||||
console.log(error); // eslint-disable-line no-console
|
||||
});
|
||||
}}>
|
||||
|
|
|
|||
|
|
@ -4,12 +4,10 @@ import { useTranslation } from 'react-i18next';
|
|||
import BuildIcon from '@material-ui/icons/Build';
|
||||
import CloudDownloadIcon from '@material-ui/icons/CloudDownload';
|
||||
import CodeIcon from '@material-ui/icons/Code';
|
||||
import ExtensionIcon from '@material-ui/icons/Extension';
|
||||
import LanguageIcon from '@material-ui/icons/Language';
|
||||
import MoreHorizIcon from '@material-ui/icons/MoreHoriz';
|
||||
import NotificationsIcon from '@material-ui/icons/Notifications';
|
||||
import PowerIcon from '@material-ui/icons/Power';
|
||||
import RotateLeftIcon from '@material-ui/icons/RotateLeft';
|
||||
import RouterIcon from '@material-ui/icons/Router';
|
||||
import SecurityIcon from '@material-ui/icons/Security';
|
||||
import StorefrontIcon from '@material-ui/icons/Storefront';
|
||||
|
|
|
|||
|
|
@ -13,14 +13,7 @@ export const remoteMethods = {
|
|||
await service.menu.buildContextMenuAndPopup(ipcSafeMenus, parameters, windowName);
|
||||
return unregister;
|
||||
},
|
||||
getCurrentWindow: async () => {
|
||||
const currentWindow = await service.window.get(windowName);
|
||||
if (currentWindow === undefined) {
|
||||
throw new Error(`currentWindow is undefined when getCurrentWindow() in preload script with windowName: ${windowName}`);
|
||||
}
|
||||
return currentWindow;
|
||||
},
|
||||
closeCurrentWindow: async () => {
|
||||
closeCurrentWindow: async (): Promise<() => void> => {
|
||||
await service.window.close(windowName);
|
||||
},
|
||||
/** call NodeJS.path */
|
||||
|
|
@ -36,11 +29,11 @@ export const remoteMethods = {
|
|||
setVisualZoomLevelLimits: (minimumLevel: number, maximumLevel: number): void => {
|
||||
webFrame.setVisualZoomLevelLimits(minimumLevel, maximumLevel);
|
||||
},
|
||||
registerOpenFindInPage: (handleOpenFindInPage: () => void) => void ipcRenderer.on(WindowChannel.openFindInPage, handleOpenFindInPage),
|
||||
unregisterOpenFindInPage: (handleOpenFindInPage: () => void) => void ipcRenderer.removeListener(WindowChannel.openFindInPage, handleOpenFindInPage),
|
||||
registerUpdateFindInPageMatches: (updateFindInPageMatches: (event: Electron.IpcRendererEvent, activeMatchOrdinal: number, matches: number) => void) =>
|
||||
registerOpenFindInPage: (handleOpenFindInPage: () => void): void => void ipcRenderer.on(WindowChannel.openFindInPage, handleOpenFindInPage),
|
||||
unregisterOpenFindInPage: (handleOpenFindInPage: () => void): void => void ipcRenderer.removeListener(WindowChannel.openFindInPage, handleOpenFindInPage),
|
||||
registerUpdateFindInPageMatches: (updateFindInPageMatches: (event: Electron.IpcRendererEvent, activeMatchOrdinal: number, matches: number) => void): void =>
|
||||
void ipcRenderer.on(ViewChannel.updateFindInPageMatches, updateFindInPageMatches),
|
||||
unregisterUpdateFindInPageMatches: (updateFindInPageMatches: (event: Electron.IpcRendererEvent, activeMatchOrdinal: number, matches: number) => void) =>
|
||||
unregisterUpdateFindInPageMatches: (updateFindInPageMatches: (event: Electron.IpcRendererEvent, activeMatchOrdinal: number, matches: number) => void): void =>
|
||||
void ipcRenderer.removeListener(ViewChannel.updateFindInPageMatches, updateFindInPageMatches),
|
||||
};
|
||||
contextBridge.exposeInMainWorld('remote', remoteMethods);
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
/* eslint-disable @typescript-eslint/no-misused-promises */
|
||||
import { webFrame } from 'electron';
|
||||
import { WorkspaceChannel } from '@/constants/channels';
|
||||
import { WorkspaceChannel, Channels } from '@/constants/channels';
|
||||
import './wiki-operation';
|
||||
import { preference, workspace, workspaceView, menu } from './common/services';
|
||||
import { IPossibleWindowMeta, WindowMeta, WindowNames } from '@services/windows/WindowProperties';
|
||||
|
|
@ -25,15 +25,13 @@ document.addEventListener('DOMContentLoaded', () => handleLoaded('document.on("D
|
|||
// DOMContentLoaded might not be triggered so double check with 'onload'
|
||||
// https://github.com/atomery/webcatalog/issues/797
|
||||
window.addEventListener('load', () => handleLoaded('window.on("onload")'));
|
||||
window.addEventListener('message', (event) => {
|
||||
if (!event.data) {
|
||||
return;
|
||||
}
|
||||
window.addEventListener('message', async (event?: MessageEvent<{ type?: Channels; workspaceID?: string } | undefined>) => {
|
||||
// set workspace to active when its notification is clicked
|
||||
if (event.data.type === WorkspaceChannel.focusWorkspace) {
|
||||
if (event?.data?.type === WorkspaceChannel.focusWorkspace) {
|
||||
const id = event.data.workspaceID;
|
||||
if (workspace.get(id) !== undefined) {
|
||||
void workspaceView.setActiveWorkspaceView(id).then(async () => await menu.buildMenu());
|
||||
if (id !== undefined && (await workspace.get(id)) !== undefined) {
|
||||
await workspaceView.setActiveWorkspaceView(id);
|
||||
await menu.buildMenu();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
|
|||
|
|
@ -1,43 +1,45 @@
|
|||
/* eslint-disable @typescript-eslint/no-misused-promises */
|
||||
/**
|
||||
* Call tiddlywiki api from electron
|
||||
* This file should be required by view.ts preload script to work
|
||||
*/
|
||||
import { ipcRenderer, webFrame } from 'electron';
|
||||
import Promise from 'bluebird';
|
||||
import { delay } from 'bluebird';
|
||||
import { WikiChannel } from '@/constants/channels';
|
||||
|
||||
// add tiddler
|
||||
ipcRenderer.on('wiki-add-tiddler', async (event, title, text, meta) => {
|
||||
ipcRenderer.on(WikiChannel.addTiddler, async (event, title: string, text: string, meta: unknown) => {
|
||||
const extraMeta = typeof meta === 'object' ? JSON.stringify(meta) : '{}';
|
||||
await webFrame.executeJavaScript(`
|
||||
$tw.wiki.addTiddler({ title: '${title}', text: '${text}', ...${extraMeta} });
|
||||
`);
|
||||
// wait for fs to be settle
|
||||
await (Promise as any).delay(1000);
|
||||
ipcRenderer.invoke('wiki-add-tiddler-done');
|
||||
await delay(1000);
|
||||
await ipcRenderer.invoke(WikiChannel.addTiddlerDone);
|
||||
});
|
||||
// get tiddler text
|
||||
ipcRenderer.on('wiki-get-tiddler-text', async (event, title) => {
|
||||
const tiddlerText = await webFrame.executeJavaScript(`
|
||||
ipcRenderer.on(WikiChannel.getTiddlerText, async (event, title: string) => {
|
||||
const tiddlerText: string = await (webFrame.executeJavaScript(`
|
||||
$tw.wiki.getTiddlerText('${title}');
|
||||
`);
|
||||
ipcRenderer.invoke('wiki-get-tiddler-text-done', tiddlerText);
|
||||
`) as Promise<string>);
|
||||
await ipcRenderer.invoke(WikiChannel.getTiddlerTextDone, tiddlerText);
|
||||
});
|
||||
// add snackbar to notify user
|
||||
ipcRenderer.on('wiki-sync-progress', (event, message) => {
|
||||
webFrame.executeJavaScript(`
|
||||
$tw.wiki.addTiddler({ title: '$:/state/notification/wiki-sync-progress', text: '${message}' });
|
||||
$tw.notifier.display('$:/state/notification/wiki-sync-progress');
|
||||
ipcRenderer.on(WikiChannel.syncProgress, async (event, message: string) => {
|
||||
await webFrame.executeJavaScript(`
|
||||
$tw.wiki.addTiddler({ title: '$:/state/notification/${WikiChannel.syncProgress}', text: '${message}' });
|
||||
$tw.notifier.display('$:/state/notification/${WikiChannel.syncProgress}');
|
||||
`);
|
||||
});
|
||||
// open a tiddler
|
||||
ipcRenderer.on('wiki-open-tiddler', (event, tiddlerName) => {
|
||||
webFrame.executeJavaScript(`
|
||||
ipcRenderer.on(WikiChannel.openTiddler, async (event, tiddlerName: string) => {
|
||||
await webFrame.executeJavaScript(`
|
||||
window.location.href = "http://localhost:5212/#${tiddlerName}";
|
||||
`);
|
||||
});
|
||||
// send an action message
|
||||
ipcRenderer.on('wiki-send-action-message', (event, actionMessage) => {
|
||||
webFrame.executeJavaScript(`
|
||||
ipcRenderer.on(WikiChannel.sendActionMessage, async (event, actionMessage: string) => {
|
||||
await webFrame.executeJavaScript(`
|
||||
$tw.rootWidget.dispatchEvent({ type: "${actionMessage}" });
|
||||
`);
|
||||
});
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@ import i18n from '@services/libs/i18n';
|
|||
import { getModifiedFileList, ModifiedFileList, getRemoteUrl } from './inspect';
|
||||
import { IGitService, IGitUserInfos } from './interface';
|
||||
import { defaultGitInfo } from './defaultGitInfo';
|
||||
import { WikiChannel } from '@/constants/channels';
|
||||
|
||||
@injectable()
|
||||
export class Git implements IGitService {
|
||||
|
|
@ -47,15 +48,15 @@ export class Git implements IGitService {
|
|||
const browserView = await this.viewService.getActiveBrowserView();
|
||||
if (browserView !== undefined) {
|
||||
const tiddlerText = await new Promise((resolve) => {
|
||||
browserView.webContents.send('wiki-get-tiddler-text', '$:/GitHub/Repo');
|
||||
ipcMain.once('wiki-get-tiddler-text-done', (_event, value) => resolve(value));
|
||||
browserView.webContents.send(WikiChannel.getTiddlerText, '$:/GitHub/Repo');
|
||||
ipcMain.once(WikiChannel.getTiddlerTextDone, (_event, value) => resolve(value));
|
||||
});
|
||||
if (tiddlerText !== githubRepoName) {
|
||||
await new Promise<void>((resolve) => {
|
||||
browserView.webContents.send('wiki-add-tiddler', '$:/GitHub/Repo', githubRepoName, {
|
||||
browserView.webContents.send(WikiChannel.addTiddler, '$:/GitHub/Repo', githubRepoName, {
|
||||
type: 'text/vnd.tiddlywiki',
|
||||
});
|
||||
ipcMain.once('wiki-add-tiddler-done', () => resolve());
|
||||
ipcMain.once(WikiChannel.addTiddlerDone, () => resolve());
|
||||
});
|
||||
}
|
||||
return;
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@ export function buildLanguageMenu(): void {
|
|||
lng: language,
|
||||
});
|
||||
});
|
||||
windowService.sendToAllWindows(I18NChannels.changeLanguageRequest, {
|
||||
await windowService.sendToAllWindows(I18NChannels.changeLanguageRequest, {
|
||||
lng: language,
|
||||
});
|
||||
},
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import { ipcMain, IpcMain, IpcMainInvokeEvent } from 'electron';
|
||||
import { ipcMain, IpcMainInvokeEvent } from 'electron';
|
||||
import fs from 'fs-extra';
|
||||
import path from 'path';
|
||||
|
||||
|
|
@ -18,7 +18,7 @@ export function mainBindings(): void {
|
|||
const localeFilePath = path.join(LOCALIZATION_FOLDER, readFileArguments.filename);
|
||||
const windowService = container.get<IWindowService>(serviceIdentifier.Window);
|
||||
fs.readFile(localeFilePath, 'utf8', (error, data) => {
|
||||
windowService.sendToAllWindows(I18NChannels.readFileResponse, {
|
||||
void windowService.sendToAllWindows(I18NChannels.readFileResponse, {
|
||||
key: readFileArguments.key,
|
||||
error,
|
||||
data: typeof data !== 'undefined' && data !== null ? data.toString() : '',
|
||||
|
|
@ -37,7 +37,7 @@ export function mainBindings(): void {
|
|||
return;
|
||||
}
|
||||
fs.writeFile(localeFilePath, JSON.stringify(writeFileArguments.data), (error: Error) => {
|
||||
windowService.sendToAllWindows(I18NChannels.writeFileResponse, {
|
||||
void windowService.sendToAllWindows(I18NChannels.writeFileResponse, {
|
||||
keys: writeFileArguments.keys,
|
||||
error,
|
||||
});
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ import type { IViewService } from '@services/view/interface';
|
|||
import type { IWindowService } from '@services/windows/interface';
|
||||
import serviceIdentifier from '@services/serviceIdentifier';
|
||||
import { WindowNames } from '@services/windows/WindowProperties';
|
||||
import { WikiChannel } from '@/constants/channels';
|
||||
|
||||
const handlers = {
|
||||
createWikiProgress: (message: string) => {
|
||||
|
|
@ -16,7 +17,7 @@ const handlers = {
|
|||
wikiSyncProgress: async (message: string) => {
|
||||
const viewService = container.get<IViewService>(serviceIdentifier.View);
|
||||
const browserView = await viewService.getActiveBrowserView();
|
||||
browserView?.webContents?.send('wiki-sync-progress', message);
|
||||
browserView?.webContents?.send(WikiChannel.syncProgress, message);
|
||||
},
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import { Menu, MenuItemConstructorOptions, shell, WebContents } from 'electron';
|
||||
import { MenuItemConstructorOptions, WebContents } from 'electron';
|
||||
|
||||
import { ProxyPropertyType } from '@/helpers/electron-ipc-proxy/common';
|
||||
import { MenuChannel } from '@/constants/channels';
|
||||
|
|
|
|||
|
|
@ -10,14 +10,12 @@ import type { INotificationService } from '@services/notifications/interface';
|
|||
import { WindowNames } from '@services/windows/WindowProperties';
|
||||
import i18n from '@services/libs/i18n';
|
||||
import { IPreferences, IPreferenceService } from './interface';
|
||||
import { IViewService } from '@services/view/interface';
|
||||
import { defaultPreferences } from './defaultPreferences';
|
||||
import { lazyInject } from '@services/container';
|
||||
|
||||
@injectable()
|
||||
export class Preference implements IPreferenceService {
|
||||
@lazyInject(serviceIdentifier.Window) private readonly windowService!: IWindowService;
|
||||
@lazyInject(serviceIdentifier.View) private readonly viewService!: IViewService;
|
||||
@lazyInject(serviceIdentifier.NotificationService) private readonly notificationService!: INotificationService;
|
||||
|
||||
private cachedPreferences: IPreferences;
|
||||
|
|
@ -82,6 +80,7 @@ export class Preference implements IPreferenceService {
|
|||
this.cachedPreferences[key] = value;
|
||||
this.cachedPreferences = { ...this.cachedPreferences, ...this.sanitizePreference(this.cachedPreferences) };
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
await settings.set(`preferences.${key}`, this.cachedPreferences[key] as any);
|
||||
|
||||
this.reactWhenPreferencesChanged(key, value);
|
||||
|
|
@ -107,6 +106,7 @@ export class Preference implements IPreferenceService {
|
|||
*/
|
||||
private async setPreferences(newPreferences: IPreferences): Promise<void> {
|
||||
this.cachedPreferences = newPreferences;
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
await settings.set(`preferences`, { ...newPreferences } as any);
|
||||
this.updatePreferenceSubject();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
/* eslint-disable @typescript-eslint/no-misused-promises */
|
||||
/* eslint-disable @typescript-eslint/consistent-type-assertions */
|
||||
import { app, dialog, shell } from 'electron';
|
||||
import { injectable } from 'inversify';
|
||||
|
|
@ -162,38 +163,34 @@ export class Updater implements IUpdaterService {
|
|||
info: progressObject,
|
||||
});
|
||||
});
|
||||
autoUpdater.on('update-downloaded', (info: UpdateInfo) => {
|
||||
autoUpdater.on('update-downloaded', async (info: UpdateInfo) => {
|
||||
const mainWindow = this.windowService.get(WindowNames.main);
|
||||
if (mainWindow !== undefined) {
|
||||
this.setMetaData({
|
||||
status: 'update-downloaded',
|
||||
info,
|
||||
});
|
||||
dialog
|
||||
.showMessageBox(mainWindow, {
|
||||
const { response } = await dialog.showMessageBox(mainWindow, {
|
||||
type: 'info',
|
||||
buttons: ['Restart', 'Later'],
|
||||
title: 'Application Update',
|
||||
message: `A new version (${info.version}) has been downloaded. Restart the application to apply the updates.`,
|
||||
cancelId: 1,
|
||||
})
|
||||
.then(({ response }) => {
|
||||
});
|
||||
if (response === 0) {
|
||||
// Fix autoUpdater.quitAndInstall() does not quit immediately
|
||||
// https://github.com/electron/electron/issues/3583
|
||||
// https://github.com/electron-userland/electron-builder/issues/1604
|
||||
setImmediate(() => {
|
||||
setImmediate(async () => {
|
||||
app.removeAllListeners(MainChannel.windowAllClosed);
|
||||
const mainWindow = this.windowService.get(WindowNames.main);
|
||||
if (mainWindow !== undefined) {
|
||||
this.windowService.updateWindowMeta(WindowNames.main, { forceClose: true });
|
||||
await this.windowService.updateWindowMeta(WindowNames.main, { forceClose: true });
|
||||
mainWindow.close();
|
||||
}
|
||||
autoUpdater.quitAndInstall(false);
|
||||
});
|
||||
}
|
||||
})
|
||||
.catch(console.log);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -25,6 +25,7 @@ import { lazyInject } from '@services/container';
|
|||
import { TIDDLYWIKI_TEMPLATE_FOLDER_PATH, TIDDLERS_PATH } from '@/constants/paths';
|
||||
import { updateSubWikiPluginContent, getSubWikiPluginContent, ISubWikiPluginContent } from './update-plugin-content';
|
||||
import { IWikiService } from './interface';
|
||||
import { WikiChannel } from '@/constants/channels';
|
||||
|
||||
@injectable()
|
||||
export class Wiki implements IWikiService {
|
||||
|
|
@ -42,14 +43,14 @@ export class Wiki implements IWikiService {
|
|||
public async requestOpenTiddlerInWiki(tiddlerName: string): Promise<void> {
|
||||
const browserView = await this.viewService.getActiveBrowserView();
|
||||
if (browserView !== undefined) {
|
||||
browserView.webContents.send('wiki-open-tiddler', tiddlerName);
|
||||
browserView.webContents.send(WikiChannel.openTiddler, tiddlerName);
|
||||
}
|
||||
}
|
||||
|
||||
public async requestWikiSendActionMessage(actionMessage: string): Promise<void> {
|
||||
const browserView = await this.viewService.getActiveBrowserView();
|
||||
if (browserView !== undefined) {
|
||||
browserView.webContents.send('wiki-send-action-message', actionMessage);
|
||||
browserView.webContents.send(WikiChannel.sendActionMessage, actionMessage);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@ export interface IWikiService {
|
|||
stopAllWiki(): Promise<void>;
|
||||
copyWikiTemplate(newFolderPath: string, folderName: string): Promise<string>;
|
||||
getSubWikiPluginContent(mainWikiPath: string): Promise<ISubWikiPluginContent[]>;
|
||||
/** send tiddlywiki action message to current active wiki */
|
||||
requestWikiSendActionMessage(actionMessage: string): Promise<void>;
|
||||
requestOpenTiddlerInWiki(tiddlerName: string): Promise<void>;
|
||||
linkWiki(mainWikiPath: string, folderName: string, subWikiPath: string): Promise<void>;
|
||||
|
|
|
|||
|
|
@ -1,3 +1,9 @@
|
|||
/* eslint-disable @typescript-eslint/no-misused-promises */
|
||||
/* eslint-disable @typescript-eslint/restrict-template-expressions */
|
||||
/* eslint-disable @typescript-eslint/no-unsafe-call */
|
||||
/* eslint-disable @typescript-eslint/no-unsafe-member-access */
|
||||
/* eslint-disable @typescript-eslint/no-var-requires */
|
||||
/* eslint-disable @typescript-eslint/no-unsafe-assignment */
|
||||
const { workerData, parentPort, isMainThread } = require('worker_threads');
|
||||
const path = require('path');
|
||||
const $tw = require('@tiddlygit/tiddlywiki').TiddlyWiki();
|
||||
|
|
@ -29,7 +35,7 @@ module.exports = startNodeJSWiki;
|
|||
|
||||
if (!isMainThread) {
|
||||
startNodeJSWiki();
|
||||
parentPort.once('message', async (message) => {
|
||||
parentPort.once('message', (message) => {
|
||||
if (typeof message === 'object' && message.type === 'command' && message.message === 'exit') {
|
||||
process.exit(0);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,5 +19,5 @@
|
|||
"./*.json",
|
||||
"./*.js"
|
||||
],
|
||||
"exclude": ["template/**/*.js", "src/services/libs/i18n/i18next-electron-fs-backend.ts"]
|
||||
"exclude": ["template/**/*.js", "src/services/libs/i18n/i18next-electron-fs-backend.ts", "src/services/wiki/wiki-worker.js"]
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue