分离主进程与渲染进程的功能,禁用remote模块
This commit is contained in:
+13
-6
@@ -20,7 +20,7 @@
|
||||
<script>
|
||||
import dnscache from 'dnscache'
|
||||
import { mapMutations, mapGetters, mapActions } from 'vuex'
|
||||
import { rendererOn } from '../common/icp'
|
||||
import { ipcRenderer } from 'electron'
|
||||
import { isLinux } from '../common/utils'
|
||||
import music from './utils/music'
|
||||
window.ELECTRON_DISABLE_SECURITY_WARNINGS = process.env.ELECTRON_DISABLE_SECURITY_WARNINGS
|
||||
@@ -97,7 +97,7 @@ export default {
|
||||
},
|
||||
methods: {
|
||||
...mapActions(['getVersionInfo']),
|
||||
...mapMutations(['setNewVersion', 'setVersionModalVisible']),
|
||||
...mapMutations(['setNewVersion', 'setVersionModalVisible', 'setDownloadProgress']),
|
||||
...mapMutations('list', ['initList']),
|
||||
...mapMutations('download', ['updateDownloadList']),
|
||||
...mapMutations(['setSetting']),
|
||||
@@ -106,13 +106,15 @@ export default {
|
||||
body.addEventListener('mouseenter', this.dieableIgnoreMouseEvents)
|
||||
body.addEventListener('mouseleave', this.enableIgnoreMouseEvents)
|
||||
}
|
||||
rendererOn('update-available', (e, info) => {
|
||||
ipcRenderer.on('update-available', (e, info) => {
|
||||
// this.showUpdateModal(true)
|
||||
console.log(info)
|
||||
this.setNewVersion({
|
||||
version: info.version,
|
||||
})
|
||||
})
|
||||
rendererOn('update-error', () => {
|
||||
ipcRenderer.on('update-error', err => {
|
||||
console.log(err)
|
||||
if (!this.updateTimeout) return
|
||||
this.setVersionModalVisible({ isError: true })
|
||||
this.clearUpdateTimeout()
|
||||
@@ -120,12 +122,17 @@ export default {
|
||||
this.showUpdateModal()
|
||||
})
|
||||
})
|
||||
rendererOn('update-downloaded', () => {
|
||||
ipcRenderer.on('update-progress', progress => {
|
||||
console.log(progress)
|
||||
this.setDownloadProgress(progress)
|
||||
})
|
||||
ipcRenderer.on('update-downloaded', info => {
|
||||
console.log(info)
|
||||
this.clearUpdateTimeout()
|
||||
this.setVersionModalVisible({ isError: false })
|
||||
this.showUpdateModal()
|
||||
})
|
||||
rendererOn('update-not-available', () => {
|
||||
ipcRenderer.on('update-not-available', () => {
|
||||
if (!this.updateTimeout) return
|
||||
if (this.setting.ignoreVersion) this.setSetting(Object.assign({}, this.setting, { ignoreVersion: null }))
|
||||
this.clearUpdateTimeout()
|
||||
|
||||
@@ -48,7 +48,7 @@ div(:class="$style.player")
|
||||
|
||||
<script>
|
||||
import Lyric from 'lrc-file-parser'
|
||||
import { rendererSend } from '../../../common/icp'
|
||||
import { rendererSend } from '../../../common/ipc'
|
||||
import { formatPlayTime2, getRandom, checkPath, setTitle, clipboardWriteText, debounce } from '../../utils'
|
||||
import { mapGetters, mapActions, mapMutations } from 'vuex'
|
||||
import { requestMsg } from '../../utils/message'
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { rendererSend } from 'common/icp'
|
||||
import { rendererSend } from 'common/ipc'
|
||||
import { mapGetters } from 'vuex'
|
||||
import music from '../../utils/music'
|
||||
import { debounce } from '../../utils'
|
||||
|
||||
@@ -45,7 +45,7 @@ material-modal(:show="version.showModal" @close="handleClose")
|
||||
|
||||
<script>
|
||||
import { mapGetters, mapMutations } from 'vuex'
|
||||
import { rendererSend } from '../../../common/icp'
|
||||
import { rendererSend } from '../../../common/ipc'
|
||||
import { checkVersion, openUrl, clipboardWriteText } from '../../utils'
|
||||
|
||||
export default {
|
||||
|
||||
@@ -22,12 +22,11 @@ export default {
|
||||
state.setting.list.scroll.locations[id] = location
|
||||
},
|
||||
setNewVersion(state, val) {
|
||||
// val.history.forEach(ver => {
|
||||
// ver.desc = ver.desc.replace(/\n/g, '<br>')
|
||||
// })
|
||||
// val.desc = val.desc.replace(/\n/g, '<br>')
|
||||
state.version.newVersion = val
|
||||
},
|
||||
setDownloadProgress(state, info) {
|
||||
state.version.downloadProgress = info
|
||||
},
|
||||
setVersionModalVisible(state, { isShow, isError }) {
|
||||
if (isShow !== undefined) state.version.showModal = isShow
|
||||
if (isError !== undefined) state.version.isError = isError
|
||||
|
||||
@@ -62,6 +62,7 @@ export default {
|
||||
newVersion: null,
|
||||
showModal: false,
|
||||
isError: false,
|
||||
downloadProgress: null,
|
||||
},
|
||||
userInfo: null,
|
||||
setting,
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
import fs from 'fs'
|
||||
import { shell, remote, clipboard } from 'electron'
|
||||
import { shell, clipboard } from 'electron'
|
||||
import path from 'path'
|
||||
import os from 'os'
|
||||
import crypto from 'crypto'
|
||||
import { rendererSend } from '../../common/icp'
|
||||
import { rendererSend, rendererInvoke } from '../../common/ipc'
|
||||
|
||||
/**
|
||||
* 获取两个数之间的随机整数,大于等于min,小于max
|
||||
@@ -86,13 +86,13 @@ export const checkPath = path => fs.existsSync(path)
|
||||
* 在资源管理器中打开目录
|
||||
* @param {*} 选项
|
||||
*/
|
||||
export const openSelectDir = options => remote.dialog.showOpenDialog(remote.getCurrentWindow(), options)
|
||||
export const selectDir = options => rendererInvoke('selectDir', options)
|
||||
|
||||
/**
|
||||
* 在资源管理器中打开目录
|
||||
* @param {*} 选项
|
||||
*/
|
||||
export const openSaveDir = options => remote.dialog.showSaveDialog(remote.getCurrentWindow(), options)
|
||||
export const openSaveDir = options => rendererInvoke('showSaveDialog', options)
|
||||
|
||||
/**
|
||||
* 在资源管理器中打开目录
|
||||
@@ -361,19 +361,17 @@ export const asyncSetArray = (from, to, num = 100) => new Promise(resolve => {
|
||||
|
||||
/**
|
||||
* 获取缓存大小
|
||||
* @param {*} win
|
||||
*/
|
||||
export const getCacheSize = () => remote.getCurrentWindow().webContents.session.getCacheSize()
|
||||
export const getCacheSize = () => rendererInvoke('getCacheSize')
|
||||
|
||||
/**
|
||||
* 清除缓存
|
||||
* @param {*} win
|
||||
*/
|
||||
export const clearCache = () => remote.getCurrentWindow().webContents.session.clearCache()
|
||||
export const clearCache = () => rendererInvoke('clearCache')
|
||||
|
||||
/**
|
||||
* 设置窗口大小
|
||||
* @param {*} width
|
||||
* @param {*} height
|
||||
*/
|
||||
export const setWindowSize = (width, height) => remote.getCurrentWindow().setBounds({ width, height })
|
||||
export const setWindowSize = (width, height) => rendererSend('setWindowSize', { width, height })
|
||||
|
||||
@@ -174,7 +174,7 @@ div.scroll(:class="$style.setting")
|
||||
import { mapGetters, mapMutations } from 'vuex'
|
||||
import {
|
||||
openDirInExplorer,
|
||||
openSelectDir,
|
||||
selectDir,
|
||||
openSaveDir,
|
||||
updateSetting,
|
||||
openUrl,
|
||||
@@ -184,7 +184,7 @@ import {
|
||||
sizeFormate,
|
||||
setWindowSize,
|
||||
} from '../utils'
|
||||
import { rendererSend } from '../../common/icp'
|
||||
import { rendererSend } from '../../common/ipc'
|
||||
import fs from 'fs'
|
||||
|
||||
export default {
|
||||
@@ -328,7 +328,7 @@ export default {
|
||||
this.getCacheSize()
|
||||
},
|
||||
handleChangeSavePath() {
|
||||
openSelectDir({
|
||||
selectDir({
|
||||
title: '选择歌曲保存路径',
|
||||
defaultPath: this.current_setting.download.savePath,
|
||||
properties: ['openDirectory'],
|
||||
@@ -421,7 +421,7 @@ export default {
|
||||
})
|
||||
},
|
||||
handleImportAllData() {
|
||||
openSelectDir({
|
||||
selectDir({
|
||||
title: '选择备份文件',
|
||||
properties: ['openFile'],
|
||||
filters: [
|
||||
@@ -443,7 +443,7 @@ export default {
|
||||
})
|
||||
},
|
||||
handleImportSetting() {
|
||||
openSelectDir({
|
||||
selectDir({
|
||||
title: '选择配置文件',
|
||||
properties: ['openFile'],
|
||||
filters: [
|
||||
@@ -465,7 +465,7 @@ export default {
|
||||
})
|
||||
},
|
||||
handleImportPlayList() {
|
||||
openSelectDir({
|
||||
selectDir({
|
||||
title: '选择列表文件',
|
||||
properties: ['openFile'],
|
||||
filters: [
|
||||
|
||||
Reference in New Issue
Block a user