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

feat: 修复头像问题,调整鉴权页面,更新后端接口 #139

Merged
merged 7 commits into from
Oct 30, 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
4 changes: 2 additions & 2 deletions .env.development
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
NEXT_PUBLIC_SERVER_URL=http://localhost:8080
NEXT_PUBLIC_WS_URL=ws://localhost:8080
NEXT_PUBLIC_SERVER_URL=http://1.117.152.40:8080
NEXT_PUBLIC_WS_URL=ws://1.117.152.40:8080

MODEL_API_BASE_URL=https://dashscope.aliyuncs.com/api/v1/apps/

Expand Down
1 change: 0 additions & 1 deletion .env.production
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# TODO 生产环境域名
NEXT_PUBLIC_SERVER_URL=http://1.117.152.40:8080
NEXT_PUBLIC_WS_URL=ws://1.117.152.40:8080

Expand Down
28 changes: 28 additions & 0 deletions src/app/cooperation/layout.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,35 @@
'use client';

import { useEffect } from 'react';
import { usePathname, useRouter } from 'next/navigation';

import { PATHS, STORAGE_KEY_AUTH } from '@/utils/constants';
import { useAuthStore } from '@/store/authStore';

export default function CooperationLayout({
children,
}: Readonly<{
children: React.ReactNode;
}>) {
const { setAuth, getAuth } = useAuthStore();
const router = useRouter();
const pathname = usePathname();
useEffect(() => {
let auth = getAuth();

if (!auth.access_token) {
const storagedAuth = localStorage.getItem(STORAGE_KEY_AUTH);

if (storagedAuth) {
auth = JSON.parse(storagedAuth);
setAuth(auth);
}
}

if (!auth.access_token) {
router.push(`${PATHS.LOGIN}?redirect=${pathname}`);
}
}, [pathname]);

return <div className=" flex w-[100vw] h-[100vh] overflow-hidden">{children}</div>;
}
4 changes: 2 additions & 2 deletions src/app/edit/[projectId]/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ const Page: React.FC<{ children: React.ReactNode; params: any }> = ({ children,
</div>
<div className=" w-full flex flex-1 overflow-hidden">
{/* 侧边栏 */}
<div className="bg-[#2e3138] text-gray-400 w-[2.9vw] flex flex-col justify-between items-center py-4">
<div className="bg-[#2e3138] text-gray-400 w-[2.9vw] flex flex-col justify-between items-center py-4 z-50">
<div className="flex flex-col items-center space-y-6">
<Link href={`/edit/${params.projectId}/file`}>
<FaFileAlt
Expand Down Expand Up @@ -226,7 +226,7 @@ const Page: React.FC<{ children: React.ReactNode; params: any }> = ({ children,
</Panel>
<ResizeHandle className=" w-[3px] bg-transparent" />
<Panel className="bg-[#202327]" minSize={1} defaultSize={35}>
<div className=" h-full">
<div className=" h-full z-[999]">
<Preview />
</div>
</Panel>
Expand Down
32 changes: 0 additions & 32 deletions src/app/layout.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
'use client';

import { Inter } from 'next/font/google';
import { useEffect } from 'react';
import { usePathname, useRouter } from 'next/navigation';

import NextProcessLoader from '@/components/nextTopLoader';
import { PATHS, PATHS_SKIPPED_AUTH, STORAGE_KEY_AUTH } from '@/utils/constants';
import { useAuthStore } from '@/store/authStore';

import './globals.css';
import './xterm.css';
Expand All @@ -18,34 +14,6 @@ export default function RootLayout({
}: Readonly<{
children: React.ReactNode;
}>) {
const { setAuth, getAuth } = useAuthStore();
const router = useRouter();
const pathname = usePathname();

useEffect(() => {
// 首先,从zustand获取登录信息
let auth = getAuth();

// TODO 使用localstorage存放登录信息不合适
// 如果zustand中没有登录信息,则从localStorage中读取
if (!auth.access_token) {
const storagedAuth = localStorage.getItem(STORAGE_KEY_AUTH);

if (storagedAuth) {
// 将localStorage中的登录信息同步到zustand
auth = JSON.parse(storagedAuth);

setAuth(auth);
}
}

if (!PATHS_SKIPPED_AUTH.includes(pathname) && !auth.access_token) {
// 当前路由需登录但未登录时,跳转到登录页
// FIXME: 跳转时,会短暂显示目标页,再跳转到登录页
router.push(`${PATHS.LOGIN}?redirect=${pathname}`);
}
}, [pathname]);

return (
<html lang="en" suppressHydrationWarning>
<body className={inter.className}>
Expand Down
4 changes: 2 additions & 2 deletions src/components/cooperation/avatarList/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ export const AnimatedTooltip = ({
items,
}: {
items: {
id: number;
id: string;
name: string;
designation: string;
image: string;
}[];
}) => {
const [hoveredIndex, setHoveredIndex] = useState<number | null>(null);
const [hoveredIndex, setHoveredIndex] = useState<string | null>(null);

return (
<div className="flex flex-row gap-2">
Expand Down
Loading
Loading