From 55104d5aefce48937a7746bbe6139352cddcccde Mon Sep 17 00:00:00 2001 From: zerosaturation Date: Tue, 21 Apr 2026 15:18:55 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E6=94=B9=E6=A8=A1=E6=8B=9F?= =?UTF-8?q?=E6=95=B0=E6=8D=AE=E8=B7=AF=E5=BE=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/gateway/config/config.go | 3 + .../gateway/controller/asset_controller.go | 2 +- backend/gateway/dto/asset_converter.go | 1 + backend/gateway/dto/asset_dto.go | 1 + backend/pkg/proto/asset/asset.pb.go | 21 +++-- backend/proto/asset.proto | 1 + .../repository/asset_repository.go | 21 +++++ frontend/pages/components/CastloveContent.vue | 85 +++++++++---------- frontend/pages/components/FriendsContent.vue | 2 +- frontend/pages/friends/index.vue | 2 +- 10 files changed, 83 insertions(+), 56 deletions(-) diff --git a/backend/gateway/config/config.go b/backend/gateway/config/config.go index 1ce8819..0a015fd 100644 --- a/backend/gateway/config/config.go +++ b/backend/gateway/config/config.go @@ -12,6 +12,7 @@ type Config struct { Dubbo DubboConfig JWT JWTConfig OSS OSSConfig + Root string } // ServerConfig 服务器配置 @@ -62,7 +63,9 @@ func (c *OSSConfig) GetUploadDir(uploadType string) string { // Load 加载配置 func Load() *Config { + root, _ := os.Getwd() return &Config{ + Root: root, Server: ServerConfig{ Port: getEnv("SERVER_PORT", "8080"), Mode: getEnv("GIN_MODE", "debug"), diff --git a/backend/gateway/controller/asset_controller.go b/backend/gateway/controller/asset_controller.go index ae9b7b8..51349a4 100644 --- a/backend/gateway/controller/asset_controller.go +++ b/backend/gateway/controller/asset_controller.go @@ -1431,7 +1431,7 @@ func (ctrl *AssetController) ImageGeneration(c *gin.Context) { // 开发模式下使用 mock 数据 if config.Load().Server.Mode == "debug" { - mockData, err := os.ReadFile(filepath.Join("..", "..", "mock", "minimax.json")) + mockData, err := os.ReadFile(filepath.Join(config.Load().Root, "..", "mock", "minimax.json")) if err != nil { response.Error(c, 500, "Failed to read mock data: "+err.Error()) return diff --git a/backend/gateway/dto/asset_converter.go b/backend/gateway/dto/asset_converter.go index 27d5072..01dd5c4 100644 --- a/backend/gateway/dto/asset_converter.go +++ b/backend/gateway/dto/asset_converter.go @@ -84,6 +84,7 @@ func ConvertAsset(pbAsset *pbAsset.Asset) AssetDTO { UpdatedAt: pbAsset.UpdatedAt, IsLiked: pbAsset.IsLiked, Info: pbAsset.Info, + DisplayStatus: pbAsset.DisplayStatus, } // 可选字段 diff --git a/backend/gateway/dto/asset_dto.go b/backend/gateway/dto/asset_dto.go index 1a651a3..8853996 100644 --- a/backend/gateway/dto/asset_dto.go +++ b/backend/gateway/dto/asset_dto.go @@ -80,6 +80,7 @@ type AssetDTO struct { Owner *OwnerInfoDTO `json:"owner,omitempty"` // 持有者信息(可选,保留用于兼容性) IsLiked bool `json:"is_liked"` // 当前用户是否已点赞 Info string `json:"info"` // 藏品信息 + DisplayStatus int32 `json:"display_status"` // 展示状态:0=待展示, 1=已展示 } // OwnerInfoDTO 持有者信息 diff --git a/backend/pkg/proto/asset/asset.pb.go b/backend/pkg/proto/asset/asset.pb.go index 9021c43..4a192a1 100644 --- a/backend/pkg/proto/asset/asset.pb.go +++ b/backend/pkg/proto/asset/asset.pb.go @@ -44,10 +44,11 @@ type Asset struct { UpdatedAt int64 `protobuf:"varint,16,opt,name=updated_at,json=updatedAt,proto3" json:"updated_at,omitempty"` // 更新时间(毫秒时间戳) MintedAt int64 `protobuf:"varint,17,opt,name=minted_at,json=mintedAt,proto3" json:"minted_at,omitempty"` // 上链成功时间(毫秒时间戳,可选) // 扩展字段:持有者信息(用于详情展示) - Owner *OwnerInfo `protobuf:"bytes,18,opt,name=owner,proto3" json:"owner,omitempty"` // 持有者信息(保留用于兼容性) - OwnerNickname string `protobuf:"bytes,19,opt,name=owner_nickname,json=ownerNickname,proto3" json:"owner_nickname,omitempty"` // 持有者昵称(在该star下的昵称) - IsLiked bool `protobuf:"varint,20,opt,name=is_liked,json=isLiked,proto3" json:"is_liked,omitempty"` // 当前用户是否已点赞 - Info string `protobuf:"bytes,21,opt,name=info,proto3" json:"info,omitempty"` // 藏品信息 + Owner *OwnerInfo `protobuf:"bytes,18,opt,name=owner,proto3" json:"owner,omitempty"` // 持有者信息(保留用于兼容性) + OwnerNickname string `protobuf:"bytes,19,opt,name=owner_nickname,json=ownerNickname,proto3" json:"owner_nickname,omitempty"` // 持有者昵称(在该star下的昵称) + IsLiked bool `protobuf:"varint,20,opt,name=is_liked,json=isLiked,proto3" json:"is_liked,omitempty"` // 当前用户是否已点赞 + Info string `protobuf:"bytes,21,opt,name=info,proto3" json:"info,omitempty"` // 藏品信息 + DisplayStatus int32 `protobuf:"varint,22,opt,name=display_status,json=displayStatus,proto3" json:"display_status,omitempty"` // 展示状态:0=待展示, 1=已展示 unknownFields protoimpl.UnknownFields sizeCache protoimpl.SizeCache } @@ -229,6 +230,13 @@ func (x *Asset) GetInfo() string { return "" } +func (x *Asset) GetDisplayStatus() int32 { + if x != nil { + return x.DisplayStatus + } + return 0 +} + // 持有者信息 type OwnerInfo struct { state protoimpl.MessageState `protogen:"open.v1"` @@ -2610,7 +2618,7 @@ var File_asset_proto protoreflect.FileDescriptor const file_asset_proto_rawDesc = "" + "\n" + - "\vasset.proto\x12\rtopfans.asset\x1a\x12proto/common.proto\x1a\x1cgoogle/api/annotations.proto\"\xec\x04\n" + + "\vasset.proto\x12\rtopfans.asset\x1a\x12proto/common.proto\x1a\x1cgoogle/api/annotations.proto\"\x93\x05\n" + "\x05Asset\x12\x19\n" + "\basset_id\x18\x01 \x01(\x03R\aassetId\x12\x1b\n" + "\towner_uid\x18\x02 \x01(\x03R\bownerUid\x12\x17\n" + @@ -2638,7 +2646,8 @@ const file_asset_proto_rawDesc = "" + "\x05owner\x18\x12 \x01(\v2\x18.topfans.asset.OwnerInfoR\x05owner\x12%\n" + "\x0eowner_nickname\x18\x13 \x01(\tR\rownerNickname\x12\x19\n" + "\bis_liked\x18\x14 \x01(\bR\aisLiked\x12\x12\n" + - "\x04info\x18\x15 \x01(\tR\x04info\"X\n" + + "\x04info\x18\x15 \x01(\tR\x04info\x12%\n" + + "\x0edisplay_status\x18\x16 \x01(\x05R\rdisplayStatus\"X\n" + "\tOwnerInfo\x12\x17\n" + "\auser_id\x18\x01 \x01(\x03R\x06userId\x12\x1a\n" + "\bnickname\x18\x02 \x01(\tR\bnickname\x12\x16\n" + diff --git a/backend/proto/asset.proto b/backend/proto/asset.proto index 45244e4..d37e044 100644 --- a/backend/proto/asset.proto +++ b/backend/proto/asset.proto @@ -34,6 +34,7 @@ message Asset { string owner_nickname = 19; // 持有者昵称(在该star下的昵称) bool is_liked = 20; // 当前用户是否已点赞 string info = 21; // 藏品信息 + int32 display_status = 22; // 展示状态:0=待展示, 1=已展示 } // 持有者信息 diff --git a/backend/services/assetService/repository/asset_repository.go b/backend/services/assetService/repository/asset_repository.go index 82b9cb3..e3e93f6 100644 --- a/backend/services/assetService/repository/asset_repository.go +++ b/backend/services/assetService/repository/asset_repository.go @@ -24,6 +24,9 @@ type AssetRepository interface { // GetByIDAndOwner 根据ID和所有者查询资产(用于权限验证) GetByIDAndOwner(assetID, ownerUID, starID int64) (*models.Asset, error) + // GetDisplayStatusByAssetID 根据asset_id查询展示状态(从asset_registry表) + GetDisplayStatusByAssetID(assetID int64) (int32, error) + // GetByOwner 查询用户的资产列表 GetByOwner(ownerUID, starID int64, limit, offset int) ([]*models.Asset, error) @@ -97,6 +100,24 @@ func (r *assetRepository) GetByID(assetID int64) (*models.Asset, error) { return &asset, nil } +// GetDisplayStatusByAssetID 根据asset_id查询展示状态(从public.asset_registry表) +func (r *assetRepository) GetDisplayStatusByAssetID(assetID int64) (int32, error) { + if assetID <= 0 { + return 0, errors.New("asset_id must be greater than 0") + } + + var registry models.AssetRegistry + // 直接使用表名查询 public.asset_registry + if err := r.db.Table("public.asset_registry").Where("asset_id = ?", assetID).First(®istry).Error; err != nil { + if errors.Is(err, gorm.ErrRecordNotFound) { + return 0, nil // 没找到返回0,不报错 + } + return 0, err + } + + return registry.DisplayStatus, nil +} + // GetByIDs 批量查询资产 func (r *assetRepository) GetByIDs(assetIDs []int64) ([]*models.Asset, error) { if len(assetIDs) == 0 { diff --git a/frontend/pages/components/CastloveContent.vue b/frontend/pages/components/CastloveContent.vue index 2ff8c20..56ebdbf 100644 --- a/frontend/pages/components/CastloveContent.vue +++ b/frontend/pages/components/CastloveContent.vue @@ -2,28 +2,22 @@ - + - + - + - + - + {{ tab.name }} - + - + @click="handleCategoryChange(category.value)"> {{ category.label }} - + - + - + @@ -90,12 +71,12 @@ - + 加载中... - + 没有更多了 @@ -192,7 +173,7 @@ onMounted(() => { console.log('[CastloveContent] 系统信息:', systemInfo); isAndroid.value = systemInfo.platform === 'android'; console.log('[CastloveContent] 是否为Android:', isAndroid.value); - + loadBanners(); loadCreations(); }); @@ -211,7 +192,7 @@ const loadBanners = async () => { // 加载创作列表 const loadCreations = async () => { if (loading.value || noMore.value) return; - + loading.value = true; try { // TODO: 调用后台接口获取创作列表 @@ -220,16 +201,16 @@ const loadCreations = async () => { // page: page.value, // page_size: pageSize.value // }); - + // 模拟数据 const mockData = generateMockData(); - + if (page.value === 1) { creationList.value = mockData; } else { creationList.value = [...creationList.value, ...mockData]; } - + if (mockData.length < pageSize.value) { noMore.value = true; } @@ -270,7 +251,7 @@ const generateMockData = () => { for (let i = 0; i < pageSize.value; i++) { // 随机选择一张素材图片 const randomImageIndex = Math.floor(Math.random() * sucaiImages.length); - + data.push({ id: `${Date.now()}_${i}`, cover_image: sucaiImages[randomImageIndex], @@ -278,7 +259,7 @@ const generateMockData = () => { creator_name: `用户${Math.floor(Math.random() * 1000)}`, creator_avatar: '/static/avatar/default.png', like_count: Math.floor(Math.random() * 1000), - type: currentCategory.value === 'hot' || currentCategory.value === 'latest' + type: currentCategory.value === 'hot' || currentCategory.value === 'latest' ? ['star_card', 'badge', 'poster'][Math.floor(Math.random() * 3)] : currentCategory.value }); @@ -313,12 +294,12 @@ const handleMainTabClick = (tab) => { // 分类切换 const handleCategoryChange = (value) => { if (currentCategory.value === value) return; - + currentCategory.value = value; page.value = 1; noMore.value = false; creationList.value = []; - + // 滚动到创作网格列表的顶部(分类栏位置) // 轮播图360rpx + 主Tab约280rpx + 间距 ≈ 320px if (isFixed.value) { @@ -328,7 +309,7 @@ const handleCategoryChange = (value) => { scrollTop.value = 361; }, 100); } - + loadCreations(); }; @@ -365,7 +346,17 @@ const formatCount = (count) => { // 返回按钮 const handleBack = () => { - uni.navigateBack(); + // 获取页面栈 + const pages = getCurrentPages(); + if (pages.length > 1) { + // 有上一页,执行返回 + uni.navigateBack(); + } else { + // 没有上一页,跳转到square页面 + uni.reLaunch({ + url: '/pages/square/square' + }); + } }; diff --git a/frontend/pages/components/FriendsContent.vue b/frontend/pages/components/FriendsContent.vue index d82a8ad..5cf4388 100644 --- a/frontend/pages/components/FriendsContent.vue +++ b/frontend/pages/components/FriendsContent.vue @@ -839,7 +839,7 @@ z-index: 1; display: flex; flex-direction: column; - padding-top: 160rpx; + padding-top: 192rpx; padding-left: 40rpx; padding-right: 40rpx; padding-bottom: 160rpx; diff --git a/frontend/pages/friends/index.vue b/frontend/pages/friends/index.vue index 3851258..6e1b670 100644 --- a/frontend/pages/friends/index.vue +++ b/frontend/pages/friends/index.vue @@ -1,6 +1,6 @@