diff --git a/docs/reference/plugin/plugins/access.md b/docs/reference/plugin/plugins/access.md index 8563003d..b06f8783 100644 --- a/docs/reference/plugin/plugins/access.md +++ b/docs/reference/plugin/plugins/access.md @@ -195,7 +195,7 @@ console.log(access.isDataReady()) - Promise,Promise resolve 的结果应对应着 `roles` 配置对象中的 `key`。 ```js import { access } from '@fesjs/fes'; -access.setRole(['admin']) +access.setRole('admin') ``` #### access.setAccess diff --git a/docs/reference/plugin/plugins/model.md b/docs/reference/plugin/plugins/model.md index 16e4b5ed..a28d2a22 100644 --- a/docs/reference/plugin/plugins/model.md +++ b/docs/reference/plugin/plugins/model.md @@ -53,6 +53,46 @@ export default { ``` +### @@initialState +在`beforeRender`的返回的内容会写入`@@initialState` +```js +export const beforeRender = { + loading: , + action() { + const { setRole } = access; + return new Promise((resolve) => { + setTimeout(() => { + setRole('admin'); + // 初始化应用的全局状态,可以通过 useModel('@@initialState') 获取,具体用法看@/components/UserCenter 文件 + resolve({ + userName: 'harrywan' + }); + }, 1000); + }); + } +}; +```` +然后我们可以在其他组件中使用: +```vue + + + +``` + ## API diff --git a/docs/zh/reference/plugin/plugins/access.md b/docs/zh/reference/plugin/plugins/access.md index 8563003d..b06f8783 100644 --- a/docs/zh/reference/plugin/plugins/access.md +++ b/docs/zh/reference/plugin/plugins/access.md @@ -195,7 +195,7 @@ console.log(access.isDataReady()) - Promise,Promise resolve 的结果应对应着 `roles` 配置对象中的 `key`。 ```js import { access } from '@fesjs/fes'; -access.setRole(['admin']) +access.setRole('admin') ``` #### access.setAccess diff --git a/docs/zh/reference/plugin/plugins/model.md b/docs/zh/reference/plugin/plugins/model.md index 16e4b5ed..a28d2a22 100644 --- a/docs/zh/reference/plugin/plugins/model.md +++ b/docs/zh/reference/plugin/plugins/model.md @@ -53,6 +53,46 @@ export default { ``` +### @@initialState +在`beforeRender`的返回的内容会写入`@@initialState` +```js +export const beforeRender = { + loading: , + action() { + const { setRole } = access; + return new Promise((resolve) => { + setTimeout(() => { + setRole('admin'); + // 初始化应用的全局状态,可以通过 useModel('@@initialState') 获取,具体用法看@/components/UserCenter 文件 + resolve({ + userName: 'harrywan' + }); + }, 1000); + }); + } +}; +```` +然后我们可以在其他组件中使用: +```vue + + + +``` + ## API