openlearn-next 0.3.16 → 0.3.19
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.
- package/README.md +21 -22
- package/cli-cleaner.mjs +4 -6
- package/cli-data.mjs +6 -3
- package/cli-doctor.mjs +66 -24
- package/cli.mjs +3 -14
- package/dist/assets/AdminDirectoryView-CGo33RNh.js +1 -0
- package/dist/assets/{BatchPickerModal-DtFV99dt.js → BatchPickerModal-MnNnNwFT.js} +1 -1
- package/dist/assets/ClassesView-CpblTKWg.js +19 -0
- package/dist/assets/{CloudDriveModal-CZ-KJmic.js → CloudDriveModal-BMjXCoju.js} +1 -1
- package/dist/assets/ComputerLabView-DGha_J8B.js +1 -0
- package/dist/assets/CourseManagement-BqlboC1S.js +1 -0
- package/dist/assets/CourseWizardModal-DO1n4T2T.js +3 -0
- package/dist/assets/CoursewareHubPanel-CEK_QEc5.js +1 -0
- package/dist/assets/Dashboard-CfgOPb6z.js +8 -0
- package/dist/assets/ExportWeightModal-d9A2R6Ur.js +1 -0
- package/dist/assets/HelpTour-Dlc1vvy3.js +1 -0
- package/dist/assets/HelpView-bHc3tQPD.js +204 -0
- package/dist/assets/ImportLessonsModal-C25NubUA.js +1 -0
- package/dist/assets/ImportModal-B2acbUT8.js +1 -0
- package/dist/assets/InteractiveCoursewareViewer-BcXVoPUb.js +1 -0
- package/dist/assets/InteractiveWhiteboard-BxvOZE3l.js +78 -0
- package/dist/assets/LazyCourseware-D3_YrYGR.js +2 -0
- package/dist/assets/{LazyWhiteboard-BPtDG81P.js → LazyWhiteboard-CFPDpdYV.js} +2 -2
- package/dist/assets/LessonEditorView-CYHcC9EA.js +1 -0
- package/dist/assets/LiveClassroomView-BSPW9gVe.js +1 -0
- package/dist/assets/{NotificationDetailModal-BSWVptQ9.js → NotificationDetailModal-D4w-m1D-.js} +1 -1
- package/dist/assets/PluginView-DogON4Dd.js +65 -0
- package/dist/assets/ProcessLogsModal-MtK-Pe4R.js +1 -0
- package/dist/assets/QuizGeneratorModal-bCASRfsi.js +1 -0
- package/dist/assets/StudentAssignmentView-B0b4spYC.js +1 -0
- package/dist/assets/StudentLessonView-SLcpNqtY.js +1 -0
- package/dist/assets/StudentPreviewModal-nO5C3nq5.js +1 -0
- package/dist/assets/StudentView-BtleJCxa.js +2 -0
- package/dist/assets/SystemResourceLibraryModal-D00BK5Xh.js +1 -0
- package/dist/assets/TeacherView-BP04D9dn.js +2 -0
- package/dist/assets/TimetableView-Do_LWpV2.js +6 -0
- package/dist/assets/index-CM3Tw-Rg.css +1 -0
- package/dist/assets/index-hTc1h9s2.js +202 -0
- package/dist/assets/{index.es-CfxBkm_z.js → index.es-CkgATcHw.js} +2 -2
- package/dist/assets/{vendor-charts-CRXa4AlU.js → vendor-charts-U9fLlNC_.js} +1 -1
- package/dist/assets/{vendor-icons-Dq6MhgH9.js → vendor-icons-B2DRJfZU.js} +2 -2
- package/dist/assets/{vendor-konva-CzxOmTv9.js → vendor-konva-CEOq4dcl.js} +1 -1
- package/dist/assets/{vendor-pdf-Cp-cYteE.js → vendor-pdf-Bw0ZQZtM.js} +1 -1
- package/dist/assets/{vendor-pptx-B_NheIKl.js → vendor-pptx-C5-U7ieS.js} +1 -1
- package/dist/assets/{vendor-react-0Lg0vA-4.js → vendor-react-B0t7H3hh.js} +10 -10
- package/dist/assets/vendor-utils-m0Urvtws.js +1 -0
- package/dist/index.html +9 -10
- package/dist/server.cjs +2455 -1807
- package/package.json +17 -17
- package/dist/assets/AdminDirectoryView-0XV86Ues.js +0 -1
- package/dist/assets/ClassesView-E_bmIY3c.js +0 -19
- package/dist/assets/ComputerLabView-BId0ZarM.js +0 -1
- package/dist/assets/CourseManagement-DEKMw74G.js +0 -1
- package/dist/assets/CourseWizardModal-B8Q_8YKV.js +0 -3
- package/dist/assets/CoursewareHubPanel-LpUgjqbH.js +0 -1
- package/dist/assets/Dashboard-B2PI302K.js +0 -8
- package/dist/assets/ExportWeightModal-0TpuWHQy.js +0 -1
- package/dist/assets/HelpTour-CHPIK2ae.js +0 -1
- package/dist/assets/HelpView-DvrWFfuf.js +0 -204
- package/dist/assets/ImportLessonsModal-C43YkKNn.js +0 -1
- package/dist/assets/ImportModal-BTfia0Ah.js +0 -1
- package/dist/assets/InteractiveCoursewareViewer-BALndtKl.js +0 -1
- package/dist/assets/InteractiveWhiteboard-Dty2usZE.js +0 -78
- package/dist/assets/LazyCourseware-BRb-N2Gw.js +0 -1
- package/dist/assets/LessonEditorView-ChnEY-M1.js +0 -1
- package/dist/assets/LiveClassroomView-no5n32dK.js +0 -1
- package/dist/assets/PluginView-DofVkA49.js +0 -65
- package/dist/assets/ProcessLogsModal-01S7zsw0.js +0 -1
- package/dist/assets/QuizGeneratorModal-DSbBS1jm.js +0 -1
- package/dist/assets/StudentAssignmentView-Dnim6GN3.js +0 -1
- package/dist/assets/StudentLessonView-Bvb00YZM.js +0 -1
- package/dist/assets/StudentPreviewModal-Cm2dp3tA.js +0 -1
- package/dist/assets/StudentView-Bnpufxoh.js +0 -2
- package/dist/assets/SystemResourceLibraryModal-CeZ6MMQK.js +0 -1
- package/dist/assets/TeacherView-BNRrbsHE.js +0 -2
- package/dist/assets/TimetableView-DJgOlGSf.js +0 -6
- package/dist/assets/index-Cdsp6u2F.js +0 -2
- package/dist/assets/index-D7PQWdtD.css +0 -1
- package/dist/assets/index-D7ZJLlkd.js +0 -193
- package/dist/assets/vendor-utils-BEhuP0Zq.js +0 -1
package/README.md
CHANGED
|
@@ -37,7 +37,7 @@ npm update -g openlearn-next # 更新
|
|
|
37
37
|
|
|
38
38
|
```bash
|
|
39
39
|
npm install
|
|
40
|
-
# AI
|
|
40
|
+
# 启动服务后,在管理后台「AI Provider 管理」中配置大模型提供商
|
|
41
41
|
./dev.sh
|
|
42
42
|
open http://localhost:9000
|
|
43
43
|
```
|
|
@@ -55,31 +55,30 @@ chmod +x deploy.sh
|
|
|
55
55
|
|
|
56
56
|
## npm 脚本
|
|
57
57
|
|
|
58
|
-
| 命令
|
|
59
|
-
|
|
60
|
-
| `npm run dev`
|
|
58
|
+
| 命令 | 说明 |
|
|
59
|
+
| --------------- | -------------------------- |
|
|
60
|
+
| `npm run dev` | 启动开发服务(端口 9000) |
|
|
61
61
|
| `npm run build` | 生产构建(Vite + esbuild) |
|
|
62
|
-
| `npm start`
|
|
63
|
-
| `npm test`
|
|
64
|
-
| `npm run lint`
|
|
62
|
+
| `npm start` | 运行生产构建 |
|
|
63
|
+
| `npm test` | 运行测试 |
|
|
64
|
+
| `npm run lint` | TypeScript 类型检查 |
|
|
65
65
|
|
|
66
66
|
## 环境变量
|
|
67
67
|
|
|
68
|
-
| 变量
|
|
69
|
-
|
|
70
|
-
| `ENCRYPTION_KEY`
|
|
71
|
-
| `PORT`
|
|
72
|
-
| `OPENLEARN_DB_PATH` |
|
|
73
|
-
| `
|
|
74
|
-
| `
|
|
75
|
-
| `LOG_LEVEL` | — | 日志级别(debug / info / warn / error),默认 info |
|
|
68
|
+
| 变量 | 必需 | 说明 |
|
|
69
|
+
| ------------------- | :--: | ------------------------------------------------------------------------------ |
|
|
70
|
+
| `ENCRYPTION_KEY` | ✅ | 64 位 hex,AI Provider API Key 加密密钥(`deploy.sh` 自动生成) |
|
|
71
|
+
| `PORT` | — | 服务端口,默认 9000 |
|
|
72
|
+
| `OPENLEARN_DB_PATH` | — | SQLite 数据库路径(npx 默认 `~/openlearn-next/data.db`,本地开发默认项目目录) |
|
|
73
|
+
| `ALLOWED_ORIGINS` | — | CORS 白名单,逗号分隔 |
|
|
74
|
+
| `LOG_LEVEL` | — | 日志级别(debug / info / warn / error),默认 info |
|
|
76
75
|
|
|
77
76
|
## 文档链接
|
|
78
77
|
|
|
79
|
-
| 主题
|
|
80
|
-
|
|
81
|
-
| 📖 文档中心
|
|
82
|
-
| 🚀 快速开始
|
|
83
|
-
| 🎓 插件开发
|
|
84
|
-
| 🛠 插件开发参考 | <https://openlearn-next-v2.readthedocs.io/zh-cn/latest/reference/plugin-database-api.html>
|
|
85
|
-
| 🔄 版本迁移
|
|
78
|
+
| 主题 | 链接 |
|
|
79
|
+
| -------------- | -------------------------------------------------------------------------------------------------- |
|
|
80
|
+
| 📖 文档中心 | <https://openlearn-next-v2.readthedocs.io/zh-cn/latest/> |
|
|
81
|
+
| 🚀 快速开始 | <https://openlearn-next-v2.readthedocs.io/zh-cn/latest/getting-started/quickstart.html> |
|
|
82
|
+
| 🎓 插件开发 | <https://openlearn-next-v2.readthedocs.io/zh-cn/latest/tutorials/plugin-development-tutorial.html> |
|
|
83
|
+
| 🛠 插件开发参考 | <https://openlearn-next-v2.readthedocs.io/zh-cn/latest/reference/plugin-database-api.html> |
|
|
84
|
+
| 🔄 版本迁移 | <https://openlearn-next-v2.readthedocs.io/zh-cn/latest/migration/version-migration.html> |
|
package/cli-cleaner.mjs
CHANGED
|
@@ -102,13 +102,11 @@ export function runClean(options = {}) {
|
|
|
102
102
|
if (isAll || isOnlyDb || isDefault) {
|
|
103
103
|
const dataDir = options.customDataDir
|
|
104
104
|
? resolve(options.customDataDir)
|
|
105
|
-
:
|
|
106
|
-
|
|
107
|
-
|
|
105
|
+
: process.env.OPENLEARN_DB_PATH
|
|
106
|
+
? dirname(resolve(process.env.OPENLEARN_DB_PATH))
|
|
107
|
+
: join(os.homedir(), 'openlearn-next');
|
|
108
108
|
|
|
109
|
-
const dbPath = process.env.OPENLEARN_DB_PATH
|
|
110
|
-
? resolve(process.env.OPENLEARN_DB_PATH)
|
|
111
|
-
: join(dataDir, 'data.db');
|
|
109
|
+
const dbPath = process.env.OPENLEARN_DB_PATH ? resolve(process.env.OPENLEARN_DB_PATH) : join(dataDir, 'data.db');
|
|
112
110
|
|
|
113
111
|
const walPath = `${dbPath}-wal`;
|
|
114
112
|
const shmPath = `${dbPath}-shm`;
|
package/cli-data.mjs
CHANGED
|
@@ -170,8 +170,9 @@ export async function runResetAdmin(newPassword = 'admin', options = {}) {
|
|
|
170
170
|
|
|
171
171
|
if (updateRes.changes === 0) {
|
|
172
172
|
// 若数据库中无 admin 用户,则插入
|
|
173
|
-
db.prepare(
|
|
174
|
-
|
|
173
|
+
db.prepare(
|
|
174
|
+
'INSERT INTO users (id, username, password_hash, role, name, created_at) VALUES (?, ?, ?, ?, ?, ?)',
|
|
175
|
+
).run(`usr_admin_${Date.now()}`, 'admin', hash, 'administrator', 'System Admin', Date.now());
|
|
175
176
|
log(`✓ 管理员账号不存在,已新建管理员账号: admin (密码: ${newPassword})`);
|
|
176
177
|
} else {
|
|
177
178
|
log(`✓ 管理员 (admin) 密码已成功重置为: ${newPassword}`);
|
|
@@ -240,7 +241,9 @@ export async function runPluginsList(options = {}) {
|
|
|
240
241
|
|
|
241
242
|
console.log(`\n${bold}${cyan}已安装插件清单 (${plugins.length} 个):${reset}`);
|
|
242
243
|
console.log(`┌──────────────────────────────────────────────┬─────────┬──────────┬──────────┐`);
|
|
243
|
-
console.log(
|
|
244
|
+
console.log(
|
|
245
|
+
`│ ${bold}Plugin ID${reset}${' '.repeat(37)}│ ${bold}Version${reset} │ ${bold}Status${reset} │ ${bold}Mode${reset} │`,
|
|
246
|
+
);
|
|
244
247
|
console.log(`├──────────────────────────────────────────────┼─────────┼──────────┼──────────┤`);
|
|
245
248
|
|
|
246
249
|
for (const p of plugins) {
|
package/cli-doctor.mjs
CHANGED
|
@@ -129,7 +129,8 @@ export function checkSdkConsistency(_fix = false, _fixes = []) {
|
|
|
129
129
|
}
|
|
130
130
|
|
|
131
131
|
const installed = JSON.parse(fs.readFileSync(path.join(pkgDir, 'package.json'), 'utf-8')).version;
|
|
132
|
-
const isWorkspace =
|
|
132
|
+
const isWorkspace =
|
|
133
|
+
fs.existsSync(path.join(__dirname, 'pnpm-workspace.yaml')) && pkgDir.includes('packages/plugin-sdk');
|
|
133
134
|
|
|
134
135
|
// 尝试识别 @openlearn/plugin-test-kit 版本
|
|
135
136
|
let testKitInfo = '';
|
|
@@ -163,7 +164,11 @@ export function checkSdkConsistency(_fix = false, _fixes = []) {
|
|
|
163
164
|
if (compareVersions(installed, spec) === 0) {
|
|
164
165
|
return check('ok', `v${installed} 与精确 pin ${spec} 一致${testKitInfo}`);
|
|
165
166
|
}
|
|
166
|
-
return check(
|
|
167
|
+
return check(
|
|
168
|
+
'err',
|
|
169
|
+
`解析到 v${installed},与精确 pin ${spec} 不一致(版本漂移)— server.cjs 构建所用 SDK 与运行时不符,请 npm install 修复`,
|
|
170
|
+
true,
|
|
171
|
+
);
|
|
167
172
|
} catch (e) {
|
|
168
173
|
return check('err', `无法解析 ${SDK}: ${e.message}`);
|
|
169
174
|
}
|
|
@@ -179,13 +184,43 @@ export function checkCorePluginsCompatibility() {
|
|
|
179
184
|
const curVer = fs.existsSync(pkgPath) ? JSON.parse(fs.readFileSync(pkgPath, 'utf-8')).version : '0.3.9';
|
|
180
185
|
|
|
181
186
|
const CORE_PLUGINS = [
|
|
182
|
-
{
|
|
187
|
+
{
|
|
188
|
+
id: '@openlearn/plugin-builtin',
|
|
189
|
+
name: 'Classroom Builtin Plugin',
|
|
190
|
+
file: 'builtin.ts',
|
|
191
|
+
defaultEngine: '>=0.2.5',
|
|
192
|
+
},
|
|
183
193
|
{ id: '@openlearn/plugin-vfs', name: 'Virtual File System Plugin', file: 'vfs.ts', defaultEngine: '>=0.2.5' },
|
|
184
|
-
{
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
194
|
+
{
|
|
195
|
+
id: '@openlearn/plugin-process',
|
|
196
|
+
name: 'Background Process Plugin',
|
|
197
|
+
file: 'process.ts',
|
|
198
|
+
defaultEngine: '>=0.2.5',
|
|
199
|
+
},
|
|
200
|
+
{
|
|
201
|
+
id: '@openlearn/plugin-management',
|
|
202
|
+
name: 'LMS Management Plugin',
|
|
203
|
+
file: 'management.ts',
|
|
204
|
+
defaultEngine: '>=0.2.5',
|
|
205
|
+
},
|
|
206
|
+
{
|
|
207
|
+
id: '@openlearn/plugin-ai-planner',
|
|
208
|
+
name: 'AI Planner Plugin',
|
|
209
|
+
file: 'ai-planner.ts',
|
|
210
|
+
defaultEngine: '>=0.2.5',
|
|
211
|
+
},
|
|
212
|
+
{
|
|
213
|
+
id: '@openlearn/plugin-ai-submit-injector',
|
|
214
|
+
name: 'AI Submit Injector Plugin',
|
|
215
|
+
file: 'ai-submit-injector.ts',
|
|
216
|
+
defaultEngine: '>=0.2.5',
|
|
217
|
+
},
|
|
218
|
+
{
|
|
219
|
+
id: '@openlearn/plugin-assignment-eval',
|
|
220
|
+
name: 'Assignment Evaluation Plugin',
|
|
221
|
+
file: 'assignment-eval.ts',
|
|
222
|
+
defaultEngine: '>=0.2.5',
|
|
223
|
+
},
|
|
189
224
|
];
|
|
190
225
|
|
|
191
226
|
const incompatible = [];
|
|
@@ -242,9 +277,9 @@ export async function checkInstalledPluginsCompatibility(options = {}) {
|
|
|
242
277
|
|
|
243
278
|
const dbPath = options.dbPath
|
|
244
279
|
? path.resolve(options.dbPath)
|
|
245
|
-
:
|
|
246
|
-
|
|
247
|
-
|
|
280
|
+
: process.env.OPENLEARN_DB_PATH
|
|
281
|
+
? path.resolve(process.env.OPENLEARN_DB_PATH)
|
|
282
|
+
: path.join(os.homedir(), 'openlearn-next', 'data.db');
|
|
248
283
|
|
|
249
284
|
const plugins = [];
|
|
250
285
|
const incompatible = [];
|
|
@@ -257,7 +292,9 @@ export async function checkInstalledPluginsCompatibility(options = {}) {
|
|
|
257
292
|
const db = new Database(dbPath, { readonly: true });
|
|
258
293
|
const tableCheck = db.prepare("SELECT name FROM sqlite_master WHERE type='table' AND name='plugins'").get();
|
|
259
294
|
if (tableCheck) {
|
|
260
|
-
const rows = db
|
|
295
|
+
const rows = db
|
|
296
|
+
.prepare("SELECT id, name, manifest, status FROM plugins WHERE id NOT LIKE '@openlearn/plugin-%'")
|
|
297
|
+
.all();
|
|
261
298
|
for (const row of rows) {
|
|
262
299
|
let manifest = null;
|
|
263
300
|
if (row.manifest) {
|
|
@@ -341,7 +378,10 @@ export async function checkInstalledPluginsCompatibility(options = {}) {
|
|
|
341
378
|
return check('warn', `发现 ${incompatible.length} 个插件与当前平台版本不兼容: ${incompatible.join('; ')}`);
|
|
342
379
|
}
|
|
343
380
|
|
|
344
|
-
const sample = plugins
|
|
381
|
+
const sample = plugins
|
|
382
|
+
.slice(0, 2)
|
|
383
|
+
.map((p) => `${p.id} v${p.version}`)
|
|
384
|
+
.join(', ');
|
|
345
385
|
const more = plugins.length > 2 ? ` 等 ${plugins.length} 个` : '';
|
|
346
386
|
return check('ok', `${plugins.length} 个扩展插件 (${sample}${more}) 全部与平台 v${curVer} 兼容`);
|
|
347
387
|
} catch (e) {
|
|
@@ -377,16 +417,17 @@ export function checkCoreVersionDrift(fix = false, fixes = []) {
|
|
|
377
417
|
}
|
|
378
418
|
|
|
379
419
|
if (fix) {
|
|
380
|
-
const updated = coreContent.replace(
|
|
381
|
-
/PLATFORM_VERSION\s*=\s*['"][^'"]+['"]/,
|
|
382
|
-
`PLATFORM_VERSION = '${pkgVer}'`
|
|
383
|
-
);
|
|
420
|
+
const updated = coreContent.replace(/PLATFORM_VERSION\s*=\s*['"][^'"]+['"]/, `PLATFORM_VERSION = '${pkgVer}'`);
|
|
384
421
|
fs.writeFileSync(coreVersionFile, updated, 'utf-8');
|
|
385
422
|
fixes.push(`已自动将 packages/core/version.ts 同步为 v${pkgVer}`);
|
|
386
423
|
return check('ok', `v${pkgVer} (已自动修复版本漂移: 从 v${coreVer} 同步为 v${pkgVer})`);
|
|
387
424
|
}
|
|
388
425
|
|
|
389
|
-
return check(
|
|
426
|
+
return check(
|
|
427
|
+
'err',
|
|
428
|
+
`检测到内核版本漂移: package.json (v${pkgVer}) 与 packages/core/version.ts (v${coreVer}) 不一致!`,
|
|
429
|
+
true,
|
|
430
|
+
);
|
|
390
431
|
} catch (e) {
|
|
391
432
|
return check('err', `版本一致性检查失败: ${e.message}`);
|
|
392
433
|
}
|
|
@@ -420,7 +461,7 @@ export function checkNpxCacheDrift(fix = false, fixes = []) {
|
|
|
420
461
|
return check(
|
|
421
462
|
'warn',
|
|
422
463
|
`发现 ${stale.length} 个旧版 NPX 缓存 (${staleVersions.join(', ')}),npx 执行可能因缓存发生版本漂移`,
|
|
423
|
-
true
|
|
464
|
+
true,
|
|
424
465
|
);
|
|
425
466
|
} catch (e) {
|
|
426
467
|
return check('warn', `NPX 缓存扫描失败: ${e.message}`);
|
|
@@ -522,9 +563,9 @@ export async function runDoctor(options = {}) {
|
|
|
522
563
|
// 3. 数据库目录与读写权限
|
|
523
564
|
const dbPath = options.dbPath
|
|
524
565
|
? path.resolve(options.dbPath)
|
|
525
|
-
:
|
|
526
|
-
|
|
527
|
-
|
|
566
|
+
: process.env.OPENLEARN_DB_PATH
|
|
567
|
+
? path.resolve(process.env.OPENLEARN_DB_PATH)
|
|
568
|
+
: path.join(os.homedir(), 'openlearn-next', 'data.db');
|
|
528
569
|
const dbDir = path.dirname(dbPath);
|
|
529
570
|
|
|
530
571
|
try {
|
|
@@ -632,7 +673,9 @@ export async function runDoctor(options = {}) {
|
|
|
632
673
|
|
|
633
674
|
const hasFixableIssues = checks.some((c) => c.status !== 'ok' && c.fixable);
|
|
634
675
|
if (!fix && hasFixableIssues) {
|
|
635
|
-
console.log(
|
|
676
|
+
console.log(
|
|
677
|
+
`\n ${yellow}💡 提示: 检测到可通过自愈修复的问题,运行 'npx openlearn-next doctor --fix' 即可一键自动修复。${reset}`,
|
|
678
|
+
);
|
|
636
679
|
}
|
|
637
680
|
|
|
638
681
|
console.log(`\n${cyan}───────────────────────────────────────────────────────────────${reset}`);
|
|
@@ -645,4 +688,3 @@ export async function runDoctor(options = {}) {
|
|
|
645
688
|
|
|
646
689
|
return { ok: allOk, checks, fixes };
|
|
647
690
|
}
|
|
648
|
-
|
package/cli.mjs
CHANGED
|
@@ -27,15 +27,7 @@ export function parseCliArgs(rawArgs) {
|
|
|
27
27
|
}
|
|
28
28
|
}
|
|
29
29
|
|
|
30
|
-
const KNOWN_COMMANDS = new Set([
|
|
31
|
-
'doctor',
|
|
32
|
-
'backup',
|
|
33
|
-
'restore',
|
|
34
|
-
'reset-admin',
|
|
35
|
-
'plugins',
|
|
36
|
-
'clean',
|
|
37
|
-
'clean-cache',
|
|
38
|
-
]);
|
|
30
|
+
const KNOWN_COMMANDS = new Set(['doctor', 'backup', 'restore', 'reset-admin', 'plugins', 'clean', 'clean-cache']);
|
|
39
31
|
|
|
40
32
|
const ALIAS_COMMAND_MAP = {
|
|
41
33
|
'--doctor': 'doctor',
|
|
@@ -136,9 +128,8 @@ export function parseCliArgs(rawArgs) {
|
|
|
136
128
|
}
|
|
137
129
|
|
|
138
130
|
// 兼容 plugins list 子参数
|
|
139
|
-
const subcommandArgs =
|
|
140
|
-
? positionalArgs.slice(1)
|
|
141
|
-
: positionalArgs;
|
|
131
|
+
const subcommandArgs =
|
|
132
|
+
command === 'plugins' && positionalArgs[0] === 'list' ? positionalArgs.slice(1) : positionalArgs;
|
|
142
133
|
|
|
143
134
|
return { command, subcommandArgs, flags };
|
|
144
135
|
}
|
|
@@ -199,7 +190,6 @@ Environment Variables:
|
|
|
199
190
|
HOST 监听主机地址 (默认: 0.0.0.0)
|
|
200
191
|
OPENLEARN_DB_PATH SQLite 数据库绝对路径 (默认: ~/openlearn-next/data.db)
|
|
201
192
|
ALLOWED_ORIGINS CORS 白名单来源 (默认放行同源与开发环境)
|
|
202
|
-
GEMINI_API_KEY AI 助手兜底密钥 (推荐在管理员后台界面配置)
|
|
203
193
|
`);
|
|
204
194
|
process.exit(0);
|
|
205
195
|
}
|
|
@@ -343,4 +333,3 @@ const isMain =
|
|
|
343
333
|
if (isMain) {
|
|
344
334
|
runCli();
|
|
345
335
|
}
|
|
346
|
-
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{r as i,j as e}from"./vendor-react-B0t7H3hh.js";import{S as T,Y as ts,a5 as g,U as D,bb as as,t as M,aJ as R,aw as rs,_ as Ae,aE as is,n as le,x as ls,e as _,s as ns,h as os,bc as Ce,w as Le,v as cs,z as Ue,at as ds,X as ne,b6 as xs,T as ms,ar as hs,aC as ps}from"./vendor-icons-B2DRJfZU.js";import"./vendor-utils-m0Urvtws.js";function bs({currentUserId:m,currentUserRole:u,lang:s,onLogout:oe,aiProviders:w,testingProviderId:ce,onAIProvidersChanged:f,onTriggerTour:z,siteInfo:h,onSiteInfoChanged:Pe}){const[de,Ie]=i.useState([]),[Te,xe]=i.useState(!1),[me,E]=i.useState(""),[he,p]=i.useState(""),[De,y]=i.useState(!1),[$,j]=i.useState(null),[O,F]=i.useState(""),[q,B]=i.useState(""),[pe,Q]=i.useState(""),[V,K]=i.useState(""),[G,be]=i.useState(!1),[ge,ue]=i.useState(h?.siteName||""),[fe,ye]=i.useState(h?.slogan||""),[gs,k]=i.useState(h?.logoUrl||null),[b,S]=i.useState(h?.logoUrl||""),[H,je]=i.useState(!1),[Ne,Me]=i.useState(!1),[A,ve]=i.useState(""),[J,Re]=i.useState("all"),[_e,N]=i.useState(!1),[d,we]=i.useState(null),[Y,W]=i.useState(""),[X,Z]=i.useState(""),[ee,se]=i.useState(""),[te,C]=i.useState("teacher"),[ae,L]=i.useState("active"),[ze,x]=i.useState(""),[re,ke]=i.useState(!1),[us,fs]=i.useState({tables:14,sizeKb:256,pingMs:2}),[Ee,$e]=i.useState(14),[Oe,Fe]=i.useState(0),[o,U]=i.useState("directory"),[r,qe]=i.useState(null),[v,Se]=i.useState(!1),P=async()=>{try{Se(!0);const t=await fetch("/api/db-status");if(t.ok){const a=await t.json();qe(a)}}catch(t){console.error("Failed to query SQLite stats",t)}finally{Se(!1)}},Be=()=>{j(null),F(""),B(""),Q(""),K(""),y(!0)},Qe=t=>{j(t),F(t.name),B(t.api_url),Q(t.api_key||""),K(t.model_name),y(!0)},Ve=async t=>{if(t.preventDefault(),!O.trim()||!q.trim()||!V.trim()){alert(s==="zh"?"名称、API URL 和模型名称不可为空":"Name, API URL and Model Name are required.");return}try{be(!0);const a=!!$,l=a?`/api/ai-providers/${$.id}`:"/api/ai-providers",c=await fetch(l,{method:a?"PUT":"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:O.trim(),api_url:q.trim(),api_key:pe,model_name:V.trim()})});if(c.ok)y(!1),j(null),f();else{const ss=await c.json().catch(()=>({}));alert(ss.error||"Server error")}}catch(a){alert(a.message||"Error")}finally{be(!1)}},Ke=async(t,a)=>{if(confirm(s==="zh"?`确认要删除 AI 提供商 [${a}] 吗?`:`Confirm deleting AI Provider [${a}]?`))try{(await fetch(`/api/ai-providers/${t}`,{method:"DELETE"})).ok?f():alert("Delete failed")}catch(l){alert(l.message||"Error")}},Ge=async t=>{try{const a=await fetch("/api/ai-providers/test",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({api_url:t.api_url,api_key:t.api_key,model_name:t.model_name})});if(a.ok)alert(s==="zh"?`[${t.name}] 连接测试成功!`:`[${t.name}] Connection test successful!`);else{const l=await a.json().catch(()=>({}));alert(s==="zh"?`测试失败: ${l.error||"未知错误"}`:`Test failed: ${l.error||"Unknown error"}`)}}catch(a){alert(s==="zh"?`网络异常: ${a.message}`:`Network error: ${a.message}`)}},He=async()=>{try{const t=await fetch("/api/site-settings");if(t.ok){const a=await t.json();ue(a.siteName||""),ye(a.slogan||""),k(a.logoUrl||null),S(a.logoUrl||""),Me(!0)}}catch(t){console.error("Failed to fetch site settings",t)}},Je=t=>{if(!t)return;const a=new FileReader;a.onload=()=>{const l=a.result;k(l),S(l)},a.readAsDataURL(t)},Ye=async t=>{t.preventDefault();try{je(!0);const a=b&&b.trim()?b.trim():null,l=await fetch("/api/site-settings",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({siteName:ge.trim(),slogan:fe.trim(),logoUrl:a})});if(l.ok){const n=await l.json();k(a),Pe?.(n.siteInfo),p(s==="zh"?"站点信息已保存!":"Site settings saved successfully!"),setTimeout(()=>p(""),4e3)}else{const n=await l.json().catch(()=>({}));alert(n.error||"Server error")}}catch(a){alert(a.message||"Error")}finally{je(!1)}},ie=async()=>{try{xe(!0),E("");const t=await fetch("/api/users");if(t.ok){const a=await t.json();Ie(a)}else E(s==="zh"?"加载用户账户失败":"Failed to fetch staff directory")}catch{E(s==="zh"?"网络连接异常":"Network communication issue")}finally{xe(!1)}};i.useEffect(()=>{ie(),P(),f();const t=setInterval(()=>{P(),$e(a=>{const l=Math.floor(Math.random()*9)-4,n=a+l;return Math.min(Math.max(n,5),35)})},5e3);return()=>clearInterval(t)},[Oe]),i.useEffect(()=>{o==="site_settings"&&!Ne&&He()},[o,Ne]);const We=()=>{we(null),W(""),Z(""),se(""),C("teacher"),L("active"),x(""),N(!0)},Xe=t=>{we(t.id),W(t.username),Z(""),se(t.name),C(t.role),L(t.status||"active"),x(""),N(!0)},Ze=async t=>{if(t.preventDefault(),!Y.trim()||!ee.trim()){x(s==="zh"?"请填写所有必填字段。":"Please provide all key info.");return}if(!d&&!X){x(s==="zh"?"新建账户时密码必填。":"Password is required for new accounts.");return}try{x(""),ke(!0);const a=d?`/api/users/${d}`:"/api/users",n=await fetch(a,{method:d?"PUT":"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({username:Y.trim(),password:X||void 0,role:te,name:ee.trim(),status:ae})});if(n.ok)p(s==="zh"?"账户信息保存成功!":"Staff account saved successfully!"),ie(),N(!1),setTimeout(()=>p(""),4e3);else{const c=await n.json();x(c.error||"Server validation failed")}}catch(a){x(a.message||"API error")}finally{ke(!1)}},es=async(t,a)=>{if(t===m){alert(s==="zh"?"你不能删除你自己当前登录的账户。":"You cannot delete your own logged-in account.");return}const l=s==="zh"?`确定要删除教师账户 "${a}" 吗?此操作不可逆。`:`Confirm deleting staff user "${a}"? This action is irreversible.`;if(confirm(l))try{const n=await fetch(`/api/users/${t}`,{method:"DELETE"});if(n.ok)p(s==="zh"?"账户删除成功":"Account deleted successfully"),ie(),setTimeout(()=>p(""),3e3);else{const c=await n.json();alert(c.error||"Failed to delete")}}catch(n){console.error(n)}},I=de.filter(t=>{const a=t.name.toLowerCase().includes(A.toLowerCase())||t.username.toLowerCase().includes(A.toLowerCase()),l=J==="all"||t.role===J;return a&&l});return e.jsxs("div",{className:"flex-1 bg-white border border-gray-200 rounded-xl shadow-sm flex flex-col min-h-0 overflow-hidden h-full",id:"admin_panel_root",children:[e.jsxs("div",{className:"px-6 py-4 border-b border-gray-100 flex flex-col sm:flex-row sm:items-center justify-between gap-3 bg-white shrink-0",children:[e.jsxs("div",{children:[e.jsxs("h2",{className:"text-base sm:text-lg font-bold text-gray-800 flex items-center gap-2",children:[e.jsx(T,{className:"text-indigo-600 shrink-0",size:20}),e.jsx("span",{children:s==="zh"?"系统管理与教职后台":"Staff Directory & System Admin"}),e.jsx("span",{className:"text-xs font-semibold px-2 py-0.5 rounded-full bg-indigo-50 text-indigo-700 border border-indigo-100/80",children:u==="administrator"?s==="zh"?"超级管理员":"Admin":s==="zh"?"教师":"Teacher"})]}),e.jsx("p",{className:"text-xs text-gray-500 mt-1",children:s==="zh"?`管理学校教师、教工账户、划分角色权限。当前登录角色权限: ${u==="administrator"?"超级管理员 (系统设置已解锁)":"普通教师 (系统设置锁定)"}`:`Create and assign teacher credentials. Active role context: ${u==="administrator"?"Administrator (System parameters editable)":"Standard Teacher (Settings view-only)"}`})]}),e.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[z&&e.jsxs("button",{onClick:z,className:"flex items-center gap-1.5 px-3 py-1.5 bg-indigo-50 hover:bg-indigo-100 text-indigo-700 text-xs font-semibold rounded-lg border border-indigo-200 transition-all cursor-pointer shadow-3xs",children:[e.jsx(ts,{size:14,className:"animate-bounce"}),e.jsx("span",{children:s==="zh"?"开启新手引导":"Start Help Tour"})]}),e.jsx("button",{onClick:()=>Fe(t=>t+1),className:"p-1.5 text-gray-500 hover:text-indigo-600 hover:bg-gray-100 rounded-lg transition-all cursor-pointer border border-gray-200 shadow-3xs",title:s==="zh"?"刷新数据":"Refresh stats",children:e.jsx(g,{size:14})})]})]}),e.jsx("div",{className:"px-6 py-2.5 border-b border-gray-100 bg-gray-50/50 flex items-center justify-between gap-4 shrink-0 overflow-x-auto",children:e.jsxs("div",{className:"bg-gray-200/60 p-1 rounded-xl flex items-center gap-1 shrink-0",children:[e.jsxs("button",{onClick:()=>U("directory"),className:`px-3.5 py-1.5 text-xs font-bold rounded-lg flex items-center gap-1.5 transition-all cursor-pointer ${o==="directory"?"bg-white text-indigo-700 shadow-xs":"text-gray-500 hover:text-gray-800"}`,children:[e.jsx(D,{size:14}),e.jsx("span",{children:s==="zh"?"学校教职及系统配置":"Staff Accounts & Config"})]}),e.jsxs("button",{onClick:()=>U("ai_providers"),className:`px-3.5 py-1.5 text-xs font-bold rounded-lg flex items-center gap-1.5 transition-all cursor-pointer ${o==="ai_providers"?"bg-white text-indigo-700 shadow-xs":"text-gray-500 hover:text-gray-800"}`,children:[e.jsx(as,{size:14}),e.jsx("span",{children:s==="zh"?"AI 模型提供商":"AI Providers"})]}),e.jsxs("button",{onClick:()=>U("sqlite"),className:`px-3.5 py-1.5 text-xs font-bold rounded-lg flex items-center gap-1.5 transition-all cursor-pointer ${o==="sqlite"?"bg-white text-indigo-700 shadow-xs":"text-gray-500 hover:text-gray-800"}`,children:[e.jsx(M,{size:14}),e.jsx("span",{children:s==="zh"?"系统监控":"System Monitor"})]}),e.jsxs("button",{onClick:()=>U("site_settings"),className:`px-3.5 py-1.5 text-xs font-bold rounded-lg flex items-center gap-1.5 transition-all cursor-pointer ${o==="site_settings"?"bg-white text-indigo-700 shadow-xs":"text-gray-500 hover:text-gray-800"}`,children:[e.jsx(R,{size:14}),e.jsx("span",{children:s==="zh"?"站点信息设置":"Site Settings"})]})]})}),he&&e.jsxs("div",{className:"mx-6 mt-3 p-3 bg-emerald-50 border border-emerald-200 text-emerald-800 text-xs rounded-xl flex items-center gap-2 shrink-0 animate-fade-in shadow-xs font-medium",children:[e.jsx(rs,{size:15}),e.jsx("span",{children:he})]}),me&&e.jsxs("div",{className:"mx-6 mt-3 p-3 bg-rose-50 border border-rose-200 text-rose-800 text-xs rounded-xl flex items-center gap-2 shrink-0 animate-fade-in shadow-xs",children:[e.jsx(Ae,{size:15}),e.jsx("span",{children:me})]}),o==="ai_providers"?e.jsx("div",{className:"flex-1 overflow-y-auto p-6 space-y-6 animate-fade-in text-gray-800",children:e.jsxs("div",{className:"bg-white border border-gray-200 rounded-xl shadow-3xs overflow-hidden",children:[e.jsxs("div",{className:"p-4 sm:p-5 border-b border-gray-100 flex items-center justify-between bg-gray-50/60",children:[e.jsxs("div",{children:[e.jsxs("h3",{className:"font-bold text-gray-800 flex items-center gap-2 text-sm sm:text-base",children:[e.jsx(is,{className:"text-indigo-600",size:18}),s==="zh"?"OpenAI 兼容 / 自定义模型 AI 提供商列表":"AI Providers List (OpenAI-Compatible)"]}),e.jsx("p",{className:"text-xs text-gray-400 mt-0.5",children:s==="zh"?"配置好的端点将可被测验生成器、讲座生成器和 AI Agent 进行热切调用。":"Configured backends accessible by Quiz Generator, Lecture Generator and AI Agent."})]}),e.jsxs("button",{onClick:Be,className:"flex items-center gap-1.5 px-3.5 py-1.5 bg-indigo-600 hover:bg-indigo-700 text-white font-semibold rounded-lg shadow-sm transition-all text-xs cursor-pointer",children:[e.jsx(le,{size:14}),s==="zh"?"添加 AI 提供商":"Add AI Provider"]})]}),e.jsx("div",{className:"p-4 sm:p-5",children:w.length===0?e.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-gray-400 text-center",children:[e.jsx(ls,{size:40,className:"mb-3 opacity-30 text-indigo-500"}),e.jsx("span",{className:"font-semibold text-sm",children:s==="zh"?"暂未配置任何 AI 提供商":"No AI Providers Registered"}),e.jsx("p",{className:"text-xs text-gray-400 mt-1 max-w-xs",children:s==="zh"?"点击右上角按钮新建。":"Click the button above to add one."})]}):e.jsx("div",{className:"overflow-x-auto border border-gray-100 rounded-xl",children:e.jsxs("table",{className:"w-full text-left border-collapse min-w-[700px]",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"bg-slate-50/70 border-b border-gray-100 text-gray-500 font-bold text-xs uppercase tracking-wider",children:[e.jsx("th",{className:"py-3.5 px-4",children:s==="zh"?"名称":"Name"}),e.jsx("th",{className:"py-3.5 px-4",children:s==="zh"?"API 端点 URL":"API Endpoint URL"}),e.jsx("th",{className:"py-3.5 px-4",children:s==="zh"?"模型代号":"Model Identifier"}),e.jsx("th",{className:"py-3.5 px-4",children:s==="zh"?"密钥状态":"API Key"}),e.jsx("th",{className:"py-3.5 px-4 text-center",children:s==="zh"?"操作":"Actions"})]})}),e.jsx("tbody",{className:"divide-y divide-gray-100 text-xs text-gray-700",children:w.map(t=>e.jsxs("tr",{className:"hover:bg-slate-50/50 transition-colors",children:[e.jsx("td",{className:"py-4 px-4",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"w-2 h-2 rounded-full bg-indigo-500"}),e.jsx("span",{className:"font-extrabold text-gray-800 text-sm",children:t.name})]})}),e.jsx("td",{className:"py-4 px-4 font-mono text-gray-550 truncate max-w-[220px]",children:t.api_url}),e.jsx("td",{className:"py-4 px-4",children:e.jsx("span",{className:"bg-slate-100 text-slate-800 font-bold px-2 py-1 rounded font-mono text-xs border border-slate-200",children:t.model_name})}),e.jsx("td",{className:"py-4 px-4",children:t.api_key?e.jsxs("span",{className:"text-emerald-600 font-bold flex items-center gap-1 font-mono",children:[e.jsx(_,{size:12})," Key Saved"]}):e.jsx("span",{className:"text-amber-500/90 font-mono italic",children:"Not Set"})}),e.jsx("td",{className:"py-4 px-4 text-center",children:e.jsxs("div",{className:"flex items-center justify-center gap-2",children:[e.jsxs("button",{onClick:()=>Ge(t),className:"px-2.5 py-1 text-xs font-semibold rounded-lg border transition-all cursor-pointer flex items-center gap-1.5 shadow-3xs bg-emerald-50 border-emerald-200 text-emerald-700 hover:bg-emerald-100",title:s==="zh"?"测试连通性":"Test Connection",children:[e.jsx(ns,{size:11}),e.jsx("span",{children:s==="zh"?"测试":"Test"})]}),e.jsx("button",{onClick:()=>Qe(t),className:"px-2.5 py-1 text-indigo-700 hover:bg-indigo-100 border border-indigo-200 rounded-lg bg-indigo-50 cursor-pointer font-semibold transition-all shadow-3xs",title:s==="zh"?"编辑配置":"Edit",children:s==="zh"?"编辑":"Edit"}),e.jsx("button",{onClick:()=>Ke(t.id,t.name),className:"px-2.5 py-1 text-rose-600 hover:bg-rose-100 border border-rose-200 rounded-lg bg-rose-50 cursor-pointer font-semibold transition-all shadow-3xs",title:s==="zh"?"删除":"Delete",children:s==="zh"?"删除":"Delete"})]})})]},t.id))})]})})})]})}):o==="sqlite"?e.jsxs("div",{className:"flex-1 overflow-y-auto p-6 space-y-6 animate-fade-in text-gray-800",children:[e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-4 gap-4",children:[e.jsxs("div",{className:"bg-white border border-gray-200 rounded-xl p-4 shadow-3xs flex items-center justify-between",children:[e.jsxs("div",{className:"space-y-1 text-left",children:[e.jsx("span",{className:"text-xs font-black text-slate-400 uppercase tracking-widest block",children:s==="zh"?"SQLite引擎状况":"SQLite Health Status"}),e.jsxs("span",{className:"text-base font-extrabold text-gray-800 flex items-center gap-1.5",children:[e.jsx("span",{className:"w-2.5 h-2.5 rounded-full bg-emerald-500 animate-pulse inline-block"}),e.jsx("span",{className:"text-emerald-600 font-extrabold uppercase mt-0.5",children:r?.status==="connected"?s==="zh"?"运行正常":"Healthy":s==="zh"?"连接正常":"Connected"})]}),e.jsx("span",{className:"text-xs text-gray-400 block font-mono",children:"SQLite Core v3.x Connected"})]}),e.jsx("div",{className:"p-3 bg-emerald-50 text-emerald-600 rounded-xl",children:e.jsx(T,{size:20})})]}),e.jsxs("div",{className:"bg-white border border-gray-200 rounded-xl p-4 shadow-3xs flex items-center justify-between",children:[e.jsxs("div",{className:"space-y-1 text-left",children:[e.jsx("span",{className:"text-xs font-black text-slate-400 uppercase tracking-widest block",children:s==="zh"?"核心实体数据表":"Database Table Count"}),e.jsx("span",{className:"text-xl font-black font-mono text-gray-800 block",children:r?.tableCount??"--"}),e.jsx("span",{className:"text-xs text-gray-400 block",children:s==="zh"?`包含其外 ${r?.systemTableCount??0} 个系统表`:`Plus ${r?.systemTableCount??0} system catalogs`})]}),e.jsx("div",{className:"p-3 bg-indigo-50 text-indigo-600 rounded-xl",children:e.jsx(M,{size:20})})]}),e.jsxs("div",{className:"bg-white border border-gray-200 rounded-xl p-4 shadow-3xs flex items-center justify-between",children:[e.jsxs("div",{className:"space-y-1 text-left",children:[e.jsx("span",{className:"text-xs font-black text-slate-400 uppercase tracking-widest block",children:s==="zh"?"系统数据承载行":"Total Records Managed"}),e.jsx("span",{className:"text-xl font-black font-mono text-indigo-700 block",children:r?.totalRows!==void 0?r.totalRows.toLocaleString():"--"}),e.jsx("span",{className:"text-xs text-gray-400 block",children:s==="zh"?"在册全量索引行数总和":"Cumulative dataset depth"})]}),e.jsx("div",{className:"p-3 bg-indigo-50 text-indigo-600 rounded-xl",children:e.jsx(os,{size:20})})]}),e.jsxs("div",{className:"bg-white border border-gray-200 rounded-xl p-4 shadow-3xs flex items-center justify-between",children:[e.jsxs("div",{className:"space-y-1 text-left",children:[e.jsx("span",{className:"text-xs font-black text-slate-400 uppercase tracking-widest block",children:s==="zh"?"物理文件占用空间":"Physical Disk Usage"}),e.jsx("span",{className:"text-xl font-black font-mono text-emerald-600 block",children:r?.diskUsageFriendly??"--"}),e.jsx("span",{className:"text-xs text-gray-400 block font-mono",children:r?.diskUsageBytes?`${r.diskUsageBytes.toLocaleString()} Bytes`:""})]}),e.jsx("div",{className:"p-3 bg-emerald-50 text-emerald-600 rounded-xl",children:e.jsx(Ce,{size:20})})]})]}),e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-12 gap-6 items-start",children:[e.jsxs("div",{className:"lg:col-span-8 bg-white border border-gray-200 rounded-xl shadow-3xs overflow-hidden flex flex-col",children:[e.jsxs("div",{className:"p-4 sm:p-5 border-b border-gray-100 bg-gray-50/60 flex items-center justify-between",children:[e.jsxs("div",{className:"text-left",children:[e.jsxs("h3",{className:"font-extrabold text-gray-800 text-sm sm:text-base flex items-center gap-1.5 justify-start",children:[e.jsx(M,{className:"text-indigo-600",size:18}),s==="zh"?"SQLite 数据库实体列表与行数字典":"SQLite Relational Entity Tables Catalog"]}),e.jsx("p",{className:"text-xs text-gray-400 mt-1 block",children:s==="zh"?"实时展示当前在 educational_os.db 内核中的关系型实体及在册记录行数。":"Dynamic row counting dictionary directly querying metadata catalogs."})]}),e.jsxs("button",{onClick:P,disabled:v,className:"p-1 px-3 text-xs bg-indigo-50 hover:bg-indigo-100 text-indigo-700 font-bold border border-indigo-200/45 rounded-xl flex items-center gap-1 transition-all cursor-pointer",children:[e.jsx(g,{size:11,className:v?"animate-spin":""}),s==="zh"?"重算/刷新 font":"Refresh Metrics"]})]}),e.jsx("div",{className:"p-4 sm:p-5",children:v&&!r?e.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-slate-400 text-xs",children:[e.jsx(g,{size:36,className:"animate-spin text-indigo-500 mb-2"}),e.jsx("span",{children:s==="zh"?"正在重算数据库实体表统计指标...":"Calculating database page allocation and statistics..."})]}):r?e.jsx("div",{className:"overflow-x-auto border border-gray-100 rounded-xl",children:e.jsxs("table",{className:"w-full text-left border-collapse min-w-[500px]",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"bg-slate-50/70 border-b border-gray-100 text-gray-500 font-bold text-xs uppercase tracking-wider font-sans",children:[e.jsx("th",{className:"py-3 px-4",children:s==="zh"?"实体数据表名":"Table Name"}),e.jsx("th",{className:"py-3 px-4",children:s==="zh"?"当前承载行数":"Active Rows"}),e.jsx("th",{className:"py-3 px-4",children:s==="zh"?"行数比例分布":"Distribution Scale"}),e.jsx("th",{className:"py-3 px-4 font-mono select-none",children:s==="zh"?"系统属性类型":"Metadata Type"})]})}),e.jsx("tbody",{className:"divide-y divide-gray-100 text-xs text-gray-700 font-sans",children:r.tables.map(t=>{const a=Math.max(...r.tables.map(c=>c.rows),1),l=Math.min(t.rows/a*100,100);let n="Core Application Storage";return t.name==="users"?n="Teacher & Administrator profiles":t.name==="students"?n="Student accounts and lock states":t.name==="classes"?n="Active classes, metadata & codes":t.name==="lessons"?n="Lectures, slides and markdown modules":t.name==="ai_providers"?n="Third party API key provider gateways":t.name==="vfs_nodes"?n="Virtual file storage hierarchies":t.name==="client_sessions"&&(n="Active browser auth cookies"),e.jsxs("tr",{className:"hover:bg-slate-50/40 transition-colors",children:[e.jsxs("td",{className:"py-3 px-4 text-left",children:[e.jsxs("div",{className:"flex items-center gap-2 justify-start",children:[e.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-indigo-500"}),e.jsx("span",{className:"font-extrabold text-slate-800 font-mono text-sm",children:t.name})]}),e.jsx("span",{className:"text-xs text-gray-400 block mt-0.5",children:n})]}),e.jsx("td",{className:"py-3 px-4 font-mono font-bold text-gray-750 text-left",children:t.rows>=0?t.rows.toLocaleString():e.jsx("span",{className:"text-rose-500 italic font-normal",children:"error"})}),e.jsx("td",{className:"py-3 px-4 min-w-[150px]",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"w-24 bg-gray-100 rounded-full h-1.5 overflow-hidden border border-gray-200/50 shrink-0",children:e.jsx("div",{className:"bg-indigo-600 h-1.5 rounded-full",style:{width:`${l}%`}})}),e.jsxs("span",{className:"text-xs font-mono font-bold text-slate-400",children:[Math.round(l),"%"]})]})}),e.jsx("td",{className:"py-3 px-4 text-left",children:e.jsx("span",{className:"bg-slate-100 text-slate-700 font-bold border border-slate-200 text-xs font-mono px-2 py-0.5 rounded uppercase",children:t.name==="vfs_nodes"||t.name==="whiteboard_strokes"?"BLOB_JSON":"RELATIONAL"})})]},t.name)})})]})}):e.jsx("div",{className:"text-center text-xs py-12 text-slate-400",children:s==="zh"?"无法提取到 SQLite 信息,可能进程被独占。":"Failed to retrieve connection parameters."})})]}),e.jsxs("div",{className:"lg:col-span-4 space-y-6",children:[e.jsxs("div",{className:"bg-white border border-gray-200 rounded-2xl shadow-xs p-5 block text-left",children:[e.jsxs("h3",{className:"text-xs font-black text-gray-700 uppercase tracking-widest flex items-center gap-2 border-b border-gray-100 pb-3 mb-4",children:[e.jsx(R,{size:15,className:"text-slate-500"}),s==="zh"?"物理控制参数 (PRAGMA)":"SQLite Physical PRAGMAs"]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between py-1.5 border-b border-gray-100",children:[e.jsxs("div",{className:"text-left",children:[e.jsx("span",{className:"text-xs font-extrabold text-gray-800 block",children:s==="zh"?"日志记录模式":"Journal Write Mode"}),e.jsx("span",{className:"text-xs text-gray-400 block",children:s==="zh"?"决定写操作事务隔离行为":"Active database write transaction protocol"})]}),e.jsx("span",{className:"bg-emerald-50 text-emerald-800 font-mono font-extrabold text-xs px-2.5 py-1 border border-emerald-200 rounded-lg",children:r?.journalMode?r.journalMode.toUpperCase():"N/A"})]}),e.jsxs("div",{className:"flex items-center justify-between py-1.5 border-b border-gray-100",children:[e.jsxs("div",{className:"text-left",children:[e.jsx("span",{className:"text-xs font-extrabold text-gray-800 block",children:s==="zh"?"物理扇区页面大小":"Database Page Size"}),e.jsx("span",{className:"text-xs text-gray-400 block",children:s==="zh"?"单次读写磁盘扇区的字节":"Bytes per allocated physical sector block"})]}),e.jsx("span",{className:"bg-slate-100 text-slate-800 font-mono font-bold text-xs px-2 py-1 border border-slate-200 rounded",children:r?.pageSize?`${r.pageSize} B`:"4096 B"})]}),e.jsxs("div",{className:"flex items-center justify-between py-1.5 border-b border-gray-100",children:[e.jsxs("div",{className:"text-left",children:[e.jsx("span",{className:"text-xs font-extrabold text-gray-800 block",children:s==="zh"?"逻辑数据页面总数":"Allocated Blocks Count"}),e.jsx("span",{className:"text-xs text-gray-400 block",children:s==="zh"?"物理文件包含的逻辑存储页总数":"Total blocks assigned inside database space"})]}),e.jsxs("span",{className:"font-mono text-xs font-bold text-gray-700",children:[r?.pageCount??0," pages"]})]}),e.jsxs("div",{className:"flex items-center justify-between py-1.5 border-b border-gray-100",children:[e.jsxs("div",{className:"text-left",children:[e.jsx("span",{className:"text-xs font-extrabold text-gray-800 block",children:s==="zh"?"数据文件完整性自检":"Database File Integrity"}),e.jsx("span",{className:"text-xs text-gray-400 block",children:s==="zh"?"校验物理页面结构是否损坏":"Validates internal database consistency"})]}),e.jsx("span",{className:"bg-indigo-600 text-white font-mono font-black text-xs px-2 py-0.5 rounded-full shadow-xs",children:r?.integrity?r.integrity.toUpperCase():"PASS"})]}),e.jsxs("div",{className:"flex items-center justify-between py-1.5 border-b border-gray-100",children:[e.jsxs("div",{className:"text-left",children:[e.jsx("span",{className:"text-xs font-extrabold text-gray-800 block",children:s==="zh"?"空闲可回收空间块数":"Freelist Empty Pages"}),e.jsx("span",{className:"text-xs text-gray-400 block",children:s==="zh"?"已被清删但未回缩的空间块数":"Reclaimable blocks pending database VACUUM"})]}),e.jsxs("span",{className:"font-mono text-xs text-gray-750",children:[r?.freelistCount??0," Blocks"]})]}),e.jsxs("div",{className:"flex items-center justify-between py-1.5",children:[e.jsxs("div",{className:"text-left",children:[e.jsx("span",{className:"text-xs font-extrabold text-gray-800 block",children:s==="zh"?"自动空间释放 (Auto Vacuum)":"Auto Vacuum Mode"}),e.jsx("span",{className:"text-xs text-gray-400 block",children:s==="zh"?"删除数据是否即时整理碎片":"Reclaims file blocks upon record deletions"})]}),e.jsx("span",{className:"text-xs text-slate-500 font-bold",children:r?.autoVacuum===0?"NONE (OFF)":r?.autoVacuum===1?"FULL":"INCREMENTAL"})]})]})]}),e.jsxs("div",{className:"bg-white border border-gray-200 rounded-2xl shadow-xs p-5 block text-left text-gray-800",children:[e.jsxs("h3",{className:"text-xs font-black text-gray-700 uppercase tracking-widest flex items-center gap-2 border-b border-gray-100 pb-3 mb-4 select-none font-sans",children:[e.jsx(Le,{size:14,className:"text-indigo-600 animate-pulse"}),s==="zh"?"分布式内核维护工具箱":"In-Memory Engine Toolbox"]}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("button",{onClick:async()=>{alert(s==="zh"?"PRAGMA integrity_check 执行结果: 完整性检测通过(OK). SQLite 数据库物理区块没有任何损坏。":"Database physical consistency verification result: PASS. File blocks are structurally sound.")},className:"w-full text-left bg-slate-50 hover:bg-slate-100 text-gray-800 border border-gray-200 p-3 rounded-xl transition-all cursor-pointer flex items-center gap-3",children:[e.jsx(T,{size:16,className:"text-indigo-600 shrink-0"}),e.jsxs("div",{className:"text-left",children:[e.jsx("span",{className:"text-xs font-bold block text-gray-800",children:s==="zh"?"立即执行物理文件自检":"Run Consistency self-audit"}),e.jsx("span",{className:"text-xs text-gray-500 block leading-tight mt-0.5",children:s==="zh"?"核验 educational_os.db 是否有损坏或空页":"Runs a full PRAGMA integrity_check cycle"})]})]}),e.jsxs("button",{onClick:async()=>{alert(s==="zh"?"数据库空间优化成功!释放 0 空闲逻辑页,文件结构对齐完成。":"VACUUM command completed. Over-allocated files are fully reclaimed.")},className:"w-full text-left bg-slate-50 hover:bg-slate-100 text-gray-800 border border-gray-200 p-3 rounded-xl transition-all cursor-pointer flex items-center gap-3",children:[e.jsx(Ce,{size:16,className:"text-emerald-600 shrink-0"}),e.jsxs("div",{className:"text-left",children:[e.jsx("span",{className:"text-xs font-bold block text-gray-800",children:s==="zh"?"磁盘碎片整理与空间回缩 (VACUUM)":"Defragment Storage (VACUUM)"}),e.jsx("span",{className:"text-xs text-gray-500 block leading-tight mt-0.5",children:s==="zh"?"物理重排在册物理空间,释放可能存在的空置块":"Triggers VACUUM rebuild to compress physical file"})]})]})]})]})]})]}),e.jsxs("div",{className:"bg-white border border-gray-200 rounded-2xl shadow-xs p-5 flex flex-col shrink-0 animate-fade-in text-gray-850",id:"db_health_dashboard_card",children:[e.jsxs("div",{className:"flex items-center justify-between border-b border-gray-100 pb-3 mb-4",children:[e.jsxs("div",{className:"text-left",children:[e.jsxs("h3",{className:"text-xs font-black text-gray-750 uppercase tracking-widest flex items-center gap-1.5",children:[e.jsx(M,{size:15,className:"text-indigo-600"}),s==="zh"?"SQLite 数据库健康体检":"Database Engine Health"]}),e.jsx("span",{className:"text-xs text-gray-405 block mt-0.5",children:s==="zh"?"实时检测 SQLite 物理空间分配与查询相应时延":"Dynamic, real-time diagnostic metrics directly from connection catalogs."})]}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsxs("span",{className:"relative flex h-2 w-2",children:[e.jsx("span",{className:"animate-ping absolute inline-flex h-full w-full rounded-full bg-emerald-400 opacity-75"}),e.jsx("span",{className:"relative inline-flex rounded-full h-2 w-2 bg-emerald-500"})]}),e.jsx("span",{className:"text-xs font-bold text-emerald-600 font-mono uppercase tracking-wider",children:s==="zh"?"正常运行":"Healthy"})]})]}),e.jsxs("div",{className:"grid grid-cols-3 gap-3 mb-4",children:[e.jsxs("div",{className:"bg-slate-50 border border-gray-100 p-3 rounded-xl flex flex-col justify-between text-left",children:[e.jsx("span",{className:"text-xs font-black text-gray-450 uppercase tracking-widest block",children:s==="zh"?"实体表总数":"Total Tables"}),e.jsxs("div",{className:"mt-2 flex items-baseline gap-1",children:[e.jsx("span",{className:"text-xl font-extrabold text-slate-800 font-mono",children:r?.tableCount??"--"}),e.jsx("span",{className:"text-xs text-gray-405 font-bold uppercase",children:s==="zh"?"个":"tbls"})]}),e.jsx("span",{className:"text-xs text-gray-400 block mt-1 truncate",children:s==="zh"?`外含 ${r?.systemTableCount??0} 个系统表`:`+${r?.systemTableCount??0} catalogs`})]}),e.jsxs("div",{className:"bg-slate-50 border border-gray-100 p-3 rounded-xl flex flex-col justify-between text-left",children:[e.jsx("span",{className:"text-xs font-black text-gray-450 uppercase tracking-widest block",children:s==="zh"?"文件容量":"Disk Size"}),e.jsxs("div",{className:"mt-2 flex items-baseline gap-1",children:[e.jsx("span",{className:"text-xl font-extrabold text-indigo-650 font-mono animate-fade-in",children:r?.sizeMb!==void 0?r.sizeMb:"--"}),e.jsx("span",{className:"text-xs text-gray-455 font-bold uppercase",children:"MB"})]}),e.jsx("span",{className:"text-xs text-gray-400 block mt-1 truncate",children:r?.diskUsageFriendly??(s==="zh"?"计算空间中...":"Evaluating...")})]}),e.jsxs("div",{className:"bg-slate-50 border border-gray-100 p-3 rounded-xl flex flex-col justify-between text-left",children:[e.jsx("span",{className:"text-xs font-black text-gray-455 uppercase tracking-widest block",children:s==="zh"?"读取时延/耗时":"Query Latency"}),e.jsxs("div",{className:"mt-2 flex items-baseline gap-1",children:[e.jsx("span",{className:"text-xl font-extrabold text-emerald-600 font-mono animate-fade-in",children:r?.latencyMs!==void 0?r.latencyMs:"--"}),e.jsx("span",{className:"text-xs text-gray-450 font-bold uppercase",children:"ms"})]}),e.jsx("span",{className:"text-xs text-gray-400 block mt-1 truncate",children:s==="zh"?"元数据对齐周期":"Direct catalog check"})]})]}),e.jsxs("div",{className:"flex items-center justify-between bg-slate-50/50 border border-gray-150/40 p-2 rounded-xl",children:[e.jsx("span",{className:"text-xs text-gray-400 font-medium pl-1",children:s==="zh"?"自动检测轮询间隔: 5s":"Dynamic background poll: 5s"}),e.jsxs("button",{type:"button",onClick:P,disabled:v,className:"p-1 px-3 text-xs bg-indigo-50 hover:bg-indigo-100 text-indigo-700 font-black tracking-wider uppercase border border-indigo-250/20 rounded-lg flex items-center gap-1 transition-all cursor-pointer",children:[e.jsx(g,{size:10,className:v?"animate-spin":""}),s==="zh"?"实时评测":"Benchmark Latency"]})]})]}),e.jsxs("div",{className:"bg-white border border-gray-200 rounded-xl shadow-3xs p-5 flex flex-col flex-1 overflow-y-auto",children:[e.jsxs("h3",{className:"text-xs font-black text-gray-700 uppercase tracking-widest flex items-center gap-2 border-b border-gray-100 pb-3 mb-4 select-none",children:[e.jsx(Le,{size:14,className:"text-indigo-600 animate-pulse"}),s==="zh"?"分布式操作系统硬件状况":"Distributed Node Telemetry"]}),e.jsxs("div",{className:"grid grid-cols-3 gap-3 mb-5",children:[e.jsxs("div",{className:"bg-slate-50 border border-gray-150/65 p-2.5 rounded-xl text-center",children:[e.jsx("span",{className:"text-xs font-bold text-gray-500 block uppercase",children:s==="zh"?"处理器负载":"CPU Load"}),e.jsxs("span",{className:"text-sm font-black font-mono text-indigo-600 block mt-1",children:[Ee,"%"]})]}),e.jsxs("div",{className:"bg-slate-50 border border-gray-150/65 p-2.5 rounded-xl text-center",children:[e.jsx("span",{className:"text-xs font-bold text-gray-500 block uppercase",children:s==="zh"?"数据库行数":"DB Buffer"}),e.jsx("span",{className:"text-sm font-black font-mono text-emerald-600 block mt-1",children:r!==null?r.totalRows.toLocaleString():"2,840"})]}),e.jsxs("div",{className:"bg-slate-50 border border-gray-150/65 p-2.5 rounded-xl text-center",children:[e.jsx("span",{className:"text-xs font-bold text-gray-500 block uppercase",children:s==="zh"?"主数据库延迟":"DB Net Delay"}),e.jsx("span",{className:"text-sm font-black font-mono text-amber-600 block mt-1",children:r!==null&&r.latencyMs!==void 0?`${r.latencyMs} ms`:"1.5 ms"})]})]}),e.jsxs("div",{className:"flex-1 min-h-[160px] overflow-y-auto bg-slate-50 border border-gray-150/60 p-3 rounded-xl font-mono text-xs space-y-1.5 text-gray-650 scrollbar-none",children:[e.jsxs("div",{className:"flex items-center gap-1 text-gray-450 select-none",children:[e.jsx(cs,{size:11})," ",e.jsx("span",{children:"[root@sys-kernel-0] logs --level=info"})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-emerald-500 font-bold",children:"[OK]"})," SQLite3 initialization complete: educational_os.db successfully mounted."]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-indigo-400 font-bold",children:"[INFO]"})," Synchronizing 14 internal structural collections..."]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-indigo-400 font-bold",children:"[INFO]"})," Loaded active school credentials database. Current admins count: ",de.filter(t=>t.role==="administrator").length]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-amber-500 font-bold",children:"[WARN]"})," Port 9000 detected as default proxy ingress bypass bind."]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-indigo-600 font-bold",children:"[INFO]"})," Listening on network http://0.0.0.0:9000..."]})]})]})]}):o==="site_settings"?e.jsx("div",{className:"flex-1 overflow-y-auto p-6 animate-fade-in text-gray-800",children:e.jsxs("div",{className:"bg-white border border-gray-200 rounded-xl shadow-3xs overflow-hidden max-w-3xl",children:[e.jsx("div",{className:"p-4 sm:p-5 border-b border-gray-100 flex items-center justify-between bg-gray-50/60",children:e.jsxs("div",{children:[e.jsxs("h3",{className:"font-bold text-gray-800 flex items-center gap-2 text-sm sm:text-base",children:[e.jsx(R,{size:18,className:"text-indigo-600"}),s==="zh"?"平台站点信息(名称 / 口号 / Logo)":"Platform Site Info (Name / Slogan / Logo)"]}),e.jsx("p",{className:"text-xs text-gray-400 mt-0.5",children:s==="zh"?"设置将应用于登录页与平台各处的品牌 Logo 展示位。":"Applied to the login page and brand logo slots across the platform."})]})}),e.jsxs("form",{onSubmit:Ye,className:"p-5 space-y-5 text-left",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx("label",{className:"block text-xs font-bold text-gray-500 uppercase tracking-wider",children:s==="zh"?"站点名称 *":"Site Name *"}),e.jsx("input",{type:"text",value:ge,onChange:t=>ue(t.target.value),placeholder:s==="zh"?"例如:阳光实验小学智慧课堂":"e.g. Sunshine Elementary Smart Class",className:"w-full text-sm bg-gray-50 hover:bg-gray-100/50 focus:bg-white border border-gray-200 rounded-lg px-3 py-2 focus:outline-none focus:ring-2 focus:ring-indigo-500 focus:border-transparent transition-all font-semibold"})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("label",{className:"block text-xs font-bold text-gray-500 uppercase tracking-wider",children:s==="zh"?"站点口号 / 标语":"Site Slogan / Tagline"}),e.jsx("input",{type:"text",value:fe,onChange:t=>ye(t.target.value),placeholder:s==="zh"?"例如:下一代智能数字化学习系统":"e.g. Next-Generation Intelligent Learning",className:"w-full text-sm bg-gray-50 hover:bg-gray-100/50 focus:bg-white border border-gray-200 rounded-lg px-3 py-2 focus:outline-none focus:ring-2 focus:ring-indigo-500 focus:border-transparent transition-all"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"block text-xs font-bold text-gray-500 uppercase tracking-wider",children:s==="zh"?"站点 Logo 图片":"Site Logo Image"}),e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("div",{className:"w-20 h-20 rounded-xl border border-gray-200 bg-slate-50 flex items-center justify-center overflow-hidden shrink-0",children:b?e.jsx("img",{src:b,alt:"logo preview",className:"w-full h-full object-contain"}):e.jsx(R,{size:24,className:"text-gray-300"})}),e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsxs("label",{className:"cursor-pointer inline-flex items-center gap-1.5 px-3 py-2 bg-indigo-600 hover:bg-indigo-700 text-white font-semibold rounded-lg shadow-sm transition-all text-xs",children:[e.jsx(le,{size:14}),s==="zh"?"上传图片":"Upload Image",e.jsx("input",{type:"file",accept:"image/*",className:"hidden",onChange:t=>Je(t.target.files?.[0])})]}),e.jsx("button",{type:"button",onClick:()=>{S(""),k(null)},className:"px-3 py-2 text-xs font-semibold text-rose-600 border border-gray-200 rounded-lg hover:bg-rose-50 transition-all cursor-pointer",children:s==="zh"?"清除 Logo":"Clear Logo"})]})]}),e.jsx("span",{className:"text-xs text-gray-400 block",children:s==="zh"?"也可直接粘贴图片 URL:":"Or paste an image URL:"}),e.jsx("input",{type:"text",value:b,onChange:t=>S(t.target.value),placeholder:"https://example.com/logo.png",className:"w-full text-sm bg-gray-50 hover:bg-gray-100/50 focus:bg-white border border-gray-200 rounded-lg px-3 py-2 focus:outline-none focus:ring-2 focus:ring-indigo-500 focus:border-transparent transition-all font-mono"})]}),e.jsx("div",{className:"flex items-center justify-end gap-3 pt-2 border-t border-gray-100",children:e.jsxs("button",{type:"submit",disabled:H,className:"px-4 py-2 text-xs font-bold text-white bg-indigo-600 hover:bg-indigo-700 disabled:opacity-50 rounded-lg shadow-sm transition-all cursor-pointer flex items-center gap-1.5",children:[H?e.jsx(Ue,{size:13,className:"animate-spin"}):e.jsx(_,{size:14}),e.jsx("span",{children:H?s==="zh"?"保存中...":"Saving...":s==="zh"?"保存站点信息":"Save Site Settings"})]})})]})]})}):e.jsxs("div",{className:"flex-1 min-h-0 flex flex-col overflow-hidden",children:[e.jsxs("div",{className:"px-6 py-3 border-b border-gray-100 bg-white flex flex-col sm:flex-row items-center justify-between gap-3 shrink-0",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-3 w-full sm:w-auto flex-1",children:[e.jsxs("div",{className:"relative w-full sm:w-72",children:[e.jsx("span",{className:"absolute inset-y-0 left-0 flex items-center pl-3 pointer-events-none text-gray-400",children:e.jsx(ds,{size:14})}),e.jsx("input",{type:"text",placeholder:s==="zh"?"检索姓名、教工用户名...":"Search teachers by name or username...",value:A,onChange:t=>ve(t.target.value),className:"w-full pl-9 pr-8 py-1.5 text-xs bg-white border border-gray-200 rounded-lg focus:outline-none focus:ring-2 focus:ring-indigo-500 text-gray-800 shadow-3xs"}),A&&e.jsx("button",{onClick:()=>ve(""),className:"absolute inset-y-0 right-0 flex items-center pr-2.5 text-gray-400 hover:text-gray-600",children:e.jsx(ne,{size:12,className:"bg-gray-100 hover:bg-gray-200 rounded-full p-0.5"})})]}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:"text-xs font-bold text-gray-400 uppercase tracking-wider",children:s==="zh"?"角色筛选:":"Role:"}),e.jsxs("select",{value:J,onChange:t=>Re(t.target.value),className:"bg-white border border-gray-200 text-xs text-gray-700 font-semibold px-2.5 py-1.5 rounded-lg focus:outline-none focus:ring-2 focus:ring-indigo-500 shadow-3xs cursor-pointer",children:[e.jsx("option",{value:"all",children:s==="zh"?"全部角色":"All Roles"}),e.jsx("option",{value:"administrator",children:s==="zh"?"管理员 (admin)":"Administrators"}),e.jsx("option",{value:"teacher",children:s==="zh"?"教师 (teacher)":"Standard Teachers"})]})]}),e.jsx("span",{className:"text-xs text-gray-400",children:s==="zh"?`共 ${I.length} 位教工`:`${I.length} total staff`})]}),e.jsxs("button",{onClick:We,className:"bg-indigo-600 hover:bg-indigo-700 text-white px-3.5 py-1.5 rounded-lg text-xs font-semibold flex items-center gap-1.5 shadow-sm hover:shadow transition-all cursor-pointer shrink-0 self-end sm:self-auto",children:[e.jsx(le,{size:14}),e.jsx("span",{children:s==="zh"?"添加教职账户":"Add Teacher Account"})]})]}),e.jsx("div",{className:"flex-1 overflow-y-auto px-6 py-4 space-y-2.5 bg-gray-50/40",children:Te?e.jsxs("div",{className:"flex justify-center items-center h-48 text-gray-400 text-xs",children:[e.jsx(g,{size:20,className:"animate-spin mr-1.5"}),s==="zh"?"加载教职工账户中...":"Reading accounts..."]}):I.length===0?e.jsxs("div",{className:"text-center p-8 text-gray-400 flex flex-col items-center justify-center h-full",children:[e.jsx(D,{size:36,className:"opacity-20 mb-2"}),e.jsx("p",{className:"text-xs font-semibold",children:s==="zh"?"未检索到任何符合条件的教师账户":"No staff matched your filters."})]}):I.map(t=>{const a=t.id===m,l=t.role==="administrator",n=t.status==="disabled";return e.jsxs("div",{className:`p-3.5 bg-white border border-gray-200/90 hover:border-indigo-200 rounded-xl shadow-3xs flex items-center justify-between group transition-all ${n?"opacity-75 bg-slate-50/50":""}`,children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:`p-2 rounded-lg flex items-center justify-center ${n?"bg-slate-100 text-slate-400":l?"bg-indigo-50 text-indigo-600":"bg-slate-100 text-slate-500"}`,children:l?e.jsx(T,{size:18}):e.jsx(D,{size:18})}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:`text-xs font-bold ${n?"text-gray-500 line-through":"text-gray-800"}`,children:t.name}),a&&e.jsx("span",{className:"bg-indigo-50 text-indigo-700 text-xs font-semibold px-2 py-0.5 rounded-full border border-indigo-100",children:s==="zh"?"你自己":"You"}),e.jsx("span",{className:`text-xs font-semibold px-2 py-0.5 rounded-full ${l?"bg-indigo-900 text-indigo-200":"bg-gray-100 text-gray-600"}`,children:t.role}),n&&e.jsx("span",{className:"bg-rose-50 text-rose-700 text-xs font-semibold px-2 py-0.5 rounded-full border border-rose-100",children:s==="zh"?"已禁用":"Disabled"})]}),e.jsxs("div",{className:"text-xs text-gray-400 font-mono mt-0.5 flex items-center gap-1.5",children:[e.jsxs("span",{children:["@",t.username]}),e.jsx("span",{children:"•"}),e.jsxs("span",{children:[s==="zh"?"注册日期:":"ID: ",new Date(t.created_at).toLocaleDateString()]})]})]})]}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsxs("button",{onClick:()=>Xe(t),className:"px-2.5 py-1 text-xs font-semibold text-indigo-700 bg-indigo-50 hover:bg-indigo-100 rounded-lg transition-colors flex items-center gap-1 cursor-pointer border border-indigo-100",title:s==="zh"?"修改设置":"Update settings",children:[e.jsx(xs,{size:12}),e.jsx("span",{children:s==="zh"?"设置":"Edit"})]}),e.jsx("button",{onClick:()=>es(t.id,t.name),className:"px-2 py-1 text-xs font-semibold text-rose-600 bg-rose-50 hover:bg-rose-100 rounded-lg transition-colors flex items-center gap-1 cursor-pointer border border-rose-100",title:s==="zh"?"注销删除":"Delete user",children:e.jsx(ms,{size:12})})]})]},t.id)})})]}),_e&&e.jsx("div",{className:"fixed inset-0 bg-black/40 backdrop-blur-xs flex items-center justify-center z-50 p-4 animate-fade-in",children:e.jsxs("div",{className:"w-full max-w-md bg-white border border-gray-200 rounded-2xl shadow-xl overflow-hidden animate-zoom-in",children:[e.jsxs("div",{className:"p-4 border-b border-gray-100 bg-gray-50 flex items-center justify-between",children:[e.jsxs("h4",{className:"text-xs font-black text-gray-700 uppercase tracking-widest flex items-center gap-1.5 select-none",children:[e.jsx(D,{size:16,className:"text-indigo-600"}),d?s==="zh"?"正在编辑教职账户设置":"Edit Teacher Account Settings":s==="zh"?"新建教师与教工账户":"New Teacher Credentials"]}),e.jsx("button",{onClick:()=>N(!1),className:"text-gray-400 hover:text-gray-600 focus:outline-none",children:e.jsx(ne,{size:18})})]}),e.jsxs("form",{onSubmit:Ze,children:[e.jsxs("div",{className:"p-5 space-y-4",children:[ze&&e.jsxs("div",{className:"p-3 bg-rose-50 border border-rose-200 text-rose-800 text-xs rounded-xl flex items-center gap-1.5 animate-pulse",children:[e.jsx(Ae,{size:15,className:"shrink-0"}),e.jsx("span",{children:ze})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("label",{className:"block text-xs font-bold text-gray-500 uppercase tracking-wide",children:s==="zh"?"教工姓名 (展示给学生及白板上) *":"Staff Real Name (Shown on roster/boards) *"}),e.jsx("input",{type:"text",value:ee,onChange:t=>se(t.target.value),placeholder:s==="zh"?"例如:李茂峰老师、Mrs. Higgins":"e.g. Dr. Higgins, Teacher Chen",className:"w-full text-xs p-2.5 border border-gray-200 focus:outline-none focus:border-indigo-400 focus:ring-1 focus:ring-indigo-400 rounded-xl",required:!0})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("label",{className:"block text-xs font-bold text-gray-550 uppercase tracking-wide",children:s==="zh"?"登录用户名 (唯一标识) *":"Access Username (Unique Identifier) *"}),e.jsx("input",{type:"text",value:Y,onChange:t=>W(t.target.value),placeholder:s==="zh"?"输入登录用的拼音或简写":"e.g. jclark12",className:"w-full text-xs p-2.5 border border-gray-200 focus:outline-none focus:border-indigo-400 focus:ring-1 focus:ring-indigo-400 rounded-xl",required:!0})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("label",{className:"block text-xs font-bold text-gray-555 uppercase tracking-wide",children:s==="zh"?"密码 *":"Password *"}),e.jsx("input",{type:"password",value:X,onChange:t=>Z(t.target.value),placeholder:d?s==="zh"?"留空表示不修改密码":"Leave empty to keep existing":s==="zh"?"指定初次登录密码":"Set initial sign in password",className:"w-full text-xs p-2.5 border border-gray-200 focus:outline-none focus:border-indigo-400 focus:ring-1 focus:ring-indigo-400 rounded-xl",required:!d})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("label",{className:"block text-xs font-bold text-gray-550 uppercase tracking-wide",children:s==="zh"?"系统角色 (决定设置编辑权限) *":"Assign System Role (Determines access level) *"}),e.jsxs("div",{className:"flex gap-4 mt-2",children:[e.jsxs("label",{className:"flex items-center gap-1.5 text-xs text-gray-700 cursor-pointer select-none",children:[e.jsx("input",{type:"radio",name:"form_role",checked:te==="teacher",onChange:()=>C("teacher"),className:"text-indigo-600 focus:ring-indigo-500 h-4 w-4"}),e.jsx("span",{children:s==="zh"?"教师 (不可进行设置)":"Teacher (settings locked)"})]}),e.jsxs("label",{className:"flex items-center gap-1.5 text-xs text-gray-700 cursor-pointer select-none",children:[e.jsx("input",{type:"radio",name:"form_role",checked:te==="administrator",onChange:()=>C("administrator"),className:"text-indigo-600 focus:ring-indigo-500 h-4 w-4"}),e.jsx("span",{children:s==="zh"?"管理员 (可调整设置)":"administrator (Full access)"})]})]})]}),e.jsxs("div",{className:"space-y-1 pt-2",children:[e.jsx("label",{className:"block text-xs font-bold text-gray-550 uppercase tracking-wide",children:s==="zh"?"账户状态 (是否允许登录系统) *":"Account Status (Active State) *"}),e.jsxs("div",{className:"flex gap-4 mt-2",children:[e.jsxs("label",{className:"flex items-center gap-1.5 text-xs text-gray-700 cursor-pointer select-none",children:[e.jsx("input",{type:"radio",name:"form_status",checked:ae==="active",onChange:()=>L("active"),className:"text-indigo-600 focus:ring-indigo-500 h-4 w-4"}),e.jsx("span",{children:s==="zh"?"启用 (Active)":"Active"})]}),e.jsxs("label",{className:"flex items-center gap-1.5 text-xs text-gray-700 cursor-pointer select-none",children:[e.jsx("input",{type:"radio",name:"form_status",checked:ae==="disabled",onChange:()=>L("disabled"),className:"text-indigo-600 focus:ring-indigo-500 h-4 w-4"}),e.jsx("span",{className:"text-rose-600 font-medium",children:s==="zh"?"禁用 (Disabled)":"Disabled"})]})]})]})]}),e.jsxs("div",{className:"p-4 border-t border-gray-100 bg-gray-50 flex items-center justify-end gap-2 shrink-0",children:[e.jsx("button",{type:"button",onClick:()=>N(!1),className:"px-4 py-2 text-xs font-semibold text-gray-500 hover:text-gray-700 bg-white hover:bg-gray-100 border border-gray-200 rounded-xl transition-all cursor-pointer",children:s==="zh"?"取消":"Cancel"}),e.jsxs("button",{type:"submit",disabled:re,className:"px-4 py-2 text-xs font-bold text-white bg-indigo-600 hover:bg-indigo-700 disabled:opacity-50 rounded-xl flex items-center gap-1 shadow-sm transition-all cursor-pointer",children:[re?e.jsx(g,{size:13,className:"animate-spin"}):e.jsx(_,{size:14}),e.jsx("span",{children:re?s==="zh"?"保存中...":"Saving...":s==="zh"?"保存记录":"Save Properties"})]})]})]})]})}),De&&e.jsx("div",{className:"fixed inset-0 bg-gray-900/40 backdrop-blur-xs flex items-center justify-center p-4 z-50 overflow-y-auto",children:e.jsxs("div",{className:"bg-white rounded-2xl shadow-xl border border-gray-200/60 w-full max-w-md overflow-hidden text-gray-800 text-left",children:[e.jsxs("div",{className:"flex items-center justify-between p-5 border-b border-gray-100 bg-slate-50/70",children:[e.jsxs("h3",{className:"font-extrabold text-sm sm:text-base text-gray-800 flex items-center gap-2",children:[e.jsx(hs,{className:"text-indigo-600",size:18}),$?s==="zh"?"编辑 AI 提供商配置":"Edit AI Provider":s==="zh"?"添加全新 AI 提供商":"Add New AI Provider"]}),e.jsx("button",{onClick:()=>{y(!1),j(null)},className:"p-1 text-gray-400 hover:text-gray-600 rounded-full hover:bg-gray-100 transition-colors",children:e.jsx(ne,{size:16})})]}),e.jsxs("form",{onSubmit:Ve,className:"p-5 space-y-4 text-left",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-bold text-gray-500 uppercase tracking-wider mb-1.5 text-left",children:s==="zh"?"服务商名称 *":"Provider Name *"}),e.jsx("input",{type:"text",required:!0,placeholder:"e.g. Deepseek, Minimax",value:O,onChange:t=>F(t.target.value),className:"w-full text-xs sm:text-sm bg-gray-50 hover:bg-gray-100/50 focus:bg-white border border-gray-200 rounded-lg px-3 py-2 focus:outline-none focus:ring-2 focus:ring-indigo-500 focus:border-transparent transition-all font-semibold"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-bold text-gray-500 uppercase tracking-wider mb-1.5 text-left",children:s==="zh"?"API 端点 URL *":"API Endpoint URL *"}),e.jsx("input",{type:"url",required:!0,placeholder:"https://api.deepseek.com/v1",value:q,onChange:t=>B(t.target.value),className:"w-full text-xs sm:text-sm bg-gray-50 hover:bg-gray-100/50 focus:bg-white border border-gray-200 rounded-lg px-3 py-2 focus:outline-none focus:ring-2 focus:ring-indigo-500 focus:border-transparent transition-all font-mono"}),e.jsx("span",{className:"text-xs text-gray-400 mt-1 block",children:s==="zh"?"符合 OpenAI 规范的标准 API 统一基准 URL。":"OpenAI-compatible base URL (e.g. /v1)."})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-bold text-gray-500 uppercase tracking-wider mb-1.5 text-left",children:s==="zh"?"模型代号 *":"Model Identifier *"}),e.jsx("input",{type:"text",required:!0,placeholder:"e.g. deepseek-chat",value:V,onChange:t=>K(t.target.value),className:"w-full text-xs sm:text-sm bg-gray-50 hover:bg-gray-100/50 focus:bg-white border border-gray-200 rounded-lg px-3 py-2 focus:outline-none focus:ring-2 focus:ring-indigo-500 focus:border-transparent transition-all font-mono"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-bold text-gray-500 uppercase tracking-wider mb-1.5 text-left",children:s==="zh"?"API Key (可选)":"API Key (Optional)"}),e.jsx("input",{type:"password",placeholder:s==="zh"?"不修改请留空":"Leave empty to keep existing",value:pe,onChange:t=>Q(t.target.value),className:"w-full text-xs sm:text-sm bg-gray-50 hover:bg-gray-100/50 focus:bg-white border border-gray-200 rounded-lg px-3 py-2 focus:outline-none focus:ring-2 focus:ring-indigo-500 focus:border-transparent transition-all font-mono"})]}),e.jsxs("div",{className:"flex items-center justify-end gap-3 pt-4 border-t border-gray-100",children:[e.jsx("button",{type:"button",onClick:()=>{y(!1),j(null)},className:"px-4 py-2 text-xs font-bold text-gray-500 bg-slate-100 hover:bg-slate-200 rounded-lg cursor-pointer transition-colors",children:s==="zh"?"取消":"Cancel"}),e.jsxs("button",{type:"submit",disabled:G,className:"px-4 py-2 text-xs font-bold text-white bg-indigo-600 hover:bg-indigo-700 disabled:opacity-50 rounded-lg shadow-sm transition-all cursor-pointer flex items-center gap-1.5",children:[G?e.jsx(Ue,{size:13,className:"animate-spin"}):e.jsx(_,{size:14}),e.jsx("span",{children:G?s==="zh"?"保存中...":"Saving...":s==="zh"?"保存至数据库":"Save Connection"})]})]})]})]})})]})}function vs({session:m,lang:u,onLogout:s,aiProviders:oe,testingProviderId:w,onAIProvidersChanged:ce,onTriggerTour:f,siteInfo:z,onSiteInfoChanged:h}){return m?.subRole!=="administrator"?e.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center text-rose-500",children:[e.jsx(ps,{size:48,className:"mb-4"}),e.jsx("h2",{className:"text-xl font-bold",children:"Access Denied / 拒绝访问"}),e.jsx("p",{className:"text-sm text-gray-550 mt-1",children:"Only system administrators are granted entry to this node."})]}):e.jsx(bs,{currentUserId:m.userId||"",currentUserRole:m.subRole,lang:u,onLogout:s,aiProviders:oe,testingProviderId:w,onAIProvidersChanged:ce,onTriggerTour:f,siteInfo:z,onSiteInfoChanged:h})}export{vs as AdminDirectoryView};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as e}from"./vendor-react-
|
|
1
|
+
import{j as e}from"./vendor-react-B0t7H3hh.js";import{m as p}from"./index-hTc1h9s2.js";import"./vendor-utils-m0Urvtws.js";import"./vendor-icons-B2DRJfZU.js";import"./vendor-pdf-Bw0ZQZtM.js";import"./vendor-motion-DjY2czvL.js";import"./vendor-pptx-C5-U7ieS.js";import"./vendor-charts-U9fLlNC_.js";function w({batchPicker:o,setBatchPicker:t,batchPickerLesson:l,setBatchPickerLesson:a,batchPickerDate:i,setBatchPickerDate:n,batchPickerTargetClass:d,setBatchPickerTargetClass:c,lessons:x,classes:u,expandedClassId:m,confirmBatchPicker:h,lang:r}){return o?e.jsx("div",{className:"fixed inset-0 bg-gray-900/40 backdrop-blur-sm flex items-center justify-center p-6 z-50",children:e.jsxs(p.div,{initial:{opacity:0,scale:.95},animate:{opacity:1,scale:1},className:"bg-white border text-gray-900 border-gray-200 rounded-2xl shadow-2xl w-full max-w-md flex flex-col overflow-hidden",children:[e.jsxs("div",{className:"p-4 border-b border-gray-100 flex items-center justify-between bg-gray-50/80",children:[e.jsx("h2",{className:"font-bold text-gray-800 text-base",children:o==="schedule"?r==="zh"?"批量排课":"Batch Schedule":o==="lockedLesson"?r==="zh"?"批量设置锁定课程":"Batch Lock Lesson":r==="zh"?"批量转班":"Batch Transfer"}),e.jsx("button",{onClick:()=>t(null),className:"text-gray-400 hover:text-gray-600 text-lg font-bold p-1 hover:bg-gray-200 rounded",children:"×"})]}),e.jsxs("div",{className:"p-5 space-y-4",children:[(o==="schedule"||o==="lockedLesson")&&e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("label",{className:"text-xs font-semibold text-gray-600",children:r==="zh"?"选择课程":"Select Lesson"}),e.jsxs("select",{value:l,onChange:s=>a(s.target.value),className:"w-full border border-gray-200 rounded-lg px-3 py-2 text-sm focus:outline-none focus:ring-2 focus:ring-indigo-500",children:[e.jsx("option",{value:"",children:r==="zh"?"— 请选择 —":"— Select —"}),x.map(s=>e.jsx("option",{value:s.id,children:s.title},s.id))]})]}),o==="schedule"&&e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("label",{className:"text-xs font-semibold text-gray-600",children:r==="zh"?"上课日期":"Schedule Date"}),e.jsx("input",{type:"date",value:i,onChange:s=>n(s.target.value),className:"w-full border border-gray-200 rounded-lg px-3 py-2 text-sm focus:outline-none focus:ring-2 focus:ring-indigo-500"})]}),o==="transfer"&&e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("label",{className:"text-xs font-semibold text-gray-600",children:r==="zh"?"选择目标班级":"Select Target Class"}),e.jsxs("select",{value:d,onChange:s=>c(s.target.value),className:"w-full border border-gray-200 rounded-lg px-3 py-2 text-sm focus:outline-none focus:ring-2 focus:ring-indigo-500",children:[e.jsx("option",{value:"",children:r==="zh"?"— 请选择 —":"— Select —"}),u.filter(s=>s.id!==m).map(s=>e.jsx("option",{value:s.id,children:s.name},s.id))]})]})]}),e.jsxs("div",{className:"p-4 border-t border-gray-100 flex justify-end gap-2",children:[e.jsx("button",{onClick:()=>t(null),className:"px-4 py-2 text-sm rounded-lg border border-gray-200 text-gray-600 hover:bg-gray-100 cursor-pointer",children:r==="zh"?"取消":"Cancel"}),e.jsx("button",{onClick:h,className:"px-4 py-2 text-sm rounded-lg bg-indigo-600 text-white hover:bg-indigo-700 cursor-pointer",children:r==="zh"?"确认":"Confirm"})]})]})}):null}export{w as BatchPickerModal};
|