再次修复问题

This commit is contained in:
海龙 2025-08-28 22:18:30 +08:00
parent 89b8413fd1
commit 92d6425333
6 changed files with 344 additions and 158 deletions

View File

@ -1,2 +1,3 @@
NEXT_PUBLIC_JAVA_URL = https://77.app.java.auth.qikongjian.com
NEXT_PUBLIC_BASE_URL = https://77.smartvideo.py.qikongjian.com
NEXT_PUBLIC_API_BASE_URL = https://77.api.qikongjian.com

View File

@ -1,3 +1,4 @@
# NEXT_PUBLIC_BASE_URL = https://77.smartvideo.py.qikongjian.com
NEXT_PUBLIC_BASE_URL = https://pre.movieflow.api.huiying.video
NEXT_PUBLIC_API_BASE_URL = https://77.api.qikongjian.com
NEXT_PUBLIC_JAVA_URL = https://77.app.java.auth.qikongjian.com

View File

@ -3,12 +3,14 @@
import React, { useState } from 'react';
import { useRouter } from 'next/navigation';
import Link from 'next/link';
import { signInWithGoogle } from '@/lib/auth';
import { signInWithGoogle, registerUser } from '@/lib/auth';
import { GradientText } from '@/components/ui/gradient-text';
export default function SignupPage() {
const [name, setName] = useState('');
const [email, setEmail] = useState('');
const [password, setPassword] = useState('');
const [inviteCode, setInviteCode] = useState('');
const [isSubmitting, setIsSubmitting] = useState(false);
const [formError, setFormError] = useState('');
const router = useRouter();
@ -19,17 +21,19 @@ export default function SignupPage() {
setFormError('');
try {
// Here you would connect to your backend API for registration
console.log('Signing up', { name, email, password });
// Use new registration API
await registerUser({
userName: name,
email,
password,
inviteCode: inviteCode || undefined,
});
// Simulate successful registration
setTimeout(() => {
// Redirect to login page with success message
// Redirect to login page after successful registration
router.push('/login?registered=true');
}, 1500);
} catch (error) {
} catch (error: any) {
console.error('Signup error:', error);
setFormError('Something went wrong. Please try again.');
setFormError(error.message || 'Registration failed, please try again');
} finally {
setIsSubmitting(false);
}
@ -40,11 +44,46 @@ export default function SignupPage() {
};
return (
<div className="min-h-screen bg-[#0C0E11] flex items-center justify-center p-4">
<div className="w-full max-w-md bg-[#13151d]/90 backdrop-blur-xl rounded-3xl p-8 shadow-xl">
<h1 className="text-4xl font-bold text-white mb-8 text-center">Sign Up, for free</h1>
<div className="min-h-screen relative overflow-hidden">
{/* 背景视频 */}
<video
autoPlay
loop
muted
playsInline
className="absolute inset-0 w-full h-full object-cover"
data-alt="background-video"
>
<source src="/assets/login.mp4" type="video/mp4" />
</video>
<form onSubmit={handleSubmit} className="space-y-6">
{/* 视频遮罩层 */}
<div className="absolute inset-0 bg-black/20" data-alt="video-overlay"></div>
{/* Logo */}
<div className="absolute top-8 left-8 z-10" data-alt="logo-container">
<span className="logo-heart">
<GradientText
text="MovieFlow"
startPercentage={30}
endPercentage={70}
/>
</span>
{/* beta标签 */}
<span className="inline-flex items-center px-1.5 py-0.5 text-[8px] font-semibold tracking-wider text-[rgb(212 202 202)] border border-[rgba(106,244,249,0.2)] rounded-full shadow-[0_0_10px_rgba(106,244,249,0.1)]">
Beta
</span>
</div>
{/* 注册框 - 居中显示 */}
<div className="relative bottom-4 z-10 flex items-center justify-center min-h-screen p-4">
<div className="max-w-md w-full bg-black/40 backdrop-blur-lg border border-white/20 rounded-2xl p-8 shadow-2xl">
<div className="text-center mb-6">
<h2 className="text-2xl font-bold text-white mb-4">Sign Up, for free</h2>
<p className="text-gray-300">Create your account to get started</p>
</div>
<form onSubmit={handleSubmit} className="space-y-4">
<div>
<label className="block text-sm font-medium text-white mb-1">Name</label>
<input
@ -53,7 +92,7 @@ export default function SignupPage() {
value={name}
onChange={(e) => setName(e.target.value)}
required
className="w-full px-4 py-3 rounded-lg bg-[#1c1e29] border border-gray-700 text-white focus:outline-none focus:ring-2 focus:ring-purple-500"
className="w-full px-4 py-3 rounded-lg bg-black/30 border border-white/20 text-white placeholder-gray-400 focus:outline-none focus:ring-2 focus:ring-purple-500 focus:border-transparent"
/>
</div>
@ -65,7 +104,7 @@ export default function SignupPage() {
value={email}
onChange={(e) => setEmail(e.target.value)}
required
className="w-full px-4 py-3 rounded-lg bg-[#1c1e29] border border-gray-700 text-white focus:outline-none focus:ring-2 focus:ring-purple-500"
className="w-full px-4 py-3 rounded-lg bg-black/30 border border-white/20 text-white placeholder-gray-400 focus:outline-none focus:ring-2 focus:ring-purple-500 focus:border-transparent"
/>
</div>
@ -77,20 +116,33 @@ export default function SignupPage() {
value={password}
onChange={(e) => setPassword(e.target.value)}
required
className="w-full px-4 py-3 rounded-lg bg-[#1c1e29] border border-gray-700 text-white focus:outline-none focus:ring-2 focus:ring-purple-500"
className="w-full px-4 py-3 rounded-lg bg-black/30 border border-white/20 text-white placeholder-gray-400 focus:outline-none focus:ring-2 focus:ring-purple-500 focus:border-transparent"
/>
</div>
<div>
<label className="block text-sm font-medium text-white mb-1">Invite Code (Optional)</label>
<input
type="text"
placeholder="Enter invite code if you have one"
value={inviteCode}
onChange={(e) => setInviteCode(e.target.value)}
className="w-full px-4 py-3 rounded-lg bg-black/30 border border-white/20 text-white placeholder-gray-400 focus:outline-none focus:ring-2 focus:ring-purple-500 focus:border-transparent"
/>
</div>
{formError && (
<div className="text-red-500 text-sm">{formError}</div>
<div className="bg-red-500/20 text-red-300 p-3 rounded-lg border border-red-500/20">
{formError}
</div>
)}
<div className="flex gap-4 mt-8">
<div className="flex gap-4 mt-6">
<Link
href="/login"
className="flex-1 py-3 text-center border border-gray-600 rounded-lg text-white hover:bg-white/10 transition-colors"
className="flex-1 py-3 text-center border border-white/20 rounded-lg text-white hover:bg-white/10 transition-colors"
>
Back to home
Back to login
</Link>
<button
type="submit"
@ -103,27 +155,24 @@ export default function SignupPage() {
</form>
<div className="my-6 relative flex items-center">
<div className="flex-grow border-t border-gray-700"></div>
<div className="flex-grow border-t border-gray-500/30"></div>
<span className="flex-shrink mx-4 text-gray-400">or</span>
<div className="flex-grow border-t border-gray-700"></div>
<div className="flex-grow border-t border-gray-500/30"></div>
</div>
<button
onClick={handleGoogleSignIn}
className="w-full flex items-center justify-center gap-3 py-3 border border-gray-600 rounded-lg text-white hover:bg-white/5 transition-colors"
className="w-full flex items-center justify-center gap-3 py-3 border border-white/20 rounded-lg text-white hover:bg-white/5 transition-colors bg-black/30"
>
<img src="https://www.gstatic.com/firebasejs/ui/2.0.0/images/auth/google.svg" className="w-5 h-5" alt="Google" />
Continue with Google
</button>
{/* Success message */}
<div className="hidden text-green-400 text-sm mt-4 text-center">
Thank you! Your submission has been received!
<div className="text-center mt-4">
<p style={{ color: "rgba(255, 255, 255, 0.6)" }}>
Already have an account? <Link href="/login" className="text-purple-400 hover:text-purple-300">Login</Link>
</p>
</div>
{/* Error message */}
<div className="hidden text-red-400 text-sm mt-4 text-center">
Oops! Something went wrong while submitting the form.
</div>
</div>
</div>

View File

@ -16,7 +16,7 @@ export default function AuthGuard({ children }: AuthGuardProps) {
const pathname = usePathname();
// 不需要鉴权的页面
const publicPaths = ['/login', '/signup', '/forgot-password'];
const publicPaths = ['/','/login', '/signup', '/forgot-password'];
const isPublicPath = publicPaths.includes(pathname);
useEffect(() => {

View File

@ -85,7 +85,7 @@ function HomeModule1() {
return (
<div className="home-module1 relative flex justify-center items-start pt-[28rem] w-full h-[1280px] bg-black snap-start">
<video
src="/assets/home.mp4"
src="https://cdn.qikongjian.com/videos/home.mp4"
autoPlay
loop
muted
@ -97,10 +97,10 @@ function HomeModule1() {
Ideas Become Movies
</h1>
<p className="text-white text-[2rem] leading-[140%] font-normal">
Next-Generation AI Movies Making Platform
One line, one filmyour story, your scene.
</p>
<p className="text-white text-[2rem] leading-[140%] font-normal">
From Ideas to Movies in just 5-10 minutes
Everyone is a movie master.
</p>
<div
className="w-[11.5rem] h-[3.75rem] mt-[4rem] text-base flex justify-center items-center font-normal border border-white rounded-full bg-white/30 cursor-pointer"
@ -118,15 +118,15 @@ function HomeModule2() {
const videoList = [
{
title: "Text to Movie",
video: "/assets/module2 (1).mp4",
video: "https://cdn.qikongjian.com/videos/module2 (1).mp4",
},
{
title: "Image to Movie",
video: "/assets/module2 (2).mp4",
video: "https://cdn.qikongjian.com/videos/module2 (2).mp4",
},
{
title: "Template to Movie",
video: "/assets/module2 (3).mp4",
video: "https://cdn.qikongjian.com/videos/module2 (3).mp4",
},
];
return (
@ -180,25 +180,25 @@ function HomeModule2() {
function HomeModule3() {
const videoList = [
[
"/assets/show (1).mp4",
"/assets/show (2).mp4",
"/assets/show (3).mp4",
"/assets/show (4).mp4",
"/assets/show (5).mp4",
"https://cdn.qikongjian.com/videos/show (1).mp4",
"https://cdn.qikongjian.com/videos/show (2).mp4",
"https://cdn.qikongjian.com/videos/show (3).mp4",
"https://cdn.qikongjian.com/videos/show (4).mp4",
"https://cdn.qikongjian.com/videos/show (5).mp4",
],
[
"/assets/show (6).mp4",
"/assets/show (7).mp4",
"/assets/show (8).mp4",
"/assets/show (9).mp4",
"/assets/show (10).mp4",
"https://cdn.qikongjian.com/videos/show (6).mp4",
"https://cdn.qikongjian.com/videos/show (7).mp4",
"https://cdn.qikongjian.com/videos/show (8).mp4",
"https://cdn.qikongjian.com/videos/show (9).mp4",
"https://cdn.qikongjian.com/videos/show (10).mp4",
],
[
"/assets/show (11).mp4",
"/assets/show (12).mp4",
"/assets/show (13).mp4",
"/assets/show (14).mp4",
"/assets/show (15).mp4",
"https://cdn.qikongjian.com/videos/show (11).mp4",
"https://cdn.qikongjian.com/videos/show (12).mp4",
"https://cdn.qikongjian.com/videos/show (13).mp4",
"https://cdn.qikongjian.com/videos/show (14).mp4",
"https://cdn.qikongjian.com/videos/show (15).mp4",
],
];
@ -312,25 +312,25 @@ function HomeModule4() {
title: "The Narrative Engine",
description:
" From a single thought, it builds entire worlds and compelling plots.",
video: "/assets/module4 (3).mp4",
video: "https://cdn.qikongjian.com/videos/module4 (3).mp4",
},
{
title: "AI Character Engine",
description:
"Cast your virtual actors. Lock them in once, for the entire story.",
video: "/assets/module4 (1).mp4",
video: "https://cdn.qikongjian.com/videos/module4 (1).mp4",
},
{
title: "AI vision engine",
description:
"It translates your aesthetic into art, light, and cinematography for every single shot.",
video: "/assets/module4 (4).mp4",
video: "https://cdn.qikongjian.com/videos/module4 (4).mp4",
},
{
title: "Intelligent Editing Engine",
description:
"An editing AI drives the final cut, for a story told seamlessly.",
video: "/assets/module4 (2).mp4",
video: "https://cdn.qikongjian.com/videos/module4 (2).mp4",
},
];
@ -476,8 +476,8 @@ function HomeModule5() {
throw new Error("create checkout session failed");
}
setShowCallbackModal(true)
window.open(result.data.checkout_url, '_blank');
setShowCallbackModal(true);
window.open(result.data.checkout_url, "_blank");
} catch (error) {
throw new Error("create checkout session failed, please try again later");
}

View File

@ -1,10 +1,11 @@
import { BASE_URL } from "@/api/constants";
import { post } from "@/api/request";
// API配置
const API_BASE_URL = process.env.NEXT_PUBLIC_API_BASE_URL || '';
const API_BASE_URL = process.env.NEXT_PUBLIC_BASE_URL || '';
const JAVA_BASE_URL = process.env.NEXT_PUBLIC_JAVA_URL || '';
// Token存储键
const TOKEN_KEY = 'X-EASE-ADMIN-TOKEN';
const TOKEN_KEY = 'token';
const USER_KEY = 'currentUser';
/**
@ -12,37 +13,26 @@ const USER_KEY = 'currentUser';
*/
export const loginUser = async (email: string, password: string) => {
try {
const response = await fetch(`${API_BASE_URL}/admin/login/signIn`, {
const response = await fetch(`${JAVA_BASE_URL}/api/user/login`, {
method: 'POST',
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json',
},
body: JSON.stringify({
userName: email,
username: email,
password: password,
}),
});
const data = await response.json();
if (data.code === '200' && data.status === 200) {
console.log('data', data)
// 保存token到本地存储
setToken(data.body.token);
setToken(data.token);
// 保存用户信息
const user = {
id: data.body.userId,
name: data.body.userName,
email: email,
token: data.body.token,
};
setUser(user);
const user = await getUserProfile();
return user;
} else {
throw new Error(data.msg || '登录失败');
}
} catch (error) {
console.error('Login failed:', error);
throw error;
@ -59,7 +49,7 @@ export const checkAuth = async (): Promise<boolean> => {
}
try {
const response = await fetch(`${API_BASE_URL}/admin/login/auth`, {
const response = await fetch(`${process.env.NEXT_PUBLIC_API_BASE_URL}/admin/login/auth`, {
method: 'POST',
headers: {
'Accept': 'application/json',
@ -69,14 +59,14 @@ export const checkAuth = async (): Promise<boolean> => {
});
const data = await response.json();
return true;
// if (data.code === '401' || data.status === 401) {
// // Token无效清除本地存储
// // clearAuthData();
// // return false;
// }
if (data.code === '401' || data.status === 401) {
// Token无效清除本地存储
clearAuthData();
return false;
}
return data.code === '200' && data.status === 200;
// return data.code === '200' && data.status === 200;
} catch (error) {
console.error('Auth check failed:', error);
return false;
@ -250,3 +240,148 @@ export const validateOAuthState = (state: string): boolean => {
// Validate that the returned state matches what we stored
return state === storedState;
};
/**
*
* @returns {Promise<any>}
*/
export const getUserProfile = async (): Promise<any> => {
try {
const token = getToken();
if (!token) {
throw new Error('No token available');
}
const response = await fetch(`${API_BASE_URL}/java-auth/profile`, {
method: 'GET',
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json',
'Authorization': `Bearer ${token}`,
},
});
if (!response.ok) {
throw new Error(`HTTP error! status: ${response.status}`);
}
const data = await response.json();
if (data.code === 0 && data.successful) {
// 更新本地存储的用户信息
const userInfo = {
id: data.data.user_id,
userId: data.data.user_id,
username: data.data.username,
name: data.data.name,
email: data.data.email,
role: data.data.role,
isActive: data.data.is_active,
authType: data.data.auth_type,
lastLogin: data.data.last_login,
};
setUser(userInfo);
return userInfo;
} else {
throw new Error(data.message || 'Failed to get user profile');
}
} catch (error) {
console.error('Get user profile failed:', error);
throw error;
}
};
/**
*
* @returns {Promise<any>}
*/
export const refreshUserProfile = async (): Promise<any> => {
try {
const profile = await getUserProfile();
return profile;
} catch (error) {
console.error('Refresh user profile failed:', error);
// 如果刷新失败,返回本地存储的用户信息
return getCurrentUser();
}
};
/**
*
* @param {string} requiredRole
* @returns {boolean}
*/
export const checkUserPermission = (requiredRole: string): boolean => {
const user = getCurrentUser();
if (!user || !user.role) {
return false;
}
// 角色权限等级
const roleHierarchy = {
'ADMIN': 3,
'MODERATOR': 2,
'USER': 1,
};
const userRoleLevel = roleHierarchy[user.role as keyof typeof roleHierarchy] || 0;
const requiredRoleLevel = roleHierarchy[requiredRole as keyof typeof roleHierarchy] || 0;
return userRoleLevel >= requiredRoleLevel;
};
/**
*
* @returns {boolean}
*/
export const isUserActive = (): boolean => {
const user = getCurrentUser();
return user?.isActive === 1;
};
/**
*
* @param {Object} params -
* @param {string} params.userName -
* @param {string} params.password -
* @param {string} params.email -
* @param {string} [params.inviteCode] -
* @returns {Promise<any>}
* @throws {Error}
*/
export const registerUser = async ({
userName,
password,
email,
inviteCode,
}: {
userName: string;
password: string;
email: string;
inviteCode?: string;
}): Promise<any> => {
try {
const response = await fetch(`${JAVA_BASE_URL}/api/user/register`, {
method: 'POST',
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json',
},
body: JSON.stringify({
userName,
password,
email,
inviteCode,
}),
});
const data = await response.json();
return data as {
success: boolean;
};
} catch (error) {
console.error('Register failed:', error);
throw error;
}
};