Skip to content

Commit

Permalink
fix type check
Browse files Browse the repository at this point in the history
  • Loading branch information
zmh-program committed Oct 31, 2023
1 parent b4ae053 commit 1d6bfb6
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 29 deletions.
78 changes: 50 additions & 28 deletions app/src/routes/Article.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import "@/assets/pages/article.less";
import { Button } from "@/components/ui/button.tsx";
import router from "@/router.tsx";
import {Check, ChevronLeft, Files, Globe, Loader2} from "lucide-react";
import { Check, ChevronLeft, Files, Globe, Loader2 } from "lucide-react";
import { Textarea } from "@/components/ui/textarea.tsx";
import { useTranslation } from "react-i18next";
import { useDispatch, useSelector } from "react-redux";
Expand All @@ -15,37 +15,40 @@ import {
import { useState } from "react";
import ModelSelector from "@/components/home/ModelSelector.tsx";
import { Toggle } from "@/components/ui/toggle.tsx";
import {selectModel, selectWeb, setWeb} from "@/store/chat.ts";
import { selectModel, selectWeb, setWeb } from "@/store/chat.ts";
import { Label } from "@/components/ui/label.tsx";
import {rest_api, tokenField, ws_api} from "@/conf.ts";
import { rest_api, tokenField, ws_api } from "@/conf.ts";
import { getMemory } from "@/utils/memory.ts";
import {Progress} from "@/components/ui/progress.tsx";
import { Progress } from "@/components/ui/progress.tsx";

type ProgressProps = {
current: number;
total: number;
}
};

function GenerateProgress({ current, total }: ProgressProps) {
const { t } = useTranslation();

return (
<div className={`article-progress w-full mb-4`}>
<p className={`select-none mt-4 mb-2.5 flex flex-row items-center content-center mx-auto w-max`}>
{
current === total ? <>
<Check className={`h-5 w-5 mr-2 inline-block animate-out`} />
{t('article.generate-success')}
</> :
<p
className={`select-none mt-4 mb-2.5 flex flex-row items-center content-center mx-auto w-max`}
>
{current === total ? (
<>
<Check className={`h-5 w-5 mr-2 inline-block animate-out`} />
{t("article.generate-success")}
</>
) : (
<>
<Loader2 className={`h-5 w-5 mr-2 inline-block animate-spin`} />
{t('article.progress-title', { current, total })}
{t("article.progress-title", { current, total })}
</>
}
)}
</p>
<Progress value={100 * current / total} />
<Progress value={(100 * current) / total} />
</div>
)
);
}

function ArticleContent() {
Expand Down Expand Up @@ -78,7 +81,10 @@ function ArticleContent() {
connection.send(
JSON.stringify({
token: getMemory(tokenField),
web, title, prompt, model,
web,
title,
prompt,
model,
}),
);
};
Expand Down Expand Up @@ -109,20 +115,36 @@ function ArticleContent() {
return progress ? (
<>
<GenerateProgress {...state} />
{
hash && (
<div className={`flex flex-row items-center mb-6`}>
<Button variant={`outline`} className={`mt-5 w-full mr-2`} onClick={() => {
{hash && (
<div className={`flex flex-row items-center mb-6`}>
<Button
variant={`outline`}
className={`mt-5 w-full mr-2`}
onClick={() => {
location.href = `${rest_api}/article/download/zip?hash=${hash}`;
}}> {t("article.download-format", { name: "zip" })} </Button>

<Button variant={`outline`} className={`mt-5 w-full ml-2`} onClick={() => {
}}
>
{" "}
{t("article.download-format", { name: "zip" })}{" "}
</Button>

<Button
variant={`outline`}
className={`mt-5 w-full ml-2`}
onClick={() => {
location.href = `${rest_api}/article/download/tar?hash=${hash}`;
}}> {t("article.download-format", { name: "tar" })} </Button>
</div>
)
}
<Button variant={`default`} className={`mt-5 w-full mx-auto`} onClick={clear}>
}}
>
{" "}
{t("article.download-format", { name: "tar" })}{" "}
</Button>
</div>
)}
<Button
variant={`default`}
className={`mt-5 w-full mx-auto`}
onClick={clear}
>
{t("close")}
</Button>
</>
Expand Down
1 change: 0 additions & 1 deletion app/src/routes/Auth.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { useToast } from "@/components/ui/use-toast.ts";
import { useLocation } from "react-router-dom";
import { ToastAction } from "@/components/ui/toast.tsx";
import { login, tokenField } from "@/conf.ts";
import { useEffect } from "react";
Expand Down

0 comments on commit 1d6bfb6

Please sign in to comment.