|
|
|
@ -2,19 +2,40 @@ import { auth } from "./auth.module";
|
|
|
|
|
import { createStore } from 'vuex' |
|
|
|
|
import { getStatusGenerator } from "@/services/analytics.service"; |
|
|
|
|
|
|
|
|
|
const SET_ANALYTICS_STATUS = 'setAnalyticsStatus'; |
|
|
|
|
// import { notify } from "@kyvg/vue3-notification";
|
|
|
|
|
|
|
|
|
|
export default createStore({ |
|
|
|
|
|
|
|
|
|
const SET_ANALYTICS_STATUS = 'SET_ANALYTICS_STATUS'; |
|
|
|
|
const _SET_STATUS_GENERATOR = '_SET_STATUS_GENERATOR'; |
|
|
|
|
|
|
|
|
|
type State = { |
|
|
|
|
analyticStatus: string, |
|
|
|
|
_statusGenerator: AsyncIterableIterator<string> |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
const store = createStore<State>({ |
|
|
|
|
state: { |
|
|
|
|
analyticStatus: 'loading...' |
|
|
|
|
analyticStatus: 'loading...', |
|
|
|
|
_statusGenerator: null |
|
|
|
|
}, |
|
|
|
|
mutations: { |
|
|
|
|
[SET_ANALYTICS_STATUS](state, status: string) { |
|
|
|
|
state.analyticStatus = status; |
|
|
|
|
}, |
|
|
|
|
|
|
|
|
|
[_SET_STATUS_GENERATOR](state, generator: AsyncIterableIterator<string>) { |
|
|
|
|
this._statusGenerator = generator; |
|
|
|
|
} |
|
|
|
|
}, |
|
|
|
|
actions: { |
|
|
|
|
async runStatusGenerator({commit}) { |
|
|
|
|
async _runStatusGenerator({commit, state}) { |
|
|
|
|
// notify({
|
|
|
|
|
// title: "Authorization",
|
|
|
|
|
// text: "You have been logged in!",
|
|
|
|
|
// });
|
|
|
|
|
if(state._statusGenerator !== null) { |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
const g = getStatusGenerator(); |
|
|
|
|
for await (const data of g) { |
|
|
|
|
// this.status = data.toLowerCase();
|
|
|
|
@ -26,3 +47,7 @@ export default createStore({
|
|
|
|
|
auth |
|
|
|
|
} |
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
store.dispatch('_runStatusGenerator'); |
|
|
|
|
|
|
|
|
|
export default store; |
|
|
|
|