Merge pull request #865 from h3poteto/iss-850

refs #850 Replace Authorize with typescript
This commit is contained in:
AkiraFukushima 2019-04-04 22:37:23 +09:00 committed by GitHub
commit c838cec9f0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 33 additions and 24 deletions

View File

@ -1,24 +0,0 @@
import { ipcRenderer } from 'electron'
const Authorize = {
namespaced: true,
state: {},
mutations: {},
actions: {
submit (_, code) {
return new Promise((resolve, reject) => {
ipcRenderer.send('get-access-token', code)
ipcRenderer.once('response-get-access-token', (event, id) => {
ipcRenderer.removeAllListeners('error-get-access-token')
resolve(id)
})
ipcRenderer.once('error-get-access-token', (event, err) => {
ipcRenderer.removeAllListeners('response-get-access-token')
reject(err)
})
})
}
}
}
export default Authorize

View File

@ -0,0 +1,33 @@
import { ipcRenderer } from 'electron'
import { Module, ActionTree } from 'vuex'
export interface AuthorizeState {}
const state = (): AuthorizeState => ({})
// TODO: use type of rootState
const actions: ActionTree<AuthorizeState, any> = {
submit: (_, code: string) => {
return new Promise((resolve, reject) => {
ipcRenderer.send('get-access-token', code)
ipcRenderer.once('response-get-access-token', (_, id: string) => {
ipcRenderer.removeAllListeners('error-get-access-token')
resolve(id)
})
ipcRenderer.once('error-get-access-token', (_, err: Error) => {
ipcRenderer.removeAllListeners('response-get-access-token')
reject(err)
})
})
}
}
// TODO: use type of rootState
const Authorize: Module<AuthorizeState, any> = {
namespaced: true,
state: state,
mutations: {},
actions: actions
}
export default Authorize