Skip to content

Commit

Permalink
Merge branch 'dev' of https://github.com/sdcb/chats into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
sdcb committed Dec 11, 2024
2 parents ba0b7ec + 81de327 commit 49dc03e
Show file tree
Hide file tree
Showing 29 changed files with 125 additions and 97 deletions.
2 changes: 1 addition & 1 deletion src/FE/.eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@
"react-hooks/exhaustive-deps": "off",
"@next/next/no-img-element": "off"
}
}
}
1 change: 1 addition & 0 deletions src/FE/.gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* text=auto
5 changes: 5 additions & 0 deletions src/FE/.prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
out/
.next/
node_module/
.husky/
public/
11 changes: 7 additions & 4 deletions src/FE/apis/adminApis.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,8 @@ export const getUsers = (
): Promise<PageResult<GetUsersResult[]>> => {
const fetchService = useFetch();
return fetchService.get(
`/api/admin/users?page=${params.page}&pageSize=${params.pageSize}&query=${params?.query || ''
`/api/admin/users?page=${params.page}&pageSize=${params.pageSize}&query=${
params?.query || ''
}`,
);
};
Expand Down Expand Up @@ -164,12 +165,14 @@ export const putFileService = (id: number, params: PostFileServicesParams) => {
export const deleteFileService = (id: number) => {
const fetchService = useFetch();
return fetchService.delete(`/api/admin/file-service/${id}`);
}
};

export const getFileServiceTypeInitialConfig = (fileServiceTypeId: number) => {
const fetchService = useFetch();
return fetchService.get<string>(`/api/admin/file-service-type/${fileServiceTypeId}/initial-config`);
}
return fetchService.get<string>(
`/api/admin/file-service-type/${fileServiceTypeId}/initial-config`,
);
};

export const getShareMessage = (
chatId: string,
Expand Down
6 changes: 1 addition & 5 deletions src/FE/components/Button/CopyButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,7 @@ export default function CopyButton(props: Props) {
onClick={handleCopy}
title={t('Copy')}
>
{isCopied ? (
<IconCheck size={18} />
) : (
<IconClipboard size={18} />
)}
{isCopied ? <IconCheck size={18} /> : <IconClipboard size={18} />}
</Button>
);
}
4 changes: 2 additions & 2 deletions src/FE/components/Spinner/Spinner.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ const Spinner = ({ className = '' }: Props) => {
className={`animate-spin ${className}`}
xmlns="http://www.w3.org/2000/svg"
fill="none"
width='24'
height='24'
width="24"
height="24"
viewBox="0 0 24 24"
>
<circle
Expand Down
7 changes: 5 additions & 2 deletions src/FE/components/ui/form/checkbox.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ const FormCheckbox = ({
options,
field,
}: {

label?: string;
disabled?: boolean;
options?: IFormFieldOption;
Expand All @@ -17,7 +16,11 @@ const FormCheckbox = ({
return (
<FormItem className="py-2 flex items-center gap-2">
<FormControl className="flex">
<Checkbox checked={field.value} disabled={disabled} onCheckedChange={field.onChange} />
<Checkbox
checked={field.value}
disabled={disabled}
onCheckedChange={field.onChange}
/>
</FormControl>
<FormLabel style={{ marginTop: 0 }}>{label}</FormLabel>
<FormMessage />
Expand Down
18 changes: 9 additions & 9 deletions src/FE/components/ui/slider.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
"use client"
'use client';

import * as React from "react"
import * as SliderPrimitive from "@radix-ui/react-slider"
import * as SliderPrimitive from '@radix-ui/react-slider';
import * as React from 'react';

import { cn } from "@/lib/utils"
import { cn } from '@/lib/utils';

const Slider = React.forwardRef<
React.ElementRef<typeof SliderPrimitive.Root>,
Expand All @@ -12,8 +12,8 @@ const Slider = React.forwardRef<
<SliderPrimitive.Root
ref={ref}
className={cn(
"relative flex w-full touch-none select-none items-center",
className
'relative flex w-full touch-none select-none items-center',
className,
)}
{...props}
>
Expand All @@ -22,7 +22,7 @@ const Slider = React.forwardRef<
</SliderPrimitive.Track>
<SliderPrimitive.Thumb className="block h-5 w-5 rounded-full border-2 border-primary bg-background ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50" />
</SliderPrimitive.Root>
))
Slider.displayName = SliderPrimitive.Root.displayName
));
Slider.displayName = SliderPrimitive.Root.displayName;

export { Slider }
export { Slider };
13 changes: 6 additions & 7 deletions src/FE/components/ui/table.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import * as React from 'react';
import { ReactElement } from 'react-markdown/lib/react-markdown';

import useTranslation from '@/hooks/useTranslation';

import { Skeleton } from './skeleton';

import { cn } from '@/lib/utils';

import useTranslation from '@/hooks/useTranslation';

const Table = React.forwardRef<
HTMLTableElement,
React.HTMLAttributes<HTMLTableElement>
Expand Down Expand Up @@ -50,10 +50,9 @@ const TableBody = React.forwardRef<HTMLTableSectionElement, TableBodyProps>(
...props
},
ref,
) =>
{
) => {
const { t } = useTranslation();
return (isLoading ? (
return isLoading ? (
<tbody>
<tr>
<td className="text-center align-middle p-4 h-32" colSpan={100}>
Expand Down Expand Up @@ -87,8 +86,8 @@ const TableBody = React.forwardRef<HTMLTableSectionElement, TableBodyProps>(
className={cn('[&_tr:last-child]:border-0', className)}
{...props}
/>
))
}
);
},
);
TableBody.displayName = 'TableBody';

Expand Down
37 changes: 19 additions & 18 deletions src/FE/components/ui/toggle-group.tsx
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
"use client"
'use client';

import * as React from "react"
import * as ToggleGroupPrimitive from "@radix-ui/react-toggle-group"
import { VariantProps } from "class-variance-authority"
import * as ToggleGroupPrimitive from '@radix-ui/react-toggle-group';
import * as React from 'react';

import { cn } from "@/lib/utils"
import { toggleVariants } from "@/components/ui/toggle"
import { toggleVariants } from '@/components/ui/toggle';

import { cn } from '@/lib/utils';
import { VariantProps } from 'class-variance-authority';

const ToggleGroupContext = React.createContext<
VariantProps<typeof toggleVariants>
>({
size: "default",
variant: "default",
})
size: 'default',
variant: 'default',
});

const ToggleGroup = React.forwardRef<
React.ElementRef<typeof ToggleGroupPrimitive.Root>,
Expand All @@ -21,23 +22,23 @@ const ToggleGroup = React.forwardRef<
>(({ className, variant, size, children, ...props }, ref) => (
<ToggleGroupPrimitive.Root
ref={ref}
className={cn("flex items-center justify-center gap-1", className)}
className={cn('flex items-center justify-center gap-1', className)}
{...props}
>
<ToggleGroupContext.Provider value={{ variant, size }}>
{children}
</ToggleGroupContext.Provider>
</ToggleGroupPrimitive.Root>
))
));

ToggleGroup.displayName = ToggleGroupPrimitive.Root.displayName
ToggleGroup.displayName = ToggleGroupPrimitive.Root.displayName;

const ToggleGroupItem = React.forwardRef<
React.ElementRef<typeof ToggleGroupPrimitive.Item>,
React.ComponentPropsWithoutRef<typeof ToggleGroupPrimitive.Item> &
VariantProps<typeof toggleVariants>
>(({ className, children, variant, size, ...props }, ref) => {
const context = React.useContext(ToggleGroupContext)
const context = React.useContext(ToggleGroupContext);

return (
<ToggleGroupPrimitive.Item
Expand All @@ -47,15 +48,15 @@ const ToggleGroupItem = React.forwardRef<
variant: context.variant || variant,
size: context.size || size,
}),
className
className,
)}
{...props}
>
{children}
</ToggleGroupPrimitive.Item>
)
})
);
});

ToggleGroupItem.displayName = ToggleGroupPrimitive.Item.displayName
ToggleGroupItem.displayName = ToggleGroupPrimitive.Item.displayName;

export { ToggleGroup, ToggleGroupItem }
export { ToggleGroup, ToggleGroupItem };
36 changes: 18 additions & 18 deletions src/FE/components/ui/toggle.tsx
Original file line number Diff line number Diff line change
@@ -1,32 +1,32 @@
"use client"
'use client';

import * as React from "react"
import * as TogglePrimitive from "@radix-ui/react-toggle"
import { cva, type VariantProps } from "class-variance-authority"
import * as TogglePrimitive from '@radix-ui/react-toggle';
import * as React from 'react';

import { cn } from "@/lib/utils"
import { cn } from '@/lib/utils';
import { type VariantProps, cva } from 'class-variance-authority';

const toggleVariants = cva(
"inline-flex items-center justify-center rounded-md text-sm font-medium ring-offset-background transition-colors hover:bg-muted hover:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50 data-[state=on]:bg-accent data-[state=on]:text-accent-foreground",
'inline-flex items-center justify-center rounded-md text-sm font-medium ring-offset-background transition-colors hover:bg-muted hover:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50 data-[state=on]:bg-accent data-[state=on]:text-accent-foreground',
{
variants: {
variant: {
default: "bg-transparent",
default: 'bg-transparent',
outline:
"border border-input bg-transparent hover:bg-accent hover:text-accent-foreground",
'border border-input bg-transparent hover:bg-accent hover:text-accent-foreground',
},
size: {
default: "h-10 px-3",
sm: "h-9 px-2.5",
lg: "h-11 px-5",
default: 'h-10 px-3',
sm: 'h-9 px-2.5',
lg: 'h-11 px-5',
},
},
defaultVariants: {
variant: "default",
size: "default",
variant: 'default',
size: 'default',
},
}
)
},
);

const Toggle = React.forwardRef<
React.ElementRef<typeof TogglePrimitive.Root>,
Expand All @@ -38,8 +38,8 @@ const Toggle = React.forwardRef<
className={cn(toggleVariants({ variant, size, className }))}
{...props}
/>
))
));

Toggle.displayName = TogglePrimitive.Root.displayName
Toggle.displayName = TogglePrimitive.Root.displayName;

export { Toggle, toggleVariants }
export { Toggle, toggleVariants };
4 changes: 2 additions & 2 deletions src/FE/locales/zh-CN.json
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,7 @@
"Token Price": "Token价格",
"404: Page not found": "404: 页面未找到",
"Sorry, we couldn't find the page you were trying to access.": "抱歉,我们找不到你要访问的页面。",
": An error has occurred": ": 发生错误",
"An error has occurred": "发生错误",
"Sorry, there was an unexpected error, please try again later.": "抱歉,出现了意外错误,请稍后再试。",
"Local": "本地",
"Minio": "Minio",
Expand All @@ -361,4 +361,4 @@
"There's no model here": "这里没有模型",
"You can contact the administrator or create one yourself": "你可以联系管理员或者自己创建一个",
"Customized Text(Company name, etc)": "自定义文本(公司名称等)"
}
}
10 changes: 5 additions & 5 deletions src/FE/next.config.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
const isDev = process.env?.NODE_ENV === 'development';
console.log("NODE_ENV", process.env?.NODE_ENV);
console.log("-------------------");
console.log('NODE_ENV', process.env?.NODE_ENV);
console.log('-------------------');

const withPWA = require('next-pwa')({
dest: 'public',
register: !isDev,
skipWaiting: !isDev,
disable: isDev,
})
});

/** @type {import('next').NextConfig} */
const nextConfig = {
Expand All @@ -22,8 +22,8 @@ const nextConfig = {
},
publicRuntimeConfig: {
chattingIds: {},
globalConfigs: {}
}
globalConfigs: {},
},
};

module.exports = withPWA(nextConfig);
6 changes: 5 additions & 1 deletion src/FE/pages/_document.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,11 @@ function ChatsDocument(props: Props) {
<Head>
<meta name="mobile-mobile-web-app-capable" content="yes" />
<meta name="apple-mobile-web-app-title" content="Chats"></meta>
<link rel="manifest" href="/manifest.json" crossOrigin="use-credentials" />
<link
rel="manifest"
href="/manifest.json"
crossOrigin="use-credentials"
/>
<link rel="apple-touch-icon" href="/icons/192x192.png" />
<link rel="shortcut icon" href="/icons/192x192.png" />
</Head>
Expand Down
5 changes: 1 addition & 4 deletions src/FE/pages/_error.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,7 @@ const ErrorPage = ({ statusCode }: { statusCode: number }) => {

return (
<div className="flex flex-col text-center gap-y-4 mt-4">
<h1 className="text-2xl">
{statusCode}
{t(': An error has occurred')}
</h1>
<h1 className="text-2xl">{t('An error has occurred')}</h1>
<p className="text-gray-500">
{t('Sorry, there was an unexpected error, please try again later.')}
</p>
Expand Down
1 change: 0 additions & 1 deletion src/FE/pages/globals.css
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@
}
}


@layer base {
* {
@apply border-border;
Expand Down
4 changes: 3 additions & 1 deletion src/FE/pages/home/_components/Chat/Chat.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -425,7 +425,9 @@ const Chat = memo(() => {
/>
)}
{selectModel?.allowTemperature &&
userModelConfig && userModelConfig.temperature !== null && userModelConfig.temperature !== undefined && (
userModelConfig &&
userModelConfig.temperature !== null &&
userModelConfig.temperature !== undefined && (
<TemperatureSlider
label={t('Temperature')}
min={0}
Expand Down
Loading

0 comments on commit 49dc03e

Please sign in to comment.