feat(web): 创作者审核页支持开号/重置密码;登录落地按角色分流 + 首登强制改密
为什么:后台能开号了,但界面还没有入口;而且创作者登录后会落到 /dashboard/index(他没有运营后台权限) 直接掉 404。这批把开号入口、一次性凭据展示、落地分流与首登改密一次补齐。 - 创作者入驻页:「新增创作者」按钮(名称/类型/联系人/邮箱/国家)、「账号」列(已开通/未开通)、 行内「开通账号 / 重置密码」;密码一次性弹窗展示(等宽可选中 + 一键复制 + 提示只显示这一次) - 落地分流:新增 landingPath()(取账号能进的第一个菜单),登录与访问根路径都走它 —— 创作者落 /creator-center/workspace,超管第一条仍是工作台(行为不变) - 首登强制改密:Layout 挂 MustChangePasswordDialog,登录或刷新后若 profile 带 mustChangePassword 就弹不可关闭的 改密框,改完清标记;只能改密或退出登录
This commit is contained in:
1 parent
bac070b60b
commit
8ce43ccd4c
10 files changed
+378
-7
No files matched your search
@@ -1,6 +1,13 @@
|
||||
import { onMounted, reactive, ref } from 'vue'
|
||||
import { ElMessage, ElMessageBox } from 'element-plus'
|
||||
import { auditCreatorApi, listCreatorDocumentsApi, pageCreatorsApi } from '@/api/admin/creator'
|
||||
import {
|
||||
auditCreatorApi,
|
||||
createCreatorApi,
|
||||
listCreatorDocumentsApi,
|
||||
openCreatorAccountApi,
|
||||
pageCreatorsApi,
|
||||
resetCreatorPasswordApi
|
||||
} from '@/api/admin/creator'
|
||||
|
||||
/** 与后端 CreatorService 的状态取值保持一致 */
|
||||
export const CREATOR_STATUS = [
|
||||
@@ -138,6 +145,97 @@ export function useCreatorAudit() {
|
||||
|
||||
onMounted(load)
|
||||
|
||||
// ---------- 手工录入创作者主体 ----------
|
||||
const createVisible = ref(false)
|
||||
const createSaving = ref(false)
|
||||
const createForm = reactive({
|
||||
name: '',
|
||||
type: 'COMPANY',
|
||||
contactName: '',
|
||||
contactEmail: '',
|
||||
countryCode: 'ID'
|
||||
})
|
||||
|
||||
function openCreate() {
|
||||
Object.assign(createForm, {
|
||||
name: '',
|
||||
type: 'COMPANY',
|
||||
contactName: '',
|
||||
contactEmail: '',
|
||||
countryCode: 'ID'
|
||||
})
|
||||
createVisible.value = true
|
||||
}
|
||||
|
||||
async function confirmCreate() {
|
||||
if (!createForm.name.trim()) return ElMessage.warning('请填写创作者名称')
|
||||
createSaving.value = true
|
||||
try {
|
||||
await createCreatorApi({ ...createForm, name: createForm.name.trim() })
|
||||
ElMessage.success('已录入,待入驻审核通过后才能开通账号')
|
||||
createVisible.value = false
|
||||
await load()
|
||||
} finally {
|
||||
createSaving.value = false
|
||||
}
|
||||
}
|
||||
|
||||
// ---------- 开通账号 / 重置密码 ----------
|
||||
const accountVisible = ref(false)
|
||||
const accountSaving = ref(false)
|
||||
/** 一次性凭据展示:password 只在开通 / 重置那一次有值 */
|
||||
const accountResult = ref(null)
|
||||
|
||||
async function openAccount(row) {
|
||||
accountSaving.value = true
|
||||
try {
|
||||
const res = await openCreatorAccountApi(row.id)
|
||||
accountResult.value = res.data || null
|
||||
accountVisible.value = true
|
||||
await load()
|
||||
} finally {
|
||||
accountSaving.value = false
|
||||
}
|
||||
}
|
||||
|
||||
async function resetPassword(row) {
|
||||
try {
|
||||
await ElMessageBox.confirm(
|
||||
`重置后「${row.name}」的旧密码立即失效,需要把新密码重新转达给他。确认重置?`,
|
||||
'重置账号密码',
|
||||
{ confirmButtonText: '确认重置', cancelButtonText: '取消', type: 'warning' }
|
||||
)
|
||||
} catch {
|
||||
return
|
||||
}
|
||||
accountSaving.value = true
|
||||
try {
|
||||
const res = await resetCreatorPasswordApi(row.id)
|
||||
accountResult.value = res.data || null
|
||||
accountVisible.value = true
|
||||
} finally {
|
||||
accountSaving.value = false
|
||||
}
|
||||
}
|
||||
|
||||
/** 一次性密码要能被复制走;复制完由运营自己销毁截图 */
|
||||
async function copyCredential() {
|
||||
const item = accountResult.value
|
||||
if (!item?.password) return
|
||||
const text = `登录地址:${window.location.origin}/#/login\n账号:${item.username}\n初始密码:${item.password}`
|
||||
try {
|
||||
await navigator.clipboard.writeText(text)
|
||||
ElMessage.success('账号与密码已复制')
|
||||
} catch {
|
||||
ElMessage.warning('浏览器不允许自动复制,请手动选中复制')
|
||||
}
|
||||
}
|
||||
|
||||
function closeAccount() {
|
||||
accountVisible.value = false
|
||||
accountResult.value = null
|
||||
}
|
||||
|
||||
return {
|
||||
rows,
|
||||
total,
|
||||
@@ -162,6 +260,18 @@ export function useCreatorAudit() {
|
||||
openDocuments,
|
||||
openAudit,
|
||||
confirmAudit,
|
||||
freeze
|
||||
freeze,
|
||||
createVisible,
|
||||
createSaving,
|
||||
createForm,
|
||||
openCreate,
|
||||
confirmCreate,
|
||||
accountVisible,
|
||||
accountSaving,
|
||||
accountResult,
|
||||
openAccount,
|
||||
resetPassword,
|
||||
copyCredential,
|
||||
closeAccount
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user