mirror of
https://github.com/tiddly-gittly/TidGi-Desktop.git
synced 2025-12-06 02:30:47 -08:00
49 lines
1.7 KiB
JavaScript
49 lines
1.7 KiB
JavaScript
const path = require('path');
|
|
const fs = require('fs-extra');
|
|
const { dialog } = require('electron');
|
|
|
|
const { startWiki } = require('./wiki-worker-mamager');
|
|
const mainWindow = require('../../windows/main');
|
|
const i18n = require('../i18n');
|
|
|
|
module.exports = function startNodeJSWiki(homePath, port, userName, workspaceID) {
|
|
if (!homePath || typeof homePath !== 'string' || !path.isAbsolute(homePath)) {
|
|
const errorMessage = i18n.t('Dialog.NeedCorrectTiddlywikiFolderPath');
|
|
console.error(errorMessage);
|
|
dialog.showMessageBox(mainWindow.get(), {
|
|
title: i18n.t('Dialog.PathPassinCantUse'),
|
|
message: errorMessage + homePath,
|
|
buttons: ['OK'],
|
|
cancelId: 0,
|
|
defaultId: 0,
|
|
});
|
|
return;
|
|
}
|
|
if (!fs.pathExistsSync(homePath)) {
|
|
const errorMessage = i18n.t('Dialog.CantFindWorkspaceFolderRemoveWorkspace');
|
|
console.error(errorMessage);
|
|
dialog
|
|
.showMessageBox(mainWindow.get(), {
|
|
title: i18n.t('Dialog.WorkspaceFolderRemoved'),
|
|
message: errorMessage + homePath,
|
|
buttons: [i18n.t('Dialog.RemoveWorkspace'), i18n.t('Dialog.DontCare')],
|
|
cancelId: 1,
|
|
defaultId: 0,
|
|
})
|
|
.then(({ response }) => {
|
|
// eslint-disable-next-line promise/always-return
|
|
if (response === 0) {
|
|
// eslint-disable-next-line global-require
|
|
const { removeWorkspaceView } = require('../workspaces-views'); // prevent circular dependence
|
|
// eslint-disable-next-line global-require
|
|
const createMenu = require('../create-menu');
|
|
removeWorkspaceView(workspaceID);
|
|
createMenu();
|
|
}
|
|
})
|
|
.catch(console.log);
|
|
return;
|
|
}
|
|
|
|
startWiki(homePath, port, userName);
|
|
};
|