refs #22 Change menu item after authorize new account

This commit is contained in:
AkiraFukushima 2018-03-21 22:32:32 +09:00
parent f2425db9c9
commit 68f3b193e3
6 changed files with 23 additions and 5 deletions

View File

@ -284,8 +284,10 @@ ipcMain.on('start-user-streaming', (event, ac) => {
})
ipcMain.on('stop-user-streaming', (event, _) => {
userStreaming.stop()
userStreaming = null
if (userStreaming !== null) {
userStreaming.stop()
userStreaming = null
}
})
let localStreaming = null

View File

@ -37,14 +37,17 @@ export default {
created () {
this.initialize()
},
methods: {
async initialize () {
await this.$store.dispatch('GlobalHeader/removeShortcutEvents')
this.$store.dispatch('GlobalHeader/watchShortcutEvents')
try {
const accounts = await this.$store.dispatch('GlobalHeader/listAccounts')
return this.$router.push({ path: `/${accounts[0]._id}/home` })
if (this.$route.params.id === undefined) {
return this.$router.push({ path: `/${accounts[0]._id}/home` })
} else {
return this.$store.dispatch('GlobalHeader/schmearMenu', this.$route.params.id)
}
} catch (err) {
return this.$router.push({ path: '/login' })
}

View File

@ -2,7 +2,7 @@
<div id="instance_form">
<el-form ref="instanceForm" label-width="120px" label-position="top" class="instance-form" v-on:submit.prevent="search">
<el-form-item label="Domain name">
<el-input v-model="instanceForm.domain" class="input"></el-input>
<el-input v-model="instanceForm.domain" class="input" ref="domain" autofocus></el-input>
</el-form-item>
<el-form-item class="submit">
<el-button type="primary" @click="search" native-type="submit">Search</el-button>
@ -21,6 +21,9 @@ export default {
}
}
},
mounted () {
this.$refs.domain.$el.getElementsByTagName('input')[0].focus()
},
methods: {
search () {
const loading = this.$loading({

View File

@ -50,6 +50,7 @@ export default {
this.$store.dispatch('Login/fetchLogin', this.selectedInstance)
.then((url) => {
loading.close()
this.$store.dispatch('Login/pageBack')
this.$router.push({ path: '/authorize' })
})
.catch(() => {

View File

@ -37,6 +37,14 @@ const GlobalHeader = {
async removeShortcutEvents () {
ipcRenderer.removeAllListeners('change-account')
return 'removeShortcutEvents'
},
schmearMenu ({ commit, state }, id) {
const index = state.accounts.findIndex((a) => {
return a._id === id
})
if (index !== undefined) {
commit('changeDefaultActive', index.toString())
}
}
}
}

View File

@ -43,6 +43,7 @@ const Login = {
return new Promise((resolve, reject) => {
ipcRenderer.send('get-auth-url', instance)
ipcRenderer.once('error-get-auth-url', (event, err) => {
// TODO: remove events
reject(err)
})
ipcRenderer.once('response-get-auth-url', (event, url) => {