mirror of
https://github.com/tiddly-gittly/TidGi-Desktop.git
synced 2025-12-15 15:10:31 -08:00
feat: adjust sync button to top, since login will clear the form state
This commit is contained in:
parent
1c76e1e88e
commit
cb2428fb70
4 changed files with 65 additions and 54 deletions
|
|
@ -1,5 +1,6 @@
|
|||
const isDev = require('electron-is-dev');
|
||||
const path = require('path');
|
||||
const os = require('os');
|
||||
|
||||
const REACT_PATH = isDev
|
||||
? 'http://localhost:3000'
|
||||
|
|
@ -13,6 +14,7 @@ const ICON_PATH = isDev
|
|||
? path.resolve(__dirname, '..', 'icon.png')
|
||||
: `file://${path.resolve(__dirname, '..', 'icon.png')}`;
|
||||
const CHROME_ERROR_PATH = 'chrome-error://chromewebdata/';
|
||||
const DESKTOP_PATH = path.join(os.homedir(), 'Desktop');
|
||||
|
||||
module.exports = {
|
||||
REACT_PATH,
|
||||
|
|
@ -20,4 +22,5 @@ module.exports = {
|
|||
TIDDLERS_PATH,
|
||||
ICON_PATH,
|
||||
CHROME_ERROR_PATH,
|
||||
DESKTOP_PATH,
|
||||
};
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ const { autoUpdater } = require('electron-updater');
|
|||
|
||||
const { createWiki, createSubWiki } = require('../libs/create-wiki');
|
||||
const startNodeJSWiki = require('../libs/wiki/start-nodejs-wiki');
|
||||
const { ICON_PATH, REACT_PATH } = require('../constants/paths');
|
||||
const { ICON_PATH, REACT_PATH, DESKTOP_PATH } = require('../constants/paths');
|
||||
|
||||
const { getPreference, getPreferences, resetPreferences, setPreference } = require('../libs/preferences');
|
||||
|
||||
|
|
@ -78,6 +78,7 @@ const loadListeners = () => {
|
|||
event.returnValue = {
|
||||
ICON_PATH,
|
||||
REACT_PATH,
|
||||
DESKTOP_PATH,
|
||||
}[name];
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -24,6 +24,7 @@ import {
|
|||
requestCopyWikiTemplate,
|
||||
requestCreateSubWiki,
|
||||
getIconPath,
|
||||
getDesktopPath,
|
||||
getWorkspaces,
|
||||
countWorkspace,
|
||||
} from '../../senders';
|
||||
|
|
@ -40,10 +41,14 @@ const Description = styled(Paper)`
|
|||
const CreateContainer = styled(Paper)`
|
||||
margin-top: 5px;
|
||||
`;
|
||||
const LocationPickerContainer = styled.div`
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
`;
|
||||
const LocationPickerInput = styled(TextField)``;
|
||||
const LocationPickerButton = styled(Button)`
|
||||
white-space: nowrap;
|
||||
width: 100%;
|
||||
width: fit-content;
|
||||
`;
|
||||
|
||||
const SyncContainer = styled(Paper)`
|
||||
|
|
@ -64,7 +69,7 @@ const SoftLinkToMainWikiSelectInputLabel = styled(InputLabel)`
|
|||
|
||||
function AddWorkspace({ wikiCreationMessage, onUpdateForm, onSave, onSetWikiCreationMessage }) {
|
||||
const [isCreateMainWorkspace, isCreateMainWorkspaceSetter] = useState(countWorkspace() === 0);
|
||||
const [parentFolderLocation, parentFolderLocationSetter] = useState('');
|
||||
const [parentFolderLocation, parentFolderLocationSetter] = useState(getDesktopPath());
|
||||
const [wikiFolderLocation, wikiFolderLocationSetter] = useState('');
|
||||
const [wikiPort, wikiPortSetter] = useState(5212 + countWorkspace());
|
||||
|
||||
|
|
@ -104,42 +109,58 @@ function AddWorkspace({ wikiCreationMessage, onUpdateForm, onSave, onSetWikiCrea
|
|||
</Typography>
|
||||
</Description>
|
||||
|
||||
<CreateContainer elevation={2} square>
|
||||
<LocationPickerButton
|
||||
onClick={() => {
|
||||
const { remote } = window.require('electron');
|
||||
// eslint-disable-next-line promise/catch-or-return
|
||||
remote.dialog
|
||||
.showOpenDialog(remote.getCurrentWindow(), {
|
||||
properties: ['openDirectory'],
|
||||
})
|
||||
.then(({ canceled, filePaths }) => {
|
||||
// eslint-disable-next-line promise/always-return
|
||||
if (!canceled && filePaths.length > 0) {
|
||||
parentFolderLocationSetter(filePaths[0]);
|
||||
}
|
||||
});
|
||||
}}
|
||||
variant="contained"
|
||||
color={parentFolderLocation ? 'default' : 'primary'}
|
||||
disableElevation
|
||||
endIcon={<FolderIcon />}
|
||||
>
|
||||
<Typography variant="button" display="inline">
|
||||
选择放置WIKI的父文件夹
|
||||
</Typography>
|
||||
</LocationPickerButton>
|
||||
<LocationPickerInput
|
||||
error={!!wikiCreationMessage}
|
||||
helperText={wikiCreationMessage}
|
||||
fullWidth
|
||||
onChange={event => {
|
||||
parentFolderLocationSetter(event.target.value);
|
||||
onSetWikiCreationMessage('');
|
||||
}}
|
||||
label="知识库的父文件夹"
|
||||
value={parentFolderLocation}
|
||||
<SyncContainer elevation={2} square>
|
||||
<Typography variant="subtitle1" align="center">
|
||||
同步到云端
|
||||
</Typography>
|
||||
<GitHubLogin
|
||||
clientId="7b6e0fc33f4afd71a4bb"
|
||||
clientSecret="6015d1ca4ded86b4778ed39109193ff20c630bdd"
|
||||
redirectUri="http://localhost"
|
||||
scope="repo"
|
||||
onSuccess={response => console.log(response)}
|
||||
onFailure={response => console.log(response)}
|
||||
/>
|
||||
</SyncContainer>
|
||||
|
||||
<CreateContainer elevation={2} square>
|
||||
<LocationPickerContainer>
|
||||
<LocationPickerInput
|
||||
error={!!wikiCreationMessage}
|
||||
helperText={wikiCreationMessage}
|
||||
fullWidth
|
||||
onChange={event => {
|
||||
parentFolderLocationSetter(event.target.value);
|
||||
onSetWikiCreationMessage('');
|
||||
}}
|
||||
label="知识库的父文件夹"
|
||||
value={parentFolderLocation}
|
||||
/>
|
||||
<LocationPickerButton
|
||||
onClick={() => {
|
||||
const { remote } = window.require('electron');
|
||||
// eslint-disable-next-line promise/catch-or-return
|
||||
remote.dialog
|
||||
.showOpenDialog(remote.getCurrentWindow(), {
|
||||
properties: ['openDirectory'],
|
||||
})
|
||||
.then(({ canceled, filePaths }) => {
|
||||
// eslint-disable-next-line promise/always-return
|
||||
if (!canceled && filePaths.length > 0) {
|
||||
parentFolderLocationSetter(filePaths[0]);
|
||||
}
|
||||
});
|
||||
}}
|
||||
variant="outlined"
|
||||
color={parentFolderLocation ? 'default' : 'primary'}
|
||||
disableElevation
|
||||
endIcon={<FolderIcon />}
|
||||
>
|
||||
<Typography variant="button" display="inline">
|
||||
选择
|
||||
</Typography>
|
||||
</LocationPickerButton>
|
||||
</LocationPickerContainer>
|
||||
<LocationPickerInput
|
||||
error={!!wikiCreationMessage}
|
||||
fullWidth
|
||||
|
|
@ -155,8 +176,7 @@ function AddWorkspace({ wikiCreationMessage, onUpdateForm, onSave, onSetWikiCrea
|
|||
onChange={event => {
|
||||
wikiPortSetter(event.target.value);
|
||||
}}
|
||||
label="WIKI服务器端口号"
|
||||
helperText="出现冲突再改,一般默认即可"
|
||||
label="WIKI服务器端口号(出现冲突再改,一般默认即可)"
|
||||
value={wikiPort}
|
||||
/>
|
||||
{!isCreateMainWorkspace && (
|
||||
|
|
@ -196,20 +216,6 @@ function AddWorkspace({ wikiCreationMessage, onUpdateForm, onSave, onSetWikiCrea
|
|||
)}
|
||||
</CreateContainer>
|
||||
|
||||
<SyncContainer elevation={2} square>
|
||||
<Typography variant="subtitle1" align="center">
|
||||
同步到云端
|
||||
</Typography>
|
||||
<GitHubLogin
|
||||
clientId="7b6e0fc33f4afd71a4bb"
|
||||
clientSecret="6015d1ca4ded86b4778ed39109193ff20c630bdd"
|
||||
redirectUri="http://localhost"
|
||||
scope="repo"
|
||||
onSuccess={response => console.log(response)}
|
||||
onFailure={response => console.log(response)}
|
||||
/>
|
||||
</SyncContainer>
|
||||
|
||||
{isCreateMainWorkspace ? (
|
||||
<CloseButton
|
||||
variant="contained"
|
||||
|
|
|
|||
|
|
@ -65,6 +65,7 @@ export const requestWakeUpWorkspace = (id) => ipcRenderer.send('request-wake-up-
|
|||
|
||||
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');
|
||||
|
||||
// Workspace Meta
|
||||
export const getWorkspaceMeta = (id) => ipcRenderer.sendSync('get-workspace-meta', id);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue