Skip to content

Commit

Permalink
[skip ci] code style fix
Browse files Browse the repository at this point in the history
  • Loading branch information
xVanTuring authored and xVanTuring committed Feb 27, 2020
1 parent 3e5f97e commit ca021b9
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 55 deletions.
85 changes: 43 additions & 42 deletions src/renderer/ipc.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,50 +8,51 @@ import { loadConfigsFromString } from '../shared/ssr'
/**
* ipc-render事件
*/
ipcRenderer.on(events.EVENT_APP_NOTIFY_MAIN, (e, { title, body }) => {
// 显示main进程的通知
showHtmlNotification(body, title)
}).on(events.EVENT_APP_SCAN_DESKTOP, () => {
// 扫描二维码
scanQrcode((e, result) => {
if (e) {
showNotification('未找到相关二维码', '扫码失败')
} else {
const configs = loadConfigsFromString(result)
if (configs.length) {
store.dispatch('addConfigs', configs)
showNotification(`已成功添加${configs.length}条记录`)
export function register () {
ipcRenderer.on(events.EVENT_APP_NOTIFY_MAIN, (e, { title, body }) => {
// 显示main进程的通知
showHtmlNotification(body, title)
}).on(events.EVENT_APP_SCAN_DESKTOP, () => {
// 扫描二维码
scanQrcode((e, result) => {
if (e) {
showNotification('未找到相关二维码', '扫码失败')
} else {
const configs = loadConfigsFromString(result)
if (configs.length) {
store.dispatch('addConfigs', configs)
showNotification(`已成功添加${configs.length}条记录`)
}
}
}
})
}).on(events.EVENT_APP_SHOW_PAGE, (e, targetView) => {
// 显示具体某页面
console.log('received view update: ', targetView.page, targetView.tab)
store.commit('updateView', { ...targetView, fromMain: true })
}).on(events.EVENT_APP_ERROR_MAIN, (e, err) => {
// 弹框显示main进程报错内容
alert(err)
}).on(events.EVENT_SUBSCRIBE_UPDATE_MAIN, (e) => {
// 更新订阅服务器
store.dispatch('updateSubscribes').then(updatedCount => {
if (updatedCount > 0) {
showNotification(`服务器订阅更新成功,共更新了${updatedCount}个节点`)
} else {
showNotification(`服务器订阅更新完成,没有新节点`)
}
}).catch(() => {
showNotification('服务器订阅更新失败')
})
}).on(events.EVENT_APP_SHOW_PAGE, (e, targetView) => {
// 显示具体某页面
console.log('received view update: ', targetView.page, targetView.tab)
store.commit('updateView', { ...targetView, fromMain: true })
}).on(events.EVENT_APP_ERROR_MAIN, (e, err) => {
// 弹框显示main进程报错内容
alert(err)
}).on(events.EVENT_SUBSCRIBE_UPDATE_MAIN, (e) => {
// 更新订阅服务器
store.dispatch('updateSubscribes').then(updatedCount => {
if (updatedCount > 0) {
showNotification(`服务器订阅更新成功,共更新了${updatedCount}个节点`)
} else {
showNotification(`服务器订阅更新完成,没有新节点`)
}
}).catch(() => {
showNotification('服务器订阅更新失败')
})
}).on(events.EVENT_RX_SYNC_MAIN, (e, appConfig) => {
// 同步数据
console.log('received sync data: %o', appConfig)
store.commit('updateConfig', [appConfig])
}).on(events.EVENT_CONFIG_CREATE, () => {
store.dispatch('newConfig')
}).on(events.EVENT_SUBSCRIBE_NEW, () => {
store.dispatch('newSubscription')
})
}).on(events.EVENT_RX_SYNC_MAIN, (e, appConfig) => {
// 同步数据
console.log('received sync data: %o', appConfig)
store.commit('updateConfig', [appConfig])
}).on(events.EVENT_CONFIG_CREATE, () => {
store.dispatch('newConfig')
}).on(events.EVENT_SUBSCRIBE_NEW, () => {
store.dispatch('newSubscription')
})

}
/**
* 与main进程同步配置项
* @param {Object} appConfig 用于更新的应用配置
Expand Down
2 changes: 1 addition & 1 deletion src/renderer/locales/en-US.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
"UI_SUBSCRIPTION_URL":"URL",
"UI_ENTER_NEW_SUB_URL":"Please enter new Subscription URL",
"UI_GROUP_NAME":"Group name",
"UI_NO_NODE":"There is no node. Please go Setting-Add to add one",
"UI_NO_NODE":"There is no node here. Please go `Add` to add one.",

"UI_FEATURE_CROSS_PLATFORM": "Cross Platform",
"UI_FEATURE_CP_DETAIL":"Support Windows, MacOs and Linux",
Expand Down
4 changes: 2 additions & 2 deletions src/renderer/main.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import Vue from 'vue'
import './components'
import { getInitConfig } from './ipc'
import { getInitConfig, register } from './ipc'
import store from './store'
import App from './App'
import i18n from './i18n'
require('./ipc')
register()
Vue.config.productionTip = false

// 启动应用时获取初始化数据
Expand Down
14 changes: 4 additions & 10 deletions src/renderer/views/ManagePanel.vue
Original file line number Diff line number Diff line change
@@ -1,24 +1,18 @@
<template>
<app-view name="panel" class="px-2 py-2" row>
<ssr-nodes ></ssr-nodes>
<node-list-panel></node-list-panel>
<info-panel></info-panel>
<!-- <div v-show="editingGroup.show&&!editingGroup.title" class="flex-1"></div> -->
</app-view>
</template>
<script>
/* eslint-disable vue/no-unused-components */
import { mapState } from 'vuex'
import SsrNodes from './panel/SSRNodeListPanel'
import NodeListPanel from './panel/SSRNodeListPanel'
import InfoPanel from './panel/InfoPanel'
export default {
components: {
SsrNodes, InfoPanel
},
computed: {
...mapState(['editingGroup'])
NodeListPanel,
InfoPanel
}
}
</script>
<style >
</style>

0 comments on commit ca021b9

Please sign in to comment.