修复修改密码弹窗&取消后台显示客服弹窗 & 取消退出登录profile为空抛异常的判断
This commit is contained in:
3
.vscode/settings.json
vendored
3
.vscode/settings.json
vendored
@@ -7,4 +7,7 @@
|
|||||||
"[json]": {
|
"[json]": {
|
||||||
"editor.defaultFormatter": "vscode.json-language-features"
|
"editor.defaultFormatter": "vscode.json-language-features"
|
||||||
},
|
},
|
||||||
|
"[typescriptreact]": {
|
||||||
|
"editor.defaultFormatter": "dbaeumer.vscode-eslint"
|
||||||
|
},
|
||||||
}
|
}
|
||||||
@@ -1,6 +1,7 @@
|
|||||||
import {ReactNode} from 'react'
|
import {ReactNode} from 'react'
|
||||||
import Header from './header'
|
import Header from './header'
|
||||||
import Footer from './footer'
|
import Footer from './footer'
|
||||||
|
import Script from 'next/script'
|
||||||
|
|
||||||
export type HomeLayoutProps = {
|
export type HomeLayoutProps = {
|
||||||
children: ReactNode
|
children: ReactNode
|
||||||
@@ -17,6 +18,8 @@ export default function HomeLayout(props: HomeLayoutProps) {
|
|||||||
|
|
||||||
{/* 页脚 */}
|
{/* 页脚 */}
|
||||||
<Footer/>
|
<Footer/>
|
||||||
|
|
||||||
|
<Script id="qd2852138148beb7882a4a6a3e5ff5b569436003e7dc" src="https://wp.qiye.qq.com/qidian/2852138148/beb7882a4a6a3e5ff5b569436003e7dc" async defer></Script>
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -75,19 +75,19 @@ export function Content(props: {children: ReactNode}) {
|
|||||||
}
|
}
|
||||||
function ContentResolved() {
|
function ContentResolved() {
|
||||||
const profile = use(useProfileStore(store => store.profile))
|
const profile = use(useProfileStore(store => store.profile))
|
||||||
if (!profile) throw new Error('登录状态异常')
|
if (profile)
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<RealnameAuthDialog
|
<RealnameAuthDialog
|
||||||
triggerClassName="hidden"
|
triggerClassName="hidden"
|
||||||
defaultOpen={!profile.id_token}
|
defaultOpen={!profile.id_token}
|
||||||
/>
|
/>
|
||||||
<ChangePasswordDialog
|
<ChangePasswordDialog
|
||||||
triggerClassName="hidden"
|
triggerClassName="hidden"
|
||||||
defaultOpen={!profile.has_password}
|
defaultOpen={!profile.has_password}
|
||||||
/>
|
/>
|
||||||
</>
|
</>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
export function Header() {
|
export function Header() {
|
||||||
@@ -127,8 +127,7 @@ export function Header() {
|
|||||||
|
|
||||||
function HeaderUserCenter() {
|
function HeaderUserCenter() {
|
||||||
const profile = use(useProfileStore(store => store.profile))
|
const profile = use(useProfileStore(store => store.profile))
|
||||||
if (!profile) throw new Error('登录状态异常')
|
if (profile) return <UserCenter profile={profile}/>
|
||||||
return <UserCenter profile={profile}/>
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export function Navbar() {
|
export function Navbar() {
|
||||||
|
|||||||
@@ -25,7 +25,6 @@ export default async function RootLayout(props: Readonly<{
|
|||||||
<Effects>{props.children}</Effects>
|
<Effects>{props.children}</Effects>
|
||||||
</StoreProviders>
|
</StoreProviders>
|
||||||
<Toaster position="top-center" richColors expand/>
|
<Toaster position="top-center" richColors expand/>
|
||||||
<Script id="qd2852138148beb7882a4a6a3e5ff5b569436003e7dc" src="https://wp.qiye.qq.com/qidian/2852138148/beb7882a4a6a3e5ff5b569436003e7dc" async defer></Script>
|
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -68,7 +68,7 @@ export function ChangePasswordDialog({
|
|||||||
})
|
})
|
||||||
|
|
||||||
// 提交处理
|
// 提交处理
|
||||||
const handler = form.handleSubmit(async (value) => {
|
const handler = async (value: Schema) => {
|
||||||
try {
|
try {
|
||||||
const resp = await updatePassword({
|
const resp = await updatePassword({
|
||||||
phone: value.phone,
|
phone: value.phone,
|
||||||
@@ -90,7 +90,7 @@ export function ChangePasswordDialog({
|
|||||||
description: e instanceof Error ? e.message : String(e),
|
description: e instanceof Error ? e.message : String(e),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
})
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Dialog open={actualOpen} onOpenChange={actualOnOpenChange}>
|
<Dialog open={actualOpen} onOpenChange={actualOnOpenChange}>
|
||||||
@@ -98,10 +98,16 @@ export function ChangePasswordDialog({
|
|||||||
<Button theme="outline" className={triggerClassName || 'w-24 h-9'}>修改密码</Button>
|
<Button theme="outline" className={triggerClassName || 'w-24 h-9'}>修改密码</Button>
|
||||||
</DialogTrigger>
|
</DialogTrigger>
|
||||||
<DialogContent>
|
<DialogContent>
|
||||||
<DialogHeader>
|
<Form
|
||||||
<DialogTitle>修改密码</DialogTitle>
|
form={form}
|
||||||
</DialogHeader>
|
handler={async () => {
|
||||||
<Form form={form} handler={handler} className="flex flex-col gap-4 mt-4">
|
const data = form.getValues()
|
||||||
|
await handler(data)
|
||||||
|
}}
|
||||||
|
className="flex flex-col gap-4 mt-4">
|
||||||
|
<DialogHeader>
|
||||||
|
<DialogTitle>修改密码</DialogTitle>
|
||||||
|
</DialogHeader>
|
||||||
{/* 手机号输入 */}
|
{/* 手机号输入 */}
|
||||||
<FormField<Schema> name="phone" label="手机号" className="flex-auto">
|
<FormField<Schema> name="phone" label="手机号" className="flex-auto">
|
||||||
{({field}) => (
|
{({field}) => (
|
||||||
@@ -132,22 +138,20 @@ export function ChangePasswordDialog({
|
|||||||
<Input {...field} placeholder="请再次输入新密码" type="password" autoComplete="new-password"/>
|
<Input {...field} placeholder="请再次输入新密码" type="password" autoComplete="new-password"/>
|
||||||
)}
|
)}
|
||||||
</FormField>
|
</FormField>
|
||||||
</Form>
|
|
||||||
|
|
||||||
<DialogFooter>
|
<DialogFooter>
|
||||||
<Button
|
<Button
|
||||||
theme="outline"
|
theme="outline"
|
||||||
type="button"
|
type="button"
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
actualOnOpenChange(false)
|
actualOnOpenChange(false)
|
||||||
form.reset()
|
form.reset()
|
||||||
}}>
|
}}>
|
||||||
关闭
|
关闭
|
||||||
</Button>
|
</Button>
|
||||||
<Button onClick={handler}>
|
<Button type="submit">保存</Button>
|
||||||
保存
|
</DialogFooter>
|
||||||
</Button>
|
</Form>
|
||||||
</DialogFooter>
|
|
||||||
</DialogContent>
|
</DialogContent>
|
||||||
</Dialog>
|
</Dialog>
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user