diff --git a/src/main/actions/help.js b/src/main/actions/help.js new file mode 100644 index 00000000..88d35fd4 --- /dev/null +++ b/src/main/actions/help.js @@ -0,0 +1,3 @@ +export const showAboutDialog = win => { + win.webContents.send('AGANI::about-dialog') +} diff --git a/src/main/index.js b/src/main/index.js index 0f9a36ea..98e78a1e 100644 --- a/src/main/index.js +++ b/src/main/index.js @@ -24,7 +24,7 @@ const onReady = () => { } else { createWindow() } - const menu = Menu.buildFromTemplate(configureMenu({ app })) + const menu = Menu.buildFromTemplate(configureMenu) Menu.setApplicationMenu(menu) if (process.platform === 'darwin') { // app.dock is only for macosx diff --git a/src/main/menus/file.js b/src/main/menus/file.js index 4e024660..61fe2040 100755 --- a/src/main/menus/file.js +++ b/src/main/menus/file.js @@ -1,7 +1,10 @@ +import { app } from 'electron' import * as actions from '../actions/file' +import { userSetting } from '../actions/marktext' import userPreference from '../preference' const { autoSave } = userPreference.getAll() +const notOsx = process.platform !== 'darwin' export default { label: 'File', @@ -70,5 +73,23 @@ export default { click (menuItem, 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 }] } diff --git a/src/main/menus/help.js b/src/main/menus/help.js index 6fc8f1e9..fa218997 100755 --- a/src/main/menus/help.js +++ b/src/main/menus/help.js @@ -1,4 +1,8 @@ import { shell } from 'electron' +import * as actions from '../actions/help' +import { checkUpdates } from '../actions/marktext' + +const notOsx = process.platform !== 'darwin' export default { label: 'Help', @@ -35,5 +39,23 @@ export default { click: function () { 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) + } }] } diff --git a/src/main/menus/index.js b/src/main/menus/index.js index 1dd0323f..35472bf9 100644 --- a/src/main/menus/index.js +++ b/src/main/menus/index.js @@ -10,18 +10,14 @@ import theme from './theme' export dockMenu from './dock' -export default function configureMenu ({ app }) { - let template = process.platform === 'darwin' ? [marktext({ app })] : [] - - return [ - ...template, - file, - edit, - paragraph, - format, - windowMenu, - theme, - view, - help - ] -} +export default [ + ...(process.platform === 'darwin' ? [marktext] : []), + file, + edit, + paragraph, + format, + windowMenu, + theme, + view, + help +] diff --git a/src/main/menus/marktext.js b/src/main/menus/marktext.js index c58bb961..623fee75 100755 --- a/src/main/menus/marktext.js +++ b/src/main/menus/marktext.js @@ -1,47 +1,49 @@ +import { app } from 'electron' +import { showAboutDialog } from '../actions/help' import * as actions from '../actions/marktext' -export default function markTextMenu ({ app }) { - return { - label: 'Mark Text', - submenu: [{ - label: 'About Mark Text', - role: 'about' - }, { - label: 'Check for updates...', - click (menuItem, browserWindow) { - actions.checkUpdates(menuItem, browserWindow) - } - }, { - label: 'Preferences', - accelerator: 'Cmd+,', - click (menuItem, browserWindow) { - actions.userSetting(menuItem, browserWindow) - } - }, { - type: 'separator' - }, { - label: 'Services', - role: 'services', - submenu: [] - }, { - type: 'separator' - }, { - label: 'Hide Mark Text', - accelerator: 'Command+H', - role: 'hide' - }, { - label: 'Hide Others', - accelerator: 'Command+Alt+H', - role: 'hideothers' - }, { - label: 'Show All', - role: 'unhide' - }, { - type: 'separator' - }, { - label: 'Quit', - accelerator: 'Command+Q', - click: app.quit - }] - } +export default { + label: 'Mark Text', + submenu: [{ + label: 'About Mark Text', + click (menuItem, browserWindow) { + showAboutDialog(browserWindow) + } + }, { + label: 'Check for updates...', + click (menuItem, browserWindow) { + actions.checkUpdates(menuItem, browserWindow) + } + }, { + label: 'Preferences', + accelerator: 'Cmd+,', + click (menuItem, browserWindow) { + actions.userSetting(menuItem, browserWindow) + } + }, { + type: 'separator' + }, { + label: 'Services', + role: 'services', + submenu: [] + }, { + type: 'separator' + }, { + label: 'Hide Mark Text', + accelerator: 'Command+H', + role: 'hide' + }, { + label: 'Hide Others', + accelerator: 'Command+Alt+H', + role: 'hideothers' + }, { + label: 'Show All', + role: 'unhide' + }, { + type: 'separator' + }, { + label: 'Quit', + accelerator: 'Command+Q', + click: app.quit + }] } diff --git a/src/renderer/app.vue b/src/renderer/app.vue index ccf32cea..3969ab5f 100644 --- a/src/renderer/app.vue +++ b/src/renderer/app.vue @@ -31,6 +31,7 @@ > + @@ -41,6 +42,7 @@ import SourceCode from '@/components/sourceCode' import Aidou from '@/components/aidou/aidou' import UploadImage from '@/components/uploadImage' + import AboutDialog from '@/components/about' import { mapState } from 'vuex' export default { @@ -51,7 +53,8 @@ TitleBar, BottomBar, SourceCode, - UploadImage + UploadImage, + AboutDialog }, data () { return {} @@ -82,6 +85,7 @@ dispatch('LISTEN_FOR_PARAGRAPH_INLINE_STYLE') dispatch('LISTEN_FOR_UPDATE') dispatch('LISTEN_FOR_INSERT_IMAGE') + dispatch('LISTEN_FOR_ABOUT_DIALOG') } } diff --git a/src/renderer/assets/images/logo.png b/src/renderer/assets/images/logo.png new file mode 100644 index 00000000..ea250930 Binary files /dev/null and b/src/renderer/assets/images/logo.png differ diff --git a/src/renderer/components/about/index.vue b/src/renderer/components/about/index.vue new file mode 100644 index 00000000..fb54c4a7 --- /dev/null +++ b/src/renderer/components/about/index.vue @@ -0,0 +1,72 @@ + + + + + + + {{ name }} + + + {{ versionPrefix }}{{ appVersion }} + + + Copyright © 2018 Jocs + + + + + + + + diff --git a/src/renderer/store/editor.js b/src/renderer/store/editor.js index 2d555135..cc2b6460 100644 --- a/src/renderer/store/editor.js +++ b/src/renderer/store/editor.js @@ -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 }) { ipcRenderer.on('AGANI::paragraph', (e, { type }) => { bus.$emit('paragraph', type) diff --git a/src/renderer/store/index.js b/src/renderer/store/index.js index c2248984..12d8a4f8 100644 --- a/src/renderer/store/index.js +++ b/src/renderer/store/index.js @@ -4,13 +4,15 @@ import Vuex from 'vuex' import editorStore from './editor' import aidouStore from './aidou' import autoUpdates from './autoUpdates' +import version from './version' Vue.use(Vuex) const storeArray = [ editorStore, aidouStore, - autoUpdates + autoUpdates, + version ] const { actions, mutations, state } = storeArray.reduce((acc, s) => { diff --git a/src/renderer/store/version.js b/src/renderer/store/version.js new file mode 100644 index 00000000..e046c1bc --- /dev/null +++ b/src/renderer/store/version.js @@ -0,0 +1,13 @@ +import { remote } from 'electron' + +const state = { + appVersion: remote.app.getVersion() +} + +const mutations = { +} + +const actions = { +} + +export default { state, mutations, actions } diff --git a/static/themes/dark.css b/static/themes/dark.css index 0c75d21d..4ff9fe5d 100755 --- a/static/themes/dark.css +++ b/static/themes/dark.css @@ -363,3 +363,7 @@ code { color: #777777; margin-top: 0; } + +.fg-color-dark { + color: #c6c6c6; +} diff --git a/static/themes/light.css b/static/themes/light.css index e47712c5..84873b44 100644 --- a/static/themes/light.css +++ b/static/themes/light.css @@ -336,3 +336,7 @@ code { color: #777777; margin-top: 0; } + +.fg-color-dark { + color: #303133; +}