mirror of
https://github.com/CodePhiliaX/Chat2DB.git
synced 2025-08-02 21:50:43 +08:00
feat: invite QrCode
This commit is contained in:
@ -167,12 +167,13 @@ function Console(props: IProps) {
|
||||
}, [props.tables]);
|
||||
|
||||
const handleApiKeyEmptyOrGetQrCode = async (shouldPoll?: boolean) => {
|
||||
const { wechatQrCodeUrl, token } = await aiServer.getLoginQrCode({});
|
||||
const { wechatQrCodeUrl, token, tip } = await aiServer.getLoginQrCode({});
|
||||
// console.log('weiChatConfig', wechatQrCodeUrl, token);
|
||||
setPopularizeModal(true);
|
||||
setModalProps({
|
||||
imageUrl: wechatQrCodeUrl,
|
||||
token,
|
||||
tip,
|
||||
});
|
||||
if (shouldPoll) {
|
||||
let pollCnt = 0;
|
||||
@ -184,7 +185,7 @@ function Console(props: IProps) {
|
||||
}
|
||||
if (apiKey) {
|
||||
setPopularizeModal(false);
|
||||
dispatch({
|
||||
await dispatch({
|
||||
type: 'ai/setKeyAndAiType',
|
||||
payload: {
|
||||
key: apiKey,
|
||||
@ -197,15 +198,17 @@ function Console(props: IProps) {
|
||||
};
|
||||
|
||||
const handleAiChat = async (content: string, promptType: IPromptType) => {
|
||||
if (!aiModel.keyAndAiType.key) {
|
||||
const { key } = aiModel?.keyAndAiType;
|
||||
if (!key) {
|
||||
handleApiKeyEmptyOrGetQrCode(true);
|
||||
return;
|
||||
}
|
||||
|
||||
console.log('aiModel?.remainingUse?.key', key);
|
||||
await dispatch({
|
||||
type: 'ai/fetchRemainingUse',
|
||||
payload: {
|
||||
key: aiModel?.remainingUse?.key,
|
||||
key,
|
||||
},
|
||||
});
|
||||
|
||||
@ -341,6 +344,20 @@ function Console(props: IProps) {
|
||||
[],
|
||||
);
|
||||
|
||||
const handleClickRemainBtn = async () => {
|
||||
if (!aiModel.keyAndAiType.key) {
|
||||
handleApiKeyEmptyOrGetQrCode(true);
|
||||
return;
|
||||
}
|
||||
|
||||
const { tip, wechatQrCodeUrl } = await aiServer.getInviteQrCode({});
|
||||
setModalProps({
|
||||
imageUrl: wechatQrCodeUrl,
|
||||
tip,
|
||||
});
|
||||
setPopularizeModal(true);
|
||||
};
|
||||
|
||||
return (
|
||||
<div className={styles.console}>
|
||||
<Spin spinning={isLoading} style={{ height: '100%' }}>
|
||||
@ -359,15 +376,7 @@ function Console(props: IProps) {
|
||||
}
|
||||
setSelectedTables(tables);
|
||||
}}
|
||||
onClickRemainBtn={async () => {
|
||||
const { tip, wechatQrCodeUrl } = await aiServer.getInviteQrCode({});
|
||||
|
||||
setModalProps({
|
||||
imageUrl: wechatQrCodeUrl,
|
||||
tip,
|
||||
});
|
||||
setPopularizeModal(true);
|
||||
}}
|
||||
onClickRemainBtn={handleClickRemainBtn}
|
||||
/>
|
||||
)}
|
||||
{/* <div key={uuid()}>{chatContent.current}</div> */}
|
||||
|
@ -17,13 +17,13 @@ export default memo<IProps>(function Popularize(props) {
|
||||
if (props.tip) {
|
||||
return <p>{props.tip}</p>;
|
||||
}
|
||||
let dom = '';
|
||||
let dom;
|
||||
if (props.source === 'setting') {
|
||||
dom += <p>{i18n('common.text.wechatPopularizeAi2')}</p>;
|
||||
dom = <p>{i18n('common.text.wechatPopularizeAi2')}</p>;
|
||||
} else {
|
||||
dom += <p>{i18n('common.text.wechatPopularizeAi')}</p>;
|
||||
dom = <p>{i18n('common.text.wechatPopularizeAi')}</p>;
|
||||
}
|
||||
dom += <p>{i18n('common.text.wechatPopularize')}</p>;
|
||||
// dom += <p>{i18n('common.text.wechatPopularize')}</p>;
|
||||
return dom;
|
||||
};
|
||||
return (
|
||||
|
@ -17,6 +17,7 @@ export interface ILoginAndQrCode {
|
||||
token: string;
|
||||
wechatQrCodeUrl: string;
|
||||
apiKey: string;
|
||||
tip: string;
|
||||
}
|
||||
|
||||
export interface IInviteQrCode {
|
||||
|
Reference in New Issue
Block a user