Skip to content

Commit

Permalink
update link
Browse files Browse the repository at this point in the history
  • Loading branch information
zmh-program committed Oct 23, 2023
1 parent 3bc8b89 commit 435308d
Show file tree
Hide file tree
Showing 7 changed files with 67 additions and 52 deletions.
2 changes: 2 additions & 0 deletions adapter/claude/chat.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
})
}
4 changes: 2 additions & 2 deletions app/src/assets/share-manager.less
Original file line number Diff line number Diff line change
@@ -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;

Expand Down
8 changes: 5 additions & 3 deletions app/src/components/home/SideBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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";

Expand Down Expand Up @@ -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"),
Expand Down
42 changes: 21 additions & 21 deletions app/src/components/ui/table.tsx
Original file line number Diff line number Diff line change
@@ -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,
Expand All @@ -13,16 +13,16 @@ const Table = React.forwardRef<
{...props}
/>
</div>
))
Table.displayName = "Table"
));
Table.displayName = "Table";

const TableHeader = React.forwardRef<
HTMLTableSectionElement,
React.HTMLAttributes<HTMLTableSectionElement>
>(({ className, ...props }, ref) => (
<thead ref={ref} className={cn("[&_tr]:border-b", className)} {...props} />
))
TableHeader.displayName = "TableHeader"
));
TableHeader.displayName = "TableHeader";

const TableBody = React.forwardRef<
HTMLTableSectionElement,
Expand All @@ -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,
Expand All @@ -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,
Expand All @@ -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,
Expand All @@ -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,
Expand All @@ -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,
Expand All @@ -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,
Expand All @@ -111,4 +111,4 @@ export {
TableRow,
TableCell,
TableCaption,
}
};
3 changes: 2 additions & 1 deletion app/src/conf.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion app/src/i18n.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
58 changes: 34 additions & 24 deletions app/src/routes/ShareManagement.tsx
Original file line number Diff line number Diff line change
@@ -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,
Expand All @@ -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();
Expand All @@ -54,9 +58,9 @@ function ShareTable({ data }: ShareTableProps) {
<TableHeader>
<TableRow>
<TableHead>ID</TableHead>
<TableHead>{t('share.name')}</TableHead>
<TableHead>{t('share.time')}</TableHead>
<TableHead>{t('share.action')}</TableHead>
<TableHead>{t("share.name")}</TableHead>
<TableHead>{t("share.time")}</TableHead>
<TableHead>{t("share.action")}</TableHead>
</TableRow>
</TableHeader>
<TableBody>
Expand All @@ -73,15 +77,19 @@ function ShareTable({ data }: ShareTableProps) {
</Button>
</DropdownMenuTrigger>
<DropdownMenuContent align={`center`}>
<DropdownMenuItem onClick={() => {
window.open(getSharedLink(row.hash), '_blank');
}}>
<DropdownMenuItem
onClick={() => {
window.open(getSharedLink(row.hash), "_blank");
}}
>
<Eye className={`h-4 w-4 mr-1`} />
{t("share.view")}
</DropdownMenuItem>
<DropdownMenuItem onClick={async () => {
await deleteData(dispatch, row.hash);
}}>
<DropdownMenuItem
onClick={async () => {
await deleteData(dispatch, row.hash);
}}
>
<Trash2 className={`h-4 w-4 mr-1`} />
{t("conversation.delete")}
</DropdownMenuItem>
Expand All @@ -92,7 +100,7 @@ function ShareTable({ data }: ShareTableProps) {
))}
</TableBody>
</Table>
)
);
}

function ShareManagement() {
Expand All @@ -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({
Expand All @@ -113,7 +123,7 @@ function ShareManagement() {
});
}
}
}, [init]);
}, [init, auth]);

return (
<Dialog open={open} onOpenChange={(open) => dispatch(setDialog(open))}>
Expand Down

0 comments on commit 435308d

Please sign in to comment.