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