-
diff --git a/src/store/index.ts b/src/store/index.ts
index 3265cbc..f8dda98 100644
--- a/src/store/index.ts
+++ b/src/store/index.ts
@@ -2,45 +2,47 @@ import { createStore, ActionContext } from 'vuex';
import createPersistedState from 'vuex-persistedstate';
import { removeCookies } from '@/utils/cookie';
import { ENDPOINT } from '@/constants';
-
-export interface ISetting {
- stream?: boolean;
- endpoint?: string;
-}
-
-export interface IState {
- accessToken: string | undefined;
- setting: ISetting;
-}
+import { IApplication } from '@/operators';
+import { ISetting, IState, IToken } from './models';
const store = createStore({
state(): IState {
return {
- accessToken: undefined,
+ token: {
+ access: undefined,
+ refresh: undefined
+ },
setting: {
endpoint: ENDPOINT,
stream: false
- }
+ },
+ applications: []
};
},
mutations: {
- setAccessToken(state: IState, payload: string): void {
- state.accessToken = payload;
+ setToken(state: IState, payload: IToken): void {
+ state.token = {
+ ...state.token,
+ ...payload
+ };
},
setSetting(state: IState, payload: ISetting): void {
state.setting = {
...state.setting,
...payload
};
+ },
+ setApplications(state: IState, payload: IApplication[]): void {
+ state.applications = payload;
}
},
actions: {
- resetAuth({ commit }) {
- commit('setAccessToken', undefined);
+ resetToken({ commit }) {
+ commit('setToken', {});
removeCookies();
},
- setAccessToken({ commit }: ActionContext
, payload: string) {
- commit('setAccessToken', payload);
+ setToken({ commit }: ActionContext, payload: IToken) {
+ commit('setToken', payload);
},
setSetting({ commit }: ActionContext, payload: ISetting) {
commit('setSetting', payload);
@@ -48,13 +50,16 @@ const store = createStore({
},
getters: {
authenticated(state): boolean {
- return !!state.accessToken;
+ return !!state.token.access;
},
- accessToken(state): string | undefined {
- return state.accessToken;
+ token(state): IToken {
+ return state.token;
},
setting(state): ISetting | undefined {
return state.setting;
+ },
+ applications(state): IApplication[] | undefined {
+ return state.applications;
}
},
plugins: [createPersistedState()]
diff --git a/src/store/models.ts b/src/store/models.ts
new file mode 100644
index 0000000..79c65f7
--- /dev/null
+++ b/src/store/models.ts
@@ -0,0 +1,49 @@
+export interface IToken {
+ access?: string;
+ refresh?: string;
+}
+
+export interface ISetting {
+ stream?: boolean;
+ endpoint?: string;
+}
+
+export enum IApplicationType {
+ API = 'Api',
+ PROXY = 'Proxy'
+}
+
+export enum ICredentialType {
+ TOKEN = 'Token',
+ IDENTITY = 'Identity'
+}
+
+export interface ICredential {
+ type: ICredentialType;
+ name?: string;
+ token?: string;
+ username?: string;
+ password?: string;
+ created_at?: string;
+ updated_at?: string;
+}
+
+export interface IApplication {
+ id?: string;
+ type?: IApplicationType;
+ api_id?: string;
+ proxy_id?: string;
+ api_key?: string;
+ user_id?: string;
+ remaining_amount?: number;
+ used_amount?: number;
+ credential?: ICredential;
+ created_at?: string;
+ updated_at?: string;
+}
+
+export interface IState {
+ token: IToken;
+ setting: ISetting;
+ applications: IApplication[];
+}