mirror of
https://github.com/freqtrade/frequi.git
synced 2024-11-23 11:35:14 +00:00
Move logout to store
This commit is contained in:
parent
8579499418
commit
f30f968a2f
|
@ -45,7 +45,7 @@
|
|||
<router-link class="dropdown-item" to="/settings">Settings</router-link>
|
||||
<b-checkbox v-model="layoutLockedLocal" class="pl-5">Lock layout</b-checkbox>
|
||||
<b-dropdown-item @click="resetDynamicLayout">Reset Layout</b-dropdown-item>
|
||||
<router-link class="dropdown-item" to="/" @click.native="logout()"
|
||||
<router-link class="dropdown-item" to="/" @click.native="clickLogout()"
|
||||
>Sign Out</router-link
|
||||
>
|
||||
</b-nav-item-dropdown>
|
||||
|
@ -64,7 +64,6 @@
|
|||
import { Component, Vue, Watch } from 'vue-property-decorator';
|
||||
import LoginModal from '@/views/LoginModal.vue';
|
||||
import { State, Action, namespace, Getter } from 'vuex-class';
|
||||
import userService from '@/shared/userService';
|
||||
import BootswatchThemeSelect from '@/components/BootswatchThemeSelect.vue';
|
||||
import { LayoutActions, LayoutGetters } from '@/store/modules/layout';
|
||||
import { BotStoreGetters } from '@/store/modules/ftbot';
|
||||
|
@ -95,6 +94,8 @@ export default class NavBar extends Vue {
|
|||
|
||||
@ftbot.Action getState;
|
||||
|
||||
@ftbot.Action logout;
|
||||
|
||||
@ftbot.Getter [BotStoreGetters.botName]: string;
|
||||
|
||||
@ftbot.Getter [BotStoreGetters.openTradeCount]: number;
|
||||
|
@ -130,8 +131,8 @@ export default class NavBar extends Vue {
|
|||
}
|
||||
}
|
||||
|
||||
logout(): void {
|
||||
userService.logout();
|
||||
clickLogout(): void {
|
||||
this.logout();
|
||||
this.setLoggedIn(false);
|
||||
}
|
||||
|
||||
|
|
|
@ -6,6 +6,13 @@ const AUTH_LOGIN_INFO = 'auth_login_info';
|
|||
const APIBASE = '/api/v1';
|
||||
|
||||
export class UserService {
|
||||
private botId: string;
|
||||
|
||||
constructor(botId: string) {
|
||||
console.log('botId', botId);
|
||||
this.botId = botId;
|
||||
}
|
||||
|
||||
private storeLoginInfo(loginInfo: AuthStorage): void {
|
||||
localStorage.setItem(AUTH_LOGIN_INFO, JSON.stringify(loginInfo));
|
||||
}
|
||||
|
@ -142,10 +149,10 @@ export class UserService {
|
|||
}
|
||||
}
|
||||
|
||||
export function useUserService() {
|
||||
const userservice = new UserService();
|
||||
export function useUserService(botId: string) {
|
||||
const userservice = new UserService(botId);
|
||||
userservice.migrateLogin();
|
||||
return userservice;
|
||||
}
|
||||
|
||||
export default useUserService();
|
||||
export default useUserService('ftbot.0');
|
||||
|
|
|
@ -53,7 +53,7 @@ export default function createBotStore() {
|
|||
return {
|
||||
namespaced: true,
|
||||
modules: {
|
||||
'ftbot.0': createBotSubStore(),
|
||||
'ftbot.0': createBotSubStore('ftbot.0'),
|
||||
},
|
||||
state,
|
||||
mutations,
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import { useApi } from '@/shared/apiService';
|
||||
import userService from '@/shared/userService';
|
||||
import { useUserService } from '@/shared/userService';
|
||||
|
||||
import {
|
||||
BacktestResult,
|
||||
|
@ -123,9 +123,11 @@ export enum BotStoreActions {
|
|||
pollBacktest = 'pollBacktest',
|
||||
removeBacktest = 'removeBacktest',
|
||||
stopBacktest = 'stopBacktest',
|
||||
logout = 'logout',
|
||||
}
|
||||
|
||||
export function createBotSubStore() {
|
||||
export function createBotSubStore(botId: string) {
|
||||
const userService = useUserService(botId);
|
||||
const { api } = useApi(userService);
|
||||
|
||||
return {
|
||||
|
@ -389,8 +391,11 @@ export function createBotSubStore() {
|
|||
.catch(console.error);
|
||||
}
|
||||
},
|
||||
[BotStoreActions.logout]() {
|
||||
userService.logout();
|
||||
},
|
||||
[BotStoreActions.setRefreshRequired]({ commit }, refreshRequired: boolean) {
|
||||
commit('setRefreshRequired', refreshRequired);
|
||||
commit('updateRefreshRequired', refreshRequired);
|
||||
},
|
||||
[BotStoreActions.setDetailTrade]({ commit }, trade: Trade) {
|
||||
commit('setDetailTrade', trade);
|
||||
|
|
Loading…
Reference in New Issue
Block a user