更新文档
Former-commit-id: 5c422b7840ae369c48138b6bd2794eae65e668f7 [formerly 5c422b7840ae369c48138b6bd2794eae65e668f7 [formerly 5c422b7840ae369c48138b6bd2794eae65e668f7 [formerly 5c422b7840ae369c48138b6bd2794eae65e668f7 [formerly e6461f0abb1d06928c404b05febbb771d39c5091 [formerly 5a15663dd319562e139a2ccf9a973ffec14bc048]]]]] Former-commit-id: 14a9d48855cae85691a0893404bcce34d16a48fc Former-commit-id: b8f32fd16fe86f27c9d8a63d8ddea798c91df52a Former-commit-id: d091616f92a9a2ee4f5c642f754e96875c127e0f [formerly 9ddba057ecab249de41c9463f4372780c6ef9d6a] Former-commit-id: ae92250f8e80a9dc4a3c70ab4fa4934d1899c238 Former-commit-id: b25441aa5e752f294f66b8566aba80c175019087 Former-commit-id: fa22ac7804ebccef3cdc3ddf9f967ccd353d5947 Former-commit-id: e1bc647f666d9a4c2c3be3cffbad919bcbc19621 Former-commit-id: 5b6196a7a9ce18d7b2023bfbf131112606768955
This commit is contained in:
Submodule docs/.vuepress/dist updated: 0d94276e9d...4eed23f59e
@@ -102,6 +102,7 @@ D2Admin 仍然处于开发中,这里有一些暂时的计划:
|
||||
* socket 连接
|
||||
* 浏览器版本提示
|
||||
* 日志控制台
|
||||
* d2-container 组件 ghost 模式和 full 模式合并
|
||||
* `1.1.4 已完成` 自定义滚动条
|
||||
* `1.1.4 已完成` 多 tab 页结构
|
||||
* `1.1.3 已完成` 更换图表库
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
|
||||
首先建议您升级 node 版本 > 8,在以下环境测试可用
|
||||
|
||||
```{10}
|
||||
``` {10}
|
||||
➜ ~ npm -v
|
||||
5.6.0
|
||||
➜ ~ node -v
|
||||
@@ -27,6 +27,54 @@ v8.11.1
|
||||
推荐使用 [nrm](https://github.com/Pana/nrm) 管理 npm 源,不建议使用 cnpm
|
||||
:::
|
||||
|
||||
## 无法跳转路由
|
||||
|
||||
有可能你在 D2Admin 的基础上进行你的开发时,发现在登陆页面进行
|
||||
|
||||
``` js
|
||||
this.$router.push({ name: 'index' })
|
||||
```
|
||||
|
||||
跳转的时候页面并没有跳转,这是因为你很有可能没有进行下面的操作:
|
||||
|
||||
``` js
|
||||
Cookies.set('token', res.token, setting)
|
||||
```
|
||||
|
||||
原因根源是在 `src/router/index.js` 中有如下一段代码,根据 `token` 判断用户是否登陆
|
||||
|
||||
``` js {3-9}
|
||||
router.beforeEach((to, from, next) => {
|
||||
if (to.matched.some(r => r.meta.requiresAuth)) {
|
||||
if (Cookies.get('token')) {
|
||||
next()
|
||||
} else {
|
||||
next({
|
||||
name: 'login'
|
||||
})
|
||||
}
|
||||
} else {
|
||||
next()
|
||||
}
|
||||
})
|
||||
```
|
||||
|
||||
所以如果你没有存 token 字段在 cookie 中,路由鉴权机制将会重定向到登录页
|
||||
|
||||
如果你想修改基于 token 验证用户登陆状态的机制,请在 `./src` 下搜索 `token` 关键字并修改他们,但是我**十分不建议你修改它们**
|
||||
|
||||
最好的做法是在登陆后返回本次登陆的 token 并且存储在 cookie 中,然后在每次 ajax 请求时都携带这个 token 给后端做权限验证(必要的话你可以还可以增加 token 的更新机制)
|
||||
|
||||
::: tip 同样需要注意的地方
|
||||
除了需要在 cookie 中保存 token,你还要保存 uuid 字段,意为“用户唯一标识”
|
||||
|
||||
``` js
|
||||
Cookies.set('uuid', res.uuid, setting)
|
||||
```
|
||||
|
||||
D2Admin 会在很多地方使用 cookie 中的此字段区分用户,比如不同用户选择的不同主题的数据持久化,还有不同用户打开的多标签页数据的持久化存储。
|
||||
:::
|
||||
|
||||
## 文档运行报错
|
||||
|
||||
这里目前还有一个小遗憾,d2admin 使用的 webpack 版本不能符合 vuepress 的要求,所以如果你想在本地启动文档站点的服务,需要按下述步骤
|
||||
|
||||
Reference in New Issue
Block a user