Skip to content

Commit

Permalink
Merge pull request #117 from TankNee/rebuild/fix
Browse files Browse the repository at this point in the history
2.1.2 [fix]  bug fix and add init language support
  • Loading branch information
TankNee authored Jul 7, 2021
2 parents 0e03645 + 0d90d5c commit 7c2a4e9
Show file tree
Hide file tree
Showing 32 changed files with 24,211 additions and 157 deletions.
23,887 changes: 23,842 additions & 45 deletions package-lock.json

Large diffs are not rendered by default.

4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "cn.memocast.app",
"version": "2.1.1",
"version": "2.1.2",
"description": "An Awesome WizNote Desktop Application",
"productName": "Memocast",
"author": "tanknee <[email protected]>",
Expand Down Expand Up @@ -44,6 +44,8 @@
"joplin-turndown-plugin-gfm": "^1.0.12",
"katex": "^0.11.1",
"lodash": "^4.17.21",
"markdown-it": "^8.4.2",
"markdown-it-pangu": "^1.0.2",
"md5": "^2.3.0",
"mermaid": "^8.4.8",
"monaco-editor": "^0.25.2",
Expand Down
1 change: 1 addition & 0 deletions share/channels.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ export default {
checkUpdate: 'check-update',
needUpdate: 'need-update',
quitAndUpdate: 'quit-and-install',
remoteRequest: 'remote-request',
getCacheImage: 'get-cache-image',
saveTempImage: 'save-temp-image',
getLocalFileData: 'get-local-file-data',
Expand Down
5 changes: 5 additions & 0 deletions src-electron/main-process/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { BrowserWindow } from 'electron'
import { checkUpdates, needUpdate, quitAndInstall } from './menu/actions/memocast'
import { cacheNoteImage, saveTempImage, saveBuffer } from './utlis/helper'
import { uploadImagesByWiz } from './utlis/wiz-resource-helper'
import { execRequest } from './service/request'

const { uploadImagesByPicGo } = require('./3rd-part/PicGoUtils')

Expand Down Expand Up @@ -221,5 +222,9 @@ export default {
handleApi('quit-and-install', async (e) => {
quitAndInstall()
}).catch(err => throw err)

handleApi('remote-request', async (e, config) => {
return execRequest(config)
}).catch(err => throw err)
}
}
3 changes: 2 additions & 1 deletion src-electron/main-process/electron-main.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,8 @@ function createWindow () {
nodeIntegration: process.env.QUASAR_NODE_INTEGRATION,
nodeIntegrationInWorker: process.env.QUASAR_NODE_INTEGRATION,
webSecurity: false,
experimentalFeatures: false
experimentalFeatures: false,
enableRemoteModule: true

// More info: /quasar-cli/developing-electron-apps/electron-preload-script
// preload: path.resolve(__dirname, 'electron-preload.js')
Expand Down
6 changes: 4 additions & 2 deletions src-electron/main-process/keyboard/shortcut.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export default class KeyBindings {
// Edit menu
['edit.undo', 'CmdOrCtrl+Z'],
['edit.redo', 'CmdOrCtrl+Shift+Z'],
['edit.save', 'CmdOrCtrl+S'],
// ['edit.save', 'CmdOrCtrl+S'],
['edit.cut', 'CmdOrCtrl+X'],
['edit.copy', 'CmdOrCtrl+C'],
['edit.paste', 'CmdOrCtrl+V'],
Expand Down Expand Up @@ -60,7 +60,9 @@ export default class KeyBindings {
['view.switch-view', 'CmdOrCtrl+Shift+,'],
['view.source-mode', 'CmdOrCtrl+Shift+.'],
['view.lock-mode', 'CmdOrCtrl+Shift+L'],
['view.devtool', 'CmdOrCtrl+Shift+P']
['view.devtool', 'CmdOrCtrl+Shift+P'],
// Note Shortcut
['note.save', 'CmdOrCtrl+S']
])
}

Expand Down
5 changes: 5 additions & 0 deletions src-electron/main-process/menu/actions/note.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export const note = (win, type) => {
if (win && win.webContents) {
win.webContents.send('editor-note-action', { type })
}
}
2 changes: 2 additions & 0 deletions src-electron/main-process/menu/templates/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,13 @@ import paragraph from './paragraph'
import edit from './edit'
import format from './format'
import view from './view'
import note from './note'
import help from './help'

export default function (keybindings) {
return [
...(process.platform === 'darwin' ? [memocast(keybindings)] : []),
note(keybindings),
paragraph(keybindings),
edit(keybindings),
format(keybindings),
Expand Down
32 changes: 32 additions & 0 deletions src-electron/main-process/menu/templates/note.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import * as actions from '../actions/note'

export default function (keybindings) {
return {
id: 'noteMenuItem',
label: '&Note',
submenu: [{
id: 'saveNote',
label: 'Save',
accelerator: keybindings.getAccelerator('note.save'),
click (menuItem, browserWindow) {
actions.note(browserWindow, 'save')
}
}, {
id: 'exportNote',
label: 'Export',
submenu: [{
id: 'exportNoteAsMarkdown',
label: 'Markdown',
click (menuItem, browserWindow) {
actions.note(browserWindow, 'exportNoteAsMarkdown')
}
}, {
id: 'exportNoteAsPNG',
label: 'PNG',
click (menuItem, browserWindow) {
actions.note(browserWindow, 'exportNoteAsPNG')
}
}]
}]
}
}
10 changes: 10 additions & 0 deletions src-electron/main-process/service/request.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import axios from 'axios'

axios.defaults.timeout = 50000 // 响应时间
const baseUrl = 'https://ac.wiz.cn'
axios.defaults.baseURL = baseUrl

export async function execRequest (config) {
const response = await axios(config)
return response.data
}
6 changes: 5 additions & 1 deletion src/ApiHandler.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export default {
icon: icon,
actions: [
{
label: 'open_in_new',
icon: 'open_in_new',
textColor: 'white',
handler: () => {
shell.showItemInFolder(filePath)
Expand Down Expand Up @@ -82,6 +82,10 @@ export default {
bus.$emit(events.VIEW_SHORTCUT_CALL[type], type)
}).catch(err => throw err)

handleApi('editor-note-action', (event, { type }) => {
bus.$emit(events.NOTE_SHORTCUT_CALL[type], true)
}).catch(err => throw err)

handleApi('updater-update-available', (event, info) => {
console.log(info)
bus.$emit(events.UPDATE_EVENTS.updateAvailable, info)
Expand Down
29 changes: 17 additions & 12 deletions src/ApiInvoker.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ const { ipcRenderer } = require('electron')
* @returns {Promise<void>}
*/
async function exportMarkdownFile (note) {
return await ipcRenderer.invoke(channels.exportMarkdownFile, note)
return ipcRenderer.invoke(channels.exportMarkdownFile, note)
}

async function exportPng (note) {
return await ipcRenderer.invoke(channels.exportPng, note)
return ipcRenderer.invoke(channels.exportPng, note)
}

/**
Expand All @@ -21,35 +21,39 @@ async function exportPng (note) {
* @returns {Promise<any>}
*/
async function exportMarkdownFiles (notes) {
return await ipcRenderer.invoke(channels.exportMarkdownFiles, notes)
return ipcRenderer.invoke(channels.exportMarkdownFiles, notes)
}

/**
* import images
* @returns {Promise<string[]>}
*/
async function importImages () {
return await ipcRenderer.invoke(channels.importImages)
return ipcRenderer.invoke(channels.importImages)
}

/**
* @param {({ext: string, file: (*|string)} | string)[]} imagePaths
* @returns {Promise<any>}
*/
async function uploadImages (imagePaths, type, options = {}) {
return await ipcRenderer.invoke(channels.uploadImages, { imagePaths, type, options })
return ipcRenderer.invoke(channels.uploadImages, { imagePaths, type, options })
}

async function checkUpdate () {
return await ipcRenderer.invoke(channels.checkUpdate)
return ipcRenderer.invoke(channels.checkUpdate)
}

async function needUpdate (need) {
return await ipcRenderer.invoke(channels.needUpdate, need)
return ipcRenderer.invoke(channels.needUpdate, need)
}

async function quitAndUpdate () {
return await ipcRenderer.invoke(channels.quitAndUpdate)
return ipcRenderer.invoke(channels.quitAndUpdate)
}

async function remoteRequest (config) {
return ipcRenderer.invoke(channels.remoteRequest, config)
}

/**
Expand All @@ -58,7 +62,7 @@ async function quitAndUpdate () {
* @returns {Promise<any>}
*/
async function getCacheImage (bundle) {
return await ipcRenderer.invoke(channels.getCacheImage, bundle)
return ipcRenderer.invoke(channels.getCacheImage, bundle)
}

/**
Expand All @@ -67,15 +71,15 @@ async function getCacheImage (bundle) {
* @returns {string}
*/
async function saveTempImage (bundle) {
return await ipcRenderer.invoke(channels.saveTempImage, bundle)
return ipcRenderer.invoke(channels.saveTempImage, bundle)
}

async function getLocalFileData (filePath) {
return await ipcRenderer.invoke(channels.getLocalFileData, filePath)
return ipcRenderer.invoke(channels.getLocalFileData, filePath)
}

async function saveUploadedImage (buffer, kbGuid, docGuid, name) {
return await ipcRenderer.invoke(channels.saveUploadedImage, { buffer, kbGuid, docGuid, name })
return ipcRenderer.invoke(channels.saveUploadedImage, { buffer, kbGuid, docGuid, name })
}

export {
Expand All @@ -87,6 +91,7 @@ export {
checkUpdate,
needUpdate,
quitAndUpdate,
remoteRequest,
getCacheImage,
saveTempImage,
getLocalFileData,
Expand Down
3 changes: 2 additions & 1 deletion src/boot/i18n.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ import Vue from 'vue'
import VueI18n from 'vue-i18n'
import messages from 'src/i18n'
import ClientFileStorage from 'src/utils/storage/ClientFileStorage'
const local = ClientFileStorage.getItemFromStore('language') || 'en-us'
const { app } = require('electron').remote
const local = ClientFileStorage.getItemFromStore('language') || app.getLocale().toLocaleLowerCase()
Vue.use(VueI18n)

const i18n = new VueI18n({
Expand Down
52 changes: 50 additions & 2 deletions src/boot/request.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,59 @@ import bus from 'components/bus'
import events from 'src/constants/events'
import NeetoError from 'app/share/error'
import ServerFileStorage from 'src/utils/storage/ServerFileStorage'
import { remoteRequest } from 'src/ApiInvoker'

axios.defaults.timeout = 50000 // 响应时间
const baseUrl = 'https://ac.wiz.cn'
axios.defaults.baseURL = baseUrl

/**
* execute network request
* @param {'GET','POST','DELETE','PUT'} method
* @param {string} url
* @param {Object} body
* @param token
* @param {Object} extraConfig
* @param {boolean} returnFullResult
* @param {boolean} ignoreStatusCode
* @returns {Promise<*>}
*/
// export async function execRequest (method, url, body = {}, token = null, extraConfig = {}, returnFullResult = false, ignoreStatusCode = false) {
// const config = {
// url,
// method,
// data: body
// }
//
// if (token) {
// config.headers = {
// 'X-Wiz-Token': token
// }
// } else if (ServerFileStorage.isKeyExistsInLocalStorage('token')) {
// config.headers = {
// 'X-Wiz-Token': ServerFileStorage.getValueFromLocalStorage('token')
// }
// }
//
// Object.assign(config, extraConfig)
//
// const res = await axios(config)
// const data = res.data
//
// if (data.returnCode !== 200 && data.code !== 200 && !ignoreStatusCode) {
// const { returnMessage, returnCode, externCode } = data
// bus.$emit(events.REQUEST_ERROR, new NeetoError(returnMessage, returnCode, externCode))
// const err = new Error(returnMessage)
// err.code = returnCode
// err.externCode = data.externCode
// throw err
// }
//
// return typeof data === 'object' && ('result' in data || !returnFullResult)
// ? data.result
// : data
// }

/**
* execute network request
* @param {'GET','POST','DELETE','PUT'} method
Expand Down Expand Up @@ -38,8 +86,8 @@ export async function execRequest (method, url, body = {}, token = null, extraCo

Object.assign(config, extraConfig)

const res = await axios(config)
const data = res.data
const data = await remoteRequest(config)
// const data = res.data

if (data.returnCode !== 200 && data.code !== 200 && !ignoreStatusCode) {
const { returnMessage, returnCode, externCode } = data
Expand Down
8 changes: 3 additions & 5 deletions src/components/Header.vue
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
style="cursor: pointer"
@click="$refs.tagDialog.toggle"
>
<q-icon key="icon" name="book" size="19px" />
<span class='save-dot' :class="{ 'show': this.noteState !== 'default' }"></span>
<q-tooltip
v-if="tags.length > 0"
:offset="[20, 10]"
Expand Down Expand Up @@ -347,15 +347,13 @@ export default {
.header-note-title {
display: flex;
align-items: center;
margin-left: 10%;
}
.header-note-title > span {
font-family: 'Open Sans', 'JetBrains Mono';
font-family: 'Open Sans', 'JetBrains Mono', serif;
margin-left: 7px;
letter-spacing: 0.3px;
font-weight: 600;
}
.note-state-icon {
color: var(--noteStateIcon);
}
</style>
Loading

0 comments on commit 7c2a4e9

Please sign in to comment.