visualknowledge 0.1.2 → 0.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* 管理对话消息、流式状态、主题、模型选择、全屏 Widget。
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
-
import { createContext, useContext, useReducer } from 'react';
|
|
8
|
+
import React, { createContext, useContext, useReducer } from 'react';
|
|
9
9
|
|
|
10
10
|
// ====== Action Types ======
|
|
11
11
|
|
|
@@ -134,10 +134,10 @@ export const AppContext = createContext(null);
|
|
|
134
134
|
export function AppProvider({ children }) {
|
|
135
135
|
const [state, dispatch] = useReducer(appReducer, initialState);
|
|
136
136
|
|
|
137
|
-
return (
|
|
138
|
-
AppContext.Provider
|
|
139
|
-
|
|
140
|
-
|
|
137
|
+
return React.createElement(
|
|
138
|
+
AppContext.Provider,
|
|
139
|
+
{ value: { state, dispatch } },
|
|
140
|
+
children
|
|
141
141
|
);
|
|
142
142
|
}
|
|
143
143
|
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* 切换时更新 document.documentElement.dataset.theme。
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
-
import { useState, useCallback } from 'react';
|
|
8
|
+
import { useState, useEffect, useCallback } from 'react';
|
|
9
9
|
|
|
10
10
|
const STORAGE_KEY = 'claude-chat-theme';
|
|
11
11
|
|
|
@@ -23,9 +23,9 @@ export function useTheme() {
|
|
|
23
23
|
}, [theme]);
|
|
24
24
|
|
|
25
25
|
// 初始化:设置 DOM 主题
|
|
26
|
-
|
|
26
|
+
useEffect(() => {
|
|
27
27
|
document.documentElement.setAttribute('data-theme', theme);
|
|
28
|
-
});
|
|
28
|
+
}, []);
|
|
29
29
|
|
|
30
30
|
return { theme, toggleTheme };
|
|
31
31
|
}
|
package/frontend/src/main.js
CHANGED
|
@@ -7,10 +7,11 @@
|
|
|
7
7
|
import React from 'react';
|
|
8
8
|
import { createRoot } from 'react-dom/client';
|
|
9
9
|
import { App } from './App.jsx';
|
|
10
|
+
import { AppProvider } from './context/AppContext.jsx';
|
|
10
11
|
|
|
11
12
|
const rootEl = document.getElementById('root');
|
|
12
13
|
if (!rootEl) {
|
|
13
14
|
throw new Error('Root element #root not found in DOM');
|
|
14
15
|
}
|
|
15
16
|
|
|
16
|
-
createRoot(rootEl).render(React.createElement(App));
|
|
17
|
+
createRoot(rootEl).render(React.createElement(AppProvider, null, React.createElement(App)));
|
package/package.json
CHANGED
package/server.py
CHANGED
|
@@ -1,10 +1,14 @@
|
|
|
1
1
|
import json
|
|
2
|
+
import mimetypes
|
|
2
3
|
import os
|
|
3
4
|
import sys
|
|
4
5
|
import logging
|
|
5
6
|
from flask import Flask, request, Response, jsonify, send_from_directory
|
|
6
7
|
from anthropic import Anthropic
|
|
7
8
|
|
|
9
|
+
# Ensure .jsx files are served with correct JS MIME type for ES modules
|
|
10
|
+
mimetypes.add_type('application/javascript', '.jsx')
|
|
11
|
+
|
|
8
12
|
sys.path.insert(0, os.path.join(os.path.dirname(__file__), 'skills'))
|
|
9
13
|
from visualize import get_skill_prompt
|
|
10
14
|
|