|
5 | 5 | <title>Ace Editor - EDA V2.3.1</title> |
6 | 6 | <link id="theme-light" rel="stylesheet" href="/iframe/style/body-light.css" disabled /> |
7 | 7 | <link id="theme-dark" rel="stylesheet" href="/iframe/style/body-dark.css" /> |
8 | | - <!-- 风格文件 --> |
9 | 8 | <link rel="stylesheet" href="/iframe/script/SweetAlert2/sweetalert2.min.css" /> |
10 | 9 | </head> |
11 | 10 | <body> |
|
23 | 22 | <li><button id="SaveinLeft-btn">保存到列表</button></li> |
24 | 23 | <li><button id="Ext-btn">插件管理</button></li> |
25 | 24 | <li><button id="ai-btn">AI编程</button></li> |
26 | | - <!-- <li><button id="example-btn" style="display: none;">案例</button></li> |
27 | | - <li><button id="about-btn" style="display: none;">关于</button></li> --> |
28 | 25 | </ul> |
29 | 26 | </div> |
30 | 27 | <div id="editor-container"> |
31 | 28 | <div id="editor"></div> |
32 | 29 | </div> |
33 | 30 | <!-- 右侧 AI 聊天窗口 --> |
34 | 31 | <div id="ai-chat" style="display: none"> |
35 | | - <!-- 1. 顶部标题栏:包含模型名称和设置齿轮 --> |
36 | 32 | <div class="ai-chat-header"> |
37 | 33 | <span class="ai-chat-title" id="ai-model-name">GPT-4 Model</span> |
38 | | - <!-- 设置齿轮图标 (使用 SVG 或 Unicode,这里用 SVG 更精致) --> |
39 | 34 | <button class="ai-chat-settings-btn" id="ai-settings-trigger" title="聊天设置"> |
40 | 35 | <svg |
41 | 36 | xmlns="http://www.w3.org/2000/svg" |
|
55 | 50 | </svg> |
56 | 51 | </button> |
57 | 52 | </div> |
58 | | - <!-- 2. 中间消息列表区域 --> |
59 | 53 | <div class="ai-chat-content" id="ai-chat-list"> |
60 | | - <!-- 欢迎语 --> |
61 | 54 | <div class="ai-message ai-message-system"> |
62 | 55 | <div class="ai-message-bubble">你好!我是你的 AI 编程助手。有什么可以帮你的吗?</div> |
63 | 56 | </div> |
64 | | - <!-- 动态消息会插入到这里 --> |
65 | 57 | </div> |
66 | | - <!-- 3. 底部输入框区域 --> |
67 | 58 | <div class="ai-chat-footer"> |
68 | 59 | <textarea id="ai-input" placeholder="输入代码问题或指令... (Shift+Enter 换行)" rows="1"></textarea> |
69 | 60 | <button id="ai-send-btn">发送</button> |
70 | 61 | </div> |
71 | 62 | </div> |
72 | 63 | </div> |
73 | 64 |
|
74 | | - <!-- Ace 插件资源等 --> |
| 65 | + <!-- Ace 核心 --> |
75 | 66 | <script src="/iframe/script/Ace_Editor/ace.js"></script> |
76 | 67 | <script src="/iframe/script/Ace_Editor/ext-language_tools.js"></script> |
77 | 68 | <script src="/iframe/script/Ace_Editor/mode-javascript.js"></script> |
|
81 | 72 | <script src="/iframe/script/Ace_Editor/ext-themelist.js"></script> |
82 | 73 | <script src="/iframe/script/Ace_Editor/ext-settings_menu.js"></script> |
83 | 74 | <script src="/iframe/script/Ace_Editor/ext-prompt.js"></script> |
84 | | - <script src="/iframe/script/Js_beautify/beautify-css.min.js"></script> |
85 | | - <script src="/iframe/script/Js_beautify/beautify.min.js"></script> |
86 | | - <script src="/iframe/script/Js_beautify/beautify-html.min.js"></script> |
87 | | - <!-- <script src="/iframe"></script> --> |
88 | | - <!-- 以下全都是ACE的风格文件,如果有需要可以自己添加 东西都在Ace_Editor文件夹里--> |
| 75 | + <!-- Ace 主题 --> |
89 | 76 | <script src="/iframe/script/Ace_Editor/theme-monokai.js"></script> |
90 | 77 | <script src="/iframe/script/Ace_Editor/theme-github.js"></script> |
91 | | - <!-- 一些编辑器支持 --> |
92 | | - <script src="/iframe/script/User_config/Ai_Chat.js"></script> |
93 | | - <script src="/iframe/script/eda_coder/EDA_Codes.js"></script> |
94 | | - <script src="/iframe/script/User_config/ACE_Config.js"></script> |
95 | | - <script src="/iframe/script/User_config/Code_Config.js"></script> |
96 | | - <!-- SweetAlert JS模态框资源 --> |
| 78 | + <script src="/iframe/script/Ace_Editor/theme-ambiance.js"></script> |
| 79 | + <script src="/iframe/script/Ace_Editor/theme-chaos.js"></script> |
| 80 | + <script src="/iframe/script/Ace_Editor/theme-chrome.js"></script> |
| 81 | + <script src="/iframe/script/Ace_Editor/theme-clouds.js"></script> |
| 82 | + <script src="/iframe/script/Ace_Editor/theme-clouds_midnight.js"></script> |
| 83 | + <script src="/iframe/script/Ace_Editor/theme-cobalt.js"></script> |
| 84 | + <script src="/iframe/script/Ace_Editor/theme-crimson_editor.js"></script> |
| 85 | + <script src="/iframe/script/Ace_Editor/theme-dreamweaver.js"></script> |
| 86 | + <!-- 代码格式化 --> |
| 87 | + <script src="/iframe/script/Js_beautify/beautify.min.js"></script> |
| 88 | + <script src="/iframe/script/Js_beautify/beautify-css.min.js"></script> |
| 89 | + <script src="/iframe/script/Js_beautify/beautify-html.min.js"></script> |
| 90 | + <!-- SweetAlert2 模态框 --> |
97 | 91 | <script src="/iframe/script/SweetAlert2/sweetalert2@11.js"></script> |
98 | | - <!-- 工具类 --> |
| 92 | + <!-- 工具库 --> |
99 | 93 | <script src="/iframe/script/eext_tool/jszip.min.js"></script> |
100 | | - <!-- 文件解压 --> |
101 | 94 | <script src="/iframe/script/eext_tool/highlight.min.js"></script> |
102 | | - <!-- AI语法高亮 --> |
103 | 95 | <script src="/iframe/script/eext_tool/marked.min.js"></script> |
104 | | - <!-- MD语法解析 --> |
| 96 | + <!-- 应用逻辑 --> |
| 97 | + <script src="/iframe/script/eda_coder/EDA_Codes.js"></script> |
| 98 | + <script src="/iframe/script/User_config/Ai_Chat.js"></script> |
| 99 | + <script src="/iframe/script/User_config/ACE_Config.js"></script> |
| 100 | + <script src="/iframe/script/User_config/Code_Config.js"></script> |
105 | 101 | <script> |
106 | | - //初始化Ace 编辑器 |
107 | | - const settingsMenu = ace.require('ace/ext/settings_menu'); |
108 | 102 | const editor = ace.edit('editor'); |
109 | 103 | ACE_Init(editor); |
110 | 104 |
|
111 | | - //加载上次关闭时的缓存 |
| 105 | + // 加载上次关闭时的缓存(|| '' 防止 null/undefined 写入编辑器) |
112 | 106 | const HistoryCode = eda.sys_Storage.getExtensionUserConfig('editor_value'); |
113 | | - editor.setValue(HistoryCode); |
| 107 | + editor.setValue(HistoryCode || '', -1); |
114 | 108 |
|
115 | | - // 注册放大缩小代码支持 |
| 109 | + // 注册 Ctrl+滚轮缩放字体 |
116 | 110 | let currentFontSize = 14; |
117 | 111 | ACE_ChangeCodeSize(editor, currentFontSize, showToast); |
118 | 112 |
|
119 | | - //注册EDA智能补全 |
| 113 | + // 注册 EDA 智能补全 |
120 | 114 | ACE_CodingForEDA(editor, edcode); |
121 | 115 |
|
122 | | - //自动缓存 |
| 116 | + // 自动缓存编辑器内容 |
123 | 117 | editor.session.on('change', function () { |
124 | 118 | eda.sys_Storage.setExtensionUserConfig('editor_value', editor.getValue()); |
125 | 119 | }); |
126 | 120 |
|
127 | | - //获取当前编辑器主题 |
| 121 | + // 初始化主题 |
128 | 122 | const light_theme = document.getElementById('theme-light'); |
129 | 123 | const dark_theme = document.getElementById('theme-dark'); |
130 | 124 | GetTheme(editor, light_theme, dark_theme); |
131 | 125 |
|
132 | | - //获取按钮状态 |
| 126 | + // 初始化 AI 按钮状态 |
133 | 127 | GetVibeCodingConfig(); |
134 | 128 |
|
135 | | - //扫描插件并执行 |
| 129 | + // 加载并执行已保存插件 |
136 | 130 | ExtStore_LoadAndRunAllPlugins(); |
137 | | - //加载按钮到左侧 |
| 131 | + // 加载快捷按钮列表 |
138 | 132 | Code_LoadBtnListFromDB(editor); |
139 | 133 |
|
140 | | - //保存代码到左侧列表 |
| 134 | + // 注册右键跳转文档 |
| 135 | + const methodList = edcode.map((item) => item.methodPath); |
| 136 | + injectContextMenuJumpToDocs(editor, methodList); |
| 137 | + |
| 138 | + // 按钮事件绑定 |
141 | 139 | document.getElementById('SaveinLeft-btn').addEventListener('click', () => { |
142 | 140 | Code_SaveToBtnList(editor); |
143 | 141 | }); |
144 | | - //格式化代码 |
145 | 142 | document.getElementById('formatEditorCode-btn').addEventListener('click', () => { |
146 | 143 | formatEditorCode(editor); |
147 | 144 | }); |
148 | | - // 运行代码 |
149 | 145 | document.getElementById('run-btn').addEventListener('click', () => { |
150 | 146 | ACE_RunCode(editor); |
151 | 147 | }); |
152 | | - // 开启AI辅助支持 |
153 | 148 | document.getElementById('ai-btn').addEventListener('click', () => { |
154 | 149 | SetVibeCodingConfig(); |
155 | 150 | }); |
156 | | - // 保存代码 |
157 | | - document.getElementById('save-btn').addEventListener('click', async () => { |
158 | | - // await eda.sys_Message.showToastMessage('这个还没写', 'info', 1); |
| 151 | + document.getElementById('save-btn').addEventListener('click', () => { |
159 | 152 | Code_SaveCode(editor); |
160 | 153 | }); |
161 | | - //加载代码 |
162 | | - document.getElementById('load-btn').addEventListener('click', async () => { |
163 | | - // await eda.sys_Message.showToastMessage('这个还没写', 'info', 1); |
| 154 | + document.getElementById('load-btn').addEventListener('click', () => { |
164 | 155 | Code_OpenLoadWindow(editor); |
165 | 156 | }); |
166 | | - //编辑器设置 |
167 | | - document.getElementById('setting-btn').addEventListener('click', async () => { |
168 | | - // await eda.sys_Message.showToastMessage('这个还没写'); |
| 157 | + document.getElementById('setting-btn').addEventListener('click', () => { |
169 | 158 | SetTheme(editor, light_theme, dark_theme); |
170 | 159 | }); |
171 | | - //删除代码 |
172 | | - document.getElementById('delete-btn').addEventListener('click', async () => { |
173 | | - // await eda.sys_Message.showToastMessage('这个还没写', 'info', 1); |
| 160 | + document.getElementById('delete-btn').addEventListener('click', () => { |
174 | 161 | eda.sys_Message.showToastMessage('注意,这玩意不会问你是否删除,点一下立马删,三思而后行', 'warn', 3); |
175 | 162 | Code_OpenDeleteWindow(editor); |
176 | 163 | }); |
177 | | - //导入JS文件 |
178 | | - document.getElementById('import-btn').addEventListener('click', async () => { |
| 164 | + document.getElementById('import-btn').addEventListener('click', () => { |
179 | 165 | ImportFile(editor); |
180 | 166 | }); |
181 | | - //导出JS文件 |
182 | | - document.getElementById('export-btn').addEventListener('click', async () => { |
| 167 | + document.getElementById('export-btn').addEventListener('click', () => { |
183 | 168 | ExportFileForJs(editor.getValue(), Date() + '_script.js'); |
184 | 169 | }); |
185 | | - //保存到插件 |
186 | | - document.getElementById('Ext-btn').addEventListener('click', async () => { |
| 170 | + document.getElementById('Ext-btn').addEventListener('click', () => { |
187 | 171 | showPluginManagerModal(editor); |
188 | 172 | }); |
189 | | - //注册文件跳转支持 |
190 | | - const methodList = edcode.map((item) => item.methodPath); // 保留 'eda.XXX' |
191 | | - injectContextMenuJumpToDocs(editor, methodList); |
192 | | - /*================================== 以下为快捷键绑定配置 ===============================================================*/ |
193 | | - //绑定运行快捷键 |
| 173 | + |
| 174 | + // 快捷键绑定 |
194 | 175 | document.addEventListener('keydown', function (event) { |
195 | 176 | if ((event.ctrlKey || event.metaKey) && event.key === 'Enter') { |
196 | 177 | ACE_RunCode(editor); |
197 | 178 | } |
198 | 179 | }); |
199 | | - //绑定保存快捷键 |
200 | 180 | document.addEventListener('keydown', function (e) { |
201 | 181 | if ((e.ctrlKey || e.metaKey) && e.key === 's') { |
202 | 182 | e.preventDefault(); |
203 | 183 | Code_SaveCode(editor); |
204 | 184 | } |
205 | 185 | }); |
206 | 186 | </script> |
207 | | - <!-- 一些资源文件 这些都不是必要的 删除也没什么影响 只不过用户也许会换主题所以放进来--> |
208 | | - <script src="/iframe/script/Ace_Editor/theme-ambiance.js"></script> |
209 | | - <script src="/iframe/script/Ace_Editor/theme-chaos.js"></script> |
210 | | - <script src="/iframe/script/Ace_Editor/theme-chrome.js"></script> |
211 | | - <script src="/iframe/script/Ace_Editor/theme-clouds.js"></script> |
212 | | - <script src="/iframe/script/Ace_Editor/theme-clouds_midnight.js"></script> |
213 | | - <script src="/iframe/script/Ace_Editor/theme-cobalt.js"></script> |
214 | | - <script src="/iframe/script/Ace_Editor/theme-crimson_editor.js"></script> |
215 | | - <script src="/iframe/script/Ace_Editor/theme-dreamweaver.js"></script> |
216 | 187 | </body> |
217 | 188 | </html> |
0 commit comments