mirror of
https://github.com/fish2018/GoComicMosaic.git
synced 2025-11-25 11:29:33 +08:00
udpate
This commit is contained in:
@@ -75,6 +75,7 @@
|
||||

|
||||
|
||||
## 新增分页
|
||||

|
||||
|
||||
---
|
||||
|
||||
|
||||
BIN
docs/21.jpg
Normal file
BIN
docs/21.jpg
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 164 KiB |
@@ -1290,18 +1290,30 @@ onMounted(async () => {
|
||||
.table-container {
|
||||
width: 100%;
|
||||
overflow-x: auto;
|
||||
overflow-y: auto; /* 添加垂直滚动功能 */
|
||||
max-height: 600px; /* 设置最大高度以触发滚动条 */
|
||||
border-radius: var(--border-radius);
|
||||
background: rgba(255, 255, 255, 0.5);
|
||||
padding: 0;
|
||||
position: relative;
|
||||
}
|
||||
|
||||
/* 固定表头样式 */
|
||||
.custom-table {
|
||||
display: table;
|
||||
min-width: 800px;
|
||||
width: 100%;
|
||||
white-space: nowrap;
|
||||
table-layout: fixed;
|
||||
border-collapse: separate; /* 设置为separate以支持固定表头 */
|
||||
border-spacing: 0; /* 移除边框间距 */
|
||||
}
|
||||
|
||||
.custom-table thead {
|
||||
position: sticky; /* 设置表头为粘性定位 */
|
||||
top: 0; /* 固定在容器顶部 */
|
||||
z-index: 1; /* 确保表头在内容上层 */
|
||||
background: rgba(255, 255, 255, 0.95); /* 确保表头背景不透明 */
|
||||
}
|
||||
|
||||
.custom-table th {
|
||||
@@ -1311,6 +1323,9 @@ onMounted(async () => {
|
||||
padding: 1rem;
|
||||
text-align: left;
|
||||
border-bottom: 1px solid rgba(99, 102, 241, 0.1);
|
||||
position: sticky; /* 确保每个th元素也保持粘性定位 */
|
||||
top: 0; /* 固定在容器顶部 */
|
||||
z-index: 2; /* 确保高于tbody内容 */
|
||||
}
|
||||
|
||||
.custom-table td {
|
||||
|
||||
@@ -504,6 +504,7 @@ const editLinks = reactive({
|
||||
"pikpak": [],
|
||||
"baidu": [],
|
||||
"123": [],
|
||||
"xunlei": [],
|
||||
"online": [],
|
||||
"others": []
|
||||
})
|
||||
@@ -865,6 +866,7 @@ const categoryDisplayNames = {
|
||||
"pikpak": "PikPak",
|
||||
"baidu": "百度网盘",
|
||||
"123": "123网盘",
|
||||
"xunlei": "迅雷网盘",
|
||||
"online": "在线观看",
|
||||
"others": "其他链接"
|
||||
}
|
||||
|
||||
@@ -433,7 +433,7 @@ const categoryDisplayNames = {
|
||||
"pikpak": "PikPak",
|
||||
"baidu": "百度网盘",
|
||||
"123": "123网盘",
|
||||
"xunlei": "迅雷",
|
||||
"xunlei": "迅雷网盘",
|
||||
"online": "在线观看",
|
||||
"others": "其他链接"
|
||||
}
|
||||
@@ -1014,8 +1014,22 @@ const selectAllLinks = () => {
|
||||
selectedLinks.value = [];
|
||||
|
||||
// 遍历所有分类和链接
|
||||
if (resource.value && resource.value.links) {
|
||||
Object.keys(resource.value.links).forEach(category => {
|
||||
if (isSupplementResource.value) {
|
||||
// 仅选择补充链接,避免选择已存在的只读链接
|
||||
Object.keys(supplementLinks.value || {}).forEach(category => {
|
||||
const categoryLinks = supplementLinks.value[category];
|
||||
if (Array.isArray(categoryLinks)) {
|
||||
categoryLinks.forEach((_, index) => {
|
||||
// 只选择未审核的链接(既不是已批准也不是已拒绝的)
|
||||
if (getLinkApprovalStatus(category, index) === 'pending') {
|
||||
selectedLinks.value.push({ category, index });
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
} else {
|
||||
// 对于新资源审核,选择所有链接
|
||||
Object.keys(resource.value?.links || {}).forEach(category => {
|
||||
const categoryLinks = resource.value.links[category];
|
||||
if (Array.isArray(categoryLinks)) {
|
||||
categoryLinks.forEach((_, index) => {
|
||||
@@ -1732,16 +1746,29 @@ const closeLargeImage = () => {
|
||||
|
||||
// 获取链接审批状态
|
||||
const getLinkApprovalStatus = (category, index) => {
|
||||
// 对于补充资源审核,确保我们只考虑补充链接的状态
|
||||
if (isSupplementResource.value) {
|
||||
// 确认该链接是补充链接而不是原始链接
|
||||
const isSupplementLink = supplementLinks.value &&
|
||||
supplementLinks.value[category] &&
|
||||
index < supplementLinks.value[category].length;
|
||||
|
||||
if (!isSupplementLink) {
|
||||
// 如果不是补充链接(是原始链接),则返回"已批准"状态,表示不需要审核
|
||||
return 'approved';
|
||||
}
|
||||
}
|
||||
|
||||
// 检查是否已批准
|
||||
if (approvedLinks.value.some(l => l.category === category && l.index === index)) {
|
||||
return 'approved'
|
||||
return 'approved';
|
||||
}
|
||||
// 检查是否已拒绝
|
||||
if (rejectedLinks.value.some(l => l.category === category && l.index === index)) {
|
||||
return 'rejected'
|
||||
return 'rejected';
|
||||
}
|
||||
// 默认为待审核
|
||||
return 'pending'
|
||||
return 'pending';
|
||||
}
|
||||
|
||||
// 切换链接批准状态
|
||||
|
||||
@@ -683,6 +683,7 @@ const resourceLinks = reactive({
|
||||
"pikpak": [],
|
||||
"baidu": [],
|
||||
"123": [],
|
||||
"xunlei": [],
|
||||
"online": [],
|
||||
"others": []
|
||||
})
|
||||
@@ -700,6 +701,7 @@ const categoryDisplayNames = {
|
||||
"pikpak": "PikPak",
|
||||
"baidu": "百度网盘",
|
||||
"123": "123网盘",
|
||||
"xunlei": "迅雷网盘",
|
||||
"online": "在线观看",
|
||||
"others": "其他链接"
|
||||
}
|
||||
|
||||
@@ -364,12 +364,50 @@ func approveResourceSupplement(c *gin.Context, resourceID int, resource models.R
|
||||
}
|
||||
|
||||
// 转换链接审批信息
|
||||
// if len(approval.ApprovedLinks) > 0 {
|
||||
// linksMap := make(map[string]interface{})
|
||||
// for i, link := range approval.ApprovedLinks {
|
||||
// linksMap[fmt.Sprintf("link_%d", i)] = link
|
||||
// }
|
||||
// approvalRecord.ApprovedLinks = linksMap
|
||||
// }
|
||||
// 处理批准的链接,将它们追加到原始资源的Links字段中
|
||||
if len(approval.ApprovedLinks) > 0 {
|
||||
linksMap := make(map[string]interface{})
|
||||
for i, link := range approval.ApprovedLinks {
|
||||
linksMap[fmt.Sprintf("link_%d", i)] = link
|
||||
log.Printf("[DEBUG] 处理批准的链接,资源ID: %d, 链接数量: %d", resourceID, len(approval.ApprovedLinks))
|
||||
|
||||
// 如果原始资源的Links字段为空,则初始化
|
||||
if resource.Links == nil {
|
||||
resource.Links = models.JsonMap{}
|
||||
}
|
||||
approvalRecord.ApprovedLinks = linksMap
|
||||
|
||||
// 先按category分组链接
|
||||
linksByCategory := make(map[string][]map[string]interface{})
|
||||
// 遍历批准的链接,按category分组
|
||||
for _, link := range approval.ApprovedLinks {
|
||||
// 使用category作为键,将链接添加到对应分组
|
||||
if category, ok := link["category"].(string); ok && category != "" {
|
||||
// 创建不包含category字段的新map
|
||||
linkData := make(map[string]interface{})
|
||||
for k, v := range link {
|
||||
if k != "category" {
|
||||
linkData[k] = v
|
||||
}
|
||||
}
|
||||
|
||||
linksByCategory[category] = append(linksByCategory[category], linkData)
|
||||
} else {
|
||||
// 如果没有有效的category,使用"unknown"作为键
|
||||
linksByCategory["other"] = append(linksByCategory["other"], link)
|
||||
}
|
||||
}
|
||||
|
||||
log.Printf("[DEBUG] 分组后的链接: %v", linksByCategory)
|
||||
// 赋值给 approvalRecord.ApprovedLinks
|
||||
jsonMap := make(map[string]interface{})
|
||||
for k, v := range linksByCategory {
|
||||
jsonMap[k] = v // []map[string]interface{} 可作为 interface{}
|
||||
}
|
||||
approvalRecord.ApprovedLinks = models.JsonMap(jsonMap)
|
||||
}
|
||||
|
||||
if len(approval.RejectedLinks) > 0 {
|
||||
@@ -735,7 +773,103 @@ func SupplementResource(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
|
||||
// 创建补充内容
|
||||
// 检查是否已有待审批的补充内容
|
||||
if resource.Supplement != nil {
|
||||
// 尝试获取现有补充内容的状态
|
||||
if status, ok := resource.Supplement["status"]; ok {
|
||||
if statusStr, ok := status.(string); ok && statusStr == string(models.ResourceStatusPending) {
|
||||
// 有待审批的补充内容,需要合并而不是覆盖
|
||||
log.Printf("资源 %d 已有待审批的补充内容,将进行合并", resourceID)
|
||||
|
||||
// 合并图片列表
|
||||
existingImages := []string{}
|
||||
if imgs, ok := resource.Supplement["images"]; ok {
|
||||
if imgList, ok := imgs.([]interface{}); ok {
|
||||
for _, img := range imgList {
|
||||
if imgStr, ok := img.(string); ok {
|
||||
existingImages = append(existingImages, imgStr)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 将新图片追加到现有图片列表中
|
||||
mergedImages := append(existingImages, supplement.Images...)
|
||||
|
||||
// 处理链接 - 合并现有链接和新链接
|
||||
existingLinks := make(map[string][]interface{})
|
||||
if links, ok := resource.Supplement["links"]; ok {
|
||||
if linksMap, ok := links.(map[string]interface{}); ok {
|
||||
for category, categoryLinks := range linksMap {
|
||||
if catLinks, ok := categoryLinks.([]interface{}); ok {
|
||||
existingLinks[category] = catLinks
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 将新链接合并到现有链接中
|
||||
mergedLinks := make(map[string]interface{})
|
||||
for category, links := range existingLinks {
|
||||
mergedLinks[category] = links
|
||||
}
|
||||
|
||||
// 合并新提交的链接
|
||||
for category, categoryLinks := range supplement.Links {
|
||||
if existingCatLinks, ok := mergedLinks[category]; ok {
|
||||
// 已有该分类的链接,追加
|
||||
if existingArr, ok := existingCatLinks.([]interface{}); ok {
|
||||
// 根据categoryLinks的类型进行不同处理
|
||||
if newLinksArray, ok := categoryLinks.([]interface{}); ok {
|
||||
// 如果已经是[]interface{}类型,直接追加
|
||||
mergedLinks[category] = append(existingArr, newLinksArray...)
|
||||
} else if newLinksArray, ok := categoryLinks.([]map[string]interface{}); ok {
|
||||
// 如果是[]map[string]interface{}类型,转换后追加
|
||||
for _, link := range newLinksArray {
|
||||
existingArr = append(existingArr, link)
|
||||
}
|
||||
mergedLinks[category] = existingArr
|
||||
} else {
|
||||
// 单个链接对象,直接追加
|
||||
mergedLinks[category] = append(existingArr, categoryLinks)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// 没有该分类的链接,直接添加
|
||||
mergedLinks[category] = categoryLinks
|
||||
}
|
||||
}
|
||||
|
||||
// 更新合并后的补充内容
|
||||
supplementData := models.JsonMap{
|
||||
"images": mergedImages,
|
||||
"links": mergedLinks,
|
||||
"status": string(models.ResourceStatusPending),
|
||||
"submission_date": time.Now().Format(time.RFC3339),
|
||||
}
|
||||
|
||||
// 更新资源,添加补充内容
|
||||
_, err = models.DB.Exec(
|
||||
`UPDATE resources SET supplement = ?, is_supplement_approval = ?, updated_at = ? WHERE id = ?`,
|
||||
supplementData, false, time.Now(), resourceID,
|
||||
)
|
||||
|
||||
if err != nil {
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"error": fmt.Sprintf("添加补充内容失败: %v", err)})
|
||||
return
|
||||
}
|
||||
|
||||
// 更新内存中的资源对象
|
||||
resource.Supplement = supplementData
|
||||
resource.UpdatedAt = time.Now()
|
||||
|
||||
c.JSON(http.StatusOK, resource)
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 没有待审批的补充内容,直接创建新的
|
||||
supplementData := models.JsonMap{
|
||||
"images": supplement.Images,
|
||||
"links": supplement.Links,
|
||||
|
||||
Reference in New Issue
Block a user