PCWEB clsdk-pcweb 接入流程
PCWEB 负责浏览器端登录态、运行态菜单、页面注册、默认页跳转和页面按钮展示。PCWEB 不保存服务态密钥,也不替代后端接口权限校验。
接入步骤
- 创建或确认 PCWEB 仓。
- 安装
clsdk-pcweb。 - 初始化 SDK。
- 接入 router adapter。
registerPage注册pageCode和本地组件。- 登录后
rebuildRuntime。 - 默认页使用
runtime.defaultRoute。 - 普通后台页优先使用
clsdk-pcweb/components标准页面组件。 - 使用
canPage判断页面权限。 - 使用
canAction / ClPermissionButton判断按钮权限。 - 按钮
actionCode必须和菜单 JSON、后端CheckPermission对齐。 - PCWEB 不保存
SystemKey、PermanentKey、tempKey、x-app-key。 - 运行
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显示或隐藏。 - 构建通过。