Skip to content

Commit

Permalink
update pwa icons
Browse files Browse the repository at this point in the history
  • Loading branch information
zmh-program committed Nov 27, 2023
1 parent 6a0bf4b commit 94f714e
Show file tree
Hide file tree
Showing 12 changed files with 52 additions and 47 deletions.
1 change: 1 addition & 0 deletions app/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
<link href="https://open.lightxi.com/fonts/Andika" rel="stylesheet">
<link href="https://open.lightxi.com/fonts/Jetbrains-Mono" rel="stylesheet">
<link href="https://open.lightxi.com/jsdelivr/npm/[email protected]/dist/katex.min.css" rel="stylesheet">
<link rel="manifest" href="/site.webmanifest">
<script src="/workbox.js" defer></script>
</head>
<body>
Expand Down
Binary file added app/public/service/android-chrome-192x192.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/public/service/android-chrome-512x512.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/public/service/favicon-64x64.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
20 changes: 20 additions & 0 deletions app/public/site.webmanifest
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"name": "Chat Nio",
"short_name": "ChatNio",
"icons": [
{
"src": "/service/android-chrome-192x192.png",
"sizes": "192x192",
"type": "image/png"
},
{
"src": "/service/android-chrome-512x512.png",
"sizes": "512x512",
"type": "image/png"
}
],
"start_url": "/",
"theme_color": "#000000",
"background_color": "#0000000",
"display": "standalone"
}
5 changes: 4 additions & 1 deletion app/src/components/FileProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,10 @@ function FileProvider({ value, onChange }: FileProviderProps) {
return (
<Dialog>
<DialogTrigger asChild>
<ChatAction text={t("file.upload")} className={value.length > 0 ? "active" : ""}>
<ChatAction
text={t("file.upload")}
className={value.length > 0 ? "active" : ""}
>
<Plus className={`h-4 w-4`} />
</ChatAction>
</DialogTrigger>
Expand Down
36 changes: 17 additions & 19 deletions app/src/components/Markdown.tsx
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
import {LightAsync as SyntaxHighlighter} from "react-syntax-highlighter";
import {atomOneDark as style} from "react-syntax-highlighter/dist/esm/styles/hljs";
import { LightAsync as SyntaxHighlighter } from "react-syntax-highlighter";
import { atomOneDark as style } from "react-syntax-highlighter/dist/esm/styles/hljs";
import ReactMarkdown from "react-markdown";
import remarkGfm from "remark-gfm";
import remarkMath from "remark-math";
import remarkBreaks from "remark-breaks";
import rehypeKatex from "rehype-katex";
import {parseFile} from "./plugins/file.tsx";
import { parseFile } from "./plugins/file.tsx";
import "@/assets/markdown/all.less";
import {useEffect, useMemo} from "react";
import {useDispatch} from "react-redux";
import {openDialog as openQuotaDialog} from "@/store/quota.ts";
import {openDialog as openSubscriptionDialog} from "@/store/subscription.ts";
import {AppDispatch} from "@/store";
import {Copy} from "lucide-react";
import {copyClipboard} from "@/utils/dom.ts";
import {useToast} from "./ui/use-toast.ts";
import {useTranslation} from "react-i18next";
import {parseProgressbar} from "@/components/plugins/progress.tsx";
import { useEffect, useMemo } from "react";
import { useDispatch } from "react-redux";
import { openDialog as openQuotaDialog } from "@/store/quota.ts";
import { openDialog as openSubscriptionDialog } from "@/store/subscription.ts";
import { AppDispatch } from "@/store";
import { Copy } from "lucide-react";
import { copyClipboard } from "@/utils/dom.ts";
import { useToast } from "./ui/use-toast.ts";
import { useTranslation } from "react-i18next";
import { parseProgressbar } from "@/components/plugins/progress.tsx";

type MarkdownProps = {
children: string;
Expand Down Expand Up @@ -125,12 +125,10 @@ function MarkdownContent({ children, className }: MarkdownProps) {
function Markdown(props: MarkdownProps) {
// memoize the component
const { children, className } = props;
return useMemo(() => (
<MarkdownContent className={className}>{children}</MarkdownContent>
), [
props.children,
props.className,
]);
return useMemo(
() => <MarkdownContent className={className}>{children}</MarkdownContent>,
[props.children, props.className],
);
}

export default Markdown;
3 changes: 2 additions & 1 deletion app/src/components/home/ChatInterface.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ function ChatInterface({ setTarget, setWorking }: ChatInterfaceProps) {
const offset = el.scrollTop - position;
setPosition(el.scrollTop);
if (offset < 0) setScrollable(false);
else setScrollable(el.scrollTop + el.clientHeight + 20 >= el.scrollHeight);
else
setScrollable(el.scrollTop + el.clientHeight + 20 >= el.scrollHeight);
};
return addEventListeners(
el,
Expand Down
19 changes: 3 additions & 16 deletions app/src/components/home/ModelFinder.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
import SelectGroup, { SelectItemProps } from "@/components/SelectGroup.tsx";
import {
expensiveModels,
login,
studentModels,
supportModels,
} from "@/conf.ts";
import { expensiveModels, login, supportModels } from "@/conf.ts";
import {
getPlanModels,
openMarket,
Expand Down Expand Up @@ -32,19 +27,13 @@ type ModelSelectorProps = {
side?: "left" | "right" | "top" | "bottom";
};

function filterModel(model: Model, level: number, student: boolean) {
function filterModel(model: Model, level: number) {
if (getPlanModels(level).includes(model.id)) {
return {
name: model.id,
value: model.name,
badge: { variant: "gold", name: "plus" },
} as SelectItemProps;
} else if (student && studentModels.includes(model.id)) {
return {
name: model.id,
value: model.name,
badge: { variant: "gold", name: "student" },
} as SelectItemProps;
} else if (expensiveModels.includes(model.id)) {
return {
name: model.id,
Expand Down Expand Up @@ -82,9 +71,7 @@ function ModelFinder(props: ModelSelectorProps) {
const models = useMemo(() => {
const raw = supportModels.filter((model) => list.includes(model.id));
return [
...raw.map(
(model: Model): SelectItemProps => filterModel(model, level, student),
),
...raw.map((model: Model): SelectItemProps => filterModel(model, level)),
{
icon: <Sparkles size={16} />,
name: "market",
Expand Down
7 changes: 2 additions & 5 deletions app/src/components/home/ModelMarket.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {
X,
} from "lucide-react";
import React, { useMemo, useState } from "react";
import { login, modelAvatars, studentModels, supportModels } from "@/conf.ts";
import { login, modelAvatars, supportModels } from "@/conf.ts";
import { splitList } from "@/utils/base.ts";
import { Model } from "@/api/types.ts";
import { useDispatch, useSelector } from "react-redux";
Expand Down Expand Up @@ -81,10 +81,7 @@ function ModelItem({ model, className, style }: ModelProps) {
}, [model, current, list]);

const pro = useMemo(() => {
return (
getPlanModels(level).includes(model.id) ||
(student && studentModels.includes(model.id))
);
return getPlanModels(level).includes(model.id);
}, [model, level, student]);

const avatar = useMemo(() => {
Expand Down
6 changes: 3 additions & 3 deletions app/src/components/home/assemblies/ScrollAction.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ import { chatEvent } from "@/events/chat.ts";
import { addEventListeners, scrollDown } from "@/utils/dom.ts";
import { ChatAction } from "@/components/home/assemblies/ChatAction.tsx";
import { useTranslation } from "react-i18next";
import {Message} from "@/api/types.ts";
import {useSelector} from "react-redux";
import {selectMessages} from "@/store/chat.ts";
import { Message } from "@/api/types.ts";
import { useSelector } from "react-redux";
import { selectMessages } from "@/store/chat.ts";

type ScrollActionProps = {
visible: boolean;
Expand Down
2 changes: 0 additions & 2 deletions app/src/conf.ts
Original file line number Diff line number Diff line change
Expand Up @@ -338,8 +338,6 @@ export const largeContextModels = [
"zhipu-chatglm-turbo",
];

export const studentModels = ["claude-2-100k", "claude-2"];

export const planModels: PlanModel[] = [
{ id: "gpt-4-0613", level: 1 },
{ id: "gpt-4-1106-preview", level: 1 },
Expand Down

0 comments on commit 94f714e

Please sign in to comment.