Skip to content

Commit

Permalink
feat: web service can be hidden
Browse files Browse the repository at this point in the history
  • Loading branch information
1943time committed Sep 23, 2023
1 parent 6205c0a commit e90539e
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 15 deletions.
10 changes: 6 additions & 4 deletions src/main/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ export const isDark = (config?: any) => {
}
return dark
}
const isBoolean = (v: any) => typeof v === 'boolean'

export const registerApi = () => {
listener(store)
Expand Down Expand Up @@ -83,11 +84,12 @@ export const registerApi = () => {
codeTheme: config.codeTheme || 'material-theme-palenight',
editorTextSize: config.editorTextSize || 16,
leadingLevel: config.leadingLevel || 4,
showCharactersCount: typeof config.showCharactersCount === 'boolean' ? config.showCharactersCount : true,
showCharactersCount: isBoolean(config.showCharactersCount) ? config.showCharactersCount : true,
mas: process.mas || false,
headingMarkLine: typeof config.headingMarkLine === 'boolean' ? config.headingMarkLine : true,
dragToSort: typeof config.dragToSort === 'boolean' ? config.dragToSort : true,
autoRebuild: typeof config.autoRebuild === 'boolean' ? config.autoRebuild : true
headingMarkLine: isBoolean(config.headingMarkLine) ? config.headingMarkLine : true,
dragToSort: isBoolean(config.dragToSort) ? config.dragToSort : true,
autoRebuild: isBoolean(config.autoRebuild) ? config.autoRebuild : true,
hideWebService: isBoolean(config.hideWebService) ? config.hideWebService : false
}
})

Expand Down
9 changes: 7 additions & 2 deletions src/renderer/src/components/Nav.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {Update} from './Update'
import {isWindows} from '../utils'
import {Share} from '../share/Share'
import {User} from '../share/User'
import {configStore} from '../store/config'
export const Nav = observer(() => {
const paths = useMemo(() => {
if (!treeStore.openNote) return ['']
Expand Down Expand Up @@ -69,7 +70,9 @@ export const Nav = observer(() => {
</div>
<div className={'flex items-center pr-3 dark:text-gray-400/70 space-x-1 text-gray-500'}>
{/*Network services are relatively private and currently not open source. Please comment on this line of code to run it*/}
<Share/>
{!configStore.config.hideWebService &&
<Share/>
}
<Update/>
<div
className={'flex items-center justify-center p-1 group'}
Expand All @@ -80,7 +83,9 @@ export const Nav = observer(() => {
/>
</div>
{/*Network services are relatively private and currently not open source. Please comment on this line of code to run it*/}
<User/>
{!configStore.config.hideWebService &&
<User/>
}
</div>
</div>
</div>
Expand Down
29 changes: 21 additions & 8 deletions src/renderer/src/components/Set.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ import {observer} from 'mobx-react-lite'
import {Checkbox, Modal, Radio, Select, Slider, Tooltip} from 'antd'
import {CloseOutlined, QuestionCircleOutlined} from '@ant-design/icons'
import {configStore} from '../store/config'
import {useCallback, useEffect} from 'react'
import {ReactNode, useCallback, useEffect} from 'react'
import {action} from 'mobx'

function Help(props: {
text: string
text: string | ReactNode
}) {
return (
<Tooltip title={props.text}>
Expand Down Expand Up @@ -73,26 +73,39 @@ export const Set = observer(() => {
</div>
<div className={'flex justify-between items-center py-3'}>
<div className={'text-sm'}>
Heading Mark Line
<span className={'mr-1'}>Automatic Rebuild</span> <Help text={'When a file or folder is renamed or moved, its related dependent links or image paths will automatically change'}/>
</div>
<div>
<Checkbox checked={configStore.config.headingMarkLine} onChange={e => configStore.setConfig('headingMarkLine', e.target.checked)}/>
<Checkbox checked={configStore.config.autoRebuild} onChange={e => configStore.setConfig('autoRebuild', e.target.checked)}/>
</div>
</div>
<div className={'flex justify-between items-center py-3'}>
<div className={'text-sm'}>
Drag To Sort
<span className={'mr-1'}>Hide Web Services</span> <Help text={(
<>
If you need to share documents with others, web services can share markdown documents online in a minimalist way,
<a className={'link ml-1'} href={'https://pb.bluemd.me/official/book/docs/share'} target={'_blank'}>more</a>.
</>
)}/>
</div>
<div>
<Checkbox checked={configStore.config.dragToSort} onChange={e => configStore.setConfig('dragToSort', e.target.checked)}/>
<Checkbox checked={configStore.config.hideWebService} onChange={e => configStore.setConfig('hideWebService', e.target.checked)}/>
</div>
</div>
<div className={'flex justify-between items-center py-3'}>
<div className={'text-sm'}>
<span className={'mr-1'}>Automatic Rebuild</span> <Help text={'When a file or folder is renamed or moved, its related dependent links or image paths will automatically change'}/>
Heading Mark Line
</div>
<div>
<Checkbox checked={configStore.config.autoRebuild} onChange={e => configStore.setConfig('autoRebuild', e.target.checked)}/>
<Checkbox checked={configStore.config.headingMarkLine} onChange={e => configStore.setConfig('headingMarkLine', e.target.checked)}/>
</div>
</div>
<div className={'flex justify-between items-center py-3'}>
<div className={'text-sm'}>
Drag To Sort
</div>
<div>
<Checkbox checked={configStore.config.dragToSort} onChange={e => configStore.setConfig('dragToSort', e.target.checked)}/>
</div>
</div>
<div className={'flex justify-between items-center py-3'}>
Expand Down
3 changes: 2 additions & 1 deletion src/renderer/src/store/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ class ConfigStore {
mas: false,
dragToSort: true,
spellCheck: false,
autoRebuild: true
autoRebuild: true,
hideWebService: false
}
timer = 0

Expand Down

0 comments on commit e90539e

Please sign in to comment.