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
@@ -0,0 +1,80 @@
|
||||
<script setup>
|
||||
import { computed, reactive, ref } from 'vue'
|
||||
import { ElMessage } from 'element-plus'
|
||||
import { changePasswordApi } from '@/api/login'
|
||||
import { useUserStore } from '@/store/modules/user'
|
||||
|
||||
/**
|
||||
* 首登强制改密:后台开号 / 重置密码时置的标记,登录(或刷新)后必须先把密码改掉。
|
||||
* 对话框不可关闭,只能改密或退出登录 —— 初始密码是运营转达的,越早换掉越好。
|
||||
*/
|
||||
const userStore = useUserStore()
|
||||
const visible = computed(() => Boolean(userStore.getUserInfo?.mustChangePassword))
|
||||
const form = reactive({ oldPassword: '', newPassword: '', confirmPassword: '' })
|
||||
const saving = ref(false)
|
||||
|
||||
async function submit() {
|
||||
if (!form.oldPassword) return ElMessage.warning('请输入当前密码(运营给你的初始密码)')
|
||||
if (!form.newPassword || form.newPassword.length < 8) return ElMessage.warning('新密码至少 8 位')
|
||||
if (form.newPassword !== form.confirmPassword) return ElMessage.warning('两次输入的新密码不一致')
|
||||
saving.value = true
|
||||
try {
|
||||
await changePasswordApi({
|
||||
oldPassword: form.oldPassword,
|
||||
newPassword: form.newPassword
|
||||
})
|
||||
ElMessage.success('密码已更新')
|
||||
userStore.setUserInfo({ ...userStore.getUserInfo, mustChangePassword: false })
|
||||
form.oldPassword = ''
|
||||
form.newPassword = ''
|
||||
form.confirmPassword = ''
|
||||
} finally {
|
||||
saving.value = false
|
||||
}
|
||||
}
|
||||
|
||||
async function logout() {
|
||||
await userStore.logout()
|
||||
window.location.reload()
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<el-dialog
|
||||
:model-value="visible"
|
||||
title="首次登录请修改密码"
|
||||
width="460px"
|
||||
:show-close="false"
|
||||
:close-on-click-modal="false"
|
||||
:close-on-press-escape="false"
|
||||
>
|
||||
<el-alert
|
||||
class="must-change-alert"
|
||||
type="warning"
|
||||
:closable="false"
|
||||
show-icon
|
||||
title="当前使用的是运营转达的初始密码,请改成只有你知道的密码后再开始使用"
|
||||
/>
|
||||
<el-form label-position="top">
|
||||
<el-form-item label="当前密码(初始密码)" required>
|
||||
<el-input v-model="form.oldPassword" type="password" show-password autocomplete="off" />
|
||||
</el-form-item>
|
||||
<el-form-item label="新密码(至少 8 位)" required>
|
||||
<el-input v-model="form.newPassword" type="password" show-password autocomplete="off" />
|
||||
</el-form-item>
|
||||
<el-form-item label="确认新密码" required>
|
||||
<el-input v-model="form.confirmPassword" type="password" show-password autocomplete="off" />
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<template #footer>
|
||||
<el-button @click="logout">退出登录</el-button>
|
||||
<el-button type="primary" :loading="saving" @click="submit">保存新密码</el-button>
|
||||
</template>
|
||||
</el-dialog>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.must-change-alert {
|
||||
margin-bottom: 14px;
|
||||
}
|
||||
</style>
|
||||
Reference in new issue
Block a user