mirror of
https://github.com/tiddly-gittly/TidGi-Desktop.git
synced 2026-03-01 19:40:47 -08:00
feat: remove workspace if folder is removed
This commit is contained in:
parent
cccf5fed30
commit
bf802b58ff
2 changed files with 23 additions and 10 deletions
|
|
@ -137,7 +137,7 @@ const addView = (browserWindow, workspace) => {
|
|||
});
|
||||
}
|
||||
if (!isSubWiki) { // if is main wiki
|
||||
startNodeJSWiki(wikiPath, port, userName);
|
||||
startNodeJSWiki(wikiPath, port, userName, workspace.id);
|
||||
userInfo && watchWiki(wikiPath, githubUrl, userInfo, path.join(wikiPath, TIDDLERS_PATH));
|
||||
} else { // if is private repo wiki
|
||||
userInfo && watchWiki(wikiPath, githubUrl, userInfo);
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ const { dialog } = require('electron');
|
|||
const { startWiki } = require('./wiki-worker-mamager');
|
||||
const mainWindow = require('../../windows/main');
|
||||
|
||||
module.exports = function startNodeJSWiki(homePath, port, userName) {
|
||||
module.exports = function startNodeJSWiki(homePath, port, userName, workspaceID) {
|
||||
if (!homePath || typeof homePath !== 'string' || !path.isAbsolute(homePath)) {
|
||||
const errorMessage = `需要传入正确的路径,而 ${homePath} 无法被 TiddlyWiki 识别。`;
|
||||
console.error(errorMessage);
|
||||
|
|
@ -19,15 +19,28 @@ module.exports = function startNodeJSWiki(homePath, port, userName) {
|
|||
return;
|
||||
}
|
||||
if (!fs.pathExistsSync(homePath)) {
|
||||
const errorMessage = `无法找到之前还在该处的工作区文件夹!本应存在于 ${homePath} 的文件夹可能被移走了!`;
|
||||
const errorMessage = `无法找到之前还在该处的工作区文件夹!本应存在于 ${homePath} 的文件夹可能被移走了!是否移除工作区?`;
|
||||
console.error(errorMessage);
|
||||
dialog.showMessageBox(mainWindow.get(), {
|
||||
title: '工作区文件夹被移走',
|
||||
message: errorMessage,
|
||||
buttons: ['OK'],
|
||||
cancelId: 0,
|
||||
defaultId: 0,
|
||||
});
|
||||
dialog
|
||||
.showMessageBox(mainWindow.get(), {
|
||||
title: '工作区文件夹被移走',
|
||||
message: errorMessage,
|
||||
buttons: ['移除工作区', '不管'],
|
||||
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;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue