Skip to content

Commit

Permalink
set nickname
Browse files Browse the repository at this point in the history
  • Loading branch information
simon300000 committed Oct 13, 2019
1 parent 43bae80 commit bcb670f
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 6 deletions.
12 changes: 11 additions & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,17 @@ <h2 class="subtitle">(重载生效)</h2>
<p class="help is-danger" v-if="intervalWarning">
间隔太小会影响使用bilibili
</p>
<p class="help">目前: {{state.INTERVAL}} ms</p>
<p class="help">当前: {{state.INTERVAL}} ms</p>
</div>

<br>

<div class="field">
<label class="label">昵称 (可选)</label>
<div class="control">
<input class="input" type="text" v-model="nickname" placeholder="会显示在统计中哦">
</div>
<p class="help">当前: {{state.nickname || '无'}}</p>
</div>

<br>
Expand Down
9 changes: 7 additions & 2 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,21 @@ new Vue({
url: undefined,
update: undefined,
updateProgress: undefined,
updateDownloaded: undefined
updateDownloaded: undefined,
nickname: undefined
},
uptime: undefined,
interval: undefined
interval: undefined,
nickname: undefined
},
watch: {
interval(value) {
if (value) {
send('updateInterval', Number(value))
}
},
nickname(value) {
send('updateNickname', value)
}
},
methods: {
Expand Down
2 changes: 1 addition & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ const autoUpdater = updater({ state })
load({ state, stateEmitter })

connect({ state, db })
.then(({ getWs, updateInterval }) => sync({ getWin, updateInterval, state, stateEmitter, getWs, autoUpdater, createWindow }))
.then(({ getWs, updateInterval, updateNickname }) => sync({ getWin, updateInterval, updateNickname, state, stateEmitter, getWs, autoUpdater, createWindow }))
4 changes: 3 additions & 1 deletion src/ipc.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@ const { ipcMain } = require('electron')
const moment = require('moment')
moment.locale('zh-cn')

module.exports = ({ getWin, state, stateEmitter, getWs, updateInterval, autoUpdater, createWindow }) => {
module.exports = ({ getWin, state, stateEmitter, getWs, updateInterval, autoUpdater, createWindow, updateNickname }) => {
const router = {
state(key) {
return state[key]
},
updateInterval,
updateNickname,
close() {
const ws = getWs()
if (ws.readyState === 1) {
Expand Down Expand Up @@ -53,6 +54,7 @@ module.exports = ({ getWin, state, stateEmitter, getWs, updateInterval, autoUpda

subscribe('completeNum')
subscribe('INTERVAL')
subscribe('nickname')
subscribe('url')
subscribe('update')
subscribe('updateProgress')
Expand Down
6 changes: 5 additions & 1 deletion src/ws.js
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,10 @@ module.exports = async ({ state, db }) => {
db.put('INTERVAL', interval)
INTERVAL = interval
}
const updateNickname = name => {
db.put('nickname', name)
nickname = name
}

return { getWs, updateInterval }
return { getWs, updateInterval, updateNickname }
}

0 comments on commit bcb670f

Please sign in to comment.