fix: 员工端Header标题显示企业名称而非安职通Logo
- 后端3处登录接口(密码/验证码/auto-login)返回 orgName - 前端 PortalLayout Header 改为显示 employee.orgName - 移除 Logo 组件引用
This commit is contained in:
@@ -40,7 +40,7 @@ router.post('/login', async (req, res, next) => {
|
||||
// 查找所有匹配手机号的在职员工(可能跨组织)
|
||||
const employees = await prisma.employee.findMany({
|
||||
where: { phone: data.phone, status: 'ACTIVE' },
|
||||
select: { id: true, name: true, department: true, orgId: true, passwordHash: true },
|
||||
select: { id: true, name: true, department: true, orgId: true, passwordHash: true, org: { select: { name: true } } },
|
||||
})
|
||||
if (employees.length === 0) {
|
||||
return res.status(400).json({ success: false, error: { code: 'AUTH_FAILED', message: '手机号或密码错误' } })
|
||||
@@ -60,7 +60,7 @@ router.post('/login', async (req, res, next) => {
|
||||
return res.status(400).json({ success: false, error: { code: 'AUTH_FAILED', message: '手机号或密码错误' } })
|
||||
}
|
||||
const token = signAccessToken({ id: matchedEmployee.id, orgId: matchedEmployee.orgId, role: 'EMPLOYEE' })
|
||||
res.json({ success: true, data: { token, employee: { id: matchedEmployee.id, name: matchedEmployee.name, department: matchedEmployee.department } } })
|
||||
res.json({ success: true, data: { token, employee: { id: matchedEmployee.id, name: matchedEmployee.name, department: matchedEmployee.department, orgName: (matchedEmployee as any).org?.name || '' } } })
|
||||
} catch (err) {
|
||||
next(err)
|
||||
}
|
||||
@@ -110,7 +110,7 @@ router.post('/verify-code', async (req, res, next) => {
|
||||
// 查找所有匹配手机号的在职员工(可能跨组织)
|
||||
const employees = await prisma.employee.findMany({
|
||||
where: { phone: data.phone, status: 'ACTIVE' },
|
||||
select: { id: true, name: true, department: true, orgId: true },
|
||||
select: { id: true, name: true, department: true, orgId: true, org: { select: { name: true } } },
|
||||
})
|
||||
if (employees.length === 0) {
|
||||
return res.status(400).json({ success: false, error: { code: 'NOT_FOUND', message: '员工不存在' } })
|
||||
@@ -118,7 +118,7 @@ router.post('/verify-code', async (req, res, next) => {
|
||||
// 如果只有一个匹配,直接登录
|
||||
const employee = employees[0]
|
||||
const token = signAccessToken({ id: employee.id, orgId: employee.orgId, role: 'EMPLOYEE' })
|
||||
res.json({ success: true, data: { token, employee: { id: employee.id, name: employee.name, department: employee.department } } })
|
||||
res.json({ success: true, data: { token, employee: { id: employee.id, name: employee.name, department: employee.department, orgName: (employee as any).org?.name || '' } } })
|
||||
} catch (err) {
|
||||
next(err)
|
||||
}
|
||||
@@ -694,13 +694,13 @@ router.get('/auto-login', async (req, res, next) => {
|
||||
}
|
||||
const employee = await prisma.employee.findFirst({
|
||||
where: { id: payload.id, orgId: payload.orgId, status: 'ACTIVE' },
|
||||
select: { id: true, name: true, department: true, orgId: true },
|
||||
select: { id: true, name: true, department: true, orgId: true, org: { select: { name: true } } },
|
||||
})
|
||||
if (!employee) {
|
||||
return res.status(404).json({ success: false, error: { code: 'NOT_FOUND', message: '员工不存在或已离职' } })
|
||||
}
|
||||
const accessToken = signAccessToken({ id: employee.id, orgId: employee.orgId, role: 'EMPLOYEE' })
|
||||
res.json({ success: true, data: { token: accessToken, employee: { id: employee.id, name: employee.name, department: employee.department } } })
|
||||
res.json({ success: true, data: { token: accessToken, employee: { id: employee.id, name: employee.name, department: employee.department, orgName: (employee as any).org?.name || '' } } })
|
||||
} catch (err) {
|
||||
next(err)
|
||||
}
|
||||
|
||||
@@ -5,7 +5,6 @@
|
||||
|
||||
import { Link, useLocation, useNavigate } from 'react-router-dom'
|
||||
import { DollarSign, FileText, ScrollText, LogOut, CalendarCheck, Home } from 'lucide-react'
|
||||
import Logo from '../../components/ui/Logo'
|
||||
|
||||
const tabItems = [
|
||||
{ path: '/portal/home', label: '首页', icon: Home },
|
||||
@@ -34,9 +33,8 @@ export default function PortalLayout({ children }: { children: React.ReactNode }
|
||||
{/* 顶部 Header — 安全区 padding 适配刘海屏 */}
|
||||
<header className="sticky top-0 z-30 bg-white border-b border-gray-200 pt-safe">
|
||||
<div className="max-w-md mx-auto h-14 flex items-center justify-between px-4">
|
||||
<div className="flex items-center gap-2 min-w-0">
|
||||
<Logo className="w-6 h-6 object-contain flex-shrink-0" />
|
||||
<span className="text-sm font-bold text-gray-900 truncate">安职通</span>
|
||||
<div className="flex items-center min-w-0">
|
||||
<span className="text-sm font-bold text-gray-900 truncate">{employee.orgName || '安职通'}</span>
|
||||
</div>
|
||||
<div className="flex items-center gap-2 flex-shrink-0">
|
||||
{employee.name && (
|
||||
|
||||
Reference in New Issue
Block a user