update 优化 后端导入返回信息使用\n分割 避免前端出现xss问题
This commit is contained in:
@@ -152,9 +152,7 @@ const handleRegister = () => {
|
|||||||
const [err] = await to(register(registerForm.value));
|
const [err] = await to(register(registerForm.value));
|
||||||
if (!err) {
|
if (!err) {
|
||||||
const username = registerForm.value.username;
|
const username = registerForm.value.username;
|
||||||
await ElMessageBox.alert('<span style="color: red; ">' + t('register.registerSuccess', { username }) + '</font>', '系统提示', {
|
await ElMessageBox.alert(t('register.registerSuccess', { username }), '系统提示', {
|
||||||
app: undefined,
|
|
||||||
dangerouslyUseHTMLString: true,
|
|
||||||
type: 'success'
|
type: 'success'
|
||||||
});
|
});
|
||||||
await router.push('/login');
|
await router.push('/login');
|
||||||
|
|||||||
@@ -596,13 +596,21 @@ const importTemplate = () => {
|
|||||||
const handleFileUploadProgress = () => {
|
const handleFileUploadProgress = () => {
|
||||||
upload.isUploading = true;
|
upload.isUploading = true;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const formatImportResultMessage = (message: unknown) => {
|
||||||
|
return String(message ?? '')
|
||||||
|
.replace(/<br\s*\/?>/gi, '\n')
|
||||||
|
.replace(/ /gi, ' ')
|
||||||
|
.replace(/<[^>]+>/g, '');
|
||||||
|
};
|
||||||
|
|
||||||
/** 文件上传成功处理 */
|
/** 文件上传成功处理 */
|
||||||
const handleFileSuccess = (response: any, file: UploadFile) => {
|
const handleFileSuccess = (response: any, file: UploadFile) => {
|
||||||
upload.open = false;
|
upload.open = false;
|
||||||
upload.isUploading = false;
|
upload.isUploading = false;
|
||||||
uploadRef.value?.handleRemove(file);
|
uploadRef.value?.handleRemove(file);
|
||||||
ElMessageBox.alert("<div style='overflow: auto;overflow-x: hidden;max-height: 70vh;padding: 10px 20px 0;'>" + response.msg + '</div>', '导入结果', {
|
ElMessageBox.alert(formatImportResultMessage(response.msg), '导入结果', {
|
||||||
dangerouslyUseHTMLString: true
|
customClass: 'import-result-box'
|
||||||
});
|
});
|
||||||
getList();
|
getList();
|
||||||
};
|
};
|
||||||
@@ -708,4 +716,13 @@ async function handleDeptChange(value: number | string) {
|
|||||||
@use '@/assets/styles/components/page-shell' as pageShell;
|
@use '@/assets/styles/components/page-shell' as pageShell;
|
||||||
|
|
||||||
@include pageShell.tree-table-crud-page;
|
@include pageShell.tree-table-crud-page;
|
||||||
|
|
||||||
|
:global(.import-result-box .el-message-box__message) {
|
||||||
|
max-height: 70vh;
|
||||||
|
overflow-y: auto;
|
||||||
|
overflow-x: hidden;
|
||||||
|
padding: 10px 20px 0;
|
||||||
|
white-space: pre-wrap;
|
||||||
|
word-break: break-word;
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
Reference in New Issue
Block a user