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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<!DOCTYPE html>
|
| 2 |
+
<html lang="zh-CN">
|
| 3 |
+
<head>
|
| 4 |
+
<meta charset="UTF-8">
|
| 5 |
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
| 6 |
+
<title>HTML文件管理器</title>
|
| 7 |
+
<script src="https://unpkg.com/vue@3/dist/vue.global.js"></script>
|
| 8 |
+
<script src="https://unpkg.com/axios/dist/axios.min.js"></script>
|
| 9 |
+
<style>
|
| 10 |
+
* {
|
| 11 |
+
margin: 0;
|
| 12 |
+
padding: 0;
|
| 13 |
+
box-sizing: border-box;
|
| 14 |
+
}
|
| 15 |
+
|
| 16 |
+
body {
|
| 17 |
+
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', sans-serif;
|
| 18 |
+
background-color: #f5f5f5;
|
| 19 |
+
color: #333;
|
| 20 |
+
line-height: 1.6;
|
| 21 |
+
}
|
| 22 |
+
|
| 23 |
+
.container {
|
| 24 |
+
max-width: 1200px;
|
| 25 |
+
margin: 0 auto;
|
| 26 |
+
padding: 20px;
|
| 27 |
+
}
|
| 28 |
+
|
| 29 |
+
.header {
|
| 30 |
+
background: white;
|
| 31 |
+
padding: 20px;
|
| 32 |
+
border-radius: 8px;
|
| 33 |
+
box-shadow: 0 2px 4px rgba(0,0,0,0.1);
|
| 34 |
+
margin-bottom: 20px;
|
| 35 |
+
}
|
| 36 |
+
|
| 37 |
+
.header h1 {
|
| 38 |
+
color: #2c3e50;
|
| 39 |
+
margin-bottom: 10px;
|
| 40 |
+
}
|
| 41 |
+
|
| 42 |
+
.header p {
|
| 43 |
+
color: #7f8c8d;
|
| 44 |
+
}
|
| 45 |
+
|
| 46 |
+
.toolbar {
|
| 47 |
+
background: white;
|
| 48 |
+
padding: 15px;
|
| 49 |
+
border-radius: 8px;
|
| 50 |
+
box-shadow: 0 2px 4px rgba(0,0,0,0.1);
|
| 51 |
+
margin-bottom: 20px;
|
| 52 |
+
display: flex;
|
| 53 |
+
justify-content: space-between;
|
| 54 |
+
align-items: center;
|
| 55 |
+
}
|
| 56 |
+
|
| 57 |
+
.btn {
|
| 58 |
+
background: #3498db;
|
| 59 |
+
color: white;
|
| 60 |
+
border: none;
|
| 61 |
+
padding: 8px 16px;
|
| 62 |
+
border-radius: 4px;
|
| 63 |
+
cursor: pointer;
|
| 64 |
+
font-size: 14px;
|
| 65 |
+
transition: background-color 0.3s;
|
| 66 |
+
}
|
| 67 |
+
|
| 68 |
+
.btn:hover {
|
| 69 |
+
background: #2980b9;
|
| 70 |
+
}
|
| 71 |
+
|
| 72 |
+
.btn-danger {
|
| 73 |
+
background: #e74c3c;
|
| 74 |
+
}
|
| 75 |
+
|
| 76 |
+
.btn-danger:hover {
|
| 77 |
+
background: #c0392b;
|
| 78 |
+
}
|
| 79 |
+
|
| 80 |
+
.btn-success {
|
| 81 |
+
background: #27ae60;
|
| 82 |
+
}
|
| 83 |
+
|
| 84 |
+
.btn-success:hover {
|
| 85 |
+
background: #229954;
|
| 86 |
+
}
|
| 87 |
+
|
| 88 |
+
.file-list {
|
| 89 |
+
background: white;
|
| 90 |
+
border-radius: 8px;
|
| 91 |
+
box-shadow: 0 2px 4px rgba(0,0,0,0.1);
|
| 92 |
+
overflow: hidden;
|
| 93 |
+
}
|
| 94 |
+
|
| 95 |
+
.file-item {
|
| 96 |
+
padding: 15px;
|
| 97 |
+
border-bottom: 1px solid #ecf0f1;
|
| 98 |
+
display: flex;
|
| 99 |
+
justify-content: space-between;
|
| 100 |
+
align-items: center;
|
| 101 |
+
transition: background-color 0.3s;
|
| 102 |
+
}
|
| 103 |
+
|
| 104 |
+
.file-item:hover {
|
| 105 |
+
background-color: #f8f9fa;
|
| 106 |
+
}
|
| 107 |
+
|
| 108 |
+
.file-item:last-child {
|
| 109 |
+
border-bottom: none;
|
| 110 |
+
}
|
| 111 |
+
|
| 112 |
+
.file-info {
|
| 113 |
+
flex: 1;
|
| 114 |
+
}
|
| 115 |
+
|
| 116 |
+
.file-title {
|
| 117 |
+
font-weight: bold;
|
| 118 |
+
color: #2c3e50;
|
| 119 |
+
margin-bottom: 5px;
|
| 120 |
+
}
|
| 121 |
+
|
| 122 |
+
.file-meta {
|
| 123 |
+
font-size: 12px;
|
| 124 |
+
color: #7f8c8d;
|
| 125 |
+
}
|
| 126 |
+
|
| 127 |
+
.file-actions {
|
| 128 |
+
display: flex;
|
| 129 |
+
gap: 10px;
|
| 130 |
+
}
|
| 131 |
+
|
| 132 |
+
.loading {
|
| 133 |
+
text-align: center;
|
| 134 |
+
padding: 40px;
|
| 135 |
+
color: #7f8c8d;
|
| 136 |
+
}
|
| 137 |
+
|
| 138 |
+
.empty {
|
| 139 |
+
text-align: center;
|
| 140 |
+
padding: 40px;
|
| 141 |
+
color: #7f8c8d;
|
| 142 |
+
}
|
| 143 |
+
|
| 144 |
+
.modal {
|
| 145 |
+
display: none;
|
| 146 |
+
position: fixed;
|
| 147 |
+
z-index: 1000;
|
| 148 |
+
left: 0;
|
| 149 |
+
top: 0;
|
| 150 |
+
width: 100%;
|
| 151 |
+
height: 100%;
|
| 152 |
+
background-color: rgba(0,0,0,0.5);
|
| 153 |
+
}
|
| 154 |
+
|
| 155 |
+
.modal.show {
|
| 156 |
+
display: flex;
|
| 157 |
+
justify-content: center;
|
| 158 |
+
align-items: center;
|
| 159 |
+
}
|
| 160 |
+
|
| 161 |
+
.modal-content {
|
| 162 |
+
background-color: white;
|
| 163 |
+
padding: 20px;
|
| 164 |
+
border-radius: 8px;
|
| 165 |
+
width: 90%;
|
| 166 |
+
max-width: 800px;
|
| 167 |
+
max-height: 80vh;
|
| 168 |
+
overflow: auto;
|
| 169 |
+
}
|
| 170 |
+
|
| 171 |
+
.modal-header {
|
| 172 |
+
display: flex;
|
| 173 |
+
justify-content: space-between;
|
| 174 |
+
align-items: center;
|
| 175 |
+
margin-bottom: 15px;
|
| 176 |
+
}
|
| 177 |
+
|
| 178 |
+
.close {
|
| 179 |
+
font-size: 28px;
|
| 180 |
+
font-weight: bold;
|
| 181 |
+
cursor: pointer;
|
| 182 |
+
color: #aaa;
|
| 183 |
+
}
|
| 184 |
+
|
| 185 |
+
.close:hover {
|
| 186 |
+
color: #000;
|
| 187 |
+
}
|
| 188 |
+
|
| 189 |
+
.preview-frame {
|
| 190 |
+
width: 100%;
|
| 191 |
+
height: 400px;
|
| 192 |
+
border: 1px solid #ddd;
|
| 193 |
+
border-radius: 4px;
|
| 194 |
+
}
|
| 195 |
+
|
| 196 |
+
.stats {
|
| 197 |
+
display: flex;
|
| 198 |
+
gap: 20px;
|
| 199 |
+
margin-bottom: 15px;
|
| 200 |
+
}
|
| 201 |
+
|
| 202 |
+
.stat-item {
|
| 203 |
+
background: #ecf0f1;
|
| 204 |
+
padding: 10px 15px;
|
| 205 |
+
border-radius: 4px;
|
| 206 |
+
text-align: center;
|
| 207 |
+
}
|
| 208 |
+
|
| 209 |
+
.stat-value {
|
| 210 |
+
font-size: 24px;
|
| 211 |
+
font-weight: bold;
|
| 212 |
+
color: #2c3e50;
|
| 213 |
+
}
|
| 214 |
+
|
| 215 |
+
.stat-label {
|
| 216 |
+
font-size: 12px;
|
| 217 |
+
color: #7f8c8d;
|
| 218 |
+
}
|
| 219 |
+
</style>
|
| 220 |
+
</head>
|
| 221 |
+
<body>
|
| 222 |
+
<div id="app">
|
| 223 |
+
<div class="container">
|
| 224 |
+
<div class="header">
|
| 225 |
+
<h1>HTML文件管理器</h1>
|
| 226 |
+
<p>管理和预览已上传的HTML文件</p>
|
| 227 |
+
</div>
|
| 228 |
+
|
| 229 |
+
<div class="toolbar">
|
| 230 |
+
<div class="stats">
|
| 231 |
+
<div class="stat-item">
|
| 232 |
+
<div class="stat-value">{{ files.length }}</div>
|
| 233 |
+
<div class="stat-label">文件总数</div>
|
| 234 |
+
</div>
|
| 235 |
+
</div>
|
| 236 |
+
<button class="btn" @click="refreshFiles">刷新列表</button>
|
| 237 |
+
</div>
|
| 238 |
+
|
| 239 |
+
<div class="file-list">
|
| 240 |
+
<div v-if="loading" class="loading">
|
| 241 |
+
加载中...
|
| 242 |
+
</div>
|
| 243 |
+
|
| 244 |
+
<div v-else-if="files.length === 0" class="empty">
|
| 245 |
+
暂无HTML文件
|
| 246 |
+
</div>
|
| 247 |
+
|
| 248 |
+
<div v-else>
|
| 249 |
+
<div v-for="file in files" :key="file.filename" class="file-item">
|
| 250 |
+
<div class="file-info">
|
| 251 |
+
<div class="file-title">
|
| 252 |
+
{{ file.title || file.filename }}
|
| 253 |
+
</div>
|
| 254 |
+
<div class="file-meta">
|
| 255 |
+
文件名: {{ file.filename }} | 创建时间: {{ file.created_time }}
|
| 256 |
+
</div>
|
| 257 |
+
</div>
|
| 258 |
+
<div class="file-actions">
|
| 259 |
+
<button class="btn btn-success" @click="previewFile(file)">预览</button>
|
| 260 |
+
<button class="btn" @click="openFile(file)">打开</button>
|
| 261 |
+
<button class="btn btn-danger" @click="deleteFile(file)">删除</button>
|
| 262 |
+
</div>
|
| 263 |
+
</div>
|
| 264 |
+
</div>
|
| 265 |
+
</div>
|
| 266 |
+
</div>
|
| 267 |
+
|
| 268 |
+
<!-- 预览模态框 -->
|
| 269 |
+
<div class="modal" :class="{ show: showPreview }" @click="closePreview">
|
| 270 |
+
<div class="modal-content" @click.stop>
|
| 271 |
+
<div class="modal-header">
|
| 272 |
+
<h3>{{ currentFile?.title || currentFile?.filename || '预览' }}</h3>
|
| 273 |
+
<span class="close" @click="closePreview">×</span>
|
| 274 |
+
</div>
|
| 275 |
+
<iframe v-if="currentFile" :src="currentFile.url" class="preview-frame"></iframe>
|
| 276 |
+
</div>
|
| 277 |
+
</div>
|
| 278 |
+
</div>
|
| 279 |
+
|
| 280 |
+
<script>
|
| 281 |
+
const { createApp } = Vue;
|
| 282 |
+
|
| 283 |
+
createApp({
|
| 284 |
+
data() {
|
| 285 |
+
return {
|
| 286 |
+
files: [],
|
| 287 |
+
loading: false,
|
| 288 |
+
showPreview: false,
|
| 289 |
+
currentFile: null
|
| 290 |
+
};
|
| 291 |
+
},
|
| 292 |
+
methods: {
|
| 293 |
+
async loadFiles() {
|
| 294 |
+
this.loading = true;
|
| 295 |
+
try {
|
| 296 |
+
const response = await axios.get('/api/files');
|
| 297 |
+
this.files = response.data.files;
|
| 298 |
+
} catch (error) {
|
| 299 |
+
console.error('加载文件列表失败:', error);
|
| 300 |
+
alert('加载文件列表失败');
|
| 301 |
+
} finally {
|
| 302 |
+
this.loading = false;
|
| 303 |
+
}
|
| 304 |
+
},
|
| 305 |
+
|
| 306 |
+
refreshFiles() {
|
| 307 |
+
this.loadFiles();
|
| 308 |
+
},
|
| 309 |
+
|
| 310 |
+
previewFile(file) {
|
| 311 |
+
this.currentFile = file;
|
| 312 |
+
this.showPreview = true;
|
| 313 |
+
},
|
| 314 |
+
|
| 315 |
+
closePreview() {
|
| 316 |
+
this.showPreview = false;
|
| 317 |
+
this.currentFile = null;
|
| 318 |
+
},
|
| 319 |
+
|
| 320 |
+
openFile(file) {
|
| 321 |
+
window.open(file.url, '_blank');
|
| 322 |
+
},
|
| 323 |
+
|
| 324 |
+
async deleteFile(file) {
|
| 325 |
+
if (!confirm(`确定要删除文件 "${file.title || file.filename}" 吗?`)) {
|
| 326 |
+
return;
|
| 327 |
+
}
|
| 328 |
+
|
| 329 |
+
try {
|
| 330 |
+
await axios.delete(`/api/files/${file.filename}`);
|
| 331 |
+
alert('文件删除成功');
|
| 332 |
+
this.loadFiles();
|
| 333 |
+
} catch (error) {
|
| 334 |
+
console.error('删除文件失败:', error);
|
| 335 |
+
alert('删除文件失败: ' + (error.response?.data?.detail || error.message));
|
| 336 |
+
}
|
| 337 |
+
}
|
| 338 |
+
},
|
| 339 |
+
|
| 340 |
+
mounted() {
|
| 341 |
+
this.loadFiles();
|
| 342 |
+
}
|
| 343 |
+
}).mount('#app');
|
| 344 |
+
</script>
|
| 345 |
+
</body>
|
| 346 |
+
</html>
|