From 435308de419ec73ba2af1f66c643910770385cd1 Mon Sep 17 00:00:00 2001 From: Zhang Minghan Date: Mon, 23 Oct 2023 17:58:34 +0800 Subject: [PATCH] update link --- adapter/claude/chat.go | 2 + app/src/assets/share-manager.less | 4 +- app/src/components/home/SideBar.tsx | 8 ++-- app/src/components/ui/table.tsx | 42 ++++++++++----------- app/src/conf.ts | 3 +- app/src/i18n.ts | 2 +- app/src/routes/ShareManagement.tsx | 58 +++++++++++++++++------------ 7 files changed, 67 insertions(+), 52 deletions(-) diff --git a/adapter/claude/chat.go b/adapter/claude/chat.go index 582db7b8..ecde8964 100644 --- a/adapter/claude/chat.go +++ b/adapter/claude/chat.go @@ -90,6 +90,8 @@ func (c *ChatInstance) CreateStreamChatRequest(props *ChatProps, hook globals.Ho return err } } + + fmt.Println(fmt.Sprintf("anthropic error: cannot parse response: %s", data)) return nil }) } diff --git a/app/src/assets/share-manager.less b/app/src/assets/share-manager.less index 9d77da31..7de72084 100644 --- a/app/src/assets/share-manager.less +++ b/app/src/assets/share-manager.less @@ -1,7 +1,7 @@ .share-table { max-height: 60vh; - overflow-y: auto; - overflow-x: hidden; + max-width: 85vw; + overflow: auto; scrollbar-width: thin; padding: 0 0.5rem; diff --git a/app/src/components/home/SideBar.tsx b/app/src/components/home/SideBar.tsx index 501bd528..f82c088e 100644 --- a/app/src/components/home/SideBar.tsx +++ b/app/src/components/home/SideBar.tsx @@ -33,7 +33,10 @@ import { AlertDialogHeader, AlertDialogTitle, } from "../ui/alert-dialog.tsx"; -import {getSharedLink, shareConversation} from "../../conversation/sharing.ts"; +import { + getSharedLink, + shareConversation, +} from "../../conversation/sharing.ts"; import { Input } from "../ui/input.tsx"; import { login } from "../../conf.ts"; @@ -198,8 +201,7 @@ function SideBar() { const resp = await shareConversation( operateConversation?.target?.id || -1, ); - if (resp.status) - setShared(getSharedLink(resp.data)); + if (resp.status) setShared(getSharedLink(resp.data)); else toast({ title: t("share.failed"), diff --git a/app/src/components/ui/table.tsx b/app/src/components/ui/table.tsx index 346b5341..820dfed7 100644 --- a/app/src/components/ui/table.tsx +++ b/app/src/components/ui/table.tsx @@ -1,6 +1,6 @@ -import * as React from "react" +import * as React from "react"; -import { cn } from "./lib/utils.ts" +import { cn } from "./lib/utils.ts"; const Table = React.forwardRef< HTMLTableElement, @@ -13,16 +13,16 @@ const Table = React.forwardRef< {...props} /> -)) -Table.displayName = "Table" +)); +Table.displayName = "Table"; const TableHeader = React.forwardRef< HTMLTableSectionElement, React.HTMLAttributes >(({ className, ...props }, ref) => ( -)) -TableHeader.displayName = "TableHeader" +)); +TableHeader.displayName = "TableHeader"; const TableBody = React.forwardRef< HTMLTableSectionElement, @@ -33,8 +33,8 @@ const TableBody = React.forwardRef< className={cn("[&_tr:last-child]:border-0", className)} {...props} /> -)) -TableBody.displayName = "TableBody" +)); +TableBody.displayName = "TableBody"; const TableFooter = React.forwardRef< HTMLTableSectionElement, @@ -45,8 +45,8 @@ const TableFooter = React.forwardRef< className={cn("bg-primary font-medium text-primary-foreground", className)} {...props} /> -)) -TableFooter.displayName = "TableFooter" +)); +TableFooter.displayName = "TableFooter"; const TableRow = React.forwardRef< HTMLTableRowElement, @@ -56,12 +56,12 @@ const TableRow = React.forwardRef< ref={ref} className={cn( "border-b transition-colors hover:bg-muted/50 data-[state=selected]:bg-muted", - className + className, )} {...props} /> -)) -TableRow.displayName = "TableRow" +)); +TableRow.displayName = "TableRow"; const TableHead = React.forwardRef< HTMLTableCellElement, @@ -71,12 +71,12 @@ const TableHead = React.forwardRef< ref={ref} className={cn( "h-12 px-4 text-left align-middle font-medium text-muted-foreground [&:has([role=checkbox])]:pr-0", - className + className, )} {...props} /> -)) -TableHead.displayName = "TableHead" +)); +TableHead.displayName = "TableHead"; const TableCell = React.forwardRef< HTMLTableCellElement, @@ -87,8 +87,8 @@ const TableCell = React.forwardRef< className={cn("p-4 align-middle [&:has([role=checkbox])]:pr-0", className)} {...props} /> -)) -TableCell.displayName = "TableCell" +)); +TableCell.displayName = "TableCell"; const TableCaption = React.forwardRef< HTMLTableCaptionElement, @@ -99,8 +99,8 @@ const TableCaption = React.forwardRef< className={cn("mt-4 text-sm text-muted-foreground", className)} {...props} /> -)) -TableCaption.displayName = "TableCaption" +)); +TableCaption.displayName = "TableCaption"; export { Table, @@ -111,4 +111,4 @@ export { TableRow, TableCell, TableCaption, -} +}; diff --git a/app/src/conf.ts b/app/src/conf.ts index 077126f5..1d5ddc64 100644 --- a/app/src/conf.ts +++ b/app/src/conf.ts @@ -2,6 +2,7 @@ import axios from "axios"; import { Model } from "./conversation/types.ts"; export const version = "3.5.0"; +export const dev: boolean = window.location.hostname === "localhost"; export const deploy: boolean = true; export let rest_api: string = "http://localhost:8094"; export let ws_api: string = "ws://localhost:8094"; @@ -54,7 +55,7 @@ export const supportModels: Model[] = [ ]; export function login() { - location.href = "https://deeptrain.net/login?app=chatnio"; + location.href = `https://deeptrain.net/login?app=${dev ? "dev" : "chatnio"}`; } axios.defaults.baseURL = rest_api; diff --git a/app/src/i18n.ts b/app/src/i18n.ts index 0425f00b..856e624c 100644 --- a/app/src/i18n.ts +++ b/app/src/i18n.ts @@ -186,7 +186,7 @@ const resources = { "not-found": "Conversation not found", "not-found-description": "Conversation not found, please check if the link is correct or the conversation has been deleted", - manage: "Manage Share", + manage: "Share Management", "sync-error": "Sync Error", name: "Conversation Title", time: "Time", diff --git a/app/src/routes/ShareManagement.tsx b/app/src/routes/ShareManagement.tsx index 90f2b2a2..4241f9ad 100644 --- a/app/src/routes/ShareManagement.tsx +++ b/app/src/routes/ShareManagement.tsx @@ -1,17 +1,22 @@ import "../assets/share-manager.less"; import { useTranslation } from "react-i18next"; import { useDispatch, useSelector } from "react-redux"; -import {dialogSelector, dataSelector, syncData, deleteData} from "../store/sharing.ts"; +import { + dialogSelector, + dataSelector, + syncData, + deleteData, +} from "../store/sharing.ts"; import { useToast } from "../components/ui/use-toast.ts"; -import { selectInit } from "../store/auth.ts"; -import {useEffectAsync} from "../utils.ts"; +import { selectAuthenticated, selectInit } from "../store/auth.ts"; +import { useEffectAsync } from "../utils.ts"; import { Dialog, DialogContent, DialogDescription, DialogFooter, DialogHeader, - DialogTitle + DialogTitle, } from "../components/ui/dialog.tsx"; import { Table, @@ -21,22 +26,21 @@ import { TableHeader, TableRow, } from "../components/ui/table.tsx"; -import {closeDialog, setDialog} from "../store/sharing.ts"; -import {Button} from "../components/ui/button.tsx"; -import {useMemo} from "react"; -import {Eye, MoreHorizontal, Trash2} from "lucide-react"; +import { closeDialog, setDialog } from "../store/sharing.ts"; +import { Button } from "../components/ui/button.tsx"; +import { useMemo } from "react"; +import { Eye, MoreHorizontal, Trash2 } from "lucide-react"; import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, - DropdownMenuTrigger + DropdownMenuTrigger, } from "../components/ui/dropdown-menu.tsx"; -import {getSharedLink, SharingPreviewForm} from "../conversation/sharing.ts"; - +import { getSharedLink, SharingPreviewForm } from "../conversation/sharing.ts"; type ShareTableProps = { data: SharingPreviewForm[]; -} +}; function ShareTable({ data }: ShareTableProps) { const { t } = useTranslation(); @@ -54,9 +58,9 @@ function ShareTable({ data }: ShareTableProps) { ID - {t('share.name')} - {t('share.time')} - {t('share.action')} + {t("share.name")} + {t("share.time")} + {t("share.action")} @@ -73,15 +77,19 @@ function ShareTable({ data }: ShareTableProps) { - { - window.open(getSharedLink(row.hash), '_blank'); - }}> + { + window.open(getSharedLink(row.hash), "_blank"); + }} + > {t("share.view")} - { - await deleteData(dispatch, row.hash); - }}> + { + await deleteData(dispatch, row.hash); + }} + > {t("conversation.delete")} @@ -92,7 +100,7 @@ function ShareTable({ data }: ShareTableProps) { ))} - ) + ); } function ShareManagement() { @@ -102,9 +110,11 @@ function ShareManagement() { const data = useSelector(dataSelector); const { toast } = useToast(); const init = useSelector(selectInit); + const auth = useSelector(selectAuthenticated); useEffectAsync(async () => { - if (init) { + if (init && auth) { + if (data.length > 0) return; const resp = await syncData(dispatch); if (resp) { toast({ @@ -113,7 +123,7 @@ function ShareManagement() { }); } } - }, [init]); + }, [init, auth]); return ( dispatch(setDialog(open))}>