@knockout-js/layout 0.0.4-beta.1 → 0.1.1-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/es2017/components/_util/index.d.ts +55 -0
- package/es2017/components/_util/index.js +96 -0
- package/es2017/components/_util/index.js.map +1 -0
- package/es2017/components/aggregate-menu/index.d.ts +7 -2
- package/es2017/components/aggregate-menu/index.js +160 -73
- package/es2017/components/aggregate-menu/index.js.map +1 -1
- package/es2017/components/aggregate-menu/index.module.css +69 -57
- package/es2017/components/avatar-dropdown/index.js +1 -1
- package/es2017/components/avatar-dropdown/index.js.map +1 -1
- package/es2017/components/i18n-dropdown/index.js.map +1 -1
- package/es2017/components/index.d.ts +2 -3
- package/es2017/components/index.js +3 -4
- package/es2017/components/index.js.map +1 -1
- package/es2017/components/layout/index.d.ts +17 -2
- package/es2017/components/layout/index.js +19 -29
- package/es2017/components/layout/index.js.map +1 -1
- package/es2017/components/layout/layout.module.css +20 -26
- package/es2017/components/locale/en_US.js +3 -1
- package/es2017/components/locale/en_US.js.map +1 -1
- package/es2017/components/locale/index.d.ts +2 -0
- package/es2017/components/locale/index.js.map +1 -1
- package/es2017/components/locale/zh_CN.js +3 -1
- package/es2017/components/locale/zh_CN.js.map +1 -1
- package/es2017/components/modal/index.module.css +4 -4
- package/es2017/components/msg-dropdown/index.d.ts +28 -0
- package/es2017/components/msg-dropdown/index.js +129 -0
- package/es2017/components/msg-dropdown/index.js.map +1 -0
- package/es2017/components/msg-dropdown/index.module.css +33 -0
- package/es2017/components/msg-dropdown/locale/en_US.d.ts +3 -0
- package/es2017/components/msg-dropdown/locale/en_US.js +7 -0
- package/es2017/components/msg-dropdown/locale/en_US.js.map +1 -0
- package/es2017/components/msg-dropdown/locale/zh_CN.d.ts +3 -0
- package/es2017/components/msg-dropdown/locale/zh_CN.js +7 -0
- package/es2017/components/msg-dropdown/locale/zh_CN.js.map +1 -0
- package/es2017/components/tenant-dropdown/index.d.ts +1 -1
- package/es2017/components/tenant-dropdown/index.js +2 -2
- package/es2017/components/tenant-dropdown/index.js.map +1 -1
- package/es2017/components/upload-file/index.d.ts +0 -2
- package/es2017/components/upload-file/index.js +1 -13
- package/es2017/components/upload-file/index.js.map +1 -1
- package/es2017/components/upload-file/index.module.css +3 -3
- package/es2017/components/upload-file/uploadAvatar.js +4 -4
- package/es2017/components/upload-file/uploadAvatar.js.map +1 -1
- package/es2017/components/upload-file/uploadMultiple.js +5 -5
- package/es2017/components/upload-file/uploadMultiple.js.map +1 -1
- package/es2017/components/upload-file/uploadTemp.js +6 -6
- package/es2017/components/upload-file/uploadTemp.js.map +1 -1
- package/esm/components/_util/index.d.ts +55 -0
- package/esm/components/_util/index.js +103 -0
- package/esm/components/_util/index.js.map +1 -0
- package/esm/components/aggregate-menu/index.d.ts +7 -2
- package/esm/components/aggregate-menu/index.js +262 -74
- package/esm/components/aggregate-menu/index.js.map +1 -1
- package/esm/components/aggregate-menu/index.module.css +69 -57
- package/esm/components/avatar-dropdown/index.js +1 -1
- package/esm/components/avatar-dropdown/index.js.map +1 -1
- package/esm/components/i18n-dropdown/index.js.map +1 -1
- package/esm/components/index.d.ts +2 -3
- package/esm/components/index.js +3 -4
- package/esm/components/index.js.map +1 -1
- package/esm/components/layout/index.d.ts +17 -2
- package/esm/components/layout/index.js +19 -34
- package/esm/components/layout/index.js.map +1 -1
- package/esm/components/layout/layout.module.css +20 -26
- package/esm/components/locale/en_US.js +3 -1
- package/esm/components/locale/en_US.js.map +1 -1
- package/esm/components/locale/index.d.ts +2 -0
- package/esm/components/locale/index.js.map +1 -1
- package/esm/components/locale/zh_CN.js +3 -1
- package/esm/components/locale/zh_CN.js.map +1 -1
- package/esm/components/modal/index.module.css +4 -4
- package/esm/components/msg-dropdown/index.d.ts +28 -0
- package/esm/components/msg-dropdown/index.js +155 -0
- package/esm/components/msg-dropdown/index.js.map +1 -0
- package/esm/components/msg-dropdown/index.module.css +33 -0
- package/esm/components/msg-dropdown/locale/en_US.d.ts +3 -0
- package/esm/components/msg-dropdown/locale/en_US.js +7 -0
- package/esm/components/msg-dropdown/locale/en_US.js.map +1 -0
- package/esm/components/msg-dropdown/locale/zh_CN.d.ts +3 -0
- package/esm/components/msg-dropdown/locale/zh_CN.js +7 -0
- package/esm/components/msg-dropdown/locale/zh_CN.js.map +1 -0
- package/esm/components/tenant-dropdown/index.d.ts +1 -1
- package/esm/components/tenant-dropdown/index.js +2 -2
- package/esm/components/tenant-dropdown/index.js.map +1 -1
- package/esm/components/upload-file/index.d.ts +0 -2
- package/esm/components/upload-file/index.js +1 -13
- package/esm/components/upload-file/index.js.map +1 -1
- package/esm/components/upload-file/index.module.css +3 -3
- package/esm/components/upload-file/uploadAvatar.js +4 -4
- package/esm/components/upload-file/uploadAvatar.js.map +1 -1
- package/esm/components/upload-file/uploadMultiple.js +5 -5
- package/esm/components/upload-file/uploadMultiple.js.map +1 -1
- package/esm/components/upload-file/uploadTemp.js +6 -6
- package/esm/components/upload-file/uploadTemp.js.map +1 -1
- package/package.json +8 -3
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 列表数据格式化成树结构
|
|
3
|
+
* @param allList
|
|
4
|
+
* @param parentList
|
|
5
|
+
* @param defineKey
|
|
6
|
+
* @param parentId
|
|
7
|
+
* @returns
|
|
8
|
+
*/
|
|
9
|
+
export declare const listFormatTreeData: <T extends Record<string, any> & {
|
|
10
|
+
children?: T[];
|
|
11
|
+
}>(allList: T[], parentList?: T[], defineKey?: {
|
|
12
|
+
key?: string;
|
|
13
|
+
parentId?: string;
|
|
14
|
+
}, parentId?: string | number) => T[];
|
|
15
|
+
/**
|
|
16
|
+
* 解析树结构按树顺序处理成列表
|
|
17
|
+
* @param treeList
|
|
18
|
+
* @returns
|
|
19
|
+
*/
|
|
20
|
+
export declare const treeFormatList: <T extends Record<string, any> & {
|
|
21
|
+
children?: T[];
|
|
22
|
+
}>(treeList: T[]) => T[];
|
|
23
|
+
/**
|
|
24
|
+
* 字节大小展示处理
|
|
25
|
+
* @param fileSize
|
|
26
|
+
* @returns
|
|
27
|
+
*/
|
|
28
|
+
export declare const formatFileSize: (fileSize: number) => string;
|
|
29
|
+
/**
|
|
30
|
+
* 随机数
|
|
31
|
+
* @param len
|
|
32
|
+
* @returns
|
|
33
|
+
*/
|
|
34
|
+
export declare const randomId: (len: number) => string;
|
|
35
|
+
/**
|
|
36
|
+
* 解析env配置的app地址字符串
|
|
37
|
+
* @param evnStr appCode@deploy_address;
|
|
38
|
+
* @returns
|
|
39
|
+
*/
|
|
40
|
+
export declare const parseEnvAppAddress: (evnStr: string) => Record<string, string>;
|
|
41
|
+
/**
|
|
42
|
+
* 格式化日期
|
|
43
|
+
* @param date
|
|
44
|
+
* @param format YYYY-MM-DD HH:mm:ss
|
|
45
|
+
* @param tz 时区
|
|
46
|
+
* @param isTzSet true将当前时间设置成这个时区,false 将当前时间根据时区转换
|
|
47
|
+
* 例子 isTzSet=true
|
|
48
|
+
* dayjs.tz("2022-07-07 16:30:00", "America/New_York").format("YYYY-MM-DDTHH:mm:ssZ")
|
|
49
|
+
* = "2022-07-07T16:30:00-04:00"
|
|
50
|
+
* 例子 isTzSet=false
|
|
51
|
+
* dayjs("2022-07-07T20:30:00Z").tz("America/New_York").format("YYYY-MM-DD HH:mm:ss")
|
|
52
|
+
* = "2022-07-07 16:30:00"
|
|
53
|
+
* @returns
|
|
54
|
+
*/
|
|
55
|
+
export declare const getDate: (date: dayjs.ConfigType, format?: string, tz?: string, isTzSet?: boolean) => any;
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import _object_spread from "@swc/helpers/src/_object_spread.mjs";
|
|
2
|
+
import dayjs from "dayjs";
|
|
3
|
+
import timezone from "dayjs/plugin/timezone";
|
|
4
|
+
import utc from "dayjs/plugin/utc";
|
|
5
|
+
dayjs.extend(utc);
|
|
6
|
+
dayjs.extend(timezone);
|
|
7
|
+
/**
|
|
8
|
+
* 列表数据格式化成树结构
|
|
9
|
+
* @param allList
|
|
10
|
+
* @param parentList
|
|
11
|
+
* @param defineKey
|
|
12
|
+
* @param parentId
|
|
13
|
+
* @returns
|
|
14
|
+
*/ export const listFormatTreeData = (allList, parentList, defineKey, parentId)=>{
|
|
15
|
+
const dataKey = _object_spread({
|
|
16
|
+
key: 'key',
|
|
17
|
+
parentId: 'parentId'
|
|
18
|
+
}, defineKey), pid = parentId === undefined ? '0' : parentId;
|
|
19
|
+
if (!parentList) parentList = allList.filter((item)=>item[dataKey.parentId] == pid);
|
|
20
|
+
parentList.forEach((pItem)=>{
|
|
21
|
+
const children = allList.filter((allItem)=>allItem[dataKey.parentId] == pItem[dataKey.key]);
|
|
22
|
+
if (children && children.length) pItem.children = listFormatTreeData(allList, children, dataKey);
|
|
23
|
+
});
|
|
24
|
+
return parentList;
|
|
25
|
+
};
|
|
26
|
+
/**
|
|
27
|
+
* 解析树结构按树顺序处理成列表
|
|
28
|
+
* @param treeList
|
|
29
|
+
* @returns
|
|
30
|
+
*/ export const treeFormatList = (treeList)=>{
|
|
31
|
+
const allList = [];
|
|
32
|
+
treeList.forEach((item)=>{
|
|
33
|
+
const children = item.children;
|
|
34
|
+
delete item.children;
|
|
35
|
+
allList === null || allList === void 0 ? void 0 : allList.push(item);
|
|
36
|
+
if (children) allList.push(...treeFormatList(children));
|
|
37
|
+
});
|
|
38
|
+
return allList;
|
|
39
|
+
};
|
|
40
|
+
/**
|
|
41
|
+
* 字节大小展示处理
|
|
42
|
+
* @param fileSize
|
|
43
|
+
* @returns
|
|
44
|
+
*/ export const formatFileSize = (fileSize)=>{
|
|
45
|
+
if (fileSize < 1024) return fileSize + 'B';
|
|
46
|
+
else if (fileSize < 1048576) return (fileSize / 1024).toFixed(2) + 'KB';
|
|
47
|
+
else if (fileSize < 1073741824) return (fileSize / 1048576).toFixed(2) + 'MB';
|
|
48
|
+
else return (fileSize / 1073741824).toFixed(2) + 'GB';
|
|
49
|
+
};
|
|
50
|
+
/**
|
|
51
|
+
* 随机数
|
|
52
|
+
* @param len
|
|
53
|
+
* @returns
|
|
54
|
+
*/ export const randomId = (len)=>{
|
|
55
|
+
let str = '';
|
|
56
|
+
for(; str.length < len; str += Math.random().toString(36).substring(2));
|
|
57
|
+
return str.substring(0, len);
|
|
58
|
+
};
|
|
59
|
+
/**
|
|
60
|
+
* 解析env配置的app地址字符串
|
|
61
|
+
* @param evnStr appCode@deploy_address;
|
|
62
|
+
* @returns
|
|
63
|
+
*/ export const parseEnvAppAddress = (evnStr)=>{
|
|
64
|
+
const address = {};
|
|
65
|
+
evnStr.split(';').forEach((str)=>{
|
|
66
|
+
if (str) {
|
|
67
|
+
const adds = str.split('@');
|
|
68
|
+
if (adds.length === 2) address[adds[0]] = adds[1];
|
|
69
|
+
}
|
|
70
|
+
});
|
|
71
|
+
return address;
|
|
72
|
+
};
|
|
73
|
+
/**
|
|
74
|
+
* 格式化日期
|
|
75
|
+
* @param date
|
|
76
|
+
* @param format YYYY-MM-DD HH:mm:ss
|
|
77
|
+
* @param tz 时区
|
|
78
|
+
* @param isTzSet true将当前时间设置成这个时区,false 将当前时间根据时区转换
|
|
79
|
+
* 例子 isTzSet=true
|
|
80
|
+
* dayjs.tz("2022-07-07 16:30:00", "America/New_York").format("YYYY-MM-DDTHH:mm:ssZ")
|
|
81
|
+
* = "2022-07-07T16:30:00-04:00"
|
|
82
|
+
* 例子 isTzSet=false
|
|
83
|
+
* dayjs("2022-07-07T20:30:00Z").tz("America/New_York").format("YYYY-MM-DD HH:mm:ss")
|
|
84
|
+
* = "2022-07-07 16:30:00"
|
|
85
|
+
* @returns
|
|
86
|
+
*/ export const getDate = (date, format = 'YYYY-MM-DD', tz, isTzSet)=>{
|
|
87
|
+
if (date) {
|
|
88
|
+
if (tz) {
|
|
89
|
+
if (isTzSet) return dayjs.tz(date, tz).format(format);
|
|
90
|
+
else return dayjs(date).tz(tz).format(format);
|
|
91
|
+
}
|
|
92
|
+
return dayjs(date).format(format);
|
|
93
|
+
} else return null;
|
|
94
|
+
};
|
|
95
|
+
|
|
96
|
+
//# sourceMappingURL=D:\codeing\git\github\knockout-js\packages\layout\es2017\components\_util\index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["D:\\codeing\\git\\github\\knockout-js\\packages\\layout\\src\\components\\_util\\index.ts"],"sourcesContent":["import dayjs from 'dayjs';\r\nimport timezone from 'dayjs/plugin/timezone';\r\nimport utc from 'dayjs/plugin/utc';\r\n\r\ndayjs.extend(utc);\r\ndayjs.extend(timezone);\r\n\r\n/**\r\n * 列表数据格式化成树结构\r\n * @param allList\r\n * @param parentList\r\n * @param defineKey\r\n * @param parentId\r\n * @returns\r\n */\r\nexport const listFormatTreeData = <T extends Record<string, any> & { children?: T[] }>(\r\n allList: T[],\r\n parentList?: T[],\r\n defineKey?: {\r\n key?: string;\r\n parentId?: string;\r\n },\r\n parentId?: string | number,\r\n) => {\r\n const dataKey = { key: 'key', parentId: 'parentId', ...defineKey },\r\n pid = parentId === undefined ? '0' : parentId;\r\n\r\n if (!parentList) {\r\n parentList = allList.filter(item => item[dataKey.parentId] == pid);\r\n }\r\n\r\n parentList.forEach((pItem) => {\r\n const children = allList.filter(\r\n (allItem) => allItem[dataKey.parentId] == pItem[dataKey.key],\r\n );\r\n if (children && children.length) {\r\n pItem.children = listFormatTreeData(allList, children, dataKey);\r\n }\r\n });\r\n return parentList;\r\n};\r\n\r\n/**\r\n * 解析树结构按树顺序处理成列表\r\n * @param treeList\r\n * @returns\r\n */\r\nexport const treeFormatList = <T extends Record<string, any> & { children?: T[] }>(treeList: T[]) => {\r\n const allList: T[] = [];\r\n\r\n treeList.forEach(item => {\r\n const children = item.children;\r\n delete item.children;\r\n allList?.push(item);\r\n if (children) {\r\n allList.push(...treeFormatList(children));\r\n }\r\n });\r\n\r\n return allList;\r\n}\r\n\r\n/**\r\n * 字节大小展示处理\r\n * @param fileSize\r\n * @returns\r\n */\r\nexport const formatFileSize = (fileSize: number) => {\r\n if (fileSize < 1024) {\r\n return fileSize + 'B';\r\n } else if (fileSize < (1024 * 1024)) {\r\n return (fileSize / 1024).toFixed(2) + 'KB';\r\n } else if (fileSize < (1024 * 1024 * 1024)) {\r\n return (fileSize / (1024 * 1024)).toFixed(2) + 'MB';\r\n } else {\r\n return (fileSize / (1024 * 1024 * 1024)).toFixed(2) + 'GB';\r\n }\r\n}\r\n\r\n/**\r\n * 随机数\r\n * @param len\r\n * @returns\r\n */\r\nexport const randomId = (len: number) => {\r\n let str = '';\r\n for (; str.length < len; str += Math.random().toString(36).substring(2));\r\n return str.substring(0, len);\r\n}\r\n\r\n\r\n/**\r\n * 解析env配置的app地址字符串\r\n * @param evnStr appCode@deploy_address;\r\n * @returns\r\n */\r\nexport const parseEnvAppAddress = (evnStr: string) => {\r\n const address: Record<string, string> = {};\r\n evnStr.split(';').forEach(str => {\r\n if (str) {\r\n const adds = str.split('@');\r\n if (adds.length === 2) {\r\n address[adds[0]] = adds[1];\r\n }\r\n }\r\n })\r\n return address;\r\n}\r\n\r\n\r\n\r\n/**\r\n * 格式化日期\r\n * @param date\r\n * @param format YYYY-MM-DD HH:mm:ss\r\n * @param tz 时区\r\n * @param isTzSet true将当前时间设置成这个时区,false 将当前时间根据时区转换\r\n * 例子 isTzSet=true\r\n * dayjs.tz(\"2022-07-07 16:30:00\", \"America/New_York\").format(\"YYYY-MM-DDTHH:mm:ssZ\")\r\n * = \"2022-07-07T16:30:00-04:00\"\r\n * 例子 isTzSet=false\r\n * dayjs(\"2022-07-07T20:30:00Z\").tz(\"America/New_York\").format(\"YYYY-MM-DD HH:mm:ss\")\r\n * = \"2022-07-07 16:30:00\"\r\n * @returns\r\n */\r\nexport const getDate = (\r\n date: dayjs.ConfigType,\r\n format = 'YYYY-MM-DD',\r\n tz?: string,\r\n isTzSet?: boolean,\r\n) => {\r\n if (date) {\r\n if (tz) {\r\n if (isTzSet) {\r\n return dayjs.tz(date, tz).format(format);\r\n } else {\r\n return dayjs(date).tz(tz).format(format);\r\n }\r\n }\r\n return dayjs(date).format(format);\r\n } else {\r\n return null\r\n }\r\n};\r\n"],"names":["dayjs","timezone","utc","extend","listFormatTreeData","allList","parentList","defineKey","parentId","dataKey","key","pid","undefined","filter","item","forEach","pItem","children","allItem","length","treeFormatList","treeList","push","formatFileSize","fileSize","toFixed","randomId","len","str","Math","random","toString","substring","parseEnvAppAddress","evnStr","address","split","adds","getDate","date","format","tz","isTzSet"],"mappings":";AAAA,OAAOA,WAAW,QAAQ;AAC1B,OAAOC,cAAc,wBAAwB;AAC7C,OAAOC,SAAS,mBAAmB;AAEnCF,MAAMG,MAAM,CAACD;AACbF,MAAMG,MAAM,CAACF;AAEb;;;;;;;CAOC,GACD,OAAO,MAAMG,qBAAqB,CAChCC,SACAC,YACAC,WAIAC,WACG;IACH,MAAMC,UAAU;QAAEC,KAAK;QAAOF,UAAU;OAAeD,YACrDI,MAAMH,aAAaI,YAAY,MAAMJ,QAAQ;IAE/C,IAAI,CAACF,YACHA,aAAaD,QAAQQ,MAAM,CAACC,CAAAA,OAAQA,IAAI,CAACL,QAAQD,QAAQ,CAAC,IAAIG;IAGhEL,WAAWS,OAAO,CAAC,CAACC,QAAU;QAC5B,MAAMC,WAAWZ,QAAQQ,MAAM,CAC7B,CAACK,UAAYA,OAAO,CAACT,QAAQD,QAAQ,CAAC,IAAIQ,KAAK,CAACP,QAAQC,GAAG,CAAC;QAE9D,IAAIO,YAAYA,SAASE,MAAM,EAC7BH,MAAMC,QAAQ,GAAGb,mBAAmBC,SAASY,UAAUR;IAE3D;IACA,OAAOH;AACT,EAAE;AAEF;;;;CAIC,GACD,OAAO,MAAMc,iBAAiB,CAAqDC,WAAkB;IACnG,MAAMhB,UAAe,EAAE;IAEvBgB,SAASN,OAAO,CAACD,CAAAA,OAAQ;QACvB,MAAMG,WAAWH,KAAKG,QAAQ;QAC9B,OAAOH,KAAKG,QAAQ;QACpBZ,oBAAAA,qBAAAA,KAAAA,IAAAA,QAASiB,IAAI,CAACR;QACd,IAAIG,UACFZ,QAAQiB,IAAI,IAAIF,eAAeH;IAEnC;IAEA,OAAOZ;AACT,EAAC;AAED;;;;CAIC,GACD,OAAO,MAAMkB,iBAAiB,CAACC,WAAqB;IAClD,IAAIA,WAAW,MACb,OAAOA,WAAW;SACb,IAAIA,WAAY,SACrB,OAAO,AAACA,CAAAA,WAAW,IAAG,EAAGC,OAAO,CAAC,KAAK;SACjC,IAAID,WAAY,YACrB,OAAO,AAACA,CAAAA,WAAY,OAAW,EAAGC,OAAO,CAAC,KAAK;SAE/C,OAAO,AAACD,CAAAA,WAAY,UAAkB,EAAGC,OAAO,CAAC,KAAK;AAE1D,EAAC;AAED;;;;CAIC,GACD,OAAO,MAAMC,WAAW,CAACC,MAAgB;IACvC,IAAIC,MAAM;IACV,MAAOA,IAAIT,MAAM,GAAGQ,KAAKC,OAAOC,KAAKC,MAAM,GAAGC,QAAQ,CAAC,IAAIC,SAAS,CAAC;IACrE,OAAOJ,IAAII,SAAS,CAAC,GAAGL;AAC1B,EAAC;AAGD;;;;CAIC,GACD,OAAO,MAAMM,qBAAqB,CAACC,SAAmB;IACpD,MAAMC,UAAkC,CAAC;IACzCD,OAAOE,KAAK,CAAC,KAAKrB,OAAO,CAACa,CAAAA,MAAO;QAC/B,IAAIA,KAAK;YACP,MAAMS,OAAOT,IAAIQ,KAAK,CAAC;YACvB,IAAIC,KAAKlB,MAAM,KAAK,GAClBgB,OAAO,CAACE,IAAI,CAAC,EAAE,CAAC,GAAGA,IAAI,CAAC,EAAE;QAE9B,CAAC;IACH;IACA,OAAOF;AACT,EAAC;AAID;;;;;;;;;;;;;CAaC,GACD,OAAO,MAAMG,UAAU,CACrBC,MACAC,SAAS,YAAY,EACrBC,IACAC,UACG;IACH,IAAIH,MAAM;QACR,IAAIE,IAAI;YACN,IAAIC,SACF,OAAO1C,MAAMyC,EAAE,CAACF,MAAME,IAAID,MAAM,CAACA;iBAEjC,OAAOxC,MAAMuC,MAAME,EAAE,CAACA,IAAID,MAAM,CAACA;QAErC,CAAC;QACD,OAAOxC,MAAMuC,MAAMC,MAAM,CAACA;IAC5B,OACE,OAAO,IAAI;AAEf,EAAE"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
import {
|
|
2
|
+
import { DrawerProps } from "antd";
|
|
3
|
+
import { App, AppMenu } from "@knockout-js/api/esm/gql/ucenter/graphql";
|
|
3
4
|
export type AggregateMenuLocale = {
|
|
4
5
|
title: string;
|
|
5
6
|
latelyTitle: string;
|
|
@@ -19,6 +20,10 @@ export interface AggregateMenuProps {
|
|
|
19
20
|
* 数据源
|
|
20
21
|
*/
|
|
21
22
|
dataSource?: AggregateMenuDataSource;
|
|
23
|
+
/**
|
|
24
|
+
* 弹框设置
|
|
25
|
+
*/
|
|
26
|
+
drawerProps?: DrawerProps;
|
|
22
27
|
/**
|
|
23
28
|
* 弹出开关变更
|
|
24
29
|
*/
|
|
@@ -26,7 +31,7 @@ export interface AggregateMenuProps {
|
|
|
26
31
|
/**
|
|
27
32
|
* 选中菜单
|
|
28
33
|
*/
|
|
29
|
-
onClick?: (menuItem: AppMenu, app: App) => void;
|
|
34
|
+
onClick?: (menuItem: AppMenu, app: App, isOpen?: boolean) => void;
|
|
30
35
|
}
|
|
31
36
|
declare const _default: (props: AggregateMenuProps) => JSX.Element;
|
|
32
37
|
export default _default;
|
|
@@ -5,28 +5,34 @@ import { CloseOutlined, DragOutlined, SearchOutlined, StarOutlined } from "@ant-
|
|
|
5
5
|
import { useCallback, useEffect, useState } from "react";
|
|
6
6
|
import styles from "./index.module.css";
|
|
7
7
|
import { Drawer, Empty, Input, Space } from "antd";
|
|
8
|
-
import { gql, paging, query } from "@knockout-js/ice-urql/request";
|
|
9
|
-
import { AppMenuKind } from "@knockout-js/api";
|
|
10
|
-
import { iceUrqlInstance } from "../index";
|
|
8
|
+
import { gql, mutation, paging, query } from "@knockout-js/ice-urql/request";
|
|
11
9
|
import { DndContext, closestCenter, KeyboardSensor, PointerSensor, useSensor, useSensors } from "@dnd-kit/core";
|
|
12
10
|
import { arrayMove, SortableContext, useSortable, sortableKeyboardCoordinates, verticalListSortingStrategy } from "@dnd-kit/sortable";
|
|
13
11
|
import { CSS } from "@dnd-kit/utilities";
|
|
14
12
|
import { useLocale } from "../locale/index";
|
|
15
|
-
import { useDark
|
|
16
|
-
|
|
13
|
+
import { useDark } from "../provider/index";
|
|
14
|
+
import { listFormatTreeData, treeFormatList } from "../_util/index";
|
|
15
|
+
import { OpenWin } from "../icons/index";
|
|
16
|
+
import { AppMenuKind } from "@knockout-js/api/esm/gql/ucenter/graphql";
|
|
17
|
+
import { instanceName } from "@knockout-js/api";
|
|
18
|
+
const userMenuListQuery = gql(/* GraphQL */ `query layoutPkgUserMenuList($appCode:String!){
|
|
17
19
|
userMenus(appCode: $appCode){
|
|
18
20
|
id,name,route,appID,parentID,displaySort,kind
|
|
19
21
|
}
|
|
20
22
|
}`);
|
|
21
|
-
const
|
|
22
|
-
|
|
23
|
-
id,
|
|
24
|
-
apps(first: $first){
|
|
25
|
-
totalCount,
|
|
26
|
-
edges{ node{ id,name,code } }
|
|
27
|
-
}
|
|
23
|
+
const userAppsQuery = gql(/* GraphQL */ `query layoutPkgUserAppList{
|
|
24
|
+
userApps{
|
|
25
|
+
id,name,code
|
|
28
26
|
}
|
|
29
27
|
}`);
|
|
28
|
+
const userPreferenceQuery = gql(/* GraphQL */ `query layoutPkgUserPreference{
|
|
29
|
+
orgUserPreference{
|
|
30
|
+
id,menuFavorite,menuRecent,
|
|
31
|
+
}
|
|
32
|
+
}`);
|
|
33
|
+
const userPreferenceMut = gql(/* GraphQL */ `mutation layoutPkgSaveUserPreference($input:OrgUserPreferenceInput!){
|
|
34
|
+
saveOrgUserPreference(input: $input){ id }
|
|
35
|
+
}`);
|
|
30
36
|
/**
|
|
31
37
|
* 排序拖拽使用的控件
|
|
32
38
|
* https://docs.dndkit.com/
|
|
@@ -58,9 +64,17 @@ const userOrgAppsQuery = gql(/* GraphQL */ `query layoutPkgUserRootOrgs($first:I
|
|
|
58
64
|
className: styles.aggregateMenuDrawerMenuItemIcons,
|
|
59
65
|
children: /*#__PURE__*/ _jsxs(Space, {
|
|
60
66
|
children: [
|
|
67
|
+
/*#__PURE__*/ _jsx(OpenWin, {
|
|
68
|
+
className: "anticon",
|
|
69
|
+
onClick: (event)=>{
|
|
70
|
+
event.stopPropagation();
|
|
71
|
+
props.onClick(true);
|
|
72
|
+
}
|
|
73
|
+
}),
|
|
61
74
|
/*#__PURE__*/ _jsx(CloseOutlined, {
|
|
62
75
|
rev: undefined,
|
|
63
|
-
onClick: ()=>{
|
|
76
|
+
onClick: (event)=>{
|
|
77
|
+
event.stopPropagation();
|
|
64
78
|
props.onDel();
|
|
65
79
|
}
|
|
66
80
|
}),
|
|
@@ -76,24 +90,16 @@ const userOrgAppsQuery = gql(/* GraphQL */ `query layoutPkgUserRootOrgs($first:I
|
|
|
76
90
|
}));
|
|
77
91
|
};
|
|
78
92
|
export default ((props)=>{
|
|
79
|
-
const [all, setAll] = useState([]), [filterList, setFilterList] = useState([]), [collects, setCollects] = useState([]), [latelys, setLately] = useState([]), locale = useLocale('AggregateMenu'), isDark = useDark(),
|
|
93
|
+
const [all, setAll] = useState([]), [filterList, setFilterList] = useState([]), [collects, setCollects] = useState([]), [latelys, setLately] = useState([]), locale = useLocale('AggregateMenu'), isDark = useDark(), sensors = useSensors(useSensor(PointerSensor), useSensor(KeyboardSensor, {
|
|
80
94
|
coordinateGetter: sortableKeyboardCoordinates
|
|
81
95
|
}));
|
|
82
96
|
const request = useCallback(async ()=>{
|
|
83
|
-
var _appsResult_data;
|
|
84
|
-
const appsResult = await paging(
|
|
85
|
-
|
|
86
|
-
}, 1, {
|
|
87
|
-
instanceName: iceUrqlInstance.ucenter
|
|
97
|
+
var _appsResult_data, _preferenceResult_data, _preferenceResult_data_orgUserPreference;
|
|
98
|
+
const appsResult = await paging(userAppsQuery, {}, 1, {
|
|
99
|
+
instanceName: instanceName.UCENTER
|
|
88
100
|
}), apps = [];
|
|
89
|
-
if ((_appsResult_data = appsResult.data) === null || _appsResult_data === void 0 ? void 0 : _appsResult_data.
|
|
90
|
-
|
|
91
|
-
if (tenantId === org.id) (_org_apps_edges = org.apps.edges) === null || _org_apps_edges === void 0 ? void 0 : _org_apps_edges.forEach((oApp)=>{
|
|
92
|
-
if ((oApp === null || oApp === void 0 ? void 0 : oApp.node) && !apps.find((app)=>{
|
|
93
|
-
var _oApp_node;
|
|
94
|
-
return app.id === ((_oApp_node = oApp.node) === null || _oApp_node === void 0 ? void 0 : _oApp_node.id);
|
|
95
|
-
})) apps.push(oApp.node);
|
|
96
|
-
});
|
|
101
|
+
if ((_appsResult_data = appsResult.data) === null || _appsResult_data === void 0 ? void 0 : _appsResult_data.userApps) appsResult.data.userApps.forEach((app)=>{
|
|
102
|
+
apps.push(app);
|
|
97
103
|
});
|
|
98
104
|
const newAll = [];
|
|
99
105
|
for(let i in apps){
|
|
@@ -101,7 +107,7 @@ export default ((props)=>{
|
|
|
101
107
|
const menuResult = await query(userMenuListQuery, {
|
|
102
108
|
appCode: apps[i].code
|
|
103
109
|
}, {
|
|
104
|
-
instanceName:
|
|
110
|
+
instanceName: instanceName.UCENTER
|
|
105
111
|
});
|
|
106
112
|
if ((_menuResult_data = menuResult.data) === null || _menuResult_data === void 0 ? void 0 : _menuResult_data.userMenus) {
|
|
107
113
|
const menu = menuResult.data.userMenus.sort((d1, d2)=>{
|
|
@@ -110,23 +116,84 @@ export default ((props)=>{
|
|
|
110
116
|
});
|
|
111
117
|
newAll.push({
|
|
112
118
|
app: apps[i],
|
|
113
|
-
menu
|
|
119
|
+
menu: treeFormatList(listFormatTreeData(menu, undefined, {
|
|
120
|
+
key: 'id',
|
|
121
|
+
parentId: 'parentID'
|
|
122
|
+
}))
|
|
114
123
|
});
|
|
115
124
|
}
|
|
116
125
|
}
|
|
117
126
|
setAll(newAll);
|
|
118
127
|
setFilterList(newAll);
|
|
119
|
-
|
|
128
|
+
// 初始化收藏和初始化最近数据
|
|
129
|
+
const preferenceResult = await query(userPreferenceQuery, {}, {
|
|
130
|
+
instanceName: instanceName.UCENTER
|
|
131
|
+
});
|
|
132
|
+
if ((_preferenceResult_data = preferenceResult.data) === null || _preferenceResult_data === void 0 ? void 0 : (_preferenceResult_data_orgUserPreference = _preferenceResult_data.orgUserPreference) === null || _preferenceResult_data_orgUserPreference === void 0 ? void 0 : _preferenceResult_data_orgUserPreference.id) {
|
|
133
|
+
const menuFavorite = preferenceResult.data.orgUserPreference.menuFavorite, menuRecent = preferenceResult.data.orgUserPreference.menuRecent, collectsList = [], latelyList = [];
|
|
134
|
+
if (menuFavorite) menuFavorite.forEach((id)=>{
|
|
135
|
+
for(let i in newAll){
|
|
136
|
+
const menuItem = newAll[i].menu.find((item)=>item.id == id);
|
|
137
|
+
if (menuItem) {
|
|
138
|
+
collectsList.push(menuItem);
|
|
139
|
+
break;
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
});
|
|
143
|
+
if (menuRecent) menuRecent.forEach((id)=>{
|
|
144
|
+
for(let i in newAll){
|
|
145
|
+
const menuItem = newAll[i].menu.find((item)=>item.id == id);
|
|
146
|
+
if (menuItem) {
|
|
147
|
+
latelyList.push(menuItem);
|
|
148
|
+
break;
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
});
|
|
152
|
+
setCollects(collectsList);
|
|
153
|
+
setLately(latelyList);
|
|
154
|
+
}
|
|
155
|
+
}, []), requestFavorite = async (list)=>{
|
|
156
|
+
// 异步存储收藏
|
|
157
|
+
await mutation(userPreferenceMut, {
|
|
158
|
+
input: {
|
|
159
|
+
menuFavorite: list.map((item)=>item.id)
|
|
160
|
+
}
|
|
161
|
+
}, {
|
|
162
|
+
instanceName: instanceName.UCENTER
|
|
163
|
+
});
|
|
164
|
+
}, requestRecent = async (ids)=>{
|
|
165
|
+
// 异步存储访问菜单记录
|
|
166
|
+
await mutation(userPreferenceMut, {
|
|
167
|
+
input: {
|
|
168
|
+
menuRecent: ids
|
|
169
|
+
}
|
|
170
|
+
}, {
|
|
171
|
+
instanceName: instanceName.UCENTER
|
|
172
|
+
});
|
|
173
|
+
}, checkCollect = useCallback((menuItem)=>{
|
|
120
174
|
return !!collects.find((item)=>item.id === menuItem.id && item.appID === menuItem.appID);
|
|
121
175
|
}, [
|
|
122
176
|
collects
|
|
123
|
-
]),
|
|
177
|
+
]), onClickItem = async (menuItem, isOpen)=>{
|
|
178
|
+
const allApp = all.find((allItem)=>allItem.app.id == menuItem.appID);
|
|
179
|
+
if (allApp) {
|
|
180
|
+
var _props_onClick;
|
|
181
|
+
const latelyList = [
|
|
182
|
+
...latelys
|
|
183
|
+
];
|
|
184
|
+
const oldIdx = latelyList.findIndex((lately)=>lately.id == menuItem.id);
|
|
185
|
+
if (oldIdx > -1) latelyList.splice(oldIdx, 1);
|
|
186
|
+
latelyList.unshift(menuItem);
|
|
187
|
+
latelyList.splice(6);
|
|
188
|
+
await requestRecent(latelyList.map((item)=>item.id));
|
|
189
|
+
setLately(latelyList);
|
|
190
|
+
(_props_onClick = props.onClick) === null || _props_onClick === void 0 ? void 0 : _props_onClick.call(props, menuItem, allApp.app, isOpen);
|
|
191
|
+
}
|
|
192
|
+
}, menuItemRender = (menuItem)=>{
|
|
124
193
|
return /*#__PURE__*/ _jsxs("div", {
|
|
125
194
|
className: styles.aggregateMenuDrawerAllMenuItem,
|
|
126
195
|
onClick: ()=>{
|
|
127
|
-
|
|
128
|
-
const allApp = all.find((allItem)=>allItem.app.id == menuItem.appID);
|
|
129
|
-
if (allApp) (_props_onClick = props.onClick) === null || _props_onClick === void 0 ? void 0 : _props_onClick.call(props, menuItem, allApp.app);
|
|
196
|
+
onClickItem(menuItem);
|
|
130
197
|
},
|
|
131
198
|
children: [
|
|
132
199
|
/*#__PURE__*/ _jsxs("div", {
|
|
@@ -137,17 +204,32 @@ export default ((props)=>{
|
|
|
137
204
|
]
|
|
138
205
|
}),
|
|
139
206
|
/*#__PURE__*/ _jsx("div", {
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
207
|
+
className: styles.aggregateMenuDrawerAllMenuItemIcons,
|
|
208
|
+
children: /*#__PURE__*/ _jsxs(Space, {
|
|
209
|
+
children: [
|
|
210
|
+
/*#__PURE__*/ _jsx(OpenWin, {
|
|
211
|
+
className: "anticon",
|
|
212
|
+
onClick: (event)=>{
|
|
213
|
+
event.stopPropagation();
|
|
214
|
+
onClickItem(menuItem, true);
|
|
215
|
+
}
|
|
216
|
+
}),
|
|
217
|
+
/*#__PURE__*/ _jsx(StarOutlined, {
|
|
218
|
+
rev: undefined,
|
|
219
|
+
className: checkCollect(menuItem) ? 'collect' : '',
|
|
220
|
+
onClick: async (event)=>{
|
|
221
|
+
event.stopPropagation();
|
|
222
|
+
let collectList = [];
|
|
223
|
+
if (checkCollect(menuItem)) collectList = collects.filter((c)=>!(c.id === menuItem.id && c.appID === menuItem.appID));
|
|
224
|
+
else collectList = [
|
|
225
|
+
...collects,
|
|
226
|
+
menuItem
|
|
227
|
+
];
|
|
228
|
+
await requestFavorite(collectList);
|
|
229
|
+
setCollects(collectList);
|
|
230
|
+
}
|
|
231
|
+
})
|
|
232
|
+
]
|
|
151
233
|
})
|
|
152
234
|
})
|
|
153
235
|
]
|
|
@@ -162,12 +244,14 @@ export default ((props)=>{
|
|
|
162
244
|
props.dataSource
|
|
163
245
|
]);
|
|
164
246
|
return /*#__PURE__*/ _jsx(_Fragment, {
|
|
165
|
-
children: /*#__PURE__*/ _jsx(Drawer, {
|
|
166
|
-
className: `${styles.aggregateMenuDrawer} ${isDark ? styles.aggregateMenuDark : ''}`,
|
|
247
|
+
children: /*#__PURE__*/ _jsx(Drawer, _object_spread_props(_object_spread({
|
|
167
248
|
title: locale.title,
|
|
249
|
+
maskClosable: false,
|
|
168
250
|
placement: "left",
|
|
251
|
+
width: 1060
|
|
252
|
+
}, props.drawerProps), {
|
|
253
|
+
className: `${styles.aggregateMenuDrawer} ${isDark ? styles.aggregateMenuDark : ''}`,
|
|
169
254
|
open: props.open,
|
|
170
|
-
width: 1060,
|
|
171
255
|
onClose: ()=>{
|
|
172
256
|
var _props_onChangeOpen;
|
|
173
257
|
(_props_onChangeOpen = props.onChangeOpen) === null || _props_onChangeOpen === void 0 ? void 0 : _props_onChangeOpen.call(props, false);
|
|
@@ -188,25 +272,25 @@ export default ((props)=>{
|
|
|
188
272
|
if (over && active.id !== over.id) setCollects((items)=>{
|
|
189
273
|
const oldIndex = items.findIndex((oItem)=>`${oItem.id}-${oItem.appID}` == active.id);
|
|
190
274
|
const newIndex = items.findIndex((nItem)=>`${nItem.id}-${nItem.appID}` == over.id);
|
|
191
|
-
|
|
275
|
+
const collectList = arrayMove(items, oldIndex, newIndex);
|
|
276
|
+
requestFavorite(collectList);
|
|
277
|
+
return collectList;
|
|
192
278
|
});
|
|
193
279
|
},
|
|
194
280
|
children: /*#__PURE__*/ _jsx(SortableContext, {
|
|
195
281
|
items: collects.map((item)=>`${item.id}-${item.appID}`),
|
|
196
282
|
strategy: verticalListSortingStrategy,
|
|
197
|
-
children: collects.map((item)
|
|
198
|
-
/*#__PURE__*/ return _jsx(DargItem, {
|
|
283
|
+
children: collects.map((item)=>/*#__PURE__*/ _jsx(DargItem, {
|
|
199
284
|
value: item,
|
|
200
|
-
onDel: ()=>{
|
|
201
|
-
|
|
285
|
+
onDel: async ()=>{
|
|
286
|
+
const collectList = collects.filter((c)=>!(c.id === item.id && c.appID === item.appID));
|
|
287
|
+
await requestFavorite(collectList);
|
|
288
|
+
setCollects(collectList);
|
|
202
289
|
},
|
|
203
|
-
onClick: ()=>{
|
|
204
|
-
|
|
205
|
-
const allApp = all.find((allItem)=>allItem.app.id == item.appID);
|
|
206
|
-
if (allApp) (_props_onClick = props.onClick) === null || _props_onClick === void 0 ? void 0 : _props_onClick.call(props, item, allApp.app);
|
|
290
|
+
onClick: (isOpen)=>{
|
|
291
|
+
onClickItem(item, isOpen);
|
|
207
292
|
}
|
|
208
|
-
}, `c${item.id}-${item.appID}`)
|
|
209
|
-
})
|
|
293
|
+
}, `c${item.id}-${item.appID}`))
|
|
210
294
|
})
|
|
211
295
|
}) : /*#__PURE__*/ _jsx(Empty, {
|
|
212
296
|
image: Empty.PRESENTED_IMAGE_SIMPLE,
|
|
@@ -260,25 +344,28 @@ export default ((props)=>{
|
|
|
260
344
|
style: {
|
|
261
345
|
height: latelys.length ? "calc(100% - 164px)" : "calc(100% - 52px)"
|
|
262
346
|
},
|
|
263
|
-
children:
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
347
|
+
children: /*#__PURE__*/ _jsx("div", {
|
|
348
|
+
className: styles.aggregateMenuDrawerAllMenuColumn,
|
|
349
|
+
children: filterList.map((item)=>/*#__PURE__*/ _jsxs("div", {
|
|
350
|
+
className: styles.aggregateMenuDrawerAllMenuColumnItem,
|
|
351
|
+
children: [
|
|
352
|
+
/*#__PURE__*/ _jsx("div", {
|
|
353
|
+
className: styles.aggregateMenuDrawerAllAppTitle,
|
|
354
|
+
children: item.app.name
|
|
355
|
+
}),
|
|
356
|
+
item.menu.map((menuItem)=>menuItem.kind === AppMenuKind.Menu ? menuItemRender(menuItem) : /*#__PURE__*/ _jsx("div", {
|
|
357
|
+
className: styles.aggregateMenuDrawerAllMenuItemDir,
|
|
358
|
+
children: menuItem.name
|
|
359
|
+
}, `${menuItem.appID}-${menuItem.id}`))
|
|
360
|
+
]
|
|
361
|
+
}, item.app.code))
|
|
362
|
+
})
|
|
276
363
|
})
|
|
277
364
|
]
|
|
278
365
|
})
|
|
279
366
|
]
|
|
280
367
|
})
|
|
281
|
-
})
|
|
368
|
+
}))
|
|
282
369
|
});
|
|
283
370
|
});
|
|
284
371
|
|