Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: login auth bugs #29

Merged
merged 1 commit into from
Feb 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added public/404/404.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
34 changes: 34 additions & 0 deletions src/app/not-found.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
'use client';

import { Button } from 'antd';
import { useRouter } from 'next/navigation';
import * as React from 'react';

import { useStyles } from '../styles/not-found-styles';

const NotFound = () => {
const { styles } = useStyles();
const router = useRouter();
return (
<div className={styles.wrapper404}>
<div className={styles.content}>
<div className={styles.imgBg}></div>
<div className={styles.text}>很抱歉,页面不小心迷路了</div>
<div className={styles.btn}>
<Button
ghost
onClick={() => {
router.push('/chat');
}}
size="large"
type="primary"
>
返回首页
</Button>
</div>
</div>
</div>
);
};

export default NotFound;
22 changes: 11 additions & 11 deletions src/app/setting/SettingClient/BtnList/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -70,18 +70,18 @@ const SettingBtnList = React.memo<any>(() => {
installPrompt.prompt();

// 等待用户做出选择
installPrompt.userChoice.then(choiceResult => {
if (choiceResult.outcome === 'accepted') {
console.warn('用户接受了安装应用');
// 在这里你可以执行接受安装后的额外逻辑
} else {
console.warn('用户拒绝了安装应用');
// 在这里你可以执行拒绝安装后的额外逻辑
}
installPrompt.userChoice.then(
(choiceResult: { outcome: 'accepted' | 'dismissed'; platform: string }) => {
if (choiceResult.outcome === 'accepted') {
// console.warn('用户接受了安装应用');
} else {
// console.warn('用户拒绝了安装应用');
}

// 清除 installPrompt,因为它不能被重用
// setInstallPrompt(null);
});
// 清除 installPrompt,因为它不能被重用
// setInstallPrompt(null);
}
);
}
},
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ interface SettingProps {
userData?: GetCurrentUserQuery;
}

const Setting = React.memo<SettingProps>(({ userData }) => {
const Setting = React.memo<SettingProps>(() => {
const { styles } = useStyles();
const { data } = sdk.useGetCurrentUser(undefined, { fallbackData: userData });
const { data } = sdk.useGetCurrentUser();
return (
<div className={styles.setting}>
<div>
Expand Down
22 changes: 11 additions & 11 deletions src/app/setting/page.tsx
Original file line number Diff line number Diff line change
@@ -1,27 +1,27 @@
import { sdk } from '@tenx-ui/bff-client';
// import { sdk } from '@tenx-ui/bff-client';
import type { Metadata } from 'next';
import React from 'react';

import SettingClient from './SettingClient/Index';
import SettingClient from './SettingClient';

export const metadata: Metadata = {
title: '个人设置',
};

export default async function DesktopPage() {
export default async function SettingPage() {
// swr SSR example, will be removed in the future
// see https://github.com/vercel/swr/blob/main/examples/server-render/pages/index.js
const userData = await sdk
.getCurrentUser(undefined, {
Authorization: 'bearer <id_token>',
})
.catch(error => {
console.warn('getCurrentUser failed', error);
});
// const userData = await sdk
// .getCurrentUser(undefined, {
// Authorization: 'bearer <id_token>',
// })
// .catch(error => {
// console.warn('getCurrentUser failed', error);
// });

return (
<>
<SettingClient userData={userData!} />
<SettingClient />
</>
);
}
2 changes: 1 addition & 1 deletion src/app/setting/user-info/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import React from 'react';
import { getUserData } from '../../actions/user';
import UserInfoClient from './UserInfoClient';

export default async function DesktopPage() {
export default async function UserinfoPage() {
const user = await getUserData();
const props = {
user,
Expand Down
1 change: 0 additions & 1 deletion src/layout/AppLayout/SideBar/Chats/styles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import { createStyles } from 'antd-style';
export const useStyles = createStyles(() => ({
chats: {
position: 'relative',
overflowY: 'auto',
flex: '1 1 0%',
},
content: {
Expand Down
5 changes: 4 additions & 1 deletion src/layout/AppLayout/SideBar/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,11 @@ import UserInfoBottom from './UserInfoBottom';
import { useStyles } from './styles';

export default function SideBar() {
const { styles } = useStyles();
const pathname: any = usePathname();
const { styles } = useStyles();
const is_no_sidebar_route =
pathname.startsWith('/oidc/') || ['/oidc', '/logout'].includes(pathname);
if (is_no_sidebar_route) return <></>;
const showSidebar = ['/chat'].includes(pathname);
return (
<div className={classNames(styles.sidebar, showSidebar ? '' : 'hide_sidebar')}>
Expand Down
2 changes: 2 additions & 0 deletions src/layout/AppLayout/SideBar/styles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,13 @@ export const useStyles = createStyles(({ token }) => ({
'[dir="ltr"] &': {
left: 0,
borderRight: '1px solid',
zIndex: 9,
},

'[dir="rtl"] &': {
right: 0,
borderLeft: '1px solid',
zIndex: 9,
},

'&': {
Expand Down
42 changes: 42 additions & 0 deletions src/styles/not-found-styles.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import { createStyles } from 'antd-style';

export const useStyles = createStyles(() => {
return {
wrapper404: {
height: '100vh',
width: '100vw',
position: 'relative',
},

content: {
position: 'absolute',
top: '50%',
left: '50%',
transform: 'translate(-50%, -50%)',
textAlign: 'center',
},

imgBg: {
backgroundImage: 'url(/404/404.png)',
height: '420px',
width: '500px',
maxWidth: '100vw',
backgroundRepeat: 'no-repeat',
backgroundPosition: 'center',
marginBottom: '24px',
},

text: {
fontSize: '24px',
marginBottom: '24px',
},
btn: {
'.ant-btn': {
paddingLeft: '30px',
paddingRight: '30px',
fontSize: '16px',
height: 'auto',
},
},
};
});
Loading