refactor(v0.11+): user 3 子命令 (list/create/delete) 改走 webapi 镜像 (loadUser)
- 新建 webapi/user.ts (25+ 函数, 镜像 web/api/permission/user.ts) - user/list: c.get → loadUser.getUserList - user/create: c.postJson+c.get → loadUser.createUser+getUserList - user/delete: c.del → loadUser.delUser user 18 子命令剩余 15 个 (auth-* / baseinfo / changepwd / resetpwd / set-position / online-kick 等), 待 webapi 化 (不紧急, 这些是次要场景) webapi 模块累计 17 个 Co-Authored-By: Claude <[email protected]>
This commit is contained in:
1 parent
cbe6a1e7d9
commit
7224156cf0
4 files changed
+64
-23
No files matched your search
@@ -0,0 +1,30 @@
|
||||
/**
|
||||
* webapi/user.ts — 镜像 web 端 permission/user.ts (v0.11+ Phase 2)
|
||||
*
|
||||
* 镜像 web/apps/jnpf-web-apps-main/src/api/permission/user.ts 25+ 函数
|
||||
* (含 list/selector/create/update/info/del/batchDelete/resetPassword/unlock/workHandover 等)
|
||||
*/
|
||||
import { JnpfClient } from '../core/client.ts'
|
||||
import { loadWebModule } from './_loader.ts'
|
||||
|
||||
const USER_SRC = '/home/ubuntu/ccWorkDir/web/apps/jnpf-web-apps-main/src/api/permission/user.ts'
|
||||
|
||||
let cached: any = null
|
||||
|
||||
export async function initWebapi(client: JnpfClient): Promise<void> {
|
||||
if (cached) return
|
||||
const { initDefHttpShim } = await import('./_defhttp_shim.ts')
|
||||
initDefHttpShim(client)
|
||||
cached = await loadWebModule(USER_SRC)
|
||||
}
|
||||
|
||||
export function isWebapiLoaded(): boolean {
|
||||
return cached !== null
|
||||
}
|
||||
|
||||
export const loadUser: any = new Proxy({} as any, {
|
||||
get(_target, prop) {
|
||||
if (!cached) throw new Error('user 模块未初始化, 请先 await initWebapi(client)')
|
||||
return cached[prop]
|
||||
},
|
||||
})
|
||||
Reference in new issue
Block a user