Commit 69a3aa26e12fc89eee8d65e15dc0e5ae6a46d659

Authored by Min
1 parent c080970d

1.完善企业公告弹窗功能

src/components/Common/PersonCenter/PersonCenter.js
... ... @@ -217,7 +217,9 @@ class PersonCenter extends Component {
217 217 // 1. 在调用接口前先检查是否已经显示过该公告
218 218 const noticeKey = `${sMsgId}_${sMsgSlaveId}`;
219 219  
220   - const shownNotices = JSON.parse(localStorage.getItem('shownNotices') || '[]');
  220 + const shownNotices = localStorage.getItem('shownNotices') || '';
  221 +
  222 + console.log('shownNotices', shownNotices, noticeKey);
221 223  
222 224 // 如果已经显示过,直接返回,不调用接口
223 225 if (shownNotices.includes(noticeKey)) {
... ... @@ -238,8 +240,8 @@ class PersonCenter extends Component {
238 240 const noticeData = dataReturn[0];
239 241  
240 242 // 3. 再次确认是否已显示(防止并发请求)
241   - const currentShownNotices = JSON.parse(localStorage.getItem('shownNotices') || '[]');
242   - console.log('currentShownNotices1', currentShownNotices);
  243 + const currentShownNotices = localStorage.getItem('shownNotices') || '';
  244 + console.log('currentShownNotices11', currentShownNotices);
243 245 if (!currentShownNotices.includes(noticeKey)) {
244 246 this.setState({
245 247 noticeVisible: true,
... ... @@ -273,16 +275,9 @@ class PersonCenter extends Component {
273 275 message.success('公告已阅读');
274 276 // 在用户确认阅读后,才将公告记录存储到shownNotices中
275 277 const noticeKey = `${sMsgId}_${sMsgSlaveId}`;
276   - const currentShownNotices = JSON.parse(localStorage.getItem('shownNotices') || '[]');
277   -
278   - if (!currentShownNotices.includes(noticeKey)) {
279   - currentShownNotices.push(noticeKey);
280   - // 限制存储最近100条记录,防止localStorage过大
281   - if (currentShownNotices.length > 100) {
282   - currentShownNotices.shift();
283   - }
284   - localStorage.setItem('shownNotices', JSON.stringify(currentShownNotices));
285   - }
  278 + const currentShownNotices = localStorage.getItem('shownNotices') || '';
  279 + console.log('noticeKe11111y', noticeKey);
  280 + localStorage.setItem('shownNotices', JSON.stringify(noticeKey));
286 281 } else {
287 282 message.error(configReturn?.msg);
288 283 }
... ... @@ -1141,7 +1136,11 @@ const PersonCenterNotice = Form.create({
1141 1136 {
1142 1137 noticeVisible ?
1143 1138 <AntdDraggableModal
1144   - title={NoticeTitle}
  1139 + title={
  1140 + <div style={{ textAlign: 'center', width: '100%', fontSize: '18px' }}>
  1141 + {NoticeTitle}
  1142 + </div>
  1143 + }
1145 1144 width={1200}
1146 1145 visible={noticeVisible}
1147 1146 onCancel={handleNoticeCancel}
... ... @@ -1153,7 +1152,7 @@ const PersonCenterNotice = Form.create({
1153 1152 display: 'flex',
1154 1153 alignItems: 'center',
1155 1154 width: '100%',
1156   - justifyContent: 'flex-start',
  1155 + justifyContent: 'flex-end',
1157 1156 padding: '0px 24px 16px 16px',
1158 1157 margin: '0', // 清除外部默认边距
1159 1158 }}
... ...