diff --git a/src/components/layout/NavBar.vue b/src/components/layout/NavBar.vue
index b83e16da..9a7c95bc 100644
--- a/src/components/layout/NavBar.vue
+++ b/src/components/layout/NavBar.vue
@@ -45,7 +45,7 @@
Settings
Lock layout
Reset Layout
- Sign Out
@@ -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);
}
diff --git a/src/shared/userService.ts b/src/shared/userService.ts
index 9bb104f6..7d225d05 100644
--- a/src/shared/userService.ts
+++ b/src/shared/userService.ts
@@ -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');
diff --git a/src/store/modules/botStoreWrapper.ts b/src/store/modules/botStoreWrapper.ts
index 73d142ce..d9894d08 100644
--- a/src/store/modules/botStoreWrapper.ts
+++ b/src/store/modules/botStoreWrapper.ts
@@ -53,7 +53,7 @@ export default function createBotStore() {
return {
namespaced: true,
modules: {
- 'ftbot.0': createBotSubStore(),
+ 'ftbot.0': createBotSubStore('ftbot.0'),
},
state,
mutations,
diff --git a/src/store/modules/ftbot/index.ts b/src/store/modules/ftbot/index.ts
index f7e80a98..91ce1711 100644
--- a/src/store/modules/ftbot/index.ts
+++ b/src/store/modules/ftbot/index.ts
@@ -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);