refactor chat

This commit is contained in:
AceDataCloud committed 2023-12-30 15:23:03 +08:00
1 parent 565b367c59
commit cd5dbaa264
20 files changed
+192 -230

No files matched your search

@@ -71,25 +71,12 @@ import { defineComponent } from 'vue';
import { ElSkeleton, ElInput } from 'element-plus'; import { ElSkeleton, ElInput } from 'element-plus';
import { FontAwesomeIcon } from '@fortawesome/vue-fontawesome'; import { FontAwesomeIcon } from '@fortawesome/vue-fontawesome';
import { ROUTE_CHAT_CONVERSATION, ROUTE_CHAT_CONVERSATION_NEW } from '@/router/constants'; import { ROUTE_CHAT_CONVERSATION, ROUTE_CHAT_CONVERSATION_NEW } from '@/router/constants';
import { apiUsageOperator, IApplication, chatOperator, applicationOperator } from '@/operators'; import { IApplication, chatOperator } from '@/operators';
import { IChatConversation } from '@/operators/chat/models'; import { IChatConversation } from '@/operators/chat/models';
import { import { Status } from '@/store/common/models';
CHAT_MODEL_CHATGPT,
CHAT_MODEL_CHATGPT4,
CHAT_MODEL_CHATGPT4_BROWSING,
CHAT_MODEL_CHATGPT_16K,
CHAT_MODEL_CHATGPT_BROWSING
} from '@/operators';
interface IData {
initializing: boolean;
loading: boolean;
conversations: IChatConversation[] | undefined;
applications: IApplication[] | undefined;
}
export default defineComponent({ export default defineComponent({
name: 'Sidebar', name: 'SidePanel',
components: { components: {
ElInput, ElInput,
FontAwesomeIcon, FontAwesomeIcon,
@@ -97,24 +84,26 @@ export default defineComponent({
}, },
props: {}, props: {},
emits: ['click'], emits: ['click'],
data(): IData { computed: {
return { conversations() {
initializing: false, return this.$store.state.chat.conversations;
loading: false, },
conversations: undefined, applications() {
applications: undefined return this.$store.state.chat.applications;
}; },
}, loading() {
watch: { return this.$store.state.chat.getConversationsStatus === Status.Request;
applications(val) {
if (val) {
this.onFetchConversations();
}
} }
}, },
async mounted() { watch: {
await this.onFetchApplications(); applications: {
await this.onFetchConversations(); async handler(val: IApplication[]) {
if (!val) {
return;
}
await this.$store.dispatch('chat/getConversations');
}
}
}, },
methods: { methods: {
async onNewConversation() { async onNewConversation() {
@@ -122,53 +111,17 @@ export default defineComponent({
name: ROUTE_CHAT_CONVERSATION_NEW name: ROUTE_CHAT_CONVERSATION_NEW
}); });
}, },
async onFetchApplications() {
this.initializing = true;
const { data: applications } = await applicationOperator.getAll({
user_id: this.$store.state.common.user.id,
api_id: [
CHAT_MODEL_CHATGPT.apiId,
CHAT_MODEL_CHATGPT_16K.apiId,
CHAT_MODEL_CHATGPT_BROWSING.apiId,
CHAT_MODEL_CHATGPT4.apiId,
CHAT_MODEL_CHATGPT4_BROWSING.apiId
]
});
this.initializing = false;
this.applications = applications?.items;
},
async onConfirm(conversation: IChatConversation) { async onConfirm(conversation: IChatConversation) {
if (conversation?.deleting) { if (conversation?.deleting) {
await chatOperator.deleteConversation(conversation.id); await chatOperator.deleteConversation(conversation.id);
await this.onFetchConversations(); await this.$store.dispatch('chat/getConversations');
} else if (conversation?.editing) { } else if (conversation?.editing) {
await chatOperator.updateConversation(conversation); await chatOperator.updateConversation(conversation);
this.onFetchConversations(); await this.$store.dispatch('chat/getConversations');
} else { } else {
conversation.editing = true; conversation.editing = true;
} }
}, },
async onFetchConversations() {
this.loading = true;
const {
data: { items: apiUsages }
} = await apiUsageOperator.getAll({
user_id: this.$store.state.common.user.id,
// @ts-ignore
application_id: this.applications?.map((application) => application.id),
offset: 0,
limit: 30,
ordering: '-created_at'
});
this.loading = false;
// de duplicate conversations using id
const conversationIds: string[] = apiUsages
.map((apiUsage) => apiUsage.metadata?.conversation_id)
.filter((id) => id);
const uniqueConversationIds = [...new Set(conversationIds)];
const conversations = (await chatOperator.getConversations(uniqueConversationIds)).data;
this.conversations = conversations;
},
onClick(id: string) { onClick(id: string) {
if (!id) { if (!id) {
return; return;
@@ -191,8 +144,13 @@ export default defineComponent({
flex-direction: column; flex-direction: column;
align-items: flex-end; align-items: flex-end;
padding: 15px; padding: 15px;
width: 300px;
height: 100%;
border-right: 1px solid #eee;
overflow-y: scroll;
.conversations { .conversations {
flex: 1; width: 100%;
display: flex; display: flex;
flex-direction: column; flex-direction: column;
align-items: center; align-items: center;
+1 -1
View File
@@ -50,7 +50,7 @@ export default defineComponent({
computed: { computed: {
headers() { headers() {
return { return {
Authorization: `Bearer ${this.$store.state.common.token.access}` Authorization: `Bearer ${this.$store.state.token.access}`
}; };
}, },
urls() { urls() {
@@ -79,7 +79,7 @@ export default defineComponent({
const { const {
data: { items: apiUsages } data: { items: apiUsages }
} = await apiUsageOperator.getAll({ } = await apiUsageOperator.getAll({
user_id: this.$store.state.common.user.id, user_id: this.$store.state.user.id,
application_id: this.applications?.map((application) => application.id), application_id: this.applications?.map((application) => application.id),
offset: 0, offset: 0,
limit: 5, limit: 5,
@@ -116,7 +116,7 @@ export default defineComponent({
const { const {
data: { items: apiUsages, count } data: { items: apiUsages, count }
} = await apiUsageOperator.getAll({ } = await apiUsageOperator.getAll({
user_id: this.$store.state.common.user.id, user_id: this.$store.state.user.id,
application_id: this.applications?.map((application) => application.id), application_id: this.applications?.map((application) => application.id),
offset: (this.page - 1) * this.limit, offset: (this.page - 1) * this.limit,
limit: this.limit, limit: this.limit,
+6 -65
View File
@@ -4,7 +4,7 @@
<navigator /> <navigator />
</div> </div>
<div class="main"> <div class="main">
<sidebar class="sidebar" /> <side-panel />
<router-view /> <router-view />
</div> </div>
</div> </div>
@@ -13,68 +13,17 @@
<script lang="ts"> <script lang="ts">
import { defineComponent } from 'vue'; import { defineComponent } from 'vue';
import Navigator from '@/components/common/Navigator.vue'; import Navigator from '@/components/common/Navigator.vue';
import Sidebar from '@/components/chat/Sidebar.vue'; import SidePanel from '@/components/chat/SidePanel.vue';
import {
CHAT_MODEL_CHATGPT,
CHAT_MODEL_CHATGPT4,
CHAT_MODEL_CHATGPT4_BROWSING,
CHAT_MODEL_CHATGPT_16K,
CHAT_MODEL_CHATGPT_BROWSING,
applicationOperator
} from '@/operators';
export default defineComponent({ export default defineComponent({
name: 'LayoutChat', name: 'LayoutChat',
components: { components: {
Sidebar, SidePanel,
Navigator Navigator
}, },
data() { async mounted() {
return { await this.$store.dispatch('chat/getApplications');
initializing: false, await this.$store.dispatch('chat/getConversations');
applications: this.$store.state.chat.applications || undefined
};
},
mounted() {
this.onFetchApplications();
},
methods: {
async onFetchConversations() {
this.loading = true;
const {
data: { items: apiUsages }
} = await apiUsageOperator.getAll({
user_id: this.$store.state.common.user.id,
// @ts-ignore
application_id: this.applications?.map((application) => application.id),
offset: 0,
limit: 30,
ordering: '-created_at'
});
this.loading = false;
// de duplicate conversations using id
const conversationIds: string[] = apiUsages
.map((apiUsage) => apiUsage.metadata?.conversation_id)
.filter((id) => id);
const uniqueConversationIds = [...new Set(conversationIds)];
const conversations = (await chatOperator.getConversations(uniqueConversationIds)).data;
this.conversations = conversations;
},
async onFetchApplications() {
this.initializing = true;
const { data: applications } = await applicationOperator.getAll({
user_id: this.$store.state.common.user.id,
api_id: [
CHAT_MODEL_CHATGPT.apiId,
CHAT_MODEL_CHATGPT_16K.apiId,
CHAT_MODEL_CHATGPT_BROWSING.apiId,
CHAT_MODEL_CHATGPT4.apiId,
CHAT_MODEL_CHATGPT4_BROWSING.apiId
]
});
this.initializing = false;
this.$store.dispatch('chat/setApplications', applications?.items);
}
} }
}); });
</script> </script>
@@ -97,14 +46,6 @@ export default defineComponent({
height: 100%; height: 100%;
display: flex; display: flex;
flex-direction: row; flex-direction: row;
.sidebar {
display: block;
width: 300px;
height: 100%;
border-right: 1px solid #eee;
overflow-y: scroll;
}
} }
} }
</style> </style>
+2 -1
View File
@@ -15,7 +15,8 @@ const httpClient: AxiosInstance = axios.create({
}); });
httpClient.interceptors.request.use((config) => { httpClient.interceptors.request.use((config) => {
const accessToken = store.state.common.token?.access; console.log('store', store.state);
const accessToken = store.state.token?.access;
if (!config.headers) { if (!config.headers) {
config.headers = {}; config.headers = {};
} }
+17 -33
View File
@@ -1,14 +1,15 @@
<script lang="ts"> <script lang="ts">
import { defineComponent } from 'vue'; import { defineComponent } from 'vue';
import { getAuthBaseUrl, getHubBaseUrl } from '@/utils'; import { IUser } from '@/operators';
import { oauthOperator } from '@/operators/auth/operator'; import { IToken } from '@/operators/auth/models';
import { applicationOperator, userOperator } from '@/operators'; import { ROUTE_AUTH_LOGIN } from '@/router';
interface IData { interface IData {
accessToken: string | undefined; accessToken: string | undefined;
refreshToken: string | undefined; refreshToken: string | undefined;
redirect: string | undefined; redirect: string | undefined;
code: string | undefined; code: string | undefined;
user: IUser | undefined;
} }
export default defineComponent({ export default defineComponent({
@@ -18,46 +19,29 @@ export default defineComponent({
accessToken: undefined, accessToken: undefined,
refreshToken: undefined, refreshToken: undefined,
redirect: this.$route.query.redirect?.toString(), redirect: this.$route.query.redirect?.toString(),
code: this.$route.query.code?.toString() code: this.$route.query.code?.toString(),
user: undefined
}; };
}, },
async mounted() { async mounted() {
// if auth code is provided, get token via oauth
if (this.code) { if (this.code) {
console.debug('code found, try to get tokens'); const data: IToken = await this.$store.dispatch('getToken', this.code);
const { data } = await oauthOperator.token({ this.accessToken = data.access;
code: this.code this.refreshToken = data.refresh;
}); } else {
this.accessToken = data.access_token; this.$router.push({ name: ROUTE_AUTH_LOGIN });
this.refreshToken = data.refresh_token; return;
console.debug('get tokens successfully');
} }
// if token acquired, get user info
if (this.accessToken && this.refreshToken) { if (this.accessToken && this.refreshToken) {
// store token to global store const user = await this.$store.dispatch('getUser');
await this.$store.dispatch('common/setToken', { this.user = user;
refresh: this.refreshToken,
access: this.accessToken
});
console.debug('set token successfully');
const { data: user } = await userOperator.getMe();
await this.$store.dispatch('common/setUser', user);
console.debug('set user successfully');
const { data: applications } = await applicationOperator.getAll({
user_id: user.id
});
await this.$store.dispatch('common/setApplications', applications);
console.debug('set applications successfully');
if (this.redirect) { if (this.redirect) {
this.$router.push(this.redirect); this.$router.push(this.redirect);
} }
} else { } else {
console.debug('access token and refresh token not found, try to re-auth again'); this.$router.push({ name: ROUTE_AUTH_LOGIN });
const hubBaseUrl = getHubBaseUrl();
const authBaseUrl = getAuthBaseUrl();
// callback url used to init access token and then redirect back of `redirect`
const callbackUrl = `${hubBaseUrl}/auth/callback?redirect=${this.redirect}`;
// redirect to auth service to get access token then redirect back
const targetUrl = `${authBaseUrl}/auth/login?redirect=${callbackUrl}`;
window.location.href = targetUrl;
} }
} }
}); });
+7 -26
View File
@@ -5,7 +5,7 @@
:initializing="initializing" :initializing="initializing"
:application="application" :application="application"
:api-id="model.apiId" :api-id="model.apiId"
@refresh="onFetchApplications" @refresh="$store.dispatch('chat/getApplications')"
/> />
<div class="dialogue"> <div class="dialogue">
<introduction v-if="messages && messages.length === 0" /> <introduction v-if="messages && messages.length === 0" />
@@ -33,10 +33,6 @@ import {
IApplication, IApplication,
IChatMessageState, IChatMessageState,
IChatAskResponse, IChatAskResponse,
CHAT_MODEL_CHATGPT_16K,
CHAT_MODEL_CHATGPT_BROWSING,
CHAT_MODEL_CHATGPT4,
CHAT_MODEL_CHATGPT4_BROWSING,
chatOperator chatOperator
} from '@/operators'; } from '@/operators';
import InputBox from '@/components/chat/InputBox.vue'; import InputBox from '@/components/chat/InputBox.vue';
@@ -48,7 +44,6 @@ import { ROUTE_CHAT_CONVERSATION, ROUTE_CHAT_CONVERSATION_NEW } from '@/router';
export interface IData { export interface IData {
messages: IChatMessage[]; messages: IChatMessage[];
model: IChatModel; model: IChatModel;
applications: IApplication[] | undefined;
question: ''; question: '';
initializing: boolean; initializing: boolean;
applied: boolean | undefined; applied: boolean | undefined;
@@ -68,7 +63,6 @@ export default defineComponent({
question: '', question: '',
initializing: false, initializing: false,
applied: undefined, applied: undefined,
applications: undefined,
messages: [] messages: []
}; };
}, },
@@ -77,7 +71,10 @@ export default defineComponent({
return this.$route.params.id?.toString(); return this.$route.params.id?.toString();
}, },
application() { application() {
return this.applications?.find((application) => application.api?.id === this.model.apiId); return this.applications?.find((application: IApplication) => application.api?.id === this.model.apiId);
},
applications() {
return this.$store.state.chat.applications;
} }
}, },
watch: { watch: {
@@ -88,7 +85,6 @@ export default defineComponent({
} }
}, },
async mounted() { async mounted() {
await this.onFetchApplications();
await this.onFetchHistory(); await this.onFetchHistory();
}, },
methods: { methods: {
@@ -100,22 +96,7 @@ export default defineComponent({
}, },
async onSelectModel() { async onSelectModel() {
await this.onCreateNewConversation(); await this.onCreateNewConversation();
await this.onFetchApplications(); await this.$store.dispatch('chat/getApplications');
},
async onFetchApplications() {
this.initializing = true;
const { data: applications } = await applicationOperator.getAll({
user_id: this.$store.state.common.user.id,
api_id: [
CHAT_MODEL_CHATGPT.apiId,
CHAT_MODEL_CHATGPT_16K.apiId,
CHAT_MODEL_CHATGPT_BROWSING.apiId,
CHAT_MODEL_CHATGPT4.apiId,
CHAT_MODEL_CHATGPT4_BROWSING.apiId
]
});
this.initializing = false;
this.applications = applications?.items;
}, },
async onSubmitQuestion() { async onSubmitQuestion() {
this.messages.push({ this.messages.push({
@@ -174,7 +155,7 @@ export default defineComponent({
) )
.then(() => { .then(() => {
this.messages[this.messages.length - 1].state = IChatMessageState.FINISHED; this.messages[this.messages.length - 1].state = IChatMessageState.FINISHED;
this.onFetchApplications(); this.$store.dispatch('chat/getConversations');
}) })
.catch((error) => { .catch((error) => {
if (this.messages && this.messages.length > 0) { if (this.messages && this.messages.length > 0) {
+1 -1
View File
@@ -103,7 +103,7 @@ export default defineComponent({
async onFetchApplications() { async onFetchApplications() {
this.initializing = true; this.initializing = true;
const { data: applications } = await applicationOperator.getAll({ const { data: applications } = await applicationOperator.getAll({
user_id: this.$store.state.common.user.id, user_id: this.$store.state.user.id,
api_id: [MIDJOURNEY_CHANNEL_FAST.apiId, MIDJOURNEY_CHANNEL_RELAX.apiId, MIDJOURNEY_CHANNEL_TURBO.apiId] api_id: [MIDJOURNEY_CHANNEL_FAST.apiId, MIDJOURNEY_CHANNEL_RELAX.apiId, MIDJOURNEY_CHANNEL_TURBO.apiId]
}); });
this.initializing = false; this.initializing = false;
+1 -1
View File
@@ -177,7 +177,7 @@ export default defineComponent({
async onFetchApplications() { async onFetchApplications() {
this.initializing = true; this.initializing = true;
const { data: applications } = await applicationOperator.getAll({ const { data: applications } = await applicationOperator.getAll({
user_id: this.$store.state.common.user.id, user_id: this.$store.state.user.id,
api_id: [MIDJOURNEY_CHANNEL_FAST.apiId, MIDJOURNEY_CHANNEL_RELAX.apiId, MIDJOURNEY_CHANNEL_TURBO.apiId] api_id: [MIDJOURNEY_CHANNEL_FAST.apiId, MIDJOURNEY_CHANNEL_RELAX.apiId, MIDJOURNEY_CHANNEL_TURBO.apiId]
}); });
this.initializing = false; this.initializing = false;
+71 -3
View File
@@ -1,9 +1,77 @@
import { IApplication } from '@/operators'; import {
CHAT_MODEL_CHATGPT,
CHAT_MODEL_CHATGPT4,
CHAT_MODEL_CHATGPT4_BROWSING,
CHAT_MODEL_CHATGPT_16K,
CHAT_MODEL_CHATGPT_BROWSING,
IApplication,
IChatConversation,
apiUsageOperator,
applicationOperator,
chatOperator
} from '@/operators';
import { IRootState, Status } from '../common/models';
import { ActionContext } from 'vuex';
import { log } from '@/utils/log';
import { IChatState } from './models';
export const setApplications = async ({ commit }: any, payload: IApplication[]) => { export const setApplications = async ({ commit }: any, payload: IApplication[]): Promise<void> => {
commit('setApplications', payload); commit('setApplications', payload);
}; };
export const getApplications = async ({
commit,
rootState
}: ActionContext<IChatState, IRootState>): Promise<IApplication[]> => {
log(getApplications, 'start to get application for chat');
commit('getApplicationsStatus', Status.Request);
const { data: applications } = await applicationOperator.getAll({
user_id: rootState.user.id,
api_id: [
CHAT_MODEL_CHATGPT.apiId,
CHAT_MODEL_CHATGPT_16K.apiId,
CHAT_MODEL_CHATGPT_BROWSING.apiId,
CHAT_MODEL_CHATGPT4.apiId,
CHAT_MODEL_CHATGPT4_BROWSING.apiId
]
});
log(getApplications, 'get application for chat success', applications);
commit('getApplicationsStatus', Status.Success);
commit('setApplications', applications?.items);
return applications.items;
};
export const getConversations = async ({
commit,
state,
rootState
}: ActionContext<IChatState, IRootState>): Promise<IChatConversation[]> => {
log(getConversations, 'start to get conversations');
commit('setGetConversationStatus', Status.Success);
const {
data: { items: apiUsages }
} = await apiUsageOperator.getAll({
user_id: rootState.user.id,
// @ts-ignore
application_id: state.applications?.map((application) => application.id),
offset: 0,
limit: 30,
ordering: '-created_at'
});
log(getConversations, 'get api usages success', apiUsages);
commit('setGetConversationStatus', Status.Success);
// de duplicate conversations using id
const conversationIds: string[] = apiUsages.map((apiUsage) => apiUsage.metadata?.conversation_id).filter((id) => id);
const uniqueConversationIds = [...new Set(conversationIds)];
log(getConversations, 'get unique conversation ids', uniqueConversationIds);
const conversations = (await chatOperator.getConversations(uniqueConversationIds)).data;
log(getConversations, 'get conversations success', conversations);
commit('setConversations', conversations);
return conversations;
};
export default { export default {
setApplications setApplications,
getApplications,
getConversations
}; };
+4 -2
View File
@@ -1,7 +1,9 @@
import { IApplication } from '@/operators'; import { IApplication, IChatConversation } from '@/operators';
import { Status } from '../common/models'; import { Status } from '../common/models';
export interface IChatState { export interface IChatState {
applications: IApplication[] | undefined; applications: IApplication[] | undefined;
applicationsStatus: Status | undefined; getApplicationsStatus: Status | undefined;
conversations: IChatConversation[] | undefined;
getConversationsStatus: Status | undefined;
} }
+13 -3
View File
@@ -6,11 +6,21 @@ export const setApplications = (state: IChatState, payload: IApplication[]): voi
state.applications = payload; state.applications = payload;
}; };
export const setApplicationsStatus = (state: IChatState, payload: Status): void => { export const setGetApplicationsStatus = (state: IChatState, payload: Status): void => {
state.applicationsStatus = payload; state.getApplicationsStatus = payload;
};
export const setConversations = (state: IChatState, payload: any): void => {
state.conversations = payload;
};
export const setGetConversationsStatus = (state: IChatState, payload: Status): void => {
state.getConversationsStatus = payload;
}; };
export default { export default {
setApplications, setApplications,
setApplicationsStatus setGetApplicationsStatus,
setConversations,
setGetConversationsStatus
}; };
+3 -1
View File
@@ -3,6 +3,8 @@ import { IChatState } from './models';
export default (): IChatState => { export default (): IChatState => {
return { return {
applications: undefined, applications: undefined,
applicationsStatus: undefined getApplicationsStatus: undefined,
conversations: undefined,
getConversationsStatus: undefined
}; };
}; };
+26 -4
View File
@@ -1,6 +1,8 @@
import { ActionContext } from 'vuex'; import { ActionContext } from 'vuex';
import { IRootState, IToken } from '../common/models'; import { IRootState, IToken } from '../common/models';
import { IApplication, IUser } from '@/operators'; import { IApplication, IUser, userOperator } from '@/operators';
import { log } from '@/utils/log';
import { oauthOperator } from '@/operators/auth/operator';
export const resetToken = ({ commit }: ActionContext<IRootState, IRootState>) => { export const resetToken = ({ commit }: ActionContext<IRootState, IRootState>) => {
commit('resetToken'); commit('resetToken');
@@ -14,13 +16,33 @@ export const setUser = ({ commit }: ActionContext<IRootState, IRootState>, paylo
commit('setUser', payload); commit('setUser', payload);
}; };
export const setApplications = ({ commit }: ActionContext<IRootState, IRootState>, payload: IApplication[]) => { export const getUser = async ({ commit }: ActionContext<IRootState, IRootState>): Promise<IUser> => {
commit('setApplications', payload); log(getUser, 'start to get user');
const { data: user } = await userOperator.getMe();
commit('setUser', user);
log(getUser, 'get user success', user);
return user;
};
export const getToken = async ({ commit }: ActionContext<IRootState, IRootState>, code: string): Promise<IToken> => {
log(getToken, 'start to get token using code', code);
const { data } = await oauthOperator.token({
code
});
const token = {
access: data.access_token,
refresh: data.refresh_token,
expiration: data.expires_in
};
commit('setToken', token);
log(getToken, 'get token success', data);
return token;
}; };
export default { export default {
resetToken, resetToken,
setToken, setToken,
setUser, setUser,
setApplications getToken,
getUser
}; };
+1 -6
View File
@@ -16,14 +16,9 @@ export const setting = (state: IRootState): any => {
return state.setting; return state.setting;
}; };
export const applications = (state: IRootState): any => {
return state.applications;
};
export default { export default {
authenticated, authenticated,
user, user,
token, token,
setting, setting
applications
}; };
+1 -1
View File
@@ -11,6 +11,7 @@ export enum Status {
export interface IToken { export interface IToken {
access?: string; access?: string;
refresh?: string; refresh?: string;
expiration?: number;
} }
export interface ISetting { export interface ISetting {
@@ -22,7 +23,6 @@ export interface ICommonState {
token: IToken; token: IToken;
user: IUser; user: IUser;
setting: ISetting; setting: ISetting;
applications: IApplication[] | undefined;
} }
export interface IRootState extends ICommonState { export interface IRootState extends ICommonState {
+1 -6
View File
@@ -26,14 +26,9 @@ export const setSetting = (state: IRootState, payload: any): void => {
}; };
}; };
export const setApplications = (state: IRootState, payload: any): void => {
state.applications = payload;
};
export default { export default {
setUser, setUser,
setToken, setToken,
resetToken, resetToken,
setSetting, setSetting
setApplications
}; };
+3 -3
View File
@@ -6,12 +6,12 @@ export default (): IRootState => {
user: {}, user: {},
token: { token: {
access: undefined, access: undefined,
refresh: undefined refresh: undefined,
expiration: undefined
}, },
setting: { setting: {
endpoint: ENDPOINT, endpoint: ENDPOINT,
stream: false stream: false
}, }
applications: undefined
}; };
}; };
+3
View File
@@ -0,0 +1,3 @@
export const log = (func: Function, ...arg: any) => {
console.debug(`${func.name}`, ...arg);
};