{"id":20551425,"url":"https://github.com/chenjinxinlove/dva-ts-auth","last_synced_at":"2025-04-14T11:21:05.473Z","repository":{"id":143817774,"uuid":"155654498","full_name":"chenjinxinlove/dva-ts-auth","owner":"chenjinxinlove","description":"dva-ts-auth基于antd-pro 1 用ts改造而成，添加了完成的权限认证和动态菜单  ","archived":false,"fork":false,"pushed_at":"2018-11-16T09:29:36.000Z","size":248,"stargazers_count":12,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-28T00:41:18.076Z","etag":null,"topics":["ant-design","ant-design-pro","antd","dva","react","redux","redux-saga","typescript"],"latest_commit_sha":null,"homepage":"http://www.chenjinxinlove.com/dva-ts-auth/#/","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/chenjinxinlove.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-11-01T03:04:54.000Z","updated_at":"2021-06-26T15:04:41.000Z","dependencies_parsed_at":null,"dependency_job_id":"2caa759e-fadd-4e64-bfe3-728ce71991f9","html_url":"https://github.com/chenjinxinlove/dva-ts-auth","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chenjinxinlove%2Fdva-ts-auth","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chenjinxinlove%2Fdva-ts-auth/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chenjinxinlove%2Fdva-ts-auth/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chenjinxinlove%2Fdva-ts-auth/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/chenjinxinlove","download_url":"https://codeload.github.com/chenjinxinlove/dva-ts-auth/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248868767,"owners_count":21174758,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ant-design","ant-design-pro","antd","dva","react","redux","redux-saga","typescript"],"created_at":"2024-11-16T02:30:49.099Z","updated_at":"2025-04-14T11:21:05.464Z","avatar_url":"https://github.com/chenjinxinlove.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"### dva-ts-auth\n\n\n```\n\nnpm install\n\nnpm start 开发\n\nnpm build  构建\n\n\n```\n\n基于antd-pro 1 用ts改造而成，添加了完成的权限认证和动态菜单\n\n[预览地址](http://www.chenjinxinlove.com/dva-ts-auth/#/)\n\n没有认证的可以使用 https://github.com/chenjinxinlove/dva-ts\n#### 权限认证\n\n权限认证分三个级别\n\n##### 视图控制\n\n登陆之后后端返回\n\n```\n{\n  \"code\": 1,\n  \"data\": {\n    \"token\": \"kshdkhalsdjlajldja;lsjd\",\n    \"slideAuths\": [\n      \"/other\",\n      \"/other/upload\",\n      \"/upload/other/add\"\n    ],\n    \"apiAuths\": [\n      \"POST/api/upload\"\n    ]\n  }\n}\n```\nslideAuths是用于侧边栏和动态路由的生成，本地全部的路由和slideAuths取交集来确定用户的权限和根据交集来生成侧边栏\n##### 请求控制\napiAuths是全端控制api的权限，如何返回空就不控制，由后端控制，在request中统一进行了一层拦截\n\n##### 自定义组件\n\n重写button组件为AuthButton组件和认证组件AuthCheck，传入对应的url\n\n```\n\u003cdiv\u003e验证api权限/upload/other/add\u003c/div\u003e\n\u003cAuthButton url=\"/upload/other/add\"\u003e验证api权限/upload/other/add\u003c/AuthButton\u003e\n\u003cdiv\u003e验证api权限/upload/other/edit\u003c/div\u003e\n\u003cAuthButton url=\"/upload/other/edit\"\u003e验证api权限/upload/other/edit\u003c/AuthButton\u003e\n```\n返回的slideAuths中\n\n```\n/upload/other/add\n```\n就是用来进行组件控制的\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchenjinxinlove%2Fdva-ts-auth","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fchenjinxinlove%2Fdva-ts-auth","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchenjinxinlove%2Fdva-ts-auth/lists"}