This commit is contained in:
2025-03-04 22:57:46 +08:00
parent fd3288cb5b
commit 4a04a432ca
39 changed files with 1062 additions and 671 deletions

View File

@@ -1,8 +1,6 @@
import { createRoot, Root } from 'react-dom/client';
import { AiApp } from './AiApp';
import { createRoot } from 'react-dom/client';
import { app, initAIAppRootOrCreate, useContextKey } from '../app';
import { Editor } from '@/pages/editor/index';
import { ExampleApp } from '@/modules/panels/Example';
import { Panels } from '@/modules/panels/index';
initAIAppRootOrCreate();
app
@@ -12,15 +10,11 @@ app
description: '渲染AI应用',
run: async (ctx) => {
const root = initAIAppRootOrCreate();
console.log('ai render');
console.log('ai render', root);
if (!root) {
return;
}
const aiRoot = createRoot(root!);
// aiRoot.render(<Editor />);
// aiRoot.render(<AiApp />);
aiRoot.render(<ExampleApp />);
aiRoot.render(<Panels />);
useContextKey('aiRoot', () => aiRoot, true);
ctx.body = 'aiRoot';
},

View File

@@ -28,6 +28,7 @@ export const queryAI = useContextKey<QueryAI>('queryAI', () => {
return new QueryAI();
});
export const rootEl = document.getElementById('root') as HTMLElement;
export const initAIAppRootOrCreate = () => {
const root = document.getElementById('ai-root');
if (!root) {

View File

@@ -1,4 +1,5 @@
import { app, page, load } from './app';
import '../src/routes';
import './ai-app/main';
import './tailwind.css';
import './workspace/entry';
@@ -8,6 +9,7 @@ page.addPage('/', 'workspace');
const runLoad = () => {
load.load(
() => {
console.log('runLoad');
// @TODO 这里需要优化,不能每次都去调用
page.subscribe(
'workspace',
@@ -36,4 +38,4 @@ const runLoad = () => {
);
};
// runLoad()
runLoad()

View File

@@ -12,14 +12,14 @@
/* # 背景设置为透明 */
#ai-root {
/* @apply bg-transparent */
@apply bg-transparent;
@apply border-none box-border border-2 border-gray-300 rounded-md;
@apply pointer-events-none;
}
#ai-root {
.node-editor {
@apply pointer-events-auto;
@apply absolute bottom-0 left-0 w-full h-[20vh] border border-gray-300 shadow-md;
@apply absolute bottom-0 left-0 w-full border border-gray-300 shadow-md;
.tiptap {
@apply mx-0 h-full overflow-y-auto;
}
@@ -28,5 +28,3 @@
@apply w-full h-full overflow-hidden;
}
}

View File

@@ -15,15 +15,16 @@ app
return;
}
console.log('workspace enter');
console.log('workspace enter', isRender);
if (!isRender) {
app.call({
const res = await app.call({
path: 'wallnote',
key: 'render',
});
console.log('res', res);
isRender = true;
}
ctx.body = '';
},
})
.addTo(app);