commit 6874096d40de243429a5c386d1704141aafe9509
Author: ruxia <752159071@qq.com>
Date: Thu Apr 3 17:16:43 2025 +0800
首次提交:上传本地文件夹
diff --git a/index.html b/index.html
new file mode 100644
index 0000000..ab9fefc
--- /dev/null
+++ b/index.html
@@ -0,0 +1,95 @@
+
+
+
+
+
+ 页面切换示例
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+

+
+
+

+
+
+

+
+
+

+
+
+

+
+
+

+
+
+

+
+
+

+
+
+
+
+
\ No newline at end of file
diff --git a/static/主页.png b/static/主页.png
new file mode 100644
index 0000000..a657b63
Binary files /dev/null and b/static/主页.png differ
diff --git a/static/取费设置.png b/static/取费设置.png
new file mode 100644
index 0000000..a51b37c
Binary files /dev/null and b/static/取费设置.png differ
diff --git a/static/工程信息.png b/static/工程信息.png
new file mode 100644
index 0000000..1fbe0a6
Binary files /dev/null and b/static/工程信息.png differ
diff --git a/static/工程费用.png b/static/工程费用.png
new file mode 100644
index 0000000..da2cbf8
Binary files /dev/null and b/static/工程费用.png differ
diff --git a/static/工程量.png b/static/工程量.png
new file mode 100644
index 0000000..19d8586
Binary files /dev/null and b/static/工程量.png differ
diff --git a/static/报表输出.png b/static/报表输出.png
new file mode 100644
index 0000000..e1bc46e
Binary files /dev/null and b/static/报表输出.png differ
diff --git a/static/材机分析.png b/static/材机分析.png
new file mode 100644
index 0000000..ed6be6b
Binary files /dev/null and b/static/材机分析.png differ
diff --git a/static/组合件.png b/static/组合件.png
new file mode 100644
index 0000000..ac1b7f7
Binary files /dev/null and b/static/组合件.png differ
diff --git a/templates/index.html b/templates/index.html
new file mode 100644
index 0000000..21028d2
--- /dev/null
+++ b/templates/index.html
@@ -0,0 +1,155 @@
+
+
+
+
+
+
+ 页面切换示例
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+

+
+
+

+
+
+

+
+
+

+
+
+

+
+
+

+
+
+

+
+
+

+
+
+
+
+
+
\ No newline at end of file
diff --git a/test_demo.py b/test_demo.py
new file mode 100644
index 0000000..7fd8b23
--- /dev/null
+++ b/test_demo.py
@@ -0,0 +1,315 @@
+import os
+import json
+from flask import Flask, render_template, request, jsonify
+from PIL import Image
+
+app = Flask(__name__)
+app.config['JSON_AS_ASCII'] = False # 确保JSON响应中的中文字符正确显示
+
+# 添加全局变量来存储当前界面
+current_page = "主页"
+
+# 确保templates和static文件夹存在
+templates_dir = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'templates')
+static_dir = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'static')
+
+if not os.path.exists(templates_dir):
+ os.makedirs(templates_dir)
+if not os.path.exists(static_dir):
+ os.makedirs(static_dir)
+
+# 图片路径
+image_paths = {
+ "主页": "E:/文件/LLM_model/RAG/图片/D3/主页.PNG",
+ "工程信息": "E:/文件/LLM_model/RAG/图片/D3/工程信息.PNG",
+ "取费设置": "E:/文件/LLM_model/RAG/图片/D3/取费设置.PNG",
+ "组合件": "E:/文件/LLM_model/RAG/图片/D3/组合件.PNG",
+ "工程量": "E:/文件/LLM_model/RAG/图片/D3/工程量.PNG",
+ "材机分析": "E:/文件/LLM_model/RAG/图片/D3/材机分析.PNG",
+ "工程费用": "E:/文件/LLM_model/RAG/图片/D3/工程费用.PNG",
+ "报表输出": "E:/文件/LLM_model/RAG/图片/D3/报表输出.PNG"
+}
+
+# 创建HTML模板
+with open(os.path.join(templates_dir, 'index.html'), 'w', encoding='utf-8') as f:
+ f.write('''
+
+
+
+
+
+ 页面切换示例
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+

+
+
+

+
+
+

+
+
+

+
+
+

+
+
+

+
+
+

+
+
+

+
+
+
+
+
+ ''')
+
+# 将图片复制到static文件夹
+def copy_image_to_static(source_path, target_name):
+ try:
+ img = Image.open(source_path)
+ target_path = os.path.join(static_dir, f"{target_name}.png")
+ img.save(target_path)
+ return True
+ except Exception as e:
+ print(f"复制图片失败: {e}")
+
+@app.route('/')
+def index():
+ # 在第一次请求时设置图片
+ setup_images()
+ return render_template('index.html')
+
+@app.route('/get_image')
+def get_image():
+ title = request.args.get('title', '主页')
+ if title in image_paths:
+ image_url = f"/static/{title}.png"
+ resp = jsonify({'image_url': image_url})
+ resp.headers['Content-Type'] = 'application/json; charset=utf-8'
+ return resp
+
+ resp = jsonify({'error': '图片不存在'})
+ resp.headers['Content-Type'] = 'application/json; charset=utf-8'
+ return resp
+
+# 设置图片
+def setup_images():
+ # 检查是否已经设置过图片
+ if not hasattr(setup_images, 'done'):
+ # 复制内容图片
+ for title, path in image_paths.items():
+ copy_image_to_static(path, title)
+
+ # 标记为已完成
+ setup_images.done = True
+
+# 添加处理聊天消息的路由
+@app.route('/ask', methods=['POST'])
+def ask():
+ data = request.json
+ message = data.get('message', '')
+
+ # 这里可以添加调用Dify API的逻辑
+ resp = jsonify({
+ 'answer': f'您好,我收到了您的问题:"{message}"。由于当前无法连接到Dify服务器,我只能提供有限的回复。'
+ })
+ resp.headers['Content-Type'] = 'application/json; charset=utf-8'
+ return resp
+
+# 添加获取当前界面名称的接口
+@app.route('/get_current_page', methods=['GET'])
+def get_current_page():
+ global current_page
+ title = request.args.get('title')
+
+ # 如果请求中包含title参数,则更新当前界面
+ if title:
+ current_page = title
+ print(f"更新当前界面为: {current_page}")
+
+ response = {
+ 'software_name': '博微配网工程计价通D3软件',#博微配网工程计价通D3软件
+ 'engineering_type': '单工程',
+ 'software_version': '3.2.4.23',
+ 'project_name': '525252.BDD3',
+ 'current_page': current_page
+ }
+
+ # 检查是否是浏览器直接访问
+ if request.headers.get('Accept', '').find('text/html') != -1:
+ # 返回一个HTML页面,显示JSON数据
+ html = f'''
+
+
+
+
+ 当前界面信息
+
+
+
+ 当前界面信息
+
+
software_name: {response['software_name']}
+
engineering_type: {response['engineering_type']}
+
software_version: {response['software_version']}
+
project_name: {response['project_name']}
+
current_page: {response['current_page']}
+
+ 原始JSON:
+ {json.dumps(response, ensure_ascii=False, indent=2)}
+
+
+
+ '''
+ return html
+
+ # API调用返回JSON
+ return json.dumps(response, ensure_ascii=False)
+
+# 添加清空JSON的路由
+@app.route('/clear_json')
+def clear_json():
+ global current_page
+ # 重置当前页面
+ current_page = ""
+
+ # 返回空JSON,添加编码设置
+ resp = jsonify({})
+ resp.headers['Content-Type'] = 'application/json; charset=utf-8'
+ return resp
+
+if __name__ == "__main__":
+ app.run(host='0.0.0.0', port=1234, debug=True)
\ No newline at end of file
diff --git a/主页.PNG b/主页.PNG
new file mode 100644
index 0000000..0dea061
Binary files /dev/null and b/主页.PNG differ
diff --git a/取费设置.PNG b/取费设置.PNG
new file mode 100644
index 0000000..0f781ee
Binary files /dev/null and b/取费设置.PNG differ
diff --git a/工程信息.PNG b/工程信息.PNG
new file mode 100644
index 0000000..934f12b
Binary files /dev/null and b/工程信息.PNG differ
diff --git a/工程费用.PNG b/工程费用.PNG
new file mode 100644
index 0000000..1ecaa6c
Binary files /dev/null and b/工程费用.PNG differ
diff --git a/工程量.PNG b/工程量.PNG
new file mode 100644
index 0000000..c2c382a
Binary files /dev/null and b/工程量.PNG differ
diff --git a/报表输出.PNG b/报表输出.PNG
new file mode 100644
index 0000000..c4016cc
Binary files /dev/null and b/报表输出.PNG differ
diff --git a/材机分析.PNG b/材机分析.PNG
new file mode 100644
index 0000000..7d1dc5b
Binary files /dev/null and b/材机分析.PNG differ
diff --git a/组合件.PNG b/组合件.PNG
new file mode 100644
index 0000000..52a8fff
Binary files /dev/null and b/组合件.PNG differ