Compare commits
18 Commits
52b62694c3
..
main
| Author | SHA1 | Date | |
|---|---|---|---|
| e6526b77aa | |||
| 780dbe075b | |||
| edf961eb7b | |||
| 285f4d07bc | |||
| f7fa3a46d2 | |||
| b0c8cfb024 | |||
| f86e3b4725 | |||
| c6a825c284 | |||
| c79de38d54 | |||
| a5b4302ab7 | |||
| 162f8fe040 | |||
| 2e4540095b | |||
| 42cf06c373 | |||
| 97187806e1 | |||
| d92202b6ab | |||
| 4ae7ed783f | |||
| 72bf4fee7c | |||
| daacab613a |
@@ -19,6 +19,7 @@ env:
|
|||||||
TELEGRAM_CHAT_ID: "-4940243803"
|
TELEGRAM_CHAT_ID: "-4940243803"
|
||||||
DOCKER_REGISTRY: registry.kxsw.us
|
DOCKER_REGISTRY: registry.kxsw.us
|
||||||
DOCKER_BUILDKIT: 1
|
DOCKER_BUILDKIT: 1
|
||||||
|
DOCKER_API_VERSION: "1.44"
|
||||||
# Host SSH - 根据分支动态选择
|
# Host SSH - 根据分支动态选择
|
||||||
SSH_HOST: ${{ github.ref_name == 'main' && vars.PRO_SSH_HOST || (github.ref_name == 'dev' && vars.DEV_SSH_HOST || vars.PRO_SSH_HOST) }}
|
SSH_HOST: ${{ github.ref_name == 'main' && vars.PRO_SSH_HOST || (github.ref_name == 'dev' && vars.DEV_SSH_HOST || vars.PRO_SSH_HOST) }}
|
||||||
SSH_PORT: ${{ github.ref_name == 'main' && vars.PRO_SSH_PORT || (github.ref_name == 'dev' && vars.DEV_SSH_PORT || vars.PRO_SSH_PORT) }}
|
SSH_PORT: ${{ github.ref_name == 'main' && vars.PRO_SSH_PORT || (github.ref_name == 'dev' && vars.DEV_SSH_PORT || vars.PRO_SSH_PORT) }}
|
||||||
@@ -97,7 +98,15 @@ jobs:
|
|||||||
echo "Still waiting for locks..."; sleep 5
|
echo "Still waiting for locks..."; sleep 5
|
||||||
done
|
done
|
||||||
apt-get update -y -o Dpkg::Lock::Timeout=600
|
apt-get update -y -o Dpkg::Lock::Timeout=600
|
||||||
apt-get install -y -o Dpkg::Lock::Timeout=600 jq curl ca-certificates docker.io
|
# 基础工具和GPG
|
||||||
|
apt-get install -y -o Dpkg::Lock::Timeout=600 jq curl ca-certificates gnupg
|
||||||
|
# 配置Docker官方源,安装新版CLI与Buildx插件(支持 API 1.44+)
|
||||||
|
install -m 0755 -d /etc/apt/keyrings
|
||||||
|
curl -fsSL https://download.docker.com/linux/debian/gpg | gpg --dearmor -o /etc/apt/keyrings/docker.gpg
|
||||||
|
chmod a+r /etc/apt/keyrings/docker.gpg
|
||||||
|
echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/debian $(. /etc/os-release && echo $VERSION_CODENAME) stable" > /etc/apt/sources.list.d/docker.list
|
||||||
|
apt-get update -y -o Dpkg::Lock::Timeout=600
|
||||||
|
apt-get install -y -o Dpkg::Lock::Timeout=600 docker-ce-cli docker-buildx-plugin
|
||||||
docker --version
|
docker --version
|
||||||
jq --version
|
jq --version
|
||||||
curl --version
|
curl --version
|
||||||
@@ -289,7 +298,23 @@ jobs:
|
|||||||
echo "Decided BUILD_TARGET=$BUILD_TARGET"
|
echo "Decided BUILD_TARGET=$BUILD_TARGET"
|
||||||
|
|
||||||
- name: Read version from package.json
|
- name: Read version from package.json
|
||||||
run: echo "VERSION=$(jq -r .version package.json)" >> $GITHUB_ENV
|
run: |
|
||||||
|
if [ "$BUILD_TARGET" = "admin" ]; then
|
||||||
|
VERSION=$(jq -r .version apps/admin/package.json)
|
||||||
|
echo "使用 admin 应用版本: $VERSION"
|
||||||
|
elif [ "$BUILD_TARGET" = "user" ]; then
|
||||||
|
VERSION=$(jq -r .version apps/user/package.json)
|
||||||
|
echo "使用 user 应用版本: $VERSION"
|
||||||
|
else
|
||||||
|
# both 或其他情况使用根目录版本
|
||||||
|
VERSION=$(jq -r .version package.json)
|
||||||
|
echo "使用根目录版本: $VERSION"
|
||||||
|
fi
|
||||||
|
if [ "$VERSION" = "null" ] || [ -z "$VERSION" ] || [ "$VERSION" = "undefined" ]; then
|
||||||
|
echo "检测到版本为空,回退到根目录版本"
|
||||||
|
VERSION=$(jq -r .version package.json)
|
||||||
|
fi
|
||||||
|
echo "VERSION=$VERSION" >> $GITHUB_ENV
|
||||||
|
|
||||||
- name: 根据分支动态设置API地址
|
- name: 根据分支动态设置API地址
|
||||||
run: |
|
run: |
|
||||||
@@ -549,6 +574,7 @@ jobs:
|
|||||||
|
|
||||||
echo "启动新容器..."
|
echo "启动新容器..."
|
||||||
docker run -d \
|
docker run -d \
|
||||||
|
--add-host api.airoport.co:103.150.215.40 \
|
||||||
--name ppanel-admin-web \
|
--name ppanel-admin-web \
|
||||||
--restart unless-stopped \
|
--restart unless-stopped \
|
||||||
-p 3001:3000 \
|
-p 3001:3000 \
|
||||||
@@ -698,6 +724,7 @@ jobs:
|
|||||||
|
|
||||||
echo "启动新容器..."
|
echo "启动新容器..."
|
||||||
docker run -d \
|
docker run -d \
|
||||||
|
--add-host api.airoport.co:103.150.215.40 \
|
||||||
--name ppanel-user-web \
|
--name ppanel-user-web \
|
||||||
--restart unless-stopped \
|
--restart unless-stopped \
|
||||||
-p 3002:3000 \
|
-p 3002:3000 \
|
||||||
|
|||||||
@@ -8,7 +8,7 @@
|
|||||||
|
|
||||||
This is a PPanel admin web powered by PPanel
|
This is a PPanel admin web powered by PPanel
|
||||||
|
|
||||||
English
|
English ##
|
||||||
·
|
·
|
||||||
[Chinese](./README.zh-CN.md)
|
[Chinese](./README.zh-CN.md)
|
||||||
·
|
·
|
||||||
|
|||||||
@@ -18,7 +18,7 @@
|
|||||||
"axios": "^1.7.9",
|
"axios": "^1.7.9",
|
||||||
"js-yaml": "^4.1.0",
|
"js-yaml": "^4.1.0",
|
||||||
"nanoid": "^5.0.9",
|
"nanoid": "^5.0.9",
|
||||||
"next": "^15.1.4",
|
"next": "15.3.6",
|
||||||
"next-intl": "^3.26.3",
|
"next-intl": "^3.26.3",
|
||||||
"next-runtime-env": "^3.2.2",
|
"next-runtime-env": "^3.2.2",
|
||||||
"next-themes": "^0.4.4",
|
"next-themes": "^0.4.4",
|
||||||
|
|||||||
@@ -179,7 +179,7 @@ export default function Content() {
|
|||||||
variant={'primary'}
|
variant={'primary'}
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
openPopupWindow({
|
openPopupWindow({
|
||||||
download: 'https://aunlock.laomaos.com/share/DEXVzMSP',
|
download: 'https://getsapp.net/StKNQY',
|
||||||
title: 'Shadowrocket',
|
title: 'Shadowrocket',
|
||||||
});
|
});
|
||||||
}}
|
}}
|
||||||
|
|||||||
@@ -0,0 +1,10 @@
|
|||||||
|
'use client';
|
||||||
|
import EmailAuthForm1 from '@/app/auth/email2/auth-form';
|
||||||
|
|
||||||
|
export default function RegisterPage() {
|
||||||
|
return (
|
||||||
|
<div className='container w-full py-8 sm:w-[496px]'>
|
||||||
|
<EmailAuthForm1 isRedirect={true} />
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -0,0 +1,45 @@
|
|||||||
|
/*import { GlobalMap } from '@/components/main/global-map';
|
||||||
|
import { Hero } from '@/components/main/hero';
|
||||||
|
import { ProductShowcase } from '@/components/main/product-showcase/index';
|
||||||
|
import { Stats } from '@/components/main/stats';*/
|
||||||
|
import Header from '@/components/Header/Header';
|
||||||
|
import { queryUserInfo } from '@/services/user/user';
|
||||||
|
import { cookies } from 'next/headers';
|
||||||
|
|
||||||
|
import EmailAuthForm2 from '@/app/auth/email2/auth-form';
|
||||||
|
import { LoginDialogProvider } from '@/app/auth/LoginDialogContext';
|
||||||
|
import FooterCopyright from '@/components/main/FooterCopyright';
|
||||||
|
import FullScreenVideoBackground from '@/components/main/FullScreenVideoBackground';
|
||||||
|
|
||||||
|
export default async function Home() {
|
||||||
|
const Authorization = (await cookies()).get('Authorization')?.value;
|
||||||
|
|
||||||
|
if (Authorization) {
|
||||||
|
let user = null;
|
||||||
|
try {
|
||||||
|
user = await queryUserInfo({
|
||||||
|
skipErrorHandler: true,
|
||||||
|
Authorization,
|
||||||
|
}).then((res) => res.data.data);
|
||||||
|
} catch (error) {
|
||||||
|
console.log('Token validation failed:', error);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (user) {
|
||||||
|
// redirect('/dashboard');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<LoginDialogProvider>
|
||||||
|
<FullScreenVideoBackground />
|
||||||
|
<Header />
|
||||||
|
<main className='fixed inset-0 z-40 flex items-center justify-center'>
|
||||||
|
<div className={'w-[80%] pt-8 sm:w-[496px]'}>
|
||||||
|
<EmailAuthForm2 isRedirect={true} />
|
||||||
|
</div>
|
||||||
|
</main>
|
||||||
|
<FooterCopyright />
|
||||||
|
</LoginDialogProvider>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -0,0 +1,111 @@
|
|||||||
|
'use client';
|
||||||
|
|
||||||
|
import { resetPassword, userLogin, userRegister } from '@/services/common/auth';
|
||||||
|
import { useTranslations } from 'next-intl';
|
||||||
|
import { useRouter } from 'next/navigation';
|
||||||
|
import { ReactNode, useState, useTransition } from 'react';
|
||||||
|
import { toast } from 'sonner';
|
||||||
|
|
||||||
|
import {
|
||||||
|
NEXT_PUBLIC_DEFAULT_USER_EMAIL,
|
||||||
|
NEXT_PUBLIC_DEFAULT_USER_PASSWORD,
|
||||||
|
} from '@/config/constants';
|
||||||
|
import useGlobalStore from '@/config/use-global';
|
||||||
|
import { getRedirectUrl, setAuthorization } from '@/utils/common';
|
||||||
|
import LoginForm from './login-form';
|
||||||
|
import RegisterForm from './register-form';
|
||||||
|
import ResetForm from './reset-form';
|
||||||
|
|
||||||
|
export default function EmailAuthForm(props: { isRedirect: boolean }) {
|
||||||
|
const t = useTranslations('auth');
|
||||||
|
const router = useRouter();
|
||||||
|
const [type, setType] = useState<'login' | 'register' | 'reset'>('register');
|
||||||
|
const [loading, startTransition] = useTransition();
|
||||||
|
const [initialValues, setInitialValues] = useState<{
|
||||||
|
email?: string;
|
||||||
|
password?: string;
|
||||||
|
}>({
|
||||||
|
email: NEXT_PUBLIC_DEFAULT_USER_EMAIL,
|
||||||
|
password: NEXT_PUBLIC_DEFAULT_USER_PASSWORD,
|
||||||
|
});
|
||||||
|
const { getUserInfo } = useGlobalStore();
|
||||||
|
const handleFormSubmit = async (params: any) => {
|
||||||
|
const onLogin = async (token?: string) => {
|
||||||
|
if (!token) return;
|
||||||
|
setAuthorization(token);
|
||||||
|
console.log('props.isRedirect', token);
|
||||||
|
console.log('props.isRedirect', props.isRedirect);
|
||||||
|
console.log('props.isRedirect ', getRedirectUrl());
|
||||||
|
if (props.isRedirect) {
|
||||||
|
router.replace(getRedirectUrl());
|
||||||
|
router.refresh();
|
||||||
|
} else {
|
||||||
|
await getUserInfo();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
startTransition(async () => {
|
||||||
|
try {
|
||||||
|
switch (type) {
|
||||||
|
case 'login': {
|
||||||
|
const login = await userLogin(params);
|
||||||
|
toast.success(t('login.success'));
|
||||||
|
onLogin(login.data.data?.token);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 'register': {
|
||||||
|
const create = await userRegister(params);
|
||||||
|
toast.success(t('register.success'));
|
||||||
|
onLogin(create.data.data?.token);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 'reset':
|
||||||
|
await resetPassword(params);
|
||||||
|
toast.success(t('reset.success'));
|
||||||
|
setType('login');
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
/* empty */
|
||||||
|
}
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
let UserForm: ReactNode = null;
|
||||||
|
switch (type) {
|
||||||
|
case 'login':
|
||||||
|
UserForm = (
|
||||||
|
<LoginForm
|
||||||
|
loading={loading}
|
||||||
|
onSubmit={handleFormSubmit}
|
||||||
|
initialValues={initialValues}
|
||||||
|
setInitialValues={setInitialValues}
|
||||||
|
onSwitchForm={setType}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
break;
|
||||||
|
case 'register':
|
||||||
|
UserForm = (
|
||||||
|
<RegisterForm
|
||||||
|
loading={loading}
|
||||||
|
onSubmit={handleFormSubmit}
|
||||||
|
initialValues={initialValues}
|
||||||
|
setInitialValues={setInitialValues}
|
||||||
|
onSwitchForm={setType}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
break;
|
||||||
|
case 'reset':
|
||||||
|
UserForm = (
|
||||||
|
<ResetForm
|
||||||
|
loading={loading}
|
||||||
|
onSubmit={handleFormSubmit}
|
||||||
|
initialValues={initialValues}
|
||||||
|
setInitialValues={setInitialValues}
|
||||||
|
onSwitchForm={setType}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return UserForm;
|
||||||
|
}
|
||||||
@@ -0,0 +1,147 @@
|
|||||||
|
import useGlobalStore from '@/config/use-global';
|
||||||
|
import { zodResolver } from '@hookform/resolvers/zod';
|
||||||
|
import { AiroButton } from '@workspace/airo-ui/components/AiroButton';
|
||||||
|
import { Button } from '@workspace/airo-ui/components/button';
|
||||||
|
import {
|
||||||
|
Form,
|
||||||
|
FormControl,
|
||||||
|
FormField,
|
||||||
|
FormItem,
|
||||||
|
FormMessage,
|
||||||
|
} from '@workspace/airo-ui/components/form';
|
||||||
|
import { Input } from '@workspace/airo-ui/components/input';
|
||||||
|
import { Icon } from '@workspace/airo-ui/custom-components/icon';
|
||||||
|
import { useTranslations } from 'next-intl';
|
||||||
|
import { Dispatch, SetStateAction, useRef } from 'react';
|
||||||
|
import { useForm } from 'react-hook-form';
|
||||||
|
import { z } from 'zod';
|
||||||
|
import CloudFlareTurnstile, { TurnstileRef } from '../turnstile';
|
||||||
|
|
||||||
|
export default function LoginForm({
|
||||||
|
loading,
|
||||||
|
onSubmit,
|
||||||
|
initialValues,
|
||||||
|
setInitialValues,
|
||||||
|
onSwitchForm,
|
||||||
|
}: {
|
||||||
|
loading?: boolean;
|
||||||
|
onSubmit: (data: any) => void;
|
||||||
|
initialValues: any;
|
||||||
|
setInitialValues: Dispatch<SetStateAction<any>>;
|
||||||
|
onSwitchForm: Dispatch<SetStateAction<'register' | 'reset' | 'login'>>;
|
||||||
|
}) {
|
||||||
|
const t = useTranslations('auth.login');
|
||||||
|
const { common } = useGlobalStore();
|
||||||
|
const { verify } = common;
|
||||||
|
|
||||||
|
const formSchema = z.object({
|
||||||
|
email: z.string().email(t('email')),
|
||||||
|
password: z.string(),
|
||||||
|
cf_token:
|
||||||
|
verify.enable_login_verify && verify.turnstile_site_key ? z.string() : z.string().optional(),
|
||||||
|
});
|
||||||
|
const form = useForm<z.infer<typeof formSchema>>({
|
||||||
|
resolver: zodResolver(formSchema),
|
||||||
|
defaultValues: initialValues,
|
||||||
|
});
|
||||||
|
|
||||||
|
const turnstile = useRef<TurnstileRef>(null);
|
||||||
|
const handleSubmit = form.handleSubmit((data) => {
|
||||||
|
try {
|
||||||
|
onSubmit(data);
|
||||||
|
} catch (error) {
|
||||||
|
turnstile.current?.reset();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<div className={'h-[84px] text-2xl font-bold leading-[84px]'}>账户验证</div>
|
||||||
|
<Form {...form}>
|
||||||
|
<form onSubmit={handleSubmit} className=''>
|
||||||
|
<FormField
|
||||||
|
control={form.control}
|
||||||
|
name='email'
|
||||||
|
render={({ field }) => (
|
||||||
|
<FormItem className={'mb-5'}>
|
||||||
|
<FormControl>
|
||||||
|
<Input
|
||||||
|
className={'h-[46px] rounded-full shadow-[inset_0_0_7.6px_0_#00000040]'}
|
||||||
|
placeholder='Email'
|
||||||
|
type='email'
|
||||||
|
{...field}
|
||||||
|
/>
|
||||||
|
</FormControl>
|
||||||
|
<FormMessage />
|
||||||
|
</FormItem>
|
||||||
|
)}
|
||||||
|
/>
|
||||||
|
<FormField
|
||||||
|
control={form.control}
|
||||||
|
name='password'
|
||||||
|
render={({ field }) => (
|
||||||
|
<FormItem className={'mb-2'}>
|
||||||
|
<FormControl>
|
||||||
|
<Input
|
||||||
|
className={'h-[46px] rounded-full shadow-[inset_0_0_7.6px_0_#00000040]'}
|
||||||
|
placeholder='Password'
|
||||||
|
type='password'
|
||||||
|
{...field}
|
||||||
|
/>
|
||||||
|
</FormControl>
|
||||||
|
<FormMessage />
|
||||||
|
</FormItem>
|
||||||
|
)}
|
||||||
|
/>
|
||||||
|
{verify.enable_login_verify && (
|
||||||
|
<FormField
|
||||||
|
control={form.control}
|
||||||
|
name='cf_token'
|
||||||
|
render={({ field }) => (
|
||||||
|
<FormItem className={'last:mb-0'}>
|
||||||
|
<FormControl>
|
||||||
|
<CloudFlareTurnstile id='login' {...field} ref={turnstile} />
|
||||||
|
</FormControl>
|
||||||
|
<FormMessage />
|
||||||
|
</FormItem>
|
||||||
|
)}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
<div className='flex w-full justify-between text-sm'>
|
||||||
|
<Button
|
||||||
|
variant='link'
|
||||||
|
type='button'
|
||||||
|
className='p-0 text-[#225BA9]'
|
||||||
|
onClick={() => onSwitchForm('reset')}
|
||||||
|
>
|
||||||
|
{t('forgotPassword')}
|
||||||
|
</Button>
|
||||||
|
<Button
|
||||||
|
variant='link'
|
||||||
|
type='button'
|
||||||
|
className='p-0 text-[#225BA9]'
|
||||||
|
onClick={() => {
|
||||||
|
setInitialValues(undefined);
|
||||||
|
onSwitchForm('register');
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{t('registerAccount')}
|
||||||
|
</Button>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className='mt-6 flex justify-center'>
|
||||||
|
<AiroButton
|
||||||
|
type='submit'
|
||||||
|
variant='default'
|
||||||
|
disabled={loading}
|
||||||
|
className='h-auto min-w-[157px] py-2 text-lg font-medium'
|
||||||
|
>
|
||||||
|
{loading && <Icon icon='mdi:loading' className='animate-spin' />}
|
||||||
|
{t('title')}
|
||||||
|
</AiroButton>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</Form>
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -0,0 +1,218 @@
|
|||||||
|
'use client';
|
||||||
|
import useGlobalStore from '@/config/use-global';
|
||||||
|
import { zodResolver } from '@hookform/resolvers/zod';
|
||||||
|
import { AiroButton } from '@workspace/airo-ui/components/AiroButton';
|
||||||
|
import { Button } from '@workspace/airo-ui/components/button';
|
||||||
|
|
||||||
|
import {
|
||||||
|
Form,
|
||||||
|
FormControl,
|
||||||
|
FormField,
|
||||||
|
FormItem,
|
||||||
|
FormMessage,
|
||||||
|
} from '@workspace/airo-ui/components/form';
|
||||||
|
import { Input } from '@workspace/airo-ui/components/input';
|
||||||
|
import { Icon } from '@workspace/airo-ui/custom-components/icon';
|
||||||
|
import { useRouter } from 'next/navigation';
|
||||||
|
import { Dispatch, SetStateAction, useEffect, useRef, useState } from 'react';
|
||||||
|
import { useForm } from 'react-hook-form';
|
||||||
|
import { z } from 'zod';
|
||||||
|
import SendCode from '../send-code';
|
||||||
|
import { TurnstileRef } from '../turnstile';
|
||||||
|
|
||||||
|
export default function RegisterForm({
|
||||||
|
loading,
|
||||||
|
onSubmit,
|
||||||
|
initialValues,
|
||||||
|
setInitialValues,
|
||||||
|
onSwitchForm,
|
||||||
|
}: {
|
||||||
|
loading?: boolean;
|
||||||
|
onSubmit: (data: any) => void;
|
||||||
|
initialValues: any;
|
||||||
|
setInitialValues: Dispatch<SetStateAction<any>>;
|
||||||
|
onSwitchForm: Dispatch<SetStateAction<'register' | 'reset' | 'login'>>;
|
||||||
|
}) {
|
||||||
|
const { common } = useGlobalStore();
|
||||||
|
const router = useRouter();
|
||||||
|
|
||||||
|
const formSchema = z
|
||||||
|
.object({
|
||||||
|
email: z.string().email('请输入有效的电子邮件地址。'),
|
||||||
|
password: z.string().min(1, '请输入密码'), // 必填提示
|
||||||
|
repeat_password: z.string().min(1, '请重复输入密码'), // 必填
|
||||||
|
code: z.string().min(1, '请输入验证码'), // 必填,
|
||||||
|
invite: z.string().nullish(),
|
||||||
|
})
|
||||||
|
.superRefine(({ password, repeat_password }, ctx) => {
|
||||||
|
if (password !== repeat_password) {
|
||||||
|
ctx.addIssue({
|
||||||
|
code: z.ZodIssueCode.custom,
|
||||||
|
message: '两次密码输入不一致',
|
||||||
|
path: ['repeat_password'],
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
const [inviteDefault, setInviteDefault] = useState('');
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
const invite = localStorage.getItem('invite') || '';
|
||||||
|
setInviteDefault(invite);
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
const form = useForm<z.infer<typeof formSchema>>({
|
||||||
|
resolver: zodResolver(formSchema),
|
||||||
|
defaultValues: {
|
||||||
|
...initialValues,
|
||||||
|
invite: inviteDefault,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
const turnstile = useRef<TurnstileRef>(null);
|
||||||
|
const handleSubmit = form.handleSubmit((data) => {
|
||||||
|
try {
|
||||||
|
onSubmit(data);
|
||||||
|
} catch (error) {
|
||||||
|
turnstile.current?.reset();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<div className={'h-[84px] text-2xl font-bold leading-[84px]'}>线路优化</div>
|
||||||
|
|
||||||
|
<Form {...form}>
|
||||||
|
<form onSubmit={handleSubmit}>
|
||||||
|
<div className='grid gap-5'>
|
||||||
|
<FormField
|
||||||
|
control={form.control}
|
||||||
|
name='email'
|
||||||
|
render={({ field }) => (
|
||||||
|
<FormItem>
|
||||||
|
<FormControl>
|
||||||
|
<Input
|
||||||
|
className={'h-[46px] rounded-full shadow-[inset_0_0_7.6px_0_#00000040]'}
|
||||||
|
placeholder='电子邮箱'
|
||||||
|
type='email'
|
||||||
|
{...field}
|
||||||
|
/>
|
||||||
|
</FormControl>
|
||||||
|
<FormMessage />
|
||||||
|
</FormItem>
|
||||||
|
)}
|
||||||
|
/>
|
||||||
|
<FormField
|
||||||
|
control={form.control}
|
||||||
|
name='password'
|
||||||
|
render={({ field }) => (
|
||||||
|
<FormItem>
|
||||||
|
<FormControl>
|
||||||
|
<Input
|
||||||
|
className={'h-[46px] rounded-full shadow-[inset_0_0_7.6px_0_#00000040]'}
|
||||||
|
placeholder='设置密码'
|
||||||
|
type='password'
|
||||||
|
{...field}
|
||||||
|
/>
|
||||||
|
</FormControl>
|
||||||
|
<FormMessage />
|
||||||
|
</FormItem>
|
||||||
|
)}
|
||||||
|
/>
|
||||||
|
<FormField
|
||||||
|
control={form.control}
|
||||||
|
name='repeat_password'
|
||||||
|
render={({ field }) => (
|
||||||
|
<FormItem>
|
||||||
|
<FormControl>
|
||||||
|
<Input
|
||||||
|
className={'h-[46px] rounded-full shadow-[inset_0_0_7.6px_0_#00000040]'}
|
||||||
|
disabled={loading}
|
||||||
|
placeholder='再次输入密码'
|
||||||
|
type='password'
|
||||||
|
{...field}
|
||||||
|
/>
|
||||||
|
</FormControl>
|
||||||
|
<FormMessage />
|
||||||
|
</FormItem>
|
||||||
|
)}
|
||||||
|
/>
|
||||||
|
{
|
||||||
|
<FormField
|
||||||
|
control={form.control}
|
||||||
|
name='code'
|
||||||
|
render={({ field }) => (
|
||||||
|
<FormItem>
|
||||||
|
<FormControl>
|
||||||
|
<div className='flex items-center gap-8'>
|
||||||
|
<Input
|
||||||
|
disabled={loading}
|
||||||
|
className={'h-[46px] rounded-full shadow-[inset_0_0_7.6px_0_#00000040]'}
|
||||||
|
placeholder='邮箱验证码'
|
||||||
|
type='text'
|
||||||
|
{...field}
|
||||||
|
value={field.value as string}
|
||||||
|
/>
|
||||||
|
<SendCode
|
||||||
|
type='email'
|
||||||
|
form={form}
|
||||||
|
params={{
|
||||||
|
...form.getValues(),
|
||||||
|
type: 1,
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</FormControl>
|
||||||
|
<FormMessage />
|
||||||
|
</FormItem>
|
||||||
|
)}
|
||||||
|
/>
|
||||||
|
}
|
||||||
|
<FormField
|
||||||
|
control={form.control}
|
||||||
|
name='invite'
|
||||||
|
render={({ field }) => (
|
||||||
|
<FormItem>
|
||||||
|
<FormControl>
|
||||||
|
<Input
|
||||||
|
className={'h-[46px] rounded-full shadow-[inset_0_0_7.6px_0_#00000040]'}
|
||||||
|
disabled={loading || !!inviteDefault}
|
||||||
|
placeholder={'邀请码(非必填)'}
|
||||||
|
{...field}
|
||||||
|
value={field.value || ''}
|
||||||
|
/>
|
||||||
|
</FormControl>
|
||||||
|
<FormMessage />
|
||||||
|
</FormItem>
|
||||||
|
)}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className='text-right text-sm'>
|
||||||
|
已有账户?
|
||||||
|
<Button
|
||||||
|
variant='link'
|
||||||
|
type='button'
|
||||||
|
className='p-0 text-[#225BA9]'
|
||||||
|
onClick={() => {
|
||||||
|
router.replace('/');
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
登录
|
||||||
|
</Button>
|
||||||
|
</div>
|
||||||
|
<div className='mt-6 flex justify-center'>
|
||||||
|
<AiroButton
|
||||||
|
type='submit'
|
||||||
|
disabled={loading}
|
||||||
|
className='h-auto min-w-[157px] py-2 text-lg font-medium'
|
||||||
|
>
|
||||||
|
{loading && <Icon icon='mdi:loading' className='animate-spin' />}
|
||||||
|
注册
|
||||||
|
</AiroButton>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</Form>
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -0,0 +1,174 @@
|
|||||||
|
import useGlobalStore from '@/config/use-global';
|
||||||
|
import { zodResolver } from '@hookform/resolvers/zod';
|
||||||
|
import { AiroButton } from '@workspace/airo-ui/components/AiroButton';
|
||||||
|
import { Button } from '@workspace/airo-ui/components/button';
|
||||||
|
import {
|
||||||
|
Form,
|
||||||
|
FormControl,
|
||||||
|
FormField,
|
||||||
|
FormItem,
|
||||||
|
FormMessage,
|
||||||
|
} from '@workspace/airo-ui/components/form';
|
||||||
|
import { Input } from '@workspace/airo-ui/components/input';
|
||||||
|
import { Icon } from '@workspace/airo-ui/custom-components/icon';
|
||||||
|
import { useTranslations } from 'next-intl';
|
||||||
|
import { Dispatch, SetStateAction, useRef } from 'react';
|
||||||
|
import { useForm } from 'react-hook-form';
|
||||||
|
import { z } from 'zod';
|
||||||
|
import SendCode from '../send-code';
|
||||||
|
import CloudFlareTurnstile, { TurnstileRef } from '../turnstile';
|
||||||
|
|
||||||
|
export default function ResetForm({
|
||||||
|
loading,
|
||||||
|
onSubmit,
|
||||||
|
initialValues,
|
||||||
|
setInitialValues,
|
||||||
|
onSwitchForm,
|
||||||
|
}: {
|
||||||
|
loading?: boolean;
|
||||||
|
onSubmit: (data: any) => void;
|
||||||
|
initialValues: any;
|
||||||
|
setInitialValues: Dispatch<SetStateAction<any>>;
|
||||||
|
onSwitchForm: Dispatch<SetStateAction<'register' | 'reset' | 'login'>>;
|
||||||
|
}) {
|
||||||
|
const t = useTranslations('auth.reset');
|
||||||
|
|
||||||
|
const { common } = useGlobalStore();
|
||||||
|
const { verify, auth } = common;
|
||||||
|
|
||||||
|
const formSchema = z.object({
|
||||||
|
email: z.string().email(t('email')),
|
||||||
|
password: z.string(),
|
||||||
|
code: auth?.email?.enable_verify ? z.string() : z.string().nullish(),
|
||||||
|
cf_token:
|
||||||
|
verify.enable_register_verify && verify.turnstile_site_key
|
||||||
|
? z.string()
|
||||||
|
: z.string().nullish(),
|
||||||
|
});
|
||||||
|
const form = useForm<z.infer<typeof formSchema>>({
|
||||||
|
resolver: zodResolver(formSchema),
|
||||||
|
defaultValues: initialValues,
|
||||||
|
});
|
||||||
|
|
||||||
|
const turnstile = useRef<TurnstileRef>(null);
|
||||||
|
const handleSubmit = form.handleSubmit((data) => {
|
||||||
|
try {
|
||||||
|
onSubmit(data);
|
||||||
|
} catch (error) {
|
||||||
|
turnstile.current?.reset();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<div className={'h-[84px] text-2xl font-bold leading-[84px]'}>找回账户</div>
|
||||||
|
<Form {...form}>
|
||||||
|
<form onSubmit={handleSubmit}>
|
||||||
|
<div className='grid gap-5'>
|
||||||
|
<FormField
|
||||||
|
control={form.control}
|
||||||
|
name='email'
|
||||||
|
render={({ field }) => (
|
||||||
|
<FormItem>
|
||||||
|
<FormControl>
|
||||||
|
<Input
|
||||||
|
className={'h-[46px] rounded-full shadow-[inset_0_0_7.6px_0_#00000040]'}
|
||||||
|
placeholder='Enter your email...'
|
||||||
|
type='email'
|
||||||
|
{...field}
|
||||||
|
/>
|
||||||
|
</FormControl>
|
||||||
|
<FormMessage />
|
||||||
|
</FormItem>
|
||||||
|
)}
|
||||||
|
/>
|
||||||
|
<FormField
|
||||||
|
control={form.control}
|
||||||
|
name='code'
|
||||||
|
render={({ field }) => (
|
||||||
|
<FormItem>
|
||||||
|
<FormControl>
|
||||||
|
<div className='flex items-center gap-8'>
|
||||||
|
<Input
|
||||||
|
className={'h-[46px] rounded-full shadow-[inset_0_0_7.6px_0_#00000040]'}
|
||||||
|
disabled={loading}
|
||||||
|
placeholder='Enter code...'
|
||||||
|
type='text'
|
||||||
|
{...field}
|
||||||
|
value={field.value as string}
|
||||||
|
/>
|
||||||
|
<SendCode
|
||||||
|
type='email'
|
||||||
|
form={form}
|
||||||
|
params={{
|
||||||
|
...form.getValues(),
|
||||||
|
type: 2,
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</FormControl>
|
||||||
|
<FormMessage />
|
||||||
|
</FormItem>
|
||||||
|
)}
|
||||||
|
/>
|
||||||
|
<FormField
|
||||||
|
control={form.control}
|
||||||
|
name='password'
|
||||||
|
render={({ field }) => (
|
||||||
|
<FormItem>
|
||||||
|
<FormControl>
|
||||||
|
<Input
|
||||||
|
className={'h-[46px] rounded-full shadow-[inset_0_0_7.6px_0_#00000040]'}
|
||||||
|
placeholder='Enter your new password...'
|
||||||
|
type='password'
|
||||||
|
{...field}
|
||||||
|
/>
|
||||||
|
</FormControl>
|
||||||
|
<FormMessage />
|
||||||
|
</FormItem>
|
||||||
|
)}
|
||||||
|
/>
|
||||||
|
{verify.enable_reset_password_verify && (
|
||||||
|
<FormField
|
||||||
|
control={form.control}
|
||||||
|
name='cf_token'
|
||||||
|
render={({ field }) => (
|
||||||
|
<FormItem>
|
||||||
|
<FormControl>
|
||||||
|
<CloudFlareTurnstile id='reset' {...field} ref={turnstile} />
|
||||||
|
</FormControl>
|
||||||
|
<FormMessage />
|
||||||
|
</FormItem>
|
||||||
|
)}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
<div className='text-right text-sm'>
|
||||||
|
{t('existingAccount')}
|
||||||
|
<Button
|
||||||
|
variant='link'
|
||||||
|
type='button'
|
||||||
|
className='p-0 text-[#225BA9]'
|
||||||
|
onClick={() => {
|
||||||
|
setInitialValues(undefined);
|
||||||
|
onSwitchForm('login');
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{t('switchToLogin')}
|
||||||
|
</Button>
|
||||||
|
</div>
|
||||||
|
<div className='mt-6 flex justify-center'>
|
||||||
|
<AiroButton
|
||||||
|
type='submit'
|
||||||
|
disabled={loading}
|
||||||
|
className='h-auto min-w-[157px] py-2 text-lg font-medium'
|
||||||
|
>
|
||||||
|
{loading && <Icon icon='mdi:loading' className='animate-spin' />}
|
||||||
|
{t('title')}
|
||||||
|
</AiroButton>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</Form>
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -0,0 +1,111 @@
|
|||||||
|
'use client';
|
||||||
|
|
||||||
|
import { resetPassword, userLogin, userRegister } from '@/services/common/auth';
|
||||||
|
import { useTranslations } from 'next-intl';
|
||||||
|
import { useRouter } from 'next/navigation';
|
||||||
|
import { ReactNode, useState, useTransition } from 'react';
|
||||||
|
import { toast } from 'sonner';
|
||||||
|
|
||||||
|
import {
|
||||||
|
NEXT_PUBLIC_DEFAULT_USER_EMAIL,
|
||||||
|
NEXT_PUBLIC_DEFAULT_USER_PASSWORD,
|
||||||
|
} from '@/config/constants';
|
||||||
|
import useGlobalStore from '@/config/use-global';
|
||||||
|
import { getRedirectUrl, setAuthorization } from '@/utils/common';
|
||||||
|
import LoginForm from './login-form';
|
||||||
|
import RegisterForm from './register-form';
|
||||||
|
import ResetForm from './reset-form';
|
||||||
|
|
||||||
|
export default function EmailAuthForm(props: { isRedirect: boolean }) {
|
||||||
|
const t = useTranslations('auth');
|
||||||
|
const router = useRouter();
|
||||||
|
const [type, setType] = useState<'login' | 'register' | 'reset'>('register');
|
||||||
|
const [loading, startTransition] = useTransition();
|
||||||
|
const [initialValues, setInitialValues] = useState<{
|
||||||
|
email?: string;
|
||||||
|
password?: string;
|
||||||
|
}>({
|
||||||
|
email: NEXT_PUBLIC_DEFAULT_USER_EMAIL,
|
||||||
|
password: NEXT_PUBLIC_DEFAULT_USER_PASSWORD,
|
||||||
|
});
|
||||||
|
const { getUserInfo } = useGlobalStore();
|
||||||
|
const handleFormSubmit = async (params: any) => {
|
||||||
|
const onLogin = async (token?: string) => {
|
||||||
|
if (!token) return;
|
||||||
|
setAuthorization(token);
|
||||||
|
console.log('props.isRedirect', token);
|
||||||
|
console.log('props.isRedirect', props.isRedirect);
|
||||||
|
console.log('props.isRedirect ', getRedirectUrl());
|
||||||
|
if (props.isRedirect) {
|
||||||
|
router.replace(getRedirectUrl());
|
||||||
|
router.refresh();
|
||||||
|
} else {
|
||||||
|
await getUserInfo();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
startTransition(async () => {
|
||||||
|
try {
|
||||||
|
switch (type) {
|
||||||
|
case 'login': {
|
||||||
|
const login = await userLogin(params);
|
||||||
|
toast.success(t('login.success'));
|
||||||
|
onLogin(login.data.data?.token);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 'register': {
|
||||||
|
const create = await userRegister(params);
|
||||||
|
toast.success(t('register.success'));
|
||||||
|
onLogin(create.data.data?.token);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 'reset':
|
||||||
|
await resetPassword(params);
|
||||||
|
toast.success(t('reset.success'));
|
||||||
|
setType('login');
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
/* empty */
|
||||||
|
}
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
let UserForm: ReactNode = null;
|
||||||
|
switch (type) {
|
||||||
|
case 'login':
|
||||||
|
UserForm = (
|
||||||
|
<LoginForm
|
||||||
|
loading={loading}
|
||||||
|
onSubmit={handleFormSubmit}
|
||||||
|
initialValues={initialValues}
|
||||||
|
setInitialValues={setInitialValues}
|
||||||
|
onSwitchForm={setType}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
break;
|
||||||
|
case 'register':
|
||||||
|
UserForm = (
|
||||||
|
<RegisterForm
|
||||||
|
loading={loading}
|
||||||
|
onSubmit={handleFormSubmit}
|
||||||
|
initialValues={initialValues}
|
||||||
|
setInitialValues={setInitialValues}
|
||||||
|
onSwitchForm={setType}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
break;
|
||||||
|
case 'reset':
|
||||||
|
UserForm = (
|
||||||
|
<ResetForm
|
||||||
|
loading={loading}
|
||||||
|
onSubmit={handleFormSubmit}
|
||||||
|
initialValues={initialValues}
|
||||||
|
setInitialValues={setInitialValues}
|
||||||
|
onSwitchForm={setType}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return UserForm;
|
||||||
|
}
|
||||||
@@ -0,0 +1,147 @@
|
|||||||
|
import useGlobalStore from '@/config/use-global';
|
||||||
|
import { zodResolver } from '@hookform/resolvers/zod';
|
||||||
|
import { AiroButton } from '@workspace/airo-ui/components/AiroButton';
|
||||||
|
import { Button } from '@workspace/airo-ui/components/button';
|
||||||
|
import {
|
||||||
|
Form,
|
||||||
|
FormControl,
|
||||||
|
FormField,
|
||||||
|
FormItem,
|
||||||
|
FormMessage,
|
||||||
|
} from '@workspace/airo-ui/components/form';
|
||||||
|
import { Input } from '@workspace/airo-ui/components/input';
|
||||||
|
import { Icon } from '@workspace/airo-ui/custom-components/icon';
|
||||||
|
import { useTranslations } from 'next-intl';
|
||||||
|
import { Dispatch, SetStateAction, useRef } from 'react';
|
||||||
|
import { useForm } from 'react-hook-form';
|
||||||
|
import { z } from 'zod';
|
||||||
|
import CloudFlareTurnstile, { TurnstileRef } from '../turnstile';
|
||||||
|
|
||||||
|
export default function LoginForm({
|
||||||
|
loading,
|
||||||
|
onSubmit,
|
||||||
|
initialValues,
|
||||||
|
setInitialValues,
|
||||||
|
onSwitchForm,
|
||||||
|
}: {
|
||||||
|
loading?: boolean;
|
||||||
|
onSubmit: (data: any) => void;
|
||||||
|
initialValues: any;
|
||||||
|
setInitialValues: Dispatch<SetStateAction<any>>;
|
||||||
|
onSwitchForm: Dispatch<SetStateAction<'register' | 'reset' | 'login'>>;
|
||||||
|
}) {
|
||||||
|
const t = useTranslations('auth.login');
|
||||||
|
const { common } = useGlobalStore();
|
||||||
|
const { verify } = common;
|
||||||
|
|
||||||
|
const formSchema = z.object({
|
||||||
|
email: z.string().email(t('email')),
|
||||||
|
password: z.string(),
|
||||||
|
cf_token:
|
||||||
|
verify.enable_login_verify && verify.turnstile_site_key ? z.string() : z.string().optional(),
|
||||||
|
});
|
||||||
|
const form = useForm<z.infer<typeof formSchema>>({
|
||||||
|
resolver: zodResolver(formSchema),
|
||||||
|
defaultValues: initialValues,
|
||||||
|
});
|
||||||
|
|
||||||
|
const turnstile = useRef<TurnstileRef>(null);
|
||||||
|
const handleSubmit = form.handleSubmit((data) => {
|
||||||
|
try {
|
||||||
|
onSubmit(data);
|
||||||
|
} catch (error) {
|
||||||
|
turnstile.current?.reset();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<div className={'h-[84px] text-2xl font-bold leading-[84px]'}>账户验证</div>
|
||||||
|
<Form {...form}>
|
||||||
|
<form onSubmit={handleSubmit} className=''>
|
||||||
|
<FormField
|
||||||
|
control={form.control}
|
||||||
|
name='email'
|
||||||
|
render={({ field }) => (
|
||||||
|
<FormItem className={'mb-5'}>
|
||||||
|
<FormControl>
|
||||||
|
<Input
|
||||||
|
className={'h-[46px] rounded-full shadow-[inset_0_0_7.6px_0_#00000040]'}
|
||||||
|
placeholder='Email'
|
||||||
|
type='email'
|
||||||
|
{...field}
|
||||||
|
/>
|
||||||
|
</FormControl>
|
||||||
|
<FormMessage />
|
||||||
|
</FormItem>
|
||||||
|
)}
|
||||||
|
/>
|
||||||
|
<FormField
|
||||||
|
control={form.control}
|
||||||
|
name='password'
|
||||||
|
render={({ field }) => (
|
||||||
|
<FormItem className={'mb-2'}>
|
||||||
|
<FormControl>
|
||||||
|
<Input
|
||||||
|
className={'h-[46px] rounded-full shadow-[inset_0_0_7.6px_0_#00000040]'}
|
||||||
|
placeholder='Password'
|
||||||
|
type='password'
|
||||||
|
{...field}
|
||||||
|
/>
|
||||||
|
</FormControl>
|
||||||
|
<FormMessage />
|
||||||
|
</FormItem>
|
||||||
|
)}
|
||||||
|
/>
|
||||||
|
{verify.enable_login_verify && (
|
||||||
|
<FormField
|
||||||
|
control={form.control}
|
||||||
|
name='cf_token'
|
||||||
|
render={({ field }) => (
|
||||||
|
<FormItem className={'last:mb-0'}>
|
||||||
|
<FormControl>
|
||||||
|
<CloudFlareTurnstile id='login' {...field} ref={turnstile} />
|
||||||
|
</FormControl>
|
||||||
|
<FormMessage />
|
||||||
|
</FormItem>
|
||||||
|
)}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
<div className='flex w-full justify-between text-sm'>
|
||||||
|
<Button
|
||||||
|
variant='link'
|
||||||
|
type='button'
|
||||||
|
className='p-0 text-[#225BA9]'
|
||||||
|
onClick={() => onSwitchForm('reset')}
|
||||||
|
>
|
||||||
|
{t('forgotPassword')}
|
||||||
|
</Button>
|
||||||
|
<Button
|
||||||
|
variant='link'
|
||||||
|
type='button'
|
||||||
|
className='p-0 text-[#225BA9]'
|
||||||
|
onClick={() => {
|
||||||
|
setInitialValues(undefined);
|
||||||
|
onSwitchForm('register');
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{t('registerAccount')}
|
||||||
|
</Button>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className='mt-6 flex justify-center'>
|
||||||
|
<AiroButton
|
||||||
|
type='submit'
|
||||||
|
variant='default'
|
||||||
|
disabled={loading}
|
||||||
|
className='h-auto min-w-[157px] py-2 text-lg font-medium'
|
||||||
|
>
|
||||||
|
{loading && <Icon icon='mdi:loading' className='animate-spin' />}
|
||||||
|
{t('title')}
|
||||||
|
</AiroButton>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</Form>
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -0,0 +1,231 @@
|
|||||||
|
'use client';
|
||||||
|
import useGlobalStore from '@/config/use-global';
|
||||||
|
import { zodResolver } from '@hookform/resolvers/zod';
|
||||||
|
import { AiroButton } from '@workspace/airo-ui/components/AiroButton';
|
||||||
|
import { Button } from '@workspace/airo-ui/components/button';
|
||||||
|
|
||||||
|
import { useLoginDialog } from '@/app/auth/LoginDialogContext';
|
||||||
|
import {
|
||||||
|
Form,
|
||||||
|
FormControl,
|
||||||
|
FormField,
|
||||||
|
FormItem,
|
||||||
|
FormMessage,
|
||||||
|
} from '@workspace/airo-ui/components/form';
|
||||||
|
import { Input } from '@workspace/airo-ui/components/input';
|
||||||
|
import { Icon } from '@workspace/airo-ui/custom-components/icon';
|
||||||
|
import { useRouter } from 'next/navigation';
|
||||||
|
import { Dispatch, SetStateAction, useEffect, useRef, useState } from 'react';
|
||||||
|
import { useForm } from 'react-hook-form';
|
||||||
|
import { z } from 'zod';
|
||||||
|
import SendCode from '../send-code';
|
||||||
|
import { TurnstileRef } from '../turnstile';
|
||||||
|
|
||||||
|
export default function RegisterForm({
|
||||||
|
loading,
|
||||||
|
onSubmit,
|
||||||
|
initialValues,
|
||||||
|
setInitialValues,
|
||||||
|
onSwitchForm,
|
||||||
|
}: {
|
||||||
|
loading?: boolean;
|
||||||
|
onSubmit: (data: any) => void;
|
||||||
|
initialValues: any;
|
||||||
|
setInitialValues: Dispatch<SetStateAction<any>>;
|
||||||
|
onSwitchForm: Dispatch<SetStateAction<'register' | 'reset' | 'login'>>;
|
||||||
|
}) {
|
||||||
|
const { common } = useGlobalStore();
|
||||||
|
const router = useRouter();
|
||||||
|
|
||||||
|
const formSchema = z
|
||||||
|
.object({
|
||||||
|
email: z.string().email('请输入有效的电子邮件地址。'),
|
||||||
|
password: z.string().min(1, '请输入密码'), // 必填提示
|
||||||
|
repeat_password: z.string().min(1, '请重复输入密码'), // 必填
|
||||||
|
code: z.string().min(1, '请输入验证码'), // 必填,
|
||||||
|
invite: z.string().nullish(),
|
||||||
|
})
|
||||||
|
.superRefine(({ password, repeat_password }, ctx) => {
|
||||||
|
if (password !== repeat_password) {
|
||||||
|
ctx.addIssue({
|
||||||
|
code: z.ZodIssueCode.custom,
|
||||||
|
message: '两次密码输入不一致',
|
||||||
|
path: ['repeat_password'],
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
const [inviteDefault, setInviteDefault] = useState('');
|
||||||
|
const { openLoginDialog } = useLoginDialog();
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
const invite = localStorage.getItem('invite') || '';
|
||||||
|
setInviteDefault(invite);
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
const form = useForm<z.infer<typeof formSchema>>({
|
||||||
|
resolver: zodResolver(formSchema),
|
||||||
|
defaultValues: {
|
||||||
|
...initialValues,
|
||||||
|
invite: inviteDefault,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
const turnstile = useRef<TurnstileRef>(null);
|
||||||
|
const handleSubmit = form.handleSubmit((data) => {
|
||||||
|
try {
|
||||||
|
onSubmit(data);
|
||||||
|
} catch (error) {
|
||||||
|
turnstile.current?.reset();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<div className={'h-[84px] text-2xl font-bold leading-[84px] text-white'}>线路优化</div>
|
||||||
|
|
||||||
|
<Form {...form}>
|
||||||
|
<form onSubmit={handleSubmit}>
|
||||||
|
<div className='grid gap-5'>
|
||||||
|
<FormField
|
||||||
|
control={form.control}
|
||||||
|
name='email'
|
||||||
|
render={({ field }) => (
|
||||||
|
<FormItem>
|
||||||
|
<FormControl>
|
||||||
|
<Input
|
||||||
|
className={
|
||||||
|
'h-[46px] rounded-full bg-white shadow-[inset_0_0_7.6px_0_#00000040]'
|
||||||
|
}
|
||||||
|
placeholder='电子邮箱'
|
||||||
|
type='email'
|
||||||
|
{...field}
|
||||||
|
/>
|
||||||
|
</FormControl>
|
||||||
|
<FormMessage />
|
||||||
|
</FormItem>
|
||||||
|
)}
|
||||||
|
/>
|
||||||
|
<FormField
|
||||||
|
control={form.control}
|
||||||
|
name='password'
|
||||||
|
render={({ field }) => (
|
||||||
|
<FormItem>
|
||||||
|
<FormControl>
|
||||||
|
<Input
|
||||||
|
className={
|
||||||
|
'h-[46px] rounded-full bg-white shadow-[inset_0_0_7.6px_0_#00000040]'
|
||||||
|
}
|
||||||
|
placeholder='设置密码'
|
||||||
|
type='password'
|
||||||
|
{...field}
|
||||||
|
/>
|
||||||
|
</FormControl>
|
||||||
|
<FormMessage />
|
||||||
|
</FormItem>
|
||||||
|
)}
|
||||||
|
/>
|
||||||
|
<FormField
|
||||||
|
control={form.control}
|
||||||
|
name='repeat_password'
|
||||||
|
render={({ field }) => (
|
||||||
|
<FormItem>
|
||||||
|
<FormControl>
|
||||||
|
<Input
|
||||||
|
className={
|
||||||
|
'h-[46px] rounded-full bg-white shadow-[inset_0_0_7.6px_0_#00000040]'
|
||||||
|
}
|
||||||
|
disabled={loading}
|
||||||
|
placeholder='再次输入密码'
|
||||||
|
type='password'
|
||||||
|
{...field}
|
||||||
|
/>
|
||||||
|
</FormControl>
|
||||||
|
<FormMessage />
|
||||||
|
</FormItem>
|
||||||
|
)}
|
||||||
|
/>
|
||||||
|
{
|
||||||
|
<FormField
|
||||||
|
control={form.control}
|
||||||
|
name='code'
|
||||||
|
render={({ field }) => (
|
||||||
|
<FormItem>
|
||||||
|
<FormControl>
|
||||||
|
<div className='flex items-center gap-8'>
|
||||||
|
<Input
|
||||||
|
disabled={loading}
|
||||||
|
className={
|
||||||
|
'h-[46px] rounded-full bg-white shadow-[inset_0_0_7.6px_0_#00000040]'
|
||||||
|
}
|
||||||
|
placeholder='邮箱验证码'
|
||||||
|
type='text'
|
||||||
|
{...field}
|
||||||
|
value={field.value as string}
|
||||||
|
/>
|
||||||
|
<SendCode
|
||||||
|
type='email'
|
||||||
|
form={form}
|
||||||
|
params={{
|
||||||
|
...form.getValues(),
|
||||||
|
type: 1,
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</FormControl>
|
||||||
|
<FormMessage />
|
||||||
|
</FormItem>
|
||||||
|
)}
|
||||||
|
/>
|
||||||
|
}
|
||||||
|
<FormField
|
||||||
|
control={form.control}
|
||||||
|
name='invite'
|
||||||
|
render={({ field }) => (
|
||||||
|
<FormItem>
|
||||||
|
<FormControl>
|
||||||
|
<Input
|
||||||
|
className={
|
||||||
|
'h-[46px] rounded-full bg-white shadow-[inset_0_0_7.6px_0_#00000040]'
|
||||||
|
}
|
||||||
|
disabled={loading || !!inviteDefault}
|
||||||
|
placeholder={'邀请码(非必填)'}
|
||||||
|
{...field}
|
||||||
|
value={field.value || ''}
|
||||||
|
/>
|
||||||
|
</FormControl>
|
||||||
|
<FormMessage />
|
||||||
|
</FormItem>
|
||||||
|
)}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className='text-right text-sm'>
|
||||||
|
已有账户?
|
||||||
|
<Button
|
||||||
|
variant='link'
|
||||||
|
type='button'
|
||||||
|
className='p-0 text-[#225BA9]'
|
||||||
|
onClick={() => {
|
||||||
|
openLoginDialog();
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
登录
|
||||||
|
</Button>
|
||||||
|
</div>
|
||||||
|
<div className='mt-6 flex justify-center'>
|
||||||
|
<AiroButton
|
||||||
|
type='submit'
|
||||||
|
variant={'default'}
|
||||||
|
disabled={loading}
|
||||||
|
className='h-auto min-w-[157px] border-[3px] border-white bg-white/10 py-2 text-lg font-medium text-white transition hover:bg-white/25'
|
||||||
|
>
|
||||||
|
{loading && <Icon icon='mdi:loading' className='animate-spin' />}
|
||||||
|
注册
|
||||||
|
</AiroButton>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</Form>
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -0,0 +1,174 @@
|
|||||||
|
import useGlobalStore from '@/config/use-global';
|
||||||
|
import { zodResolver } from '@hookform/resolvers/zod';
|
||||||
|
import { AiroButton } from '@workspace/airo-ui/components/AiroButton';
|
||||||
|
import { Button } from '@workspace/airo-ui/components/button';
|
||||||
|
import {
|
||||||
|
Form,
|
||||||
|
FormControl,
|
||||||
|
FormField,
|
||||||
|
FormItem,
|
||||||
|
FormMessage,
|
||||||
|
} from '@workspace/airo-ui/components/form';
|
||||||
|
import { Input } from '@workspace/airo-ui/components/input';
|
||||||
|
import { Icon } from '@workspace/airo-ui/custom-components/icon';
|
||||||
|
import { useTranslations } from 'next-intl';
|
||||||
|
import { Dispatch, SetStateAction, useRef } from 'react';
|
||||||
|
import { useForm } from 'react-hook-form';
|
||||||
|
import { z } from 'zod';
|
||||||
|
import SendCode from '../send-code';
|
||||||
|
import CloudFlareTurnstile, { TurnstileRef } from '../turnstile';
|
||||||
|
|
||||||
|
export default function ResetForm({
|
||||||
|
loading,
|
||||||
|
onSubmit,
|
||||||
|
initialValues,
|
||||||
|
setInitialValues,
|
||||||
|
onSwitchForm,
|
||||||
|
}: {
|
||||||
|
loading?: boolean;
|
||||||
|
onSubmit: (data: any) => void;
|
||||||
|
initialValues: any;
|
||||||
|
setInitialValues: Dispatch<SetStateAction<any>>;
|
||||||
|
onSwitchForm: Dispatch<SetStateAction<'register' | 'reset' | 'login'>>;
|
||||||
|
}) {
|
||||||
|
const t = useTranslations('auth.reset');
|
||||||
|
|
||||||
|
const { common } = useGlobalStore();
|
||||||
|
const { verify, auth } = common;
|
||||||
|
|
||||||
|
const formSchema = z.object({
|
||||||
|
email: z.string().email(t('email')),
|
||||||
|
password: z.string(),
|
||||||
|
code: auth?.email?.enable_verify ? z.string() : z.string().nullish(),
|
||||||
|
cf_token:
|
||||||
|
verify.enable_register_verify && verify.turnstile_site_key
|
||||||
|
? z.string()
|
||||||
|
: z.string().nullish(),
|
||||||
|
});
|
||||||
|
const form = useForm<z.infer<typeof formSchema>>({
|
||||||
|
resolver: zodResolver(formSchema),
|
||||||
|
defaultValues: initialValues,
|
||||||
|
});
|
||||||
|
|
||||||
|
const turnstile = useRef<TurnstileRef>(null);
|
||||||
|
const handleSubmit = form.handleSubmit((data) => {
|
||||||
|
try {
|
||||||
|
onSubmit(data);
|
||||||
|
} catch (error) {
|
||||||
|
turnstile.current?.reset();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<div className={'h-[84px] text-2xl font-bold leading-[84px]'}>找回账户</div>
|
||||||
|
<Form {...form}>
|
||||||
|
<form onSubmit={handleSubmit}>
|
||||||
|
<div className='grid gap-5'>
|
||||||
|
<FormField
|
||||||
|
control={form.control}
|
||||||
|
name='email'
|
||||||
|
render={({ field }) => (
|
||||||
|
<FormItem>
|
||||||
|
<FormControl>
|
||||||
|
<Input
|
||||||
|
className={'h-[46px] rounded-full shadow-[inset_0_0_7.6px_0_#00000040]'}
|
||||||
|
placeholder='Enter your email...'
|
||||||
|
type='email'
|
||||||
|
{...field}
|
||||||
|
/>
|
||||||
|
</FormControl>
|
||||||
|
<FormMessage />
|
||||||
|
</FormItem>
|
||||||
|
)}
|
||||||
|
/>
|
||||||
|
<FormField
|
||||||
|
control={form.control}
|
||||||
|
name='code'
|
||||||
|
render={({ field }) => (
|
||||||
|
<FormItem>
|
||||||
|
<FormControl>
|
||||||
|
<div className='flex items-center gap-8'>
|
||||||
|
<Input
|
||||||
|
className={'h-[46px] rounded-full shadow-[inset_0_0_7.6px_0_#00000040]'}
|
||||||
|
disabled={loading}
|
||||||
|
placeholder='Enter code...'
|
||||||
|
type='text'
|
||||||
|
{...field}
|
||||||
|
value={field.value as string}
|
||||||
|
/>
|
||||||
|
<SendCode
|
||||||
|
type='email'
|
||||||
|
form={form}
|
||||||
|
params={{
|
||||||
|
...form.getValues(),
|
||||||
|
type: 2,
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</FormControl>
|
||||||
|
<FormMessage />
|
||||||
|
</FormItem>
|
||||||
|
)}
|
||||||
|
/>
|
||||||
|
<FormField
|
||||||
|
control={form.control}
|
||||||
|
name='password'
|
||||||
|
render={({ field }) => (
|
||||||
|
<FormItem>
|
||||||
|
<FormControl>
|
||||||
|
<Input
|
||||||
|
className={'h-[46px] rounded-full shadow-[inset_0_0_7.6px_0_#00000040]'}
|
||||||
|
placeholder='Enter your new password...'
|
||||||
|
type='password'
|
||||||
|
{...field}
|
||||||
|
/>
|
||||||
|
</FormControl>
|
||||||
|
<FormMessage />
|
||||||
|
</FormItem>
|
||||||
|
)}
|
||||||
|
/>
|
||||||
|
{verify.enable_reset_password_verify && (
|
||||||
|
<FormField
|
||||||
|
control={form.control}
|
||||||
|
name='cf_token'
|
||||||
|
render={({ field }) => (
|
||||||
|
<FormItem>
|
||||||
|
<FormControl>
|
||||||
|
<CloudFlareTurnstile id='reset' {...field} ref={turnstile} />
|
||||||
|
</FormControl>
|
||||||
|
<FormMessage />
|
||||||
|
</FormItem>
|
||||||
|
)}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
<div className='text-right text-sm'>
|
||||||
|
{t('existingAccount')}
|
||||||
|
<Button
|
||||||
|
variant='link'
|
||||||
|
type='button'
|
||||||
|
className='p-0 text-[#225BA9]'
|
||||||
|
onClick={() => {
|
||||||
|
setInitialValues(undefined);
|
||||||
|
onSwitchForm('login');
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{t('switchToLogin')}
|
||||||
|
</Button>
|
||||||
|
</div>
|
||||||
|
<div className='mt-6 flex justify-center'>
|
||||||
|
<AiroButton
|
||||||
|
type='submit'
|
||||||
|
disabled={loading}
|
||||||
|
className='h-auto min-w-[157px] py-2 text-lg font-medium'
|
||||||
|
>
|
||||||
|
{loading && <Icon icon='mdi:loading' className='animate-spin' />}
|
||||||
|
{t('title')}
|
||||||
|
</AiroButton>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</Form>
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -84,16 +84,14 @@ export default function SendCode({ type, params, form }: SendCodeProps) {
|
|||||||
await getPhoneCode();
|
await getPhoneCode();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
const disabled =
|
const disabled = seconds > 0;
|
||||||
seconds > 0 ||
|
|
||||||
(type === 'email' ? !params.email : !params.telephone || !params.telephone_area_code);
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
<AiroButton
|
<AiroButton
|
||||||
type='button'
|
type='button'
|
||||||
variant={'primary'}
|
variant={'primary'}
|
||||||
className={'h-[30px] w-[109px]'}
|
className={'h-[46px] w-[109px]'}
|
||||||
onClick={handleSendCode}
|
onClick={handleSendCode}
|
||||||
disabled={disabled}
|
disabled={disabled}
|
||||||
>
|
>
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ export default function Providers({
|
|||||||
|
|
||||||
const { setCommon, setUser } = useGlobalStore();
|
const { setCommon, setUser } = useGlobalStore();
|
||||||
const pathname = usePathname();
|
const pathname = usePathname();
|
||||||
const whiteList = ['/'];
|
const whiteList = ['/', '/register', '/register2'];
|
||||||
const isWhite = whiteList.includes(pathname);
|
const isWhite = whiteList.includes(pathname);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
|||||||
@@ -3,7 +3,8 @@
|
|||||||
import PaymentMethods from '@/components/subscribe/payment-methods';
|
import PaymentMethods from '@/components/subscribe/payment-methods';
|
||||||
import PlanTabs, { TabValueType } from '@/components/SubscribePlan/PlanTabs/PlanTabs';
|
import PlanTabs, { TabValueType } from '@/components/SubscribePlan/PlanTabs/PlanTabs';
|
||||||
import useGlobalStore from '@/config/use-global';
|
import useGlobalStore from '@/config/use-global';
|
||||||
import { preCreateOrder, purchase } from '@/services/user/order';
|
import { preCreateOrder, purchase, renewal } from '@/services/user/order';
|
||||||
|
import { queryUserSubscribe } from '@/services/user/user';
|
||||||
import { useQuery } from '@tanstack/react-query';
|
import { useQuery } from '@tanstack/react-query';
|
||||||
import { AiroButton } from '@workspace/airo-ui/components/AiroButton';
|
import { AiroButton } from '@workspace/airo-ui/components/AiroButton';
|
||||||
import {
|
import {
|
||||||
@@ -104,7 +105,23 @@ const Purchase = forwardRef<PurchaseDialogRef, PurchaseProps>((props, ref) => {
|
|||||||
const handleSubmit = useCallback(async () => {
|
const handleSubmit = useCallback(async () => {
|
||||||
startTransition(async () => {
|
startTransition(async () => {
|
||||||
try {
|
try {
|
||||||
const response = await purchase(params as API.PurchaseOrderRequest);
|
const { data } = await queryUserSubscribe({ params: { includeExpired: 'all' } });
|
||||||
|
const activeList = data.data?.list || [];
|
||||||
|
const existingUser = activeList.find(
|
||||||
|
(item: any) => item.subscribe_id === params.subscribe_id,
|
||||||
|
);
|
||||||
|
let response;
|
||||||
|
// 3. 根据判断结果调用不同接口
|
||||||
|
if (existingUser) {
|
||||||
|
// 已有记录,走续费逻辑
|
||||||
|
response = await renewal({
|
||||||
|
user_subscribe_id: existingUser.id,
|
||||||
|
...params,
|
||||||
|
} as API.RenewalOrderRequest);
|
||||||
|
} else {
|
||||||
|
// 无记录,走新购逻辑
|
||||||
|
response = await purchase(params as API.PurchaseOrderRequest);
|
||||||
|
}
|
||||||
const orderNo = response.data.data?.order_no;
|
const orderNo = response.data.data?.order_no;
|
||||||
if (orderNo) {
|
if (orderNo) {
|
||||||
await getUserInfo();
|
await getUserInfo();
|
||||||
|
|||||||
@@ -32,7 +32,7 @@
|
|||||||
"framer-motion": "^11.16.1",
|
"framer-motion": "^11.16.1",
|
||||||
"gray-matter": "^4.0.3",
|
"gray-matter": "^4.0.3",
|
||||||
"lucide-react": "^0.469.0",
|
"lucide-react": "^0.469.0",
|
||||||
"next": "^15.1.4",
|
"next": "15.3.6",
|
||||||
"next-intl": "^3.26.3",
|
"next-intl": "^3.26.3",
|
||||||
"next-runtime-env": "^3.2.2",
|
"next-runtime-env": "^3.2.2",
|
||||||
"next-themes": "^0.4.4",
|
"next-themes": "^0.4.4",
|
||||||
|
|||||||
@@ -53,7 +53,7 @@ export function Logout() {
|
|||||||
Crisp.session.reset(); // 2. Unbind the current session
|
Crisp.session.reset(); // 2. Unbind the current session
|
||||||
const pathname = location.pathname;
|
const pathname = location.pathname;
|
||||||
if (
|
if (
|
||||||
!['', '/', '/auth', '/tos', '/privacy-policy'].includes(pathname) &&
|
!['', '/', '/auth', '/tos', '/privacy-policy', '/register', '/register2'].includes(pathname) &&
|
||||||
!pathname.startsWith('/purchasing') &&
|
!pathname.startsWith('/purchasing') &&
|
||||||
!pathname.startsWith('/oauth/')
|
!pathname.startsWith('/oauth/')
|
||||||
) {
|
) {
|
||||||
|
|||||||
@@ -29,7 +29,7 @@
|
|||||||
"axios": "^1.7.9",
|
"axios": "^1.7.9",
|
||||||
"js-yaml": "^4.1.0",
|
"js-yaml": "^4.1.0",
|
||||||
"nanoid": "^5.0.9",
|
"nanoid": "^5.0.9",
|
||||||
"next": "^15.1.4",
|
"next": "15.3.6",
|
||||||
"next-intl": "^3.26.3",
|
"next-intl": "^3.26.3",
|
||||||
"next-runtime-env": "^3.2.2",
|
"next-runtime-env": "^3.2.2",
|
||||||
"next-themes": "^0.4.4",
|
"next-themes": "^0.4.4",
|
||||||
@@ -70,7 +70,7 @@
|
|||||||
"framer-motion": "^11.16.1",
|
"framer-motion": "^11.16.1",
|
||||||
"gray-matter": "^4.0.3",
|
"gray-matter": "^4.0.3",
|
||||||
"lucide-react": "^0.469.0",
|
"lucide-react": "^0.469.0",
|
||||||
"next": "^15.1.4",
|
"next": "15.3.6",
|
||||||
"next-intl": "^3.26.3",
|
"next-intl": "^3.26.3",
|
||||||
"next-runtime-env": "^3.2.2",
|
"next-runtime-env": "^3.2.2",
|
||||||
"next-themes": "^0.4.4",
|
"next-themes": "^0.4.4",
|
||||||
@@ -716,27 +716,27 @@
|
|||||||
|
|
||||||
"@netlify/plugin-nextjs": ["@netlify/plugin-nextjs@5.12.1", "", {}, "sha512-b2Ic9NkNnnh0lKC/YWDZ2+HdLd/uYdBzLvLKYOkPyFt8KEszoC+Je3GRcwBeOLxaNtK8lji7YPIjtGz8K2sLVQ=="],
|
"@netlify/plugin-nextjs": ["@netlify/plugin-nextjs@5.12.1", "", {}, "sha512-b2Ic9NkNnnh0lKC/YWDZ2+HdLd/uYdBzLvLKYOkPyFt8KEszoC+Je3GRcwBeOLxaNtK8lji7YPIjtGz8K2sLVQ=="],
|
||||||
|
|
||||||
"@next/env": ["@next/env@15.5.2", "", {}, "sha512-Qe06ew4zt12LeO6N7j8/nULSOe3fMXE4dM6xgpBQNvdzyK1sv5y4oAP3bq4LamrvGCZtmRYnW8URFCeX5nFgGg=="],
|
"@next/env": ["@next/env@15.3.6", "", {}, "sha512-/cK+QPcfRbDZxmI/uckT4lu9pHCfRIPBLqy88MhE+7Vg5hKrEYc333Ae76dn/cw2FBP2bR/GoK/4DU+U7by/Nw=="],
|
||||||
|
|
||||||
"@next/eslint-plugin-next": ["@next/eslint-plugin-next@15.5.2", "", { "dependencies": { "fast-glob": "3.3.1" } }, "sha512-lkLrRVxcftuOsJNhWatf1P2hNVfh98k/omQHrCEPPriUypR6RcS13IvLdIrEvkm9AH2Nu2YpR5vLqBuy6twH3Q=="],
|
"@next/eslint-plugin-next": ["@next/eslint-plugin-next@15.5.2", "", { "dependencies": { "fast-glob": "3.3.1" } }, "sha512-lkLrRVxcftuOsJNhWatf1P2hNVfh98k/omQHrCEPPriUypR6RcS13IvLdIrEvkm9AH2Nu2YpR5vLqBuy6twH3Q=="],
|
||||||
|
|
||||||
"@next/swc-darwin-arm64": ["@next/swc-darwin-arm64@15.5.2", "", { "os": "darwin", "cpu": "arm64" }, "sha512-8bGt577BXGSd4iqFygmzIfTYizHb0LGWqH+qgIF/2EDxS5JsSdERJKA8WgwDyNBZgTIIA4D8qUtoQHmxIIquoQ=="],
|
"@next/swc-darwin-arm64": ["@next/swc-darwin-arm64@15.3.5", "", { "os": "darwin", "cpu": "arm64" }, "sha512-lM/8tilIsqBq+2nq9kbTW19vfwFve0NR7MxfkuSUbRSgXlMQoJYg+31+++XwKVSXk4uT23G2eF/7BRIKdn8t8w=="],
|
||||||
|
|
||||||
"@next/swc-darwin-x64": ["@next/swc-darwin-x64@15.5.2", "", { "os": "darwin", "cpu": "x64" }, "sha512-2DjnmR6JHK4X+dgTXt5/sOCu/7yPtqpYt8s8hLkHFK3MGkka2snTv3yRMdHvuRtJVkPwCGsvBSwmoQCHatauFQ=="],
|
"@next/swc-darwin-x64": ["@next/swc-darwin-x64@15.3.5", "", { "os": "darwin", "cpu": "x64" }, "sha512-WhwegPQJ5IfoUNZUVsI9TRAlKpjGVK0tpJTL6KeiC4cux9774NYE9Wu/iCfIkL/5J8rPAkqZpG7n+EfiAfidXA=="],
|
||||||
|
|
||||||
"@next/swc-linux-arm64-gnu": ["@next/swc-linux-arm64-gnu@15.5.2", "", { "os": "linux", "cpu": "arm64" }, "sha512-3j7SWDBS2Wov/L9q0mFJtEvQ5miIqfO4l7d2m9Mo06ddsgUK8gWfHGgbjdFlCp2Ek7MmMQZSxpGFqcC8zGh2AA=="],
|
"@next/swc-linux-arm64-gnu": ["@next/swc-linux-arm64-gnu@15.3.5", "", { "os": "linux", "cpu": "arm64" }, "sha512-LVD6uMOZ7XePg3KWYdGuzuvVboxujGjbcuP2jsPAN3MnLdLoZUXKRc6ixxfs03RH7qBdEHCZjyLP/jBdCJVRJQ=="],
|
||||||
|
|
||||||
"@next/swc-linux-arm64-musl": ["@next/swc-linux-arm64-musl@15.5.2", "", { "os": "linux", "cpu": "arm64" }, "sha512-s6N8k8dF9YGc5T01UPQ08yxsK6fUow5gG1/axWc1HVVBYQBgOjca4oUZF7s4p+kwhkB1bDSGR8QznWrFZ/Rt5g=="],
|
"@next/swc-linux-arm64-musl": ["@next/swc-linux-arm64-musl@15.3.5", "", { "os": "linux", "cpu": "arm64" }, "sha512-k8aVScYZ++BnS2P69ClK7v4nOu702jcF9AIHKu6llhHEtBSmM2zkPGl9yoqbSU/657IIIb0QHpdxEr0iW9z53A=="],
|
||||||
|
|
||||||
"@next/swc-linux-x64-gnu": ["@next/swc-linux-x64-gnu@15.5.2", "", { "os": "linux", "cpu": "x64" }, "sha512-o1RV/KOODQh6dM6ZRJGZbc+MOAHww33Vbs5JC9Mp1gDk8cpEO+cYC/l7rweiEalkSm5/1WGa4zY7xrNwObN4+Q=="],
|
"@next/swc-linux-x64-gnu": ["@next/swc-linux-x64-gnu@15.3.5", "", { "os": "linux", "cpu": "x64" }, "sha512-2xYU0DI9DGN/bAHzVwADid22ba5d/xrbrQlr2U+/Q5WkFUzeL0TDR963BdrtLS/4bMmKZGptLeg6282H/S2i8A=="],
|
||||||
|
|
||||||
"@next/swc-linux-x64-musl": ["@next/swc-linux-x64-musl@15.5.2", "", { "os": "linux", "cpu": "x64" }, "sha512-/VUnh7w8RElYZ0IV83nUcP/J4KJ6LLYliiBIri3p3aW2giF+PAVgZb6mk8jbQSB3WlTai8gEmCAr7kptFa1H6g=="],
|
"@next/swc-linux-x64-musl": ["@next/swc-linux-x64-musl@15.3.5", "", { "os": "linux", "cpu": "x64" }, "sha512-TRYIqAGf1KCbuAB0gjhdn5Ytd8fV+wJSM2Nh2is/xEqR8PZHxfQuaiNhoF50XfY90sNpaRMaGhF6E+qjV1b9Tg=="],
|
||||||
|
|
||||||
"@next/swc-win32-arm64-msvc": ["@next/swc-win32-arm64-msvc@15.5.2", "", { "os": "win32", "cpu": "arm64" }, "sha512-sMPyTvRcNKXseNQ/7qRfVRLa0VhR0esmQ29DD6pqvG71+JdVnESJaHPA8t7bc67KD5spP3+DOCNLhqlEI2ZgQg=="],
|
"@next/swc-win32-arm64-msvc": ["@next/swc-win32-arm64-msvc@15.3.5", "", { "os": "win32", "cpu": "arm64" }, "sha512-h04/7iMEUSMY6fDGCvdanKqlO1qYvzNxntZlCzfE8i5P0uqzVQWQquU1TIhlz0VqGQGXLrFDuTJVONpqGqjGKQ=="],
|
||||||
|
|
||||||
"@next/swc-win32-ia32-msvc": ["@next/swc-win32-ia32-msvc@14.2.32", "", { "os": "win32", "cpu": "ia32" }, "sha512-jHUeDPVHrgFltqoAqDB6g6OStNnFxnc7Aks3p0KE0FbwAvRg6qWKYF5mSTdCTxA3axoSAUwxYdILzXJfUwlHhA=="],
|
"@next/swc-win32-ia32-msvc": ["@next/swc-win32-ia32-msvc@14.2.32", "", { "os": "win32", "cpu": "ia32" }, "sha512-jHUeDPVHrgFltqoAqDB6g6OStNnFxnc7Aks3p0KE0FbwAvRg6qWKYF5mSTdCTxA3axoSAUwxYdILzXJfUwlHhA=="],
|
||||||
|
|
||||||
"@next/swc-win32-x64-msvc": ["@next/swc-win32-x64-msvc@15.5.2", "", { "os": "win32", "cpu": "x64" }, "sha512-W5VvyZHnxG/2ukhZF/9Ikdra5fdNftxI6ybeVKYvBPDtyx7x4jPPSNduUkfH5fo3zG0JQ0bPxgy41af2JX5D4Q=="],
|
"@next/swc-win32-x64-msvc": ["@next/swc-win32-x64-msvc@15.3.5", "", { "os": "win32", "cpu": "x64" }, "sha512-5fhH6fccXxnX2KhllnGhkYMndhOiLOLEiVGYjP2nizqeGWkN10sA9taATlXwake2E2XMvYZjjz0Uj7T0y+z1yw=="],
|
||||||
|
|
||||||
"@nodelib/fs.scandir": ["@nodelib/fs.scandir@2.1.5", "", { "dependencies": { "@nodelib/fs.stat": "2.0.5", "run-parallel": "^1.1.9" } }, "sha512-vq24Bq3ym5HEQm2NKCr3yXDwjc7vTsEThRDnkp2DK9p1uqLR+DHurm/NOTo0KG7HYHU7eppKZj3MyqYuMBf62g=="],
|
"@nodelib/fs.scandir": ["@nodelib/fs.scandir@2.1.5", "", { "dependencies": { "@nodelib/fs.stat": "2.0.5", "run-parallel": "^1.1.9" } }, "sha512-vq24Bq3ym5HEQm2NKCr3yXDwjc7vTsEThRDnkp2DK9p1uqLR+DHurm/NOTo0KG7HYHU7eppKZj3MyqYuMBf62g=="],
|
||||||
|
|
||||||
@@ -2440,7 +2440,7 @@
|
|||||||
|
|
||||||
"netmask": ["netmask@2.0.2", "", {}, "sha512-dBpDMdxv9Irdq66304OLfEmQ9tbNRFnFTuZiLo+bD+r332bBmMJ8GBLXklIXXgxd3+v9+KUnZaUR5PJMa75Gsg=="],
|
"netmask": ["netmask@2.0.2", "", {}, "sha512-dBpDMdxv9Irdq66304OLfEmQ9tbNRFnFTuZiLo+bD+r332bBmMJ8GBLXklIXXgxd3+v9+KUnZaUR5PJMa75Gsg=="],
|
||||||
|
|
||||||
"next": ["next@15.5.2", "", { "dependencies": { "@next/env": "15.5.2", "@swc/helpers": "0.5.15", "caniuse-lite": "^1.0.30001579", "postcss": "8.4.31", "styled-jsx": "5.1.6" }, "optionalDependencies": { "@next/swc-darwin-arm64": "15.5.2", "@next/swc-darwin-x64": "15.5.2", "@next/swc-linux-arm64-gnu": "15.5.2", "@next/swc-linux-arm64-musl": "15.5.2", "@next/swc-linux-x64-gnu": "15.5.2", "@next/swc-linux-x64-musl": "15.5.2", "@next/swc-win32-arm64-msvc": "15.5.2", "@next/swc-win32-x64-msvc": "15.5.2", "sharp": "^0.34.3" }, "peerDependencies": { "@opentelemetry/api": "^1.1.0", "@playwright/test": "^1.51.1", "babel-plugin-react-compiler": "*", "react": "^18.2.0 || 19.0.0-rc-de68d2f4-20241204 || ^19.0.0", "react-dom": "^18.2.0 || 19.0.0-rc-de68d2f4-20241204 || ^19.0.0", "sass": "^1.3.0" }, "optionalPeers": ["@opentelemetry/api", "@playwright/test", "babel-plugin-react-compiler", "sass"], "bin": { "next": "dist/bin/next" } }, "sha512-H8Otr7abj1glFhbGnvUt3gz++0AF1+QoCXEBmd/6aKbfdFwrn0LpA836Ed5+00va/7HQSDD+mOoVhn3tNy3e/Q=="],
|
"next": ["next@15.3.6", "", { "dependencies": { "@next/env": "15.3.6", "@swc/counter": "0.1.3", "@swc/helpers": "0.5.15", "busboy": "1.6.0", "caniuse-lite": "^1.0.30001579", "postcss": "8.4.31", "styled-jsx": "5.1.6" }, "optionalDependencies": { "@next/swc-darwin-arm64": "15.3.5", "@next/swc-darwin-x64": "15.3.5", "@next/swc-linux-arm64-gnu": "15.3.5", "@next/swc-linux-arm64-musl": "15.3.5", "@next/swc-linux-x64-gnu": "15.3.5", "@next/swc-linux-x64-musl": "15.3.5", "@next/swc-win32-arm64-msvc": "15.3.5", "@next/swc-win32-x64-msvc": "15.3.5", "sharp": "^0.34.1" }, "peerDependencies": { "@opentelemetry/api": "^1.1.0", "@playwright/test": "^1.41.2", "babel-plugin-react-compiler": "*", "react": "^18.2.0 || 19.0.0-rc-de68d2f4-20241204 || ^19.0.0", "react-dom": "^18.2.0 || 19.0.0-rc-de68d2f4-20241204 || ^19.0.0", "sass": "^1.3.0" }, "optionalPeers": ["@opentelemetry/api", "@playwright/test", "babel-plugin-react-compiler", "sass"], "bin": { "next": "dist/bin/next" } }, "sha512-oI6D1zbbsh6JzzZFDCSHnnx6Qpvd1fSkVJu/5d8uluqnxzuoqtodVZjYvNovooznUq8udSAiKp7MbwlfZ8Gm6w=="],
|
||||||
|
|
||||||
"next-intl": ["next-intl@3.26.5", "", { "dependencies": { "@formatjs/intl-localematcher": "^0.5.4", "negotiator": "^1.0.0", "use-intl": "^3.26.5" }, "peerDependencies": { "next": "^10.0.0 || ^11.0.0 || ^12.0.0 || ^13.0.0 || ^14.0.0 || ^15.0.0", "react": "^16.8.0 || ^17.0.0 || ^18.0.0 || >=19.0.0-rc <19.0.0 || ^19.0.0" } }, "sha512-EQlCIfY0jOhRldiFxwSXG+ImwkQtDEfQeSOEQp6ieAGSLWGlgjdb/Ck/O7wMfC430ZHGeUKVKax8KGusTPKCgg=="],
|
"next-intl": ["next-intl@3.26.5", "", { "dependencies": { "@formatjs/intl-localematcher": "^0.5.4", "negotiator": "^1.0.0", "use-intl": "^3.26.5" }, "peerDependencies": { "next": "^10.0.0 || ^11.0.0 || ^12.0.0 || ^13.0.0 || ^14.0.0 || ^15.0.0", "react": "^16.8.0 || ^17.0.0 || ^18.0.0 || >=19.0.0-rc <19.0.0 || ^19.0.0" } }, "sha512-EQlCIfY0jOhRldiFxwSXG+ImwkQtDEfQeSOEQp6ieAGSLWGlgjdb/Ck/O7wMfC430ZHGeUKVKax8KGusTPKCgg=="],
|
||||||
|
|
||||||
|
|||||||
@@ -5,8 +5,8 @@ FROM oven/bun:latest AS base
|
|||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
||||||
# Create a non-root user for running the production application
|
# Create a non-root user for running the production application
|
||||||
RUN addgroup --system --gid 1001 nodejs \
|
RUN groupadd -r -g 1001 nodejs && \
|
||||||
&& adduser --system --uid 1001 nextjs
|
useradd -r -u 1001 -g nodejs -d /home/nextjs -m nextjs
|
||||||
|
|
||||||
# Change to non-root user
|
# Change to non-root user
|
||||||
USER nextjs
|
USER nextjs
|
||||||
|
|||||||
@@ -5,8 +5,8 @@ FROM oven/bun:latest AS base
|
|||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
||||||
# Create non-root user and set permissions
|
# Create non-root user and set permissions
|
||||||
RUN addgroup --system --gid 1001 nodejs \
|
RUN groupadd -r -g 1001 nodejs && \
|
||||||
&& adduser --system --uid 1001 nextjs
|
useradd -r -u 1001 -g nodejs -d /home/nextjs -m nextjs
|
||||||
|
|
||||||
# Copy build output and static files
|
# Copy build output and static files
|
||||||
COPY ./apps/user/.next/standalone ./
|
COPY ./apps/user/.next/standalone ./
|
||||||
|
|||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "ppanel-web",
|
"name": "ppanel-web",
|
||||||
"version": "1.3.1",
|
"version": "1.3.2",
|
||||||
"private": true,
|
"private": true,
|
||||||
"homepage": "https://github.com/perfect-panel/ppanel-web",
|
"homepage": "https://github.com/perfect-panel/ppanel-web",
|
||||||
"bugs": {
|
"bugs": {
|
||||||
|
|||||||
Reference in New Issue
Block a user