mirror of
https://github.com/marktext/marktext.git
synced 2025-05-04 03:51:01 +08:00
Added 'Mark Text' menu for Linux and Windows (#59)
* Add 'Mark Text' menu for Linux and Windows * Add about dialog for linux and windows
This commit is contained in:
parent
79cbc0d1ab
commit
e3340e14a2
3
src/main/actions/help.js
Normal file
3
src/main/actions/help.js
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
export const showAboutDialog = win => {
|
||||||
|
win.webContents.send('AGANI::about-dialog')
|
||||||
|
}
|
@ -24,7 +24,7 @@ const onReady = () => {
|
|||||||
} else {
|
} else {
|
||||||
createWindow()
|
createWindow()
|
||||||
}
|
}
|
||||||
const menu = Menu.buildFromTemplate(configureMenu({ app }))
|
const menu = Menu.buildFromTemplate(configureMenu)
|
||||||
Menu.setApplicationMenu(menu)
|
Menu.setApplicationMenu(menu)
|
||||||
if (process.platform === 'darwin') {
|
if (process.platform === 'darwin') {
|
||||||
// app.dock is only for macosx
|
// app.dock is only for macosx
|
||||||
|
@ -1,7 +1,10 @@
|
|||||||
|
import { app } from 'electron'
|
||||||
import * as actions from '../actions/file'
|
import * as actions from '../actions/file'
|
||||||
|
import { userSetting } from '../actions/marktext'
|
||||||
import userPreference from '../preference'
|
import userPreference from '../preference'
|
||||||
|
|
||||||
const { autoSave } = userPreference.getAll()
|
const { autoSave } = userPreference.getAll()
|
||||||
|
const notOsx = process.platform !== 'darwin'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
label: 'File',
|
label: 'File',
|
||||||
@ -70,5 +73,23 @@ export default {
|
|||||||
click (menuItem, browserWindow) {
|
click (menuItem, browserWindow) {
|
||||||
actions.print(browserWindow)
|
actions.print(browserWindow)
|
||||||
}
|
}
|
||||||
|
}, {
|
||||||
|
type: 'separator',
|
||||||
|
visible: notOsx
|
||||||
|
}, {
|
||||||
|
label: 'Preferences',
|
||||||
|
accelerator: 'Ctrl+,',
|
||||||
|
visible: notOsx,
|
||||||
|
click (menuItem, browserWindow) {
|
||||||
|
userSetting(menuItem, browserWindow)
|
||||||
|
}
|
||||||
|
}, {
|
||||||
|
type: 'separator',
|
||||||
|
visible: notOsx
|
||||||
|
}, {
|
||||||
|
label: 'Quit',
|
||||||
|
accelerator: 'Ctrl+Q',
|
||||||
|
visible: notOsx,
|
||||||
|
click: app.quit
|
||||||
}]
|
}]
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,8 @@
|
|||||||
import { shell } from 'electron'
|
import { shell } from 'electron'
|
||||||
|
import * as actions from '../actions/help'
|
||||||
|
import { checkUpdates } from '../actions/marktext'
|
||||||
|
|
||||||
|
const notOsx = process.platform !== 'darwin'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
label: 'Help',
|
label: 'Help',
|
||||||
@ -35,5 +39,23 @@ export default {
|
|||||||
click: function () {
|
click: function () {
|
||||||
shell.openExternal('https://github.com/Jocs')
|
shell.openExternal('https://github.com/Jocs')
|
||||||
}
|
}
|
||||||
|
}, {
|
||||||
|
type: 'separator',
|
||||||
|
visible: notOsx
|
||||||
|
}, {
|
||||||
|
label: 'Check for updates...',
|
||||||
|
visible: notOsx,
|
||||||
|
click (menuItem, browserWindow) {
|
||||||
|
checkUpdates(menuItem, browserWindow)
|
||||||
|
}
|
||||||
|
}, {
|
||||||
|
type: 'separator',
|
||||||
|
visible: notOsx
|
||||||
|
}, {
|
||||||
|
label: 'About Mark Text',
|
||||||
|
visible: notOsx,
|
||||||
|
click (menuItem, browserWindow) {
|
||||||
|
actions.showAboutDialog(browserWindow)
|
||||||
|
}
|
||||||
}]
|
}]
|
||||||
}
|
}
|
||||||
|
@ -10,11 +10,8 @@ import theme from './theme'
|
|||||||
|
|
||||||
export dockMenu from './dock'
|
export dockMenu from './dock'
|
||||||
|
|
||||||
export default function configureMenu ({ app }) {
|
export default [
|
||||||
let template = process.platform === 'darwin' ? [marktext({ app })] : []
|
...(process.platform === 'darwin' ? [marktext] : []),
|
||||||
|
|
||||||
return [
|
|
||||||
...template,
|
|
||||||
file,
|
file,
|
||||||
edit,
|
edit,
|
||||||
paragraph,
|
paragraph,
|
||||||
@ -23,5 +20,4 @@ export default function configureMenu ({ app }) {
|
|||||||
theme,
|
theme,
|
||||||
view,
|
view,
|
||||||
help
|
help
|
||||||
]
|
]
|
||||||
}
|
|
||||||
|
@ -1,11 +1,14 @@
|
|||||||
|
import { app } from 'electron'
|
||||||
|
import { showAboutDialog } from '../actions/help'
|
||||||
import * as actions from '../actions/marktext'
|
import * as actions from '../actions/marktext'
|
||||||
|
|
||||||
export default function markTextMenu ({ app }) {
|
export default {
|
||||||
return {
|
|
||||||
label: 'Mark Text',
|
label: 'Mark Text',
|
||||||
submenu: [{
|
submenu: [{
|
||||||
label: 'About Mark Text',
|
label: 'About Mark Text',
|
||||||
role: 'about'
|
click (menuItem, browserWindow) {
|
||||||
|
showAboutDialog(browserWindow)
|
||||||
|
}
|
||||||
}, {
|
}, {
|
||||||
label: 'Check for updates...',
|
label: 'Check for updates...',
|
||||||
click (menuItem, browserWindow) {
|
click (menuItem, browserWindow) {
|
||||||
@ -43,5 +46,4 @@ export default function markTextMenu ({ app }) {
|
|||||||
accelerator: 'Command+Q',
|
accelerator: 'Command+Q',
|
||||||
click: app.quit
|
click: app.quit
|
||||||
}]
|
}]
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -31,6 +31,7 @@
|
|||||||
></bottom-bar>
|
></bottom-bar>
|
||||||
<aidou></aidou>
|
<aidou></aidou>
|
||||||
<upload-image></upload-image>
|
<upload-image></upload-image>
|
||||||
|
<about-dialog></about-dialog>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
@ -41,6 +42,7 @@
|
|||||||
import SourceCode from '@/components/sourceCode'
|
import SourceCode from '@/components/sourceCode'
|
||||||
import Aidou from '@/components/aidou/aidou'
|
import Aidou from '@/components/aidou/aidou'
|
||||||
import UploadImage from '@/components/uploadImage'
|
import UploadImage from '@/components/uploadImage'
|
||||||
|
import AboutDialog from '@/components/about'
|
||||||
import { mapState } from 'vuex'
|
import { mapState } from 'vuex'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
@ -51,7 +53,8 @@
|
|||||||
TitleBar,
|
TitleBar,
|
||||||
BottomBar,
|
BottomBar,
|
||||||
SourceCode,
|
SourceCode,
|
||||||
UploadImage
|
UploadImage,
|
||||||
|
AboutDialog
|
||||||
},
|
},
|
||||||
data () {
|
data () {
|
||||||
return {}
|
return {}
|
||||||
@ -82,6 +85,7 @@
|
|||||||
dispatch('LISTEN_FOR_PARAGRAPH_INLINE_STYLE')
|
dispatch('LISTEN_FOR_PARAGRAPH_INLINE_STYLE')
|
||||||
dispatch('LISTEN_FOR_UPDATE')
|
dispatch('LISTEN_FOR_UPDATE')
|
||||||
dispatch('LISTEN_FOR_INSERT_IMAGE')
|
dispatch('LISTEN_FOR_INSERT_IMAGE')
|
||||||
|
dispatch('LISTEN_FOR_ABOUT_DIALOG')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
BIN
src/renderer/assets/images/logo.png
Normal file
BIN
src/renderer/assets/images/logo.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 6.5 KiB |
72
src/renderer/components/about/index.vue
Normal file
72
src/renderer/components/about/index.vue
Normal file
@ -0,0 +1,72 @@
|
|||||||
|
<template>
|
||||||
|
<div class="about-dialog" :class="theme">
|
||||||
|
<el-dialog
|
||||||
|
:visible.sync="showAboutDialog"
|
||||||
|
:show-close="false"
|
||||||
|
:modal="true"
|
||||||
|
custom-class="ag-dialog-table"
|
||||||
|
width="400px"
|
||||||
|
>
|
||||||
|
<img class="logo" src="../../assets/images/logo.png" />
|
||||||
|
<el-row>
|
||||||
|
<el-col :span="24">
|
||||||
|
<h3 class="text fg-color-dark">{{ name }}</h3>
|
||||||
|
</el-col>
|
||||||
|
<el-col :span="24">
|
||||||
|
<div class="text">{{ versionPrefix }}{{ appVersion }}</div>
|
||||||
|
</el-col>
|
||||||
|
<el-col :span="24">
|
||||||
|
<div class="text">Copyright © 2018 Jocs</div>
|
||||||
|
</el-col>
|
||||||
|
</el-row>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
import { mapState } from 'vuex'
|
||||||
|
import bus from '../../bus'
|
||||||
|
|
||||||
|
export default {
|
||||||
|
data () {
|
||||||
|
return {
|
||||||
|
showAboutDialog: false,
|
||||||
|
name: 'Mark Text',
|
||||||
|
versionPrefix: 'v'
|
||||||
|
}
|
||||||
|
},
|
||||||
|
computed: {
|
||||||
|
...mapState([
|
||||||
|
'appVersion',
|
||||||
|
'theme'
|
||||||
|
])
|
||||||
|
},
|
||||||
|
created () {
|
||||||
|
bus.$on('aboutDialog', this.showDialog)
|
||||||
|
},
|
||||||
|
beforeDestroy () {
|
||||||
|
bus.$off('aboutDialog', this.showDialog)
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
showDialog () {
|
||||||
|
this.showAboutDialog = true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style>
|
||||||
|
.about-dialog el-row,
|
||||||
|
.about-dialog el-col {
|
||||||
|
display: block;
|
||||||
|
}
|
||||||
|
|
||||||
|
.about-dialog .logo {
|
||||||
|
display: inherit;
|
||||||
|
margin: 0 auto;
|
||||||
|
}
|
||||||
|
|
||||||
|
.about-dialog .text {
|
||||||
|
text-align: center;
|
||||||
|
min-height: 32px;
|
||||||
|
}
|
||||||
|
</style>
|
@ -237,6 +237,12 @@ const actions = {
|
|||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
|
||||||
|
LISTEN_FOR_ABOUT_DIALOG ({ commit }) {
|
||||||
|
ipcRenderer.on('AGANI::about-dialog', e => {
|
||||||
|
bus.$emit('aboutDialog')
|
||||||
|
})
|
||||||
|
},
|
||||||
|
|
||||||
LISTEN_FOR_PARAGRAPH_INLINE_STYLE ({ commit }) {
|
LISTEN_FOR_PARAGRAPH_INLINE_STYLE ({ commit }) {
|
||||||
ipcRenderer.on('AGANI::paragraph', (e, { type }) => {
|
ipcRenderer.on('AGANI::paragraph', (e, { type }) => {
|
||||||
bus.$emit('paragraph', type)
|
bus.$emit('paragraph', type)
|
||||||
|
@ -4,13 +4,15 @@ import Vuex from 'vuex'
|
|||||||
import editorStore from './editor'
|
import editorStore from './editor'
|
||||||
import aidouStore from './aidou'
|
import aidouStore from './aidou'
|
||||||
import autoUpdates from './autoUpdates'
|
import autoUpdates from './autoUpdates'
|
||||||
|
import version from './version'
|
||||||
|
|
||||||
Vue.use(Vuex)
|
Vue.use(Vuex)
|
||||||
|
|
||||||
const storeArray = [
|
const storeArray = [
|
||||||
editorStore,
|
editorStore,
|
||||||
aidouStore,
|
aidouStore,
|
||||||
autoUpdates
|
autoUpdates,
|
||||||
|
version
|
||||||
]
|
]
|
||||||
|
|
||||||
const { actions, mutations, state } = storeArray.reduce((acc, s) => {
|
const { actions, mutations, state } = storeArray.reduce((acc, s) => {
|
||||||
|
13
src/renderer/store/version.js
Normal file
13
src/renderer/store/version.js
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
import { remote } from 'electron'
|
||||||
|
|
||||||
|
const state = {
|
||||||
|
appVersion: remote.app.getVersion()
|
||||||
|
}
|
||||||
|
|
||||||
|
const mutations = {
|
||||||
|
}
|
||||||
|
|
||||||
|
const actions = {
|
||||||
|
}
|
||||||
|
|
||||||
|
export default { state, mutations, actions }
|
@ -363,3 +363,7 @@ code {
|
|||||||
color: #777777;
|
color: #777777;
|
||||||
margin-top: 0;
|
margin-top: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.fg-color-dark {
|
||||||
|
color: #c6c6c6;
|
||||||
|
}
|
||||||
|
@ -336,3 +336,7 @@ code {
|
|||||||
color: #777777;
|
color: #777777;
|
||||||
margin-top: 0;
|
margin-top: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.fg-color-dark {
|
||||||
|
color: #303133;
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user