@@ -87,8 +86,8 @@ const TableBody = React.forwardRef(
className={cn('[&_tr:last-child]:border-0', className)}
{...props}
/>
- ))
- }
+ );
+ },
);
TableBody.displayName = 'TableBody';
diff --git a/src/FE/components/ui/toggle-group.tsx b/src/FE/components/ui/toggle-group.tsx
index 6cadb522..e5322f8a 100644
--- a/src/FE/components/ui/toggle-group.tsx
+++ b/src/FE/components/ui/toggle-group.tsx
@@ -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
>({
- size: "default",
- variant: "default",
-})
+ size: 'default',
+ variant: 'default',
+});
const ToggleGroup = React.forwardRef<
React.ElementRef,
@@ -21,23 +22,23 @@ const ToggleGroup = React.forwardRef<
>(({ className, variant, size, children, ...props }, ref) => (
{children}
-))
+));
-ToggleGroup.displayName = ToggleGroupPrimitive.Root.displayName
+ToggleGroup.displayName = ToggleGroupPrimitive.Root.displayName;
const ToggleGroupItem = React.forwardRef<
React.ElementRef,
React.ComponentPropsWithoutRef &
VariantProps
>(({ className, children, variant, size, ...props }, ref) => {
- const context = React.useContext(ToggleGroupContext)
+ const context = React.useContext(ToggleGroupContext);
return (
{children}
- )
-})
+ );
+});
-ToggleGroupItem.displayName = ToggleGroupPrimitive.Item.displayName
+ToggleGroupItem.displayName = ToggleGroupPrimitive.Item.displayName;
-export { ToggleGroup, ToggleGroupItem }
+export { ToggleGroup, ToggleGroupItem };
diff --git a/src/FE/components/ui/toggle.tsx b/src/FE/components/ui/toggle.tsx
index 1379f75d..4cf886e4 100644
--- a/src/FE/components/ui/toggle.tsx
+++ b/src/FE/components/ui/toggle.tsx
@@ -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,
@@ -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 };
diff --git a/src/FE/locales/zh-CN.json b/src/FE/locales/zh-CN.json
index c5b9b029..e7b0f45b 100644
--- a/src/FE/locales/zh-CN.json
+++ b/src/FE/locales/zh-CN.json
@@ -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",
@@ -361,4 +361,4 @@
"There's no model here": "这里没有模型",
"You can contact the administrator or create one yourself": "你可以联系管理员或者自己创建一个",
"Customized Text(Company name, etc)": "自定义文本(公司名称等)"
-}
\ No newline at end of file
+}
diff --git a/src/FE/next.config.js b/src/FE/next.config.js
index f341adf8..9c576cb7 100644
--- a/src/FE/next.config.js
+++ b/src/FE/next.config.js
@@ -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 = {
@@ -22,8 +22,8 @@ const nextConfig = {
},
publicRuntimeConfig: {
chattingIds: {},
- globalConfigs: {}
- }
+ globalConfigs: {},
+ },
};
module.exports = withPWA(nextConfig);
diff --git a/src/FE/package-lock.json b/src/FE/package-lock.json
index b3702542..2fe84c73 100644
--- a/src/FE/package-lock.json
+++ b/src/FE/package-lock.json
@@ -62,6 +62,7 @@
"cross-env": "^7.0.3",
"eslint": "8.49.0",
"eslint-config-next": "13.4.19",
+ "husky": "^9.1.7",
"postcss": "^8.4.41",
"prettier": "^2.8.7",
"prettier-plugin-tailwindcss": "^0.2.5",
@@ -8019,6 +8020,22 @@
"node": "*"
}
},
+ "node_modules/husky": {
+ "version": "9.1.7",
+ "resolved": "https://registry.npmjs.org/husky/-/husky-9.1.7.tgz",
+ "integrity": "sha512-5gs5ytaNjBrh5Ow3zrvdUUY+0VxIuWVL4i9irt6friV+BqdCfmV11CQTWMiBYWHbXhco+J1kHfTOUkePhCDvMA==",
+ "dev": true,
+ "license": "MIT",
+ "bin": {
+ "husky": "bin.js"
+ },
+ "engines": {
+ "node": ">=18"
+ },
+ "funding": {
+ "url": "https://github.com/sponsors/typicode"
+ }
+ },
"node_modules/idb": {
"version": "7.1.1",
"resolved": "https://registry.npmjs.org/idb/-/idb-7.1.1.tgz",
@@ -13849,21 +13866,6 @@
"type": "github",
"url": "https://github.com/sponsors/wooorm"
}
- },
- "node_modules/@next/swc-win32-ia32-msvc": {
- "version": "14.2.5",
- "resolved": "https://registry.npmjs.org/@next/swc-win32-ia32-msvc/-/swc-win32-ia32-msvc-14.2.5.tgz",
- "integrity": "sha512-Igh9ZlxwvCDsu6438FXlQTHlRno4gFpJzqPjSIBZooD22tKeI4fE/YMRoHVJHmrQ2P5YL1DoZ0qaOKkbeFWeMg==",
- "cpu": [
- "ia32"
- ],
- "optional": true,
- "os": [
- "win32"
- ],
- "engines": {
- "node": ">= 10"
- }
}
}
}
diff --git a/src/FE/package.json b/src/FE/package.json
index 3ededf52..d58bf404 100644
--- a/src/FE/package.json
+++ b/src/FE/package.json
@@ -8,7 +8,8 @@
"build": "next build",
"start": "next start",
"lint": "next lint",
- "format": "prettier --write ."
+ "format": "prettier --write .",
+ "prepare": "husky"
},
"dependencies": {
"@hookform/resolvers": "^3.3.4",
@@ -65,6 +66,7 @@
"cross-env": "^7.0.3",
"eslint": "8.49.0",
"eslint-config-next": "13.4.19",
+ "husky": "^9.1.7",
"postcss": "^8.4.41",
"prettier": "^2.8.7",
"prettier-plugin-tailwindcss": "^0.2.5",
diff --git a/src/FE/pages/_app.tsx b/src/FE/pages/_app.tsx
index 8c25e65d..04203d68 100644
--- a/src/FE/pages/_app.tsx
+++ b/src/FE/pages/_app.tsx
@@ -9,12 +9,11 @@ import { getUserInfo } from '@/utils/user';
import { UserRole } from '@/types/adminApis';
-import { ThemeProvider } from '@/components/Theme/ThemeProvider';
-
import ErrorPage from './_error';
import AdminLayout from './admin/layout';
import './globals.css';
+import { ThemeProvider } from '@/providers/ThemeProvider';
import 'katex/dist/katex.min.css';
function App({ Component, pageProps }: AppProps<{}> | any) {
@@ -25,7 +24,7 @@ function App({ Component, pageProps }: AppProps<{}> | any) {
useEffect(() => {
setIsClient(true);
- document.title = "Chats";
+ document.title = 'Chats';
}, []);
const isAdmin = () => {
diff --git a/src/FE/pages/_document.tsx b/src/FE/pages/_document.tsx
index 9eb3466a..016e5cb8 100644
--- a/src/FE/pages/_document.tsx
+++ b/src/FE/pages/_document.tsx
@@ -17,7 +17,11 @@ function ChatsDocument(props: Props) {
-
+
diff --git a/src/FE/pages/_error.tsx b/src/FE/pages/_error.tsx
index 456abe24..b45e4ff7 100644
--- a/src/FE/pages/_error.tsx
+++ b/src/FE/pages/_error.tsx
@@ -22,10 +22,7 @@ const ErrorPage = ({ statusCode }: { statusCode: number }) => {
return (
-
- {statusCode}
- {t(': An error has occurred')}
-
+ {t('An error has occurred')}
{t('Sorry, there was an unexpected error, please try again later.')}
diff --git a/src/FE/components/Admin/Files/FileServiceModal.tsx b/src/FE/pages/admin/_components/Files/FileServiceModal.tsx
similarity index 98%
rename from src/FE/components/Admin/Files/FileServiceModal.tsx
rename to src/FE/pages/admin/_components/Files/FileServiceModal.tsx
index eac92fdc..0174a46f 100644
--- a/src/FE/components/Admin/Files/FileServiceModal.tsx
+++ b/src/FE/pages/admin/_components/Files/FileServiceModal.tsx
@@ -42,7 +42,7 @@ interface IProps {
saveLoading?: boolean;
}
-export const FileServiceModal = (props: IProps) => {
+const FileServiceModal = (props: IProps) => {
const { t } = useTranslation();
const { selected, isOpen, onClose, onSuccessful } = props;
const formFields: IFormFieldOption[] = [
@@ -220,3 +220,5 @@ export const FileServiceModal = (props: IProps) => {
);
};
+
+export default FileServiceModal;
diff --git a/src/FE/components/Admin/GlobalConfigs/GlobalConfigsModal.tsx b/src/FE/pages/admin/_components/GlobalConfigs/GlobalConfigsModal.tsx
similarity index 98%
rename from src/FE/components/Admin/GlobalConfigs/GlobalConfigsModal.tsx
rename to src/FE/pages/admin/_components/GlobalConfigs/GlobalConfigsModal.tsx
index baf22766..fd1670c5 100644
--- a/src/FE/components/Admin/GlobalConfigs/GlobalConfigsModal.tsx
+++ b/src/FE/pages/admin/_components/GlobalConfigs/GlobalConfigsModal.tsx
@@ -33,7 +33,7 @@ interface IProps {
saveLoading?: boolean;
}
-export const GlobalConfigsModal = (props: IProps) => {
+const GlobalConfigsModal = (props: IProps) => {
const { t } = useTranslation();
const { configKeys = [], selected, isOpen, onClose, onSuccessful } = props;
const formFields: IFormFieldOption[] = [
@@ -158,3 +158,4 @@ export const GlobalConfigsModal = (props: IProps) => {
);
};
+export default GlobalConfigsModal;
diff --git a/src/FE/components/Admin/InvitationCode/InvitationCodeModal.tsx b/src/FE/pages/admin/_components/InvitationCode/InvitationCodeModal.tsx
similarity index 97%
rename from src/FE/components/Admin/InvitationCode/InvitationCodeModal.tsx
rename to src/FE/pages/admin/_components/InvitationCode/InvitationCodeModal.tsx
index b60ad431..c93c7c4c 100644
--- a/src/FE/components/Admin/InvitationCode/InvitationCodeModal.tsx
+++ b/src/FE/pages/admin/_components/InvitationCode/InvitationCodeModal.tsx
@@ -34,7 +34,7 @@ interface IProps {
saveLoading?: boolean;
}
-export const InvitationCodeModal = (props: IProps) => {
+const InvitationCodeModal = (props: IProps) => {
const { t } = useTranslation();
const { selected, isOpen, onClose, onSuccessful } = props;
const formFields: IFormFieldOption[] = [
@@ -137,3 +137,4 @@ export const InvitationCodeModal = (props: IProps) => {
);
};
+export default InvitationCodeModal;
diff --git a/src/FE/components/Admin/LoginService/LoginServiceModal.tsx b/src/FE/pages/admin/_components/LoginService/LoginServiceModal.tsx
similarity index 98%
rename from src/FE/components/Admin/LoginService/LoginServiceModal.tsx
rename to src/FE/pages/admin/_components/LoginService/LoginServiceModal.tsx
index 51201547..180581a1 100644
--- a/src/FE/components/Admin/LoginService/LoginServiceModal.tsx
+++ b/src/FE/pages/admin/_components/LoginService/LoginServiceModal.tsx
@@ -40,7 +40,7 @@ interface IProps {
saveLoading?: boolean;
}
-export const LoginServiceModal = (props: IProps) => {
+const LoginServiceModal = (props: IProps) => {
const { t } = useTranslation();
const { selected, types, isOpen, onClose, onSuccessful } = props;
const formFields: IFormFieldOption[] = [
@@ -169,3 +169,4 @@ export const LoginServiceModal = (props: IProps) => {
);
};
+export default LoginServiceModal;
diff --git a/src/FE/components/Admin/ModelKeys/ConfigModelModal.tsx b/src/FE/pages/admin/_components/ModelKeys/ConfigModelModal.tsx
similarity index 98%
rename from src/FE/components/Admin/ModelKeys/ConfigModelModal.tsx
rename to src/FE/pages/admin/_components/ModelKeys/ConfigModelModal.tsx
index 25c810a8..98916bba 100644
--- a/src/FE/components/Admin/ModelKeys/ConfigModelModal.tsx
+++ b/src/FE/pages/admin/_components/ModelKeys/ConfigModelModal.tsx
@@ -6,7 +6,7 @@ import useTranslation from '@/hooks/useTranslation';
import { DBModelProvider } from '@/types/model';
import { IconInfo } from '@/components/Icons';
-import Spinner from '@/components/Spinner';
+import Spinner from '@/components/Spinner/Spinner';
import Tips from '@/components/Tips/Tips';
import { Badge } from '@/components/ui/badge';
import { Button } from '@/components/ui/button';
@@ -51,7 +51,7 @@ export interface PossibleModel {
deploymentName: string | null;
}
-export const ConfigModelModal = (props: IProps) => {
+const ConfigModelModal = (props: IProps) => {
const { t } = useTranslation();
const { modelKeyId, modelProverId, isOpen, onClose } = props;
const [models, setModels] = useState ([]);
@@ -235,3 +235,4 @@ export const ConfigModelModal = (props: IProps) => {
);
};
+export default ConfigModelModal;
diff --git a/src/FE/components/Admin/ModelKeys/ModelKeysModal.tsx b/src/FE/pages/admin/_components/ModelKeys/ModelKeysModal.tsx
similarity index 95%
rename from src/FE/components/Admin/ModelKeys/ModelKeysModal.tsx
rename to src/FE/pages/admin/_components/ModelKeys/ModelKeysModal.tsx
index 34eab153..8b1cd05f 100644
--- a/src/FE/components/Admin/ModelKeys/ModelKeysModal.tsx
+++ b/src/FE/pages/admin/_components/ModelKeys/ModelKeysModal.tsx
@@ -1,21 +1,17 @@
-import { Label } from '@radix-ui/react-dropdown-menu';
-import React, { useEffect, useState } from 'react';
+import React, { useEffect } from 'react';
import { useForm } from 'react-hook-form';
import toast from 'react-hot-toast';
import useTranslation from '@/hooks/useTranslation';
import {
- AutoCreateModelResult,
GetModelKeysResult,
ModelProviderInitialConfig,
PostModelKeysParams,
} from '@/types/adminApis';
import { feModelProviders } from '@/types/model';
-import { IconInfo } from '@/components/Icons';
-import Spinner from '@/components/Spinner';
-import Tips from '@/components/Tips/Tips';
+import Spinner from '@/components/Spinner/Spinner';
import { Button } from '@/components/ui/button';
import {
Dialog,
@@ -32,7 +28,6 @@ import FormTextarea from '@/components/ui/form/textarea';
import {
deleteModelKeys,
getModelProviderInitialConfig,
- postAutoCreateModels,
postModelKeys,
putModelKeys,
} from '@/apis/adminApis';
@@ -49,7 +44,7 @@ interface IProps {
saveLoading?: boolean;
}
-export const ModelKeysModal = (props: IProps) => {
+const ModelKeysModal = (props: IProps) => {
const { t } = useTranslation();
const {
selected,
@@ -271,3 +266,4 @@ export const ModelKeysModal = (props: IProps) => {
);
};
+export default ModelKeysModal;
diff --git a/src/FE/components/Admin/Models/AddModelModal.tsx b/src/FE/pages/admin/_components/Models/AddModelModal.tsx
similarity index 99%
rename from src/FE/components/Admin/Models/AddModelModal.tsx
rename to src/FE/pages/admin/_components/Models/AddModelModal.tsx
index e6cabc1d..17ce1751 100644
--- a/src/FE/components/Admin/Models/AddModelModal.tsx
+++ b/src/FE/pages/admin/_components/Models/AddModelModal.tsx
@@ -47,7 +47,7 @@ interface IProps {
saveLoading?: boolean;
}
-export const AddModelModal = (props: IProps) => {
+const AddModelModal = (props: IProps) => {
const { t } = useTranslation();
const [fileServices, setFileServices] = useState([]);
const [modelVersions, setModelVersions] = useState(
@@ -55,7 +55,6 @@ export const AddModelModal = (props: IProps) => {
);
const [modelReference, setModelReference] = useState();
const { isOpen, onClose, onSuccessful, modelKeys } = props;
- const [loading, setLoading] = useState(true);
const formSchema = z.object({
modelReferenceId: z.string().default('0'),
@@ -307,3 +306,4 @@ export const AddModelModal = (props: IProps) => {
);
};
+export default AddModelModal;
diff --git a/src/FE/components/Admin/Models/EditModelModal.tsx b/src/FE/pages/admin/_components/Models/EditModelModal.tsx
similarity index 99%
rename from src/FE/components/Admin/Models/EditModelModal.tsx
rename to src/FE/pages/admin/_components/Models/EditModelModal.tsx
index 60acc246..0b04c733 100644
--- a/src/FE/components/Admin/Models/EditModelModal.tsx
+++ b/src/FE/pages/admin/_components/Models/EditModelModal.tsx
@@ -43,7 +43,7 @@ interface IProps {
saveLoading?: boolean;
}
-export const EditModelModal = (props: IProps) => {
+const EditModelModal = (props: IProps) => {
const { t } = useTranslation();
const { isOpen, onClose, selected, onSuccessful, modelKeys } = props;
const [fileServices, setFileServices] = useState([]);
@@ -329,3 +329,4 @@ export const EditModelModal = (props: IProps) => {
);
};
+export default EditModelModal;
diff --git a/src/FE/components/Admin/Nav/Nav.tsx b/src/FE/pages/admin/_components/Nav/Nav.tsx
similarity index 96%
rename from src/FE/components/Admin/Nav/Nav.tsx
rename to src/FE/pages/admin/_components/Nav/Nav.tsx
index 01b5d22d..02a02a3d 100644
--- a/src/FE/components/Admin/Nav/Nav.tsx
+++ b/src/FE/pages/admin/_components/Nav/Nav.tsx
@@ -17,7 +17,7 @@ interface NavProps {
menus: IMenu[];
}
-export function Nav({ menus }: NavProps) {
+function Nav({ menus }: NavProps) {
const router = useRouter();
const active = (link: IMenu) => {
const { url } = link;
@@ -52,3 +52,4 @@ export function Nav({ menus }: NavProps) {
);
}
+export default Nav;
diff --git a/src/FE/components/Admin/Pagiation/Pagiation.tsx b/src/FE/pages/admin/_components/Pagiation/Pagiation.tsx
similarity index 100%
rename from src/FE/components/Admin/Pagiation/Pagiation.tsx
rename to src/FE/pages/admin/_components/Pagiation/Pagiation.tsx
diff --git a/src/FE/components/Admin/PayService/PayServiceModal.tsx b/src/FE/pages/admin/_components/PayService/PayServiceModal.tsx
similarity index 98%
rename from src/FE/components/Admin/PayService/PayServiceModal.tsx
rename to src/FE/pages/admin/_components/PayService/PayServiceModal.tsx
index a0456d56..656648b2 100644
--- a/src/FE/components/Admin/PayService/PayServiceModal.tsx
+++ b/src/FE/pages/admin/_components/PayService/PayServiceModal.tsx
@@ -41,7 +41,7 @@ interface IProps {
saveLoading?: boolean;
}
-export const PayServiceModal = (props: IProps) => {
+const PayServiceModal = (props: IProps) => {
const { t } = useTranslation();
const { selected, types, isOpen, onClose, onSuccessful } = props;
const formFields: IFormFieldOption[] = [
@@ -181,3 +181,4 @@ export const PayServiceModal = (props: IProps) => {
);
};
+export default PayServiceModal;
diff --git a/src/FE/components/Admin/RequestLogs/RequestLogDetailsModal.tsx b/src/FE/pages/admin/_components/RequestLogs/RequestLogDetailsModal.tsx
similarity index 97%
rename from src/FE/components/Admin/RequestLogs/RequestLogDetailsModal.tsx
rename to src/FE/pages/admin/_components/RequestLogs/RequestLogDetailsModal.tsx
index 7f842ea7..74040301 100644
--- a/src/FE/components/Admin/RequestLogs/RequestLogDetailsModal.tsx
+++ b/src/FE/pages/admin/_components/RequestLogs/RequestLogDetailsModal.tsx
@@ -19,7 +19,7 @@ interface IProps {
onClose: () => void;
}
-export const RequestLogDetailsModal = (props: IProps) => {
+const RequestLogDetailsModal = (props: IProps) => {
const { t } = useTranslation();
const { isOpen, onClose } = props;
const [log, setLog] = useState();
@@ -111,3 +111,4 @@ export const RequestLogDetailsModal = (props: IProps) => {
);
};
+export default RequestLogDetailsModal;
diff --git a/src/FE/components/Admin/Users/EditUserBalanceModel.tsx b/src/FE/pages/admin/_components/Users/EditUserBalanceModel.tsx
similarity index 97%
rename from src/FE/components/Admin/Users/EditUserBalanceModel.tsx
rename to src/FE/pages/admin/_components/Users/EditUserBalanceModel.tsx
index 81708620..0000b686 100644
--- a/src/FE/components/Admin/Users/EditUserBalanceModel.tsx
+++ b/src/FE/pages/admin/_components/Users/EditUserBalanceModel.tsx
@@ -29,7 +29,7 @@ interface IProps {
onSuccessful: () => void;
}
-export const EditUserBalanceModal = (props: IProps) => {
+const EditUserBalanceModal = (props: IProps) => {
const { t } = useTranslation();
const { userId, userBalance, isOpen, onClose, onSuccessful } = props;
const [loading, setLoading] = useState(false);
@@ -117,3 +117,5 @@ export const EditUserBalanceModal = (props: IProps) => {
);
};
+
+export default EditUserBalanceModal;
diff --git a/src/FE/components/Admin/Users/EditUserModelModal.tsx b/src/FE/pages/admin/_components/Users/EditUserModelModal.tsx
similarity index 97%
rename from src/FE/components/Admin/Users/EditUserModelModal.tsx
rename to src/FE/pages/admin/_components/Users/EditUserModelModal.tsx
index 9f862d6e..23390530 100644
--- a/src/FE/components/Admin/Users/EditUserModelModal.tsx
+++ b/src/FE/pages/admin/_components/Users/EditUserModelModal.tsx
@@ -5,7 +5,7 @@ import useTranslation from '@/hooks/useTranslation';
import { termDateString } from '@/utils/common';
-import { UserModelDisplay, UserModelDisplayDto } from '@/types/adminApis';
+import { UserModelDisplay } from '@/types/adminApis';
import { IconSquareRoundedX } from '@/components/Icons';
import { Button } from '@/components/ui/button';
@@ -42,7 +42,7 @@ interface IProps {
onClose: () => void;
onSuccessful: () => void;
}
-export const EditUserModelModal = (props: IProps) => {
+const EditUserModelModal = (props: IProps) => {
const { t } = useTranslation();
const { isOpen, onClose, onSuccessful } = props;
const [submit, setSubmit] = useState(false);
@@ -184,3 +184,4 @@ export const EditUserModelModal = (props: IProps) => {
);
};
+export default EditUserModelModal;
diff --git a/src/FE/components/Admin/Users/UserInitialConfigModal.tsx b/src/FE/pages/admin/_components/Users/UserInitialConfigModal.tsx
similarity index 99%
rename from src/FE/components/Admin/Users/UserInitialConfigModal.tsx
rename to src/FE/pages/admin/_components/Users/UserInitialConfigModal.tsx
index c12a9eac..3ddae90b 100644
--- a/src/FE/components/Admin/Users/UserInitialConfigModal.tsx
+++ b/src/FE/pages/admin/_components/Users/UserInitialConfigModal.tsx
@@ -62,7 +62,7 @@ interface IProps {
onSuccessful: () => void;
}
let ModelKeyMap = {} as any;
-export const UserInitialConfigModal = (props: IProps) => {
+const UserInitialConfigModal = (props: IProps) => {
const { t } = useTranslation();
const { models, isOpen, select, onClose, onSuccessful } = props;
const [submit, setSubmit] = useState(false);
@@ -371,3 +371,4 @@ export const UserInitialConfigModal = (props: IProps) => {
);
};
+export default UserInitialConfigModal;
diff --git a/src/FE/components/Admin/Users/UserModal.tsx b/src/FE/pages/admin/_components/Users/UserModal.tsx
similarity index 98%
rename from src/FE/components/Admin/Users/UserModal.tsx
rename to src/FE/pages/admin/_components/Users/UserModal.tsx
index 2d651c43..2ffc4f45 100644
--- a/src/FE/components/Admin/Users/UserModal.tsx
+++ b/src/FE/pages/admin/_components/Users/UserModal.tsx
@@ -42,7 +42,7 @@ const ROLES = [
},
];
-export const UserModal = (props: IProps) => {
+const UserModal = (props: IProps) => {
const { t } = useTranslation();
const { user, isOpen, onClose, onSuccessful } = props;
const [submit, setSubmit] = useState(false);
@@ -206,3 +206,4 @@ export const UserModal = (props: IProps) => {
);
};
+export default UserModal;
diff --git a/src/FE/pages/admin/file-service/index.tsx b/src/FE/pages/admin/file-service/index.tsx
index a0b5b3bf..5977b0df 100644
--- a/src/FE/pages/admin/file-service/index.tsx
+++ b/src/FE/pages/admin/file-service/index.tsx
@@ -4,7 +4,6 @@ import useTranslation from '@/hooks/useTranslation';
import { GetFileServicesResult } from '@/types/adminApis';
-import { FileServiceModal } from '@/components/Admin/Files/FileServiceModal';
import { Button } from '@/components/ui/button';
import { Card } from '@/components/ui/card';
import {
@@ -16,6 +15,8 @@ import {
TableRow,
} from '@/components/ui/table';
+import FileServiceModal from '../_components/Files/FileServiceModal';
+
import { getFileServices } from '@/apis/adminApis';
export default function FileService() {
diff --git a/src/FE/pages/admin/global-configs/index.tsx b/src/FE/pages/admin/global-configs/index.tsx
index 4a9d69cd..55c386c6 100644
--- a/src/FE/pages/admin/global-configs/index.tsx
+++ b/src/FE/pages/admin/global-configs/index.tsx
@@ -4,7 +4,6 @@ import useTranslation from '@/hooks/useTranslation';
import { GetConfigsResult } from '@/types/adminApis';
-import { GlobalConfigsModal } from '@/components/Admin/GlobalConfigs/GlobalConfigsModal';
import { Button } from '@/components/ui/button';
import { Card } from '@/components/ui/card';
import {
@@ -16,6 +15,8 @@ import {
TableRow,
} from '@/components/ui/table';
+import GlobalConfigsModal from '../_components/GlobalConfigs/GlobalConfigsModal';
+
import { getConfigs } from '@/apis/adminApis';
export default function Configs() {
diff --git a/src/FE/pages/admin/index.tsx b/src/FE/pages/admin/index.tsx
index 6244318f..80d68452 100644
--- a/src/FE/pages/admin/index.tsx
+++ b/src/FE/pages/admin/index.tsx
@@ -19,4 +19,4 @@ const Dashboard = () => {
);
};
-export default Dashboard;
\ No newline at end of file
+export default Dashboard;
diff --git a/src/FE/pages/admin/invitation-code/index.tsx b/src/FE/pages/admin/invitation-code/index.tsx
index b6cefa87..ea458baf 100644
--- a/src/FE/pages/admin/invitation-code/index.tsx
+++ b/src/FE/pages/admin/invitation-code/index.tsx
@@ -4,7 +4,6 @@ import useTranslation from '@/hooks/useTranslation';
import { GetInvitationCodeResult } from '@/types/adminApis';
-import { InvitationCodeModal } from '@/components/Admin/InvitationCode/InvitationCodeModal';
import { Button } from '@/components/ui/button';
import { Card } from '@/components/ui/card';
import {
@@ -16,6 +15,8 @@ import {
TableRow,
} from '@/components/ui/table';
+import InvitationCodeModal from '../_components/InvitationCode/InvitationCodeModal';
+
import { getInvitationCode } from '@/apis/adminApis';
export default function InvitationCode() {
diff --git a/src/FE/pages/admin/layout/index.tsx b/src/FE/pages/admin/layout/index.tsx
index 520d03cb..0cf8ca5d 100644
--- a/src/FE/pages/admin/layout/index.tsx
+++ b/src/FE/pages/admin/layout/index.tsx
@@ -6,7 +6,6 @@ import { useRouter } from 'next/router';
import useTranslation from '@/hooks/useTranslation';
-import { Nav } from '@/components/Admin/Nav/Nav';
import {
IconFiles,
IconIdBadge,
@@ -20,6 +19,8 @@ import {
IconUsers,
} from '@/components/Icons/index';
+import Nav from '../_components/Nav/Nav';
+
const AdminLayout = ({
children,
}: {
diff --git a/src/FE/pages/admin/login-service/index.tsx b/src/FE/pages/admin/login-service/index.tsx
index 377a172e..a7910f99 100644
--- a/src/FE/pages/admin/login-service/index.tsx
+++ b/src/FE/pages/admin/login-service/index.tsx
@@ -2,11 +2,8 @@ import React, { useEffect, useState } from 'react';
import useTranslation from '@/hooks/useTranslation';
-import { DEFAULT_LANGUAGE } from '@/utils/settings';
-
import { GetLoginServicesResult } from '@/types/adminApis';
-import { LoginServiceModal } from '@/components/Admin/LoginService/LoginServiceModal';
import { Button } from '@/components/ui/button';
import { Card } from '@/components/ui/card';
import {
@@ -18,6 +15,8 @@ import {
TableRow,
} from '@/components/ui/table';
+import LoginServiceModal from '../_components/LoginService/LoginServiceModal';
+
import { getLoginServices } from '@/apis/adminApis';
export default function LoginService() {
diff --git a/src/FE/pages/admin/messages/index.tsx b/src/FE/pages/admin/messages/index.tsx
index f2a704bf..37387d9c 100644
--- a/src/FE/pages/admin/messages/index.tsx
+++ b/src/FE/pages/admin/messages/index.tsx
@@ -2,12 +2,9 @@ import React, { useEffect, useState } from 'react';
import useTranslation from '@/hooks/useTranslation';
-import { DEFAULT_LANGUAGE } from '@/utils/settings';
-
import { GetUserMessageResult } from '@/types/adminApis';
import { PageResult, Paging } from '@/types/page';
-import PaginationContainer from '@/components/Admin/Pagiation/Pagiation';
import { Badge } from '@/components/ui/badge';
import { Card } from '@/components/ui/card';
import { Input } from '@/components/ui/input';
@@ -20,6 +17,8 @@ import {
TableRow,
} from '@/components/ui/table';
+import PaginationContainer from '../_components/Pagiation/Pagiation';
+
import { getMessages } from '@/apis/adminApis';
export default function Messages() {
diff --git a/src/FE/pages/admin/model-keys/index.tsx b/src/FE/pages/admin/model-keys/index.tsx
index fdef4628..4596373d 100644
--- a/src/FE/pages/admin/model-keys/index.tsx
+++ b/src/FE/pages/admin/model-keys/index.tsx
@@ -6,8 +6,6 @@ import useTranslation from '@/hooks/useTranslation';
import { GetModelKeysResult } from '@/types/adminApis';
import { feModelProviders } from '@/types/model';
-import { ConfigModelModal } from '@/components/Admin/ModelKeys/ConfigModelModal';
-import { ModelKeysModal } from '@/components/Admin/ModelKeys/ModelKeysModal';
import { Button } from '@/components/ui/button';
import { Card } from '@/components/ui/card';
import {
@@ -19,6 +17,9 @@ import {
TableRow,
} from '@/components/ui/table';
+import ConfigModelModal from '../_components/ModelKeys/ConfigModelModal';
+import ModelKeysModal from '../_components/ModelKeys/ModelKeysModal';
+
import { getModelKeys } from '@/apis/adminApis';
export default function ModelKeys() {
diff --git a/src/FE/pages/admin/models/index.tsx b/src/FE/pages/admin/models/index.tsx
index 24cbafa1..d358f2c6 100644
--- a/src/FE/pages/admin/models/index.tsx
+++ b/src/FE/pages/admin/models/index.tsx
@@ -5,9 +5,8 @@ import useTranslation from '@/hooks/useTranslation';
import { formatNumberAsMoney } from '@/utils/common';
import { AdminModelDto, GetModelKeysResult } from '@/types/adminApis';
+import { feModelProviders } from '@/types/model';
-import { AddModelModal } from '@/components/Admin/Models/AddModelModal';
-import { EditModelModal } from '@/components/Admin/Models/EditModelModal';
import { Button } from '@/components/ui/button';
import { Card } from '@/components/ui/card';
import {
@@ -19,8 +18,10 @@ import {
TableRow,
} from '@/components/ui/table';
+import AddModelModal from '../_components/Models/AddModelModal';
+import EditModelModal from '../_components/Models/EditModelModal';
+
import { getModelKeys, getModels } from '@/apis/adminApis';
-import { feModelProviders } from '@/types/model';
export default function Models() {
const { t } = useTranslation();
@@ -65,7 +66,9 @@ export default function Models() {
);
};
+export default ChatInput;
diff --git a/src/FE/components/Chat/EnableNetworkSearch.tsx b/src/FE/pages/home/_components/Chat/EnableNetworkSearch.tsx
similarity index 100%
rename from src/FE/components/Chat/EnableNetworkSearch.tsx
rename to src/FE/pages/home/_components/Chat/EnableNetworkSearch.tsx
diff --git a/src/FE/pages/home/_components/Chat/MemoizedChatMessage.tsx b/src/FE/pages/home/_components/Chat/MemoizedChatMessage.tsx
new file mode 100644
index 00000000..1384e5cd
--- /dev/null
+++ b/src/FE/pages/home/_components/Chat/MemoizedChatMessage.tsx
@@ -0,0 +1,12 @@
+import { FC, memo } from 'react';
+
+import { ChatMessage, Props } from '@/components/ChatMessage';
+
+const MemoizedChatMessage: FC = memo(
+ ChatMessage,
+ (prevProps, nextProps) =>
+ prevProps.message.content === nextProps.message.content &&
+ prevProps.messageIsStreaming === nextProps.messageIsStreaming,
+);
+
+export default MemoizedChatMessage;
diff --git a/src/FE/components/Chat/ModelSelect.tsx b/src/FE/pages/home/_components/Chat/ModelSelect.tsx
similarity index 65%
rename from src/FE/components/Chat/ModelSelect.tsx
rename to src/FE/pages/home/_components/Chat/ModelSelect.tsx
index 1bc843de..6a4c6ade 100644
--- a/src/FE/components/Chat/ModelSelect.tsx
+++ b/src/FE/pages/home/_components/Chat/ModelSelect.tsx
@@ -6,23 +6,15 @@ import { formatNumberAsMoney } from '@/utils/common';
import { ModelUsageDto } from '@/types/clientApis';
-import {
- Select,
- SelectContent,
- SelectItem,
- SelectTrigger,
- SelectValue,
-} from '../ui/select';
+import HomeContext from '../../_contents/Home.context';
import { getModelUsage } from '@/apis/clientApis';
-import { HomeContext } from '@/contexts/Home.context';
-export const ModelSelect = () => {
+const ModelSelect = () => {
const { t } = useTranslation();
const {
- state: { selectModel, models },
- handleSelectModel,
+ state: { selectModel },
} = useContext(HomeContext);
const [modelUsage, setModelUsage] = useState();
@@ -34,16 +26,6 @@ export const ModelSelect = () => {
}
}, [selectModel]);
- const handleChange = (value: string) => {
- const model = models.find((m) => m.modelId.toString() == value);
- if (!model) return;
-
- handleSelectModel(model);
- getModelUsage(model.modelId).then((res) => {
- setModelUsage(res);
- });
- };
-
const getTitle = () => {
if (modelUsage) {
if (modelUsage.tokens === 0 && modelUsage.counts === 0) {
@@ -64,24 +46,6 @@ export const ModelSelect = () => {
- {/*
-
- */}
{modelUsage && modelUsage.tokens === 0 && modelUsage.counts === 0 ? (
¥{modelUsage.inputTokenPrice1M.toFixed(4)}/
@@ -120,3 +84,5 @@ export const ModelSelect = () => {
);
};
+
+export default ModelSelect;
diff --git a/src/FE/components/Chat/NoModel.tsx b/src/FE/pages/home/_components/Chat/NoModel.tsx
similarity index 93%
rename from src/FE/components/Chat/NoModel.tsx
rename to src/FE/pages/home/_components/Chat/NoModel.tsx
index 0bb7c01b..396b1f9a 100644
--- a/src/FE/components/Chat/NoModel.tsx
+++ b/src/FE/pages/home/_components/Chat/NoModel.tsx
@@ -1,6 +1,6 @@
import useTranslation from '@/hooks/useTranslation';
-import { IconModelSearch } from '../Icons';
+import { IconModelSearch } from '@/components/Icons';
const NoModel = () => {
const { t } = useTranslation();
diff --git a/src/FE/components/Chat/PromptList.tsx b/src/FE/pages/home/_components/Chat/PromptList.tsx
similarity index 92%
rename from src/FE/components/Chat/PromptList.tsx
rename to src/FE/pages/home/_components/Chat/PromptList.tsx
index 3b008083..d50b8e34 100644
--- a/src/FE/components/Chat/PromptList.tsx
+++ b/src/FE/pages/home/_components/Chat/PromptList.tsx
@@ -1,4 +1,4 @@
-import { ForwardedRef, MutableRefObject, forwardRef } from 'react';
+import { MutableRefObject } from 'react';
import { Prompt } from '@/types/prompt';
@@ -10,7 +10,7 @@ interface Props {
promptListRef: MutableRefObject;
}
-export const PromptList = ({
+const PromptList = ({
prompts,
activePromptIndex,
promptListRef,
@@ -43,3 +43,5 @@ export const PromptList = ({
);
};
+
+export default PromptList;
diff --git a/src/FE/components/Chat/SharedMessageModal.tsx b/src/FE/pages/home/_components/Chat/SharedMessageModal.tsx
similarity index 96%
rename from src/FE/components/Chat/SharedMessageModal.tsx
rename to src/FE/pages/home/_components/Chat/SharedMessageModal.tsx
index a539747b..13925391 100644
--- a/src/FE/components/Chat/SharedMessageModal.tsx
+++ b/src/FE/pages/home/_components/Chat/SharedMessageModal.tsx
@@ -23,7 +23,7 @@ interface IProps {
onShareChange: (isShared: boolean) => void;
}
-export const SharedMessageModal = (props: IProps) => {
+const SharedMessageModal = (props: IProps) => {
const { t } = useTranslation();
const { chat, isOpen, onClose, onShareChange } = props;
const [loading, setLoading] = useState(false);
@@ -104,3 +104,4 @@ export const SharedMessageModal = (props: IProps) => {
);
};
+export default SharedMessageModal;
diff --git a/src/FE/components/Chat/SystemPrompt.tsx b/src/FE/pages/home/_components/Chat/SystemPrompt.tsx
similarity index 95%
rename from src/FE/components/Chat/SystemPrompt.tsx
rename to src/FE/pages/home/_components/Chat/SystemPrompt.tsx
index 478360ba..e2509911 100644
--- a/src/FE/components/Chat/SystemPrompt.tsx
+++ b/src/FE/pages/home/_components/Chat/SystemPrompt.tsx
@@ -9,24 +9,25 @@ import {
import useTranslation from '@/hooks/useTranslation';
+import { formatPrompt } from '@/utils/promptVariable';
+
+import { AdminModelDto } from '@/types/adminApis';
import { Prompt } from '@/types/prompt';
-import { PromptList } from './PromptList';
-import { VariableModal } from './VariableModal';
+import PromptList from './PromptList';
+import VariableModal from './VariableModal';
import { getUserPromptDetail } from '@/apis/clientApis';
-import { formatPrompt } from '@/utils/promptVariable';
-import { AdminModelDto } from '@/types/adminApis';
interface Props {
currentPrompt: string;
prompts: Prompt[];
- model: AdminModelDto,
+ model: AdminModelDto;
onChangePromptText: (prompt: string) => void;
onChangePrompt: (prompt: Prompt) => void;
}
-export const SystemPrompt: FC = ({
+const SystemPrompt: FC = ({
currentPrompt,
prompts,
model,
@@ -196,10 +197,11 @@ export const SystemPrompt: FC = ({
resize: 'none',
bottom: `${textareaRef?.current?.scrollHeight}px`,
maxHeight: '300px',
- overflow: `${textareaRef.current && textareaRef.current.scrollHeight > 400
+ overflow: `${
+ textareaRef.current && textareaRef.current.scrollHeight > 400
? 'auto'
: 'hidden'
- }`,
+ }`,
}}
placeholder={
t(`Enter a prompt or type "/" to select a prompt...`) || ''
@@ -233,3 +235,5 @@ export const SystemPrompt: FC = ({
);
};
+
+export default SystemPrompt;
diff --git a/src/FE/components/Chat/VariableModal.tsx b/src/FE/pages/home/_components/Chat/VariableModal.tsx
similarity index 96%
rename from src/FE/components/Chat/VariableModal.tsx
rename to src/FE/pages/home/_components/Chat/VariableModal.tsx
index d989bea8..34f36edc 100644
--- a/src/FE/components/Chat/VariableModal.tsx
+++ b/src/FE/pages/home/_components/Chat/VariableModal.tsx
@@ -21,12 +21,7 @@ interface Props {
onClose: () => void;
}
-export const VariableModal: FC = ({
- prompt,
- variables,
- onSubmit,
- onClose,
-}) => {
+const VariableModal: FC = ({ prompt, variables, onSubmit, onClose }) => {
const { t } = useTranslation();
const [updatedVariables, setUpdatedVariables] = useState<
{ key: string; value: string }[]
@@ -112,3 +107,5 @@ export const VariableModal: FC = ({
);
};
+
+export default VariableModal;
diff --git a/src/FE/components/ChatSettings/ChatSettings.tsx b/src/FE/pages/home/_components/ChatSettings/ChatSettings.tsx
similarity index 100%
rename from src/FE/components/ChatSettings/ChatSettings.tsx
rename to src/FE/pages/home/_components/ChatSettings/ChatSettings.tsx
diff --git a/src/FE/components/ChatSettings/ChatSettingsBar.tsx b/src/FE/pages/home/_components/ChatSettings/ChatSettingsBar.tsx
similarity index 88%
rename from src/FE/components/ChatSettings/ChatSettingsBar.tsx
rename to src/FE/pages/home/_components/ChatSettings/ChatSettingsBar.tsx
index 2d932f50..54a59091 100644
--- a/src/FE/components/ChatSettings/ChatSettingsBar.tsx
+++ b/src/FE/pages/home/_components/ChatSettings/ChatSettingsBar.tsx
@@ -1,9 +1,8 @@
-import { useContext, useEffect, useState } from 'react';
+import { useContext, useState } from 'react';
-import { HomeContext } from '@/contexts/Home.context';
+import { IconX } from '@/components/Icons';
-import { IconX } from '../Icons';
-import ChatSettings from './ChatSettings';
+import HomeContext from '../../_contents/Home.context';
import SliderSetting from './SliderSetting';
const ChatSettingsBar = () => {
diff --git a/src/FE/components/ChatSettings/SliderSetting.tsx b/src/FE/pages/home/_components/ChatSettings/SliderSetting.tsx
similarity index 100%
rename from src/FE/components/ChatSettings/SliderSetting.tsx
rename to src/FE/pages/home/_components/ChatSettings/SliderSetting.tsx
diff --git a/src/FE/components/Chatbar/Chatbar.context.tsx b/src/FE/pages/home/_components/Chatbar/Chatbar.context.tsx
similarity index 61%
rename from src/FE/components/Chatbar/Chatbar.context.tsx
rename to src/FE/pages/home/_components/Chatbar/Chatbar.context.tsx
index 15f38cf1..c21f11db 100644
--- a/src/FE/components/Chatbar/Chatbar.context.tsx
+++ b/src/FE/pages/home/_components/Chatbar/Chatbar.context.tsx
@@ -2,13 +2,22 @@ import { Dispatch, createContext } from 'react';
import { ActionType } from '@/hooks/useCreateReducer';
-import { ChatbarInitialState } from './Chatbar.state';
+import { ChatResult } from '@/types/clientApis';
export interface ChatbarContextProps {
state: ChatbarInitialState;
dispatch: Dispatch>;
handleDeleteChat: (chatId: string) => void;
}
+export interface ChatbarInitialState {
+ searchTerm: string;
+ filteredChats: ChatResult[];
+}
+
+export const initialState: ChatbarInitialState = {
+ searchTerm: '',
+ filteredChats: [],
+};
const ChatbarContext = createContext(undefined!);
diff --git a/src/FE/components/Chatbar/Chatbar.tsx b/src/FE/pages/home/_components/Chatbar/Chatbar.tsx
similarity index 89%
rename from src/FE/components/Chatbar/Chatbar.tsx
rename to src/FE/pages/home/_components/Chatbar/Chatbar.tsx
index 2701aa2e..357c078c 100644
--- a/src/FE/components/Chatbar/Chatbar.tsx
+++ b/src/FE/pages/home/_components/Chatbar/Chatbar.tsx
@@ -7,16 +7,14 @@ import { removeSelectChatId, saveSelectChatId } from '@/utils/chats';
import { ChatResult } from '@/types/clientApis';
-import Sidebar from '@/components/Sidebar';
-
+import HomeContext from '../../_contents/Home.context';
+import Sidebar from '../Sidebar/Sidebar';
import ChatbarContext from './Chatbar.context';
-import { ChatbarInitialState, initialState } from './Chatbar.state';
-import { ChatBarSettings } from './ChatbarSettings';
-import { Conversations } from './Conversations';
-
-import { HomeContext } from '@/contexts/Home.context';
+import { ChatbarInitialState, initialState } from './Chatbar.context';
+import ChatBarSettings from './ChatbarSettings';
+import Conversations from './Conversations';
-export const Chatbar = () => {
+const Chatbar = () => {
const { t } = useTranslation();
const chatBarContextValue = useCreateReducer({
@@ -102,3 +100,4 @@ export const Chatbar = () => {
);
};
+export default Chatbar;
diff --git a/src/FE/components/Chatbar/ChatbarSettings.tsx b/src/FE/pages/home/_components/Chatbar/ChatbarSettings.tsx
similarity index 91%
rename from src/FE/components/Chatbar/ChatbarSettings.tsx
rename to src/FE/pages/home/_components/Chatbar/ChatbarSettings.tsx
index 713af4d9..99ff4f53 100644
--- a/src/FE/components/Chatbar/ChatbarSettings.tsx
+++ b/src/FE/pages/home/_components/Chatbar/ChatbarSettings.tsx
@@ -17,10 +17,6 @@ import {
IconSettingsCog,
IconUser,
} from '@/components/Icons/index';
-import { ChangePasswordModal } from '@/components/Modal/ChangePasswordModal';
-import UserBalanceModal from '@/components/Modal/UserBalanceModal';
-import { SettingModal } from '@/components/Settings/SettingModal';
-import { SidebarButton } from '@/components/Sidebar/SidebarButton';
import {
Popover,
PopoverContent,
@@ -28,10 +24,15 @@ import {
} from '@/components/ui/popover';
import { Separator } from '@/components/ui/separator';
+import HomeContext from '../../_contents/Home.context';
+import ChangePasswordModal from '../Modal/ChangePasswordModal';
+import UserBalanceModal from '../Modal/UserBalanceModal';
+import SettingModal from '../Settings/SettingModal';
+import SidebarButton from '../Sidebar/SidebarButton';
+
import { getUserBalanceOnly } from '@/apis/clientApis';
-import { HomeContext } from '@/contexts/Home.context';
-export const ChatBarSettings = () => {
+const ChatBarSettings = () => {
const router = useRouter();
const { t } = useTranslation();
const [changePwdModalOpen, setChangePwdModalOpen] = useState(false);
@@ -153,3 +154,4 @@ export const ChatBarSettings = () => {
);
};
+export default ChatBarSettings;
diff --git a/src/FE/components/Chatbar/ClearConversations.tsx b/src/FE/pages/home/_components/Chatbar/ClearConversations.tsx
similarity index 89%
rename from src/FE/components/Chatbar/ClearConversations.tsx
rename to src/FE/pages/home/_components/Chatbar/ClearConversations.tsx
index 1989ac88..fb4bfc32 100644
--- a/src/FE/components/Chatbar/ClearConversations.tsx
+++ b/src/FE/pages/home/_components/Chatbar/ClearConversations.tsx
@@ -3,13 +3,14 @@ import { FC, useState } from 'react';
import useTranslation from '@/hooks/useTranslation';
import { IconCheck, IconTrash, IconX } from '@/components/Icons/index';
-import { SidebarButton } from '@/components/Sidebar/SidebarButton';
+
+import SidebarButton from '../Sidebar/SidebarButton';
interface Props {
onClearConversations: () => void;
}
-export const ClearConversations: FC = ({ onClearConversations }) => {
+const ClearConversations: FC = ({ onClearConversations }) => {
const [isConfirming, setIsConfirming] = useState(false);
const { t } = useTranslation();
@@ -55,3 +56,5 @@ export const ClearConversations: FC = ({ onClearConversations }) => {
/>
);
};
+
+export default ClearConversations;
diff --git a/src/FE/components/Chatbar/Conversation.tsx b/src/FE/pages/home/_components/Chatbar/Conversation.tsx
similarity index 94%
rename from src/FE/components/Chatbar/Conversation.tsx
rename to src/FE/pages/home/_components/Chatbar/Conversation.tsx
index f2d11585..895e04a8 100644
--- a/src/FE/components/Chatbar/Conversation.tsx
+++ b/src/FE/pages/home/_components/Chatbar/Conversation.tsx
@@ -10,12 +10,9 @@ import toast from 'react-hot-toast';
import useTranslation from '@/hooks/useTranslation';
import { ChatResult } from '@/types/clientApis';
-import { DBModelProvider } from '@/types/model';
import SidebarActionButton from '@/components/Button/SidebarActionButton';
-import { SharedMessageModal } from '@/components/Chat/SharedMessageModal';
import ChatIcon from '@/components/ChatIcon/ChatIcon';
-import ChatbarContext from '@/components/Chatbar/Chatbar.context';
import {
IconCheck,
IconDots,
@@ -24,7 +21,6 @@ import {
IconTrash,
IconX,
} from '@/components/Icons/index';
-import { Button } from '@/components/ui/button';
import {
DropdownMenu,
DropdownMenuContent,
@@ -32,14 +28,17 @@ import {
DropdownMenuTrigger,
} from '@/components/ui/dropdown-menu';
+import HomeContext from '../../_contents/Home.context';
+import SharedMessageModal from '../Chat/SharedMessageModal';
+import ChatbarContext from '../Chatbar/Chatbar.context';
+
import { deleteChats, putChats } from '@/apis/clientApis';
-import { HomeContext } from '@/contexts/Home.context';
interface Props {
chat: ChatResult;
}
-export const ConversationComponent = ({ chat }: Props) => {
+const ConversationComponent = ({ chat }: Props) => {
const { t } = useTranslation();
const {
state: {
@@ -215,3 +214,5 @@ export const ConversationComponent = ({ chat }: Props) => {
);
};
+
+export default ConversationComponent;
diff --git a/src/FE/components/Chatbar/Conversations.tsx b/src/FE/pages/home/_components/Chatbar/Conversations.tsx
similarity index 85%
rename from src/FE/components/Chatbar/Conversations.tsx
rename to src/FE/pages/home/_components/Chatbar/Conversations.tsx
index 2c552378..c4c3b0d0 100644
--- a/src/FE/components/Chatbar/Conversations.tsx
+++ b/src/FE/pages/home/_components/Chatbar/Conversations.tsx
@@ -4,17 +4,16 @@ import useTranslation from '@/hooks/useTranslation';
import { ChatResult } from '@/types/clientApis';
-import { HomeContext } from '@/contexts/Home.context';
-
import { Button } from '@/components/ui/button';
-import { ConversationComponent } from './Conversation';
+import HomeContext from '../../_contents/Home.context';
+import ConversationComponent from './Conversation';
interface Props {
chats: ChatResult[];
}
-export const Conversations = ({ chats }: Props) => {
+const Conversations = ({ chats }: Props) => {
const { t } = useTranslation();
const {
state: { chatsPaging },
@@ -46,3 +45,4 @@ export const Conversations = ({ chats }: Props) => {
);
};
+export default Conversations;
diff --git a/src/FE/components/HomeContent/HomeContent.tsx b/src/FE/pages/home/_components/HomeContent/HomeContent.tsx
similarity index 96%
rename from src/FE/components/HomeContent/HomeContent.tsx
rename to src/FE/pages/home/_components/HomeContent/HomeContent.tsx
index 49b60c72..251703e9 100644
--- a/src/FE/components/HomeContent/HomeContent.tsx
+++ b/src/FE/pages/home/_components/HomeContent/HomeContent.tsx
@@ -1,4 +1,4 @@
-import { useEffect, useRef } from 'react';
+import { useEffect } from 'react';
import { useRouter } from 'next/router';
@@ -22,11 +22,17 @@ import { DEFAULT_TEMPERATURE, IChat, Role } from '@/types/chat';
import { ChatMessage } from '@/types/chatMessage';
import { ChatResult, GetChatsParams } from '@/types/clientApis';
-import { Chat } from '@/components/Chat/Chat';
-import ChatSettingsBar from '@/components/ChatSettings/ChatSettingsBar';
-import { Chatbar } from '@/components/Chatbar/Chatbar';
-import PromptBar from '@/components/Promptbar';
-import Spinner from '@/components/Spinner';
+import Spinner from '@/components/Spinner/Spinner';
+
+import HomeContext, {
+ HandleUpdateChatParams,
+ HomeInitialState,
+ initialState,
+} from '../../_contents/Home.context';
+import Chat from '../Chat/Chat';
+import ChatSettingsBar from '../ChatSettings/ChatSettingsBar';
+import Chatbar from '../Chatbar/Chatbar';
+import PromptBar from '../Promptbar/Promptbar';
import {
getChatsByPaging,
@@ -36,12 +42,6 @@ import {
getUserPromptBrief,
postChats,
} from '@/apis/clientApis';
-import {
- HandleUpdateChatParams,
- HomeContext,
- HomeInitialState,
- initialState,
-} from '@/contexts/Home.context';
import Decimal from 'decimal.js';
import { v4 as uuidv4 } from 'uuid';
@@ -103,7 +103,7 @@ const HomeContent = () => {
data.temperature ??
userModelConfig?.temperature ??
DEFAULT_TEMPERATURE,
- prompt: data.content,
+ prompt: formatPrompt(data.content, { model }),
});
});
};
diff --git a/src/FE/components/Modal/ChangePasswordModal.tsx b/src/FE/pages/home/_components/Modal/ChangePasswordModal.tsx
similarity index 98%
rename from src/FE/components/Modal/ChangePasswordModal.tsx
rename to src/FE/pages/home/_components/Modal/ChangePasswordModal.tsx
index ae833119..a7ecf701 100644
--- a/src/FE/components/Modal/ChangePasswordModal.tsx
+++ b/src/FE/pages/home/_components/Modal/ChangePasswordModal.tsx
@@ -29,7 +29,7 @@ interface Props {
onClose: () => void;
}
-export const ChangePasswordModal = (props: Props) => {
+const ChangePasswordModal = (props: Props) => {
const { isOpen, onClose } = props;
const { t } = useTranslation();
const router = useRouter();
@@ -159,3 +159,4 @@ export const ChangePasswordModal = (props: Props) => {
);
};
+export default ChangePasswordModal;
diff --git a/src/FE/components/Modal/UserBalanceModal.tsx b/src/FE/pages/home/_components/Modal/UserBalanceModal.tsx
similarity index 100%
rename from src/FE/components/Modal/UserBalanceModal.tsx
rename to src/FE/pages/home/_components/Modal/UserBalanceModal.tsx
diff --git a/src/FE/components/ModeToggle/ModeTooggle.tsx b/src/FE/pages/home/_components/ModeToggle/ModeToggle.tsx
similarity index 92%
rename from src/FE/components/ModeToggle/ModeTooggle.tsx
rename to src/FE/pages/home/_components/ModeToggle/ModeToggle.tsx
index fc6cb780..5c4ad186 100644
--- a/src/FE/components/ModeToggle/ModeTooggle.tsx
+++ b/src/FE/pages/home/_components/ModeToggle/ModeToggle.tsx
@@ -7,7 +7,7 @@ import { useTheme } from 'next-themes';
import { IconMoon, IconSun } from '@/components/Icons';
import { Button } from '@/components/ui/button';
-export function ModeToggle() {
+function ModeToggle() {
const { setTheme } = useTheme();
return (
@@ -25,3 +25,4 @@ export function ModeToggle() {
);
}
+export default ModeToggle;
diff --git a/src/FE/components/PasteUpload/PasteUpload.tsx b/src/FE/pages/home/_components/PasteUpload/PasteUpload.tsx
similarity index 99%
rename from src/FE/components/PasteUpload/PasteUpload.tsx
rename to src/FE/pages/home/_components/PasteUpload/PasteUpload.tsx
index 0c7c329c..13c222e9 100644
--- a/src/FE/components/PasteUpload/PasteUpload.tsx
+++ b/src/FE/pages/home/_components/PasteUpload/PasteUpload.tsx
@@ -1,8 +1,9 @@
import React, { useEffect, useRef } from 'react';
import { checkFileSizeCanUpload, uploadFile } from '@/utils/uploadFile';
-import { ChatModelFileConfig } from '@/types/model';
+
import { ImageDef } from '@/types/chat';
+import { ChatModelFileConfig } from '@/types/model';
interface IPasteUploadProps {
fileServiceId: number;
diff --git a/src/FE/components/Popover/DateTimePopover.tsx b/src/FE/pages/home/_components/Popover/DateTimePopover.tsx
similarity index 93%
rename from src/FE/components/Popover/DateTimePopover.tsx
rename to src/FE/pages/home/_components/Popover/DateTimePopover.tsx
index dc18d626..1ff52815 100644
--- a/src/FE/components/Popover/DateTimePopover.tsx
+++ b/src/FE/pages/home/_components/Popover/DateTimePopover.tsx
@@ -1,7 +1,11 @@
import { IconSquareRoundedX } from '@/components/Icons';
import { Button } from '@/components/ui/button';
import { Calendar } from '@/components/ui/calendar';
-import { Popover, PopoverContent, PopoverTrigger } from '@/components/ui/popover';
+import {
+ Popover,
+ PopoverContent,
+ PopoverTrigger,
+} from '@/components/ui/popover';
import { cn } from '@/lib/utils';
diff --git a/src/FE/components/Popover/DeletePopover.tsx b/src/FE/pages/home/_components/Popover/DeletePopover.tsx
similarity index 93%
rename from src/FE/components/Popover/DeletePopover.tsx
rename to src/FE/pages/home/_components/Popover/DeletePopover.tsx
index 98f952c4..0ea3cf95 100644
--- a/src/FE/components/Popover/DeletePopover.tsx
+++ b/src/FE/pages/home/_components/Popover/DeletePopover.tsx
@@ -3,7 +3,11 @@ import { useState } from 'react';
import useTranslation from '@/hooks/useTranslation';
import { Button } from '@/components/ui/button';
-import { Popover, PopoverContent, PopoverTrigger } from '@/components/ui/popover';
+import {
+ Popover,
+ PopoverContent,
+ PopoverTrigger,
+} from '@/components/ui/popover';
interface Props {
onDelete: () => void;
diff --git a/src/FE/components/Promptbar/components/Prompt.tsx b/src/FE/pages/home/_components/Promptbar/Prompt.tsx
similarity index 95%
rename from src/FE/components/Promptbar/components/Prompt.tsx
rename to src/FE/pages/home/_components/Promptbar/Prompt.tsx
index c7b4d480..0eb116b4 100644
--- a/src/FE/components/Promptbar/components/Prompt.tsx
+++ b/src/FE/pages/home/_components/Promptbar/Prompt.tsx
@@ -10,8 +10,8 @@ import {
IconX,
} from '@/components/Icons/index';
-import PromptbarContext from '../PromptBar.context';
-import { PromptModal } from './PromptModal';
+import PromptbarContext from './PromptBar.context';
+import PromptModal from './PromptModal';
import { getUserPromptDetail } from '@/apis/clientApis';
@@ -19,7 +19,7 @@ interface Props {
prompt: PromptSlim;
}
-export const PromptComponent = ({ prompt }: Props) => {
+const PromptComponent = ({ prompt }: Props) => {
const {
dispatch: promptDispatch,
handleUpdatePrompt,
@@ -128,3 +128,4 @@ export const PromptComponent = ({ prompt }: Props) => {
);
};
+export default PromptComponent;
diff --git a/src/FE/components/Promptbar/PromptBar.context.tsx b/src/FE/pages/home/_components/Promptbar/PromptBar.context.tsx
similarity index 63%
rename from src/FE/components/Promptbar/PromptBar.context.tsx
rename to src/FE/pages/home/_components/Promptbar/PromptBar.context.tsx
index 497cf510..9201a0ee 100644
--- a/src/FE/components/Promptbar/PromptBar.context.tsx
+++ b/src/FE/pages/home/_components/Promptbar/PromptBar.context.tsx
@@ -2,9 +2,8 @@ import { Dispatch, createContext } from 'react';
import { ActionType } from '@/hooks/useCreateReducer';
-import { Prompt, PromptSlim } from '@/types/prompt';
-
-import { PromptbarInitialState } from './Promptbar.state';
+import { Prompt } from '@/types/prompt';
+import { PromptSlim } from '@/types/prompt';
export interface PromptbarContextProps {
state: PromptbarInitialState;
@@ -14,6 +13,16 @@ export interface PromptbarContextProps {
handleUpdatePrompt: (prompt: Prompt) => void;
}
+export interface PromptbarInitialState {
+ searchTerm: string;
+ filteredPrompts: PromptSlim[];
+}
+
+export const initialState: PromptbarInitialState = {
+ searchTerm: '',
+ filteredPrompts: [],
+};
+
const PromptbarContext = createContext(undefined!);
export default PromptbarContext;
diff --git a/src/FE/components/Promptbar/components/PromptModal.tsx b/src/FE/pages/home/_components/Promptbar/PromptModal.tsx
similarity index 96%
rename from src/FE/components/Promptbar/components/PromptModal.tsx
rename to src/FE/pages/home/_components/Promptbar/PromptModal.tsx
index a5d77ca4..c6d7e51f 100644
--- a/src/FE/components/Promptbar/components/PromptModal.tsx
+++ b/src/FE/pages/home/_components/Promptbar/PromptModal.tsx
@@ -9,8 +9,8 @@ import { UserRole } from '@/types/adminApis';
import { DEFAULT_TEMPERATURE } from '@/types/chat';
import { Prompt } from '@/types/prompt';
-import { TemperatureSlider } from '@/components/Chat/Temperature';
import { IconInfo } from '@/components/Icons';
+import TemperatureSlider from '@/components/TemperatureSlider/TemperatureSlider';
import Tips from '@/components/Tips/Tips';
import { Button } from '@/components/ui/button';
import {
@@ -24,7 +24,8 @@ import FormInput from '@/components/ui/form/input';
import FormSwitch from '@/components/ui/form/switch';
import FormTextarea from '@/components/ui/form/textarea';
-import { HomeContext } from '@/contexts/Home.context';
+import HomeContext from '../../_contents/Home.context';
+
import { zodResolver } from '@hookform/resolvers/zod';
import { z } from 'zod';
@@ -34,7 +35,7 @@ interface IProps {
onClose: () => void;
}
-export const PromptModal = (props: IProps) => {
+const PromptModal = (props: IProps) => {
const { t } = useTranslation();
const { prompt, onUpdatePrompt, onClose } = props;
@@ -191,3 +192,4 @@ export const PromptModal = (props: IProps) => {
);
};
+export default PromptModal;
diff --git a/src/FE/components/Promptbar/Promptbar.tsx b/src/FE/pages/home/_components/Promptbar/Promptbar.tsx
similarity index 91%
rename from src/FE/components/Promptbar/Promptbar.tsx
rename to src/FE/pages/home/_components/Promptbar/Promptbar.tsx
index df0089df..744a550e 100644
--- a/src/FE/components/Promptbar/Promptbar.tsx
+++ b/src/FE/pages/home/_components/Promptbar/Promptbar.tsx
@@ -1,19 +1,16 @@
import { useContext, useEffect } from 'react';
import toast from 'react-hot-toast';
-import useTranslation from '@/hooks/useTranslation';
-
import { useCreateReducer } from '@/hooks/useCreateReducer';
+import useTranslation from '@/hooks/useTranslation';
import { Prompt, PromptSlim } from '@/types/prompt';
-import { HomeContext } from '@/contexts/Home.context';
-
-import { Prompts } from './components/Prompts';
-import Sidebar from '@/components/Sidebar';
-
+import HomeContext from '../../_contents/Home.context';
+import Sidebar from '../Sidebar/Sidebar';
import PromptbarContext from './PromptBar.context';
-import { PromptbarInitialState, initialState } from './Promptbar.state';
+import { PromptbarInitialState, initialState } from './PromptBar.context';
+import Prompts from './Prompts';
import {
deleteUserPrompts,
@@ -72,7 +69,7 @@ const PromptBar = () => {
const handleUpdatePrompt = (prompt: Prompt) => {
putUserPrompts(prompt.id, prompt).then(() => {
- const existingPrompts = prompts.filter(x => x.id !== prompt.id);
+ const existingPrompts = prompts.filter((x) => x.id !== prompt.id);
homeDispatch({ field: 'prompts', value: [...existingPrompts, prompt] });
toast.success(t('Updated successful'));
});
diff --git a/src/FE/components/Promptbar/components/Prompts.tsx b/src/FE/pages/home/_components/Promptbar/Prompts.tsx
similarity index 76%
rename from src/FE/components/Promptbar/components/Prompts.tsx
rename to src/FE/pages/home/_components/Promptbar/Prompts.tsx
index 8b85569a..54e674c9 100644
--- a/src/FE/components/Promptbar/components/Prompts.tsx
+++ b/src/FE/pages/home/_components/Promptbar/Prompts.tsx
@@ -2,13 +2,13 @@ import { FC } from 'react';
import { PromptSlim } from '@/types/prompt';
-import { PromptComponent } from './Prompt';
+import PromptComponent from './Prompt';
interface Props {
prompts: PromptSlim[];
}
-export const Prompts: FC = ({ prompts }) => {
+const Prompts: FC = ({ prompts }) => {
return (
{prompts
@@ -20,3 +20,4 @@ export const Prompts: FC = ({ prompts }) => {
);
};
+export default Prompts;
diff --git a/src/FE/components/Settings/ApiKeyTabContent.tsx b/src/FE/pages/home/_components/Settings/ApiKeyTabContent.tsx
similarity index 97%
rename from src/FE/components/Settings/ApiKeyTabContent.tsx
rename to src/FE/pages/home/_components/Settings/ApiKeyTabContent.tsx
index ca5d9c98..96970078 100644
--- a/src/FE/components/Settings/ApiKeyTabContent.tsx
+++ b/src/FE/pages/home/_components/Settings/ApiKeyTabContent.tsx
@@ -10,8 +10,6 @@ import { getApiUrl } from '@/utils/common';
import { GetUserApiKeyResult } from '@/types/clientApis';
import CopyButton from '@/components/Button/CopyButton';
-import DateTimePopover from '@/components/Popover/DateTimePopover';
-import DeletePopover from '@/components/Popover/DeletePopover';
import { Button } from '@/components/ui/button';
import { Card, CardContent } from '@/components/ui/card';
import { Input } from '@/components/ui/input';
@@ -24,6 +22,9 @@ import {
TableRow,
} from '@/components/ui/table';
+import DateTimePopover from '../Popover/DateTimePopover';
+import DeletePopover from '../Popover/DeletePopover';
+
import {
deleteUserApiKey,
getUserApiKey,
@@ -32,7 +33,7 @@ import {
} from '@/apis/clientApis';
let timer: NodeJS.Timeout;
-export const ApiKeyTab = () => {
+const ApiKeyTab = () => {
const { t } = useTranslation();
const [loading, setLoading] = useState(false);
const [apiKeys, setApiKeys] = useState([]);
@@ -178,3 +179,4 @@ export const ApiKeyTab = () => {
);
};
+export default ApiKeyTab;
diff --git a/src/FE/components/Settings/SettingModal.tsx b/src/FE/pages/home/_components/Settings/SettingModal.tsx
similarity index 86%
rename from src/FE/components/Settings/SettingModal.tsx
rename to src/FE/pages/home/_components/Settings/SettingModal.tsx
index 5dd79942..fa0e92d8 100644
--- a/src/FE/components/Settings/SettingModal.tsx
+++ b/src/FE/pages/home/_components/Settings/SettingModal.tsx
@@ -9,14 +9,14 @@ import {
DialogTitle,
} from '@/components/ui/dialog';
-import { ApiKeyTab } from './ApiKeyTabContent';
+import ApiKeyTab from './ApiKeyTabContent';
interface Props {
isOpen: boolean;
onClose: () => void;
}
-export const SettingModal = (props: Props) => {
+const SettingModal = (props: Props) => {
const { isOpen, onClose } = props;
const { t } = useTranslation();
@@ -33,3 +33,4 @@ export const SettingModal = (props: Props) => {
);
};
+export default SettingModal;
diff --git a/src/FE/components/Sidebar/Sidebar.tsx b/src/FE/pages/home/_components/Sidebar/Sidebar.tsx
similarity index 98%
rename from src/FE/components/Sidebar/Sidebar.tsx
rename to src/FE/pages/home/_components/Sidebar/Sidebar.tsx
index 5eb5e62a..4fbc35c6 100644
--- a/src/FE/components/Sidebar/Sidebar.tsx
+++ b/src/FE/pages/home/_components/Sidebar/Sidebar.tsx
@@ -8,7 +8,7 @@ import {
IconSearch,
IconSquarePlus,
} from '@/components/Icons/index';
-import Search from '@/components/Search';
+import Search from '@/components/Search/Search';
import Tips from '@/components/Tips/Tips';
import { Button } from '@/components/ui/button';
diff --git a/src/FE/components/Sidebar/SidebarButton.tsx b/src/FE/pages/home/_components/Sidebar/SidebarButton.tsx
similarity index 93%
rename from src/FE/components/Sidebar/SidebarButton.tsx
rename to src/FE/pages/home/_components/Sidebar/SidebarButton.tsx
index 91ad5114..74a936a0 100644
--- a/src/FE/components/Sidebar/SidebarButton.tsx
+++ b/src/FE/pages/home/_components/Sidebar/SidebarButton.tsx
@@ -8,7 +8,7 @@ interface Props {
onClick: () => void;
}
-export const SidebarButton: FC = ({
+const SidebarButton: FC = ({
text,
icon,
className,
@@ -36,3 +36,4 @@ export const SidebarButton: FC = ({
);
};
+export default SidebarButton;
diff --git a/src/FE/contexts/Home.context.ts b/src/FE/pages/home/_contents/Home.context.ts
similarity index 96%
rename from src/FE/contexts/Home.context.ts
rename to src/FE/pages/home/_contents/Home.context.ts
index 1064e755..26626062 100644
--- a/src/FE/contexts/Home.context.ts
+++ b/src/FE/pages/home/_contents/Home.context.ts
@@ -40,7 +40,7 @@ export interface HomeInitialState {
searchTerm: string;
}
-const initialState: HomeInitialState = {
+export const initialState: HomeInitialState = {
user: null,
loading: false,
messageIsStreaming: false,
@@ -86,4 +86,4 @@ export interface HomeContextProps {
const HomeContext = createContext(undefined!);
-export { initialState, HomeContext };
+export default HomeContext;
diff --git a/src/FE/pages/home/index.tsx b/src/FE/pages/home/index.tsx
index eca169bb..5afb5164 100644
--- a/src/FE/pages/home/index.tsx
+++ b/src/FE/pages/home/index.tsx
@@ -1,6 +1,6 @@
import Head from 'next/head';
-import HomeContent from '@/components/HomeContent/HomeContent';
+import HomeContent from './_components/HomeContent/HomeContent';
const Home = () => {
return (
diff --git a/src/FE/components/Login/AccountLoginCard.tsx b/src/FE/pages/login/_components/AccountLoginCard.tsx
similarity index 100%
rename from src/FE/components/Login/AccountLoginCard.tsx
rename to src/FE/pages/login/_components/AccountLoginCard.tsx
diff --git a/src/FE/components/Login/KeyCloakLogin.tsx b/src/FE/pages/login/_components/KeyCloakLogin.tsx
similarity index 100%
rename from src/FE/components/Login/KeyCloakLogin.tsx
rename to src/FE/pages/login/_components/KeyCloakLogin.tsx
diff --git a/src/FE/components/Login/PhoneLoginCard.tsx b/src/FE/pages/login/_components/PhoneLoginCard.tsx
similarity index 100%
rename from src/FE/components/Login/PhoneLoginCard.tsx
rename to src/FE/pages/login/_components/PhoneLoginCard.tsx
diff --git a/src/FE/components/Login/PhoneRegisterCard.tsx b/src/FE/pages/login/_components/PhoneRegisterCard.tsx
similarity index 100%
rename from src/FE/components/Login/PhoneRegisterCard.tsx
rename to src/FE/pages/login/_components/PhoneRegisterCard.tsx
index 790ea604..418f254f 100644
--- a/src/FE/components/Login/PhoneRegisterCard.tsx
+++ b/src/FE/pages/login/_components/PhoneRegisterCard.tsx
@@ -8,6 +8,7 @@ import useTranslation from '@/hooks/useTranslation';
import { PhoneRegExp, SmsExpirationSeconds } from '@/utils/common';
import { saveUserInfo, setUserSession } from '@/utils/user';
+import { redirectToGithub } from '@/utils/website';
import { Button } from '@/components/ui/button';
import { Card, CardContent } from '@/components/ui/card';
@@ -23,7 +24,6 @@ import { Input } from '@/components/ui/input';
import { registerByPhone, sendRegisterSmsCode } from '@/apis/clientApis';
import { zodResolver } from '@hookform/resolvers/zod';
import { z } from 'zod';
-import { redirectToGithub } from '@/utils/website';
const PhoneRegisterCard = (props: {
loginLoading: boolean;
diff --git a/src/FE/components/Login/WeChatLogin.tsx b/src/FE/pages/login/_components/WeChatLogin.tsx
similarity index 100%
rename from src/FE/components/Login/WeChatLogin.tsx
rename to src/FE/pages/login/_components/WeChatLogin.tsx
diff --git a/src/FE/components/Login/WeChatLoginModal.tsx b/src/FE/pages/login/_components/WeChatLoginModal.tsx
similarity index 96%
rename from src/FE/components/Login/WeChatLoginModal.tsx
rename to src/FE/pages/login/_components/WeChatLoginModal.tsx
index f2b68d0f..6502ab31 100644
--- a/src/FE/components/Login/WeChatLoginModal.tsx
+++ b/src/FE/pages/login/_components/WeChatLoginModal.tsx
@@ -2,7 +2,7 @@ import { useEffect } from 'react';
import useExternal from '@/hooks/useExternal';
-import Spinner from '@/components/Spinner';
+import Spinner from '@/components/Spinner/Spinner';
import { Dialog, DialogContent } from '@/components/ui/dialog';
const WeChatLoginModal = (props: {
diff --git a/src/FE/pages/login/index.tsx b/src/FE/pages/login/index.tsx
index 64667732..c256bb3a 100644
--- a/src/FE/pages/login/index.tsx
+++ b/src/FE/pages/login/index.tsx
@@ -8,14 +8,15 @@ import { LoginConfigsResult } from '@/types/clientApis';
import { SiteInfoConfig } from '@/types/config';
import { LoginType } from '@/types/user';
-import AccountLoginCard from '@/components/Login/AccountLoginCard';
-import KeyCloakLogin from '@/components/Login/KeyCloakLogin';
-import PhoneLoginCard from '@/components/Login/PhoneLoginCard';
-import PhoneRegisterCard from '@/components/Login/PhoneRegisterCard';
-import WeChatLogin from '@/components/Login/WeChatLogin';
import { Button } from '@/components/ui/button';
import { Tabs, TabsContent, TabsList, TabsTrigger } from '@/components/ui/tabs';
+import AccountLoginCard from './_components/AccountLoginCard';
+import KeyCloakLogin from './_components/KeyCloakLogin';
+import PhoneLoginCard from './_components/PhoneLoginCard';
+import PhoneRegisterCard from './_components/PhoneRegisterCard';
+import WeChatLogin from './_components/WeChatLogin';
+
import { getLoginProviders, getSiteInfo } from '@/apis/clientApis';
enum TabKeys {
@@ -136,8 +137,8 @@ export default function LoginPage() {
Chats
-
-
+
+
{webSiteInfo?.filingNumber}
-
- © {new Date().getFullYear()} Chats™ . All Rights Reserved.
-
- {webSiteInfo?.companyName && t(webSiteInfo.companyName)}
-
+ {webSiteInfo?.companyName}
+
+
+ © {new Date().getFullYear()}
+
+ ™ . All Rights Reserved.
+
)}
diff --git a/src/FE/pages/message/[id].tsx b/src/FE/pages/message/[id].tsx
index 33364fee..c62f7284 100644
--- a/src/FE/pages/message/[id].tsx
+++ b/src/FE/pages/message/[id].tsx
@@ -2,16 +2,16 @@ import { useEffect, useState } from 'react';
import { useRouter } from 'next/router';
+import { getQueryId } from '@/utils/common';
import { getSelectMessages } from '@/utils/message';
import { GetMessageDetailsResult } from '@/types/adminApis';
import { ChatMessage } from '@/types/chatMessage';
-import { ChatMessage as ChatMessageComponent } from '@/components/Admin/Messages/ChatMessage';
+import { ChatMessageByReadOnly } from '@/components/ChatMessage/ChatMessageByReadOnly';
import { getMessageDetails } from '@/apis/adminApis';
import Decimal from 'decimal.js';
-import { getQueryId } from '@/utils/common';
export default function MessageDetails() {
const router = useRouter();
@@ -84,12 +84,11 @@ export default function MessageDetails() {
parentChildrenIds = [...parentChildrenIds].reverse();
}
return (
- x === current.id,
)}
isLastMessage={selectMessages.length - 1 === index}
- id={current.id!}
key={current.id + index}
parentId={current.parentId}
onChangeMessage={(messageId: string) => {
diff --git a/src/FE/pages/share/[id].tsx b/src/FE/pages/share/[id].tsx
index c0aaddeb..55c5793f 100644
--- a/src/FE/pages/share/[id].tsx
+++ b/src/FE/pages/share/[id].tsx
@@ -1,22 +1,22 @@
import { useEffect, useState } from 'react';
import Link from 'next/link';
-import { NextRouter, useRouter } from 'next/router';
+import { useRouter } from 'next/router';
import useTranslation from '@/hooks/useTranslation';
+import { getQueryId } from '@/utils/common';
import { getSelectMessages } from '@/utils/message';
import { GetMessageDetailsResult } from '@/types/adminApis';
import { ChatMessage } from '@/types/chatMessage';
-import { ChatMessage as ChatMessageComponent } from '@/components/Admin/Messages/ChatMessage';
+import { ChatMessageByReadOnly } from '@/components/ChatMessage/ChatMessageByReadOnly';
import PageNotFound from '@/components/PageNotFound/PageNotFound';
import { Button } from '@/components/ui/button';
import { getShareMessage } from '@/apis/adminApis';
import Decimal from 'decimal.js';
-import { getQueryId } from '@/utils/common';
export default function ShareMessage() {
const { t } = useTranslation();
@@ -26,8 +26,6 @@ export default function ShareMessage() {
const [loading, setLoading] = useState(true);
const [currentMessages, setCurrentMessages] = useState([]);
-
-
useEffect(() => {
setLoading(true);
if (!router.isReady) return;
@@ -74,12 +72,11 @@ export default function ShareMessage() {
parentChildrenIds = [...parentChildrenIds].reverse();
}
return (
- x === current.id,
)}
isLastMessage={selectMessages.length - 1 === index}
- id={current.id!}
key={current.id + index}
parentId={current.parentId}
onChangeMessage={(messageId: string) => {
diff --git a/src/FE/components/Theme/ThemeProvider.tsx b/src/FE/providers/ThemeProvider.tsx
similarity index 100%
rename from src/FE/components/Theme/ThemeProvider.tsx
rename to src/FE/providers/ThemeProvider.tsx
diff --git a/src/FE/public/logos/azure.svg b/src/FE/public/logos/azure.svg
index fcb11483..142e3b38 100644
--- a/src/FE/public/logos/azure.svg
+++ b/src/FE/public/logos/azure.svg
@@ -1 +1,9 @@
-
\ No newline at end of file
+
+
+
\ No newline at end of file
diff --git a/src/FE/public/logos/github.svg b/src/FE/public/logos/github.svg
new file mode 100644
index 00000000..ce2371a4
--- /dev/null
+++ b/src/FE/public/logos/github.svg
@@ -0,0 +1 @@
+
\ No newline at end of file
diff --git a/src/FE/public/logos/x.svg b/src/FE/public/logos/x.svg
new file mode 100644
index 00000000..39a664ae
--- /dev/null
+++ b/src/FE/public/logos/x.svg
@@ -0,0 +1,12 @@
+
+
\ No newline at end of file
diff --git a/src/FE/types/chat.ts b/src/FE/types/chat.ts
index 8b043200..32e8d308 100644
--- a/src/FE/types/chat.ts
+++ b/src/FE/types/chat.ts
@@ -1,3 +1,5 @@
+import { UserModelConfig } from './model';
+
export type Role = 'assistant' | 'user' | 'system';
export const DEFAULT_TEMPERATURE = 0.5;
@@ -35,7 +37,6 @@ export interface IChat {
title: string;
chatModelId?: string;
modelName: string;
- modelConfig: any;
- userModelConfig: any;
+ userModelConfig: UserModelConfig;
isShared: boolean;
}
diff --git a/src/FE/types/clientApis.ts b/src/FE/types/clientApis.ts
index 7b8dd9db..016c17d2 100644
--- a/src/FE/types/clientApis.ts
+++ b/src/FE/types/clientApis.ts
@@ -1,4 +1,4 @@
-import { DBModelProvider } from './model';
+import { DBModelProvider, UserModelConfig } from './model';
import { Paging } from './page';
import { LoginType } from './user';
@@ -64,8 +64,7 @@ export interface ChatResult {
title: string;
modelId: number;
modelName: string;
- modelConfig: any;
- userModelConfig: any;
+ userModelConfig: UserModelConfig;
isShared: boolean;
modelProviderId: DBModelProvider;
}
diff --git a/src/FE/types/file.ts b/src/FE/types/file.ts
index b7e1e952..097931dd 100644
--- a/src/FE/types/file.ts
+++ b/src/FE/types/file.ts
@@ -8,7 +8,7 @@ export const feFileServiceTypes: FileServiceType[] = [
{ id: 1, name: 'Minio' },
{ id: 2, name: 'AWS S3' },
{ id: 3, name: 'Aliyun OSS' },
- { id: 4, name: 'Azure Blob Storage' }
+ { id: 4, name: 'Azure Blob Storage' },
];
export enum DBFileServiceType {
@@ -16,5 +16,5 @@ export enum DBFileServiceType {
Minio = 1,
AWSS3 = 2,
AliyunOSS = 3,
- AzureBlobStorage = 4
-}
\ No newline at end of file
+ AzureBlobStorage = 4,
+}
diff --git a/src/FE/types/model.ts b/src/FE/types/model.ts
index 6e5e51bf..be07ebe3 100644
--- a/src/FE/types/model.ts
+++ b/src/FE/types/model.ts
@@ -1,8 +1,8 @@
-export interface ModelConfig {
+export interface UserModelConfig {
prompt: string | null;
- maxLength: number;
- temperature?: number;
- enableSearch?: boolean;
+ maxLength: number | null;
+ temperature: number | null;
+ enableSearch: boolean | null;
}
export enum DBModelProvider {
@@ -16,6 +16,8 @@ export enum DBModelProvider {
Spark = 8,
ZhiPuAI = 9,
DeepSeek = 10,
+ X_AI = 11,
+ GithubModels = 12,
}
export type FEModelProvider = {
@@ -36,6 +38,8 @@ export const feModelProviders: FEModelProvider[] = [
{ id: 8, name: 'Xunfei SparkDesk', icon: '/logos/spark.svg' },
{ id: 9, name: 'Zhipu AI', icon: '/logos/zhipuai.svg' },
{ id: 10, name: 'DeepSeek', icon: '/logos/deepseek.svg' },
+ { id: 11, name: 'x.ai', icon: '/logos/x.svg' },
+ { id: 12, name: 'Github Models', icon: '/logos/github.svg' },
];
export interface ChatModelFileConfig {
@@ -47,5 +51,3 @@ export interface ChatModelPriceConfig {
input: number;
out: number;
}
-
-export interface UserModelConfig extends ModelConfig { }
diff --git a/src/FE/types/page.ts b/src/FE/types/page.ts
index b364b598..23e1f324 100644
--- a/src/FE/types/page.ts
+++ b/src/FE/types/page.ts
@@ -6,4 +6,4 @@ export interface PageResult {
export interface Paging {
page: number;
pageSize: number;
-}
\ No newline at end of file
+}
diff --git a/src/FE/types/prompt.ts b/src/FE/types/prompt.ts
index 73457148..33d14303 100644
--- a/src/FE/types/prompt.ts
+++ b/src/FE/types/prompt.ts
@@ -13,4 +13,4 @@ export interface IdName {
export interface PromptSlim extends IdName {
isDefault: boolean;
isSystem: boolean;
-}
\ No newline at end of file
+}
diff --git a/src/FE/utils/chats.ts b/src/FE/utils/chats.ts
index 2c1f6491..2e9b25ee 100644
--- a/src/FE/utils/chats.ts
+++ b/src/FE/utils/chats.ts
@@ -30,4 +30,4 @@ export function preprocessLaTeX(content?: string) {
(_, equation) => `$${equation}$`,
);
return inlineProcessedContent;
-}
\ No newline at end of file
+}
diff --git a/src/FE/utils/common.ts b/src/FE/utils/common.ts
index dd4f34df..dd4e92c0 100644
--- a/src/FE/utils/common.ts
+++ b/src/FE/utils/common.ts
@@ -1,4 +1,4 @@
-import { NextRouter } from "next/router";
+import { NextRouter } from 'next/router';
export const isMobile = () => {
const userAgent =
@@ -23,7 +23,9 @@ export function formatNumberAsMoney(amount: number, maximumFractionDigits = 5) {
}
export function termDateString() {
- return new Date(new Date().getTime() + 10 * 365 * 24 * 60 * 60 * 1000).toISOString(); // 10 years
+ return new Date(
+ new Date().getTime() + 10 * 365 * 24 * 60 * 60 * 1000,
+ ).toISOString(); // 10 years
}
export const PhoneRegExp = /^[1][3,4,5,6,7,8,9][0-9]{9}$/;
@@ -47,4 +49,4 @@ export const getQueryId = (router: NextRouter): string => {
const asPath = router.asPath.split('?')[0]; // 移除查询参数
const pathSegments = asPath.split('/');
return pathSegments[pathSegments.length - 1] || '';
-}
\ No newline at end of file
+};
diff --git a/src/FE/utils/promptVariable.ts b/src/FE/utils/promptVariable.ts
index 307a651a..777abccb 100644
--- a/src/FE/utils/promptVariable.ts
+++ b/src/FE/utils/promptVariable.ts
@@ -1,4 +1,4 @@
-import { AdminModelDto } from "@/types/adminApis";
+import { AdminModelDto } from '@/types/adminApis';
interface PromptParams {
model: AdminModelDto;
@@ -7,7 +7,10 @@ interface PromptParams {
export const PromptVariables = {
'{{CURRENT_DATE}}': () => new Date().toLocaleDateString(),
'{{CURRENT_TIME}}': () => new Date().toLocaleString(),
- '{{MODEL_NAME}}': (params?: PromptParams) => params?.model?.modelReferenceShortName || params?.model?.modelReferenceName || '',
+ '{{MODEL_NAME}}': (params?: PromptParams) =>
+ params?.model?.modelReferenceShortName ||
+ params?.model?.modelReferenceName ||
+ '',
};
export function formatPrompt(prompt: string, params?: PromptParams) {
diff --git a/src/scripts/20240902-db-migration.linq b/src/scripts/db-migration/2024/20240902-db-migration.linq
similarity index 100%
rename from src/scripts/20240902-db-migration.linq
rename to src/scripts/db-migration/2024/20240902-db-migration.linq
diff --git a/src/scripts/20241101-model-reference-sql.linq b/src/scripts/db-migration/2024/20241101-model-reference-sql.linq
similarity index 100%
rename from src/scripts/20241101-model-reference-sql.linq
rename to src/scripts/db-migration/2024/20241101-model-reference-sql.linq
diff --git a/src/scripts/20241112-db-migration.linq b/src/scripts/db-migration/2024/20241112-db-migration.linq
similarity index 100%
rename from src/scripts/20241112-db-migration.linq
rename to src/scripts/db-migration/2024/20241112-db-migration.linq
diff --git a/src/scripts/20241115-db-migration.sql b/src/scripts/db-migration/2024/20241115-db-migration.sql
similarity index 100%
rename from src/scripts/20241115-db-migration.sql
rename to src/scripts/db-migration/2024/20241115-db-migration.sql
diff --git a/src/scripts/20241121-int-migration.sql b/src/scripts/db-migration/2024/20241121-int-migration.sql
similarity index 100%
rename from src/scripts/20241121-int-migration.sql
rename to src/scripts/db-migration/2024/20241121-int-migration.sql
diff --git a/src/scripts/20241127-ref.sql b/src/scripts/db-migration/2024/20241127-ref.sql
similarity index 100%
rename from src/scripts/20241127-ref.sql
rename to src/scripts/db-migration/2024/20241127-ref.sql
diff --git a/src/scripts/20241129-file.sql b/src/scripts/db-migration/2024/20241129-file.sql
similarity index 100%
rename from src/scripts/20241129-file.sql
rename to src/scripts/db-migration/2024/20241129-file.sql
diff --git a/src/scripts/db-migration/2024/20241211-xai-githubmodels.sql b/src/scripts/db-migration/2024/20241211-xai-githubmodels.sql
new file mode 100644
index 00000000..77df5dc4
--- /dev/null
+++ b/src/scripts/db-migration/2024/20241211-xai-githubmodels.sql
@@ -0,0 +1,27 @@
+insert into ModelProvider values(11, 'x.ai', NULL, 'xai-yourkey');
+insert into ModelProvider values(12, 'Github Models', NULL, 'ghp_yourkey');
+update ModelProvider set InitialSecret = '' where id = 8;
+
+insert into ModelReference values
+(1100, 11, 'grok-beta', 'grok', 0, 0, 2, 0, 0, 1, 1, 131072, 4096, NULL, 5, 15, 'USD'),
+(1101, 11, 'grok-vision-beta', 'grok', 0, 0, 2, 0, 1, 1, 1, 8192, 4096, NULL, 5, 15, 'USD'),
+(1200, 12, 'AI21-Jamba-1.5-Large', 'AI21-Jamba', 0, 0, 2, 0, 0, 1, 1, 256000, 4000, NULL, 5, 15, 'USD'),
+(1201, 12, 'AI21-Jamba-1.5-Mini', 'AI21-Jamba', 0, 0, 2, 0, 0, 1, 1, 256000, 4000, NULL, 1, 2, 'USD'),
+(1202, 12, 'Cohere-command-r', NULL, 0, 0, 2, 0, 0, 1, 1, 131072, 4096, NULL, 1, 2, 'USD'),
+(1203, 12, 'Cohere-command-r-plus', NULL, 0, 0, 2, 0, 0, 1, 1, 131072, 4096, NULL, 0, 0, 'USD'),
+(1204, 12, 'Llama-3.2-11B-Vision-Instruct', 'LLaMA', 0, 0, 2, 0, 1, 1, 1, 128000, 4000, NULL, 1, 2, 'USD'),
+(1205, 12, 'Llama-3.2-90B-Vision-Instruct', 'LLaMA', 0, 0, 2, 0, 0, 1, 1, 128000, 4000, NULL, 5, 15, 'USD'),
+(1206, 12, 'Meta-Llama-3.1-405B-Instruct', 'LLaMA', 0, 0, 2, 0, 0, 1, 1, 131072, 4096, NULL, 5, 15, 'USD'),
+(1207, 12, 'Meta-Llama-3.1-70B-Instruct', 'LLaMA', 0, 0, 2, 0, 0, 1, 1, 131072, 4096, NULL, 2.5, 5, 'USD'),
+(1208, 12, 'Meta-Llama-3.1-8B-Instruct', 'LLaMA', 0, 0, 2, 0, 0, 1, 1, 131072, 4096, NULL, 1, 2, 'USD'),
+(1209, 12, 'Mistral-large', 'Mistral', 1, 0, 2, 0, 0, 1, 0, 32768, 4096, NULL, 5, 15, 'USD'),
+(1210, 12, 'Mistral-large-2407', 'Mistral', 0, 0, 2, 0, 0, 1, 0, 131072, 4096, NULL, 5, 15, 'USD'),
+(1211, 12, 'Mistral-Nemo', 'Mistral', 0, 0, 2, 0, 0, 1, 0, 131072, 4096, NULL, 1, 2, 'USD'),
+(1212, 12, 'Mistral-small', 'Mistral', 1, 0, 2, 0, 0, 1, 0, 32768, 4096, NULL, 1, 2, 'USD'),
+(1213, 12, 'gpt-4o', NULL, 0, 0, 2, 0, 1, 1, 1, 128000, 4096, 2, 5, 15, 'USD'),
+(1214, 12, 'gpt-4o-mini', NULL, 0, 0, 2, 0, 1, 1, 1, 128000, 4096, 2, 1, 2, 'USD'),
+(1215, 12, 'Phi-3.5-MoE-instruct', 'Phi-3.5', 0, 0, 2, 0, 0, 1, 1, 131072, 4096, NULL, 1, 2, 'USD'),
+(1216, 12, 'Phi-3.5-mini-instruct', 'Phi-3.5', 0, 0, 2, 0, 0, 1, 1, 131072, 4096, NULL, 0.5, 1, 'USD'),
+(1217, 12, 'Phi-3.5-vision-instruct', 'Phi-3.5', 0, 0, 2, 0, 1, 1, 1, 131072, 4096, NULL, 1, 2, 'USD'),
+(1218, 12, 'o1-preview', NULL, 0, 1, 1, 0, 0, 0, 0, 128000, 32768, NULL, 15, 60, 'USD'),
+(1219, 12, 'o1-mini', NULL, 0, 1, 1, 0, 0, 0, 0, 128000, 65536, NULL, 3, 12, 'USD');
diff --git a/src/scripts/readme.md b/src/scripts/readme.md
new file mode 100644
index 00000000..4abbd609
--- /dev/null
+++ b/src/scripts/readme.md
@@ -0,0 +1,2 @@
+# NOTE
+This is a empty project and only put some scripts here for reference.
\ No newline at end of file
diff --git a/src/scripts/scripts.csproj b/src/scripts/scripts.csproj
new file mode 100644
index 00000000..dbdcea46
--- /dev/null
+++ b/src/scripts/scripts.csproj
@@ -0,0 +1,7 @@
+
+
+
+ netstandard2.0
+
+
+
diff --git a/src/scripts/tools/20241210-scaffold-fe.linq b/src/scripts/tools/20241210-scaffold-fe.linq
new file mode 100644
index 00000000..14de83ad
--- /dev/null
+++ b/src/scripts/tools/20241210-scaffold-fe.linq
@@ -0,0 +1,84 @@
+
+ System.Net.Http
+ System.IO.Compression
+ System.Threading.Tasks
+
+
+async Task Main()
+{
+ string wwwroot = Path.Combine(new DirectoryInfo(Path.GetDirectoryName(Util.CurrentQueryPath)!).Parent!.Parent!.ToString(), "BE", "wwwroot");
+ Directory.Delete(wwwroot, recursive: true);
+ string latestfeUrl = "https://github.com/sdcb/chats/releases/latest/download/chats-fe.zip";
+ using HttpClient http = new();
+ ZipArchive zip = new(await http.GetStreamAsync(latestfeUrl), ZipArchiveMode.Read, leaveOpen: false);
+ foreach (ZipArchiveEntry entry in zip.Entries)
+ {
+ entry.Uncapsulate()._storedEntryName = entry.FullName.Replace("chats-fe/", "");
+ ExtractRelativeToDirectory(entry, wwwroot, overwrite: false);
+ }
+ File.WriteAllBytes(Path.Combine(wwwroot, ".gitkeep"), new byte[0]);
+}
+
+internal static void ExtractRelativeToDirectory(ZipArchiveEntry source, string destinationDirectoryName, bool overwrite)
+{
+ ArgumentNullException.ThrowIfNull(source);
+ ArgumentNullException.ThrowIfNull(destinationDirectoryName);
+
+ // Note that this will give us a good DirectoryInfo even if destinationDirectoryName exists:
+ DirectoryInfo di = Directory.CreateDirectory(destinationDirectoryName);
+ string destinationDirectoryFullPath = di.FullName;
+ if (!destinationDirectoryFullPath.EndsWith(Path.DirectorySeparatorChar))
+ {
+ char sep = Path.DirectorySeparatorChar;
+ destinationDirectoryFullPath = string.Concat(destinationDirectoryFullPath, new ReadOnlySpan(in sep));
+ }
+
+ string fileDestinationPath = Path.GetFullPath(Path.Combine(destinationDirectoryFullPath, SanitizeEntryFilePath(source.FullName)));
+
+ if (!fileDestinationPath.StartsWith(destinationDirectoryFullPath, PathInternal.StringComparison))
+ throw new IOException("IO_ExtractingResultsInOutside");
+
+ if (Path.GetFileName(fileDestinationPath).Length == 0)
+ {
+ // If it is a directory:
+
+ if (source.Length != 0)
+ throw new IOException("IO_DirectoryNameWithData");
+
+ Directory.CreateDirectory(fileDestinationPath);
+ }
+ else
+ {
+ // If it is a file:
+ // Create containing directory:
+ Directory.CreateDirectory(Path.GetDirectoryName(fileDestinationPath)!);
+ source.ExtractToFile(fileDestinationPath, overwrite: overwrite);
+ }
+
+
+ static string SanitizeEntryFilePath(string entryPath, bool preserveDriveRoot = false) => entryPath.Replace('\0', '_');
+}
+
+/// Contains internal path helpers that are shared between many projects.
+internal static partial class PathInternal
+{
+ /// Returns a comparison that can be used to compare file and directory names for equality.
+ internal static StringComparison StringComparison
+ {
+ get
+ {
+ return IsCaseSensitive ?
+ StringComparison.Ordinal :
+ StringComparison.OrdinalIgnoreCase;
+ }
+ }
+
+ /// Gets whether the system is case-sensitive.
+ internal static bool IsCaseSensitive
+ {
+ get
+ {
+ return !(OperatingSystem.IsWindows() || OperatingSystem.IsMacOS() || OperatingSystem.IsIOS() || OperatingSystem.IsTvOS() || OperatingSystem.IsWatchOS());
+ }
+ }
+}
\ No newline at end of file
|