fix(ProfileCard): 修复群聊信息编辑时JSON字符串格式问题

修复群名称和群公告编辑时JSON字符串格式错误,将单引号替换为双引号以确保正确解析
This commit is contained in:
超级老白兔
2025-09-04 11:07:44 +08:00
parent 8d9d069267
commit 890e3c338b
3 changed files with 73 additions and 44 deletions

View File

@@ -1,14 +1,18 @@
{
"_charts-BET_YNJb.js": {
"file": "assets/charts-BET_YNJb.js",
"_charts-Bwx_qhiY.js": {
"file": "assets/charts-Bwx_qhiY.js",
"name": "charts",
"imports": [
"_ui-BSfOMVFg.js",
"_ui-D94amoNo.js",
"_vendor-2vc8h_ct.js"
]
},
"_ui-BSfOMVFg.js": {
"file": "assets/ui-BSfOMVFg.js",
"_ui-D0C0OGrH.css": {
"file": "assets/ui-D0C0OGrH.css",
"src": "_ui-D0C0OGrH.css"
},
"_ui-D94amoNo.js": {
"file": "assets/ui-D94amoNo.js",
"name": "ui",
"imports": [
"_vendor-2vc8h_ct.js"
@@ -17,10 +21,6 @@
"assets/ui-D0C0OGrH.css"
]
},
"_ui-D0C0OGrH.css": {
"file": "assets/ui-D0C0OGrH.css",
"src": "_ui-D0C0OGrH.css"
},
"_utils-6WF66_dS.js": {
"file": "assets/utils-6WF66_dS.js",
"name": "utils",
@@ -33,15 +33,15 @@
"name": "vendor"
},
"index.html": {
"file": "assets/index-DX2o9_TA.js",
"file": "assets/index-_v-odON8.js",
"name": "index",
"src": "index.html",
"isEntry": true,
"imports": [
"_vendor-2vc8h_ct.js",
"_utils-6WF66_dS.js",
"_ui-BSfOMVFg.js",
"_charts-BET_YNJb.js"
"_ui-D94amoNo.js",
"_charts-Bwx_qhiY.js"
],
"css": [
"assets/index-DwDrBOQB.css"

View File

@@ -11,11 +11,11 @@
</style>
<!-- 引入 uni-app web-view SDK必须 -->
<script type="text/javascript" src="/websdk.js"></script>
<script type="module" crossorigin src="/assets/index-DX2o9_TA.js"></script>
<script type="module" crossorigin src="/assets/index-_v-odON8.js"></script>
<link rel="modulepreload" crossorigin href="/assets/vendor-2vc8h_ct.js">
<link rel="modulepreload" crossorigin href="/assets/utils-6WF66_dS.js">
<link rel="modulepreload" crossorigin href="/assets/ui-BSfOMVFg.js">
<link rel="modulepreload" crossorigin href="/assets/charts-BET_YNJb.js">
<link rel="modulepreload" crossorigin href="/assets/ui-D94amoNo.js">
<link rel="modulepreload" crossorigin href="/assets/charts-Bwx_qhiY.js">
<link rel="stylesheet" crossorigin href="/assets/ui-D0C0OGrH.css">
<link rel="stylesheet" crossorigin href="/assets/index-DwDrBOQB.css">
</head>

View File

@@ -55,16 +55,22 @@ const Person: React.FC<PersonProps> = ({
const [newTagValue, setNewTagValue] = useState("");
// 判断是否为群聊
const isGroup = 'chatroomId' in contract;
const isGroup = "chatroomId" in contract;
// 群聊相关状态
const [isEditingGroupName, setIsEditingGroupName] = useState(false);
const [groupNameValue, setGroupNameValue] = useState(contract.name || '');
const [groupNameValue, setGroupNameValue] = useState(contract.name || "");
const [isEditingGroupNotice, setIsEditingGroupNotice] = useState(false);
const [groupNoticeValue, setGroupNoticeValue] = useState(contract.notice || '');
const [isEditingSelfDisplayName, setIsEditingSelfDisplayName] = useState(false);
const [selfDisplayNameValue, setSelfDisplayNameValue] = useState(contract.selfDisplyName || '');
const [isGroupNoticeModalVisible, setIsGroupNoticeModalVisible] = useState(false);
const [groupNoticeValue, setGroupNoticeValue] = useState(
contract.notice || "",
);
const [isEditingSelfDisplayName, setIsEditingSelfDisplayName] =
useState(false);
const [selfDisplayNameValue, setSelfDisplayNameValue] = useState(
contract.selfDisplyName || "",
);
const [isGroupNoticeModalVisible, setIsGroupNoticeModalVisible] =
useState(false);
// 构建联系人或群聊详细信息
@@ -96,14 +102,21 @@ const Person: React.FC<PersonProps> = ({
setSelectedTags(contract.labels || []);
if (isGroup) {
setGroupNameValue(contract.name || '');
setGroupNameValue(contract.name || "");
setIsEditingGroupName(false);
setGroupNoticeValue(contract.notice || '');
setGroupNoticeValue(contract.notice || "");
setIsEditingGroupNotice(false);
setSelfDisplayNameValue(contract.selfDisplyName || '');
setSelfDisplayNameValue(contract.selfDisplyName || "");
setIsEditingSelfDisplayName(false);
}
}, [contract.conRemark, contract.labels, contract.name, contract.notice, contract.selfDisplyName, isGroup]);
}, [
contract.conRemark,
contract.labels,
contract.name,
contract.notice,
contract.selfDisplyName,
isGroup,
]);
// 处理备注保存
const handleSaveRemark = () => {
@@ -134,7 +147,7 @@ const Person: React.FC<PersonProps> = ({
wechatAccountId: contract.wechatAccountId,
wechatChatroomId: contract.id,
chatroomOperateType: 6,
extra: `{\"chatroomName\":\"${groupNameValue}\"}`,
extra: `{"chatroomName":"${groupNameValue}"}`,
});
messageApi.success("群名称修改成功");
@@ -143,7 +156,7 @@ const Person: React.FC<PersonProps> = ({
// 点击编辑群名称按钮
const handleEditGroupName = () => {
setGroupNameValue(contract.name || '');
setGroupNameValue(contract.name || "");
setIsEditingGroupName(true);
};
@@ -153,7 +166,7 @@ const Person: React.FC<PersonProps> = ({
wechatAccountId: contract.wechatAccountId,
wechatChatroomId: contract.id,
chatroomOperateType: 5,
extra: `{\"announce\":\"${groupNoticeValue}\"}`,
extra: `{"announce":"${groupNoticeValue}"}`,
});
messageApi.success("群公告修改成功");
@@ -162,7 +175,7 @@ const Person: React.FC<PersonProps> = ({
// 点击编辑群公告按钮
const handleEditGroupNotice = () => {
setGroupNoticeValue(contract.notice || '');
setGroupNoticeValue(contract.notice || "");
setIsGroupNoticeModalVisible(true);
};
@@ -181,7 +194,7 @@ const Person: React.FC<PersonProps> = ({
// 点击编辑群昵称按钮
const handleEditSelfDisplayName = () => {
setSelfDisplayNameValue(contract.selfDisplyName || '');
setSelfDisplayNameValue(contract.selfDisplyName || "");
setIsEditingSelfDisplayName(true);
};
@@ -351,7 +364,7 @@ const Person: React.FC<PersonProps> = ({
size="small"
icon={<CloseOutlined />}
onClick={() => {
setGroupNameValue(contract.name || '');
setGroupNameValue(contract.name || "");
setIsEditingGroupName(false);
}}
style={{ color: "#ff4d4f" }}
@@ -400,7 +413,9 @@ const Person: React.FC<PersonProps> = ({
<div className={styles.infoItem}>
<UserOutlined className={styles.infoIcon} />
<span className={styles.infoLabel}>:</span>
<span className={styles.infoValue}>{contractInfo.chatroomOwner}</span>
<span className={styles.infoValue}>
{contractInfo.chatroomOwner}
</span>
</div>
<div className={styles.infoItem}>
<UserOutlined className={styles.infoIcon} />
@@ -416,7 +431,9 @@ const Person: React.FC<PersonProps> = ({
>
<Input
value={selfDisplayNameValue}
onChange={e => setSelfDisplayNameValue(e.target.value)}
onChange={e =>
setSelfDisplayNameValue(e.target.value)
}
placeholder="请输入群昵称"
size="small"
style={{ flex: 1 }}
@@ -433,7 +450,9 @@ const Person: React.FC<PersonProps> = ({
size="small"
icon={<CloseOutlined />}
onClick={() => {
setSelfDisplayNameValue(contract.selfDisplyName || '');
setSelfDisplayNameValue(
contract.selfDisplyName || "",
);
setIsEditingSelfDisplayName(false);
}}
style={{ color: "#ff4d4f" }}
@@ -447,7 +466,9 @@ const Person: React.FC<PersonProps> = ({
gap: "8px",
}}
>
<span>{contractInfo.selfDisplyName || "点击添加群昵称"}</span>
<span>
{contractInfo.selfDisplyName || "点击添加群昵称"}
</span>
<Button
type="text"
size="small"
@@ -477,7 +498,9 @@ const Person: React.FC<PersonProps> = ({
<div className={styles.infoItem}>
<EnvironmentOutlined className={styles.infoIcon} />
<span className={styles.infoLabel}>:</span>
<span className={styles.infoValue}>{contractInfo.region}</span>
<span className={styles.infoValue}>
{contractInfo.region}
</span>
</div>
</>
)}
@@ -621,7 +644,10 @@ const Person: React.FC<PersonProps> = ({
)}
{/* 个人简介或群公告 */}
<Card title={isGroup ? "群公告" : "个人简介"} className={styles.profileCard}>
<Card
title={isGroup ? "群公告" : "个人简介"}
className={styles.profileCard}
>
{isGroup ? (
// 群聊简介(原群公告)
<div className={styles.infoValue}>
@@ -638,7 +664,7 @@ const Person: React.FC<PersonProps> = ({
onChange={e => setGroupNoticeValue(e.target.value)}
placeholder="请输入内容"
rows={6}
style={{ width: '100%' }}
style={{ width: "100%" }}
/>
</div>
) : (
@@ -649,7 +675,7 @@ const Person: React.FC<PersonProps> = ({
gap: "8px",
}}
>
<div
<div
className={styles.bioText}
style={{
maxHeight: "120px", // 约5行文本的高度
@@ -696,12 +722,15 @@ const Person: React.FC<PersonProps> = ({
open={isGroupNoticeModalVisible}
onCancel={() => setIsGroupNoticeModalVisible(false)}
footer={[
<Button key="cancel" onClick={() => setIsGroupNoticeModalVisible(false)}>
<Button
key="cancel"
onClick={() => setIsGroupNoticeModalVisible(false)}
>
</Button>,
<Button
key="submit"
type="primary"
<Button
key="submit"
type="primary"
onClick={() => {
handleSaveGroupNotice();
setIsGroupNoticeModalVisible(false);
@@ -716,7 +745,7 @@ const Person: React.FC<PersonProps> = ({
onChange={e => setGroupNoticeValue(e.target.value)}
placeholder="请输入内容"
rows={6}
style={{ width: '100%' }}
style={{ width: "100%" }}
/>
</Modal>
</>