@gientech/modual 1.3.0 → 1.3.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +129 -129
- package/{dist/assets/mysql.svg → assets/MySQL.svg} +14 -14
- package/{dist/assets → assets}/database.svg +11 -11
- package/{src/modules/database/assets → assets}/database_add.svg +53 -53
- package/{dist/assets → assets}/database_connect.svg +66 -66
- package/{dist/assets → assets}/database_upload.svg +29 -29
- package/{dist/assets → assets}/defaultWeLogo.svg +14 -14
- package/{dist/assets/index-DIm7RgkM.js → assets/index-D-dGaGjW.js} +93 -279
- package/assets/index-ldqIbm0x.js +1289 -0
- package/assets/style.css +1 -0
- package/assets/style3.css +1 -0
- package/{dist/chat.js → chat.js} +78 -78
- package/database.js +20 -0
- package/{dist/databaseId.js → databaseId.js} +1 -1
- package/{dist/databaseTable.js → databaseTable.js} +1 -1
- package/{dist/modelManage.js → modelManage.js} +1 -1
- package/package.json +39 -83
- package/{dist/sensitive.js → sensitive.js} +1 -1
- package/{dist/streamFilesReader.js → streamFilesReader.js} +11 -11
- package/{dist/worker → worker}/pdf.worker.min.js +21 -21
- package/.editorconfig +0 -38
- package/.prettierignore +0 -16
- package/.prettierrc +0 -17
- package/USAGE.md +0 -191
- package/bash.exe.stackdump +0 -40
- package/components.json +0 -21
- package/dist/README.md +0 -129
- package/dist/assets/database_add.svg +0 -53
- package/dist/assets/index-Bpnc4tRH.js +0 -1284
- package/dist/assets/style.css +0 -1
- package/dist/assets/style3.css +0 -1
- package/dist/database.js +0 -20
- package/dist/package.json +0 -56
- package/doc_assets/2.png +0 -0
- package/doc_assets/demo.md +0 -27
- package/doc_assets/demos/dist-app/assets/index.Dh-ZAS9Z.css +0 -2
- package/doc_assets/demos/dist-app/assets/index.Dv8KVW18.js +0 -23699
- package/doc_assets/demos/dist-app/assets/index.Dv8KVW18.js.map +0 -1
- package/doc_assets/demos/dist-app/index.html +0 -14
- package/doc_assets/demos/dist-app/vite.svg +0 -1
- package/doc_assets/images/1.png +0 -0
- package/doc_assets/images/3.png +0 -0
- package/doc_assets/images/component-screenshot.png +0 -1
- package/doc_assets/install.md +0 -5
- package/eslint.config.js +0 -92
- package/index.html +0 -13
- package/postcss.config.cjs +0 -19
- package/public/vite.svg +0 -1
- package/public/worker/pdf.worker.min.js +0 -22
- package/scripts/README.md +0 -133
- package/scripts/build-demo.js +0 -88
- package/scripts/demo-selector.js +0 -216
- package/scripts/dev-demo.js +0 -76
- package/scripts/preview-demo.js +0 -130
- package/scripts/run-demo.bat +0 -34
- package/src/assets/img/downArrow.png +0 -0
- package/src/assets/img/excel.png +0 -0
- package/src/assets/img/img.png +0 -0
- package/src/assets/img/pdf.png +0 -0
- package/src/assets/img/ppt.png +0 -0
- package/src/assets/img/txt.png +0 -0
- package/src/assets/img/word.png +0 -0
- package/src/assets/login/homeBg.png +0 -0
- package/src/assets/login/left.jpg +0 -0
- package/src/assets/login/logoImg.png +0 -0
- package/src/examples/LoginPage/index.tsx +0 -18
- package/src/examples/chat/components/DrawerGraphPreview.tsx +0 -77
- package/src/examples/chat/index.tsx +0 -179
- package/src/examples/gientechStreamFilesReader/index.tsx +0 -1016
- package/src/examples/ragDatabaseDataPage/index.tsx +0 -36
- package/src/examples/ragDatabaseIdPage/index.tsx +0 -44
- package/src/examples/ragDatabasePage/index.tsx +0 -36
- package/src/examples/ragModelManagePage/index.tsx +0 -37
- package/src/examples/ragSearchPage/index.tsx +0 -0
- package/src/examples/ragSensitiveWordsPage/index.tsx +0 -32
- package/src/examples/streamFiles/index.tsx +0 -384
- package/src/lib_enter.ts +0 -38
- package/src/main.tsx +0 -5
- package/src/main.tsx.backup +0 -5
- package/src/modules/chat/Conversations/Item.tsx +0 -167
- package/src/modules/chat/Conversations/List.tsx +0 -143
- package/src/modules/chat/Conversations/groupByTime.ts +0 -39
- package/src/modules/chat/Conversations/index.tsx +0 -212
- package/src/modules/chat/constants.tsx +0 -33
- package/src/modules/chat/index.tsx +0 -1836
- package/src/modules/chat/types.ts +0 -17
- package/src/modules/database/CreateModal.tsx +0 -398
- package/src/modules/database/assets/Doris.png +0 -0
- package/src/modules/database/assets/PostgreSQL.png +0 -0
- package/src/modules/database/assets/SQLServer.png +0 -0
- package/src/modules/database/assets/database.svg +0 -11
- package/src/modules/database/assets/database_connect.svg +0 -66
- package/src/modules/database/assets/database_upload.svg +0 -29
- package/src/modules/database/assets/empty.png +0 -0
- package/src/modules/database/assets/mysql.svg +0 -14
- package/src/modules/database/index.tsx +0 -466
- package/src/modules/database/server.ts +0 -196
- package/src/modules/databaseId/CustomCom.tsx +0 -156
- package/src/modules/databaseId/EditConfig.tsx +0 -268
- package/src/modules/databaseId/UploadDrawer.tsx +0 -520
- package/src/modules/databaseId/assets/aiOptimize.svg +0 -10
- package/src/modules/databaseId/assets/empty.png +0 -0
- package/src/modules/databaseId/assets/template.svg +0 -6
- package/src/modules/databaseId/assets/upload.svg +0 -9
- package/src/modules/databaseId/assets/useTemp.svg +0 -6
- package/src/modules/databaseId/index.tsx +0 -734
- package/src/modules/databaseId/server.ts +0 -286
- package/src/modules/databaseId/style.css +0 -5
- package/src/modules/databaseTable/EditRowDrawer.tsx +0 -119
- package/src/modules/databaseTable/index.tsx +0 -357
- package/src/modules/databaseTable/server.ts +0 -180
- package/src/modules/headlessChat/constants.tsx +0 -32
- package/src/modules/headlessChat/index.tsx +0 -1065
- package/src/modules/headlessChat/types.ts +0 -23
- package/src/modules/login/components/Login/LoginBox/index.tsx +0 -102
- package/src/modules/login/components/Login/RegisterBox/index.tsx +0 -180
- package/src/modules/login/components/Login/index.tsx +0 -100
- package/src/modules/login/index.tsx +0 -106
- package/src/modules/login/style.css +0 -3
- package/src/modules/login/useServices.ts +0 -53
- package/src/modules/login/utils.ts +0 -42
- package/src/modules/modelManage/ConfigDrawer.tsx +0 -249
- package/src/modules/modelManage/assets/empty.png +0 -0
- package/src/modules/modelManage/const.ts +0 -50
- package/src/modules/modelManage/index.tsx +0 -439
- package/src/modules/modelManage/server.ts +0 -185
- package/src/modules/nodegraph/index.tsx +0 -1
- package/src/modules/search/assets/Icon-history.svg +0 -8
- package/src/modules/search/assets/answerAwartar.png +0 -0
- package/src/modules/search/assets/doc.png +0 -0
- package/src/modules/search/assets/genera.gif +0 -0
- package/src/modules/search/assets/icon-robot.svg +0 -9
- package/src/modules/search/assets/icon-search-bar.svg +0 -14
- package/src/modules/search/assets/icon-sub-title.svg +0 -3
- package/src/modules/search/assets/icon-title.svg +0 -9
- package/src/modules/search/assets/icon-zoomOut.svg +0 -9
- package/src/modules/search/assets/iconAi.svg +0 -9
- package/src/modules/search/assets/pdf.png +0 -0
- package/src/modules/search/assets/ppt.png +0 -0
- package/src/modules/search/assets/search.svg +0 -3
- package/src/modules/search/assets/selected.svg +0 -4
- package/src/modules/search/assets/txt.png +0 -0
- package/src/modules/search/assets/xls.png +0 -0
- package/src/modules/search/components/AssisSelect.tsx +0 -137
- package/src/modules/search/components/Editor/ChatViewEditor.tsx +0 -261
- package/src/modules/search/components/Editor/aichat.css +0 -1
- package/src/modules/search/components/Editor/constant.ts +0 -13
- package/src/modules/search/components/Editor/index.tsx +0 -113
- package/src/modules/search/components/Editor/plugins/autofomatRules.ts +0 -332
- package/src/modules/search/components/Editor/plugins/convertImgPlugins.tsx +0 -20
- package/src/modules/search/components/Editor/plugins/createIndexes.tsx +0 -38
- package/src/modules/search/components/Editor/plugins/displayer.ts +0 -298
- package/src/modules/search/components/Editor/plugins/imageClick.tsx +0 -32
- package/src/modules/search/components/Editor/plugins/myplugin.tsx +0 -98
- package/src/modules/search/components/Editor/ui/avatar.tsx +0 -19
- package/src/modules/search/components/Editor/ui/blockquote-element.tsx +0 -21
- package/src/modules/search/components/Editor/ui/button.tsx +0 -58
- package/src/modules/search/components/Editor/ui/calendar.tsx +0 -68
- package/src/modules/search/components/Editor/ui/caption.tsx +0 -46
- package/src/modules/search/components/Editor/ui/checkbox.tsx +0 -27
- package/src/modules/search/components/Editor/ui/code-block-combobox.tsx +0 -188
- package/src/modules/search/components/Editor/ui/code-block-element.css +0 -434
- package/src/modules/search/components/Editor/ui/code-block-element.tsx +0 -39
- package/src/modules/search/components/Editor/ui/code-leaf.tsx +0 -24
- package/src/modules/search/components/Editor/ui/code-line-element.tsx +0 -10
- package/src/modules/search/components/Editor/ui/code-syntax-leaf.tsx +0 -21
- package/src/modules/search/components/Editor/ui/column-element.tsx +0 -30
- package/src/modules/search/components/Editor/ui/column-group-element.tsx +0 -94
- package/src/modules/search/components/Editor/ui/command.tsx +0 -75
- package/src/modules/search/components/Editor/ui/comment-avatar.tsx +0 -22
- package/src/modules/search/components/Editor/ui/comment-create-form.tsx +0 -37
- package/src/modules/search/components/Editor/ui/comment-item.tsx +0 -74
- package/src/modules/search/components/Editor/ui/comment-leaf.tsx +0 -49
- package/src/modules/search/components/Editor/ui/comment-more-dropdown.tsx +0 -42
- package/src/modules/search/components/Editor/ui/comment-reply-items.tsx +0 -22
- package/src/modules/search/components/Editor/ui/comment-resolve-button.tsx +0 -32
- package/src/modules/search/components/Editor/ui/comment-value.tsx +0 -34
- package/src/modules/search/components/Editor/ui/comments-popover.tsx +0 -63
- package/src/modules/search/components/Editor/ui/date-element.tsx +0 -83
- package/src/modules/search/components/Editor/ui/dialog.tsx +0 -63
- package/src/modules/search/components/Editor/ui/draggable.tsx +0 -177
- package/src/modules/search/components/Editor/ui/dropdown-menu.tsx +0 -180
- package/src/modules/search/components/Editor/ui/emoji-input-element.tsx +0 -85
- package/src/modules/search/components/Editor/ui/excalidraw-element.tsx +0 -28
- package/src/modules/search/components/Editor/ui/fixed-toolbar-buttons.tsx +0 -76
- package/src/modules/search/components/Editor/ui/fixed-toolbar.tsx +0 -8
- package/src/modules/search/components/Editor/ui/floating-toolbar-buttons.tsx +0 -51
- package/src/modules/search/components/Editor/ui/floating-toolbar.tsx +0 -77
- package/src/modules/search/components/Editor/ui/heading-element.tsx +0 -48
- package/src/modules/search/components/Editor/ui/highlight-leaf.tsx +0 -17
- package/src/modules/search/components/Editor/ui/hr-element.tsx +0 -30
- package/src/modules/search/components/Editor/ui/icons.tsx +0 -267
- package/src/modules/search/components/Editor/ui/image-element.tsx +0 -74
- package/src/modules/search/components/Editor/ui/inline-combobox.tsx +0 -368
- package/src/modules/search/components/Editor/ui/input.tsx +0 -25
- package/src/modules/search/components/Editor/ui/insert-dropdown-menu.tsx +0 -218
- package/src/modules/search/components/Editor/ui/kbd-leaf.tsx +0 -20
- package/src/modules/search/components/Editor/ui/link-element.tsx +0 -29
- package/src/modules/search/components/Editor/ui/link-floating-toolbar.tsx +0 -161
- package/src/modules/search/components/Editor/ui/list-element.tsx +0 -30
- package/src/modules/search/components/Editor/ui/mark-toolbar-button.tsx +0 -24
- package/src/modules/search/components/Editor/ui/media-embed-element.tsx +0 -133
- package/src/modules/search/components/Editor/ui/media-popover.tsx +0 -97
- package/src/modules/search/components/Editor/ui/mention-element.tsx +0 -43
- package/src/modules/search/components/Editor/ui/mention-input-element.tsx +0 -141
- package/src/modules/search/components/Editor/ui/mode-dropdown-menu.tsx +0 -93
- package/src/modules/search/components/Editor/ui/more-dropdown-menu.tsx +0 -67
- package/src/modules/search/components/Editor/ui/paragraph-element.tsx +0 -4
- package/src/modules/search/components/Editor/ui/placeholder.tsx +0 -52
- package/src/modules/search/components/Editor/ui/popover.tsx +0 -32
- package/src/modules/search/components/Editor/ui/resizable.tsx +0 -66
- package/src/modules/search/components/Editor/ui/separator.tsx +0 -25
- package/src/modules/search/components/Editor/ui/style.less +0 -12
- package/src/modules/search/components/Editor/ui/table-cell-element.tsx +0 -143
- package/src/modules/search/components/Editor/ui/table-element.tsx +0 -243
- package/src/modules/search/components/Editor/ui/table-row-element.tsx +0 -22
- package/src/modules/search/components/Editor/ui/tableValue.tsx +0 -135
- package/src/modules/search/components/Editor/ui/todo-list-element.tsx +0 -43
- package/src/modules/search/components/Editor/ui/toggle-element.tsx +0 -31
- package/src/modules/search/components/Editor/ui/toolbar.tsx +0 -157
- package/src/modules/search/components/Editor/ui/tooltip.tsx +0 -65
- package/src/modules/search/components/Editor/ui/turn-into-dropdown-menu.tsx +0 -160
- package/src/modules/search/components/Editor/ui/with-draggables.tsx +0 -175
- package/src/modules/search/components/FileList.tsx +0 -287
- package/src/modules/search/components/ImageGroupView/index.tsx +0 -85
- package/src/modules/search/components/ResultContent.tsx +0 -232
- package/src/modules/search/components/SearchInput.tsx +0 -232
- package/src/modules/search/components/SearchLanding.tsx +0 -74
- package/src/modules/search/components/SearchView.tsx +0 -563
- package/src/modules/search/components/SimpleEditor.tsx +0 -158
- package/src/modules/search/components/SimpleFileList.tsx +0 -215
- package/src/modules/search/index.tsx +0 -10
- package/src/modules/search/reademe.md +0 -1
- package/src/modules/search/servers/apis.tsx +0 -19
- package/src/modules/search/servers/index.ts +0 -184
- package/src/modules/search/style.less +0 -503
- package/src/modules/search/type.ts +0 -22
- package/src/modules/search/utils.ts +0 -34
- package/src/modules/sensitive/index.tsx +0 -313
- package/src/modules/sensitive/server.ts +0 -122
- package/src/modules/streamFilesReader/GientechStreamReader.tsx +0 -1555
- package/src/modules/streamFilesReader/components/Header/Toolbar.tsx +0 -0
- package/src/modules/streamFilesReader/components/Header/index.tsx +0 -297
- package/src/modules/streamFilesReader/index.tsx +0 -3
- package/src/style.css +0 -6
- package/src/type.d.ts +0 -0
- package/src/utils/commonFn.tsx +0 -111
- package/src/utils/gientechCommon/components/AppError.tsx +0 -32
- package/src/utils/gientechCommon/components/AppLoading.tsx +0 -75
- package/src/utils/gientechCommon/components/DeleteModal.tsx +0 -75
- package/src/utils/gientechCommon/components/DisplayError.tsx +0 -33
- package/src/utils/gientechCommon/components/DisplayLoading.tsx +0 -38
- package/src/utils/gientechCommon/components/FeedBackModal.tsx +0 -310
- package/src/utils/gientechCommon/components/FileCardCommon.tsx +0 -82
- package/src/utils/gientechCommon/components/FileManager/index.tsx +0 -390
- package/src/utils/gientechCommon/components/FileManager/style.css +0 -5
- package/src/utils/gientechCommon/components/Messages/GientechNewChatWelcome.tsx +0 -296
- package/src/utils/gientechCommon/components/Messages/ReferenceCard.tsx +0 -339
- package/src/utils/gientechCommon/components/Messages/RetriveItem.tsx +0 -245
- package/src/utils/gientechCommon/components/Messages/WebRetriveItem.tsx +0 -209
- package/src/utils/gientechCommon/components/Messages/defaultBot.png +0 -0
- package/src/utils/gientechCommon/components/Messages/defaultStyleSet.tsx +0 -148
- package/src/utils/gientechCommon/components/Messages/defaultWeLogo.svg +0 -14
- package/src/utils/gientechCommon/components/RenameModal.tsx +0 -86
- package/src/utils/gientechCommon/components/style.less +0 -11
- package/src/utils/gientechCommon/configs/commonConfig.ts +0 -2
- package/src/utils/gientechCommon/configs/senderConfig.ts +0 -0
- package/src/utils/gientechCommon/configs/stylesConfig.ts +0 -142
- package/src/utils/gientechCommon/hooks/AichatUseController.tsx +0 -339
- package/src/utils/gientechCommon/slate/converters/deserializers.ts +0 -763
- package/src/utils/gientechCommon/slate/converters/mockData.ts +0 -232
- package/src/utils/gientechCommon/slate/converters/slateConverters.ts +0 -258
- package/src/utils/gientechCommon/slate/richElements/index.tsx +0 -499
- package/src/utils/gientechCommon/utils/request.ts +0 -37
- package/src/utils/gientechCommon/utils/serverFn.ts +0 -172
- package/src/utils/index.tsx +0 -126
- package/src/utils/testconfigs/demologin/index.tsx +0 -32
- package/src/utils/testconfigs/index.ts +0 -53
- package/src/vite-env.d.ts +0 -11
- package/stats.html +0 -4949
- package/tailwind.config.js +0 -170
- package/tsconfig.app.json +0 -30
- package/tsconfig.app.tsbuildinfo +0 -11
- package/tsconfig.json +0 -13
- package/tsconfig.node.json +0 -22
- package/tsconfig.node.tsbuildinfo +0 -1
- package/vite.config.ts +0 -177
- package/workflows/release.yml +0 -60
- /package/{dist/assets → assets}/Doris.png +0 -0
- /package/{dist/assets → assets}/PostgreSQL.png +0 -0
- /package/{dist/assets → assets}/SQLServer.png +0 -0
- /package/{dist/assets → assets}/_commonjsHelpers-gnU0ypJ3.js +0 -0
- /package/{dist/assets → assets}/circle-alert-g2Y6zAjt.js +0 -0
- /package/{dist/assets → assets}/empty.png +0 -0
- /package/{dist/assets → assets}/index-CEK88UzR.js +0 -0
- /package/{dist/assets → assets}/index-CpW6Dhpp.js +0 -0
- /package/{dist/assets → assets}/plus-omCUN0e3.js +0 -0
- /package/{dist/assets → assets}/style2.css +0 -0
- /package/{dist/assets → assets}/styled-components.browser.esm-DPkS13KC.js +0 -0
- /package/{dist/assets → assets}/x-vPcWt3fC.js +0 -0
- /package/{dist/chat.d.ts → chat.d.ts} +0 -0
- /package/{dist/database.d.ts → database.d.ts} +0 -0
- /package/{dist/databaseId.d.ts → databaseId.d.ts} +0 -0
- /package/{dist/databaseTable.d.ts → databaseTable.d.ts} +0 -0
- /package/{dist/modelManage.d.ts → modelManage.d.ts} +0 -0
- /package/{dist/sensitive.d.ts → sensitive.d.ts} +0 -0
- /package/{dist/streamFilesReader.d.ts → streamFilesReader.d.ts} +0 -0
- /package/{dist/vite.svg → vite.svg} +0 -0
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
export interface UploadedFile {
|
|
2
|
-
name: string;
|
|
3
|
-
size: number;
|
|
4
|
-
type: string;
|
|
5
|
-
filePath: string;
|
|
6
|
-
convertedFilePath?: string;
|
|
7
|
-
uid: string;
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
export interface EmptyMessageData {
|
|
11
|
-
content: string;
|
|
12
|
-
filePaths?: string;
|
|
13
|
-
queryId: string;
|
|
14
|
-
currentFiles?: UploadedFile[];
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
export interface GientechChatAdopterProps {
|
|
18
|
-
token: string;
|
|
19
|
-
url?: string;
|
|
20
|
-
styles?: any;
|
|
21
|
-
eventsEmit?: (eventName: string, data: any) => void;
|
|
22
|
-
[key: string]: any;
|
|
23
|
-
}
|
|
@@ -1,102 +0,0 @@
|
|
|
1
|
-
import { Loader2, ShoppingCart, User } from 'lucide-react';
|
|
2
|
-
import { Button, Flex, Form, FormInstance, Input, Typography } from 'antd';
|
|
3
|
-
import React, { useState } from 'react';
|
|
4
|
-
export enum LoginFormActionEnum {
|
|
5
|
-
CANCEL = 'cancel',
|
|
6
|
-
SUBMIT = 'submit',
|
|
7
|
-
REFRESH = 'refresh',
|
|
8
|
-
REGISTER = 'register',
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
interface Iprops {
|
|
12
|
-
setIsRegister: React.Dispatch<React.SetStateAction<boolean>>;
|
|
13
|
-
logoImg?: string;
|
|
14
|
-
eventEmit?: (n: string, d: any) => void;
|
|
15
|
-
form: FormInstance<any>;
|
|
16
|
-
codeImgSrc?: string;
|
|
17
|
-
loginLoading?: boolean;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
const LoginBox: React.FC<Iprops> = props => {
|
|
21
|
-
const { logoImg, setIsRegister, eventEmit, form, codeImgSrc, loginLoading = false } = props;
|
|
22
|
-
const [codeLoading, setCodeLoading] = useState<boolean>(false);
|
|
23
|
-
const handleLogin = () => {
|
|
24
|
-
form.validateFields().then(async res => {
|
|
25
|
-
eventEmit && (await eventEmit('login:login', res));
|
|
26
|
-
});
|
|
27
|
-
};
|
|
28
|
-
|
|
29
|
-
const handleClickCode = async () => {
|
|
30
|
-
setCodeLoading(true);
|
|
31
|
-
eventEmit && (await eventEmit('login:codeClick', ''));
|
|
32
|
-
setCodeLoading(false);
|
|
33
|
-
};
|
|
34
|
-
return (
|
|
35
|
-
<Flex vertical justify="center">
|
|
36
|
-
<img
|
|
37
|
-
style={{
|
|
38
|
-
display: 'inline-block',
|
|
39
|
-
width: '100%',
|
|
40
|
-
objectFit: 'cover',
|
|
41
|
-
marginTop: '12px',
|
|
42
|
-
marginBottom: '20px',
|
|
43
|
-
textAlign: 'center',
|
|
44
|
-
}}
|
|
45
|
-
src={logoImg}
|
|
46
|
-
/>
|
|
47
|
-
<Form.Item name={'userName'} rules={[{ required: true, message: '请输入用户名字' }]}>
|
|
48
|
-
<Input placeholder="输入用户名字" prefix={<User size={16} />} />
|
|
49
|
-
</Form.Item>
|
|
50
|
-
<Form.Item name={'password'} rules={[{ required: true, message: '请输入密码' }]}>
|
|
51
|
-
<Input placeholder="输入密码" prefix={<ShoppingCart size={16} />} type="password" />
|
|
52
|
-
</Form.Item>
|
|
53
|
-
{codeImgSrc && (
|
|
54
|
-
<Form.Item name={'verifyCode'} rules={[{ required: true, message: '请输入验证码' }]}>
|
|
55
|
-
<Flex>
|
|
56
|
-
<Input placeholder="输入验证码" />
|
|
57
|
-
|
|
58
|
-
{codeLoading ? (
|
|
59
|
-
<Flex style={{ width: '96px', height: '40px' }} justify="center">
|
|
60
|
-
<Loader2 className="animate-spin" size={20} />
|
|
61
|
-
</Flex>
|
|
62
|
-
) : (
|
|
63
|
-
<img
|
|
64
|
-
onClick={handleClickCode}
|
|
65
|
-
src={codeImgSrc}
|
|
66
|
-
style={{
|
|
67
|
-
width: '96px',
|
|
68
|
-
height: '40px',
|
|
69
|
-
background: 'white',
|
|
70
|
-
border: 'solid 1px #d9d9d9',
|
|
71
|
-
cursor: 'pointer',
|
|
72
|
-
borderRadius: '6px',
|
|
73
|
-
}}
|
|
74
|
-
/>
|
|
75
|
-
)}
|
|
76
|
-
</Flex>
|
|
77
|
-
</Form.Item>
|
|
78
|
-
)}
|
|
79
|
-
<Form.Item>
|
|
80
|
-
<Button
|
|
81
|
-
style={{ width: '100%' }}
|
|
82
|
-
type="primary"
|
|
83
|
-
loading={loginLoading}
|
|
84
|
-
onClick={handleLogin}
|
|
85
|
-
>
|
|
86
|
-
登录
|
|
87
|
-
</Button>
|
|
88
|
-
</Form.Item>
|
|
89
|
-
{/* <Text
|
|
90
|
-
style={{
|
|
91
|
-
textAlign: "right",
|
|
92
|
-
cursor: "pointer"
|
|
93
|
-
}}
|
|
94
|
-
onClick={() => setIsRegister(true)}
|
|
95
|
-
>
|
|
96
|
-
点击注册
|
|
97
|
-
</Text> */}
|
|
98
|
-
</Flex>
|
|
99
|
-
);
|
|
100
|
-
};
|
|
101
|
-
|
|
102
|
-
export default LoginBox;
|
|
@@ -1,180 +0,0 @@
|
|
|
1
|
-
import { Button, Flex, Form, FormInstance, Input, Typography } from "antd";
|
|
2
|
-
import { LoadingOutlined } from "@ant-design/icons";
|
|
3
|
-
import React, { useState } from "react";
|
|
4
|
-
|
|
5
|
-
export enum RegisterFormActionEnum {
|
|
6
|
-
CANCEL = "cancel",
|
|
7
|
-
SUBMIT = "submit"
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
//不能用数字开头,长度不超过25,无特殊符号,无空格
|
|
11
|
-
const REG_NAME = /^[\u4e00-\u9fa5A-Za-z_][\u4e00-\u9fa5A-Za-z0-9_]{0,24}$/;
|
|
12
|
-
const REG_NAME_MSG = "不能用数字开头,长度不超过25,无特殊符号,无空格";
|
|
13
|
-
|
|
14
|
-
const REG_PHONE =
|
|
15
|
-
/^(((13[0-9]{1})|(15[0-9]{1})|(18[0-9]{1})|(16[0-9]{1})|(17[0-9]{1})|(19[0-9]{1}))+\d{8})$/;
|
|
16
|
-
const REF_PHONE_MSG = "手机号格式不正确";
|
|
17
|
-
|
|
18
|
-
const REG_EMAIL = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
|
|
19
|
-
const REF_EMAIL_MSG = "邮箱格式不正确";
|
|
20
|
-
|
|
21
|
-
const REG_PASSWORD = /^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)[A-Za-z\d]{8,}$/;
|
|
22
|
-
const REF_PASSWORD_MSG =
|
|
23
|
-
"密码必须包含大小写字母和数字,不包含特殊字符,长度至少是8";
|
|
24
|
-
|
|
25
|
-
interface Iprops {
|
|
26
|
-
eventEmit?: (name: string, data: any) => void;
|
|
27
|
-
setIsRegister: React.Dispatch<React.SetStateAction<boolean>>;
|
|
28
|
-
form: FormInstance<any>;
|
|
29
|
-
registerLoading?: boolean;
|
|
30
|
-
registreKaptchaUrl?: string;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
const RegisterBox: React.FC<Iprops> = (props) => {
|
|
34
|
-
const {
|
|
35
|
-
eventEmit,
|
|
36
|
-
setIsRegister,
|
|
37
|
-
form,
|
|
38
|
-
registreKaptchaUrl,
|
|
39
|
-
registerLoading = false
|
|
40
|
-
} = props;
|
|
41
|
-
|
|
42
|
-
const [codeLoading, setCodeLoading] = useState<boolean>(false);
|
|
43
|
-
|
|
44
|
-
const handleRegister = async () => {
|
|
45
|
-
form.validateFields().then(async (res) => {
|
|
46
|
-
eventEmit && (await eventEmit("login:register", res));
|
|
47
|
-
});
|
|
48
|
-
};
|
|
49
|
-
|
|
50
|
-
const handleClickCode = async () => {
|
|
51
|
-
setCodeLoading(true);
|
|
52
|
-
eventEmit && (await eventEmit("login:registerCodeClick", ""));
|
|
53
|
-
setCodeLoading(false);
|
|
54
|
-
};
|
|
55
|
-
|
|
56
|
-
return (
|
|
57
|
-
<Flex style={{ paddingTop: "35px" }} vertical>
|
|
58
|
-
<Form.Item
|
|
59
|
-
label="用户名"
|
|
60
|
-
name={"userName"}
|
|
61
|
-
rules={[
|
|
62
|
-
{ required: true, message: "请输入名称" },
|
|
63
|
-
{
|
|
64
|
-
pattern: new RegExp(REG_NAME),
|
|
65
|
-
message: `名称${REG_NAME_MSG}`
|
|
66
|
-
}
|
|
67
|
-
]}
|
|
68
|
-
>
|
|
69
|
-
<Input placeholder="输入用户名字" />
|
|
70
|
-
</Form.Item>
|
|
71
|
-
<Form.Item
|
|
72
|
-
label="手机号"
|
|
73
|
-
name={"userIphone"}
|
|
74
|
-
rules={[
|
|
75
|
-
{ required: true, message: "请输入手机号" },
|
|
76
|
-
{
|
|
77
|
-
pattern: new RegExp(REG_PHONE),
|
|
78
|
-
message: `${REF_PHONE_MSG}`
|
|
79
|
-
}
|
|
80
|
-
]}
|
|
81
|
-
>
|
|
82
|
-
<Input placeholder="请输入手机号" />
|
|
83
|
-
</Form.Item>
|
|
84
|
-
<Form.Item
|
|
85
|
-
label="邮箱"
|
|
86
|
-
name={"userEmail"}
|
|
87
|
-
rules={[
|
|
88
|
-
{ required: true, message: "请输入邮箱" },
|
|
89
|
-
{
|
|
90
|
-
pattern: new RegExp(REG_EMAIL),
|
|
91
|
-
message: `${REF_EMAIL_MSG}`
|
|
92
|
-
}
|
|
93
|
-
]}
|
|
94
|
-
>
|
|
95
|
-
<Input placeholder="输入邮箱" />
|
|
96
|
-
</Form.Item>
|
|
97
|
-
<Form.Item
|
|
98
|
-
label="密码"
|
|
99
|
-
name={"password"}
|
|
100
|
-
rules={[
|
|
101
|
-
{ required: true, message: "请输入密码" },
|
|
102
|
-
{
|
|
103
|
-
pattern: new RegExp(REG_PASSWORD),
|
|
104
|
-
message: `${REF_PASSWORD_MSG}`
|
|
105
|
-
}
|
|
106
|
-
]}
|
|
107
|
-
>
|
|
108
|
-
<Input placeholder="请输入密码" type="password" />
|
|
109
|
-
</Form.Item>
|
|
110
|
-
<Form.Item
|
|
111
|
-
label="确认密码"
|
|
112
|
-
name={"passwordAffirm"}
|
|
113
|
-
dependencies={["password"]}
|
|
114
|
-
rules={[
|
|
115
|
-
{
|
|
116
|
-
required: true,
|
|
117
|
-
message: "请确认新密码"
|
|
118
|
-
},
|
|
119
|
-
({ getFieldValue }) => ({
|
|
120
|
-
validator(_, value) {
|
|
121
|
-
if (!value || getFieldValue("password") === value) {
|
|
122
|
-
return Promise.resolve();
|
|
123
|
-
}
|
|
124
|
-
return Promise.reject(new Error("两次密码不一致!"));
|
|
125
|
-
}
|
|
126
|
-
})
|
|
127
|
-
]}
|
|
128
|
-
>
|
|
129
|
-
<Input placeholder="请确认新密码" type="password" />
|
|
130
|
-
</Form.Item>
|
|
131
|
-
{registreKaptchaUrl && (
|
|
132
|
-
<Form.Item
|
|
133
|
-
label="验证码"
|
|
134
|
-
name={"verifyCode"}
|
|
135
|
-
rules={[{ required: true, message: "请输入验证码" }]}
|
|
136
|
-
>
|
|
137
|
-
<Flex>
|
|
138
|
-
<Input placeholder="输入验证码" />
|
|
139
|
-
|
|
140
|
-
{codeLoading ? (
|
|
141
|
-
<Flex style={{ width: "96px", height: "40px" }} justify="center">
|
|
142
|
-
<LoadingOutlined />
|
|
143
|
-
</Flex>
|
|
144
|
-
) : (
|
|
145
|
-
<img
|
|
146
|
-
onClick={handleClickCode}
|
|
147
|
-
src={registreKaptchaUrl}
|
|
148
|
-
style={{
|
|
149
|
-
width: "96px",
|
|
150
|
-
height: "40px",
|
|
151
|
-
background: "white",
|
|
152
|
-
border: "solid 1px #d9d9d9",
|
|
153
|
-
cursor: "pointer",
|
|
154
|
-
borderRadius: "6px"
|
|
155
|
-
}}
|
|
156
|
-
/>
|
|
157
|
-
)}
|
|
158
|
-
</Flex>
|
|
159
|
-
</Form.Item>
|
|
160
|
-
)}
|
|
161
|
-
<Form.Item>
|
|
162
|
-
<Flex justify="space-between">
|
|
163
|
-
<Button style={{ width: "48%" }} onClick={() => setIsRegister(false)}>
|
|
164
|
-
取消
|
|
165
|
-
</Button>
|
|
166
|
-
<Button
|
|
167
|
-
style={{ width: "48%" }}
|
|
168
|
-
onClick={handleRegister}
|
|
169
|
-
type="primary"
|
|
170
|
-
loading={registerLoading}
|
|
171
|
-
>
|
|
172
|
-
注册
|
|
173
|
-
</Button>
|
|
174
|
-
</Flex>
|
|
175
|
-
</Form.Item>
|
|
176
|
-
</Flex>
|
|
177
|
-
);
|
|
178
|
-
};
|
|
179
|
-
|
|
180
|
-
export default RegisterBox;
|
|
@@ -1,100 +0,0 @@
|
|
|
1
|
-
import { ConfigProvider, Flex, Form } from 'antd';
|
|
2
|
-
import { useState } from 'react';
|
|
3
|
-
import LoginBox from './LoginBox';
|
|
4
|
-
|
|
5
|
-
const defaultStyle = {
|
|
6
|
-
colorPrimary: '#1677ff',
|
|
7
|
-
defaultBg: '#ffffff',
|
|
8
|
-
};
|
|
9
|
-
|
|
10
|
-
interface LoginStyle {
|
|
11
|
-
defaultBg?: string;
|
|
12
|
-
colorPrimary?: string;
|
|
13
|
-
}
|
|
14
|
-
interface LoginProps {
|
|
15
|
-
homeBg?: string;
|
|
16
|
-
leftImg?: string;
|
|
17
|
-
logoImg?: string;
|
|
18
|
-
eventEmit?: (n: string, d: any) => void;
|
|
19
|
-
loginLoading?: boolean;
|
|
20
|
-
registerLoading?: boolean;
|
|
21
|
-
codeImgSrc?: string;
|
|
22
|
-
loginStyle?: LoginStyle;
|
|
23
|
-
registreKaptchaUrl?: string;
|
|
24
|
-
}
|
|
25
|
-
const Login = (props: LoginProps) => {
|
|
26
|
-
const {
|
|
27
|
-
homeBg,
|
|
28
|
-
leftImg,
|
|
29
|
-
logoImg,
|
|
30
|
-
eventEmit,
|
|
31
|
-
codeImgSrc = '',
|
|
32
|
-
loginStyle,
|
|
33
|
-
loginLoading,
|
|
34
|
-
registerLoading,
|
|
35
|
-
registreKaptchaUrl,
|
|
36
|
-
} = props;
|
|
37
|
-
const [isRegister, setIsRegister] = useState<boolean>(false);
|
|
38
|
-
const [form] = Form.useForm();
|
|
39
|
-
|
|
40
|
-
return (
|
|
41
|
-
<ConfigProvider
|
|
42
|
-
theme={{
|
|
43
|
-
token: {
|
|
44
|
-
colorPrimary: loginStyle?.colorPrimary || defaultStyle.colorPrimary,
|
|
45
|
-
},
|
|
46
|
-
components: {
|
|
47
|
-
Button: {
|
|
48
|
-
defaultBg: loginStyle?.defaultBg || defaultStyle.defaultBg,
|
|
49
|
-
},
|
|
50
|
-
},
|
|
51
|
-
}}
|
|
52
|
-
>
|
|
53
|
-
<Flex
|
|
54
|
-
style={{
|
|
55
|
-
width: '100%',
|
|
56
|
-
height: '100%',
|
|
57
|
-
background: `url('${homeBg}') no-repeat center/cover`,
|
|
58
|
-
}}
|
|
59
|
-
justify="center"
|
|
60
|
-
align="center"
|
|
61
|
-
>
|
|
62
|
-
<Flex
|
|
63
|
-
style={{
|
|
64
|
-
background: 'white',
|
|
65
|
-
height: '55vh',
|
|
66
|
-
minHeight: '393px',
|
|
67
|
-
width: 'calc(55vh * 2)',
|
|
68
|
-
minWidth: '840px',
|
|
69
|
-
borderRadius: '10px',
|
|
70
|
-
overflow: 'hidden',
|
|
71
|
-
}}
|
|
72
|
-
>
|
|
73
|
-
{leftImg && (
|
|
74
|
-
<img
|
|
75
|
-
style={{
|
|
76
|
-
objectFit: 'cover',
|
|
77
|
-
width: '50%',
|
|
78
|
-
}}
|
|
79
|
-
src={leftImg}
|
|
80
|
-
/>
|
|
81
|
-
)}
|
|
82
|
-
<Flex flex={1} style={{ padding: '0 50px' }} justify="center" align="center">
|
|
83
|
-
<Form form={form} labelCol={{ span: 8 }}>
|
|
84
|
-
<LoginBox
|
|
85
|
-
loginLoading={loginLoading}
|
|
86
|
-
form={form}
|
|
87
|
-
logoImg={logoImg}
|
|
88
|
-
setIsRegister={setIsRegister}
|
|
89
|
-
codeImgSrc={codeImgSrc}
|
|
90
|
-
eventEmit={eventEmit}
|
|
91
|
-
/>
|
|
92
|
-
</Form>
|
|
93
|
-
</Flex>
|
|
94
|
-
</Flex>
|
|
95
|
-
</Flex>
|
|
96
|
-
</ConfigProvider>
|
|
97
|
-
);
|
|
98
|
-
};
|
|
99
|
-
|
|
100
|
-
export default Login;
|
|
@@ -1,106 +0,0 @@
|
|
|
1
|
-
import homeBg from '@/assets/login/homeBg.png';
|
|
2
|
-
import leftImg from '@/assets/login/left.jpg';
|
|
3
|
-
import logoImg from '@/assets/login/logoImg.png';
|
|
4
|
-
import { Layout, message } from 'antd';
|
|
5
|
-
import { Encrypt } from './utils';
|
|
6
|
-
import { useEffect, useState } from 'react';
|
|
7
|
-
import Login from './components/Login';
|
|
8
|
-
import { api_getKaptchaImage, login } from './useServices';
|
|
9
|
-
import './style.css'
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
const baseUrl = '/proxy';
|
|
13
|
-
interface LoginMainProps {
|
|
14
|
-
eventsEmit: (eventName: string, data: any) => void;
|
|
15
|
-
}
|
|
16
|
-
function LoginMain({ eventsEmit }: LoginMainProps) {
|
|
17
|
-
const [loginLoading, setLoginLoading] = useState(false);
|
|
18
|
-
const [registerLoading, setRegisterLoading] = useState(false);
|
|
19
|
-
const handleLogin = async (data: any) => {
|
|
20
|
-
try {
|
|
21
|
-
setLoginLoading(true);
|
|
22
|
-
login(
|
|
23
|
-
{ url: baseUrl },
|
|
24
|
-
{
|
|
25
|
-
...data,
|
|
26
|
-
password: Encrypt(data.password),
|
|
27
|
-
},
|
|
28
|
-
res => {
|
|
29
|
-
if (res?.success) {
|
|
30
|
-
eventsEmit('afterLogin',res?.data?.token || '');
|
|
31
|
-
}
|
|
32
|
-
setLoginLoading(false);
|
|
33
|
-
},
|
|
34
|
-
msg => {
|
|
35
|
-
setLoginLoading(false);
|
|
36
|
-
if (msg) {
|
|
37
|
-
message.error(msg);
|
|
38
|
-
} else {
|
|
39
|
-
message.error('登录失败,请稍后再试');
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
);
|
|
43
|
-
} catch (e) {
|
|
44
|
-
setLoginLoading(false);
|
|
45
|
-
}
|
|
46
|
-
};
|
|
47
|
-
|
|
48
|
-
const [kaptchaUrl, setKaptchaUrl] = useState('');
|
|
49
|
-
const [registreKaptchaUrl, setRegistreKaptchaUrl] = useState('');
|
|
50
|
-
|
|
51
|
-
const handleGetImage = () => {
|
|
52
|
-
try {
|
|
53
|
-
setRegisterLoading(true);
|
|
54
|
-
api_getKaptchaImage({ url: baseUrl }, data => {
|
|
55
|
-
setRegisterLoading(false);
|
|
56
|
-
if (data) {
|
|
57
|
-
const imgBlob = new Blob([data], { type: 'image/jpeg' });
|
|
58
|
-
const imageUrl = window.URL.createObjectURL(imgBlob);
|
|
59
|
-
setKaptchaUrl(imageUrl);
|
|
60
|
-
setRegistreKaptchaUrl(imageUrl);
|
|
61
|
-
}
|
|
62
|
-
});
|
|
63
|
-
} catch (error) {
|
|
64
|
-
setRegisterLoading(false);
|
|
65
|
-
}
|
|
66
|
-
};
|
|
67
|
-
|
|
68
|
-
useEffect(() => {
|
|
69
|
-
handleGetImage();
|
|
70
|
-
return () => {
|
|
71
|
-
window.URL.revokeObjectURL(kaptchaUrl);
|
|
72
|
-
};
|
|
73
|
-
}, []);
|
|
74
|
-
|
|
75
|
-
const eventEmit = async (name: string, data: any) => {
|
|
76
|
-
switch (name) {
|
|
77
|
-
case 'login:login':
|
|
78
|
-
await handleLogin(data);
|
|
79
|
-
break;
|
|
80
|
-
case 'login:codeClick':
|
|
81
|
-
handleGetImage();
|
|
82
|
-
break;
|
|
83
|
-
case 'login:registerCodeClick':
|
|
84
|
-
handleGetImage();
|
|
85
|
-
break;
|
|
86
|
-
default:
|
|
87
|
-
break;
|
|
88
|
-
}
|
|
89
|
-
};
|
|
90
|
-
return (
|
|
91
|
-
<Layout style={{ height: '100vh', overflow: 'hidden' }}>
|
|
92
|
-
<Login
|
|
93
|
-
loginLoading={loginLoading}
|
|
94
|
-
registerLoading={registerLoading}
|
|
95
|
-
homeBg={homeBg}
|
|
96
|
-
leftImg={leftImg}
|
|
97
|
-
logoImg={logoImg}
|
|
98
|
-
codeImgSrc={kaptchaUrl}
|
|
99
|
-
registreKaptchaUrl={registreKaptchaUrl}
|
|
100
|
-
eventEmit={eventEmit}
|
|
101
|
-
/>
|
|
102
|
-
</Layout>
|
|
103
|
-
);
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
export default LoginMain;
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
import axios from 'axios';
|
|
2
|
-
|
|
3
|
-
export const login = async (
|
|
4
|
-
config: { url: string },
|
|
5
|
-
data: { restult: number; queryId: string },
|
|
6
|
-
sucCb: (arg: any) => void,
|
|
7
|
-
failCb: (arg: any) => void = () => {}
|
|
8
|
-
) => {
|
|
9
|
-
try {
|
|
10
|
-
axios
|
|
11
|
-
.post(`${config.url}/auth/user/login`, data)
|
|
12
|
-
.then(res => {
|
|
13
|
-
if (res.data.success) {
|
|
14
|
-
sucCb && sucCb(res.data);
|
|
15
|
-
} else {
|
|
16
|
-
failCb && failCb(false);
|
|
17
|
-
}
|
|
18
|
-
})
|
|
19
|
-
.catch(error => {
|
|
20
|
-
failCb && failCb(error?.response?.data?.errorMsg);
|
|
21
|
-
console.error('Login error:', error);
|
|
22
|
-
});
|
|
23
|
-
} catch (error) {
|
|
24
|
-
failCb && failCb(false);
|
|
25
|
-
console.log('error', error);
|
|
26
|
-
}
|
|
27
|
-
};
|
|
28
|
-
|
|
29
|
-
export const api_getKaptchaImage = (config: { url: string }, cb: (arg: any) => void) => {
|
|
30
|
-
try {
|
|
31
|
-
axios
|
|
32
|
-
.get(`/user/kaptcha`, {
|
|
33
|
-
baseURL: '/proxy/auth',
|
|
34
|
-
responseType: 'arraybuffer', // 关键:必须添加
|
|
35
|
-
//params: { t: Date.now() },
|
|
36
|
-
headers: { Accept: '*/*', 'Content-Type': 'application/json' },
|
|
37
|
-
})
|
|
38
|
-
.then(res => {
|
|
39
|
-
if (res.data) {
|
|
40
|
-
cb && cb(res.data);
|
|
41
|
-
} else {
|
|
42
|
-
cb && cb(false);
|
|
43
|
-
}
|
|
44
|
-
})
|
|
45
|
-
.catch(error => {
|
|
46
|
-
cb && cb(false);
|
|
47
|
-
console.error('Login error:', error);
|
|
48
|
-
});
|
|
49
|
-
} catch (error) {
|
|
50
|
-
cb && cb(false);
|
|
51
|
-
console.log('error', error);
|
|
52
|
-
}
|
|
53
|
-
};
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
import CryptoJS from "crypto-js";
|
|
2
|
-
// 默认的 KEY 与 iv
|
|
3
|
-
const KEY = CryptoJS.enc.Utf8.parse("1234567890123456");
|
|
4
|
-
const IV = CryptoJS.enc.Utf8.parse("1234567890123456");
|
|
5
|
-
|
|
6
|
-
export const Encrypt = (word: any, keyStr?: any, ivStr?: any) => {
|
|
7
|
-
let key = KEY;
|
|
8
|
-
let iv = IV;
|
|
9
|
-
if (keyStr) {
|
|
10
|
-
key = CryptoJS.enc.Utf8.parse(keyStr);
|
|
11
|
-
iv = CryptoJS.enc.Utf8.parse(ivStr);
|
|
12
|
-
}
|
|
13
|
-
const srcs = CryptoJS.enc.Utf8.parse(word);
|
|
14
|
-
const encrypted = CryptoJS.AES.encrypt(srcs, key, {
|
|
15
|
-
iv: iv,
|
|
16
|
-
mode: CryptoJS.mode.CBC,
|
|
17
|
-
padding: CryptoJS.pad.ZeroPadding,
|
|
18
|
-
});
|
|
19
|
-
return CryptoJS.enc.Base64.stringify(encrypted.ciphertext);
|
|
20
|
-
};
|
|
21
|
-
|
|
22
|
-
export const Decrypt = (word: string, keyStr: string, ivStr: string) => {
|
|
23
|
-
let key = KEY;
|
|
24
|
-
let iv = IV;
|
|
25
|
-
|
|
26
|
-
if (keyStr) {
|
|
27
|
-
key = CryptoJS.enc.Utf8.parse(keyStr);
|
|
28
|
-
iv = CryptoJS.enc.Utf8.parse(ivStr);
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
const base64 = CryptoJS.enc.Base64.parse(word);
|
|
32
|
-
const src = CryptoJS.enc.Base64.stringify(base64);
|
|
33
|
-
|
|
34
|
-
const decrypt = CryptoJS.AES.decrypt(src, key, {
|
|
35
|
-
iv: iv,
|
|
36
|
-
mode: CryptoJS.mode.CBC,
|
|
37
|
-
padding: CryptoJS.pad.ZeroPadding,
|
|
38
|
-
});
|
|
39
|
-
|
|
40
|
-
const decryptedStr = decrypt.toString(CryptoJS.enc.Utf8);
|
|
41
|
-
return decryptedStr.toString();
|
|
42
|
-
};
|