Commit 43ba1a03 authored by jaden's avatar jaden

fix: fix bug

parent 41a93931
...@@ -7,7 +7,8 @@ ...@@ -7,7 +7,8 @@
## 演示 ## 演示
> [view](https://chat-query.netlify.app/) **由于netlify网络限制问题,请尽量选择一下模式:** > [view](https://chat-query.vercel.app/)
> [国内](http://139.198.179.193:32205/)
+ 选择网站设置 ![Choose website settings](./public/image.png) + 选择网站设置 ![Choose website settings](./public/image.png)
+ 允许不安全内容 ![Allow Unsafe](./public/image1.png) + 允许不安全内容 ![Allow Unsafe](./public/image1.png)
......
...@@ -5,10 +5,8 @@ ...@@ -5,10 +5,8 @@
> Chat-Query is a data query tool based on metadata models and AI technology, enabling natural language queries. > Chat-Query is a data query tool based on metadata models and AI technology, enabling natural language queries.
## Demo ## Demo
> [view](https://chat-query.netlify.app/) **Due to network restrictions on Netlify, please try to choose one of the following modes:** > [view](https://chat-query.vercel.app/)
> [zh](http://139.198.179.193:32205/)
+ Choose website settings ![Choose website settings](./public/image.png)
+ Allow Unsafe Content ![Allow Unsafe](./public/image1.png)
> [demo](https://cdn.glitch.me/fd139a45-4a65-41b6-9634-41617ab20cdc/%E6%BC%94%E7%A4%BA.gif?v=1686907695067) > [demo](https://cdn.glitch.me/fd139a45-4a65-41b6-9634-41617ab20cdc/%E6%BC%94%E7%A4%BA.gif?v=1686907695067)
......
...@@ -23,6 +23,7 @@ ENV OPENAI_PROXY_URL $OPENAI_PROXY_URL ...@@ -23,6 +23,7 @@ ENV OPENAI_PROXY_URL $OPENAI_PROXY_URL
# 执行构建命令 # 执行构建命令
COPY .next ./.next COPY .next ./.next
COPY public ./public
# 暴露 3000 端口 # 暴露 3000 端口
EXPOSE 3000 EXPOSE 3000
......
...@@ -96,7 +96,7 @@ export function ChatView({ ...@@ -96,7 +96,7 @@ export function ChatView({
defaultNode, defaultNode,
props: propsRaw, props: propsRaw,
id, id,
functions, functions = init,
}: { }: {
defaultNode?: ReactElement; defaultNode?: ReactElement;
props: Record<string, any>; props: Record<string, any>;
...@@ -300,24 +300,23 @@ export function ChatView({ ...@@ -300,24 +300,23 @@ export function ChatView({
showSearch={{ showSearch={{
retainInputValue: true, retainInputValue: true,
}} }}
onFocus={() => { onClick={() => {
if (editor) {
const root: any = Parser.parse( const root: any = Parser.parse(
editor.getValue(), editor?.getValue() || functions,
{ {
ecmaVersion: 6, ecmaVersion: 6,
} }
); );
console.log(root, 'content');
const body: ReturnType<typeof Parser.parse>[] = const body: ReturnType<typeof Parser.parse>[] = get(
get(root, 'body'); root,
'body'
);
setFunctionOption( setFunctionOption(
body.filter( body.filter(
v => v.type === 'FunctionDeclaration' v => v.type === 'FunctionDeclaration'
) )
); );
}
}} }}
onChange={setFunctionName} onChange={setFunctionName}
> >
...@@ -339,11 +338,13 @@ export function ChatView({ ...@@ -339,11 +338,13 @@ export function ChatView({
} }
const data = await workerFn( const data = await workerFn(
propsRaw, propsRaw,
`${editor?.getValue()};\n return ${functionName}(data);` `${
editor?.getValue() || functions
};\n return ${functionName}(data);`
); );
ConnectDb.updateQuery( ConnectDb.updateQuery(
id, id,
`${editor?.getValue()}\n` `${editor?.getValue() || functions}\n`
); );
setProps(data); setProps(data);
}} }}
...@@ -363,7 +364,7 @@ export function ChatView({ ...@@ -363,7 +364,7 @@ export function ChatView({
}} }}
height="300px" height="300px"
defaultLanguage="javascript" defaultLanguage="javascript"
defaultValue={functions || init} defaultValue={functions}
/> />
</CollapseItem> </CollapseItem>
</Collapse> </Collapse>
......
...@@ -8,9 +8,15 @@ import { HTML5Backend } from 'react-dnd-html5-backend'; ...@@ -8,9 +8,15 @@ import { HTML5Backend } from 'react-dnd-html5-backend';
import { DndProvider, useDrag, useDrop } from 'react-dnd'; import { DndProvider, useDrag, useDrop } from 'react-dnd';
import Link from 'next/link'; import Link from 'next/link';
import { useTranslation, Trans } from 'react-i18next'; import { useTranslation, Trans } from 'react-i18next';
import { useEffect } from 'react';
import Script from 'next/script';
function Home() { function Home() {
const { t } = useTranslation(); const { t } = useTranslation();
useEffect(() => {
return () => {
document.querySelector('#fireworks')?.remove();
};
}, []);
return ( return (
<> <>
<Head> <Head>
...@@ -23,6 +29,15 @@ function Home() { ...@@ -23,6 +29,15 @@ function Home() {
<link rel="icon" href="/favicon.ico" /> <link rel="icon" href="/favicon.ico" />
</Head> </Head>
<main className="home bg-scroll"> <main className="home bg-scroll">
<Script
src="https://cdn.jsdelivr.net/npm/tsparticles-fireworks@2.10.1/tsparticles.fireworks.bundle.min.js"
onLoad={() => {
if (window?.fireworks) {
document.querySelector('#fireworks')?.remove();
fireworks();
}
}}
/>
<Layout className="main"> <Layout className="main">
<Layout> <Layout>
<div className="container"> <div className="container">
......
...@@ -253,3 +253,8 @@ background:rgba(255, 166, 0, 0.53) !important; ...@@ -253,3 +253,8 @@ background:rgba(255, 166, 0, 0.53) !important;
.shadow-t { .shadow-t {
box-shadow: 0 -5px 10px 0px rgba(130, 130, 130, 0.1); box-shadow: 0 -5px 10px 0px rgba(130, 130, 130, 0.1);
} }
#fireworks{
position: relative;
z-index: -1;
}
\ No newline at end of file
.home { .home {
color: #fff; color: #fff;
font-family: "Roboto Condensed", sans-serif; font-family: "Roboto Condensed", sans-serif;
background-image: url(https://images.unsplash.com/photo-1508389377389-b8221c0bcc9e?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=1350&q=80);
background-size: 110%;
background-position: 0% 0%;
margin: 0; margin: 0;
animation: change-background 15s linear infinite alternate-reverse; animation: change-background 15s linear infinite alternate-reverse;
width: 100%; width: 100%;
......
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