mirror of
https://github.com/marktext/marktext.git
synced 2025-05-02 15:21:33 +08:00
Add zoom persistence (#2858)
This commit is contained in:
parent
30ed5af274
commit
0954f70d71
@ -11,6 +11,7 @@ Preferences can be controlled and modified in the settings window or via the `pr
|
||||
| titleBarStyle | String | custom | The title bar style on Linux and Window: `custom` or `native` |
|
||||
| openFilesInNewWindow | Boolean | false | true, false |
|
||||
| openFolderInNewWindow | Boolean | false | true, false |
|
||||
| zoom | Number | 1.0 | The zoom level. Between 0.5 and 2.0 inclusive. |
|
||||
| hideScrollbar | Boolean | false | Whether to hide scrollbars. Optional value: true, false |
|
||||
| wordWrapInToc | Boolean | false | Whether to enable word wrap in TOC. Optional value: true, false |
|
||||
| aidou | Boolean | true | Enable aidou. Optional value: true, false |
|
||||
|
@ -28,6 +28,13 @@
|
||||
"type": "boolean",
|
||||
"default": false
|
||||
},
|
||||
"zoom": {
|
||||
"description": "General--The zoom level. Between 0.5 and 2.0 inclusive.",
|
||||
"type": "number",
|
||||
"minimum": 0.5,
|
||||
"maximum": 2.0,
|
||||
"default": 1.0
|
||||
},
|
||||
"hideScrollbar": {
|
||||
"description": "General--Whether to hide scrollbars.",
|
||||
"type": "boolean",
|
||||
|
@ -54,6 +54,7 @@ import { loadingPageMixins } from '@/mixins'
|
||||
import { mapState } from 'vuex'
|
||||
import bus from '@/bus'
|
||||
import { DEFAULT_STYLE } from '@/config'
|
||||
import { ipcRenderer } from 'electron'
|
||||
|
||||
export default {
|
||||
name: 'marktext',
|
||||
@ -82,6 +83,9 @@ export default {
|
||||
theme: state => state.preferences.theme,
|
||||
textDirection: state => state.preferences.textDirection
|
||||
}),
|
||||
...mapState({
|
||||
zoom: state => state.preferences.zoom
|
||||
}),
|
||||
...mapState({
|
||||
projectTree: state => state.project.projectTree,
|
||||
pathname: state => state.editor.currentFile.pathname,
|
||||
@ -103,6 +107,9 @@ export default {
|
||||
if (value !== oldValue) {
|
||||
addThemeStyle(value)
|
||||
}
|
||||
},
|
||||
zoom: function (zoom) {
|
||||
ipcRenderer.emit('mt::window-zoom', null, zoom)
|
||||
}
|
||||
},
|
||||
created () {
|
||||
|
@ -6,6 +6,47 @@ export const titleBarStyleOptions = [{
|
||||
value: 'native'
|
||||
}]
|
||||
|
||||
export const zoomOptions = [{
|
||||
label: '50.0%',
|
||||
value: 0.5
|
||||
}, {
|
||||
label: '62.5%',
|
||||
value: 0.625
|
||||
}, {
|
||||
label: '75.0%',
|
||||
value: 0.75
|
||||
}, {
|
||||
label: '87.5%',
|
||||
value: 0.875
|
||||
}, {
|
||||
label: '100.0%',
|
||||
value: 1.0
|
||||
}, {
|
||||
label: '112.5%',
|
||||
value: 1.125
|
||||
}, {
|
||||
label: '125.0%',
|
||||
value: 1.25
|
||||
}, {
|
||||
label: '137.5%',
|
||||
value: 1.375
|
||||
}, {
|
||||
label: '150.0%',
|
||||
value: 1.5
|
||||
}, {
|
||||
label: '162.5%',
|
||||
value: 1.625
|
||||
}, {
|
||||
label: '175.0%',
|
||||
value: 1.75
|
||||
}, {
|
||||
label: '187.5%',
|
||||
value: 1.875
|
||||
}, {
|
||||
label: '200.0%',
|
||||
value: 2.0
|
||||
}]
|
||||
|
||||
export const fileSortByOptions = [{
|
||||
label: 'Creation time',
|
||||
value: 'created'
|
||||
|
@ -51,6 +51,12 @@
|
||||
:bool="openFolderInNewWindow"
|
||||
:onChange="value => onSelectChange('openFolderInNewWindow', value)"
|
||||
></bool>
|
||||
<cur-select
|
||||
description="Zoom"
|
||||
:value="zoom"
|
||||
:options="zoomOptions"
|
||||
:onChange="value => onSelectChange('zoom', value)"
|
||||
></cur-select>
|
||||
</template>
|
||||
</compound>
|
||||
|
||||
@ -129,6 +135,7 @@ import { isOsx } from '@/util'
|
||||
|
||||
import {
|
||||
titleBarStyleOptions,
|
||||
zoomOptions,
|
||||
fileSortByOptions,
|
||||
languageOptions
|
||||
} from './config'
|
||||
@ -143,6 +150,7 @@ export default {
|
||||
},
|
||||
data () {
|
||||
this.titleBarStyleOptions = titleBarStyleOptions
|
||||
this.zoomOptions = zoomOptions
|
||||
this.fileSortByOptions = fileSortByOptions
|
||||
this.languageOptions = languageOptions
|
||||
this.isOsx = isOsx
|
||||
@ -156,6 +164,7 @@ export default {
|
||||
defaultDirectoryToOpen: state => state.preferences.defaultDirectoryToOpen,
|
||||
openFilesInNewWindow: state => state.preferences.openFilesInNewWindow,
|
||||
openFolderInNewWindow: state => state.preferences.openFolderInNewWindow,
|
||||
zoom: state => state.preferences.zoom,
|
||||
hideScrollbar: state => state.preferences.hideScrollbar,
|
||||
wordWrapInToc: state => state.preferences.wordWrapInToc,
|
||||
aidou: state => state.preferences.aidou,
|
||||
|
@ -1219,8 +1219,13 @@ const actions = {
|
||||
return ipcRenderer.sendSync('mt::ask-for-image-path')
|
||||
},
|
||||
|
||||
LISTEN_WINDOW_ZOOM () {
|
||||
LISTEN_WINDOW_ZOOM ({ dispatch, rootState }) {
|
||||
ipcRenderer.on('mt::window-zoom', (e, zoomFactor) => {
|
||||
zoomFactor = Number.parseFloat(zoomFactor.toFixed(3)) // prevent float rounding errors
|
||||
const { zoom } = rootState.preferences
|
||||
if (zoom !== zoomFactor) {
|
||||
dispatch('SET_SINGLE_PREFERENCE', { type: 'zoom', value: zoomFactor })
|
||||
}
|
||||
webFrame.setZoomFactor(zoomFactor)
|
||||
})
|
||||
}
|
||||
|
@ -8,6 +8,7 @@ const state = {
|
||||
titleBarStyle: 'custom',
|
||||
openFilesInNewWindow: false,
|
||||
openFolderInNewWindow: false,
|
||||
zoom: 1.0,
|
||||
hideScrollbar: false,
|
||||
wordWrapInToc: false,
|
||||
aidou: true,
|
||||
|
@ -4,6 +4,7 @@
|
||||
"titleBarStyle": "custom",
|
||||
"openFilesInNewWindow": false,
|
||||
"openFolderInNewWindow": false,
|
||||
"zoom": 1.0,
|
||||
"hideScrollbar": false,
|
||||
"wordWrapInToc": false,
|
||||
"aidou": true,
|
||||
|
Loading…
Reference in New Issue
Block a user