提交
This commit is contained in:
1 parent
b9b4cc2673
commit
4928e00423
28 files changed
+12299
-11102
No files matched your search
@@ -185,9 +185,9 @@ export function fetchDeleteUser(id: string) {
|
||||
}
|
||||
|
||||
export function fetchResetPassword(id: string) {
|
||||
return request.post({
|
||||
return request.post<{ tempPassword: string }>({
|
||||
url: `/web/admin/users/${id}/reset-password`,
|
||||
showSuccessMessage: true
|
||||
showSuccessMessage: false
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@@ -164,7 +164,7 @@ export function fetchRefreshToken(refreshToken: string) {
|
||||
expiresIn: number
|
||||
}>({
|
||||
url: '/web/auth/refresh-token',
|
||||
params: { refreshToken }
|
||||
data: { refreshToken }
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@@ -153,7 +153,7 @@
|
||||
<span>详情内容</span>
|
||||
</div>
|
||||
<div class="content-editor-section">
|
||||
<div class="view-content-html" v-html="formData.detailContent || ''"></div>
|
||||
<div class="view-content-html" v-html="safeDetailContent"></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -301,6 +301,7 @@
|
||||
import { computed, reactive, ref, watch } from 'vue'
|
||||
import { Close, Document, Money, Picture, Setting, VideoPlay } from '@element-plus/icons-vue'
|
||||
import { buildTreePathLabelFromFlat } from '@/utils/tree-path'
|
||||
import { sanitizeHtml } from '@/utils/sanitize-html'
|
||||
import {
|
||||
fetchProductDetail,
|
||||
fetchCategoryList,
|
||||
@@ -356,6 +357,8 @@
|
||||
detailContent: ''
|
||||
})
|
||||
|
||||
const safeDetailContent = computed(() => sanitizeHtml(formData.detailContent))
|
||||
|
||||
const isCategoryEnabled = (c: any) => {
|
||||
const v = c?.isActive ?? c?.is_active
|
||||
return v === true || v === 1
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
import DOMPurify from 'dompurify'
|
||||
|
||||
/**
|
||||
* 消毒富文本 HTML,供 v-html 安全渲染。
|
||||
* 保留常见排版/图片标签,剥离 script、事件属性等。
|
||||
*/
|
||||
export function sanitizeHtml(dirty: string | null | undefined): string {
|
||||
if (!dirty) return ''
|
||||
return DOMPurify.sanitize(String(dirty), {
|
||||
USE_PROFILES: { html: true }
|
||||
})
|
||||
}
|
||||
@@ -303,7 +303,7 @@
|
||||
import { ElMessage, ElMessageBox } from 'element-plus'
|
||||
import { withFullscreenLoading, fullscreenLoadingText } from '@/utils/fullscreen-loading'
|
||||
import { ArrowLeft, Close, Check } from '@element-plus/icons-vue'
|
||||
import { fetchUserDetail, fetchUpdateUser, fetchActiveRegions } from '@/api/admin'
|
||||
import { fetchUserDetail, fetchUpdateUser, fetchActiveRegions, fetchResetPassword } from '@/api/admin'
|
||||
import { resolveUserAvatarUrl } from '@/utils/user-avatar'
|
||||
import { formatMoneyDisplay } from '@/utils/money-format'
|
||||
import type { FormInstance, FormRules } from 'element-plus'
|
||||
@@ -566,7 +566,7 @@
|
||||
const handleResetPassword = async () => {
|
||||
try {
|
||||
await ElMessageBox.confirm(
|
||||
`确定要重置用户「${userData.value.realName}」的密码吗?重置后密码将恢复为默认密码。`,
|
||||
`确定要重置用户「${userData.value.realName}」的密码吗?将生成随机临时密码。`,
|
||||
'重置密码',
|
||||
{
|
||||
confirmButtonText: '确认重置',
|
||||
@@ -574,7 +574,17 @@
|
||||
type: 'warning'
|
||||
}
|
||||
)
|
||||
ElMessage.success('密码已重置,默认密码为:123456')
|
||||
const res = await fetchResetPassword(String(route.params.id || userData.value.id || ''))
|
||||
const tempPassword = res?.tempPassword || ''
|
||||
if (tempPassword) {
|
||||
await ElMessageBox.alert(
|
||||
`临时密码:${tempPassword}\n请立即告知用户,并督促其登录后修改密码。`,
|
||||
'密码已重置',
|
||||
{ confirmButtonText: '已知晓', type: 'success' }
|
||||
)
|
||||
} else {
|
||||
ElMessage.success('密码重置成功')
|
||||
}
|
||||
} catch (error) {
|
||||
// 取消操作
|
||||
}
|
||||
|
||||
@@ -821,11 +821,22 @@
|
||||
}
|
||||
|
||||
async function handleRowResetPwd(row: Api.User.UserItem) {
|
||||
await ElMessageBox.confirm(`确定将用户「${row.nickName}」的密码重置为 111111 吗?`, '提示', {
|
||||
type: 'warning'
|
||||
})
|
||||
await fetchResetPassword(row.id)
|
||||
ElMessage.success('密码重置成功')
|
||||
await ElMessageBox.confirm(
|
||||
`确定重置用户「${row.nickName}」的密码吗?将生成随机临时密码,请妥善告知用户。`,
|
||||
'提示',
|
||||
{ type: 'warning' }
|
||||
)
|
||||
const res = await fetchResetPassword(row.id)
|
||||
const tempPassword = res?.tempPassword || ''
|
||||
if (tempPassword) {
|
||||
await ElMessageBox.alert(
|
||||
`临时密码:${tempPassword}\n请立即告知用户,并督促其登录后修改密码。`,
|
||||
'密码已重置',
|
||||
{ confirmButtonText: '已复制/已知晓', type: 'success' }
|
||||
)
|
||||
} else {
|
||||
ElMessage.success('密码重置成功')
|
||||
}
|
||||
}
|
||||
|
||||
function handleDropdownCommand(command: string, row: Api.User.UserItem) {
|
||||
@@ -869,14 +880,26 @@
|
||||
}
|
||||
const message =
|
||||
rows.length === 1
|
||||
? `确定将用户「${rows[0].nickName}」的密码重置为 111111 吗?`
|
||||
: `确定将选中的 ${rows.length} 个用户的密码重置为 111111 吗?`
|
||||
? `确定重置用户「${rows[0].nickName}」的密码吗?将生成随机临时密码。`
|
||||
: `确定将选中的 ${rows.length} 个用户密码重置为随机临时密码吗?`
|
||||
await ElMessageBox.confirm(message, '提示', { type: 'warning' })
|
||||
const results: string[] = []
|
||||
for (const row of rows) {
|
||||
await fetchResetPassword(row.id)
|
||||
const res = await fetchResetPassword(row.id)
|
||||
const tempPassword = res?.tempPassword || ''
|
||||
if (tempPassword) {
|
||||
results.push(`${row.nickName || row.userNo}:${tempPassword}`)
|
||||
}
|
||||
}
|
||||
ElMessage.success('密码重置成功')
|
||||
selectedRows.value = []
|
||||
if (results.length) {
|
||||
await ElMessageBox.alert(results.join('\n'), '密码已重置(请妥善告知用户)', {
|
||||
confirmButtonText: '已知晓',
|
||||
type: 'success'
|
||||
})
|
||||
} else {
|
||||
ElMessage.success('密码重置成功')
|
||||
}
|
||||
}
|
||||
|
||||
// ---- 查看弹窗 ----
|
||||
|
||||
Reference in new issue
Block a user