Skip to content

Commit c184aa4

Browse files
committed
feat(preview): 更好的预览体验
1 parent e38960c commit c184aa4

4 files changed

Lines changed: 143 additions & 8 deletions

File tree

js/src/main.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,14 @@ function loadScript(src: string): Promise<void> {
2727
});
2828
}
2929

30+
function hidePageLoader() {
31+
const loader = document.getElementById('page-loader');
32+
if (loader) {
33+
loader.classList.add('hidden');
34+
setTimeout(() => loader.remove(), 300);
35+
}
36+
}
37+
3038
const initTerminal = (authToken: string = '') => {
3139
const elem = document.getElementById("terminal");
3240

@@ -88,6 +96,7 @@ if (shareMatch) {
8896
h(SharePage, { token: shareToken, basePath }),
8997
shareContainer
9098
);
99+
hidePageLoader();
91100
} else {
92101
// Normal page: load config scripts then initialize
93102
Promise.all([loadScript('./auth_token.js'), loadScript('./config.js')]).then(() => {
@@ -98,6 +107,7 @@ if (shareMatch) {
98107
const loginContainer = document.createElement("div");
99108
loginContainer.id = "login-container";
100109
document.body.appendChild(loginContainer);
110+
hidePageLoader();
101111

102112
render(
103113
h(Login, {
@@ -113,19 +123,24 @@ if (shareMatch) {
113123
} else {
114124
initTerminal(storedAuth || '');
115125
initFileManager();
126+
hidePageLoader();
116127
}
117128
}).catch((err) => {
118129
console.error('Failed to load config scripts:', err);
119130
// Fallback: try to initialize anyway
120131
initTerminal('');
121132
initFileManager();
133+
hidePageLoader();
122134
});
123135
}
124136

125137
function initFileManager() {
126138
const fileManagerBtn = document.getElementById("file-manager-btn") as HTMLElement | null;
127139
if (!fileManagerBtn) return;
128140

141+
// Show the button now that initialization is complete
142+
fileManagerBtn.classList.add('ready');
143+
129144
let fileManagerContainer: HTMLDivElement | null = null;
130145

131146
// Draggable functionality

resources/filemanager.css

Lines changed: 82 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -371,12 +371,18 @@
371371
font-size: 14px;
372372
z-index: 1000;
373373
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
374-
transition: transform 0.2s, box-shadow 0.2s, background 0.2s;
375-
display: flex;
374+
transition: transform 0.2s, box-shadow 0.2s, background 0.2s, opacity 0.3s;
375+
display: none;
376376
align-items: center;
377377
justify-content: center;
378378
user-select: none;
379379
touch-action: none;
380+
opacity: 0;
381+
}
382+
383+
.file-manager-btn.ready {
384+
display: flex;
385+
opacity: 1;
380386
}
381387

382388
.file-manager-btn:hover {
@@ -2608,4 +2614,78 @@ input[type="checkbox"] {
26082614
overflow: hidden;
26092615
text-overflow: ellipsis;
26102616
white-space: nowrap;
2617+
}
2618+
2619+
/* Mobile responsive */
2620+
@media (max-width: 768px) {
2621+
.share-page {
2622+
padding: 16px;
2623+
}
2624+
2625+
.share-page-header {
2626+
flex-direction: column;
2627+
align-items: flex-start;
2628+
gap: 12px;
2629+
}
2630+
2631+
.share-page-header h1 {
2632+
font-size: 16px;
2633+
word-break: break-all;
2634+
}
2635+
2636+
.share-page-header-right {
2637+
flex-wrap: wrap;
2638+
gap: 8px;
2639+
width: 100%;
2640+
}
2641+
2642+
.share-expires-info {
2643+
font-size: 12px;
2644+
}
2645+
2646+
.share-download-btn {
2647+
padding: 8px 14px;
2648+
font-size: 13px;
2649+
}
2650+
2651+
.file-manager {
2652+
width: 98%;
2653+
max-height: 90vh;
2654+
border-radius: 6px;
2655+
}
2656+
2657+
.breadcrumb {
2658+
flex-wrap: wrap;
2659+
gap: 6px;
2660+
}
2661+
2662+
.search-box {
2663+
min-width: 120px;
2664+
max-width: none;
2665+
flex: 1;
2666+
}
2667+
2668+
.upload-section {
2669+
flex-wrap: wrap;
2670+
gap: 6px;
2671+
}
2672+
2673+
.upload-btn,
2674+
.refresh-btn,
2675+
.batch-download-btn,
2676+
.batch-delete-btn,
2677+
.share-manage-btn {
2678+
padding: 6px 10px;
2679+
font-size: 12px;
2680+
}
2681+
2682+
.file-manager-body {
2683+
padding: 12px;
2684+
}
2685+
2686+
.share-page-files table th,
2687+
.share-page-files table td {
2688+
padding: 8px 6px;
2689+
font-size: 12px;
2690+
}
26112691
}

resources/index.css

Lines changed: 43 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,46 @@
1-
html, body, #terminal {
2-
background: black;
3-
height: 100%;
4-
width: 100%;
5-
padding: 0%;
6-
margin: 0%;
1+
html,
2+
body,
3+
#terminal {
4+
background: black;
5+
height: 100%;
6+
width: 100%;
7+
padding: 0%;
8+
margin: 0%;
9+
}
10+
11+
/* Page loader */
12+
.page-loader {
13+
position: fixed;
14+
top: 0;
15+
left: 0;
16+
width: 100%;
17+
height: 100%;
18+
display: flex;
19+
align-items: center;
20+
justify-content: center;
21+
background: #000;
22+
z-index: 10000;
23+
transition: opacity 0.3s;
24+
}
25+
26+
.page-loader.hidden {
27+
opacity: 0;
28+
pointer-events: none;
29+
}
30+
31+
.page-loader-spinner {
32+
width: 36px;
33+
height: 36px;
34+
border: 3px solid #333;
35+
border-top-color: #888;
36+
border-radius: 50%;
37+
animation: page-spin 0.8s linear infinite;
38+
}
39+
40+
@keyframes page-spin {
41+
to {
42+
transform: rotate(360deg);
43+
}
744
}
845

946
.progress .progress-bar {

resources/index.html

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@
1616
</head>
1717

1818
<body>
19+
<div id="page-loader" class="page-loader">
20+
<div class="page-loader-spinner"></div>
21+
</div>
1922
<button id="file-manager-btn" class="file-manager-btn" title="文件管理">
2023
<svg class="file-manager-icon" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg">
2124
<path

0 commit comments

Comments
 (0)