@whitesev/pops 3.2.1 → 3.3.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/README.md +249 -249
- package/dist/index.amd.js +736 -948
- package/dist/index.amd.js.map +1 -1
- package/dist/index.amd.min.js +1 -1
- package/dist/index.amd.min.js.map +1 -1
- package/dist/index.cjs.js +736 -948
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.cjs.min.js +1 -1
- package/dist/index.cjs.min.js.map +1 -1
- package/dist/index.esm.js +736 -948
- package/dist/index.esm.js.map +1 -1
- package/dist/index.esm.min.js +1 -1
- package/dist/index.esm.min.js.map +1 -1
- package/dist/index.iife.js +736 -948
- package/dist/index.iife.js.map +1 -1
- package/dist/index.iife.min.js +1 -1
- package/dist/index.iife.min.js.map +1 -1
- package/dist/index.system.js +736 -948
- package/dist/index.system.js.map +1 -1
- package/dist/index.system.min.js +1 -1
- package/dist/index.system.min.js.map +1 -1
- package/dist/index.umd.js +736 -948
- package/dist/index.umd.js.map +1 -1
- package/dist/index.umd.min.js +1 -1
- package/dist/index.umd.min.js.map +1 -1
- package/dist/types/src/PopsCore.d.ts +15 -7
- package/dist/types/src/components/folder/types/index.d.ts +43 -13
- package/dist/types/src/types/PopsDOMUtilsEventType.d.ts +313 -313
- package/dist/types/src/types/animation.d.ts +19 -19
- package/dist/types/src/types/button.d.ts +94 -94
- package/dist/types/src/types/components.d.ts +211 -211
- package/dist/types/src/types/event.d.ts +43 -43
- package/dist/types/src/types/global.d.ts +31 -31
- package/dist/types/src/types/icon.d.ts +32 -32
- package/dist/types/src/types/inst.d.ts +28 -28
- package/dist/types/src/types/main.d.ts +66 -66
- package/dist/types/src/types/mask.d.ts +52 -52
- package/dist/types/src/types/position.d.ts +60 -60
- package/package.json +28 -27
- package/src/Pops.ts +206 -206
- package/src/PopsAnimation.ts +32 -32
- package/src/PopsCSS.ts +54 -54
- package/src/PopsCore.ts +53 -37
- package/src/PopsIcon.ts +95 -95
- package/src/PopsInst.ts +21 -21
- package/src/components/alert/defaultConfig.ts +62 -62
- package/src/components/alert/index.ts +163 -163
- package/src/components/alert/types/index.ts +23 -23
- package/src/components/confirm/defaultConfig.ts +90 -90
- package/src/components/confirm/index.ts +165 -165
- package/src/components/confirm/types/index.ts +13 -17
- package/src/components/drawer/defaultConfig.ts +89 -89
- package/src/components/drawer/index.css +37 -37
- package/src/components/drawer/index.ts +245 -245
- package/src/components/drawer/types/index.ts +62 -61
- package/src/components/folder/defaultConfig.ts +151 -151
- package/src/components/folder/folderIcon.ts +28 -28
- package/src/components/folder/index.css +303 -303
- package/src/components/folder/index.ts +953 -932
- package/src/components/folder/types/index.ts +143 -110
- package/src/components/iframe/defaultConfig.ts +60 -60
- package/src/components/iframe/index.css +76 -76
- package/src/components/iframe/index.ts +331 -331
- package/src/components/iframe/types/index.ts +96 -96
- package/src/components/loading/defaultConfig.ts +29 -29
- package/src/components/loading/index.css +66 -66
- package/src/components/loading/index.ts +101 -101
- package/src/components/loading/types/index.ts +36 -34
- package/src/components/panel/css/components-select.css +84 -84
- package/src/components/panel/defaultConfig.ts +868 -868
- package/src/components/panel/handlerComponents.ts +3993 -3993
- package/src/components/panel/index.css +1403 -1403
- package/src/components/panel/index.ts +221 -221
- package/src/components/panel/types/components-button.ts +56 -56
- package/src/components/panel/types/components-common.ts +73 -73
- package/src/components/panel/types/components-container.ts +25 -25
- package/src/components/panel/types/components-deepMenu.ts +64 -64
- package/src/components/panel/types/components-input.ts +90 -90
- package/src/components/panel/types/components-own.ts +16 -16
- package/src/components/panel/types/components-select.ts +169 -169
- package/src/components/panel/types/components-selectMultiple.ts +105 -104
- package/src/components/panel/types/components-slider.ts +55 -55
- package/src/components/panel/types/components-switch.ts +33 -33
- package/src/components/panel/types/components-textarea.ts +45 -45
- package/src/components/panel/types/index.ts +244 -244
- package/src/components/prompt/defaultConfig.ts +94 -94
- package/src/components/prompt/index.css +34 -34
- package/src/components/prompt/index.ts +187 -215
- package/src/components/prompt/types/index.ts +57 -56
- package/src/components/rightClickMenu/defaultConfig.ts +103 -103
- package/src/components/rightClickMenu/index.css +115 -115
- package/src/components/rightClickMenu/index.ts +662 -662
- package/src/components/rightClickMenu/types/index.ts +145 -143
- package/src/components/searchSuggestion/defaultConfig.ts +63 -63
- package/src/components/searchSuggestion/index.ts +813 -813
- package/src/components/searchSuggestion/types/index.ts +244 -242
- package/src/components/tooltip/defaultConfig.ts +33 -33
- package/src/components/tooltip/index.css +199 -199
- package/src/components/tooltip/index.ts +617 -617
- package/src/components/tooltip/types/index.ts +123 -121
- package/src/config/CommonCSSClassName.ts +17 -17
- package/src/config/GlobalConfig.ts +63 -63
- package/src/css/animation.css +987 -987
- package/src/css/button.css +551 -551
- package/src/css/common.css +54 -54
- package/src/css/index.css +253 -253
- package/src/css/ninePalaceGridPosition.css +50 -50
- package/src/css/scrollbar.css +22 -22
- package/src/handler/PopsElementHandler.ts +303 -303
- package/src/handler/PopsHandler.ts +611 -611
- package/src/types/PopsDOMUtilsEventType.d.ts +313 -313
- package/src/types/animation.d.ts +19 -19
- package/src/types/button.d.ts +94 -94
- package/src/types/components.d.ts +211 -211
- package/src/types/event.d.ts +43 -43
- package/src/types/global.d.ts +31 -31
- package/src/types/icon.d.ts +32 -32
- package/src/types/inst.d.ts +28 -28
- package/src/types/main.d.ts +66 -66
- package/src/types/mask.d.ts +52 -52
- package/src/types/position.d.ts +60 -60
- package/src/utils/PopsDOMUtils.ts +2483 -2483
- package/src/utils/PopsDOMUtilsEventsConfig.ts +4 -4
- package/src/utils/PopsInstanceUtils.ts +714 -714
- package/src/utils/PopsMathUtils.ts +71 -71
- package/src/utils/PopsSafeUtils.ts +22 -22
- package/src/utils/PopsUtils.ts +391 -421
|
@@ -1,932 +1,953 @@
|
|
|
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 { PopsFolderDefaultConfig } from "./defaultConfig";
|
|
12
|
-
import { Folder_ICON } from "./folderIcon";
|
|
13
|
-
import type { PopsFolderDataConfig, PopsFolderConfig, PopsFolderDownloadOption } from "./types";
|
|
14
|
-
|
|
15
|
-
export const PopsFolder = {
|
|
16
|
-
init(__config__: PopsFolderConfig) {
|
|
17
|
-
const guid = popsUtils.getRandomGUID();
|
|
18
|
-
// 设置当前类型
|
|
19
|
-
const popsType: PopsType = "folder";
|
|
20
|
-
|
|
21
|
-
let config = PopsFolderDefaultConfig();
|
|
22
|
-
config = popsUtils.assign(config, GlobalConfig.getGlobalConfig());
|
|
23
|
-
config = popsUtils.assign(config, __config__);
|
|
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 (config?.folder) {
|
|
109
|
-
Reflect.set(config, "folder", config.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
|
-
$pops: $pops,
|
|
236
|
-
$title: $title,
|
|
237
|
-
$content: $content,
|
|
238
|
-
// folderListElement,
|
|
239
|
-
// folderListHeaderElement,
|
|
240
|
-
// folderListHeaderRowElement,
|
|
241
|
-
$folderTbody: folderListBodyElement,
|
|
242
|
-
$folderHeaderBreadcrumbPrimary: folderFileListBreadcrumbPrimaryElement,
|
|
243
|
-
$headerBtnClose: $btnCloseBtn,
|
|
244
|
-
$btnOk: btnOkElement,
|
|
245
|
-
$btnCancel: btnCancelElement,
|
|
246
|
-
$btnOther: btnOtherElement,
|
|
247
|
-
$folderSortFileName: folderListSortFileNameElement,
|
|
248
|
-
$folderSortLatestTime: folderListSortLatestTimeElement,
|
|
249
|
-
$folderSortFileSize: folderListSortFileSizeElement,
|
|
250
|
-
} = PopsHandler.handleQueryElement($anim, popsType);
|
|
251
|
-
|
|
252
|
-
/**
|
|
253
|
-
* 遮罩层元素
|
|
254
|
-
*/
|
|
255
|
-
let $mask: HTMLDivElement | undefined = void 0;
|
|
256
|
-
/**
|
|
257
|
-
* 已创建的元素列表
|
|
258
|
-
*/
|
|
259
|
-
const $elList: 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
|
-
$elList.push($mask);
|
|
271
|
-
}
|
|
272
|
-
// 事件
|
|
273
|
-
const evtConfig = PopsHandler.handleEventConfig(
|
|
274
|
-
config,
|
|
275
|
-
guid,
|
|
276
|
-
$shadowContainer,
|
|
277
|
-
$shadowRoot,
|
|
278
|
-
popsType,
|
|
279
|
-
$anim,
|
|
280
|
-
$pops,
|
|
281
|
-
$mask
|
|
282
|
-
);
|
|
283
|
-
const result = PopsHandler.handleResultConfig(evtConfig);
|
|
284
|
-
PopsHandler.handleClickEvent("close", $btnCloseBtn, evtConfig, config.btn.close.callback);
|
|
285
|
-
PopsHandler.handleClickEvent("ok", btnOkElement, evtConfig, config.btn.ok.callback);
|
|
286
|
-
PopsHandler.handleClickEvent("cancel", btnCancelElement, evtConfig, config.btn.cancel.callback);
|
|
287
|
-
PopsHandler.handleClickEvent("other", btnOtherElement, evtConfig, config.btn.other.callback);
|
|
288
|
-
// 创建到页面中
|
|
289
|
-
|
|
290
|
-
popsDOMUtils.append($shadowRoot, $elList);
|
|
291
|
-
if (typeof config.beforeAppendToPageCallBack === "function") {
|
|
292
|
-
config.beforeAppendToPageCallBack($shadowRoot, $shadowContainer);
|
|
293
|
-
}
|
|
294
|
-
|
|
295
|
-
popsDOMUtils.appendBody($shadowContainer);
|
|
296
|
-
if ($mask != null) {
|
|
297
|
-
$anim.after($mask);
|
|
298
|
-
}
|
|
299
|
-
class PopsFolder {
|
|
300
|
-
init() {
|
|
301
|
-
config.folder.sort();
|
|
302
|
-
this.initFolderView(config.folder);
|
|
303
|
-
// 将数据存到全部文件的属性_config_中
|
|
304
|
-
|
|
305
|
-
const $allFiles = folderFileListBreadcrumbPrimaryElement.querySelector<HTMLDivElement>(
|
|
306
|
-
".pops-folder-list .pops-folder-file-list-breadcrumb-allFiles:first-child"
|
|
307
|
-
)!;
|
|
308
|
-
|
|
309
|
-
Reflect.set($allFiles, "data-config", config.folder);
|
|
310
|
-
// 设置点击顶部的全部文件事件
|
|
311
|
-
popsDOMUtils.on<MouseEvent | PointerEvent>($allFiles, "click", (event) => {
|
|
312
|
-
this.setBreadcrumbClickEvent(event, true, config.folder);
|
|
313
|
-
});
|
|
314
|
-
// 文件名的点击排序
|
|
315
|
-
popsDOMUtils.on<MouseEvent | PointerEvent>(
|
|
316
|
-
folderListSortFileNameElement.closest("th"),
|
|
317
|
-
"click",
|
|
318
|
-
(event) => {
|
|
319
|
-
this.arrowToSortFolderInfoView(folderListSortFileNameElement, event, "fileName");
|
|
320
|
-
},
|
|
321
|
-
{
|
|
322
|
-
capture: true,
|
|
323
|
-
}
|
|
324
|
-
);
|
|
325
|
-
// 修改事件的点击排序
|
|
326
|
-
popsDOMUtils.on(
|
|
327
|
-
folderListSortLatestTimeElement.closest("th"),
|
|
328
|
-
"click",
|
|
329
|
-
(event) => {
|
|
330
|
-
this.arrowToSortFolderInfoView(folderListSortLatestTimeElement, event, "latestTime");
|
|
331
|
-
},
|
|
332
|
-
{
|
|
333
|
-
capture: true,
|
|
334
|
-
}
|
|
335
|
-
);
|
|
336
|
-
// 文件大小的点击排序
|
|
337
|
-
popsDOMUtils.on(
|
|
338
|
-
folderListSortFileSizeElement.closest("th"),
|
|
339
|
-
"click",
|
|
340
|
-
(event) => {
|
|
341
|
-
this.arrowToSortFolderInfoView(folderListSortFileSizeElement, event, "fileSize");
|
|
342
|
-
},
|
|
343
|
-
{
|
|
344
|
-
capture: true,
|
|
345
|
-
}
|
|
346
|
-
);
|
|
347
|
-
// 设置默认触发的arrow
|
|
348
|
-
if (config.sort.name === "fileName") {
|
|
349
|
-
popsDOMUtils.emit(folderListSortFileNameElement, "click", {
|
|
350
|
-
notChangeSortRule: true,
|
|
351
|
-
});
|
|
352
|
-
} else if (config.sort.name === "latestTime") {
|
|
353
|
-
popsDOMUtils.emit(folderListSortLatestTimeElement, "click", {
|
|
354
|
-
notChangeSortRule: true,
|
|
355
|
-
});
|
|
356
|
-
} else if (config.sort.name === "fileSize") {
|
|
357
|
-
popsDOMUtils.emit(folderListSortFileSizeElement, "click", {
|
|
358
|
-
notChangeSortRule: true,
|
|
359
|
-
});
|
|
360
|
-
}
|
|
361
|
-
}
|
|
362
|
-
/**
|
|
363
|
-
*
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
};
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
},
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
}
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
$
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
}
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
return
|
|
741
|
-
});
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
if (
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
}
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
} else {
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
}
|
|
869
|
-
}
|
|
870
|
-
/**
|
|
871
|
-
*
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
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 { PopsFolderDefaultConfig } from "./defaultConfig";
|
|
12
|
+
import { Folder_ICON } from "./folderIcon";
|
|
13
|
+
import type { PopsFolderDataConfig, PopsFolderConfig, PopsFolderDownloadOption } from "./types";
|
|
14
|
+
|
|
15
|
+
export const PopsFolder = {
|
|
16
|
+
init(__config__: PopsFolderConfig) {
|
|
17
|
+
const guid = popsUtils.getRandomGUID();
|
|
18
|
+
// 设置当前类型
|
|
19
|
+
const popsType: PopsType = "folder";
|
|
20
|
+
|
|
21
|
+
let config = PopsFolderDefaultConfig();
|
|
22
|
+
config = popsUtils.assign(config, GlobalConfig.getGlobalConfig());
|
|
23
|
+
config = popsUtils.assign(config, __config__);
|
|
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 (config?.folder) {
|
|
109
|
+
Reflect.set(config, "folder", config.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
|
+
$pops: $pops,
|
|
236
|
+
$title: $title,
|
|
237
|
+
$content: $content,
|
|
238
|
+
// folderListElement,
|
|
239
|
+
// folderListHeaderElement,
|
|
240
|
+
// folderListHeaderRowElement,
|
|
241
|
+
$folderTbody: folderListBodyElement,
|
|
242
|
+
$folderHeaderBreadcrumbPrimary: folderFileListBreadcrumbPrimaryElement,
|
|
243
|
+
$headerBtnClose: $btnCloseBtn,
|
|
244
|
+
$btnOk: btnOkElement,
|
|
245
|
+
$btnCancel: btnCancelElement,
|
|
246
|
+
$btnOther: btnOtherElement,
|
|
247
|
+
$folderSortFileName: folderListSortFileNameElement,
|
|
248
|
+
$folderSortLatestTime: folderListSortLatestTimeElement,
|
|
249
|
+
$folderSortFileSize: folderListSortFileSizeElement,
|
|
250
|
+
} = PopsHandler.handleQueryElement($anim, popsType);
|
|
251
|
+
|
|
252
|
+
/**
|
|
253
|
+
* 遮罩层元素
|
|
254
|
+
*/
|
|
255
|
+
let $mask: HTMLDivElement | undefined = void 0;
|
|
256
|
+
/**
|
|
257
|
+
* 已创建的元素列表
|
|
258
|
+
*/
|
|
259
|
+
const $elList: 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
|
+
$elList.push($mask);
|
|
271
|
+
}
|
|
272
|
+
// 事件
|
|
273
|
+
const evtConfig = PopsHandler.handleEventConfig(
|
|
274
|
+
config,
|
|
275
|
+
guid,
|
|
276
|
+
$shadowContainer,
|
|
277
|
+
$shadowRoot,
|
|
278
|
+
popsType,
|
|
279
|
+
$anim,
|
|
280
|
+
$pops,
|
|
281
|
+
$mask
|
|
282
|
+
);
|
|
283
|
+
const result = PopsHandler.handleResultConfig(evtConfig);
|
|
284
|
+
PopsHandler.handleClickEvent("close", $btnCloseBtn, evtConfig, config.btn.close.callback);
|
|
285
|
+
PopsHandler.handleClickEvent("ok", btnOkElement, evtConfig, config.btn.ok.callback);
|
|
286
|
+
PopsHandler.handleClickEvent("cancel", btnCancelElement, evtConfig, config.btn.cancel.callback);
|
|
287
|
+
PopsHandler.handleClickEvent("other", btnOtherElement, evtConfig, config.btn.other.callback);
|
|
288
|
+
// 创建到页面中
|
|
289
|
+
|
|
290
|
+
popsDOMUtils.append($shadowRoot, $elList);
|
|
291
|
+
if (typeof config.beforeAppendToPageCallBack === "function") {
|
|
292
|
+
config.beforeAppendToPageCallBack($shadowRoot, $shadowContainer);
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
popsDOMUtils.appendBody($shadowContainer);
|
|
296
|
+
if ($mask != null) {
|
|
297
|
+
$anim.after($mask);
|
|
298
|
+
}
|
|
299
|
+
class PopsFolder {
|
|
300
|
+
init() {
|
|
301
|
+
config.folder.sort();
|
|
302
|
+
this.initFolderView(config.folder);
|
|
303
|
+
// 将数据存到全部文件的属性_config_中
|
|
304
|
+
|
|
305
|
+
const $allFiles = folderFileListBreadcrumbPrimaryElement.querySelector<HTMLDivElement>(
|
|
306
|
+
".pops-folder-list .pops-folder-file-list-breadcrumb-allFiles:first-child"
|
|
307
|
+
)!;
|
|
308
|
+
|
|
309
|
+
Reflect.set($allFiles, "data-config", config.folder);
|
|
310
|
+
// 设置点击顶部的全部文件事件
|
|
311
|
+
popsDOMUtils.on<MouseEvent | PointerEvent>($allFiles, "click", (event) => {
|
|
312
|
+
this.setBreadcrumbClickEvent(event, true, config.folder);
|
|
313
|
+
});
|
|
314
|
+
// 文件名的点击排序
|
|
315
|
+
popsDOMUtils.on<MouseEvent | PointerEvent>(
|
|
316
|
+
folderListSortFileNameElement.closest("th"),
|
|
317
|
+
"click",
|
|
318
|
+
(event) => {
|
|
319
|
+
this.arrowToSortFolderInfoView(folderListSortFileNameElement, event, "fileName");
|
|
320
|
+
},
|
|
321
|
+
{
|
|
322
|
+
capture: true,
|
|
323
|
+
}
|
|
324
|
+
);
|
|
325
|
+
// 修改事件的点击排序
|
|
326
|
+
popsDOMUtils.on(
|
|
327
|
+
folderListSortLatestTimeElement.closest("th"),
|
|
328
|
+
"click",
|
|
329
|
+
(event) => {
|
|
330
|
+
this.arrowToSortFolderInfoView(folderListSortLatestTimeElement, event, "latestTime");
|
|
331
|
+
},
|
|
332
|
+
{
|
|
333
|
+
capture: true,
|
|
334
|
+
}
|
|
335
|
+
);
|
|
336
|
+
// 文件大小的点击排序
|
|
337
|
+
popsDOMUtils.on(
|
|
338
|
+
folderListSortFileSizeElement.closest("th"),
|
|
339
|
+
"click",
|
|
340
|
+
(event) => {
|
|
341
|
+
this.arrowToSortFolderInfoView(folderListSortFileSizeElement, event, "fileSize");
|
|
342
|
+
},
|
|
343
|
+
{
|
|
344
|
+
capture: true,
|
|
345
|
+
}
|
|
346
|
+
);
|
|
347
|
+
// 设置默认触发的arrow
|
|
348
|
+
if (config.sort.name === "fileName") {
|
|
349
|
+
popsDOMUtils.emit(folderListSortFileNameElement, "click", {
|
|
350
|
+
notChangeSortRule: true,
|
|
351
|
+
});
|
|
352
|
+
} else if (config.sort.name === "latestTime") {
|
|
353
|
+
popsDOMUtils.emit(folderListSortLatestTimeElement, "click", {
|
|
354
|
+
notChangeSortRule: true,
|
|
355
|
+
});
|
|
356
|
+
} else if (config.sort.name === "fileSize") {
|
|
357
|
+
popsDOMUtils.emit(folderListSortFileSizeElement, "click", {
|
|
358
|
+
notChangeSortRule: true,
|
|
359
|
+
});
|
|
360
|
+
}
|
|
361
|
+
}
|
|
362
|
+
/**
|
|
363
|
+
* 在创建文件|文件夹创建元素前处理东西
|
|
364
|
+
*/
|
|
365
|
+
handlerWithBeforeCreateFileOrFolderInfoNode(folderData: PopsFolderDataConfig) {
|
|
366
|
+
let { fileSize } = folderData;
|
|
367
|
+
const { fileName, latestTime, isFolder = false } = folderData;
|
|
368
|
+
folderData.latestTime = folderData.latestTime ?? "-";
|
|
369
|
+
folderData.fileSize = folderData.fileSize ?? "-";
|
|
370
|
+
const $folder = popsDOMUtils.createElement("tr");
|
|
371
|
+
|
|
372
|
+
const $fileName = popsDOMUtils.createElement("td");
|
|
373
|
+
const $fileTime = popsDOMUtils.createElement("td");
|
|
374
|
+
const $fileFormatSize = popsDOMUtils.createElement("td");
|
|
375
|
+
|
|
376
|
+
let show_latestTime = "";
|
|
377
|
+
let show_fileSize = "";
|
|
378
|
+
let fileType = "";
|
|
379
|
+
let fileIcon = "";
|
|
380
|
+
if (isFolder) {
|
|
381
|
+
// 文件夹
|
|
382
|
+
fileType = "";
|
|
383
|
+
fileIcon = Folder_ICON.folder;
|
|
384
|
+
show_latestTime = "";
|
|
385
|
+
fileSize = "";
|
|
386
|
+
show_fileSize = "";
|
|
387
|
+
} else {
|
|
388
|
+
// 文件
|
|
389
|
+
if (typeof latestTime === "function") {
|
|
390
|
+
const timeRet = latestTime();
|
|
391
|
+
show_latestTime = timeRet.showText;
|
|
392
|
+
} else if (typeof latestTime === "number") {
|
|
393
|
+
show_latestTime = popsUtils.formatTime(latestTime);
|
|
394
|
+
} else if (typeof latestTime === "string") {
|
|
395
|
+
show_latestTime = latestTime;
|
|
396
|
+
}
|
|
397
|
+
if (typeof fileSize === "number") {
|
|
398
|
+
show_fileSize = popsUtils.formatByteToSize(fileSize, true);
|
|
399
|
+
} else if (typeof fileSize === "string") {
|
|
400
|
+
show_fileSize = fileSize;
|
|
401
|
+
}
|
|
402
|
+
// 找到对应的图标
|
|
403
|
+
const findIconKeyName = Object.keys(Folder_ICON).find((keyName) => {
|
|
404
|
+
if (fileName.toLowerCase().endsWith("." + keyName)) {
|
|
405
|
+
fileType = keyName;
|
|
406
|
+
fileIcon = Reflect.get(Folder_ICON, keyName);
|
|
407
|
+
return true;
|
|
408
|
+
}
|
|
409
|
+
});
|
|
410
|
+
if (findIconKeyName) {
|
|
411
|
+
fileIcon = Reflect.get(Folder_ICON, findIconKeyName);
|
|
412
|
+
fileType = findIconKeyName;
|
|
413
|
+
} else {
|
|
414
|
+
fileType = "Null";
|
|
415
|
+
fileIcon = Folder_ICON.Null;
|
|
416
|
+
}
|
|
417
|
+
}
|
|
418
|
+
|
|
419
|
+
if (typeof folderData.fileIcon === "string") {
|
|
420
|
+
// 强制使用自定义
|
|
421
|
+
fileIcon = folderData.fileIcon;
|
|
422
|
+
}
|
|
423
|
+
$folder.className = "pops-folder-list-table__body-row";
|
|
424
|
+
$fileName.className = "pops-folder-list-table__body-td";
|
|
425
|
+
$fileTime.className = "pops-folder-list-table__body-td";
|
|
426
|
+
$fileFormatSize.className = "pops-folder-list-table__body-td";
|
|
427
|
+
|
|
428
|
+
return {
|
|
429
|
+
$folder,
|
|
430
|
+
$fileName,
|
|
431
|
+
$fileTime,
|
|
432
|
+
$fileFormatSize,
|
|
433
|
+
/** 经过处理后的数据 */
|
|
434
|
+
data: {
|
|
435
|
+
fileType,
|
|
436
|
+
fileIcon,
|
|
437
|
+
show_latestTime,
|
|
438
|
+
show_fileSize,
|
|
439
|
+
},
|
|
440
|
+
};
|
|
441
|
+
}
|
|
442
|
+
/**
|
|
443
|
+
* 创建文件夹元素
|
|
444
|
+
* @param fileName 文件名
|
|
445
|
+
* @param latestTime 修改时间
|
|
446
|
+
* @param [fileSize="-"] 文件大小
|
|
447
|
+
* @param isFolder 是否是文件夹
|
|
448
|
+
*/
|
|
449
|
+
createFolderRowElement(folderData: PopsFolderDataConfig) {
|
|
450
|
+
const { $folder, $fileName, $fileTime, $fileFormatSize, data } =
|
|
451
|
+
this.handlerWithBeforeCreateFileOrFolderInfoNode(folderData);
|
|
452
|
+
|
|
453
|
+
const { fileName } = folderData;
|
|
454
|
+
|
|
455
|
+
PopsSafeUtils.setSafeHTML(
|
|
456
|
+
$fileName,
|
|
457
|
+
/*html*/ `
|
|
458
|
+
<div class="pops-folder-list-file-name cursor-p">
|
|
459
|
+
<div>
|
|
460
|
+
<img src="${data.fileIcon}" alt="${data.fileType}" class="pops-folder-list-file-icon u-file-icon u-file-icon--list">
|
|
461
|
+
<a href="javascript:;" title="${fileName}" class="pops-folder-list-file-name-title-text inline-block-v-middle text-ellip list-name-text">${fileName}</a>
|
|
462
|
+
</div>
|
|
463
|
+
</div>`
|
|
464
|
+
);
|
|
465
|
+
PopsSafeUtils.setSafeHTML(
|
|
466
|
+
$fileTime,
|
|
467
|
+
/*html*/ `
|
|
468
|
+
<div class="pops-folder-list__time">
|
|
469
|
+
<span>${data.show_latestTime}</span>
|
|
470
|
+
</div>`
|
|
471
|
+
);
|
|
472
|
+
PopsSafeUtils.setSafeHTML(
|
|
473
|
+
$fileFormatSize,
|
|
474
|
+
/*html*/ `
|
|
475
|
+
<div class="pops-folder-list-format-size">
|
|
476
|
+
<span>${data.show_fileSize}</span>
|
|
477
|
+
</div>`
|
|
478
|
+
);
|
|
479
|
+
|
|
480
|
+
Reflect.set($fileName, "__value__", folderData);
|
|
481
|
+
Reflect.set($fileTime, "__value__", folderData);
|
|
482
|
+
Reflect.set($fileFormatSize, "__value__", folderData);
|
|
483
|
+
Reflect.set($folder, "__value__", folderData);
|
|
484
|
+
|
|
485
|
+
$folder.appendChild($fileName);
|
|
486
|
+
$folder.appendChild($fileTime);
|
|
487
|
+
$folder.appendChild($fileFormatSize);
|
|
488
|
+
return {
|
|
489
|
+
folderElement: $folder,
|
|
490
|
+
fileNameElement: $fileName,
|
|
491
|
+
fileTimeElement: $fileTime,
|
|
492
|
+
fileFormatSize: $fileFormatSize,
|
|
493
|
+
};
|
|
494
|
+
}
|
|
495
|
+
/**
|
|
496
|
+
* 创建移动端文件夹元素
|
|
497
|
+
* @param fileName 文件名
|
|
498
|
+
* @param latestTime 创建时间
|
|
499
|
+
* @param [fileSize="-"] 文件大小
|
|
500
|
+
* @param isFolder 是否是文件夹
|
|
501
|
+
*/
|
|
502
|
+
createFolderRowElementByMobile(folderData: PopsFolderDataConfig) {
|
|
503
|
+
const { $folder, $fileName, data } = this.handlerWithBeforeCreateFileOrFolderInfoNode(folderData);
|
|
504
|
+
|
|
505
|
+
const { fileName } = folderData;
|
|
506
|
+
|
|
507
|
+
PopsSafeUtils.setSafeHTML(
|
|
508
|
+
$fileName,
|
|
509
|
+
/*html*/ `
|
|
510
|
+
<div class="pops-folder-list-file-name pops-mobile-folder-list-file-name cursor-p">
|
|
511
|
+
<img src="${data.fileIcon}" alt="${data.fileType}" class="pops-folder-list-file-icon u-file-icon u-file-icon--list">
|
|
512
|
+
<div>
|
|
513
|
+
<a title="${fileName}" class="pops-folder-list-file-name-title-text inline-block-v-middle text-ellip list-name-text">${fileName}</a>
|
|
514
|
+
<span>${data.show_latestTime} ${data.show_fileSize}</span>
|
|
515
|
+
</div>
|
|
516
|
+
</div>`
|
|
517
|
+
);
|
|
518
|
+
// 存储原来的值
|
|
519
|
+
Reflect.set($fileName, "__value__", folderData);
|
|
520
|
+
Reflect.set($folder, "folderData", folderData);
|
|
521
|
+
$folder.appendChild($fileName);
|
|
522
|
+
return {
|
|
523
|
+
folderElement: $folder,
|
|
524
|
+
fileNameElement: $fileName,
|
|
525
|
+
};
|
|
526
|
+
}
|
|
527
|
+
/**
|
|
528
|
+
* 清空文件夹信息页面
|
|
529
|
+
*/
|
|
530
|
+
clearFolderInfoView() {
|
|
531
|
+
PopsSafeUtils.setSafeHTML(folderListBodyElement, "");
|
|
532
|
+
}
|
|
533
|
+
/**
|
|
534
|
+
* 创建顶部导航的箭头图标
|
|
535
|
+
*/
|
|
536
|
+
createHeaderArrowIcon() {
|
|
537
|
+
const $arrowIcon = popsDOMUtils.createElement("div", {
|
|
538
|
+
className: "iconArrow",
|
|
539
|
+
});
|
|
540
|
+
return $arrowIcon;
|
|
541
|
+
}
|
|
542
|
+
/**
|
|
543
|
+
* 添加顶部导航元素
|
|
544
|
+
* @param folderName 文件夹名
|
|
545
|
+
* @param folderDataConfig 文件夹配置
|
|
546
|
+
*/
|
|
547
|
+
createBreadcrumb(
|
|
548
|
+
folderName: string,
|
|
549
|
+
folderDataConfig: PopsFolderDownloadOption | PopsFolderDataConfig[] | null | undefined | void
|
|
550
|
+
) {
|
|
551
|
+
const $breadcrumb = popsDOMUtils.createElement(
|
|
552
|
+
"span",
|
|
553
|
+
{
|
|
554
|
+
className: "pops-folder-file-list-breadcrumb-allFiles cursor-p",
|
|
555
|
+
innerHTML: `<a>${folderName}</a>`,
|
|
556
|
+
"data-config": folderDataConfig,
|
|
557
|
+
},
|
|
558
|
+
{
|
|
559
|
+
title: folderName,
|
|
560
|
+
}
|
|
561
|
+
);
|
|
562
|
+
return $breadcrumb;
|
|
563
|
+
}
|
|
564
|
+
/**
|
|
565
|
+
* 顶部导航的点击事件
|
|
566
|
+
* @param clickEvent
|
|
567
|
+
* @param isTop 是否是全部文件按钮
|
|
568
|
+
* @param dataConfigList 配置
|
|
569
|
+
*/
|
|
570
|
+
setBreadcrumbClickEvent(
|
|
571
|
+
clickEvent: MouseEvent | PointerEvent,
|
|
572
|
+
isTop: boolean,
|
|
573
|
+
dataConfigList: PopsFolderDataConfig[]
|
|
574
|
+
) {
|
|
575
|
+
this.clearFolderInfoView();
|
|
576
|
+
// 获取当前的导航元素
|
|
577
|
+
const $click = clickEvent.target as HTMLElement;
|
|
578
|
+
const currentBreadcrumb = $click.closest<HTMLSpanElement>("span.pops-folder-file-list-breadcrumb-allFiles");
|
|
579
|
+
if (currentBreadcrumb) {
|
|
580
|
+
while (currentBreadcrumb.nextElementSibling) {
|
|
581
|
+
currentBreadcrumb.nextElementSibling.remove();
|
|
582
|
+
}
|
|
583
|
+
} else {
|
|
584
|
+
console.error("获取导航按钮失败");
|
|
585
|
+
}
|
|
586
|
+
const loadingMask = PopsLoading.init({
|
|
587
|
+
$parent: $content,
|
|
588
|
+
content: {
|
|
589
|
+
text: "获取文件列表中...",
|
|
590
|
+
},
|
|
591
|
+
mask: {
|
|
592
|
+
enable: true,
|
|
593
|
+
clickEvent: {
|
|
594
|
+
toClose: false,
|
|
595
|
+
toHide: false,
|
|
596
|
+
},
|
|
597
|
+
},
|
|
598
|
+
addIndexCSS: false,
|
|
599
|
+
});
|
|
600
|
+
this.initFolderView(dataConfigList);
|
|
601
|
+
loadingMask.close();
|
|
602
|
+
}
|
|
603
|
+
/**
|
|
604
|
+
* 文件夹的点击事件 - 进入文件夹
|
|
605
|
+
*
|
|
606
|
+
* 先情况页面元素
|
|
607
|
+
* @param clickEvent
|
|
608
|
+
* @param dataConfig
|
|
609
|
+
*/
|
|
610
|
+
async enterFolder(clickEvent: MouseEvent | PointerEvent, dataConfig: PopsFolderDataConfig) {
|
|
611
|
+
this.clearFolderInfoView();
|
|
612
|
+
const loadingMask = PopsLoading.init({
|
|
613
|
+
$parent: $content,
|
|
614
|
+
content: {
|
|
615
|
+
text: "获取文件列表中...",
|
|
616
|
+
},
|
|
617
|
+
mask: {
|
|
618
|
+
enable: true,
|
|
619
|
+
},
|
|
620
|
+
addIndexCSS: false,
|
|
621
|
+
});
|
|
622
|
+
if (typeof dataConfig.clickEvent === "function") {
|
|
623
|
+
const childConfig = await dataConfig.clickEvent(clickEvent, dataConfig);
|
|
624
|
+
// 添加顶部导航的箭头
|
|
625
|
+
folderFileListBreadcrumbPrimaryElement.appendChild(this.createHeaderArrowIcon());
|
|
626
|
+
// 添加顶部导航的链接文字
|
|
627
|
+
const $breadcrumbAllFiles = this.createBreadcrumb(dataConfig.fileName, childConfig);
|
|
628
|
+
|
|
629
|
+
folderFileListBreadcrumbPrimaryElement.appendChild($breadcrumbAllFiles);
|
|
630
|
+
// 设置顶部导航点击事件
|
|
631
|
+
|
|
632
|
+
popsDOMUtils.on<MouseEvent | PointerEvent>($breadcrumbAllFiles, "click", (event) => {
|
|
633
|
+
this.setBreadcrumbClickEvent(event, false, childConfig as PopsFolderDataConfig[]);
|
|
634
|
+
});
|
|
635
|
+
|
|
636
|
+
this.initFolderView(childConfig as PopsFolderDataConfig[]);
|
|
637
|
+
}
|
|
638
|
+
loadingMask.close();
|
|
639
|
+
}
|
|
640
|
+
/**
|
|
641
|
+
* 文件的点击事件 - 下载文件
|
|
642
|
+
* @param $target
|
|
643
|
+
* @param dataConfig
|
|
644
|
+
*/
|
|
645
|
+
async downloadFile(clickEvent: MouseEvent | PointerEvent, $row: HTMLElement, dataConfig: PopsFolderDataConfig) {
|
|
646
|
+
popsDOMUtils.preventEvent(clickEvent);
|
|
647
|
+
|
|
648
|
+
const $link = $row.querySelector("a")!;
|
|
649
|
+
if (typeof dataConfig.clickEvent === "function") {
|
|
650
|
+
const downloadInfo = await dataConfig.clickEvent(clickEvent, dataConfig)!;
|
|
651
|
+
if (
|
|
652
|
+
downloadInfo != null &&
|
|
653
|
+
typeof downloadInfo === "object" &&
|
|
654
|
+
!Array.isArray(downloadInfo) &&
|
|
655
|
+
typeof downloadInfo.url === "string" &&
|
|
656
|
+
downloadInfo.url.trim() !== ""
|
|
657
|
+
) {
|
|
658
|
+
$link.setAttribute("href", downloadInfo.url);
|
|
659
|
+
$link.setAttribute("target", "_blank");
|
|
660
|
+
if (downloadInfo.autoDownload) {
|
|
661
|
+
if (downloadInfo.mode == null || String(downloadInfo.mode) === "") {
|
|
662
|
+
// 未设置mode的话默认为aBlank
|
|
663
|
+
downloadInfo.mode = "aBlank";
|
|
664
|
+
}
|
|
665
|
+
if (downloadInfo.mode === "a" || downloadInfo.mode === "aBlank") {
|
|
666
|
+
// a标签下载
|
|
667
|
+
const $anchor = popsDOMUtils.createElement("a");
|
|
668
|
+
|
|
669
|
+
if (downloadInfo.mode === "aBlank") {
|
|
670
|
+
$anchor.setAttribute("target", "_blank");
|
|
671
|
+
}
|
|
672
|
+
|
|
673
|
+
$anchor.href = downloadInfo.url;
|
|
674
|
+
$anchor.click();
|
|
675
|
+
} else if (downloadInfo.mode === "open" || downloadInfo.mode === "openBlank") {
|
|
676
|
+
// window.open下载
|
|
677
|
+
|
|
678
|
+
if (downloadInfo.mode === "openBlank") {
|
|
679
|
+
globalThis.open(downloadInfo.url, "_blank");
|
|
680
|
+
} else {
|
|
681
|
+
globalThis.open(downloadInfo.url);
|
|
682
|
+
}
|
|
683
|
+
} else if (downloadInfo.mode === "iframe") {
|
|
684
|
+
// iframe下载
|
|
685
|
+
const $downloadIframe = popsDOMUtils.createElement("iframe");
|
|
686
|
+
|
|
687
|
+
$downloadIframe.src = downloadInfo.url;
|
|
688
|
+
$downloadIframe.onload = function () {
|
|
689
|
+
popsUtils.setTimeout(() => {
|
|
690
|
+
$downloadIframe.remove();
|
|
691
|
+
}, 1000);
|
|
692
|
+
};
|
|
693
|
+
$shadowRoot.appendChild($downloadIframe);
|
|
694
|
+
popsUtils.setTimeout(
|
|
695
|
+
() => {
|
|
696
|
+
$downloadIframe.remove();
|
|
697
|
+
},
|
|
698
|
+
3 * 60 * 1000
|
|
699
|
+
);
|
|
700
|
+
} else {
|
|
701
|
+
console.error("未知的下载模式", downloadInfo);
|
|
702
|
+
}
|
|
703
|
+
}
|
|
704
|
+
}
|
|
705
|
+
}
|
|
706
|
+
}
|
|
707
|
+
/**
|
|
708
|
+
* 对配置进行排序
|
|
709
|
+
* @param folderDataConfigList
|
|
710
|
+
* @param sortName 比较的属性,默认fileName
|
|
711
|
+
* @param isDesc 是否降序,默认false(升序)
|
|
712
|
+
*/
|
|
713
|
+
sortFolderConfig(
|
|
714
|
+
folderDataConfigList: PopsFolderDataConfig[],
|
|
715
|
+
sortName: "fileName" | "fileSize" | "latestTime" = "fileName",
|
|
716
|
+
isDesc = false
|
|
717
|
+
) {
|
|
718
|
+
// 文件夹
|
|
719
|
+
const onlyFolderDataConfigList = folderDataConfigList.filter((value) => {
|
|
720
|
+
return value.isFolder;
|
|
721
|
+
});
|
|
722
|
+
// 文件
|
|
723
|
+
const onlyFileDataConfigList = folderDataConfigList.filter((value) => {
|
|
724
|
+
return !value.isFolder;
|
|
725
|
+
});
|
|
726
|
+
if (sortName === "fileName") {
|
|
727
|
+
// 文件夹排序
|
|
728
|
+
onlyFolderDataConfigList.sort((leftConfig, rightConfig) => {
|
|
729
|
+
const beforeVal = leftConfig[sortName].toString();
|
|
730
|
+
const afterVal = rightConfig[sortName].toString();
|
|
731
|
+
let compareVal = beforeVal.localeCompare(afterVal);
|
|
732
|
+
if (isDesc) {
|
|
733
|
+
// 降序
|
|
734
|
+
if (compareVal > 0) {
|
|
735
|
+
compareVal = -1;
|
|
736
|
+
} else if (compareVal < 0) {
|
|
737
|
+
compareVal = 1;
|
|
738
|
+
}
|
|
739
|
+
}
|
|
740
|
+
return compareVal;
|
|
741
|
+
});
|
|
742
|
+
// 文件名排序
|
|
743
|
+
onlyFileDataConfigList.sort((leftConfig, rightConfig) => {
|
|
744
|
+
const beforeVal = leftConfig[sortName].toString();
|
|
745
|
+
const afterVal = rightConfig[sortName].toString();
|
|
746
|
+
let compareVal = beforeVal.localeCompare(afterVal);
|
|
747
|
+
if (isDesc) {
|
|
748
|
+
// 降序
|
|
749
|
+
if (compareVal > 0) {
|
|
750
|
+
compareVal = -1;
|
|
751
|
+
} else if (compareVal < 0) {
|
|
752
|
+
compareVal = 1;
|
|
753
|
+
}
|
|
754
|
+
}
|
|
755
|
+
return compareVal;
|
|
756
|
+
});
|
|
757
|
+
} else {
|
|
758
|
+
// 文件夹排序
|
|
759
|
+
onlyFolderDataConfigList.sort((beforeConfig, afterConfig) => {
|
|
760
|
+
let beforeVal = beforeConfig[sortName];
|
|
761
|
+
let afterVal = afterConfig[sortName];
|
|
762
|
+
if (typeof beforeVal === "function") {
|
|
763
|
+
beforeVal = beforeVal().timeStamp;
|
|
764
|
+
}
|
|
765
|
+
if (typeof afterVal === "function") {
|
|
766
|
+
afterVal = afterVal().timeStamp;
|
|
767
|
+
}
|
|
768
|
+
if (sortName === "fileSize") {
|
|
769
|
+
// 文件大小,进行Float转换
|
|
770
|
+
beforeVal = parseFloat(beforeVal.toString());
|
|
771
|
+
afterVal = parseFloat(afterVal.toString());
|
|
772
|
+
} else if (sortName === "latestTime") {
|
|
773
|
+
// 文件时间
|
|
774
|
+
beforeVal = new Date(beforeVal || "").getTime();
|
|
775
|
+
afterVal = new Date(afterVal || "").getTime();
|
|
776
|
+
}
|
|
777
|
+
if (beforeVal > afterVal) {
|
|
778
|
+
if (isDesc) {
|
|
779
|
+
// 降序
|
|
780
|
+
return -1;
|
|
781
|
+
} else {
|
|
782
|
+
return 1;
|
|
783
|
+
}
|
|
784
|
+
} else if (beforeVal < afterVal) {
|
|
785
|
+
if (isDesc) {
|
|
786
|
+
// 降序
|
|
787
|
+
return 1;
|
|
788
|
+
} else {
|
|
789
|
+
return -1;
|
|
790
|
+
}
|
|
791
|
+
} else {
|
|
792
|
+
return 0;
|
|
793
|
+
}
|
|
794
|
+
});
|
|
795
|
+
// 文件排序
|
|
796
|
+
onlyFileDataConfigList.sort((beforeConfig, afterConfig) => {
|
|
797
|
+
let beforeVal = beforeConfig[sortName];
|
|
798
|
+
let afterVal = afterConfig[sortName];
|
|
799
|
+
if (typeof beforeVal === "function") {
|
|
800
|
+
beforeVal = beforeVal().timeStamp;
|
|
801
|
+
}
|
|
802
|
+
if (typeof afterVal === "function") {
|
|
803
|
+
afterVal = afterVal().timeStamp;
|
|
804
|
+
}
|
|
805
|
+
if (sortName === "fileSize") {
|
|
806
|
+
// 文件大小,进行Float转换
|
|
807
|
+
beforeVal = parseFloat(beforeVal.toString());
|
|
808
|
+
afterVal = parseFloat(afterVal.toString());
|
|
809
|
+
} else if (sortName === "latestTime") {
|
|
810
|
+
// 文件时间
|
|
811
|
+
beforeVal = new Date(beforeVal).getTime();
|
|
812
|
+
afterVal = new Date(afterVal).getTime();
|
|
813
|
+
}
|
|
814
|
+
if (beforeVal > afterVal) {
|
|
815
|
+
if (isDesc) {
|
|
816
|
+
// 降序
|
|
817
|
+
return -1;
|
|
818
|
+
} else {
|
|
819
|
+
return 1;
|
|
820
|
+
}
|
|
821
|
+
} else if (beforeVal < afterVal) {
|
|
822
|
+
if (isDesc) {
|
|
823
|
+
// 降序
|
|
824
|
+
return 1;
|
|
825
|
+
} else {
|
|
826
|
+
return -1;
|
|
827
|
+
}
|
|
828
|
+
} else {
|
|
829
|
+
return 0;
|
|
830
|
+
}
|
|
831
|
+
});
|
|
832
|
+
}
|
|
833
|
+
|
|
834
|
+
// 文件夹始终优先放前面
|
|
835
|
+
return [...onlyFolderDataConfigList, ...onlyFileDataConfigList];
|
|
836
|
+
}
|
|
837
|
+
/**
|
|
838
|
+
* 添加文件夹/文件行元素
|
|
839
|
+
* @param dataConfig 配置
|
|
840
|
+
*/
|
|
841
|
+
initFolderView(dataConfig: PopsFolderDataConfig[]) {
|
|
842
|
+
// 先对文件夹、文件进行排序
|
|
843
|
+
const sortedConfigList = this.sortFolderConfig(dataConfig, config.sort.name, config.sort.isDesc);
|
|
844
|
+
sortedConfigList.forEach((item) => {
|
|
845
|
+
if (item.isFolder) {
|
|
846
|
+
const { folderElement, fileNameElement } = popsUtils.isPhone()
|
|
847
|
+
? this.createFolderRowElementByMobile(item)
|
|
848
|
+
: this.createFolderRowElement(item);
|
|
849
|
+
// 文件夹 - 点击事件
|
|
850
|
+
popsDOMUtils.on<MouseEvent | PointerEvent>(fileNameElement, "click", (event) => {
|
|
851
|
+
// 进入文件夹
|
|
852
|
+
this.enterFolder(event, item);
|
|
853
|
+
});
|
|
854
|
+
|
|
855
|
+
folderListBodyElement.appendChild(folderElement);
|
|
856
|
+
} else {
|
|
857
|
+
const { folderElement, fileNameElement } = popsUtils.isPhone()
|
|
858
|
+
? this.createFolderRowElementByMobile(item)
|
|
859
|
+
: this.createFolderRowElement(item);
|
|
860
|
+
// 文件 - 点击事件
|
|
861
|
+
popsDOMUtils.on<MouseEvent | PointerEvent>(fileNameElement, "click", (event) => {
|
|
862
|
+
// 下载文件
|
|
863
|
+
this.downloadFile(event, fileNameElement, item);
|
|
864
|
+
});
|
|
865
|
+
|
|
866
|
+
folderListBodyElement.appendChild(folderElement);
|
|
867
|
+
}
|
|
868
|
+
});
|
|
869
|
+
}
|
|
870
|
+
/**
|
|
871
|
+
* 移除所有箭头的被访问状态
|
|
872
|
+
*/
|
|
873
|
+
removeArrowActiveStatus() {
|
|
874
|
+
[
|
|
875
|
+
...Array.from(folderListSortFileNameElement.querySelectorAll<HTMLElement>(".pops-folder-icon-active")),
|
|
876
|
+
...Array.from(folderListSortLatestTimeElement.querySelectorAll<HTMLElement>(".pops-folder-icon-active")),
|
|
877
|
+
...Array.from(folderListSortFileSizeElement.querySelectorAll<HTMLElement>(".pops-folder-icon-active")),
|
|
878
|
+
].forEach((ele) => ele.classList.remove("pops-folder-icon-active"));
|
|
879
|
+
}
|
|
880
|
+
/**
|
|
881
|
+
* 修改导航箭头的状态
|
|
882
|
+
*/
|
|
883
|
+
changeArrowActive(arrowUp: HTMLElement, arrowDown: HTMLElement, isDesc: boolean) {
|
|
884
|
+
this.removeArrowActiveStatus();
|
|
885
|
+
if (isDesc) {
|
|
886
|
+
arrowDown.classList.add("pops-folder-icon-active");
|
|
887
|
+
} else {
|
|
888
|
+
arrowUp.classList.add("pops-folder-icon-active");
|
|
889
|
+
}
|
|
890
|
+
}
|
|
891
|
+
/**
|
|
892
|
+
* 排序按钮的点击事件
|
|
893
|
+
* @param $target
|
|
894
|
+
* @param event
|
|
895
|
+
* @param sortName
|
|
896
|
+
*/
|
|
897
|
+
arrowToSortFolderInfoView($target: HTMLDivElement, event: MouseEvent | PointerEvent, sortName: string) {
|
|
898
|
+
const notChangeSortRule = Reflect.get(event, "notChangeSortRule");
|
|
899
|
+
if (!notChangeSortRule) {
|
|
900
|
+
config.sort.name = sortName as PopsFolderConfig["sort"]["name"];
|
|
901
|
+
config.sort.isDesc = !config.sort.isDesc;
|
|
902
|
+
}
|
|
903
|
+
|
|
904
|
+
const $arrowUp = $target.querySelector<HTMLDivElement>(".pops-folder-icon-arrow-up")!;
|
|
905
|
+
const $arrowDown = $target.querySelector<HTMLDivElement>(".pops-folder-icon-arrow-down")!;
|
|
906
|
+
this.changeArrowActive($arrowUp, $arrowDown, config.sort.isDesc);
|
|
907
|
+
if (
|
|
908
|
+
typeof config.sort.callback === "function" &&
|
|
909
|
+
config.sort.callback($target, event, config.sort.name, config.sort.isDesc)
|
|
910
|
+
) {
|
|
911
|
+
return;
|
|
912
|
+
}
|
|
913
|
+
|
|
914
|
+
const childrenList: PopsFolderDataConfig[] = [];
|
|
915
|
+
|
|
916
|
+
Array.from(folderListBodyElement.children).forEach(($tr) => {
|
|
917
|
+
const __value__ = Reflect.get($tr, "__value__");
|
|
918
|
+
Reflect.set(__value__, "target", $tr);
|
|
919
|
+
childrenList.push(__value__);
|
|
920
|
+
});
|
|
921
|
+
const sortedConfigList = this.sortFolderConfig(childrenList, config.sort.name, config.sort.isDesc);
|
|
922
|
+
sortedConfigList.forEach((item) => {
|
|
923
|
+
folderListBodyElement.appendChild((item as any).target);
|
|
924
|
+
});
|
|
925
|
+
}
|
|
926
|
+
}
|
|
927
|
+
|
|
928
|
+
const popsFolder = new PopsFolder();
|
|
929
|
+
popsFolder.init();
|
|
930
|
+
Reflect.set($pops, "data-pops-folder", popsFolder);
|
|
931
|
+
// 拖拽
|
|
932
|
+
if (config.drag) {
|
|
933
|
+
PopsInstanceUtils.drag($pops, {
|
|
934
|
+
dragElement: $title,
|
|
935
|
+
limit: config.dragLimit,
|
|
936
|
+
extraDistance: config.dragExtraDistance,
|
|
937
|
+
moveCallBack: config.dragMoveCallBack,
|
|
938
|
+
endCallBack: config.dragEndCallBack,
|
|
939
|
+
});
|
|
940
|
+
}
|
|
941
|
+
PopsHandler.handlePush(popsType, {
|
|
942
|
+
guid: guid,
|
|
943
|
+
$anim: $anim,
|
|
944
|
+
$pops: $pops,
|
|
945
|
+
$mask: $mask!,
|
|
946
|
+
$shadowContainer: $shadowContainer,
|
|
947
|
+
$shadowRoot: $shadowRoot,
|
|
948
|
+
config: config,
|
|
949
|
+
destory: result.close,
|
|
950
|
+
});
|
|
951
|
+
return result;
|
|
952
|
+
},
|
|
953
|
+
};
|