@whitesev/pops 2.4.6 → 2.4.7
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/dist/index.amd.js +578 -571
- package/dist/index.amd.js.map +1 -1
- package/dist/index.cjs.js +578 -571
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +578 -571
- package/dist/index.esm.js.map +1 -1
- package/dist/index.iife.js +578 -571
- package/dist/index.iife.js.map +1 -1
- package/dist/index.system.js +578 -571
- package/dist/index.system.js.map +1 -1
- package/dist/index.umd.js +578 -571
- package/dist/index.umd.js.map +1 -1
- package/dist/types/src/types/PopsDOMUtilsEventType.d.ts +252 -252
- package/dist/types/src/types/animation.d.ts +19 -19
- package/dist/types/src/types/button.d.ts +187 -187
- package/dist/types/src/types/components.d.ts +210 -210
- package/dist/types/src/types/event.d.ts +63 -63
- package/dist/types/src/types/global.d.ts +25 -25
- package/dist/types/src/types/icon.d.ts +32 -32
- package/dist/types/src/types/inst.d.ts +24 -24
- package/dist/types/src/types/main.d.ts +111 -111
- package/dist/types/src/types/mask.d.ts +49 -49
- package/dist/types/src/types/position.d.ts +60 -60
- package/index.ts +3 -0
- package/package.json +4 -2
- package/src/Pops.ts +206 -0
- package/src/PopsAnimation.ts +32 -0
- package/src/PopsCSS.ts +51 -0
- package/src/PopsCore.ts +64 -0
- package/src/PopsIcon.ts +95 -0
- package/src/PopsInst.ts +21 -0
- package/src/components/alert/config.ts +62 -0
- package/src/components/alert/index.css +0 -0
- package/src/components/alert/index.ts +163 -0
- package/src/components/alert/types/index.ts +23 -0
- package/src/components/confirm/config.ts +90 -0
- package/src/components/confirm/index.css +0 -0
- package/src/components/confirm/index.ts +166 -0
- package/src/components/confirm/types/index.ts +17 -0
- package/src/components/drawer/config.ts +89 -0
- package/src/components/drawer/index.css +37 -0
- package/src/components/drawer/index.ts +237 -0
- package/src/components/drawer/types/index.ts +61 -0
- package/src/components/folder/config.ts +147 -0
- package/src/components/folder/folderIcon.ts +28 -0
- package/src/components/folder/index.css +303 -0
- package/src/components/folder/index.ts +929 -0
- package/src/components/folder/types/index.ts +97 -0
- package/src/components/iframe/config.ts +60 -0
- package/src/components/iframe/index.css +76 -0
- package/src/components/iframe/index.ts +334 -0
- package/src/components/iframe/types/index.ts +139 -0
- package/src/components/loading/config.ts +29 -0
- package/src/components/loading/index.css +66 -0
- package/src/components/loading/index.ts +99 -0
- package/src/components/loading/types/index.ts +34 -0
- package/src/components/panel/config.ts +519 -0
- package/src/components/panel/handlerComponents.ts +2900 -0
- package/src/components/panel/index.css +1222 -0
- package/src/components/panel/index.ts +207 -0
- package/src/components/panel/types/components-button.ts +68 -0
- package/src/components/panel/types/components-common.ts +50 -0
- package/src/components/panel/types/components-deepMenu.ts +84 -0
- package/src/components/panel/types/components-forms.ts +44 -0
- package/src/components/panel/types/components-input.ts +78 -0
- package/src/components/panel/types/components-own.ts +30 -0
- package/src/components/panel/types/components-select.ts +93 -0
- package/src/components/panel/types/components-selectMultiple.ts +130 -0
- package/src/components/panel/types/components-slider.ts +77 -0
- package/src/components/panel/types/components-switch.ts +56 -0
- package/src/components/panel/types/components-textarea.ts +68 -0
- package/src/components/panel/types/index.ts +177 -0
- package/src/components/prompt/config.ts +94 -0
- package/src/components/prompt/index.css +34 -0
- package/src/components/prompt/index.ts +216 -0
- package/src/components/prompt/types/index.ts +55 -0
- package/src/components/rightClickMenu/config.ts +98 -0
- package/src/components/rightClickMenu/index.css +112 -0
- package/src/components/rightClickMenu/index.ts +602 -0
- package/src/components/rightClickMenu/types/index.ts +97 -0
- package/src/components/searchSuggestion/config.ts +56 -0
- package/src/components/searchSuggestion/index.ts +856 -0
- package/src/components/searchSuggestion/types/index.ts +239 -0
- package/src/components/tooltip/config.ts +34 -0
- package/src/components/tooltip/index.css +199 -0
- package/src/components/tooltip/index.ts +604 -0
- package/src/components/tooltip/types/index.ts +117 -0
- package/src/config/CommonCSSClassName.ts +17 -0
- package/src/config/GlobalConfig.ts +63 -0
- package/src/css/animation.css +987 -0
- package/src/css/button.css +551 -0
- package/src/css/common.css +48 -0
- package/src/css/index.css +253 -0
- package/src/css/ninePalaceGridPosition.css +50 -0
- package/src/css/scrollbar.css +22 -0
- package/src/handler/PopsElementHandler.ts +304 -0
- package/src/handler/PopsHandler.ts +589 -0
- package/src/svg/arrowLeft.svg +4 -0
- package/src/svg/arrowRight.svg +4 -0
- package/src/svg/chromeFilled.svg +11 -0
- package/src/svg/circleClose.svg +8 -0
- package/src/svg/close.svg +5 -0
- package/src/svg/cpu.svg +8 -0
- package/src/svg/delete.svg +5 -0
- package/src/svg/documentCopy.svg +5 -0
- package/src/svg/edit.svg +8 -0
- package/src/svg/eleme.svg +5 -0
- package/src/svg/elemePlus.svg +5 -0
- package/src/svg/headset.svg +5 -0
- package/src/svg/hide.svg +8 -0
- package/src/svg/keyboard.svg +8 -0
- package/src/svg/loading.svg +5 -0
- package/src/svg/max.svg +5 -0
- package/src/svg/min.svg +5 -0
- package/src/svg/mise.svg +5 -0
- package/src/svg/monitor.svg +5 -0
- package/src/svg/next.svg +5 -0
- package/src/svg/picture.svg +8 -0
- package/src/svg/prev.svg +5 -0
- package/src/svg/search.svg +5 -0
- package/src/svg/share.svg +5 -0
- package/src/svg/upload.svg +5 -0
- package/src/svg/videoPause.svg +5 -0
- package/src/svg/videoPlay.svg +5 -0
- package/src/svg/view.svg +5 -0
- package/src/types/PopsDOMUtilsEventType.d.ts +252 -0
- package/src/types/animation.d.ts +19 -0
- package/src/types/button.d.ts +187 -0
- package/src/types/components.d.ts +210 -0
- package/src/types/event.d.ts +63 -0
- package/src/types/global.d.ts +25 -0
- package/src/types/icon.d.ts +32 -0
- package/src/types/inst.d.ts +24 -0
- package/src/types/main.d.ts +111 -0
- package/src/types/mask.d.ts +49 -0
- package/src/types/position.d.ts +60 -0
- package/src/utils/PopsDOMUtils.ts +2408 -0
- package/src/utils/PopsDOMUtilsEventsConfig.ts +4 -0
- package/src/utils/PopsInstanceUtils.ts +688 -0
- package/src/utils/PopsMathUtils.ts +71 -0
- package/src/utils/PopsSafeUtils.ts +22 -0
- package/src/utils/PopsUtils.ts +406 -0
|
@@ -0,0 +1,929 @@
|
|
|
1
|
+
import { GlobalConfig } from "../../config/GlobalConfig";
|
|
2
|
+
import { PopsElementHandler } from "../../handler/PopsElementHandler";
|
|
3
|
+
import { PopsHandler } from "../../handler/PopsHandler";
|
|
4
|
+
import { PopsCSS } from "../../PopsCSS";
|
|
5
|
+
import type { PopsType } from "../../types/main";
|
|
6
|
+
import { popsDOMUtils } from "../../utils/PopsDOMUtils";
|
|
7
|
+
import { PopsInstanceUtils } from "../../utils/PopsInstanceUtils";
|
|
8
|
+
import { PopsSafeUtils } from "../../utils/PopsSafeUtils";
|
|
9
|
+
import { popsUtils } from "../../utils/PopsUtils";
|
|
10
|
+
import { PopsLoading } from "../loading";
|
|
11
|
+
import { PopsFolderConfig } from "./config";
|
|
12
|
+
import { Folder_ICON } from "./folderIcon";
|
|
13
|
+
import type { PopsFolderDataConfig, PopsFolderDetails } from "./types";
|
|
14
|
+
|
|
15
|
+
export const PopsFolder = {
|
|
16
|
+
init(details: PopsFolderDetails) {
|
|
17
|
+
const guid = popsUtils.getRandomGUID();
|
|
18
|
+
// 设置当前类型
|
|
19
|
+
const popsType: PopsType = "folder";
|
|
20
|
+
|
|
21
|
+
let config = PopsFolderConfig();
|
|
22
|
+
config = popsUtils.assign(config, GlobalConfig.getGlobalConfig());
|
|
23
|
+
config = popsUtils.assign(config, details);
|
|
24
|
+
config = PopsHandler.handleOnly(popsType, config);
|
|
25
|
+
|
|
26
|
+
const { $shadowContainer, $shadowRoot } = PopsHandler.handlerShadow(config);
|
|
27
|
+
PopsHandler.handleInit($shadowRoot, [
|
|
28
|
+
{
|
|
29
|
+
name: "index",
|
|
30
|
+
css: PopsCSS.index,
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
name: "ninePalaceGridPosition",
|
|
34
|
+
css: PopsCSS.ninePalaceGridPosition,
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
name: "scrollbar",
|
|
38
|
+
css: PopsCSS.scrollbar,
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
name: "button",
|
|
42
|
+
css: PopsCSS.button,
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
name: "anim",
|
|
46
|
+
css: PopsCSS.anim,
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
name: "common",
|
|
50
|
+
css: PopsCSS.common,
|
|
51
|
+
},
|
|
52
|
+
{
|
|
53
|
+
name: "folderCSS",
|
|
54
|
+
css: PopsCSS.folderCSS,
|
|
55
|
+
},
|
|
56
|
+
]);
|
|
57
|
+
|
|
58
|
+
/* 办公几件套 */
|
|
59
|
+
Reflect.set(Folder_ICON, "docx", Folder_ICON.doc);
|
|
60
|
+
Reflect.set(Folder_ICON, "rtf", Folder_ICON.doc);
|
|
61
|
+
Reflect.set(Folder_ICON, "xlsx", Folder_ICON.xls);
|
|
62
|
+
Reflect.set(Folder_ICON, "pptx", Folder_ICON.ppt);
|
|
63
|
+
Reflect.set(Folder_ICON, "dmg", Folder_ICON.ipa);
|
|
64
|
+
Reflect.set(Folder_ICON, "json", Folder_ICON.js);
|
|
65
|
+
|
|
66
|
+
/* 压缩包 */
|
|
67
|
+
const zipIconList = [
|
|
68
|
+
"rar",
|
|
69
|
+
"7z",
|
|
70
|
+
"arj",
|
|
71
|
+
"bz2",
|
|
72
|
+
"cab",
|
|
73
|
+
"iso",
|
|
74
|
+
"jar",
|
|
75
|
+
"lz",
|
|
76
|
+
"lzh",
|
|
77
|
+
"tar",
|
|
78
|
+
"uue",
|
|
79
|
+
"xz",
|
|
80
|
+
"z",
|
|
81
|
+
"zipx",
|
|
82
|
+
"zst",
|
|
83
|
+
"001",
|
|
84
|
+
];
|
|
85
|
+
|
|
86
|
+
/* 图片 */
|
|
87
|
+
const imageIconList = ["jpg", "jpeg", "ico", "webp"];
|
|
88
|
+
|
|
89
|
+
/* 代码语言 */
|
|
90
|
+
const codeLanguageIconList = ["htm", "py", "vue", "bat", "sh", "vbs", "java", "kt"];
|
|
91
|
+
|
|
92
|
+
/* Android安装包 */
|
|
93
|
+
const androidIconList = ["apk", "apkm", "xapk"];
|
|
94
|
+
|
|
95
|
+
zipIconList.forEach((keyName) => {
|
|
96
|
+
Folder_ICON[keyName as keyof typeof Folder_ICON] = Folder_ICON.zip;
|
|
97
|
+
});
|
|
98
|
+
imageIconList.forEach((keyName) => {
|
|
99
|
+
Folder_ICON[keyName as keyof typeof Folder_ICON] = Folder_ICON.png;
|
|
100
|
+
});
|
|
101
|
+
codeLanguageIconList.forEach((keyName) => {
|
|
102
|
+
Folder_ICON[keyName as keyof typeof Folder_ICON] = Folder_ICON.html;
|
|
103
|
+
});
|
|
104
|
+
androidIconList.forEach((keyName) => {
|
|
105
|
+
Folder_ICON[keyName as keyof typeof Folder_ICON] = Folder_ICON.apk;
|
|
106
|
+
});
|
|
107
|
+
|
|
108
|
+
if (details?.folder) {
|
|
109
|
+
Reflect.set(config, "folder", details.folder);
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
// 先把z-index提取出来
|
|
113
|
+
const zIndex = PopsHandler.handleZIndex(config.zIndex);
|
|
114
|
+
const maskHTML = PopsElementHandler.createMask(guid, zIndex);
|
|
115
|
+
|
|
116
|
+
const headerBtnHTML = PopsElementHandler.createHeader(popsType, config);
|
|
117
|
+
const bottomBtnHTML = PopsElementHandler.createBottom(popsType, config);
|
|
118
|
+
const { headerStyle, headerPStyle } = PopsElementHandler.createHeaderStyle(popsType, config);
|
|
119
|
+
const animHTML = PopsElementHandler.createAnim(
|
|
120
|
+
guid,
|
|
121
|
+
popsType,
|
|
122
|
+
config,
|
|
123
|
+
/*html*/ `
|
|
124
|
+
<div class="pops-title pops-${popsType}-title" style="text-align: ${
|
|
125
|
+
config.title.position
|
|
126
|
+
};${headerStyle}">${
|
|
127
|
+
config.title.html
|
|
128
|
+
? config.title.text
|
|
129
|
+
: `<p pops class="pops-${popsType}-title-text" style="${headerPStyle}">${config.title.text}</p>`
|
|
130
|
+
}${headerBtnHTML}</div>
|
|
131
|
+
<div class="pops-content pops-${popsType}-content ${popsUtils.isPhone() ? "pops-mobile-folder-content" : ""}">
|
|
132
|
+
<div class="pops-folder-list">
|
|
133
|
+
<div class="pops-folder-file-list-breadcrumb">
|
|
134
|
+
<div class="pops-folder-file-list-breadcrumb-primary">
|
|
135
|
+
<span class="pops-folder-file-list-breadcrumb-allFiles cursor-p" title="全部文件">
|
|
136
|
+
<a>全部文件</a>
|
|
137
|
+
</span>
|
|
138
|
+
</div>
|
|
139
|
+
</div>
|
|
140
|
+
<div class="pops-folder-list-table__header-div">
|
|
141
|
+
<table class="pops-folder-list-table__header">
|
|
142
|
+
<colgroup>
|
|
143
|
+
<col width="52%">
|
|
144
|
+
<col width="24%">
|
|
145
|
+
<col width="16%">
|
|
146
|
+
</colgroup>
|
|
147
|
+
<thead>
|
|
148
|
+
<tr class="pops-folder-list-table__header-row">
|
|
149
|
+
<th class="pops-folder-list-table__header-th cursor-p">
|
|
150
|
+
<div class="text-ellip content flex-a-i-center">
|
|
151
|
+
<span>文件名</span>
|
|
152
|
+
<div class="pops-folder-list-table__sort" data-sort="fileName">
|
|
153
|
+
<div class="pops-folder-icon-arrow" data-sort="按文件名排序">
|
|
154
|
+
<svg
|
|
155
|
+
viewBox="0 0 1024 1024"
|
|
156
|
+
xmlns="http://www.w3.org/2000/svg">
|
|
157
|
+
<path
|
|
158
|
+
d="M509.624392 5.882457 57.127707 458.379143 962.121078 458.379143Z"
|
|
159
|
+
class="pops-folder-icon-arrow-up"></path>
|
|
160
|
+
<path
|
|
161
|
+
d="M509.624392 1024 962.121078 571.503314 57.127707 571.503314Z"
|
|
162
|
+
class="pops-folder-icon-arrow-down"></path>
|
|
163
|
+
</svg>
|
|
164
|
+
</div>
|
|
165
|
+
</div>
|
|
166
|
+
</div>
|
|
167
|
+
</th>
|
|
168
|
+
<th class="pops-folder-list-table__header-th cursor-p">
|
|
169
|
+
<div class="text-ellip content flex-a-i-center">
|
|
170
|
+
<span>修改时间</span>
|
|
171
|
+
<div class="pops-folder-list-table__sort" data-sort="latestTime">
|
|
172
|
+
<div class="pops-folder-icon-arrow" title="按修改时间排序">
|
|
173
|
+
<svg
|
|
174
|
+
viewBox="0 0 1024 1024"
|
|
175
|
+
xmlns="http://www.w3.org/2000/svg">
|
|
176
|
+
<path
|
|
177
|
+
d="M509.624392 5.882457 57.127707 458.379143 962.121078 458.379143Z"
|
|
178
|
+
class="pops-folder-icon-arrow-up"></path>
|
|
179
|
+
<path
|
|
180
|
+
d="M509.624392 1024 962.121078 571.503314 57.127707 571.503314Z"
|
|
181
|
+
class="pops-folder-icon-arrow-down"></path>
|
|
182
|
+
</svg>
|
|
183
|
+
</div>
|
|
184
|
+
</div>
|
|
185
|
+
</div>
|
|
186
|
+
</th>
|
|
187
|
+
<th class="pops-folder-list-table__header-th cursor-p">
|
|
188
|
+
<div class="text-ellip content flex-a-i-center">
|
|
189
|
+
<span>大小</span>
|
|
190
|
+
<div class="pops-folder-list-table__sort" data-sort="fileSize">
|
|
191
|
+
<div class="pops-folder-icon-arrow" title="按大小排序">
|
|
192
|
+
<svg
|
|
193
|
+
viewBox="0 0 1024 1024"
|
|
194
|
+
xmlns="http://www.w3.org/2000/svg">
|
|
195
|
+
<path
|
|
196
|
+
d="M509.624392 5.882457 57.127707 458.379143 962.121078 458.379143Z"
|
|
197
|
+
class="pops-folder-icon-arrow-up"></path>
|
|
198
|
+
<path
|
|
199
|
+
d="M509.624392 1024 962.121078 571.503314 57.127707 571.503314Z"
|
|
200
|
+
class="pops-folder-icon-arrow-down"></path>
|
|
201
|
+
</svg>
|
|
202
|
+
</div>
|
|
203
|
+
</div>
|
|
204
|
+
</div>
|
|
205
|
+
</th>
|
|
206
|
+
</tr>
|
|
207
|
+
</thead>
|
|
208
|
+
</table>
|
|
209
|
+
</div>
|
|
210
|
+
<div class="pops-folder-list-table__body-div">
|
|
211
|
+
<table class="pops-folder-list-table__body">
|
|
212
|
+
<colgroup>
|
|
213
|
+
${
|
|
214
|
+
popsUtils.isPhone()
|
|
215
|
+
? `<col width="100%">`
|
|
216
|
+
: `
|
|
217
|
+
<col width="52%">
|
|
218
|
+
<col width="24%">
|
|
219
|
+
<col width="16%">`
|
|
220
|
+
}
|
|
221
|
+
</colgroup>
|
|
222
|
+
<tbody></tbody>
|
|
223
|
+
</table>
|
|
224
|
+
</div>
|
|
225
|
+
</div>
|
|
226
|
+
</div>${bottomBtnHTML}`,
|
|
227
|
+
bottomBtnHTML,
|
|
228
|
+
zIndex
|
|
229
|
+
);
|
|
230
|
+
/**
|
|
231
|
+
* 弹窗的主元素,包括动画层
|
|
232
|
+
*/
|
|
233
|
+
const $anim = PopsElementHandler.parseElement<HTMLDivElement>(animHTML);
|
|
234
|
+
const {
|
|
235
|
+
popsElement: $pops,
|
|
236
|
+
titleElement: $title,
|
|
237
|
+
contentElement: $content,
|
|
238
|
+
// folderListElement,
|
|
239
|
+
// folderListHeaderElement,
|
|
240
|
+
// folderListHeaderRowElement,
|
|
241
|
+
folderListBodyElement,
|
|
242
|
+
folderFileListBreadcrumbPrimaryElement,
|
|
243
|
+
headerCloseBtnElement: $btnCloseBtn,
|
|
244
|
+
btnOkElement,
|
|
245
|
+
btnCancelElement,
|
|
246
|
+
btnOtherElement,
|
|
247
|
+
folderListSortFileNameElement,
|
|
248
|
+
folderListSortLatestTimeElement,
|
|
249
|
+
folderListSortFileSizeElement,
|
|
250
|
+
} = PopsHandler.handleQueryElement($anim, popsType);
|
|
251
|
+
|
|
252
|
+
/**
|
|
253
|
+
* 遮罩层元素
|
|
254
|
+
*/
|
|
255
|
+
let $mask: HTMLDivElement | null = null;
|
|
256
|
+
/**
|
|
257
|
+
* 已创建的元素列表
|
|
258
|
+
*/
|
|
259
|
+
const elementList: HTMLElement[] = [$anim];
|
|
260
|
+
|
|
261
|
+
if (config.mask.enable) {
|
|
262
|
+
const _handleMask_ = PopsHandler.handleMask({
|
|
263
|
+
type: popsType,
|
|
264
|
+
guid: guid,
|
|
265
|
+
config: config,
|
|
266
|
+
animElement: $anim,
|
|
267
|
+
maskHTML: maskHTML,
|
|
268
|
+
});
|
|
269
|
+
$mask = _handleMask_.maskElement;
|
|
270
|
+
elementList.push($mask);
|
|
271
|
+
}
|
|
272
|
+
/* 事件 */
|
|
273
|
+
const eventDetails = PopsHandler.handleEventDetails(
|
|
274
|
+
guid,
|
|
275
|
+
$shadowContainer,
|
|
276
|
+
$shadowRoot,
|
|
277
|
+
popsType,
|
|
278
|
+
$anim,
|
|
279
|
+
$pops,
|
|
280
|
+
$mask!,
|
|
281
|
+
config
|
|
282
|
+
);
|
|
283
|
+
PopsHandler.handleClickEvent("close", $btnCloseBtn, eventDetails, config.btn.close!.callback!);
|
|
284
|
+
PopsHandler.handleClickEvent("ok", btnOkElement, eventDetails, config.btn.ok!.callback!);
|
|
285
|
+
PopsHandler.handleClickEvent("cancel", btnCancelElement, eventDetails, config.btn.cancel!.callback!);
|
|
286
|
+
PopsHandler.handleClickEvent("other", btnOtherElement, eventDetails, config.btn.other!.callback!);
|
|
287
|
+
/* 创建到页面中 */
|
|
288
|
+
|
|
289
|
+
popsDOMUtils.append($shadowRoot, elementList);
|
|
290
|
+
if (typeof config.beforeAppendToPageCallBack === "function") {
|
|
291
|
+
config.beforeAppendToPageCallBack($shadowRoot, $shadowContainer);
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
popsDOMUtils.appendBody($shadowContainer);
|
|
295
|
+
if ($mask != null) {
|
|
296
|
+
$anim.after($mask);
|
|
297
|
+
}
|
|
298
|
+
class PopsFolder {
|
|
299
|
+
init() {
|
|
300
|
+
config.folder.sort();
|
|
301
|
+
this.initFolderView(config.folder);
|
|
302
|
+
/* 将数据存到全部文件的属性_config_中 */
|
|
303
|
+
|
|
304
|
+
const allFilesElement = folderFileListBreadcrumbPrimaryElement.querySelector<HTMLDivElement>(
|
|
305
|
+
".pops-folder-list .pops-folder-file-list-breadcrumb-allFiles:first-child"
|
|
306
|
+
)!;
|
|
307
|
+
|
|
308
|
+
Reflect.set(allFilesElement, "_config_", config.folder);
|
|
309
|
+
/* 设置点击顶部的全部文件事件 */
|
|
310
|
+
popsDOMUtils.on<MouseEvent | PointerEvent>(allFilesElement, "click", (event) => {
|
|
311
|
+
this.setBreadcrumbClickEvent(event, true, config.folder);
|
|
312
|
+
});
|
|
313
|
+
// 文件名的点击排序
|
|
314
|
+
popsDOMUtils.on<MouseEvent | PointerEvent>(
|
|
315
|
+
folderListSortFileNameElement.closest("th"),
|
|
316
|
+
"click",
|
|
317
|
+
(event) => {
|
|
318
|
+
this.arrowToSortFolderInfoView(folderListSortFileNameElement, event, "fileName");
|
|
319
|
+
},
|
|
320
|
+
{
|
|
321
|
+
capture: true,
|
|
322
|
+
}
|
|
323
|
+
);
|
|
324
|
+
// 修改事件的点击排序
|
|
325
|
+
popsDOMUtils.on(
|
|
326
|
+
folderListSortLatestTimeElement.closest("th"),
|
|
327
|
+
"click",
|
|
328
|
+
(event) => {
|
|
329
|
+
this.arrowToSortFolderInfoView(folderListSortLatestTimeElement, event, "latestTime");
|
|
330
|
+
},
|
|
331
|
+
{
|
|
332
|
+
capture: true,
|
|
333
|
+
}
|
|
334
|
+
);
|
|
335
|
+
// 文件大小的点击排序
|
|
336
|
+
popsDOMUtils.on(
|
|
337
|
+
folderListSortFileSizeElement.closest("th"),
|
|
338
|
+
"click",
|
|
339
|
+
(event) => {
|
|
340
|
+
this.arrowToSortFolderInfoView(folderListSortFileSizeElement, event, "fileSize");
|
|
341
|
+
},
|
|
342
|
+
{
|
|
343
|
+
capture: true,
|
|
344
|
+
}
|
|
345
|
+
);
|
|
346
|
+
/* 设置默认触发的arrow */
|
|
347
|
+
if (config.sort.name === "fileName") {
|
|
348
|
+
popsDOMUtils.trigger(folderListSortFileNameElement, "click", {
|
|
349
|
+
notChangeSortRule: true,
|
|
350
|
+
});
|
|
351
|
+
} else if (config.sort.name === "latestTime") {
|
|
352
|
+
popsDOMUtils.trigger(folderListSortLatestTimeElement, "click", {
|
|
353
|
+
notChangeSortRule: true,
|
|
354
|
+
});
|
|
355
|
+
} else if (config.sort.name === "fileSize") {
|
|
356
|
+
popsDOMUtils.trigger(folderListSortFileSizeElement, "click", {
|
|
357
|
+
notChangeSortRule: true,
|
|
358
|
+
});
|
|
359
|
+
}
|
|
360
|
+
}
|
|
361
|
+
/**
|
|
362
|
+
* 创建文件夹元素
|
|
363
|
+
* @param fileName 文件名
|
|
364
|
+
* @param latestTime 修改时间
|
|
365
|
+
* @param [fileSize="-"] 文件大小
|
|
366
|
+
* @param isFolder 是否是文件夹
|
|
367
|
+
*/
|
|
368
|
+
createFolderRowElement(
|
|
369
|
+
fileName: string,
|
|
370
|
+
latestTime: string | number = "-",
|
|
371
|
+
fileSize: string | number = "-",
|
|
372
|
+
isFolder: boolean = false
|
|
373
|
+
) {
|
|
374
|
+
const origin_fileName = fileName;
|
|
375
|
+
const origin_latestTime = latestTime;
|
|
376
|
+
const origin_fileSize = fileSize;
|
|
377
|
+
|
|
378
|
+
const folderElement = popsDOMUtils.createElement("tr");
|
|
379
|
+
|
|
380
|
+
const fileNameElement = popsDOMUtils.createElement("td");
|
|
381
|
+
|
|
382
|
+
const fileTimeElement = popsDOMUtils.createElement("td");
|
|
383
|
+
|
|
384
|
+
const fileFormatSize = popsDOMUtils.createElement("td");
|
|
385
|
+
let fileType = "";
|
|
386
|
+
let fileIcon = Folder_ICON.folder;
|
|
387
|
+
if (isFolder) {
|
|
388
|
+
/* 文件夹 */
|
|
389
|
+
latestTime = "";
|
|
390
|
+
fileSize = "";
|
|
391
|
+
} else {
|
|
392
|
+
/* 文件 */
|
|
393
|
+
fileIcon = "";
|
|
394
|
+
if (typeof latestTime === "number") {
|
|
395
|
+
latestTime = popsUtils.formatTime(latestTime);
|
|
396
|
+
}
|
|
397
|
+
if (typeof fileSize === "number") {
|
|
398
|
+
fileSize = popsUtils.formatByteToSize(fileSize) as string;
|
|
399
|
+
}
|
|
400
|
+
for (const keyName in Folder_ICON) {
|
|
401
|
+
if (fileName.toLowerCase().endsWith("." + keyName)) {
|
|
402
|
+
fileType = keyName;
|
|
403
|
+
|
|
404
|
+
fileIcon = (Folder_ICON as any)[keyName];
|
|
405
|
+
break;
|
|
406
|
+
}
|
|
407
|
+
}
|
|
408
|
+
if (!fileIcon) {
|
|
409
|
+
fileType = "Null";
|
|
410
|
+
fileIcon = Folder_ICON.Null;
|
|
411
|
+
}
|
|
412
|
+
}
|
|
413
|
+
folderElement.className = "pops-folder-list-table__body-row";
|
|
414
|
+
fileNameElement.className = "pops-folder-list-table__body-td";
|
|
415
|
+
fileTimeElement.className = "pops-folder-list-table__body-td";
|
|
416
|
+
fileFormatSize.className = "pops-folder-list-table__body-td";
|
|
417
|
+
PopsSafeUtils.setSafeHTML(
|
|
418
|
+
fileNameElement,
|
|
419
|
+
/*html*/ `
|
|
420
|
+
<div class="pops-folder-list-file-name cursor-p">
|
|
421
|
+
<div>
|
|
422
|
+
<img src="${fileIcon}" alt="${fileType}" class="pops-folder-list-file-icon u-file-icon u-file-icon--list">
|
|
423
|
+
<a title="${fileName}" class="pops-folder-list-file-name-title-text inline-block-v-middle text-ellip list-name-text">
|
|
424
|
+
${fileName}
|
|
425
|
+
</a>
|
|
426
|
+
</div>
|
|
427
|
+
</div>
|
|
428
|
+
`
|
|
429
|
+
);
|
|
430
|
+
PopsSafeUtils.setSafeHTML(
|
|
431
|
+
fileTimeElement,
|
|
432
|
+
/*html*/ `
|
|
433
|
+
<div class="pops-folder-list__time">
|
|
434
|
+
<span>${latestTime}</span>
|
|
435
|
+
</div>
|
|
436
|
+
`
|
|
437
|
+
);
|
|
438
|
+
PopsSafeUtils.setSafeHTML(
|
|
439
|
+
fileFormatSize,
|
|
440
|
+
/*html*/ `
|
|
441
|
+
<div class="pops-folder-list-format-size">
|
|
442
|
+
<span>${fileSize}</span>
|
|
443
|
+
</div>
|
|
444
|
+
`
|
|
445
|
+
);
|
|
446
|
+
|
|
447
|
+
/* 存储原来的值 */
|
|
448
|
+
const __value__ = {
|
|
449
|
+
fileName: origin_fileName,
|
|
450
|
+
latestTime: origin_latestTime,
|
|
451
|
+
fileSize: origin_fileSize,
|
|
452
|
+
isFolder: isFolder,
|
|
453
|
+
};
|
|
454
|
+
|
|
455
|
+
Reflect.set(fileNameElement, "__value__", __value__);
|
|
456
|
+
Reflect.set(fileTimeElement, "__value__", __value__);
|
|
457
|
+
Reflect.set(fileFormatSize, "__value__", __value__);
|
|
458
|
+
Reflect.set(folderElement, "__value__", __value__);
|
|
459
|
+
|
|
460
|
+
folderElement.appendChild(fileNameElement);
|
|
461
|
+
folderElement.appendChild(fileTimeElement);
|
|
462
|
+
folderElement.appendChild(fileFormatSize);
|
|
463
|
+
return {
|
|
464
|
+
folderElement,
|
|
465
|
+
fileNameElement,
|
|
466
|
+
fileTimeElement,
|
|
467
|
+
fileFormatSize,
|
|
468
|
+
};
|
|
469
|
+
}
|
|
470
|
+
/**
|
|
471
|
+
* 创建移动端文件夹元素
|
|
472
|
+
* @param fileName 文件名
|
|
473
|
+
* @param latestTime 创建时间
|
|
474
|
+
* @param [fileSize="-"] 文件大小
|
|
475
|
+
* @param isFolder 是否是文件夹
|
|
476
|
+
*/
|
|
477
|
+
createFolderRowElementByMobile(
|
|
478
|
+
fileName: string,
|
|
479
|
+
latestTime: number | string = "-",
|
|
480
|
+
fileSize: number | string = "-",
|
|
481
|
+
isFolder: boolean = false
|
|
482
|
+
) {
|
|
483
|
+
const origin_fileName = fileName;
|
|
484
|
+
const origin_latestTime = latestTime;
|
|
485
|
+
const origin_fileSize = fileSize;
|
|
486
|
+
|
|
487
|
+
const folderElement = popsDOMUtils.createElement("tr");
|
|
488
|
+
|
|
489
|
+
const fileNameElement = popsDOMUtils.createElement("td");
|
|
490
|
+
let fileType = "";
|
|
491
|
+
let fileIcon = Folder_ICON.folder;
|
|
492
|
+
if (isFolder) {
|
|
493
|
+
/* 文件夹 */
|
|
494
|
+
latestTime = "";
|
|
495
|
+
fileSize = "";
|
|
496
|
+
} else {
|
|
497
|
+
/* 文件 */
|
|
498
|
+
fileIcon = "";
|
|
499
|
+
if (typeof latestTime === "number") {
|
|
500
|
+
latestTime = popsUtils.formatTime(latestTime);
|
|
501
|
+
}
|
|
502
|
+
if (typeof fileSize === "number") {
|
|
503
|
+
fileSize = popsUtils.formatByteToSize(fileSize) as string;
|
|
504
|
+
}
|
|
505
|
+
for (const keyName in Folder_ICON) {
|
|
506
|
+
if (fileName.toLowerCase().endsWith("." + keyName)) {
|
|
507
|
+
fileType = keyName;
|
|
508
|
+
|
|
509
|
+
fileIcon = (Folder_ICON as any)[keyName];
|
|
510
|
+
break;
|
|
511
|
+
}
|
|
512
|
+
}
|
|
513
|
+
if (!fileIcon) {
|
|
514
|
+
fileType = "Null";
|
|
515
|
+
fileIcon = Folder_ICON.Null;
|
|
516
|
+
}
|
|
517
|
+
}
|
|
518
|
+
folderElement.className = "pops-folder-list-table__body-row";
|
|
519
|
+
fileNameElement.className = "pops-folder-list-table__body-td";
|
|
520
|
+
PopsSafeUtils.setSafeHTML(
|
|
521
|
+
fileNameElement,
|
|
522
|
+
/*html*/ `
|
|
523
|
+
<div class="pops-folder-list-file-name pops-mobile-folder-list-file-name cursor-p">
|
|
524
|
+
<img src="${fileIcon}" alt="${fileType}" class="pops-folder-list-file-icon u-file-icon u-file-icon--list">
|
|
525
|
+
<div>
|
|
526
|
+
<a title="${fileName}" class="pops-folder-list-file-name-title-text inline-block-v-middle text-ellip list-name-text">${fileName}</a>
|
|
527
|
+
<span>${latestTime} ${fileSize}</span>
|
|
528
|
+
</div>
|
|
529
|
+
</div>
|
|
530
|
+
`
|
|
531
|
+
);
|
|
532
|
+
/* 存储原来的值 */
|
|
533
|
+
const __value__ = {
|
|
534
|
+
fileName: origin_fileName,
|
|
535
|
+
latestTime: origin_latestTime,
|
|
536
|
+
fileSize: origin_fileSize,
|
|
537
|
+
isFolder: isFolder,
|
|
538
|
+
};
|
|
539
|
+
Reflect.set(fileNameElement, "__value__", __value__);
|
|
540
|
+
Reflect.set(folderElement, "__value__", __value__);
|
|
541
|
+
folderElement.appendChild(fileNameElement);
|
|
542
|
+
return {
|
|
543
|
+
folderElement,
|
|
544
|
+
fileNameElement,
|
|
545
|
+
};
|
|
546
|
+
}
|
|
547
|
+
/**
|
|
548
|
+
* 清空文件夹信息页面
|
|
549
|
+
*/
|
|
550
|
+
clearFolderInfoView() {
|
|
551
|
+
PopsSafeUtils.setSafeHTML(folderListBodyElement, "");
|
|
552
|
+
}
|
|
553
|
+
/**
|
|
554
|
+
* 创建顶部导航的箭头图标
|
|
555
|
+
*/
|
|
556
|
+
createHeaderArrowIcon() {
|
|
557
|
+
const $arrowIcon = popsDOMUtils.createElement("div", {
|
|
558
|
+
className: "iconArrow",
|
|
559
|
+
});
|
|
560
|
+
return $arrowIcon;
|
|
561
|
+
}
|
|
562
|
+
/**
|
|
563
|
+
* 添加顶部导航元素
|
|
564
|
+
* @param folderName 文件夹名
|
|
565
|
+
* @param folderDataConfig 文件夹配置
|
|
566
|
+
*/
|
|
567
|
+
createBreadcrumb(folderName: string, folderDataConfig: PopsFolderDataConfig) {
|
|
568
|
+
const $breadcrumb = popsDOMUtils.createElement(
|
|
569
|
+
"span",
|
|
570
|
+
{
|
|
571
|
+
className: "pops-folder-file-list-breadcrumb-allFiles cursor-p",
|
|
572
|
+
innerHTML: `<a>${folderName}</a>`,
|
|
573
|
+
_config_: folderDataConfig,
|
|
574
|
+
},
|
|
575
|
+
{
|
|
576
|
+
title: folderName,
|
|
577
|
+
}
|
|
578
|
+
);
|
|
579
|
+
return $breadcrumb;
|
|
580
|
+
}
|
|
581
|
+
/**
|
|
582
|
+
* 顶部导航的点击事件
|
|
583
|
+
* @param clickEvent
|
|
584
|
+
* @param isTop 是否是全部文件按钮
|
|
585
|
+
* @param dataConfigList 配置
|
|
586
|
+
*/
|
|
587
|
+
setBreadcrumbClickEvent(
|
|
588
|
+
clickEvent: MouseEvent | PointerEvent,
|
|
589
|
+
isTop: boolean,
|
|
590
|
+
dataConfigList: PopsFolderDataConfig[]
|
|
591
|
+
) {
|
|
592
|
+
this.clearFolderInfoView();
|
|
593
|
+
/* 获取当前的导航元素 */
|
|
594
|
+
const $click = clickEvent.target as HTMLElement;
|
|
595
|
+
const currentBreadcrumb = $click.closest<HTMLSpanElement>("span.pops-folder-file-list-breadcrumb-allFiles");
|
|
596
|
+
if (currentBreadcrumb) {
|
|
597
|
+
while (currentBreadcrumb.nextElementSibling) {
|
|
598
|
+
currentBreadcrumb.nextElementSibling.remove();
|
|
599
|
+
}
|
|
600
|
+
} else {
|
|
601
|
+
console.error("获取导航按钮失败");
|
|
602
|
+
}
|
|
603
|
+
const loadingMask = PopsLoading.init({
|
|
604
|
+
parent: $content,
|
|
605
|
+
content: {
|
|
606
|
+
text: "获取文件列表中...",
|
|
607
|
+
},
|
|
608
|
+
mask: {
|
|
609
|
+
enable: true,
|
|
610
|
+
clickEvent: {
|
|
611
|
+
toClose: false,
|
|
612
|
+
toHide: false,
|
|
613
|
+
},
|
|
614
|
+
},
|
|
615
|
+
addIndexCSS: false,
|
|
616
|
+
});
|
|
617
|
+
this.initFolderView(dataConfigList);
|
|
618
|
+
loadingMask.close();
|
|
619
|
+
}
|
|
620
|
+
/**
|
|
621
|
+
* 文件夹的点击事件 - 进入文件夹
|
|
622
|
+
*
|
|
623
|
+
* 先情况页面元素
|
|
624
|
+
* @param clickEvent
|
|
625
|
+
* @param dataConfig
|
|
626
|
+
*/
|
|
627
|
+
async enterFolder(clickEvent: MouseEvent | PointerEvent, dataConfig: PopsFolderDataConfig) {
|
|
628
|
+
this.clearFolderInfoView();
|
|
629
|
+
const loadingMask = PopsLoading.init({
|
|
630
|
+
parent: $content,
|
|
631
|
+
content: {
|
|
632
|
+
text: "获取文件列表中...",
|
|
633
|
+
},
|
|
634
|
+
mask: {
|
|
635
|
+
enable: true,
|
|
636
|
+
},
|
|
637
|
+
addIndexCSS: false,
|
|
638
|
+
});
|
|
639
|
+
if (typeof dataConfig.clickEvent === "function") {
|
|
640
|
+
const childConfig = await dataConfig.clickEvent(clickEvent, dataConfig);
|
|
641
|
+
/* 添加顶部导航的箭头 */
|
|
642
|
+
folderFileListBreadcrumbPrimaryElement.appendChild(this.createHeaderArrowIcon());
|
|
643
|
+
/* 添加顶部导航的链接文字 */
|
|
644
|
+
const breadcrumbAllFilesElement = this.createBreadcrumb(dataConfig.fileName, childConfig as any);
|
|
645
|
+
|
|
646
|
+
folderFileListBreadcrumbPrimaryElement.appendChild(breadcrumbAllFilesElement);
|
|
647
|
+
/* 设置顶部导航点击事件 */
|
|
648
|
+
|
|
649
|
+
popsDOMUtils.on<MouseEvent | PointerEvent>(breadcrumbAllFilesElement, "click", (event) => {
|
|
650
|
+
this.setBreadcrumbClickEvent(event, false, childConfig as PopsFolderDataConfig[]);
|
|
651
|
+
});
|
|
652
|
+
|
|
653
|
+
this.initFolderView(childConfig as PopsFolderDataConfig[]);
|
|
654
|
+
}
|
|
655
|
+
loadingMask.close();
|
|
656
|
+
}
|
|
657
|
+
/**
|
|
658
|
+
* 文件的点击事件 - 下载文件
|
|
659
|
+
* @param $target
|
|
660
|
+
* @param dataConfig
|
|
661
|
+
*/
|
|
662
|
+
async downloadFile(clickEvent: MouseEvent | PointerEvent, $row: HTMLElement, dataConfig: PopsFolderDataConfig) {
|
|
663
|
+
popsDOMUtils.preventEvent(clickEvent);
|
|
664
|
+
|
|
665
|
+
const $link = $row.querySelector("a")!;
|
|
666
|
+
if (typeof dataConfig.clickEvent === "function") {
|
|
667
|
+
const downloadInfo = await dataConfig.clickEvent(clickEvent, dataConfig)!;
|
|
668
|
+
if (
|
|
669
|
+
downloadInfo != null &&
|
|
670
|
+
typeof downloadInfo === "object" &&
|
|
671
|
+
!Array.isArray(downloadInfo) &&
|
|
672
|
+
typeof downloadInfo.url === "string" &&
|
|
673
|
+
downloadInfo.url.trim() !== ""
|
|
674
|
+
) {
|
|
675
|
+
$link.setAttribute("href", downloadInfo.url);
|
|
676
|
+
$link.setAttribute("target", "_blank");
|
|
677
|
+
if (downloadInfo.autoDownload) {
|
|
678
|
+
if (downloadInfo.mode == null || (downloadInfo as any).mode === "") {
|
|
679
|
+
/* 未设置mode的话默认为aBlank */
|
|
680
|
+
downloadInfo.mode = "aBlank";
|
|
681
|
+
}
|
|
682
|
+
if (downloadInfo.mode === "a" || downloadInfo.mode === "aBlank") {
|
|
683
|
+
/* a标签下载 */
|
|
684
|
+
const downloadLinkElement = document.createElement("a");
|
|
685
|
+
|
|
686
|
+
if (downloadInfo.mode === "aBlank") {
|
|
687
|
+
downloadLinkElement.setAttribute("target", "_blank");
|
|
688
|
+
}
|
|
689
|
+
|
|
690
|
+
downloadLinkElement.href = downloadInfo.url;
|
|
691
|
+
downloadLinkElement.click();
|
|
692
|
+
} else if (downloadInfo.mode === "open" || downloadInfo.mode === "openBlank") {
|
|
693
|
+
/* window.open下载 */
|
|
694
|
+
|
|
695
|
+
if (downloadInfo.mode === "openBlank") {
|
|
696
|
+
globalThis.open(downloadInfo.url, "_blank");
|
|
697
|
+
} else {
|
|
698
|
+
globalThis.open(downloadInfo.url);
|
|
699
|
+
}
|
|
700
|
+
} else if (downloadInfo.mode === "iframe") {
|
|
701
|
+
/* iframe下载 */
|
|
702
|
+
const downloadIframeLinkElement = document.createElement("iframe");
|
|
703
|
+
|
|
704
|
+
downloadIframeLinkElement.src = downloadInfo.url;
|
|
705
|
+
downloadIframeLinkElement.onload = function () {
|
|
706
|
+
popsUtils.setTimeout(() => {
|
|
707
|
+
downloadIframeLinkElement.remove();
|
|
708
|
+
}, 1000);
|
|
709
|
+
};
|
|
710
|
+
$shadowRoot.appendChild(downloadIframeLinkElement);
|
|
711
|
+
popsUtils.setTimeout(
|
|
712
|
+
() => {
|
|
713
|
+
downloadIframeLinkElement.remove();
|
|
714
|
+
},
|
|
715
|
+
3 * 60 * 1000
|
|
716
|
+
);
|
|
717
|
+
} else {
|
|
718
|
+
console.error("未知的下载模式", downloadInfo);
|
|
719
|
+
}
|
|
720
|
+
}
|
|
721
|
+
}
|
|
722
|
+
}
|
|
723
|
+
}
|
|
724
|
+
/**
|
|
725
|
+
* 对配置进行排序
|
|
726
|
+
* @param folderDataConfigList
|
|
727
|
+
* @param sortName 比较的属性,默认fileName
|
|
728
|
+
* @param isDesc 是否降序,默认false(升序)
|
|
729
|
+
*/
|
|
730
|
+
sortFolderConfig(
|
|
731
|
+
folderDataConfigList: PopsFolderDataConfig[],
|
|
732
|
+
sortName: "fileName" | "fileSize" | "latestTime" = "fileName",
|
|
733
|
+
isDesc = false
|
|
734
|
+
) {
|
|
735
|
+
if (sortName === "fileName") {
|
|
736
|
+
// 如果是以文件名排序,文件夹优先放前面
|
|
737
|
+
const onlyFolderDataConfigList = folderDataConfigList.filter((value) => {
|
|
738
|
+
return value.isFolder;
|
|
739
|
+
});
|
|
740
|
+
const onlyFileDataConfigList = folderDataConfigList.filter((value) => {
|
|
741
|
+
return !value.isFolder;
|
|
742
|
+
});
|
|
743
|
+
// 文件夹排序
|
|
744
|
+
onlyFolderDataConfigList.sort((leftConfig, rightConfig) => {
|
|
745
|
+
const beforeVal = leftConfig[sortName].toString();
|
|
746
|
+
const afterVal = rightConfig[sortName].toString();
|
|
747
|
+
let compareVal = beforeVal.localeCompare(afterVal);
|
|
748
|
+
if (isDesc) {
|
|
749
|
+
/* 降序 */
|
|
750
|
+
if (compareVal > 0) {
|
|
751
|
+
compareVal = -1;
|
|
752
|
+
} else if (compareVal < 0) {
|
|
753
|
+
compareVal = 1;
|
|
754
|
+
}
|
|
755
|
+
}
|
|
756
|
+
return compareVal;
|
|
757
|
+
});
|
|
758
|
+
// 文件名排序
|
|
759
|
+
onlyFileDataConfigList.sort((leftConfig, rightConfig) => {
|
|
760
|
+
const beforeVal = leftConfig[sortName].toString();
|
|
761
|
+
const afterVal = rightConfig[sortName].toString();
|
|
762
|
+
let compareVal = beforeVal.localeCompare(afterVal);
|
|
763
|
+
if (isDesc) {
|
|
764
|
+
/* 降序 */
|
|
765
|
+
if (compareVal > 0) {
|
|
766
|
+
compareVal = -1;
|
|
767
|
+
} else if (compareVal < 0) {
|
|
768
|
+
compareVal = 1;
|
|
769
|
+
}
|
|
770
|
+
}
|
|
771
|
+
return compareVal;
|
|
772
|
+
});
|
|
773
|
+
if (isDesc) {
|
|
774
|
+
// 降序,文件夹在下面
|
|
775
|
+
return [...onlyFileDataConfigList, ...onlyFolderDataConfigList];
|
|
776
|
+
} else {
|
|
777
|
+
// 升序,文件夹在上面
|
|
778
|
+
return [...onlyFolderDataConfigList, ...onlyFileDataConfigList];
|
|
779
|
+
}
|
|
780
|
+
} else {
|
|
781
|
+
folderDataConfigList.sort((beforeConfig, afterConfig) => {
|
|
782
|
+
let beforeVal = beforeConfig[sortName];
|
|
783
|
+
let afterVal = afterConfig[sortName];
|
|
784
|
+
if (sortName === "fileSize") {
|
|
785
|
+
/* 文件大小,进行Float转换 */
|
|
786
|
+
beforeVal = parseFloat(beforeVal.toString());
|
|
787
|
+
afterVal = parseFloat(afterVal.toString());
|
|
788
|
+
} else if (sortName === "latestTime") {
|
|
789
|
+
/* 文件时间 */
|
|
790
|
+
beforeVal = new Date(beforeVal).getTime();
|
|
791
|
+
afterVal = new Date(afterVal).getTime();
|
|
792
|
+
}
|
|
793
|
+
if (beforeVal > afterVal) {
|
|
794
|
+
if (isDesc) {
|
|
795
|
+
/* 降序 */
|
|
796
|
+
return -1;
|
|
797
|
+
} else {
|
|
798
|
+
return 1;
|
|
799
|
+
}
|
|
800
|
+
} else if (beforeVal < afterVal) {
|
|
801
|
+
if (isDesc) {
|
|
802
|
+
/* 降序 */
|
|
803
|
+
return 1;
|
|
804
|
+
} else {
|
|
805
|
+
return -1;
|
|
806
|
+
}
|
|
807
|
+
} else {
|
|
808
|
+
return 0;
|
|
809
|
+
}
|
|
810
|
+
});
|
|
811
|
+
return folderDataConfigList;
|
|
812
|
+
}
|
|
813
|
+
}
|
|
814
|
+
/**
|
|
815
|
+
* 添加文件夹/文件行元素
|
|
816
|
+
* @param dataConfig 配置
|
|
817
|
+
*/
|
|
818
|
+
initFolderView(dataConfig: PopsFolderDataConfig[]) {
|
|
819
|
+
// 先对文件夹、文件进行排序
|
|
820
|
+
this.sortFolderConfig(dataConfig, config.sort.name, config.sort.isDesc);
|
|
821
|
+
dataConfig.forEach((item) => {
|
|
822
|
+
if (item.isFolder) {
|
|
823
|
+
const { folderElement, fileNameElement } = popsUtils.isPhone()
|
|
824
|
+
? this.createFolderRowElementByMobile(item.fileName, "", "", true)
|
|
825
|
+
: this.createFolderRowElement(item.fileName, "", "", true);
|
|
826
|
+
// 文件夹 - 点击事件
|
|
827
|
+
popsDOMUtils.on<MouseEvent | PointerEvent>(fileNameElement, "click", (event) => {
|
|
828
|
+
// 进入文件夹
|
|
829
|
+
this.enterFolder(event, item);
|
|
830
|
+
});
|
|
831
|
+
|
|
832
|
+
folderListBodyElement.appendChild(folderElement);
|
|
833
|
+
} else {
|
|
834
|
+
const { folderElement, fileNameElement } = popsUtils.isPhone()
|
|
835
|
+
? this.createFolderRowElementByMobile(item.fileName, item.latestTime, item.fileSize, false)
|
|
836
|
+
: this.createFolderRowElement(item.fileName, item.latestTime, item.fileSize, false);
|
|
837
|
+
// 文件 - 点击事件
|
|
838
|
+
popsDOMUtils.on<MouseEvent | PointerEvent>(fileNameElement, "click", (event) => {
|
|
839
|
+
// 下载文件
|
|
840
|
+
this.downloadFile(event, fileNameElement, item);
|
|
841
|
+
});
|
|
842
|
+
|
|
843
|
+
folderListBodyElement.appendChild(folderElement);
|
|
844
|
+
}
|
|
845
|
+
});
|
|
846
|
+
}
|
|
847
|
+
/**
|
|
848
|
+
* 移除所有箭头的被访问状态
|
|
849
|
+
*/
|
|
850
|
+
removeArrowActiveStatus() {
|
|
851
|
+
[
|
|
852
|
+
...Array.from(folderListSortFileNameElement.querySelectorAll<HTMLElement>(".pops-folder-icon-active")),
|
|
853
|
+
...Array.from(folderListSortLatestTimeElement.querySelectorAll<HTMLElement>(".pops-folder-icon-active")),
|
|
854
|
+
...Array.from(folderListSortFileSizeElement.querySelectorAll<HTMLElement>(".pops-folder-icon-active")),
|
|
855
|
+
].forEach((ele) => ele.classList.remove("pops-folder-icon-active"));
|
|
856
|
+
}
|
|
857
|
+
/**
|
|
858
|
+
* 修改导航箭头的状态
|
|
859
|
+
*/
|
|
860
|
+
changeArrowActive(arrowUp: HTMLElement, arrowDown: HTMLElement, isDesc: boolean) {
|
|
861
|
+
this.removeArrowActiveStatus();
|
|
862
|
+
if (isDesc) {
|
|
863
|
+
arrowDown.classList.add("pops-folder-icon-active");
|
|
864
|
+
} else {
|
|
865
|
+
arrowUp.classList.add("pops-folder-icon-active");
|
|
866
|
+
}
|
|
867
|
+
}
|
|
868
|
+
/**
|
|
869
|
+
* 排序按钮的点击事件
|
|
870
|
+
* @param target
|
|
871
|
+
* @param event
|
|
872
|
+
* @param sortName
|
|
873
|
+
*/
|
|
874
|
+
arrowToSortFolderInfoView(target: HTMLDivElement, event: MouseEvent | PointerEvent, sortName: string) {
|
|
875
|
+
const notChangeSortRule = Reflect.get(event, "notChangeSortRule");
|
|
876
|
+
if (!notChangeSortRule) {
|
|
877
|
+
(config as any).sort.name = sortName;
|
|
878
|
+
config.sort.isDesc = !config.sort.isDesc;
|
|
879
|
+
}
|
|
880
|
+
|
|
881
|
+
const arrowUp = target.querySelector<HTMLDivElement>(".pops-folder-icon-arrow-up")!;
|
|
882
|
+
const arrowDown = target.querySelector<HTMLDivElement>(".pops-folder-icon-arrow-down")!;
|
|
883
|
+
this.changeArrowActive(arrowUp, arrowDown, config.sort.isDesc);
|
|
884
|
+
if (
|
|
885
|
+
typeof config.sort.callback === "function" &&
|
|
886
|
+
config.sort.callback(target, event, config.sort.name, config.sort.isDesc)
|
|
887
|
+
) {
|
|
888
|
+
return;
|
|
889
|
+
}
|
|
890
|
+
|
|
891
|
+
const childrenList: PopsFolderDataConfig[] = [];
|
|
892
|
+
|
|
893
|
+
Array.from(folderListBodyElement.children).forEach((trElement) => {
|
|
894
|
+
const __value__ = Reflect.get(trElement, "__value__");
|
|
895
|
+
Reflect.set(__value__, "target", trElement);
|
|
896
|
+
childrenList.push(__value__);
|
|
897
|
+
});
|
|
898
|
+
const sortedConfigList = this.sortFolderConfig(childrenList, config.sort.name, config.sort.isDesc);
|
|
899
|
+
sortedConfigList.forEach((item) => {
|
|
900
|
+
folderListBodyElement.appendChild((item as any).target);
|
|
901
|
+
});
|
|
902
|
+
}
|
|
903
|
+
}
|
|
904
|
+
|
|
905
|
+
const popsFolder = new PopsFolder();
|
|
906
|
+
popsFolder.init();
|
|
907
|
+
Reflect.set($pops, "data-pops-folder", popsFolder);
|
|
908
|
+
/* 拖拽 */
|
|
909
|
+
if (config.drag) {
|
|
910
|
+
PopsInstanceUtils.drag($pops, {
|
|
911
|
+
dragElement: $title,
|
|
912
|
+
limit: config.dragLimit,
|
|
913
|
+
extraDistance: config.dragExtraDistance,
|
|
914
|
+
moveCallBack: config.dragMoveCallBack,
|
|
915
|
+
endCallBack: config.dragEndCallBack,
|
|
916
|
+
});
|
|
917
|
+
}
|
|
918
|
+
PopsHandler.handlePush(popsType, {
|
|
919
|
+
guid: guid,
|
|
920
|
+
animElement: $anim,
|
|
921
|
+
popsElement: $pops,
|
|
922
|
+
maskElement: $mask!,
|
|
923
|
+
$shadowContainer: $shadowContainer,
|
|
924
|
+
$shadowRoot: $shadowRoot,
|
|
925
|
+
});
|
|
926
|
+
const result = PopsHandler.handleResultDetails(eventDetails);
|
|
927
|
+
return result;
|
|
928
|
+
},
|
|
929
|
+
};
|