Commit e845bb19 authored by Ylg's avatar Ylg

Put the modal component on the chat page

parent 1020b88c
...@@ -62,10 +62,6 @@ ...@@ -62,10 +62,6 @@
} }
} }
:global(.ant-checkbox-inner) {
background-color: #009b95;
}
.modal_button { .modal_button {
width: 100%; width: 100%;
height: 44px; height: 44px;
......
...@@ -36,6 +36,8 @@ const LoginModal = (props: ILoginModalProps) => { ...@@ -36,6 +36,8 @@ const LoginModal = (props: ILoginModalProps) => {
password, password,
}); });
localStorage.setItem('user', JSON.stringify(result || {}));
console.log('result', result); console.log('result', result);
setLoading(false); setLoading(false);
} catch(error) { } catch(error) {
...@@ -60,6 +62,7 @@ const LoginModal = (props: ILoginModalProps) => { ...@@ -60,6 +62,7 @@ const LoginModal = (props: ILoginModalProps) => {
height: '496px', height: '496px',
}} }}
centered centered
maskClosable={true}
> >
<div className={styles.modal_login}> <div className={styles.modal_login}>
<div className={styles.modal_title}> <div className={styles.modal_title}>
......
/* eslint-disable @typescript-eslint/no-unused-expressions */ /* eslint-disable @typescript-eslint/no-unused-expressions */
import { Layout, Form, Button } from 'antd'; import { Layout, Form, Button, message } from 'antd';
import React, { useState } from 'react'; import React, { useEffect, useState } from 'react';
import styles from './index.less'; import styles from './index.less';
import ChatFirstContent from './components/content'; import ChatFirstContent from './components/content';
import ChatHeader from './components/header'; import ChatHeader from './components/header';
...@@ -13,6 +13,7 @@ import { ...@@ -13,6 +13,7 @@ import {
WechatOutlined, WechatOutlined,
} from '@ant-design/icons'; } from '@ant-design/icons';
import classNames from 'classnames'; import classNames from 'classnames';
import LoginModal from "@/components/loginModal";
const { Sider } = Layout; const { Sider } = Layout;
const { Item } = Form; const { Item } = Form;
...@@ -25,22 +26,37 @@ const Chat: React.FC = () => { ...@@ -25,22 +26,37 @@ const Chat: React.FC = () => {
const [form] = Form.useForm(); const [form] = Form.useForm();
const [selectSiderTabs, setSelectSiderTabs] = useState(''); const [selectSiderTabs, setSelectSiderTabs] = useState('');
const [open, setOpen] = useState(false);
useEffect(() => {
let token = '';
if(localStorage.getItem('user')) {
token = JSON.parse(localStorage.user)?.token;
}
if(token) {
setOpen(false);
} else {
setOpen(true);
}
}, []);
const onSend = (value: any) => { const onSend = (value: any) => {
console.log(value); console.log(value);
form.setFieldValue('chatInput', ''); form.setFieldValue('chatInput', '');
setFirstChat(true); setFirstChat(true);
}; };
const onChange = (value: any) => {
value?.chatInput && SetChat(value?.chatInput);
value?.firstInput && setInput(value);
};
const setInput = (value: any) => { const setInput = (value: any) => {
form.setFieldValue('chatInput', value?.firstInput); form.setFieldValue('chatInput', value?.firstInput);
setFirstChat(true); setFirstChat(true);
}; };
const onChange = (value: any) => {
value?.chatInput && SetChat(value?.chatInput);
value?.firstInput && setInput(value);
};
const siderTabsList = [ const siderTabsList = [
{ {
icons: <DeleteOutlined />, icons: <DeleteOutlined />,
...@@ -70,6 +86,10 @@ const Chat: React.FC = () => { ...@@ -70,6 +86,10 @@ const Chat: React.FC = () => {
return ( return (
<Layout> <Layout>
<LoginModal
open={open}
setOpen={setOpen}
/>
<Sider className={styles.sider}> <Sider className={styles.sider}>
<div className={styles.siderChatContent}> <div className={styles.siderChatContent}>
<Button size="large" block type="primary" icon={<PlusOutlined />}> <Button size="large" block type="primary" icon={<PlusOutlined />}>
...@@ -132,3 +152,7 @@ const Chat: React.FC = () => { ...@@ -132,3 +152,7 @@ const Chat: React.FC = () => {
}; };
export default Chat; export default Chat;
function async() {
throw new Error('Function not implemented.');
}
import LoginModal from "@/components/loginModal";
import { Button } from "antd";
import { useState } from "react"; import { useState } from "react";
const PromptWord = () => { const PromptWord = () => {
const [open, setOpen] = useState(false);
return ( return (
<> <>
PromptWord PromptWord
<Button onClick={() => setOpen(true)} />
<LoginModal
open={open}
setOpen={setOpen}
/>
</> </>
) )
......
import { request } from 'umi'; import request from 'umi-request';
interface LoginParams { interface ILoginParams {
name: string; name: string;
password: string; password: string;
} }
export function loginChatGLM(options: LoginParams) { request.interceptors.request.use((url, options) => {
let { token } = JSON.parse(localStorage.getItem('user') || '');
if (null === token) {
token = '';
}
const authHeader = {
Authorization: `Bearer ${token}`,
'Content-Type': 'application/json',
'__tenant': '3a0a90fe-9a0d-70f4-200d-a80a41fb6195' // 用户id
};
return {
url: url,
options: { ...options, interceptors: true, headers: authHeader },
};
});
export function loginChatGLM(options: ILoginParams) {
return request('https://glm-mangement-api.baibaomen.com/api/app/account/login', { return request('https://glm-mangement-api.baibaomen.com/api/app/account/login', {
method: 'POST', method: 'POST',
headers: {
'Content-Type': 'application/json',
'__tenant': '3a0a90fe-9a0d-70f4-200d-a80a41fb6195'
},
data: options data: options
}) })
} }
type History = [string, string];
interface ITalkParams {
prompt: string;
history: History[];
max_length?: number;
top_p?: number;
temperature?: number;
}
// export function talkChatGLM({ prompt, history, max_length = 2000, top_p = 0.9, temperature = 0.8 }: ITalkParams) {
// return request('https://glm-mangement-api.baibaomen.com/', {
// method: 'POST',
// data: {
// prompt,
// history,
// max_length,
// top_p,
// temperature
// }
// })
// }
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment