Commit 26f4855ab016c463316b4d8e8e2c2810130fff2d
Committed by
xp.Huang
1 parent
b60e8d59
fix: 查看消息配置时,隐藏配置内容
Showing
3 changed files
with
80 additions
and
1 deletions
@@ -5,4 +5,5 @@ | @@ -5,4 +5,5 @@ | ||
5 | export const enum UserDropDownItemEnum { | 5 | export const enum UserDropDownItemEnum { |
6 | FORGOT_PASSWORD = 'system:password:view', //忘记密码权限标识key | 6 | FORGOT_PASSWORD = 'system:password:view', //忘记密码权限标识key |
7 | ABOUT_SOFTWARE = 'system:about_software:view', //关于软件权限标识key | 7 | ABOUT_SOFTWARE = 'system:about_software:view', //关于软件权限标识key |
8 | + PERSONAL_CENTER = 'system:personal_center:view', //个人中心权限标识key | ||
8 | } | 9 | } |
@@ -12,6 +12,7 @@ | @@ -12,6 +12,7 @@ | ||
12 | <template #overlay> | 12 | <template #overlay> |
13 | <Menu @click="handleMenuClick"> | 13 | <Menu @click="handleMenuClick"> |
14 | <MenuItem | 14 | <MenuItem |
15 | + v-if="hasPermission(UserDropDownItemEnum.PERSONAL_CENTER)" | ||
15 | key="personal" | 16 | key="personal" |
16 | :text="t('layout.header.dropdownItemPersonal')" | 17 | :text="t('layout.header.dropdownItemPersonal')" |
17 | icon="ion:document-text-outline" | 18 | icon="ion:document-text-outline" |
@@ -138,13 +138,90 @@ | @@ -138,13 +138,90 @@ | ||
138 | }); | 138 | }); |
139 | } | 139 | } |
140 | 140 | ||
141 | + const cipherLength = 7; | ||
142 | + | ||
143 | + //字符串星号替代 | ||
144 | + function parseStringToStar(originalStr: string, startLength: number, endLength: number) { | ||
145 | + //字符串大于7位,前3后4明文,其他以星号替代 | ||
146 | + //字符串小于7位,前1后1明文,其他以星号替代 | ||
147 | + return originalStr?.length > startLength | ||
148 | + ? originalStr?.substr(0, startLength) + | ||
149 | + new Array(originalStr?.length - endLength)?.join('*') + | ||
150 | + originalStr?.substr(-endLength) | ||
151 | + : originalStr; | ||
152 | + } | ||
153 | + | ||
154 | + //长度 都大于或者小于7或者其中一个大于7,一个小于7个字符的处理 | ||
155 | + //二维数组优化if else if else | ||
156 | + const mapConditionConfig = [ | ||
157 | + [ | ||
158 | + (startParam, endParam) => | ||
159 | + String(startParam)?.length > cipherLength && String(endParam)?.length > cipherLength, | ||
160 | + (startParam) => parseStringToStar(startParam, 3, 4), | ||
161 | + (endParam) => parseStringToStar(endParam, 3, 4), | ||
162 | + ], | ||
163 | + [ | ||
164 | + (startParam, endParam) => | ||
165 | + String(startParam)?.length < cipherLength && String(endParam)?.length < cipherLength, | ||
166 | + (startParam) => parseStringToStar(startParam, 1, 1), | ||
167 | + (endParam) => parseStringToStar(endParam, 1, 1), | ||
168 | + ], | ||
169 | + [ | ||
170 | + (startParam, endParam) => | ||
171 | + String(startParam)?.length > cipherLength || String(endParam)?.length < cipherLength, | ||
172 | + (startParam) => parseStringToStar(startParam, 3, 4), | ||
173 | + (endParam) => parseStringToStar(endParam, 1, 1), | ||
174 | + ], | ||
175 | + [ | ||
176 | + (startParam, endParam) => | ||
177 | + String(startParam)?.length < cipherLength || String(endParam)?.length > cipherLength, | ||
178 | + (startParam) => parseStringToStar(startParam, 1, 1), | ||
179 | + (endParam) => parseStringToStar(endParam, 3, 4), | ||
180 | + ], | ||
181 | + ]; | ||
182 | + | ||
183 | + const handleStandardLength = ( | ||
184 | + startKey: string, | ||
185 | + endKey: string, | ||
186 | + startParam: string, | ||
187 | + endParam: string | ||
188 | + ) => { | ||
189 | + const findDateFlow: any = mapConditionConfig.find((item: Function[]) => | ||
190 | + item[0](startParam, endParam) | ||
191 | + ); | ||
192 | + if (!findDateFlow) return; | ||
193 | + const cipherData: Recordable = {}; | ||
194 | + cipherData[startKey] = findDateFlow[1](startParam); | ||
195 | + cipherData[endKey] = findDateFlow[2](endParam); | ||
196 | + return cipherData; | ||
197 | + }; | ||
198 | + | ||
199 | + const handleCipherTextConfig = (e) => { | ||
200 | + /** | ||
201 | + * username和password 存在则是邮件配置 | ||
202 | + * secretId和secretKey 存在则是腾讯云配置信息 | ||
203 | + * accessKeyId和accessKeySecret 存在则是阿里云配置信息 | ||
204 | + */ | ||
205 | + const { username, password, secretId, secretKey, accessKeyId, accessKeySecret } = e; | ||
206 | + return JSON.parse( | ||
207 | + JSON.stringify({ | ||
208 | + ...e, | ||
209 | + ...handleStandardLength('username', 'password', username, password), | ||
210 | + ...handleStandardLength('secretId', 'secretKey', secretId, secretKey), | ||
211 | + ...handleStandardLength('accessKeyId', 'accessKeySecret', accessKeyId, accessKeySecret), | ||
212 | + }) | ||
213 | + ); | ||
214 | + }; | ||
215 | + | ||
141 | function showData(record: Recordable) { | 216 | function showData(record: Recordable) { |
142 | Modal.info({ | 217 | Modal.info({ |
143 | title: '当前配置', | 218 | title: '当前配置', |
144 | width: 600, | 219 | width: 600, |
145 | centered: true, | 220 | centered: true, |
146 | maskClosable: true, | 221 | maskClosable: true, |
147 | - content: h(JsonPreview, { data: JSON.parse(JSON.stringify(record.config)) }), | 222 | + content: h(JsonPreview, { |
223 | + data: handleCipherTextConfig(record.config), | ||
224 | + }), | ||
148 | }); | 225 | }); |
149 | } | 226 | } |
150 | const statusChange = async (checked, record) => { | 227 | const statusChange = async (checked, record) => { |