simulator.html 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342
  1. <!DOCTYPE html>
  2. <html lang="zh">
  3. <head>
  4. <meta charset="UTF-8">
  5. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  6. <title>BRAIN Alpha 模拟器 - 用户界面</title>
  7. <link rel="stylesheet" href="{{ url_for('static', filename='styles.css') }}">
  8. <style>
  9. .simulator-container {
  10. max-width: 1200px;
  11. margin: 0 auto;
  12. padding: 20px;
  13. }
  14. .simulator-grid {
  15. display: grid;
  16. grid-template-columns: 1fr 1fr;
  17. gap: 20px;
  18. margin-top: 20px;
  19. }
  20. .simulator-panel {
  21. background: #f8f9fa;
  22. border-radius: 8px;
  23. padding: 20px;
  24. border: 1px solid #dee2e6;
  25. }
  26. .form-group {
  27. margin-bottom: 15px;
  28. }
  29. .form-group label {
  30. display: block;
  31. margin-bottom: 5px;
  32. font-weight: 600;
  33. color: #495057;
  34. }
  35. .form-group input, .form-group textarea, .form-group select {
  36. width: 100%;
  37. padding: 8px 12px;
  38. border: 1px solid #ced4da;
  39. border-radius: 4px;
  40. font-size: 14px;
  41. }
  42. .form-group input[type="number"] {
  43. width: 120px;
  44. }
  45. .form-group input[type="file"] {
  46. padding: 4px;
  47. }
  48. .form-group textarea {
  49. height: 60px;
  50. resize: vertical;
  51. }
  52. .checkbox-group {
  53. display: flex;
  54. align-items: center;
  55. gap: 8px;
  56. }
  57. .checkbox-group input[type="checkbox"] {
  58. width: auto;
  59. }
  60. .log-viewer {
  61. background: #1e1e1e;
  62. color: #f8f8f2;
  63. padding: 15px;
  64. border-radius: 4px;
  65. font-family: 'Courier New', 'SimSun', 'Microsoft YaHei', monospace;
  66. font-size: 12px;
  67. height: 300px;
  68. overflow-y: auto;
  69. white-space: pre-wrap;
  70. margin-top: 10px;
  71. unicode-bidi: embed;
  72. word-break: break-all;
  73. }
  74. .status-indicator {
  75. padding: 8px 12px;
  76. border-radius: 4px;
  77. font-weight: 500;
  78. margin-bottom: 15px;
  79. }
  80. .status-idle {
  81. background: #e9ecef;
  82. color: #495057;
  83. }
  84. .status-running {
  85. background: #fff3cd;
  86. color: #856404;
  87. }
  88. .status-success {
  89. background: #d1edff;
  90. color: #0c5460;
  91. }
  92. .status-error {
  93. background: #f8d7da;
  94. color: #721c24;
  95. }
  96. .parameter-help {
  97. font-size: 12px;
  98. color: #6c757d;
  99. margin-top: 4px;
  100. }
  101. .action-buttons {
  102. display: flex;
  103. gap: 10px;
  104. margin-top: 20px;
  105. }
  106. .btn-run {
  107. background: #28a745;
  108. color: white;
  109. border: none;
  110. padding: 12px 24px;
  111. border-radius: 4px;
  112. font-size: 16px;
  113. font-weight: 500;
  114. cursor: pointer;
  115. }
  116. .btn-run:hover {
  117. background: #218838;
  118. }
  119. .btn-run:disabled {
  120. background: #6c757d;
  121. cursor: not-allowed;
  122. }
  123. .password-input {
  124. position: relative;
  125. }
  126. .password-toggle {
  127. position: absolute;
  128. right: 10px;
  129. top: 50%;
  130. transform: translateY(-50%);
  131. background: none;
  132. border: none;
  133. cursor: pointer;
  134. color: #6c757d;
  135. }
  136. .file-info {
  137. margin-top: 8px;
  138. padding: 8px;
  139. background: #e9ecef;
  140. border-radius: 4px;
  141. font-size: 12px;
  142. }
  143. .back-link {
  144. color: #007bff;
  145. text-decoration: none;
  146. margin-bottom: 20px;
  147. display: inline-block;
  148. }
  149. .back-link:hover {
  150. text-decoration: underline;
  151. }
  152. .warning-box {
  153. background: #fff3cd;
  154. border: 1px solid #ffeaa7;
  155. border-radius: 4px;
  156. padding: 12px;
  157. margin: 10px 0;
  158. color: #856404;
  159. }
  160. .info-box {
  161. background: #d1ecf1;
  162. border: 1px solid #bee5eb;
  163. border-radius: 4px;
  164. padding: 12px;
  165. margin: 10px 0;
  166. color: #0c5460;
  167. }
  168. </style>
  169. </head>
  170. <body>
  171. <div class="simulator-container">
  172. <a href="/" class="back-link">← 返回主页</a>
  173. <header>
  174. <h1>🚀 BRAIN Alpha 模拟器</h1>
  175. <p class="subtitle">用户友好的界面,用于运行 alpha 模拟</p>
  176. <div class="status-indicator" id="simulatorStatus">
  177. 准备配置模拟参数
  178. </div>
  179. </header>
  180. <div class="simulator-grid">
  181. <!-- 配置面板 -->
  182. <div class="simulator-panel">
  183. <h3>📋 模拟配置</h3>
  184. <form id="simulatorForm">
  185. <!-- JSON 文件选择 -->
  186. <div class="form-group">
  187. <label for="jsonFile">📁 表达式 JSON 文件</label>
  188. <input type="file" id="jsonFile" accept=".json" required>
  189. <div class="parameter-help">选择 expressions_with_settings.json 文件</div>
  190. <div id="jsonFileInfo" class="file-info" style="display: none;"></div>
  191. </div>
  192. <!-- 身份验证 -->
  193. <div class="form-group">
  194. <label for="username">👤 BRAIN 用户名</label>
  195. <input type="text" id="username" required placeholder="your.email@domain.com">
  196. </div>
  197. <div class="form-group">
  198. <label for="password">🔒 BRAIN 密码</label>
  199. <div class="password-input">
  200. <input type="password" id="password" required placeholder="您的密码">
  201. <button type="button" class="password-toggle" onclick="togglePassword()">👁️</button>
  202. </div>
  203. </div>
  204. <!-- 模拟参数 -->
  205. <div class="form-group">
  206. <label for="startPosition">🎯 起始位置</label>
  207. <input type="number" id="startPosition" min="0" value="0" required>
  208. <div class="parameter-help">从表达式 N 开始(基于 0 的索引)</div>
  209. </div>
  210. <div class="form-group">
  211. <label for="concurrentCount">⚡ 并发模拟</label>
  212. <input type="number" id="concurrentCount" min="1" value="3" required>
  213. <div class="parameter-help">并行模拟的数量</div>
  214. </div>
  215. <!-- 高级选项 -->
  216. <div class="form-group">
  217. <div class="checkbox-group">
  218. <input type="checkbox" id="randomShuffle">
  219. <label for="randomShuffle">🔀 随机打乱</label>
  220. </div>
  221. <div class="parameter-help">随机打乱表达式顺序</div>
  222. </div>
  223. <div class="form-group">
  224. <div class="checkbox-group">
  225. <input type="checkbox" id="useMultiSim" onchange="toggleMultiSimOptions()">
  226. <label for="useMultiSim">🎛️ 多重模拟模式</label>
  227. </div>
  228. <div class="parameter-help">在一个模拟槽中组合多个 alpha</div>
  229. </div>
  230. <div class="form-group" id="multiSimOptions" style="display: none;">
  231. <label for="alphaCountPerSlot">📊 每个槽的 Alphas</label>
  232. <input type="number" id="alphaCountPerSlot" min="2" max="10" value="3">
  233. <div class="parameter-help">每个多重模拟槽的 alpha 数量(2-10)</div>
  234. </div>
  235. <div class="warning-box" id="overwriteWarning" style="display: none;">
  236. ⚠️ 警告:如果起始位置 > 0 或启用了随机打乱,则原始 JSON 文件将被覆盖!
  237. </div>
  238. </form>
  239. <div class="action-buttons">
  240. <button class="btn-run" id="runSimulator" onclick="runSimulator()">
  241. 🚀 开始模拟
  242. </button>
  243. <button class="btn btn-outline" onclick="testConnection()" id="testBtn">
  244. 🔗 测试连接
  245. </button>
  246. <button class="btn btn-outline" onclick="stopSimulation()" id="stopBtn" style="display: none;">
  247. ⏹️ 停止
  248. </button>
  249. </div>
  250. </div>
  251. <!-- 日志查看面板 -->
  252. <div class="simulator-panel">
  253. <h3>📊 模拟日志与状态</h3>
  254. <div class="info-box" id="currentLogFile">
  255. 未选择日志文件。模拟开始时将自动监控最新日志。
  256. </div>
  257. <div class="form-group">
  258. <label for="logSelector">📁 选择日志文件</label>
  259. <select id="logSelector" onchange="loadSelectedLog()">
  260. <option value="">选择一个日志文件...</option>
  261. </select>
  262. <button class="btn btn-small btn-outline" onclick="refreshLogFiles()">🔄 刷新</button>
  263. </div>
  264. <div class="log-viewer" id="logViewer">
  265. 欢迎使用 BRAIN Alpha 模拟器!
  266. 该界面将显示:
  267. - 实时模拟进度
  268. - 身份验证状态
  269. - Alpha 生成结果
  270. - 错误消息和警告
  271. 配置您的参数并点击“开始模拟”以开始。
  272. </div>
  273. <div id="simulationProgress" style="margin-top: 15px; display: none;">
  274. <div style="display: flex; justify-content: space-between; align-items: center;">
  275. <span>进度:</span>
  276. <span id="progressText">0/0</span>
  277. </div>
  278. <div style="background: #e9ecef; height: 8px; border-radius: 4px; margin-top: 5px;">
  279. <div id="progressBar" style="background: #28a745; height: 100%; border-radius: 4px; width: 0%; transition: width 0.3s;"></div>
  280. </div>
  281. </div>
  282. </div>
  283. </div>
  284. <!-- 结果部分 -->
  285. <div class="simulator-panel" id="resultsPanel" style="margin-top: 20px; display: none;">
  286. <h3>✅ 模拟请求成功发送</h3>
  287. <div id="simulationResults"></div>
  288. </div>
  289. </div>
  290. <script src="{{ url_for('static', filename='simulator.js') }}"></script>
  291. </body>
  292. </html>