mirror of
https://github.com/tiddly-gittly/TidGi-Desktop.git
synced 2026-02-16 21:21:37 -08:00
feat: open log folder from error page
This commit is contained in:
parent
54aa9cb7d9
commit
d0dc4e90af
8 changed files with 51 additions and 30 deletions
|
|
@ -15,6 +15,9 @@ const ICON_PATH = isDev
|
|||
: `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
|
||||
? path.resolve(__dirname, '..', '..', 'logs')
|
||||
: path.resolve(process.resourcesPath, '..', 'logs');
|
||||
|
||||
module.exports = {
|
||||
REACT_PATH,
|
||||
|
|
@ -23,4 +26,5 @@ module.exports = {
|
|||
ICON_PATH,
|
||||
CHROME_ERROR_PATH,
|
||||
DESKTOP_PATH,
|
||||
LOG_FOLDER,
|
||||
};
|
||||
|
|
|
|||
|
|
@ -1,13 +1,8 @@
|
|||
const isDev = require('electron-is-dev');
|
||||
const path = require('path');
|
||||
|
||||
const winston = require('winston');
|
||||
require('winston-daily-rotate-file');
|
||||
const RendererTransport = require('./renderer-transport');
|
||||
|
||||
const dirname = isDev
|
||||
? path.resolve(__dirname, '..', '..', '..', 'logs')
|
||||
: path.resolve(process.resourcesPath, '..', 'logs');
|
||||
const { LOG_FOLDER } = require('../../constants/paths');
|
||||
const RendererTransport = require('./renderer-transport');
|
||||
|
||||
const logger = winston.createLogger({
|
||||
levels: winston.config.syslog.levels,
|
||||
|
|
@ -18,7 +13,7 @@ const logger = winston.createLogger({
|
|||
zippedArchive: false,
|
||||
maxSize: '20mb',
|
||||
maxFiles: '14d',
|
||||
dirname,
|
||||
dirname: LOG_FOLDER,
|
||||
}),
|
||||
new RendererTransport(),
|
||||
],
|
||||
|
|
@ -29,7 +24,7 @@ const logger = winston.createLogger({
|
|||
zippedArchive: false,
|
||||
maxSize: '20mb',
|
||||
maxFiles: '14d',
|
||||
dirname,
|
||||
dirname: LOG_FOLDER,
|
||||
}),
|
||||
],
|
||||
});
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ const path = require('path');
|
|||
const $tw = require('tiddlywiki').TiddlyWiki();
|
||||
|
||||
async function startNodeJSWiki() {
|
||||
const { homePath, userName, tiddlyWikiPort = 5112 } = workerData;
|
||||
const { homePath, tiddlyWikiPort = 5112 } = workerData;
|
||||
const bobServerConfigFolderPath = path.join(homePath, 'settings');
|
||||
const bobServerConfigPath = path.join(bobServerConfigFolderPath, 'settings.json');
|
||||
try {
|
||||
|
|
@ -15,7 +15,7 @@ async function startNodeJSWiki() {
|
|||
.catch(() => false)
|
||||
) {
|
||||
await fs.promises.unlink(bobServerConfigPath);
|
||||
await fs.promises.unlink(bobServerConfigFolderPath);
|
||||
await fs.promises.rmdir(bobServerConfigFolderPath);
|
||||
}
|
||||
await fs.promises.mkdir(bobServerConfigFolderPath);
|
||||
} catch (error) {
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ const { stopWatchWiki } = require('../libs/wiki/watch-wiki');
|
|||
const { stopWiki } = require('../libs/wiki/wiki-worker-mamager');
|
||||
const { logger } = require('../libs/log');
|
||||
const { createWiki, createSubWiki, removeWiki, ensureWikiExist } = require('../libs/create-wiki');
|
||||
const { ICON_PATH, REACT_PATH, DESKTOP_PATH } = require('../constants/paths');
|
||||
const { ICON_PATH, REACT_PATH, DESKTOP_PATH, LOG_FOLDER } = require('../constants/paths');
|
||||
|
||||
const { getPreference, getPreferences, resetPreferences, setPreference } = require('../libs/preferences');
|
||||
|
||||
|
|
@ -88,6 +88,7 @@ const loadListeners = () => {
|
|||
ICON_PATH,
|
||||
REACT_PATH,
|
||||
DESKTOP_PATH,
|
||||
LOG_FOLDER,
|
||||
}[name];
|
||||
});
|
||||
ipcMain.handle('request-init-wiki-git', async (event, wikiFolderPath, githubRepoUrl, userInfo, isMainWiki) => {
|
||||
|
|
@ -100,8 +101,12 @@ const loadListeners = () => {
|
|||
}
|
||||
});
|
||||
|
||||
ipcMain.on('request-open', (e, uri) => {
|
||||
shell.openExternal(uri);
|
||||
ipcMain.on('request-open', (_, uri, isDirectory) => {
|
||||
if (isDirectory) {
|
||||
shell.showItemInFolder(uri);
|
||||
} else {
|
||||
shell.openExternal(uri);
|
||||
}
|
||||
});
|
||||
|
||||
// Find In Page
|
||||
|
|
|
|||
|
|
@ -28,6 +28,8 @@ import DraggableRegion from './draggable-region';
|
|||
import arrowWhite from '../../images/arrow-white.png';
|
||||
import arrowBlack from '../../images/arrow-black.png';
|
||||
|
||||
import { requestOpen, getLogFolderPath } from '../../senders';
|
||||
|
||||
import {
|
||||
requestHibernateWorkspace,
|
||||
requestRemoveWorkspace,
|
||||
|
|
@ -41,6 +43,8 @@ import {
|
|||
requestReload,
|
||||
} from '../../senders';
|
||||
|
||||
console.log(getLogFolderPath())
|
||||
|
||||
// https://github.com/sindresorhus/array-move/blob/master/index.js
|
||||
const arrayMove = (array, from, to) => {
|
||||
const newArray = array.slice();
|
||||
|
|
@ -233,13 +237,6 @@ const Main = ({
|
|||
}) => {
|
||||
const workspacesList = getWorkspacesAsList(workspaces);
|
||||
const showTitleBar = window.process.platform === 'darwin' && titleBar && !isFullScreen;
|
||||
console.log('renderer', Date.now());
|
||||
console.warn(`didFailLoad`, JSON.stringify(didFailLoad, null, ' '));
|
||||
console.warn(`isLoading`, JSON.stringify(isLoading, null, ' '));
|
||||
console.warn(
|
||||
`Object.keys(workspaces).length > 0 && didFailLoad && !isLoading`,
|
||||
JSON.stringify(Object.keys(workspaces).length > 0 && didFailLoad && !isLoading, null, ' '),
|
||||
);
|
||||
|
||||
return (
|
||||
<div className={classes.outerRoot}>
|
||||
|
|
@ -273,10 +270,7 @@ const Main = ({
|
|||
<SortableItem key={`item-${workspace.id}`} index={i} value={{ index: i, workspace }} />
|
||||
))}
|
||||
</SortableContainer>
|
||||
<WorkspaceSelector
|
||||
id="add"
|
||||
onClick={() => requestShowAddWorkspaceWindow()}
|
||||
/>
|
||||
<WorkspaceSelector id="add" onClick={() => requestShowAddWorkspaceWindow()} />
|
||||
</div>
|
||||
{!navigationBar && (
|
||||
<div className={classes.end}>
|
||||
|
|
@ -318,8 +312,32 @@ const Main = ({
|
|||
<>
|
||||
Try:
|
||||
<ul className={classes.ul}>
|
||||
<li>Click <b>Reload</b> button below or press <b>CMD_or_Ctrl + R</b> to reload the page.</li>
|
||||
<li>Check the log to see what happened.</li>
|
||||
<li>
|
||||
Click{' '}
|
||||
<b
|
||||
onClick={requestReload}
|
||||
onKeyPress={requestReload}
|
||||
role="button"
|
||||
tabIndex="0"
|
||||
style={{ cursor: 'pointer' }}
|
||||
>
|
||||
Reload
|
||||
</b>{' '}
|
||||
button below or press <b>CMD_or_Ctrl + R</b> to reload the page.
|
||||
</li>
|
||||
<li>
|
||||
Check the{' '}
|
||||
<b
|
||||
onClick={() => requestOpen(getLogFolderPath(), true)}
|
||||
onKeyPress={() => requestOpen(getLogFolderPath(), true)}
|
||||
role="button"
|
||||
tabIndex="0"
|
||||
style={{ cursor: 'pointer' }}
|
||||
>
|
||||
Log Folder
|
||||
</b>{' '}
|
||||
to see what happened.
|
||||
</li>
|
||||
<li>Backup your file, remove workspace and recreate one.</li>
|
||||
</ul>
|
||||
</>
|
||||
|
|
|
|||
|
|
@ -53,7 +53,6 @@ const loadListeners = (store) => {
|
|||
});
|
||||
|
||||
ipcRenderer.on('set-workspace-meta', (e, id, value) => {
|
||||
console.log('set-workspace-meta', Date.now());
|
||||
store.dispatch(setWorkspaceMeta(id, value));
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ export const requestCreateSubWiki = (
|
|||
) => ipcRenderer.invoke('create-sub-wiki', newFolderPath, folderName, mainWikiToLink, onlyLink);
|
||||
export const ensureWikiExist = (wikiPath: string, shouldBeMainWiki: boolean) =>
|
||||
ipcRenderer.invoke('ensure-wiki-exist', wikiPath, shouldBeMainWiki);
|
||||
export const requestOpen = (uri: string) => ipcRenderer.send('request-open', uri);
|
||||
export const requestOpen = (uri: string, isDirectory?: boolean) => ipcRenderer.send('request-open', uri, !!isDirectory);
|
||||
export const requestShowMessageBox = (message: string, type: string) => ipcRenderer.send('request-show-message-box', message, type);
|
||||
export const requestLoadUrl = (url: string, id: string) => ipcRenderer.send('request-load-url', url, id);
|
||||
|
||||
|
|
@ -105,6 +105,7 @@ export const requestWakeUpWorkspace = id => ipcRenderer.send('request-wake-up-wo
|
|||
export const getIconPath = () => ipcRenderer.sendSync('get-constant', 'ICON_PATH');
|
||||
export const getReactPath = () => ipcRenderer.sendSync('get-constant', 'REACT_PATH');
|
||||
export const getDesktopPath = () => ipcRenderer.sendSync('get-constant', 'DESKTOP_PATH');
|
||||
export const getLogFolderPath = () => ipcRenderer.sendSync('get-constant', 'LOG_FOLDER');
|
||||
|
||||
// Workspace Meta
|
||||
export const getWorkspaceMeta = id => ipcRenderer.sendSync('get-workspace-meta', id);
|
||||
|
|
|
|||
|
|
@ -14,7 +14,6 @@ const workspaceMetas = (state = initialState, action) => {
|
|||
|
||||
if (action.value) newState[action.id] = { ...newState[action.id], ...action.value };
|
||||
else delete newState[action.id];
|
||||
console.log('reducer', Date.now());
|
||||
|
||||
return newState;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue