From c037ac1db515d6f2ba9eb05d819dc5aeaba73c90 Mon Sep 17 00:00:00 2001
From: 14790897 <14790897abc@gmail.com>
Date: Wed, 6 Mar 2024 21:41:44 +0800
Subject: [PATCH] =?UTF-8?q?chore:=20=E5=B0=9D=E8=AF=95=E4=BF=AE=E5=A4=8DGi?=
=?UTF-8?q?tHub=E7=99=BB=E5=BD=95?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
app/[lng]/welcome/page.tsx | 43 +++++++++++++++++++++++++++++++++++++
components/QuillEditor.tsx | 4 +++-
components/SignInGitHub.tsx | 18 ++++++++--------
components/chatAI.tsx | 2 +-
4 files changed, 56 insertions(+), 11 deletions(-)
create mode 100644 app/[lng]/welcome/page.tsx
diff --git a/app/[lng]/welcome/page.tsx b/app/[lng]/welcome/page.tsx
new file mode 100644
index 0000000..e92a488
--- /dev/null
+++ b/app/[lng]/welcome/page.tsx
@@ -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 ? (
+
+ Hey, {user.email}!
+
+
welcome, {user.email}!
+
+
+ ) : (
+
+ Login
+
+ );
+ {
+ isLoading ? : null;
+ }
+}
diff --git a/components/QuillEditor.tsx b/components/QuillEditor.tsx
index 9b523c6..0c73ef6 100644
--- a/components/QuillEditor.tsx
+++ b/components/QuillEditor.tsx
@@ -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(
"光标位置",
- 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;
diff --git a/components/SignInGitHub.tsx b/components/SignInGitHub.tsx
index c71d286..ff9df5e 100644
--- a/components/SignInGitHub.tsx
+++ b/components/SignInGitHub.tsx
@@ -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);
}
);
diff --git a/components/chatAI.tsx b/components/chatAI.tsx
index d79c29b..f18c544 100644
--- a/components/chatAI.tsx
+++ b/components/chatAI.tsx
@@ -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();
//开始前先进行换行