227 lines
4.6 KiB
HTML
227 lines
4.6 KiB
HTML
<!DOCTYPE html>
|
|
<html lang="zh-CN">
|
|
|
|
<head>
|
|
<meta charset="UTF-8" />
|
|
<title>G3 File UI Demo</title>
|
|
|
|
<style>
|
|
body {
|
|
margin: 0;
|
|
background: #f5f6f7;
|
|
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Arial;
|
|
}
|
|
|
|
/* 列表 */
|
|
.g3-file-list {
|
|
width: 600px;
|
|
margin: 40px auto;
|
|
}
|
|
|
|
/* 文件项 */
|
|
.g3-file-item {
|
|
display: flex;
|
|
align-items: center;
|
|
padding: 10px;
|
|
background: #fff;
|
|
border-radius: 8px;
|
|
margin-bottom: 10px;
|
|
border: 1px solid #eee;
|
|
transition: 0.2s;
|
|
}
|
|
|
|
.g3-file-item:hover {
|
|
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
|
|
}
|
|
|
|
/* 缩略图 */
|
|
.g3-file-thumb {
|
|
width: 40px;
|
|
height: 40px;
|
|
margin-right: 10px;
|
|
}
|
|
|
|
.g3-file-thumb img {
|
|
width: 100%;
|
|
height: 100%;
|
|
object-fit: cover;
|
|
border-radius: 6px;
|
|
}
|
|
|
|
/* 信息 */
|
|
.g3-file-info {
|
|
flex: 1;
|
|
min-width: 0;
|
|
}
|
|
|
|
.g3-file-name {
|
|
font-size: 14px;
|
|
color: #333;
|
|
white-space: nowrap;
|
|
overflow: hidden;
|
|
text-overflow: ellipsis;
|
|
}
|
|
|
|
.g3-file-meta {
|
|
display: flex;
|
|
align-items: center;
|
|
gap: 10px;
|
|
margin-top: 4px;
|
|
font-size: 12px;
|
|
color: #999;
|
|
}
|
|
|
|
/* 进度条 */
|
|
.g3-file-progress {
|
|
flex: 1;
|
|
height: 4px;
|
|
background: #eee;
|
|
border-radius: 2px;
|
|
overflow: hidden;
|
|
}
|
|
|
|
.g3-file-progress-bar {
|
|
height: 100%;
|
|
background: #52c41a;
|
|
width: 0%;
|
|
}
|
|
|
|
/* 错误 */
|
|
.g3-file-error {
|
|
color: #ff4d4f;
|
|
}
|
|
|
|
/* 操作 */
|
|
.g3-file-actions {
|
|
display: flex;
|
|
gap: 6px;
|
|
margin-left: 10px;
|
|
opacity: 0;
|
|
}
|
|
|
|
.g3-file-item:hover .g3-file-actions {
|
|
opacity: 1;
|
|
}
|
|
|
|
.g3-btn {
|
|
border: none;
|
|
background: #f0f0f0;
|
|
padding: 4px 8px;
|
|
font-size: 12px;
|
|
border-radius: 4px;
|
|
cursor: pointer;
|
|
}
|
|
|
|
.g3-btn:hover {
|
|
background: #e6e6e6;
|
|
}
|
|
|
|
.g3-btn.danger {
|
|
color: #ff4d4f;
|
|
}
|
|
|
|
/* 状态控制 */
|
|
.is-success .g3-file-progress {
|
|
display: none;
|
|
}
|
|
|
|
.is-error .g3-file-progress {
|
|
display: none;
|
|
}
|
|
|
|
.is-error .g3-file-error {
|
|
display: inline;
|
|
}
|
|
</style>
|
|
</head>
|
|
|
|
<body>
|
|
|
|
<div class="g3-file-list" id="fileList">
|
|
|
|
<!-- 上传中 -->
|
|
<div class="g3-file-item is-uploading">
|
|
<div class="g3-file-thumb">
|
|
<img src="https://via.placeholder.com/40" />
|
|
</div>
|
|
|
|
<div class="g3-file-info">
|
|
<div class="g3-file-name">uploading-file.zip</div>
|
|
<div class="g3-file-meta">
|
|
<span>3.2 MB</span>
|
|
<div class="g3-file-progress">
|
|
<div class="g3-file-progress-bar"></div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="g3-file-actions">
|
|
<button class="g3-btn">查看</button>
|
|
<button class="g3-btn">下载</button>
|
|
<button class="g3-btn danger">删除</button>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- 成功 -->
|
|
<div class="g3-file-item is-success">
|
|
<div class="g3-file-thumb">
|
|
<img src="https://via.placeholder.com/40" />
|
|
</div>
|
|
|
|
<div class="g3-file-info">
|
|
<div class="g3-file-name">finished.pdf</div>
|
|
<div class="g3-file-meta">
|
|
<span>1.1 MB</span>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="g3-file-actions">
|
|
<button class="g3-btn">查看</button>
|
|
<button class="g3-btn">下载</button>
|
|
<button class="g3-btn danger">删除</button>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- 失败 -->
|
|
<div class="g3-file-item is-error">
|
|
<div class="g3-file-thumb">
|
|
<img src="https://via.placeholder.com/40" />
|
|
</div>
|
|
|
|
<div class="g3-file-info">
|
|
<div class="g3-file-name">error-image.png</div>
|
|
<div class="g3-file-meta">
|
|
<span>5.6 MB</span>
|
|
<span class="g3-file-error">上传失败</span>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="g3-file-actions">
|
|
<button class="g3-btn">重试</button>
|
|
<button class="g3-btn danger">删除</button>
|
|
</div>
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<script>
|
|
// 模拟上传进度
|
|
const progressBar = document.querySelector('.is-uploading .g3-file-progress-bar');
|
|
let percent = 0;
|
|
|
|
const timer = setInterval(() => {
|
|
percent += 5;
|
|
progressBar.style.width = percent + '%';
|
|
|
|
if (percent >= 100) {
|
|
clearInterval(timer);
|
|
const item = progressBar.closest('.g3-file-item');
|
|
item.classList.remove('is-uploading');
|
|
item.classList.add('is-success');
|
|
}
|
|
}, 300);
|
|
</script>
|
|
|
|
</body>
|
|
|
|
</html> |