refs #850 Replace Authorize with typescript
This commit is contained in:
parent
fb378a6d24
commit
0e33b465a1
|
@ -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
|
|
|
@ -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
|
Loading…
Reference in New Issue