Skip to content

Commit

Permalink
chore: 尝试修复GitHub登录
Browse files Browse the repository at this point in the history
  • Loading branch information
14790897 committed Mar 6, 2024
1 parent 4b64827 commit c037ac1
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 11 deletions.
43 changes: 43 additions & 0 deletions app/[lng]/welcome/page.tsx
Original file line number Diff line number Diff line change
@@ -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 changes: 3 additions & 1 deletion components/QuillEditor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -93,7 +94,7 @@ const QEditor = ({ lng }) => {
//quill编辑器鼠标位置
const [cursorPosition, setCursorPosition] = useLocalStorage<number | null>(
"光标位置",
null
0
);
//
// 初始化 Quill 编辑器
Expand Down Expand Up @@ -508,6 +509,7 @@ const QEditor = ({ lng }) => {
autoClose: 3000,
pauseOnHover: true,
});
Sentry.captureMessage(`AI写作出现错误: ${error}`, "error");
} finally {
// 通用的后处理逻辑
const updatedContent = quill!.root.innerHTML;
Expand Down
18 changes: 9 additions & 9 deletions components/SignInGitHub.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,18 @@ 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中的非SIGNED_IN的event:${event}`,
"warning"
);
console.log("SignInGitHub中的非SIGNED_IN的event:", event);
Sentry.captureMessage("SignInGitHub中成功", "info");
console.log("SignInGitHub中成功");
}

Sentry.captureMessage(
`SignInGitHub中的非SIGNED_IN的event:${event}`,
"warning"
);
console.log("SignInGitHub中的非SIGNED_IN的event:", event);
}
);

Expand Down
2 changes: 1 addition & 1 deletion components/chatAI.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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();
//开始前先进行换行
Expand Down

0 comments on commit c037ac1

Please sign in to comment.