Commit e845bb19 authored by Ylg's avatar Ylg

Put the modal component on the chat page

parent 1020b88c
......@@ -62,10 +62,6 @@
}
}
:global(.ant-checkbox-inner) {
background-color: #009b95;
}
.modal_button {
width: 100%;
height: 44px;
......
......@@ -36,6 +36,8 @@ const LoginModal = (props: ILoginModalProps) => {
password,
});
localStorage.setItem('user', JSON.stringify(result || {}));
console.log('result', result);
setLoading(false);
} catch(error) {
......@@ -60,6 +62,7 @@ const LoginModal = (props: ILoginModalProps) => {
height: '496px',
}}
centered
maskClosable={true}
>
<div className={styles.modal_login}>
<div className={styles.modal_title}>
......
/* eslint-disable @typescript-eslint/no-unused-expressions */
import { Layout, Form, Button } from 'antd';
import React, { useState } from 'react';
import { Layout, Form, Button, message } from 'antd';
import React, { useEffect, useState } from 'react';
import styles from './index.less';
import ChatFirstContent from './components/content';
import ChatHeader from './components/header';
......@@ -13,6 +13,7 @@ import {
WechatOutlined,
} from '@ant-design/icons';
import classNames from 'classnames';
import LoginModal from "@/components/loginModal";
const { Sider } = Layout;
const { Item } = Form;
......@@ -25,22 +26,37 @@ const Chat: React.FC = () => {
const [form] = Form.useForm();
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) => {
console.log(value);
form.setFieldValue('chatInput', '');
setFirstChat(true);
};
const onChange = (value: any) => {
value?.chatInput && SetChat(value?.chatInput);
value?.firstInput && setInput(value);
};
const setInput = (value: any) => {
form.setFieldValue('chatInput', value?.firstInput);
setFirstChat(true);
};
const onChange = (value: any) => {
value?.chatInput && SetChat(value?.chatInput);
value?.firstInput && setInput(value);
};
const siderTabsList = [
{
icons: <DeleteOutlined />,
......@@ -70,6 +86,10 @@ const Chat: React.FC = () => {
return (
<Layout>
<LoginModal
open={open}
setOpen={setOpen}
/>
<Sider className={styles.sider}>
<div className={styles.siderChatContent}>
<Button size="large" block type="primary" icon={<PlusOutlined />}>
......@@ -132,3 +152,7 @@ const Chat: React.FC = () => {
};
export default Chat;
function async() {
throw new Error('Function not implemented.');
}
import LoginModal from "@/components/loginModal";
import { Button } from "antd";
import { useState } from "react";
const PromptWord = () => {
const [open, setOpen] = useState(false);
return (
<>
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;
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', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'__tenant': '3a0a90fe-9a0d-70f4-200d-a80a41fb6195'
},
data: options
})
}
\ No newline at end of file
}
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