Skip to content

Commit

Permalink
优化一波
Browse files Browse the repository at this point in the history
  • Loading branch information
Yurunsoft committed Aug 25, 2023
1 parent 9afed83 commit a1251b8
Show file tree
Hide file tree
Showing 11 changed files with 70 additions and 39 deletions.
33 changes: 0 additions & 33 deletions admin/src/router/modules/management.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,28 +3,6 @@ const management: AuthRoute.Route = {
path: '/management',
component: 'basic',
children: [
// {
// name: 'management_auth',
// path: '/management/auth',
// component: 'self',
// meta: {
// title: '权限管理',
// i18nTitle: 'routes.management.auth',
// requiresAuth: true,
// icon: 'ic:baseline-security'
// }
// },
// {
// name: 'management_role',
// path: '/management/role',
// component: 'self',
// meta: {
// title: '角色管理',
// i18nTitle: 'routes.management.role',
// requiresAuth: true,
// icon: 'carbon:user-role'
// }
// },
{
name: 'management_admin_member',
path: '/management/admin/member',
Expand All @@ -35,17 +13,6 @@ const management: AuthRoute.Route = {
icon: 'ic:round-manage-accounts'
}
}
// {
// name: 'management_route',
// path: '/management/route',
// component: 'self',
// meta: {
// title: '路由管理',
// i18nTitle: 'routes.management.route',
// requiresAuth: true,
// icon: 'material-symbols:route'
// }
// }
],
meta: {
title: '系统管理',
Expand Down
5 changes: 3 additions & 2 deletions admin/src/service/api/chat.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ export const fetchChatSessionList = async (search = '', type = 0, page = 1, limi
(await response).data?.list.forEach(item => {
item.title = decodeSecureField(item.title);
item.prompt = decodeSecureField(item.prompt);
item.memberInfo.nickname = decodeSecureField(item.memberInfo.nickname);
});

return response;
Expand All @@ -26,15 +27,15 @@ export const deleteChatSession = async (id: number) => {
};

export const fetchChatMessageList = async (sessionId: number, page = 1, limit = 15) => {
const response = request.get<Chat.MessageListResponse>('/admin/chat/messageList', {
const response = await request.get<Chat.MessageListResponse>('/admin/chat/messageList', {
params: {
sessionId,
page,
limit
}
});

(await response).data?.list.forEach(item => {
response.data?.list.forEach(item => {
item.message = decodeSecureField(item.message);
});

Expand Down
9 changes: 8 additions & 1 deletion admin/src/service/api/member.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,22 @@
import { decodeSecureField } from '~/src/utils/crypto';
import { request } from '../request';

/** 获取用户列表 */
export const fetchMemberList = async (search = '', status = 0, page = 1, limit = 15) => {
return request.get<Member.MemberListResponse>('/admin/member/list', {
const response = await request.get<Member.MemberListResponse>('/admin/member/list', {
params: {
search,
status,
page,
limit
}
});

response.data?.list.forEach(item => {
item.nickname = decodeSecureField(item.nickname);
});

return response;
};

export const updateMember = async (
Expand Down
4 changes: 4 additions & 0 deletions admin/src/typings/chat.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ declare namespace Chat {
ip: string;
createTime: number;
updateTime: number;
memberInfo: {
recordId: string;
nickname: string;
};
}

interface Message {
Expand Down
17 changes: 16 additions & 1 deletion admin/src/views/chat/list/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
:loading="loading"
:pagination="pagination"
:row-key="row => row.id"
scroll-x="1000"
scroll-x="1200"
flex-height
remote
class="flex-1-hidden"
Expand Down Expand Up @@ -106,6 +106,21 @@ const columns: Ref<DataTableColumns<Chat.Session>> = ref([
title: '类型',
width: 100
},
{
key: 'member',
title: '用户',
width: 140,
render: row => {
return (
<>
<p>
ID:{row.memberId} ({row.memberInfo.recordId})
</p>
<p>昵称:{row.memberInfo.nickname}</p>
</>
);
}
},
{
key: 'title',
title: '内容',
Expand Down
2 changes: 1 addition & 1 deletion admin/src/views/chat/message_list/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ const tableData = ref<Chat.Message[]>([]);
const pagination = defaultPaginationProps(getTableData);
function setTableData(response: Chat.MessageListResponse) {
tableData.value = response.list.reverse();
tableData.value = response.list;
pagination.pageCount = response.pageCount;
pagination.itemCount = response.total;
}
Expand Down
12 changes: 12 additions & 0 deletions server/Module/Chat/Model/Admin/ChatSession.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

namespace app\Module\Chat\Model\Admin;

use app\Module\Member\Model\Traits\TMemberInfo;
use Imi\Bean\Annotation\Inherit;
use Imi\Config;
use Imi\Model\Annotation\Serializables;
Expand All @@ -14,8 +15,19 @@
]
class ChatSession extends \app\Module\Chat\Model\ChatSession
{
use TMemberInfo;

public static function __getSalt(): string
{
return (static::$saltClass ?? parent::class) . ':' . Config::get('@app.ai.idSalt');
}

public function __setSecureField(bool $secureField): self
{
parent::__setSecureField($secureField);
$this->memberInfo = null;
$this->member->__setSecureField($secureField);

return $this;
}
}
9 changes: 9 additions & 0 deletions server/Module/Embedding/Model/DTO/PublicEmbeddingProject.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,13 @@ class PublicEmbeddingProject extends EmbeddingProject
use TMemberInfo;

protected static ?string $saltClass = EmbeddingProject::class;

public function __setSecureField(bool $secureField): self
{
parent::__setSecureField($secureField);
$this->memberInfo = null;
$this->member->__setSecureField($secureField);

return $this;
}
}
10 changes: 9 additions & 1 deletion server/Module/Member/ApiController/Admin/MemberController.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

use app\Module\Admin\Annotation\AdminLoginRequired;
use app\Module\Admin\Util\AdminMemberUtil;
use app\Module\Member\Model\Admin\Member;
use app\Module\Member\Service\MemberService;
use app\Util\IPUtil;
use Imi\Aop\Annotation\Inject;
Expand All @@ -27,7 +28,14 @@ class MemberController extends HttpController
]
public function list(string $search = '', int $status = 0, int $page = 1, int $limit = 15): array
{
return $this->memberService->list($search, $status, $page, $limit);
$result = $this->memberService->list($search, $status, $page, $limit);
/** @var Member $item */
foreach ($result['list'] as $item)
{
$item->__setSecureField(true);
}

return $result;
}

/**
Expand Down
7 changes: 7 additions & 0 deletions server/Module/Member/Model/Member.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
namespace app\Module\Member\Model;

use app\Module\Common\Model\Traits\TRecordId;
use app\Module\Common\Model\Traits\TSecureField;
use app\Module\Member\Enum\MemberStatus;
use app\Module\Member\Model\Base\MemberBase;
use Hashids\Hashids;
Expand All @@ -21,6 +22,12 @@
class Member extends MemberBase
{
use TRecordId;
use TSecureField;

/**
* 安全处理字段.
*/
protected static array $__secureFields = ['nickname'];

/**
* 注册时间.
Expand Down
1 change: 1 addition & 0 deletions web/src/api/embedding.ts
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,7 @@ export function retrySection(

function decodeEmbeddingProjectSecureFields(data: any) {
data.name = decodeSecureField(data.name)
data.memberInfo.nickname = decodeSecureField(data.memberInfo.nickname)
data.publicList = PublicProjectStatus.OPEN === data.publicProject?.status
}

Expand Down

0 comments on commit a1251b8

Please sign in to comment.