vite-plugin-files-server 1.0.2 → 1.1.1

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.
@@ -0,0 +1,855 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+
30
+ // src/v1_1_0_theme/index.ts
31
+ var v1_1_0_theme_exports = {};
32
+ __export(v1_1_0_theme_exports, {
33
+ default: () => fileServerPlugin
34
+ });
35
+ module.exports = __toCommonJS(v1_1_0_theme_exports);
36
+ var import_fs = __toESM(require("fs"), 1);
37
+ var import_path = __toESM(require("path"), 1);
38
+
39
+ // src/v1_1_0_theme/tempFolderDark.html?raw
40
+ var tempFolderDark_default = `<!doctype html>\r
41
+ <html lang="en">\r
42
+ <head>\r
43
+ <meta charset="UTF-8" />\r
44
+ <meta name="viewport" content="width=device-width, initial-scale=1.0" />\r
45
+ <title>Demo List {{pageTitle}}</title>\r
46
+ <style>\r
47
+ /* \u6697\u8272\u4E3B\u9898 - \u53EA\u4FEE\u6539\u989C\u8272\uFF0C\u4FDD\u6301\u4E0E\u4EAE\u8272\u4E3B\u9898\u76F8\u540C\u7684\u5E03\u5C40\u548C\u5C3A\u5BF8 */\r
48
+ body {\r
49
+ background-color: #1a1a1a; /* \u4FEE\u6539\uFF1A\u4EAE\u8272 #f8f9fa \u2192 \u6697\u8272 #1a1a1a */\r
50
+ color: #e0e0e0; /* \u4FEE\u6539\uFF1A\u4EAE\u8272 #212529 \u2192 \u6697\u8272 #e0e0e0 */\r
51
+ font-family:\r
52
+ -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Helvetica Neue', Arial, sans-serif;\r
53
+ margin: 0;\r
54
+ padding: 20px;\r
55
+ font-size: 14px;\r
56
+ line-height: 1.5;\r
57
+ }\r
58
+ \r
59
+ /* \u9762\u5305\u5C51\u5BFC\u822A - \u6697\u8272 */\r
60
+ .breadcrumb {\r
61
+ color: #a0a0a0; /* \u4FEE\u6539\uFF1A\u4EAE\u8272 #6c757d \u2192 \u6697\u8272 #a0a0a0 */\r
62
+ margin-bottom: 20px;\r
63
+ font-size: 13px;\r
64
+ background-color: #2a2a2a; /* \u4FEE\u6539\uFF1A\u4EAE\u8272 #ffffff \u2192 \u6697\u8272 #2a2a2a */\r
65
+ padding: 12px 16px;\r
66
+ border-radius: 8px;\r
67
+ box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2); /* \u4FEE\u6539\uFF1A\u9634\u5F71\u52A0\u6DF1 */\r
68
+ border: 1px solid #3a3a3a; /* \u4FEE\u6539\uFF1A\u4EAE\u8272 #e9ecef \u2192 \u6697\u8272 #3a3a3a */\r
69
+ }\r
70
+ .breadcrumb-link {\r
71
+ color: #4dabf7; /* \u4FEE\u6539\uFF1A\u4EAE\u8272 #0d6efd \u2192 \u6697\u8272 #4dabf7 */\r
72
+ text-decoration: none;\r
73
+ font-weight: 500;\r
74
+ transition: all 0.2s;\r
75
+ padding: 4px 8px;\r
76
+ border-radius: 4px;\r
77
+ }\r
78
+ .breadcrumb-link:hover {\r
79
+ background-color: #3a3a3a; /* \u4FEE\u6539\uFF1A\u4EAE\u8272 #e7f1ff \u2192 \u6697\u8272 #3a3a3a */\r
80
+ color: #74c0fc; /* \u4FEE\u6539\uFF1A\u4EAE\u8272 #0a58ca \u2192 \u6697\u8272 #74c0fc */\r
81
+ text-decoration: none;\r
82
+ }\r
83
+ \r
84
+ /* \u5185\u5BB9\u533A\u57DF */\r
85
+ .content-area {\r
86
+ margin-top: 20px;\r
87
+ }\r
88
+ \r
89
+ /* gallery\u6811\u5F62\u89C6\u56FE - \u6697\u8272 */\r
90
+ .gallery-tree {\r
91
+ font-family: 'SF Mono', 'Monaco', 'Consolas', 'Liberation Mono', monospace;\r
92
+ line-height: 1.6;\r
93
+ color: #e0e0e0; /* \u4FEE\u6539\uFF1A\u4EAE\u8272 #212529 \u2192 \u6697\u8272 #e0e0e0 */\r
94
+ }\r
95
+ \r
96
+ /* \u6587\u4EF6\u5939\u9879 - \u6697\u8272\u4E3B\u9898 */\r
97
+ .folder-item {\r
98
+ cursor: default;\r
99
+ margin: 6px 0;\r
100
+ padding-left: 20px;\r
101
+ position: relative;\r
102
+ }\r
103
+ /* .folder-item:hover {\r
104
+ background-color: #2a2a2a; \r
105
+ } */\r
106
+ .folder-name {\r
107
+ color: #4dabf7; /* \u4FEE\u6539\uFF1A\u4EAE\u8272 #0d6efd \u2192 \u6697\u8272 #4dabf7 */\r
108
+ text-decoration: none;\r
109
+ display: inline-block;\r
110
+ padding: 6px 12px;\r
111
+ border-radius: 6px;\r
112
+ font-weight: 500;\r
113
+ background-color: #2a2a2a; /* \u4FEE\u6539\uFF1A\u4EAE\u8272 #e7f1ff \u2192 \u6697\u8272 #2a2a2a */\r
114
+ border: 1px solid #3a3a3a; /* \u4FEE\u6539\uFF1A\u4EAE\u8272 #cfe2ff \u2192 \u6697\u8272 #3a3a3a */\r
115
+ transition: all 0.2s;\r
116
+ }\r
117
+ .folder-name::before {\r
118
+ content: '\u{1F4C1}';\r
119
+ margin-right: 8px;\r
120
+ }\r
121
+ \r
122
+ /* \u6587\u4EF6\u7F51\u683C\u5E03\u5C40 - \u4E09\u5217 */\r
123
+ .file-grid {\r
124
+ margin: 12px 0 20px 0;\r
125
+ display: block;\r
126
+ }\r
127
+ .file-row {\r
128
+ display: flex;\r
129
+ margin: 8px 0;\r
130
+ }\r
131
+ .file-column {\r
132
+ flex: 1;\r
133
+ min-width: 0;\r
134
+ margin: 0 6px;\r
135
+ padding: 8px 12px;\r
136
+ border-radius: 8px;\r
137
+ transition: all 0.2s;\r
138
+ background-color: #2a2a2a; /* \u4FEE\u6539\uFF1A\u4EAE\u8272 #ffffff \u2192 \u6697\u8272 #2a2a2a */\r
139
+ border: 1px solid #3a3a3a; /* \u4FEE\u6539\uFF1A\u4EAE\u8272 #dee2e6 \u2192 \u6697\u8272 #3a3a3a */\r
140
+ box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2); /* \u4FEE\u6539\uFF1A\u9634\u5F71\u52A0\u6DF1 */\r
141
+ }\r
142
+ .file-column:hover {\r
143
+ background-color: #3a3a3a; /* \u4FEE\u6539\uFF1A\u4EAE\u8272 #f8f9fa \u2192 \u6697\u8272 #3a3a3a */\r
144
+ transform: translateY(-2px);\r
145
+ box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3); /* \u4FEE\u6539\uFF1A\u9634\u5F71\u52A0\u6DF1 */\r
146
+ border-color: #4dabf7; /* \u4FEE\u6539\uFF1A\u4EAE\u8272 #0d6efd \u2192 \u6697\u8272 #4dabf7 */\r
147
+ }\r
148
+ .empty-column {\r
149
+ background-color: transparent;\r
150
+ border: 1px solid transparent;\r
151
+ box-shadow: none;\r
152
+ }\r
153
+ .empty-column:hover {\r
154
+ background-color: transparent;\r
155
+ transform: none;\r
156
+ box-shadow: none;\r
157
+ border-color: transparent;\r
158
+ }\r
159
+ .html-file-link {\r
160
+ color: #e0e0e0; /* \u4FEE\u6539\uFF1A\u4EAE\u8272 #212529 \u2192 \u6697\u8272 #e0e0e0 */\r
161
+ text-decoration: none;\r
162
+ display: block;\r
163
+ white-space: nowrap;\r
164
+ overflow: hidden;\r
165
+ text-overflow: ellipsis;\r
166
+ padding-left: 24px;\r
167
+ position: relative;\r
168
+ font-size: 13px;\r
169
+ }\r
170
+ .html-file-link:hover {\r
171
+ color: #ffffff; /* \u4FEE\u6539\uFF1A\u4EAE\u8272 #0d6efd \u2192 \u6697\u8272 #ffffff */\r
172
+ }\r
173
+ .html-file-link::before {\r
174
+ content: '\u{1F4C4}';\r
175
+ position: absolute;\r
176
+ left: 0;\r
177
+ top: 0;\r
178
+ color: #a0a0a0; /* \u4FEE\u6539\uFF1A\u4EAE\u8272 #6c757d \u2192 \u6697\u8272 #a0a0a0 */\r
179
+ }\r
180
+ \r
181
+ .back-all-link {\r
182
+ font-family:\r
183
+ -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Helvetica Neue', Arial, sans-serif;\r
184
+ }\r
185
+ .back-all-link a {\r
186
+ text-decoration: none;\r
187
+ padding: 10px 16px;\r
188
+ display: block;\r
189
+ border-radius: 8px;\r
190
+ transition: all 0.2s;\r
191
+ background-color: #2a2a2a; /* \u4FEE\u6539\uFF1A\u4EAE\u8272 #ffffff \u2192 \u6697\u8272 #2a2a2a */\r
192
+ border: 1px solid #3a3a3a; /* \u4FEE\u6539\uFF1A\u4EAE\u8272 #dee2e6 \u2192 \u6697\u8272 #3a3a3a */\r
193
+ box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2); /* \u4FEE\u6539\uFF1A\u9634\u5F71\u52A0\u6DF1 */\r
194
+ }\r
195
+ .back-all-link a:hover {\r
196
+ transform: translateY(-2px);\r
197
+ box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3); /* \u4FEE\u6539\uFF1A\u9634\u5F71\u52A0\u6DF1 */\r
198
+ }\r
199
+ .back-all-link a.back-link {\r
200
+ color: #4dabf7; /* \u4FEE\u6539\uFF1A\u4EAE\u8272 #0d6efd \u2192 \u6697\u8272 #4dabf7 */\r
201
+ background-color: #2a2a2a; /* \u4FEE\u6539\uFF1A\u4EAE\u8272 #ffffff \u2192 \u6697\u8272 #2a2a2a */\r
202
+ border: 1px solid #3a3a3a; /* \u4FEE\u6539\uFF1A\u4EAE\u8272 #cfe2ff \u2192 \u6697\u8272 #3a3a3a */\r
203
+ padding-left: 48px;\r
204
+ position: relative;\r
205
+ color: #a0a0a0; /* \u4FEE\u6539\uFF1A\u4EAE\u8272 #6c757d \u2192 \u6697\u8272 #a0a0a0 */\r
206
+ background-color: #2a2a2a; /* \u4FEE\u6539\uFF1A\u4EAE\u8272 #f8f9fa \u2192 \u6697\u8272 #2a2a2a */\r
207
+ border: 1px solid #3a3a3a; /* \u4FEE\u6539\uFF1A\u4EAE\u8272 #e9ecef \u2192 \u6697\u8272 #3a3a3a */\r
208
+ }\r
209
+ .back-all-link a.back-link:hover {\r
210
+ background-color: #3a3a3a; /* \u4FEE\u6539\uFF1A\u4EAE\u8272 #f8f9fa \u2192 \u6697\u8272 #3a3a3a */\r
211
+ border-color: #4dabf7; /* \u4FEE\u6539\uFF1A\u4EAE\u8272 #0d6efd \u2192 \u6697\u8272 #4dabf7 */\r
212
+ background-color: #3a3a3a; /* \u4FEE\u6539\uFF1A\u4EAE\u8272 #e9ecef \u2192 \u6697\u8272 #3a3a3a */\r
213
+ border-color: #4dabf7; /* \u4FEE\u6539\uFF1A\u4EAE\u8272 #dee2e6 \u2192 \u6697\u8272 #4dabf7 */\r
214
+ }\r
215
+ .back-all-link a.back-link::before {\r
216
+ content: '\u{1F4C1}';\r
217
+ position: absolute;\r
218
+ left: 16px;\r
219
+ top: 50%;\r
220
+ transform: translateY(-50%);\r
221
+ font-size: 16px;\r
222
+ content: '\u2190';\r
223
+ margin-right: 8px;\r
224
+ }\r
225
+ \r
226
+ /* \u6587\u4EF6\u5217\u8868\u89C6\u56FE - \u6697\u8272\u4E3B\u9898 */\r
227
+ .file-list {\r
228
+ list-style: none;\r
229
+ padding: 0;\r
230
+ margin: 0;\r
231
+ }\r
232
+ .file-list li {\r
233
+ margin: 6px 0;\r
234
+ }\r
235
+ .file-list a {\r
236
+ text-decoration: none;\r
237
+ padding: 10px 16px;\r
238
+ display: block;\r
239
+ border-radius: 8px;\r
240
+ transition: all 0.2s;\r
241
+ background-color: #2a2a2a; /* \u4FEE\u6539\uFF1A\u4EAE\u8272 #ffffff \u2192 \u6697\u8272 #2a2a2a */\r
242
+ border: 1px solid #3a3a3a; /* \u4FEE\u6539\uFF1A\u4EAE\u8272 #dee2e6 \u2192 \u6697\u8272 #3a3a3a */\r
243
+ box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2); /* \u4FEE\u6539\uFF1A\u9634\u5F71\u52A0\u6DF1 */\r
244
+ }\r
245
+ .file-list a:hover {\r
246
+ transform: translateY(-2px);\r
247
+ box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3); /* \u4FEE\u6539\uFF1A\u9634\u5F71\u52A0\u6DF1 */\r
248
+ }\r
249
+ .file-list a.folder-link {\r
250
+ color: #4dabf7; /* \u4FEE\u6539\uFF1A\u4EAE\u8272 #0d6efd \u2192 \u6697\u8272 #4dabf7 */\r
251
+ background-color: #2a2a2a; /* \u4FEE\u6539\uFF1A\u4EAE\u8272 #ffffff \u2192 \u6697\u8272 #2a2a2a */\r
252
+ border: 1px solid #3a3a3a; /* \u4FEE\u6539\uFF1A\u4EAE\u8272 #cfe2ff \u2192 \u6697\u8272 #3a3a3a */\r
253
+ padding-left: 48px;\r
254
+ position: relative;\r
255
+ }\r
256
+ .file-list a.folder-link:hover {\r
257
+ background-color: #3a3a3a; /* \u4FEE\u6539\uFF1A\u4EAE\u8272 #f8f9fa \u2192 \u6697\u8272 #3a3a3a */\r
258
+ border-color: #4dabf7; /* \u4FEE\u6539\uFF1A\u4EAE\u8272 #0d6efd \u2192 \u6697\u8272 #4dabf7 */\r
259
+ }\r
260
+ .file-list a.folder-link::before {\r
261
+ content: '\u{1F4C1}';\r
262
+ position: absolute;\r
263
+ left: 16px;\r
264
+ top: 50%;\r
265
+ transform: translateY(-50%);\r
266
+ font-size: 16px;\r
267
+ }\r
268
+ .file-list a.back-link {\r
269
+ color: #a0a0a0; /* \u4FEE\u6539\uFF1A\u4EAE\u8272 #6c757d \u2192 \u6697\u8272 #a0a0a0 */\r
270
+ background-color: #2a2a2a; /* \u4FEE\u6539\uFF1A\u4EAE\u8272 #f8f9fa \u2192 \u6697\u8272 #2a2a2a */\r
271
+ border: 1px solid #3a3a3a; /* \u4FEE\u6539\uFF1A\u4EAE\u8272 #e9ecef \u2192 \u6697\u8272 #3a3a3a */\r
272
+ }\r
273
+ .file-list a.back-link:hover {\r
274
+ background-color: #3a3a3a; /* \u4FEE\u6539\uFF1A\u4EAE\u8272 #e9ecef \u2192 \u6697\u8272 #3a3a3a */\r
275
+ border-color: #4dabf7; /* \u4FEE\u6539\uFF1A\u4EAE\u8272 #dee2e6 \u2192 \u6697\u8272 #4dabf7 */\r
276
+ }\r
277
+ .file-list a.back-link::before {\r
278
+ content: '\u2190';\r
279
+ margin-right: 8px;\r
280
+ }\r
281
+ .file-list a.file-link {\r
282
+ color: #e0e0e0; /* \u4FEE\u6539\uFF1A\u4EAE\u8272 #212529 \u2192 \u6697\u8272 #e0e0e0 */\r
283
+ background-color: #2a2a2a; /* \u4FEE\u6539\uFF1A\u4EAE\u8272 #ffffff \u2192 \u6697\u8272 #2a2a2a */\r
284
+ border: 1px solid #3a3a3a; /* \u4FEE\u6539\uFF1A\u4EAE\u8272 #dee2e6 \u2192 \u6697\u8272 #3a3a3a */\r
285
+ padding-left: 48px;\r
286
+ position: relative;\r
287
+ }\r
288
+ .file-list a.file-link:hover {\r
289
+ background-color: #3a3a3a; /* \u4FEE\u6539\uFF1A\u4EAE\u8272 #f8f9fa \u2192 \u6697\u8272 #3a3a3a */\r
290
+ border-color: #4dabf7; /* \u4FEE\u6539\uFF1A\u4EAE\u8272 #0d6efd \u2192 \u6697\u8272 #4dabf7 */\r
291
+ }\r
292
+ .file-list a.file-link::before {\r
293
+ content: '\u{1F4C4}';\r
294
+ position: absolute;\r
295
+ left: 16px;\r
296
+ top: 50%;\r
297
+ transform: translateY(-50%);\r
298
+ font-size: 16px;\r
299
+ color: #a0a0a0; /* \u4FEE\u6539\uFF1A\u4EAE\u8272 #6c757d \u2192 \u6697\u8272 #a0a0a0 */\r
300
+ }\r
301
+ \r
302
+ /* \u7A7A\u72B6\u6001 - \u6697\u8272 */\r
303
+ .empty-message {\r
304
+ color: #a0a0a0; /* \u4FEE\u6539\uFF1A\u4EAE\u8272 #6c757d \u2192 \u6697\u8272 #a0a0a0 */\r
305
+ font-style: italic;\r
306
+ text-align: center;\r
307
+ padding: 32px;\r
308
+ background-color: #2a2a2a; /* \u4FEE\u6539\uFF1A\u4EAE\u8272 #ffffff \u2192 \u6697\u8272 #2a2a2a */\r
309
+ border-radius: 8px;\r
310
+ border: 1px dashed #3a3a3a; /* \u4FEE\u6539\uFF1A\u4EAE\u8272 #dee2e6 \u2192 \u6697\u8272 #3a3a3a */\r
311
+ box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2); /* \u4FEE\u6539\uFF1A\u9634\u5F71\u52A0\u6DF1 */\r
312
+ }\r
313
+ \r
314
+ /* \u54CD\u5E94\u5F0F\u8BBE\u8BA1 */\r
315
+ @media (max-width: 768px) {\r
316
+ body {\r
317
+ padding: 12px;\r
318
+ }\r
319
+ .file-row {\r
320
+ flex-direction: column;\r
321
+ }\r
322
+ .file-column {\r
323
+ margin: 4px 0;\r
324
+ }\r
325
+ }\r
326
+ </style>\r
327
+ </head>\r
328
+ <body>\r
329
+ <div class="breadcrumb">{{breadcrumb}}</div>\r
330
+ <div class="content-area">{{list}}</div>\r
331
+ </body>\r
332
+ </html>\r
333
+ `;
334
+
335
+ // src/v1_1_0_theme/tempFolderLight.html?raw
336
+ var tempFolderLight_default = `<!doctype html>\r
337
+ <html lang="en">\r
338
+ <head>\r
339
+ <meta charset="UTF-8" />\r
340
+ <meta name="viewport" content="width=device-width, initial-scale=1.0" />\r
341
+ <title>Demo List {{pageTitle}}</title>\r
342
+ <style>\r
343
+ /* \u4EAE\u8272\u4E3B\u9898 - \u6574\u4F53\u660E\u4EAE\u98CE\u683C */\r
344
+ body {\r
345
+ background-color: #f8f9fa;\r
346
+ color: #212529;\r
347
+ font-family:\r
348
+ -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Helvetica Neue', Arial, sans-serif;\r
349
+ margin: 0;\r
350
+ padding: 20px;\r
351
+ font-size: 14px;\r
352
+ line-height: 1.5;\r
353
+ }\r
354
+ \r
355
+ /* \u9762\u5305\u5C51\u5BFC\u822A - \u4EAE\u8272 */\r
356
+ .breadcrumb {\r
357
+ color: #6c757d;\r
358
+ margin-bottom: 20px;\r
359
+ font-size: 13px;\r
360
+ background-color: #ffffff;\r
361
+ padding: 12px 16px;\r
362
+ border-radius: 8px;\r
363
+ box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);\r
364
+ border: 1px solid #e9ecef;\r
365
+ }\r
366
+ .breadcrumb-link {\r
367
+ color: #0d6efd;\r
368
+ text-decoration: none;\r
369
+ font-weight: 500;\r
370
+ transition: all 0.2s;\r
371
+ padding: 4px 8px;\r
372
+ border-radius: 4px;\r
373
+ }\r
374
+ .breadcrumb-link:hover {\r
375
+ background-color: #e7f1ff;\r
376
+ color: #0a58ca;\r
377
+ text-decoration: none;\r
378
+ }\r
379
+ \r
380
+ /* \u5185\u5BB9\u533A\u57DF */\r
381
+ .content-area {\r
382
+ margin-top: 20px;\r
383
+ }\r
384
+ \r
385
+ /* gallery\u6811\u5F62\u89C6\u56FE - \u4EAE\u8272 */\r
386
+ .gallery-tree {\r
387
+ font-family: 'SF Mono', 'Monaco', 'Consolas', 'Liberation Mono', monospace;\r
388
+ line-height: 1.6;\r
389
+ color: #212529;\r
390
+ }\r
391
+ \r
392
+ /* \u6587\u4EF6\u5939\u9879 - \u4EAE\u8272\u4E3B\u9898 */\r
393
+ .folder-item {\r
394
+ cursor: default;\r
395
+ margin: 6px 0;\r
396
+ padding-left: 20px;\r
397
+ position: relative;\r
398
+ }\r
399
+ .folder-item:hover {\r
400
+ background-color: #f8f9fa;\r
401
+ }\r
402
+ .folder-name {\r
403
+ color: #0d6efd;\r
404
+ text-decoration: none;\r
405
+ display: inline-block;\r
406
+ padding: 6px 12px;\r
407
+ border-radius: 6px;\r
408
+ font-weight: 500;\r
409
+ background-color: #e7f1ff;\r
410
+ border: 1px solid #cfe2ff;\r
411
+ transition: all 0.2s;\r
412
+ }\r
413
+ .folder-name::before {\r
414
+ content: '\u{1F4C1}';\r
415
+ margin-right: 8px;\r
416
+ }\r
417
+ \r
418
+ /* \u6587\u4EF6\u7F51\u683C\u5E03\u5C40 - \u4E09\u5217 */\r
419
+ .file-grid {\r
420
+ margin: 12px 0 20px 0;\r
421
+ display: block;\r
422
+ }\r
423
+ .file-row {\r
424
+ display: flex;\r
425
+ margin: 8px 0;\r
426
+ }\r
427
+ .file-column {\r
428
+ flex: 1;\r
429
+ min-width: 0;\r
430
+ margin: 0 6px;\r
431
+ padding: 8px 12px;\r
432
+ border-radius: 8px;\r
433
+ transition: all 0.2s;\r
434
+ background-color: #ffffff;\r
435
+ border: 1px solid #dee2e6;\r
436
+ box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);\r
437
+ }\r
438
+ .file-column:hover {\r
439
+ background-color: #f8f9fa;\r
440
+ transform: translateY(-2px);\r
441
+ box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);\r
442
+ border-color: #0d6efd;\r
443
+ }\r
444
+ .empty-column {\r
445
+ background-color: transparent;\r
446
+ border: 1px solid transparent;\r
447
+ box-shadow: none;\r
448
+ }\r
449
+ .empty-column:hover {\r
450
+ background-color: transparent;\r
451
+ transform: none;\r
452
+ box-shadow: none;\r
453
+ border-color: transparent;\r
454
+ }\r
455
+ .html-file-link {\r
456
+ color: #212529;\r
457
+ text-decoration: none;\r
458
+ display: block;\r
459
+ white-space: nowrap;\r
460
+ overflow: hidden;\r
461
+ text-overflow: ellipsis;\r
462
+ padding-left: 24px;\r
463
+ position: relative;\r
464
+ font-size: 13px;\r
465
+ }\r
466
+ .html-file-link:hover {\r
467
+ color: #0d6efd;\r
468
+ }\r
469
+ .html-file-link::before {\r
470
+ content: '\u{1F4C4}';\r
471
+ position: absolute;\r
472
+ left: 0;\r
473
+ top: 0;\r
474
+ color: #6c757d;\r
475
+ }\r
476
+ \r
477
+ .back-all-link {\r
478
+ font-family:\r
479
+ -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Helvetica Neue', Arial, sans-serif;\r
480
+ }\r
481
+ .back-all-link a {\r
482
+ text-decoration: none;\r
483
+ padding: 10px 16px;\r
484
+ display: block;\r
485
+ border-radius: 8px;\r
486
+ transition: all 0.2s;\r
487
+ background-color: #ffffff;\r
488
+ border: 1px solid #dee2e6;\r
489
+ box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);\r
490
+ }\r
491
+ .back-all-link a:hover {\r
492
+ transform: translateY(-2px);\r
493
+ box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);\r
494
+ }\r
495
+ .back-all-link a.back-link {\r
496
+ color: #0d6efd;\r
497
+ background-color: #ffffff;\r
498
+ border: 1px solid #cfe2ff;\r
499
+ padding-left: 48px;\r
500
+ position: relative;\r
501
+ color: #6c757d;\r
502
+ background-color: #f8f9fa;\r
503
+ border: 1px solid #e9ecef;\r
504
+ }\r
505
+ .back-all-link a.back-link:hover {\r
506
+ background-color: #e9ecef;\r
507
+ border-color: #dee2e6;\r
508
+ background-color: #f8f9fa;\r
509
+ border-color: #0d6efd;\r
510
+ }\r
511
+ .back-all-link a.back-link::before {\r
512
+ content: '\u{1F4C1}';\r
513
+ position: absolute;\r
514
+ left: 16px;\r
515
+ top: 50%;\r
516
+ transform: translateY(-50%);\r
517
+ font-size: 16px;\r
518
+ content: '\u2190';\r
519
+ margin-right: 8px;\r
520
+ }\r
521
+ \r
522
+ /* \u6587\u4EF6\u5217\u8868\u89C6\u56FE - \u4EAE\u8272\u4E3B\u9898 */\r
523
+ .file-list {\r
524
+ list-style: none;\r
525
+ padding: 0;\r
526
+ margin: 0;\r
527
+ }\r
528
+ .file-list li {\r
529
+ margin: 6px 0;\r
530
+ }\r
531
+ .file-list a {\r
532
+ text-decoration: none;\r
533
+ padding: 10px 16px;\r
534
+ display: block;\r
535
+ border-radius: 8px;\r
536
+ transition: all 0.2s;\r
537
+ background-color: #ffffff;\r
538
+ border: 1px solid #dee2e6;\r
539
+ box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);\r
540
+ }\r
541
+ .file-list a:hover {\r
542
+ transform: translateY(-2px);\r
543
+ box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);\r
544
+ }\r
545
+ .file-list a.folder-link {\r
546
+ color: #0d6efd;\r
547
+ background-color: #ffffff;\r
548
+ border: 1px solid #cfe2ff;\r
549
+ padding-left: 48px;\r
550
+ position: relative;\r
551
+ }\r
552
+ .file-list a.folder-link:hover {\r
553
+ background-color: #f8f9fa;\r
554
+ border-color: #0d6efd;\r
555
+ }\r
556
+ .file-list a.folder-link::before {\r
557
+ content: '\u{1F4C1}';\r
558
+ position: absolute;\r
559
+ left: 16px;\r
560
+ top: 50%;\r
561
+ transform: translateY(-50%);\r
562
+ font-size: 16px;\r
563
+ }\r
564
+ .file-list a.back-link {\r
565
+ color: #6c757d;\r
566
+ background-color: #f8f9fa;\r
567
+ border: 1px solid #e9ecef;\r
568
+ }\r
569
+ .file-list a.back-link:hover {\r
570
+ background-color: #e9ecef;\r
571
+ border-color: #dee2e6;\r
572
+ }\r
573
+ .file-list a.back-link::before {\r
574
+ content: '\u2190';\r
575
+ margin-right: 8px;\r
576
+ }\r
577
+ .file-list a.file-link {\r
578
+ color: #212529;\r
579
+ background-color: #ffffff;\r
580
+ border: 1px solid #dee2e6;\r
581
+ padding-left: 48px;\r
582
+ position: relative;\r
583
+ }\r
584
+ .file-list a.file-link:hover {\r
585
+ background-color: #f8f9fa;\r
586
+ border-color: #0d6efd;\r
587
+ }\r
588
+ .file-list a.file-link::before {\r
589
+ content: '\u{1F4C4}';\r
590
+ position: absolute;\r
591
+ left: 16px;\r
592
+ top: 50%;\r
593
+ transform: translateY(-50%);\r
594
+ font-size: 16px;\r
595
+ color: #6c757d;\r
596
+ }\r
597
+ \r
598
+ /* \u7A7A\u72B6\u6001 - \u4EAE\u8272 */\r
599
+ .empty-message {\r
600
+ color: #6c757d;\r
601
+ font-style: italic;\r
602
+ text-align: center;\r
603
+ padding: 32px;\r
604
+ background-color: #ffffff;\r
605
+ border-radius: 8px;\r
606
+ border: 1px dashed #dee2e6;\r
607
+ box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);\r
608
+ }\r
609
+ \r
610
+ /* \u54CD\u5E94\u5F0F\u8BBE\u8BA1 */\r
611
+ @media (max-width: 768px) {\r
612
+ body {\r
613
+ padding: 12px;\r
614
+ }\r
615
+ .file-row {\r
616
+ flex-direction: column;\r
617
+ }\r
618
+ .file-column {\r
619
+ margin: 4px 0;\r
620
+ }\r
621
+ }\r
622
+ </style>\r
623
+ </head>\r
624
+ <body>\r
625
+ <div class="breadcrumb">{{breadcrumb}}</div>\r
626
+ <div class="content-area">{{list}}</div>\r
627
+ </body>\r
628
+ </html>\r
629
+ `;
630
+
631
+ // src/v1_1_0_theme/index.ts
632
+ function fileServerPlugin(options = {}) {
633
+ const { enable = true, root = "", theme = "dark" } = options;
634
+ return {
635
+ name: "vite-plugin-files-server",
636
+ configureServer(server) {
637
+ if (!enable) return;
638
+ let templateString;
639
+ try {
640
+ if (theme === "light") {
641
+ templateString = tempFolderLight_default;
642
+ } else {
643
+ templateString = tempFolderDark_default;
644
+ }
645
+ } catch (e) {
646
+ console.error("Failed to load template:", e);
647
+ templateString = tempFolderDark_default;
648
+ }
649
+ function buildGalleryTree(dirPath, baseUrl = "", depth = 0) {
650
+ try {
651
+ const files = import_fs.default.readdirSync(dirPath);
652
+ let html = "";
653
+ files.sort((a, b) => {
654
+ const aPath = import_path.default.join(dirPath, a);
655
+ const bPath = import_path.default.join(dirPath, b);
656
+ const aIsDir = import_fs.default.statSync(aPath).isDirectory();
657
+ const bIsDir = import_fs.default.statSync(bPath).isDirectory();
658
+ if (aIsDir && !bIsDir) return -1;
659
+ if (!aIsDir && bIsDir) return 1;
660
+ return a.localeCompare(b);
661
+ });
662
+ const folderItems = [];
663
+ const htmlFiles = [];
664
+ files.forEach((file) => {
665
+ const filePath = import_path.default.join(dirPath, file);
666
+ const relativePath = import_path.default.join(baseUrl, file).replace(/\\/g, "/");
667
+ try {
668
+ const stats = import_fs.default.statSync(filePath);
669
+ if (stats.isDirectory()) {
670
+ folderItems.push({ file, filePath, relativePath });
671
+ } else if (import_path.default.extname(file).toLowerCase() === ".html" || import_path.default.extname(file).toLowerCase() === ".htm") {
672
+ htmlFiles.push({ file, relativePath });
673
+ }
674
+ } catch (e) {
675
+ console.error(`Error reading ${filePath}:`, e);
676
+ }
677
+ });
678
+ folderItems.forEach(({ file, filePath, relativePath }) => {
679
+ html += `<div class="folder-item">
680
+ <a class="folder-name">${file}</a>
681
+ </div>`;
682
+ const subTree = buildGalleryTree(filePath, relativePath, depth + 1);
683
+ if (subTree) {
684
+ html += subTree;
685
+ }
686
+ });
687
+ if (htmlFiles.length > 0) {
688
+ html += `<div class="file-grid">`;
689
+ for (let i = 0; i < htmlFiles.length; i += 3) {
690
+ const rowFiles = htmlFiles.slice(i, i + 3);
691
+ html += `<div class="file-row">`;
692
+ rowFiles.forEach(({ file, relativePath }) => {
693
+ html += `<div class="file-column">
694
+ <a href="${relativePath}" class="html-file-link">${file}</a>
695
+ </div>`;
696
+ });
697
+ for (let j = rowFiles.length; j < 3; j++) {
698
+ html += `<div class="file-column empty-column"></div>`;
699
+ }
700
+ html += `</div>`;
701
+ }
702
+ html += `</div>`;
703
+ }
704
+ return html;
705
+ } catch (e) {
706
+ console.error(`Error reading directory ${dirPath}:`, e);
707
+ return "";
708
+ }
709
+ }
710
+ function generateFileList(fullPath, url) {
711
+ try {
712
+ const files = import_fs.default.readdirSync(fullPath);
713
+ let listItems = "";
714
+ const sortedFiles = files.sort((a, b) => {
715
+ const aPath = import_path.default.join(fullPath, a);
716
+ const bPath = import_path.default.join(fullPath, b);
717
+ const aIsDir = import_fs.default.statSync(aPath).isDirectory();
718
+ const bIsDir = import_fs.default.statSync(bPath).isDirectory();
719
+ if (aIsDir && !bIsDir) return -1;
720
+ if (!aIsDir && bIsDir) return 1;
721
+ return a.localeCompare(b);
722
+ });
723
+ if (url !== "/") {
724
+ const backUrl = url.split("/").slice(0, -1).join("/") || "/";
725
+ listItems += `<li><a href="${backUrl}" class="folder-link back-link">..</a></li>
726
+ `;
727
+ }
728
+ sortedFiles.forEach((file) => {
729
+ const filePath = import_path.default.join(fullPath, file);
730
+ const stats = import_fs.default.statSync(filePath);
731
+ const isDir = stats.isDirectory();
732
+ const href = import_path.default.join(url, file).replace(/\\/g, "/");
733
+ if (isDir) {
734
+ listItems += `<li><a href="${href}" class="folder-link">${file}</a></li>
735
+ `;
736
+ } else {
737
+ listItems += `<li><a href="${href}" class="file-link">${file}</a></li>
738
+ `;
739
+ }
740
+ });
741
+ return listItems;
742
+ } catch (e) {
743
+ console.error(`Error generating file list:`, e);
744
+ return "";
745
+ }
746
+ }
747
+ function generateHtmlPage(url, content, isGalleryTree = false) {
748
+ let urlSplitArray = url.split("/").filter(Boolean);
749
+ let breadcrumb = "";
750
+ if (url === "/") {
751
+ breadcrumb = '<a href="/" class="breadcrumb-link">/</a>';
752
+ } else {
753
+ breadcrumb = '<a href="/" class="breadcrumb-link">Home</a> ';
754
+ urlSplitArray.forEach((p, index) => {
755
+ const href = "/" + urlSplitArray.slice(0, index + 1).join("/");
756
+ breadcrumb += `<a href="${href}" class="breadcrumb-link"> / ${p}</a>`;
757
+ if (index < urlSplitArray.length - 1) {
758
+ breadcrumb += " ";
759
+ }
760
+ });
761
+ }
762
+ const pageTitle = url === "/" ? "/" : url;
763
+ const list = isGalleryTree ? `<div class="gallery-tree">${content || '<div class="empty-message">No HTML files found</div>'}</div>` : `
764
+ <ul class="file-list">
765
+ ${content || '<li class="empty-message">No files found</li>'}
766
+ </ul>
767
+ `;
768
+ const html = templateString.replace(/{{pageTitle}}/g, pageTitle).replace(/{{breadcrumb}}/g, breadcrumb).replace(/{{list}}/g, list);
769
+ return html;
770
+ }
771
+ server.middlewares.use((req, res, next) => {
772
+ const url = req.url ? decodeURIComponent(req.url.split("?")[0]) : "/";
773
+ if (url.startsWith("/@") || url.includes("vite")) {
774
+ return next();
775
+ }
776
+ const projectRoot = server.config.root;
777
+ const fullPath = import_path.default.join(projectRoot, url);
778
+ try {
779
+ if (import_fs.default.existsSync(fullPath) && import_fs.default.statSync(fullPath).isDirectory()) {
780
+ if (import_fs.default.existsSync(import_path.default.join(fullPath, "index.html"))) {
781
+ return next();
782
+ }
783
+ let content = "";
784
+ const isGalleryTree = url === "/apps/gallery" || url.startsWith("/gallery/");
785
+ if (isGalleryTree) {
786
+ content = `<p class="back-all-link"><a href="/apps" class="back-link">..</a></p>`;
787
+ content += buildGalleryTree(fullPath, url === "/" ? "" : url);
788
+ } else {
789
+ content = generateFileList(fullPath, url);
790
+ }
791
+ const html = generateHtmlPage(url, content, isGalleryTree);
792
+ res.setHeader("Content-Type", "text/html");
793
+ res.end(html);
794
+ return;
795
+ } else if (!import_fs.default.existsSync(fullPath)) {
796
+ setStatus404(res, url, theme);
797
+ return;
798
+ }
799
+ } catch (e) {
800
+ setStatus500(res, e, theme);
801
+ return;
802
+ }
803
+ next();
804
+ });
805
+ }
806
+ };
807
+ }
808
+ function setStatus404(res, url, theme) {
809
+ res.statusCode = 404;
810
+ res.setHeader("Content-Type", "text/html");
811
+ if (theme === "light") {
812
+ res.end(`
813
+ <!DOCTYPE html>
814
+ <html>
815
+ <head><title>404 Not Found</title></head>
816
+ <body style="background:#f8f9fa;color:#212529;font-family:Consolas;padding:20px;">
817
+ <h1>404 Not Found</h1>
818
+ <p>The requested URL ${url} was not found on this server.</p>
819
+ <p><a href="/" style="color:#0d6efd;">Return to home</a></p>
820
+ </body>
821
+ </html>
822
+ `);
823
+ } else {
824
+ res.end(`
825
+ <!DOCTYPE html>
826
+ <html>
827
+ <head><title>404 Not Found</title></head>
828
+ <body style="background:#000;color:#fff;font-family:Consolas;padding:20px;">
829
+ <h1>404 Not Found</h1>
830
+ <p>The requested URL ${url} was not found on this server.</p>
831
+ <p><a href="/" style="color:#569cd6;">Return to home</a></p>
832
+ </body>
833
+ </html>
834
+ `);
835
+ }
836
+ }
837
+ function setStatus500(res, error, theme) {
838
+ console.error("File Server Plugin Error:", error);
839
+ res.statusCode = 500;
840
+ if (theme === "light") {
841
+ res.end(`
842
+ <!DOCTYPE html>
843
+ <html>
844
+ <head><title>500 Internal Server Error</title></head>
845
+ <body style="background:#f8f9fa;color:#212529;font-family:Consolas;padding:20px;">
846
+ <h1>500 Internal Server Error</h1>
847
+ <p>An error occurred on the server.</p>
848
+ <p><a href="/" style="color:#0d6efd;">Return to home</a></p>
849
+ </body>
850
+ </html>
851
+ `);
852
+ } else {
853
+ res.end("Internal Server Error");
854
+ }
855
+ }