Skip to content

PCWEB clsdk-pcweb 接入流程

PCWEB 负责浏览器端登录态、运行态菜单、页面注册、默认页跳转和页面按钮展示。PCWEB 不保存服务态密钥,也不替代后端接口权限校验。

接入步骤

  1. 创建或确认 PCWEB 仓。
  2. 安装 clsdk-pcweb
  3. 初始化 SDK。
  4. 接入 router adapter。
  5. registerPage 注册 pageCode 和本地组件。
  6. 登录后 rebuildRuntime
  7. 默认页使用 runtime.defaultRoute
  8. 普通后台页优先使用 clsdk-pcweb/components 标准页面组件。
  9. 使用 canPage 判断页面权限。
  10. 使用 canAction / ClPermissionButton 判断按钮权限。
  11. 按钮 actionCode 必须和菜单 JSON、后端 CheckPermission 对齐。
  12. PCWEB 不保存 SystemKeyPermanentKeytempKeyx-app-key
  13. 运行 npm install / npm run build,具体命令以项目 package.json 为准。

安装方式

bash
npm install git+https://gitee.com/lixiaodongdong/clsdk-pcweb.git#版本号

SDK README 版本示例为:

bash
npm install git+https://gitee.com/lixiaodongdong/clsdk-pcweb.git#v0.1.2

正式项目应引用明确 tag,不允许正式提交本地 file: 依赖。

页面注册

PCWEB 动态页面必须先通过 registerPage 把菜单中的 pageCode 和本地组件绑定起来。菜单只告诉前端用户能看到什么页面,真正挂载到路由时还需要本地组件存在。

ts
sdk.registerPage({
  pageCode: "demo.rule.list",
  routeName: "demo-rule-list",
  routePath: "/demo/rule/list",
  componentPath: "src/views/demo/rule/list.vue",
  componentLoader: () => import("./views/demo/rule/list.vue")
});

权限展示

  • canPage("demo.rule.list") 只判断页面是否可见。
  • canAction("demo.rule.create")ClPermissionButton 判断按钮或动作是否可见。
  • 按钮隐藏不等于接口安全,后端写接口仍必须 CheckPermission
  • 只做 .view 页面权限不算完成按钮和接口权限闭环。

验收口径

  • 能登录。
  • 能选择角色。
  • 能拉取菜单。
  • 默认页正确。
  • 页面按权限显示。
  • 按钮按 actionCode 显示或隐藏。
  • 构建通过。

CL 正式文档平台