diff --git a/src/components/Common/GlobalComps/typeIcon.tsx b/src/components/Common/GlobalComps/typeIcon.tsx index 7e1e3165ed75d6cb11f670cc33d7d04c374087e2..483f191f41b20a0a1b0bc280c98acee95ec14b5a 100644 --- a/src/components/Common/GlobalComps/typeIcon.tsx +++ b/src/components/Common/GlobalComps/typeIcon.tsx @@ -41,7 +41,7 @@ const TypeIcon = ({ avatar, iconType, size }: TypeIconInfo) => { case '动态': return ; case '目录': - return ; + return ; case '成员目录': return ; case '标准': diff --git a/src/components/Common/SegmentContent/index.tsx b/src/components/Common/SegmentContent/index.tsx index 2573bf8f34c4af5dd928daae7229925b0090a44e..d0655047d918ac1a22a151344b42cc8c19b85691 100644 --- a/src/components/Common/SegmentContent/index.tsx +++ b/src/components/Common/SegmentContent/index.tsx @@ -10,6 +10,7 @@ type segmentedTypes = 'icon' | 'table' | 'list'; interface IProps { height?: number | string; descriptions: string; + hiddenSegment?: Boolean; children?: React.ReactNode; // 子组件 onSegmentChanged: (type: segmentedTypes) => void; } @@ -20,6 +21,7 @@ const SegmentContent: React.FC = ({ height, children, descriptions, + hiddenSegment, onSegmentChanged, }: IProps) => { const [segmented, setSegmented] = useStorage('segmented', 'list'); @@ -30,44 +32,46 @@ const SegmentContent: React.FC = ({
{children && children}
- - { - setSegmented(value as segmentedTypes); - onSegmentChanged(value as segmentedTypes); - }} - options={[ - { - value: 'list', - icon: ( - - ), - }, - { - value: 'icon', - icon: ( - - ), - }, - // { - // value: 'table', - // icon: ( - // - // ), - // }, - ]} - /> - + {!hiddenSegment && ( + + { + setSegmented(value as segmentedTypes); + onSegmentChanged(value as segmentedTypes); + }} + options={[ + { + value: 'list', + icon: ( + + ), + }, + { + value: 'icon', + icon: ( + + ), + }, + // { + // value: 'table', + // icon: ( + // + // ), + // }, + ]} + /> + + )} }> {descriptions} diff --git a/src/components/Directory/index.tsx b/src/components/Directory/index.tsx index d0ed2a51592d7aff819e911cab64b6e8d31ee7f7..afcffcdf2dd55be5822689933fe0e4d4715d20c9 100644 --- a/src/components/Directory/index.tsx +++ b/src/components/Directory/index.tsx @@ -9,7 +9,11 @@ import { cleanMenus } from '@/utils/tools'; * @description: 默认目录 * @return {*} */ -const Directory: React.FC<{ root: IFile }> = ({ root }) => { +const Directory: React.FC<{ + root: IFile; + isStore?: boolean; + isSidebar?: boolean; +}> = ({ root, isStore, isSidebar }) => { const [currentTag, setCurrentTag] = useState('全部'); const [preDirectory, setPreDirectory] = useState(); const [directory, setDirectory] = useState(root); @@ -35,7 +39,7 @@ const Directory: React.FC<{ root: IFile }> = ({ root }) => { file.loadContent(reload).then(() => { if (file.key === directory.key) { setCurrentTag('全部'); - setContent(directory.content()); + setContent(directory.content(isStore, isSidebar)); } setLoaded(true); }); diff --git a/src/components/Directory/views/index.tsx b/src/components/Directory/views/index.tsx index 841b46c283114cf263a851e44de332ef15ad0475..71494f442fe7306689c40b22e78a7ffd77f86f42 100644 --- a/src/components/Directory/views/index.tsx +++ b/src/components/Directory/views/index.tsx @@ -21,6 +21,7 @@ interface IProps { focusFile?: IDEntity; rightBars?: ReactNode; height?: number | string; + hiddenSegment?: boolean; currentTag: string; badgeCount?: (tag: string) => number; tagChanged?: (tag: string) => void; @@ -114,6 +115,7 @@ const DirectoryView: React.FC = (props) => { onChanged={(t) => props.tagChanged && props.tagChanged(t)}> {segmented === 'icon' ? ( diff --git a/src/components/MainLayout/preview/index.tsx b/src/components/MainLayout/preview/index.tsx index 2098b2017b6668e8c7a6030b7724b6824de60926..692658f3fe07dcdff811cf744c2f7d034c5bd22d 100644 --- a/src/components/MainLayout/preview/index.tsx +++ b/src/components/MainLayout/preview/index.tsx @@ -2,6 +2,7 @@ import ImageView from './image'; import VideoView from './video'; import { IEntity, + IFile, IForm, ISession, ISysFileInfo, @@ -68,8 +69,12 @@ const EntityPreview: React.FC<{ flag?: string }> = (props) => { }; }, [props]); - const renderEntityBody = (entity: any, children?: React.ReactNode) => { - return {children && children}; + const renderEntityBody = (entity: any, children?: React.ReactNode, actions?: any[]) => { + return ( + + {children && children} + + ); }; if (entity && typeof entity != 'string') { @@ -126,6 +131,29 @@ const EntityPreview: React.FC<{ flag?: string }> = (props) => { return ; } } + //数据查看 + if (location.hash.startsWith('#/store')) { + console.log('数据查看选择内容', entity); + return renderEntityBody( + entity, + , + [ + { + key: 'activity', + label: '动态', + }, + { + key: 'store', + label: '数据', + }, + { + key: 'relation', + label: '关系', + }, + ], + ); + } + return renderEntityBody(entity); } return <>; diff --git a/src/executor/action.tsx b/src/executor/action.tsx index a0124c4c557bef9081638f995cd97d84dda78e6b..82f65dd67c640c729a632aee194ee276a11f4114 100644 --- a/src/executor/action.tsx +++ b/src/executor/action.tsx @@ -71,6 +71,8 @@ export const executeCmd = (cmd: string, entity: any) => { return onlineChanged(cmd, entity); case 'activate': return activateStorage(entity); + case 'checkDirectory': + return checkDirectory(entity); case 'hslSplit': return videoHslSplit(entity); case 'removeSession': @@ -98,7 +100,10 @@ const directoryRefresh = (dir: IDirectory | IApplication, reload: boolean) => { const activateStorage = (store: IStorage) => { store.activateStorage(); }; - +/** 初始化存储 */ +const checkDirectory = (store: IStorage) => { + store.checkDirectory(); +}; /** 视频切片 */ const videoHslSplit = (file: ISysFileInfo) => { const modal = Modal.confirm({ diff --git a/src/pages/Store/index.tsx b/src/pages/Store/index.tsx index 63399d64b75949f34feedfa54eaac8b64e7784d9..8703adfca2378d5654aaba388d0418b7cff3da8a 100644 --- a/src/pages/Store/index.tsx +++ b/src/pages/Store/index.tsx @@ -51,7 +51,7 @@ const FileBrowser: React.FC = () => { if (current === 'disk') { contents.push(orgCtrl.user, ...orgCtrl.user.companys); } else { - contents.push(...current.content()); + contents.push(...current.content(true)); } return contents; }; @@ -64,7 +64,7 @@ const FileBrowser: React.FC = () => { type="link" title="返回" icon={} - onClick={() => setCurrent(current.superior as ITarget)} + onClick={() => setCurrent((current.superior as ITarget) ?? 'disk')} /> )} {current != 'disk' ? ( @@ -90,6 +90,7 @@ const FileBrowser: React.FC = () => { initTags={['全部']} selectFiles={[]} extraTags={true} + hiddenSegment focusFile={focusFile} content={getContent()} currentTag={currentTag} diff --git a/src/ts/base/model.ts b/src/ts/base/model.ts index 07ebf3d852ed167eb8dd3d7762ffb14f8496bb7a..f1defc45cb9ffe8d344ed34070f01688cc017094 100644 --- a/src/ts/base/model.ts +++ b/src/ts/base/model.ts @@ -1496,3 +1496,33 @@ export type DiskInfoType = { // 查询时间 getTime: string; }; + +// 草稿 +export type DraftsType = { + // 数据 + typeName: string; + // 关系 + relations: string; + // 办事id + workId: string; + // 备注信息 + contentText: string; + // 办事名称 + name?: string; + // 节点信息 + data: model.InstanceDataModel; +} & Xbase; + +// 标准目录 +export type StandardDirectoryType = { + // 目录名称 + name: string; + // 目录编码 + code: string; + // 排序 + sort: number; + // 内容支持类型 + accept?: string[]; + // 子级目录 + children?: StandardDirectoryType[]; +}; diff --git a/src/ts/base/schema.ts b/src/ts/base/schema.ts index 60809f16358486de9bf0362bb6ea12d8e0a82f2d..739a9822fa21fa76edadb3f4ea761ae921d5e0df 100644 --- a/src/ts/base/schema.ts +++ b/src/ts/base/schema.ts @@ -177,6 +177,10 @@ export type XAuthority = { export type XDirectory = { // 共享用户ID shareId: string; + // 目录支持类型 + accept?: string[]; + // 目录排序标识 + sort?: number; // 目录下的属性 propertys: XProperty[] | undefined; // 目录下的单 diff --git a/src/ts/core/public/consts.ts b/src/ts/core/public/consts.ts index a96955143dce17966fa45616cf5ee21d2024cd82..7d924cdb6f795df4c801cc4816bc2deaf684d2b4 100644 --- a/src/ts/core/public/consts.ts +++ b/src/ts/core/public/consts.ts @@ -1,5 +1,5 @@ -import { PageModel } from '../../base/model'; -import { TargetType, ValueType } from './enums'; +import { PageModel, StandardDirectoryType } from '../../base/model'; +import { DirectoryType, TargetType, ValueType } from './enums'; /** 资产共享云模块权限Id */ export const orgAuth = { @@ -47,6 +47,65 @@ export const PageAll: PageModel = { limit: (2 << 15) - 1, //ushort.max filter: '', }; +/** 固定标准目录 */ +export const StandardDirectory: StandardDirectoryType[] = [ + { + name: DirectoryType.DataStandard, + code: 'standardData', + sort: 1, + accept: [DirectoryType.Attribute, DirectoryType.Dict, DirectoryType.Species], + children: [ + { + name: DirectoryType.Attribute, + code: 'standardAttribute', + sort: 1, + }, + { + name: DirectoryType.Dict, + code: 'standardDict', + sort: 2, + }, + { name: DirectoryType.Species, code: 'standardSpecies', sort: 3 }, + ], + }, + { + name: DirectoryType.Model, + code: 'standardModel', + sort: 2, + accept: [ + DirectoryType.Form, + DirectoryType.Report, + DirectoryType.Transfer, + DirectoryType.PageTemplate, + ], + children: [ + { + name: DirectoryType.Form, + code: 'standardForm', + sort: 1, + }, + { + name: DirectoryType.Report, + code: 'standardReport', + sort: 2, + }, + { + name: DirectoryType.Transfer, + code: 'standardTransfer', + sort: 3, + }, + { + name: DirectoryType.PageTemplate, + code: 'standardPageTemplate', + sort: 4, + }, + ], + }, + { name: DirectoryType.App, code: 'standardApp', sort: 3 }, + { name: DirectoryType.File, code: 'standardFile', sort: 4 }, + { name: DirectoryType.Code, code: 'standardCode', sort: 5 }, + { name: DirectoryType.Mirror, code: 'standardMirror', sort: 6 }, +]; /** 通用状态信息Map */ export const StatusMap = new Map([ diff --git a/src/ts/core/public/enums.ts b/src/ts/core/public/enums.ts index bebd476bfd27470518d4f778f77af9e9fbcb5d78..7624ba88c863ead629bf5d2651046712e9d99cbd 100644 --- a/src/ts/core/public/enums.ts +++ b/src/ts/core/public/enums.ts @@ -89,3 +89,23 @@ export enum FromOrigin { 'Person' = 'Person', 'Group' = 'Group', } + +/** 文件类型 */ +export enum DirectoryType { + /* 一级类目 */ + 'Storage' = '存储资源', + 'DataStandard' = '数据标准', + 'Model' = '业务模型', + 'App' = '应用', + 'File' = '文件', + 'Code' = '代码', + 'Mirror' = '镜像', + /* 二级类目 */ + 'Attribute' = '属性', + 'Species' = '分类', + 'Dict' = '字典', + 'Form' = '表单', + 'Report' = '报表', + 'PageTemplate' = '模板', + 'Transfer' = '迁移', +} diff --git a/src/ts/core/public/operates.ts b/src/ts/core/public/operates.ts index 5627e1c4f767ae90a6eb381c3db9d622e3d5b17a..e977fe0afc62d0248854acc6822b630de7815761 100644 --- a/src/ts/core/public/operates.ts +++ b/src/ts/core/public/operates.ts @@ -1,3 +1,4 @@ +import { DirectoryType } from './enums'; /** 实体的操作 */ export const entityOperates = { Open: { @@ -48,6 +49,12 @@ export const entityOperates = { label: '分享二维码', iconType: 'qrcode', }, + CheckDirectory: { + sort: 102, + cmd: 'checkDirectory', + label: '校验文件夹', + iconType: 'update', + }, }; /** 文件支持的操作 */ export const fileOperates = { @@ -224,6 +231,52 @@ export const directoryNew = { directoryOperates.NewPageTemplate, ], }; +/** 目录下新增 */ +export const getDirectoryNew = (accept: DirectoryType[]) => { + const menus = [directoryOperates.NewDir]; + // directoryOperates.NewDir, + // directoryOperates.NewDict, + // directoryOperates.NewSpecies, + // directoryOperates.NewProperty, + // directoryOperates.NewApp, + // directoryOperates.NewForm, + // directoryOperates.NewTransferConfig, + // directoryOperates.NewPageTemplate, + for (const item of accept) { + switch (item) { + case DirectoryType.App: + menus.push(directoryOperates.NewApp); + break; + case DirectoryType.Attribute: + menus.push(directoryOperates.NewProperty); + break; + case DirectoryType.Form: + menus.push(directoryOperates.NewForm); + break; + case DirectoryType.Species: + menus.push(directoryOperates.NewSpecies); + break; + case DirectoryType.Dict: + menus.push(directoryOperates.NewDict); + break; + case DirectoryType.Transfer: + menus.push(directoryOperates.NewTransferConfig); + break; + case DirectoryType.PageTemplate: + menus.push(directoryOperates.NewPageTemplate); + break; + default: + break; + } + } + return { + sort: 0, + cmd: 'new', + label: '新建更多', + iconType: 'new', + menus: menus, + }; +}; /** 新建仓库 */ export const newWarehouse = { diff --git a/src/ts/core/target/outTeam/storage.ts b/src/ts/core/target/outTeam/storage.ts index 391aba4617c667bc3607e6a07d6891af5d550e76..51793b9f52a64e799939b9f2f128f10d98ad7a7f 100644 --- a/src/ts/core/target/outTeam/storage.ts +++ b/src/ts/core/target/outTeam/storage.ts @@ -1,9 +1,12 @@ -import { OperateModel } from '@/ts/base/model'; +import { IDirectory } from '@/ts/core'; +import { OperateModel, StandardDirectoryType } from '@/ts/base/model'; import { kernel, schema } from '../../../base'; import { OperateType, TargetType, entityOperates, targetOperates } from '../../public'; import { IBelong } from '../base/belong'; import { ITarget, Target } from '../base/target'; import { ISession } from '../../chat/session'; +import { IFile } from '../../thing/fileinfo'; +import { StandardDirectory } from '../../public/consts'; /** 存储资源接口 */ export interface IStorage extends ITarget { @@ -11,6 +14,8 @@ export interface IStorage extends ITarget { isActivate: boolean; /** 激活存储 */ activateStorage(): Promise; + /** 初始化存储 */ + checkDirectory(): void; } export class Storage extends Target implements IStorage { @@ -42,7 +47,11 @@ export class Storage extends Target implements IStorage { return success; } override operates(): OperateModel[] { - const operates = [entityOperates.Remark, entityOperates.QrCode]; + const operates = [ + entityOperates.Remark, + entityOperates.QrCode, + entityOperates.CheckDirectory, + ]; if (this.hasRelationAuth()) { operates.unshift(entityOperates.Update, entityOperates.HardDelete); } @@ -72,6 +81,7 @@ export class Storage extends Target implements IStorage { if (res.success) { this.space.updateMetadata(res.data); this.space.sendTargetNotity(OperateType.Update); + this.checkDirectory(); } return res.success; } @@ -84,6 +94,16 @@ export class Storage extends Target implements IStorage { } this.directory.loadDirectoryResource(reload); } + content(store?: boolean, isSidebar?: boolean): IFile[] { + console.log('存储展示是否数据展示:', store, '----是否侧边栏:', isSidebar); + const items = this.space.directory.children.sort((a, b) => { + const curr = a.metadata.sort ?? a.metadata.updateTime; + const next = b.metadata.sort ?? b.metadata.updateTime; + return curr > next ? 1 : -1; + }); + return store ? items : []; + } + override async pullMembers( members: schema.XTarget[], notity?: boolean, @@ -93,4 +113,44 @@ export class Storage extends Target implements IStorage { } return await super.pullMembers(members, notity); } + async checkDirectory() { + await this.space.directory.loadContent(true); + await this.space.directory.standard.loadDirectorys(true); + this.creatStandardDirectory(this.space.directory, StandardDirectory); + } + async creatStandardDirectory( + directory: IDirectory, + standardDirectorys: StandardDirectoryType[], + ) { + if (standardDirectorys.length > 0) { + for (const dirItem of standardDirectorys) { + //若 已存在目标文件夹,禁止创建 + if (!directory.children.find((child) => child.code === dirItem.code)) { + const params = { + name: dirItem.name, + code: dirItem.code, + sort: dirItem.sort, + accept: dirItem.accept ?? [dirItem.name], + typeName: '目录', + directoryId: directory.id, + } as schema.XDirectory; + directory.create(params).then((res) => { + console.log('创建文件:', dirItem.name); + if (dirItem.children && dirItem.children.length > 0 && res?.id) { + setTimeout(() => { + const newDirectory = directory.children.find( + (child) => child.id === res.id, + ); + if (newDirectory) { + this.creatStandardDirectory(newDirectory, dirItem.children!); + } + }, 300); + } + }); + } else { + console.warn('跳过创建,已存在文件夹:', dirItem.name); + } + } + } + } } diff --git a/src/ts/core/target/team/company.ts b/src/ts/core/target/team/company.ts index b072a792fcbc1a04af79e8affb8d0a3a8856a5ac..17942f4c8d40b712b091f33fa16ef65d64b84bdb 100644 --- a/src/ts/core/target/team/company.ts +++ b/src/ts/core/target/team/company.ts @@ -249,7 +249,11 @@ export class Company extends Belong implements ICompany { return operates; } - content(): IFile[] { + content(isStore?: boolean): IFile[] { + if (isStore) { + return this.storages.filter((i) => i.isMyTeam); + } + return [ ...this.groups, ...this.departments, diff --git a/src/ts/core/thing/directory.ts b/src/ts/core/thing/directory.ts index 0a8fd813cd303d49bc2fee75359b992b2de48ec6..946f290ff648957643653816ef9983d9acdefd46 100644 --- a/src/ts/core/thing/directory.ts +++ b/src/ts/core/thing/directory.ts @@ -1,3 +1,5 @@ +import { getDirectoryNew } from './../public/operates'; +import { DirectoryType } from './../public/enums'; import { common, model, schema } from '../../base'; import { directoryNew, directoryOperates, entityOperates, fileOperates } from '../public'; import { ITarget } from '../target/base/target'; @@ -19,6 +21,8 @@ export interface IDirectory extends IStandardFileInfo { directoryId: string; /** 目录下标准类 */ standard: StandardFiles; + /** 目录下支持的标准类 */ + accept: DirectoryType[]; /** 当前加载目录的用户 */ target: ITarget; /** 资源类 */ @@ -32,7 +36,7 @@ export interface IDirectory extends IStandardFileInfo { /** 任务发射器 */ taskEmitter: common.Emitter; /** 目录下的内容 */ - content(store?: boolean): IFile[]; + content(store?: boolean, isSidebar?: boolean): IFile[]; /** 创建子目录 */ create(data: schema.XDirectory): Promise; /** 目录下的文件 */ @@ -75,10 +79,12 @@ export class Directory extends StandardFileInfo implements ID _parent ?? (_target as unknown as IDirectory), _target.resource.directoryColl, ); + this.accept = (_metadata.accept as DirectoryType[]) ?? []; this.parent = _parent; this.taskEmitter = new common.Emitter(); this.standard = new StandardFiles(this); } + accept: DirectoryType[]; standard: StandardFiles; taskEmitter: common.Emitter; parent: IDirectory | undefined; @@ -127,22 +133,73 @@ export class Directory extends StandardFileInfo implements ID get resource(): DataResource { return this.target.resource; } - content(store: boolean = false): IFile[] { - const cnt: IFile[] = [...this.children]; + content(store: boolean = false, isSidebar: boolean = true): IFile[] { + console.log( + '文件夹展示是否数据展示:', + store, + '----是否侧边栏:', + isSidebar, + this.accept, + ); + const cnt: IFile[] = []; + console.log(this.name, store, this.accept); if (this.target.session.isMyChat || this.target.hasRelationAuth()) { - cnt.push(...this.files); - cnt.push(...this.standard.forms); - cnt.push(...this.standard.applications); - cnt.push(...this.standard.propertys); - cnt.push(...this.standard.specieses); - cnt.push(...this.standard.transfers); - cnt.push(...this.standard.templates); + if (store && this.accept.length > 0) { + if (isSidebar) { + cnt.push(...this.children); + } else { + for (const typeItem of this.accept) { + switch (typeItem) { + case DirectoryType.App: + cnt.push(...this.standard.applications); + break; + case DirectoryType.Species: + cnt.push(...this.standard.specieses); + break; + case DirectoryType.File: + cnt.push(...this.files); + break; + case DirectoryType.Attribute: + cnt.push(...this.standard.propertys); + break; + case DirectoryType.Transfer: + cnt.push(...this.standard.transfers); + break; + case DirectoryType.PageTemplate: + cnt.push(...this.standard.templates); + break; + case DirectoryType.Form: + cnt.push(...this.standard.forms); + break; + case DirectoryType.Report: + // cnt.push(...this.standard.report); + break; + default: + break; + } + } + for (const childrenDir of this.children) { + cnt.push(...childrenDir.content(store, isSidebar)); + } + } + } else { + cnt.push(...this.children); + cnt.push(...this.files); + cnt.push(...this.standard.forms); + cnt.push(...this.standard.applications); + cnt.push(...this.standard.propertys); + cnt.push(...this.standard.specieses); + cnt.push(...this.standard.transfers); + cnt.push(...this.standard.templates); + } } return cnt.sort((a, b) => (a.metadata.updateTime < b.metadata.updateTime ? 1 : -1)); } async loadContent(reload: boolean = false): Promise { - await this.loadFiles(reload); - await this.standard.loadStandardFiles(reload); + if (this.accept.length == 0 || this.accept.includes(DirectoryType.File)) { + await this.loadFiles(reload); + } + await this.standard.loadStandardFiles(reload, this.accept); if (reload) { await this.loadDirectoryResource(reload); } @@ -237,7 +294,10 @@ export class Directory extends StandardFileInfo implements ID } return this.files; } - async createFile(file: Blob, p?: OnProgress): Promise { + async createFile( + file: Blob & { name: string }, + p?: OnProgress, + ): Promise { while (this.taskList.filter((i) => i.finished < i.size).length > 2) { await sleep(1000); } @@ -308,19 +368,20 @@ export class Directory extends StandardFileInfo implements ID directoryOperates.TaskList, directoryOperates.Refesh, ); + const _directoryNew = getDirectoryNew(this.accept); if (this.target.hasRelationAuth()) { if (this.name.includes('业务')) { operates.push({ - ...directoryNew, + ..._directoryNew, menus: [...directoryNew.menus, directoryOperates.Business], }); } else if (this.name.includes('标准')) { operates.push({ - ...directoryNew, + ..._directoryNew, menus: [...directoryNew.menus, directoryOperates.Standard], }); } else { - operates.push(directoryNew); + operates.push(_directoryNew); } if (this.target.user.copyFiles.size > 0) { operates.push(fileOperates.Parse); @@ -330,7 +391,7 @@ export class Directory extends StandardFileInfo implements ID if (this.target.hasRelationAuth()) { operates.push(directoryOperates.Shortcut); } - operates.push(...super.operates()); + // operates.push(...super.operates()); } else { operates.push(entityOperates.Open); } diff --git a/src/ts/core/thing/fileinfo.ts b/src/ts/core/thing/fileinfo.ts index 81eba58b4ffa8fa9a44cb991adf13b1c49b08265..1d6f5f0403ae27e71fedcbabea4d5b382b1de560 100644 --- a/src/ts/core/thing/fileinfo.ts +++ b/src/ts/core/thing/fileinfo.ts @@ -51,7 +51,7 @@ export interface IFileInfo extends IEntity { /** 加载文件内容 */ loadContent(reload?: boolean): Promise; /** 目录下的内容 */ - content(args?: boolean): IFile[]; + content(...args: any): IFile[]; /** 缓存用户数据 */ cacheUserData(notify?: boolean): Promise; } diff --git a/src/ts/core/thing/standard/index.ts b/src/ts/core/thing/standard/index.ts index 539cb1b3edbe5208bd2ad5a3dcba2aa2e1296199..e14afb3c4de3409d24e718bb99e58b1197b8f6ae 100644 --- a/src/ts/core/thing/standard/index.ts +++ b/src/ts/core/thing/standard/index.ts @@ -1,3 +1,4 @@ +import { DirectoryType } from './../../public/enums'; import { model, schema } from '../../../base'; import { Directory, IDirectory } from '../directory'; import { IStandard } from '../fileinfo'; @@ -59,14 +60,41 @@ export class StandardFiles { ...this.templates, ]; } - async loadStandardFiles(reload: boolean = false): Promise { - await Promise.all([ - this.loadForms(reload), - this.loadTransfers(reload), - this.loadPropertys(reload), - this.loadSpecieses(reload), - this.loadTemplates(reload), - ]); + async loadStandardFiles( + reload: boolean = false, + accept: DirectoryType[], + ): Promise { + let waitPromises: Promise[] = []; + if (accept.length > 0) { + for (const type of accept) { + switch (type) { + case DirectoryType.Form: + waitPromises.push(this.loadForms(reload)); + break; + case DirectoryType.Transfer: + waitPromises.push(this.loadTransfers(reload)); + break; + case DirectoryType.Attribute: + waitPromises.push(this.loadPropertys(reload)); + break; + case DirectoryType.Species: + waitPromises.push(this.loadSpecieses(reload)); + break; + case DirectoryType.PageTemplate: + waitPromises.push(this.loadTemplates(reload)); + break; + } + } + } else { + waitPromises = [ + this.loadForms(reload), + this.loadTransfers(reload), + this.loadPropertys(reload), + this.loadSpecieses(reload), + this.loadTemplates(reload), + ]; + } + await Promise.all(waitPromises); return this.standardFiles; } async loadForms(reload: boolean = false): Promise {