index.html 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222
  1. <!DOCTYPE html>
  2. <html lang="zh-CN">
  3. <head>
  4. <meta charset="UTF-8">
  5. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  6. <title>License 管理平台</title>
  7. <link rel="stylesheet" href="/web/css/index.css">
  8. </head>
  9. <body>
  10. <!-- Toast 通知容器 -->
  11. <div class="toast-container" id="toast-container"></div>
  12. <!-- 确认对话框 -->
  13. <div id="confirmDialog" class="confirm-dialog">
  14. <div class="confirm-content">
  15. <div class="confirm-icon">⚠️</div>
  16. <div class="confirm-title" id="confirm-title">确认操作</div>
  17. <div class="confirm-message" id="confirm-message"></div>
  18. <div class="confirm-actions">
  19. <button class="btn btn-secondary" onclick="closeConfirmDialog(false)">取消</button>
  20. <button class="btn btn-danger" onclick="closeConfirmDialog(true)" id="confirm-ok-btn">确定</button>
  21. </div>
  22. </div>
  23. </div>
  24. <div class="container">
  25. <div class="header">
  26. <h1>🔑 License 管理平台</h1>
  27. <div style="display: flex; gap: 10px;">
  28. <button class="btn btn-primary" onclick="openBatchModal()">📦 批量生成</button>
  29. <button class="btn btn-primary" onclick="exportToCSV()">📥 导出 CSV</button>
  30. <button class="btn btn-primary" onclick="openCreateModal()">+ 创建 License</button>
  31. </div>
  32. </div>
  33. <!-- 统计信息卡片 -->
  34. <div class="stats-container" id="stats-container" style="display: none;">
  35. <div class="stat-card primary">
  36. <div class="stat-label">总 License 数</div>
  37. <div class="stat-value" id="stat-total">0</div>
  38. </div>
  39. <div class="stat-card success">
  40. <div class="stat-label">已激活</div>
  41. <div class="stat-value" id="stat-activated">0</div>
  42. </div>
  43. <div class="stat-card warning">
  44. <div class="stat-label">未激活</div>
  45. <div class="stat-value" id="stat-unactivated">0</div>
  46. </div>
  47. <div class="stat-card danger">
  48. <div class="stat-label">总设备数</div>
  49. <div class="stat-value" id="stat-devices">0</div>
  50. </div>
  51. </div>
  52. <div class="card">
  53. <div id="loading" class="loading" style="display: none;">加载中...</div>
  54. <div id="empty-state" class="empty-state" style="display: none;">
  55. <svg fill="none" stroke="currentColor" viewBox="0 0 24 24">
  56. <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 12h6m-6 4h6m2 5H7a2 2 0 01-2-2V5a2 2 0 012-2h5.586a1 1 0 01.707.293l5.414 5.414a1 1 0 01.293.707V19a2 2 0 01-2 2z"></path>
  57. </svg>
  58. <p>暂无 License 数据</p>
  59. </div>
  60. <div class="table-container" id="table-container" style="display: none;">
  61. <!-- 筛选和操作栏 -->
  62. <div class="filter-bar">
  63. <div class="filter-group">
  64. <label for="status-filter">状态筛选:</label>
  65. <select id="status-filter" class="filter-select" onchange="handleStatusFilter()">
  66. <option value="">全部</option>
  67. <option value="activated">已激活</option>
  68. <option value="unactivated">未激活</option>
  69. </select>
  70. </div>
  71. <div style="display: flex; gap: 10px;">
  72. <button class="btn btn-primary" id="batch-update-btn" onclick="openBatchUpdateModal()" style="display: none;">
  73. ⚙️ 批量修改最大设备数
  74. </button>
  75. <button class="btn btn-danger" id="batch-delete-btn" onclick="batchDeleteLicenses()" style="display: none;">
  76. 批量删除
  77. </button>
  78. </div>
  79. </div>
  80. <div style="margin-bottom: 15px; display: flex; align-items: center; gap: 10px;">
  81. <input type="checkbox" id="select-all" onchange="toggleSelectAll()" style="width: 18px; height: 18px; cursor: pointer;">
  82. <label for="select-all" style="cursor: pointer; user-select: none;">全选</label>
  83. <span id="selected-count" style="color: #6b7280; font-size: 14px;">已选择 0 项</span>
  84. </div>
  85. <table>
  86. <thead>
  87. <tr>
  88. <th style="width: 50px;">
  89. <input type="checkbox" id="select-all-header" onchange="toggleSelectAll()" style="width: 18px; height: 18px; cursor: pointer;">
  90. </th>
  91. <th>ID</th>
  92. <th>激活码</th>
  93. <th>设备详情</th>
  94. <th>绑定设备数</th>
  95. <th>备注</th>
  96. <th>创建时间</th>
  97. <th>操作</th>
  98. </tr>
  99. </thead>
  100. <tbody id="license-table-body">
  101. </tbody>
  102. </table>
  103. <div class="pagination" id="pagination"></div>
  104. </div>
  105. </div>
  106. </div>
  107. <!-- 创建/编辑 Modal -->
  108. <div id="licenseModal" class="modal">
  109. <div class="modal-content">
  110. <div class="modal-header">
  111. <h2 id="modal-title">创建 License</h2>
  112. <button class="close" onclick="closeModal()">&times;</button>
  113. </div>
  114. <form id="licenseForm" onsubmit="handleSubmit(event)">
  115. <input type="hidden" id="license-id">
  116. <div class="form-group">
  117. <label for="license-key">激活码 *</label>
  118. <input type="text" id="license-key" required placeholder="例如: VIP-8888">
  119. </div>
  120. <div class="form-group">
  121. <label for="license-max-devices">最大设备数 *</label>
  122. <input type="number" id="license-max-devices" required min="1" value="2">
  123. </div>
  124. <div class="form-group">
  125. <label for="license-bound-devices">已绑定设备 (JSON 数组,可选)</label>
  126. <input type="text" id="license-bound-devices" placeholder='例如: ["device-1", "device-2"]'>
  127. </div>
  128. <div class="form-group">
  129. <label for="license-remark">备注 (可选)</label>
  130. <textarea id="license-remark" rows="3" placeholder="请输入备注信息" style="width: 100%; padding: 10px; border: 1px solid #d1d5db; border-radius: 5px; font-size: 14px; font-family: inherit; resize: vertical;"></textarea>
  131. </div>
  132. <div class="form-actions">
  133. <button type="button" class="btn btn-secondary" onclick="closeModal()">取消</button>
  134. <button type="submit" class="btn btn-primary">保存</button>
  135. </div>
  136. </form>
  137. </div>
  138. </div>
  139. <!-- 批量生成 Modal -->
  140. <div id="batchModal" class="modal">
  141. <div class="modal-content">
  142. <div class="modal-header">
  143. <h2>批量生成 License</h2>
  144. <button class="close" onclick="closeBatchModal()">&times;</button>
  145. </div>
  146. <form id="batchForm" onsubmit="handleBatchSubmit(event)">
  147. <div class="form-group">
  148. <label for="batch-prefix">激活码前缀 *</label>
  149. <input type="text" id="batch-prefix" required placeholder="例如: VIP" value="VIP">
  150. <small style="color: #6b7280; font-size: 12px; margin-top: 4px; display: block;">
  151. 生成的激活码格式:前缀-随机32位字符串(如:VIP-A3B9C2D4E5F6G7H8I9J0K1L2M3N4O5P6)
  152. </small>
  153. </div>
  154. <div class="form-group">
  155. <label for="batch-count">生成数量 *</label>
  156. <input type="number" id="batch-count" required min="1" max="1000" value="10">
  157. <small style="color: #6b7280; font-size: 12px; margin-top: 4px; display: block;">
  158. 一次最多可生成 1000 个
  159. </small>
  160. </div>
  161. <div class="form-group">
  162. <label for="batch-max-devices">最大设备数 *</label>
  163. <input type="number" id="batch-max-devices" required min="1" value="2">
  164. </div>
  165. <div class="form-actions">
  166. <button type="button" class="btn btn-secondary" onclick="closeBatchModal()">取消</button>
  167. <button type="submit" class="btn btn-primary">生成</button>
  168. </div>
  169. </form>
  170. </div>
  171. </div>
  172. <!-- 设备列表 Modal -->
  173. <div id="deviceListModal" class="modal device-list-modal">
  174. <div class="modal-content">
  175. <div class="modal-header">
  176. <h2 id="device-list-title">设备列表</h2>
  177. <button class="close" onclick="closeDeviceListModal()">&times;</button>
  178. </div>
  179. <div id="device-list-content">
  180. <div class="device-list-empty">加载中...</div>
  181. </div>
  182. </div>
  183. </div>
  184. <!-- 批量修改最大设备数 Modal -->
  185. <div id="batchUpdateModal" class="modal">
  186. <div class="modal-content">
  187. <div class="modal-header">
  188. <h2>批量修改最大设备数</h2>
  189. <button class="close" onclick="closeBatchUpdateModal()">&times;</button>
  190. </div>
  191. <form id="batchUpdateForm" onsubmit="handleBatchUpdateSubmit(event)">
  192. <div class="form-group">
  193. <label>已选择 <span id="batch-update-count">0</span> 个 License</label>
  194. </div>
  195. <div class="form-group">
  196. <label for="batch-update-max-devices">新的最大设备数 *</label>
  197. <input type="number" id="batch-update-max-devices" required min="1" value="2">
  198. <small style="color: #6b7280; font-size: 12px; margin-top: 4px; display: block;">
  199. 将把选中 License 的最大设备数统一修改为此值
  200. </small>
  201. </div>
  202. <div class="form-actions">
  203. <button type="button" class="btn btn-secondary" onclick="closeBatchUpdateModal()">取消</button>
  204. <button type="submit" class="btn btn-primary">确认修改</button>
  205. </div>
  206. </form>
  207. </div>
  208. </div>
  209. <script src="/web/js/index.js"></script>
  210. </body>
  211. </html>