chore: 尝试修复GitHub登录
This commit is contained in:
parent
4b64827c1d
commit
c037ac1db5
43
app/[lng]/welcome/page.tsx
Normal file
43
app/[lng]/welcome/page.tsx
Normal file
|
@ -0,0 +1,43 @@
|
|||
import { createClient } from "@/utils/supabase/server";
|
||||
import Link from "next/link";
|
||||
import { cookies } from "next/headers";
|
||||
import { redirect } from "next/navigation";
|
||||
import LoadingIndicator from "@/components/LoadingIndicator"; // 确保路径正确
|
||||
import { insertUserProfile } from "@/utils/supabase/supabaseutils";
|
||||
import React from "react";
|
||||
export default async function WelcomeScreen() {
|
||||
const [isLoading, setIsLoading] = React.useState(true);
|
||||
const cookieStore = cookies();
|
||||
const supabase = createClient(cookieStore);
|
||||
|
||||
const {
|
||||
data,
|
||||
data: { user },
|
||||
} = await supabase.auth.getUser();
|
||||
//profiles表 插入用户信息
|
||||
await insertUserProfile(data, supabase);
|
||||
setIsLoading(false);
|
||||
//2秒后跳转到首页
|
||||
setTimeout(() => {
|
||||
redirect("/");
|
||||
}, 1000);
|
||||
|
||||
return user ? (
|
||||
<div className="flex items-center gap-4">
|
||||
Hey, {user.email}!
|
||||
<div style={{ margin: "20px", textAlign: "center" }}>
|
||||
<h1>welcome, {user.email}!</h1>
|
||||
</div>
|
||||
</div>
|
||||
) : (
|
||||
<Link
|
||||
href="/login"
|
||||
className="py-2 px-3 flex rounded-md no-underline bg-btn-background hover:bg-btn-background-hover"
|
||||
>
|
||||
Login
|
||||
</Link>
|
||||
);
|
||||
{
|
||||
isLoading ? <LoadingIndicator /> : null;
|
||||
}
|
||||
}
|
|
@ -4,6 +4,7 @@ import React, { useState, useEffect, useRef } from "react";
|
|||
import Quill from "quill";
|
||||
import "quill/dist/quill.snow.css";
|
||||
import { useLocalStorage } from "react-use";
|
||||
import * as Sentry from "@sentry/react";
|
||||
|
||||
// 一些工具函数导入
|
||||
import getArxivPapers from "./GetArxiv";
|
||||
|
@ -93,7 +94,7 @@ const QEditor = ({ lng }) => {
|
|||
//quill编辑器鼠标位置
|
||||
const [cursorPosition, setCursorPosition] = useLocalStorage<number | null>(
|
||||
"光标位置",
|
||||
null
|
||||
0
|
||||
);
|
||||
//
|
||||
// 初始化 Quill 编辑器
|
||||
|
@ -508,6 +509,7 @@ const QEditor = ({ lng }) => {
|
|||
autoClose: 3000,
|
||||
pauseOnHover: true,
|
||||
});
|
||||
Sentry.captureMessage(`AI写作出现错误: ${error}`, "error");
|
||||
} finally {
|
||||
// 通用的后处理逻辑
|
||||
const updatedContent = quill!.root.innerHTML;
|
||||
|
|
|
@ -9,19 +9,19 @@ export function SignInGitHub() {
|
|||
const supabase = createClient();
|
||||
const { data: data } = supabase.auth.onAuthStateChange(
|
||||
async (event, session) => {
|
||||
if (event === "SIGNED_IN") {
|
||||
if (session && session.provider_token) {
|
||||
// 用户登录成功,执行后续操作
|
||||
await insertUserProfile(session!.user, supabase);
|
||||
Sentry.captureMessage("SignInGitHub中的SIGNED_IN成功", "info");
|
||||
console.log("SignInGitHub中的SIGNED_IN成功");
|
||||
} else {
|
||||
Sentry.captureMessage("SignInGitHub中成功", "info");
|
||||
console.log("SignInGitHub中成功");
|
||||
}
|
||||
|
||||
Sentry.captureMessage(
|
||||
`SignInGitHub中的非SIGNED_IN的event:${event}`,
|
||||
"warning"
|
||||
);
|
||||
console.log("SignInGitHub中的非SIGNED_IN的event:", event);
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
return () => {
|
||||
|
|
|
@ -90,7 +90,7 @@ const sendMessageToOpenAI = async (
|
|||
}
|
||||
// 克隆响应以备后用
|
||||
responseClone = response.clone();
|
||||
if (useEditorFlag) {
|
||||
if (useEditorFlag && editor && cursorPosition !== null) {
|
||||
const reader = response.body!.getReader();
|
||||
const decoder = new TextDecoder();
|
||||
//开始前先进行换行
|
||||
|
|
Loading…
Reference in New Issue
Block a user