-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: 组织初始化 & 课程选择 feat: 调试backend接口 feat: 新增我的页面
- Loading branch information
Showing
57 changed files
with
1,276 additions
and
556 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export * from './runtime-model' | ||
export * from './system-model' | ||
export * from './userinfo-model' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import { createModel } from '@rematch/core' | ||
import { RootModel } from 'src/models' | ||
import { getStorage, setStorage } from '../utils/storage' | ||
|
||
type TOrganizationCache = { | ||
/** 所属组织 */ | ||
orgId?: number | ||
orgName?: string | ||
gradeId?: number | ||
gradeName?: string | ||
classId?: number | ||
className?: string | ||
courseIds?: number[] | ||
} | ||
/** 系统运行所需全局缓存 */ | ||
export interface IRuntimeCache { | ||
organizationCache: TOrganizationCache | ||
} | ||
|
||
/** 默认store值 从storage中激活 */ | ||
export const defaultRuntimeValue: IRuntimeCache = { | ||
organizationCache: getStorage('runtimeCache').organizationCache || {}, | ||
} | ||
|
||
export const runtimeModel = createModel<RootModel>()({ | ||
state: defaultRuntimeValue, | ||
reducers: { | ||
writeOrgCache( | ||
state: IRuntimeCache, | ||
newCache: Partial<TOrganizationCache>, | ||
needLasting?: boolean, | ||
) { | ||
state.organizationCache = newCache | ||
state.organizationCache = Object.assign({}, state.organizationCache, newCache) | ||
if (needLasting) { | ||
setStorage('runtimeCache', state) | ||
} | ||
return state | ||
}, | ||
}, | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import { createModel } from '@rematch/core' | ||
import { RootModel } from 'src/models' | ||
|
||
/** 系统运行所需全局缓存 */ | ||
export interface ISystemInfo { | ||
/** session状态 */ | ||
sessionStatus?: string | ||
/** 冷启动初始化是否完成 */ | ||
coldStartSuccess?: boolean | ||
/** 是否完善用户信息 */ | ||
hasAccountCompleted?: boolean | ||
/** 是否弹过授权弹窗 */ | ||
isAuthorizeSubscribePop?: boolean | ||
} | ||
|
||
/** 默认store值 从storage中激活 */ | ||
export const defaultSystemValue: ISystemInfo = { | ||
coldStartSuccess: false, | ||
hasAccountCompleted: false, | ||
isAuthorizeSubscribePop: false, | ||
} | ||
|
||
export const systemModel = createModel<RootModel>()({ | ||
state: defaultSystemValue, | ||
reducers: { | ||
update_SystemInfo: (state: ISystemInfo, newSystemInfo: Partial<ISystemInfo>) => { | ||
state = Object.assign({}, state, newSystemInfo) | ||
return state | ||
}, | ||
}, | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import { createModel } from '@rematch/core' | ||
import { RootModel } from 'src/models' | ||
import { IStudentStruct } from 'src/types' | ||
import { getStorage, setStorage } from '../utils/storage' | ||
|
||
/** TODO: 用户信息需要确定好内容 */ | ||
export interface IUserInfo extends IStudentStruct { | ||
/** 鉴权 */ | ||
token?: string | ||
} | ||
|
||
/** 默认store值 从storage中激活 */ | ||
export const defaultUserinfoValue: Partial<IUserInfo> = { | ||
...(getStorage('userInfo') || {}), | ||
} | ||
|
||
export const userinfoModel = createModel<RootModel>()({ | ||
state: defaultUserinfoValue, | ||
reducers: { | ||
update_UserInfo: (state: IUserInfo, newUserinfo: Partial<IUserInfo>) => { | ||
state = Object.assign({}, state, newUserinfo) | ||
setStorage('userInfo', state) | ||
return state | ||
}, | ||
}, | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,14 @@ | ||
import { Models } from '@rematch/core' | ||
import { common } from './common-model' | ||
import { userinfoModel, systemModel, runtimeModel } from './model' | ||
|
||
export interface RootModel extends Models<RootModel> { | ||
common: typeof common | ||
userinfoModel: typeof userinfoModel | ||
systemModel: typeof systemModel | ||
runtimeModel: typeof runtimeModel | ||
} | ||
|
||
export const models: RootModel = { | ||
common, | ||
userinfoModel, | ||
systemModel, | ||
runtimeModel, | ||
} |
Oops, something went wrong.