diff --git a/Cunkebao/src/pages/mobile/mine/content/materials/list/data.ts b/Cunkebao/src/pages/mobile/mine/content/materials/list/data.ts index 4217465e..3be3872f 100644 --- a/Cunkebao/src/pages/mobile/mine/content/materials/list/data.ts +++ b/Cunkebao/src/pages/mobile/mine/content/materials/list/data.ts @@ -26,6 +26,7 @@ export interface ContentItem { delTime: number; wechatChatroomId?: string | null; senderNickname: string; + senderAvatar?: string | null; createMessageTime?: string | null; comment: string; sendTime: number; diff --git a/Cunkebao/src/pages/mobile/mine/content/materials/list/index.module.scss b/Cunkebao/src/pages/mobile/mine/content/materials/list/index.module.scss index 1d5b5666..29c91883 100644 --- a/Cunkebao/src/pages/mobile/mine/content/materials/list/index.module.scss +++ b/Cunkebao/src/pages/mobile/mine/content/materials/list/index.module.scss @@ -131,6 +131,25 @@ display: flex; align-items: center; justify-content: center; + overflow: hidden; + position: relative; +} + +.avatar-img { + width: 100%; + height: 100%; + object-fit: cover; +} + +.avatar-icon-wrapper { + width: 100%; + height: 100%; + display: flex; + align-items: center; + justify-content: center; + position: absolute; + top: 0; + left: 0; } .avatar-icon { @@ -617,7 +636,7 @@ // AI改写弹框样式 .ai-popup-content { padding: 20px; - max-height: 80vh; + max-height: 100vh; overflow-y: auto; background: #f9fbfd; @@ -695,8 +714,8 @@ border: 1px solid #e0f0ff; border-radius: 8px; padding: 16px; - min-height: 150px; - max-height: 300px; + min-height: 100px; + max-height: 200px; overflow-y: auto; box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05); @@ -743,13 +762,15 @@ height: 44px; font-size: 16px; border-radius: 8px; - background: #52c41a; - border-color: #52c41a; - box-shadow: 0 2px 6px rgba(82, 196, 26, 0.2); + background: #1677ff; + border-color: #1677ff; + box-shadow: 0 2px 6px rgba(22, 119, 255, 0.2); + color: #ffffff; &:hover, &:focus { - background: #73d13d; - border-color: #73d13d; + background: #4096ff; + border-color: #4096ff; + color: #ffffff; } } } diff --git a/Cunkebao/src/pages/mobile/mine/content/materials/list/index.tsx b/Cunkebao/src/pages/mobile/mine/content/materials/list/index.tsx index e05012a0..aef8c2a8 100644 --- a/Cunkebao/src/pages/mobile/mine/content/materials/list/index.tsx +++ b/Cunkebao/src/pages/mobile/mine/content/materials/list/index.tsx @@ -422,7 +422,23 @@ const MaterialsList: React.FC = () => {
- + {material.senderAvatar ? ( + 头像 { + e.currentTarget.style.display = 'none'; + const nextElement = e.currentTarget.nextSibling as HTMLElement; + if (nextElement) { + nextElement.style.display = 'flex'; + } + }} + /> + ) : null} +
+ +
diff --git a/Server/application/cunkebao/controller/ContentLibraryController.php b/Server/application/cunkebao/controller/ContentLibraryController.php index c527021c..9dbc438b 100644 --- a/Server/application/cunkebao/controller/ContentLibraryController.php +++ b/Server/application/cunkebao/controller/ContentLibraryController.php @@ -40,8 +40,21 @@ class ContentLibraryController extends Controller return json(['code' => 400, 'msg' => '内容库名称不能为空']); } + // 检查内容库名称是否已存在 - $exists = ContentLibrary::where(['name' => $param['name'], 'userId' => $this->request->userInfo['id'], 'isDel' => 0])->find(); + $where = [ + ['name', '=', $param['name']], + ['companyId', '=', $this->request->userInfo['companyId']], + ['isDel', '=', 0] + ]; + if (empty($this->request->userInfo['isAdmin'])) { + $where[] = ['userId', '=', $this->request->userInfo['id']]; + } + + // 查询内容库是否存在 + $exists = ContentLibrary::where($where)->find(); + + if ($exists) { return json(['code' => 400, 'msg' => '内容库名称已存在']); } @@ -111,16 +124,14 @@ class ContentLibraryController extends Controller $sourceType = $this->request->param('sourceType', ''); // 新增:来源类型,1=好友,2=群 $where = [ - ['companyId' , '=', $this->request->userInfo['companyId']], + ['companyId', '=', $this->request->userInfo['companyId']], ['isDel', '=', 0] // 只查询未删除的记录 ]; - if(empty($this->request->userInfo['isAdmin'])){ - $where[] = ['userId', '=', $this->request->userInfo['id']]; + if (empty($this->request->userInfo['isAdmin'])) { + $where[] = ['userId', '=', $this->request->userInfo['id']]; } - - // 添加名称模糊搜索 if ($keyword !== '') { $where[] = ['name', 'like', '%' . $keyword . '%']; @@ -214,11 +225,17 @@ class ContentLibraryController extends Controller return json(['code' => 400, 'msg' => '参数错误']); } - $library = ContentLibrary::where([ - ['id', '=', $id], - ['userId', '=', $this->request->userInfo['id']], + $where = [ + ['companyId', '=', $this->request->userInfo['companyId']], ['isDel', '=', 0] // 只查询未删除的记录 - ]) + ]; + + if (empty($this->request->userInfo['isAdmin'])) { + $where[] = ['userId', '=', $this->request->userInfo['id']]; + } + + + $library = ContentLibrary::where($where) ->field('id,name,sourceType,sourceFriends,sourceGroups,keywordInclude,keywordExclude,aiEnabled,aiPrompt,timeEnabled,timeStart,timeEnd,status,userId,companyId,createTime,updateTime,groupMembers,catchType') ->find(); @@ -233,7 +250,7 @@ class ContentLibraryController extends Controller $library['keywordExclude'] = json_decode($library['keywordExclude'] ?: '[]', true); $library['groupMembers'] = json_decode($library['groupMembers'] ?: '[]', true); $library['catchType'] = json_decode($library['catchType'] ?: '[]', true); - unset($library['sourceFriends'],$library['sourceGroups']); + unset($library['sourceFriends'], $library['sourceGroups']); // 将时间戳转换为日期格式(精确到日) if (!empty($library['timeStart'])) { @@ -260,7 +277,7 @@ class ContentLibraryController extends Controller // 将好友信息添加到返回数据中 $library['friendsGroupsOptions'] = $friendsInfo; - }else{ + } else { $library['friendsGroupsOptions'] = []; } @@ -280,7 +297,7 @@ class ContentLibraryController extends Controller // 将群组信息添加到返回数据中 $library['wechatGroupsOptions'] = $groupsInfo; - }else{ + } else { $library['wechatGroupsOptions'] = []; } @@ -315,12 +332,12 @@ class ContentLibraryController extends Controller $where = [ - ['companyId' , '=', $this->request->userInfo['companyId']], + ['companyId', '=', $this->request->userInfo['companyId']], ['isDel', '=', 0] // 只查询未删除的记录 ]; - if(empty($this->request->userInfo['isAdmin'])){ - $where[] = ['userId', '=', $this->request->userInfo['id']]; + if (empty($this->request->userInfo['isAdmin'])) { + $where[] = ['userId', '=', $this->request->userInfo['id']]; } // 查询内容库是否存在 @@ -375,11 +392,16 @@ class ContentLibraryController extends Controller return json(['code' => 400, 'msg' => '参数错误']); } - $library = ContentLibrary::where([ + + $where = [ ['id', '=', $id], - ['userId', '=', $this->request->userInfo['id']], - ['isDel', '=', 0] // 只删除未删除的记录 - ])->find(); + ['companyId', '=', $this->request->userInfo['companyId']], + ['isDel', '=', 0] + ]; + if (empty($this->request->userInfo['isAdmin'])) { + $where[] = ['userId', '=', $this->request->userInfo['id']]; + } + $library = ContentLibrary::where($where)->find(); if (empty($library)) { return json(['code' => 500, 'msg' => '内容库不存在']); @@ -416,12 +438,17 @@ class ContentLibraryController extends Controller return json(['code' => 400, 'msg' => '内容库ID不能为空']); } - // 验证内容库权限 - $library = ContentLibrary::where([ + $where = [ ['id', '=', $libraryId], - ['userId', '=', $this->request->userInfo['id']], + ['companyId', '=', $this->request->userInfo['companyId']], ['isDel', '=', 0] - ])->find(); + ]; + if (empty($this->request->userInfo['isAdmin'])) { + $where[] = ['userId', '=', $this->request->userInfo['id']]; + } + + // 验证内容库权限 + $library = ContentLibrary::where($where)->find(); if (empty($library)) { return json(['code' => 500, 'msg' => '内容库不存在或无权限访问']); @@ -447,10 +474,13 @@ class ContentLibraryController extends Controller // 处理数据 foreach ($list as &$item) { + $item['content'] = !empty($item['contentAi']) ? $item['contentAi'] : $item['content']; + // 处理资源URL $item['resUrls'] = json_decode($item['resUrls'] ?: '[]', true); $item['urls'] = json_decode($item['urls'] ?: '[]', true); + // 格式化时间 //$item['createTime'] = date('Y-m-d H:i:s', $item['createTime']); if ($item['createMomentTime']) { @@ -462,11 +492,10 @@ class ContentLibraryController extends Controller // 获取发送者信息 if ($item['type'] == 'moment' && !empty($item['friendId'])) { - $friendInfo = Db::name('wechat_friendship') - ->alias('wf') - ->join('wechat_account wa', 'wf.wechatId = wa.wechatId') - ->where('wf.id', $item['friendId']) - ->field('wa.nickname, wa.avatar') + $friendInfo = Db::table('s2_wechat_friend') + ->where('id', $item['friendId']) + ->field('nickname, avatar') + ->order('id desc') ->find(); $item['senderNickname'] = !empty($friendInfo['nickname']) ? $friendInfo['nickname'] : ''; $item['senderAvatar'] = !empty($friendInfo['avatar']) ? $friendInfo['avatar'] : ''; @@ -478,6 +507,8 @@ class ContentLibraryController extends Controller $item['senderNickname'] = !empty($friendInfo['nickname']) ? $friendInfo['nickname'] : ''; $item['senderAvatar'] = !empty($friendInfo['avatar']) ? $friendInfo['avatar'] : ''; } + + unset($item['contentAi']); } unset($item); @@ -534,11 +565,17 @@ class ContentLibraryController extends Controller } } - // 查询内容库是否存在 - $library = ContentLibrary::where([ + $where = [ ['id', '=', $param['libraryId']], - ['userId', '=', $this->request->userInfo['id']] - ])->find(); + ['companyId', '=', $this->request->userInfo['companyId']], + ['isDel', '=', 0] + ]; + if (empty($this->request->userInfo['isAdmin'])) { + $where[] = ['userId', '=', $this->request->userInfo['id']]; + } + + // 查询内容库是否存在 + $library = ContentLibrary::where($where)->find(); if (!$library) { return json(['code' => 500, 'msg' => '内容库不存在']); @@ -783,14 +820,14 @@ class ContentLibraryController extends Controller return json(['code' => 400, 'msg' => '参数错误']); } - if(!empty($id)) { + if (!empty($id)) { // 查询内容项目是否存在并检查权限 $item = ContentItem::alias('ci') ->join('content_library cl', 'ci.libraryId = cl.id') ->where(['ci.id' => $id, 'ci.isDel' => 0, 'cl.isDel' => 0, 'cl.companyId' => $companyId]) ->field('ci.*') ->find(); - }else{ + } else { $item['content'] = $content; }