Skip to content

Commit

Permalink
docs: refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
posva committed May 15, 2024
1 parent a29ff0f commit 947bf65
Show file tree
Hide file tree
Showing 39 changed files with 544 additions and 541 deletions.
6 changes: 3 additions & 3 deletions packages/docs/core-concepts/actions.md
Original file line number Diff line number Diff line change
Expand Up @@ -116,13 +116,13 @@ import { defineStore } from 'pinia'

export const useCounterStore = defineStore('counter', {
state: () => ({
count: 0
count: 0,
}),
actions: {
increment() {
this.count++
}
}
},
},
})
```

Expand Down
2 changes: 1 addition & 1 deletion packages/docs/core-concepts/outside-component-usage.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ If you are not doing any SSR (Server Side Rendering), any call of `useStore()` a

```js
import { useUserStore } from '@/stores/user'
import { createPinia } from 'pinia';
import { createPinia } from 'pinia'
import { createApp } from 'vue'
import App from './App.vue'

Expand Down
2 changes: 1 addition & 1 deletion packages/docs/introduction.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ Pinia [started](https://github.com/vuejs/pinia/commit/06aeef54e2cad66696063c6282

## Why should I use Pinia?

<!--
<!--
https://masteringpinia.com/lessons/why-use-pinia
-->

Expand Down
12 changes: 6 additions & 6 deletions packages/docs/zh/api/enums/pinia.MutationType.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
sidebar: "auto"
sidebar: 'auto'
editLinks: false
sidebarDepth: 3
---
Expand All @@ -16,29 +16,29 @@ SubscriptionCallback 的可能类型

### direct %{#direct}%

**direct** = ``"direct"``
**direct** = `"direct"`

Direct mutation of the state:

- `store.name = 'new name'`
- `store.$state.name = 'new name'`
- `store.list.push('new item')`

___
---

### patchFunction %{#patchfunction}%

**patchFunction** = ``"patch function"``
**patchFunction** = `"patch function"`

通过 `$patch` 和一个函数更改 state:

- `store.$patch(state => state.name = 'newName')`

___
---

### patchObject %{#patchobject}%

**patchObject** = ``"patch object"``
**patchObject** = `"patch object"`

通过 `$patch` 和一个对象更改 state:

Expand Down
14 changes: 7 additions & 7 deletions packages/docs/zh/api/interfaces/pinia.DefineSetupStoreOptions.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
sidebar: "auto"
sidebar: 'auto'
editLinks: false
sidebarDepth: 3
---
Expand All @@ -19,12 +19,12 @@ sidebarDepth: 3

## 类型参数 %{#type-parameters}%

| 名称 | 类型 |
| :------ | :------ |
| `Id` | extends `string` |
| `S` | extends [`StateTree`](../modules/pinia.md#statetree) |
| `G` | `G` |
| `A` | `A` |
| 名称 | 类型 |
| :--- | :--------------------------------------------------- |
| `Id` | extends `string` |
| `S` | extends [`StateTree`](../modules/pinia.md#statetree) |
| `G` | `G` |
| `A` | `A` |

## 层次结构 %{#hierarchy}%

Expand Down
32 changes: 16 additions & 16 deletions packages/docs/zh/api/interfaces/pinia.DefineStoreOptions.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
sidebar: "auto"
sidebar: 'auto'
editLinks: false
sidebarDepth: 3
---
Expand All @@ -19,12 +19,12 @@ sidebarDepth: 3

## 类型参数 %{#type-parameters}%

| 名字 | 类型 |
| :------ | :------ |
| `Id` | extends `string` |
| `S` | extends [`StateTree`](../modules/pinia.md#statetree) |
| `G` | `G` |
| `A` | `A` |
| 名字 | 类型 |
| :--- | :--------------------------------------------------- |
| `Id` | extends `string` |
| `S` | extends [`StateTree`](../modules/pinia.md#statetree) |
| `G` | `G` |
| `A` | `A` |

## 层次结构 %{#hierarchy}%

Expand All @@ -40,23 +40,23 @@ sidebarDepth: 3

action 的可选对象

___
---

### getters %{#getters}%

`Optional` **getters**: `G` & `ThisType`<`UnwrapRef`<`S`\> & [`_StoreWithGetters`](../modules/pinia.md#_storewithgetters)<`G`\> & [`PiniaCustomProperties`](pinia.PiniaCustomProperties.md)<`string`, [`StateTree`](../modules/pinia.md#statetree), [`_GettersTree`](../modules/pinia.md#_getterstree)<[`StateTree`](../modules/pinia.md#statetree)\>, [`_ActionsTree`](../modules/pinia.md#_actionstree)\>\> & [`_GettersTree`](../modules/pinia.md#_getterstree)<`S`\>

getter 的可选对象

___
---

### id %{#id}%

**id**: `Id`

唯一的字符串密钥,用于识别整个应用中的 store。

___
---

### state %{#state}%

Expand Down Expand Up @@ -91,21 +91,21 @@ ___
```ts
const useStore = defineStore('main', {
state: () => ({
n: useLocalStorage('key', 0)
n: useLocalStorage('key', 0),
}),
hydrate(storeState, initialState) {
// @ts-expect-error: https://github.com/microsoft/TypeScript/issues/43826
storeState.n = useLocalStorage('key', 0)
}
},
})
```

#### 参数

| 名字 | 类型 | 描述 |
| :------ | :------ | :------ |
| `storeState` | `UnwrapRef`<`S`\> | the current state in the store |
| `initialState` | `UnwrapRef`<`S`\> | initialState |
| 名字 | 类型 | 描述 |
| :------------- | :---------------- | :----------------------------- |
| `storeState` | `UnwrapRef`<`S`\> | the current state in the store |
| `initialState` | `UnwrapRef`<`S`\> | initialState |

#### 返回值

Expand Down
10 changes: 5 additions & 5 deletions packages/docs/zh/api/interfaces/pinia.DefineStoreOptionsBase.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
sidebar: "auto"
sidebar: 'auto'
editLinks: false
sidebarDepth: 3
---
Expand All @@ -16,10 +16,10 @@ sidebarDepth: 3

## 类型参数 %{#type-parameters}%

| Name | Type |
| :------ | :------ |
| `S` | extends [`StateTree`](../modules/pinia.md#statetree) |
| `Store` | `Store` |
| Name | Type |
| :------ | :--------------------------------------------------- |
| `S` | extends [`StateTree`](../modules/pinia.md#statetree) |
| `Store` | `Store` |

## 层次结构 %{#hierarchy}%

Expand Down
32 changes: 16 additions & 16 deletions packages/docs/zh/api/interfaces/pinia.DefineStoreOptionsInPlugin.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
sidebar: "auto"
sidebar: 'auto'
editLinks: false
sidebarDepth: 3
---
Expand All @@ -14,16 +14,16 @@ sidebarDepth: 3

## 类型参数 %{#type-parameters}%

| 名字 | 类型 |
| :------ | :------ |
| `Id` | extends `string` |
| `S` | extends [`StateTree`](../modules/pinia.md#statetree) |
| `G` | `G` |
| `A` | `A` |
| 名字 | 类型 |
| :--- | :--------------------------------------------------- |
| `Id` | extends `string` |
| `S` | extends [`StateTree`](../modules/pinia.md#statetree) |
| `G` | `G` |
| `A` | `A` |

## 层次结构 %{#hierarchy}%

- `Omit`<[`DefineStoreOptions`](pinia.DefineStoreOptions.md)<`Id`, `S`, `G`, `A`\>, ``"id"`` \| ``"actions"``\>
- `Omit`<[`DefineStoreOptions`](pinia.DefineStoreOptions.md)<`Id`, `S`, `G`, `A`\>, `"id"` \| `"actions"`\>

**`DefineStoreOptionsInPlugin`**

Expand All @@ -37,7 +37,7 @@ sidebarDepth: 3
否则使用传递给 `defineStore()` 的对象。
如果没有定义 action,则默认为一个空对象。

___
---

### getters %{#getters}%

Expand All @@ -49,7 +49,7 @@ getter 的可选对象

Omit.getters

___
---

### state

Expand Down Expand Up @@ -88,21 +88,21 @@ Omit.state
```ts
const useStore = defineStore('main', {
state: () => ({
n: useLocalStorage('key', 0)
n: useLocalStorage('key', 0),
}),
hydrate(storeState, initialState) {
// @ts-expect-error: https://github.com/microsoft/TypeScript/issues/43826
storeState.n = useLocalStorage('key', 0)
}
},
})
```

#### 参数

| 名字 | 类型 | 描述 |
| :------ | :------ | :------ |
| `storeState` | `UnwrapRef`<`S`\> | the current state in the store |
| `initialState` | `UnwrapRef`<`S`\> | initialState |
| 名字 | 类型 | 描述 |
| :------------- | :---------------- | :----------------------------- |
| `storeState` | `UnwrapRef`<`S`\> | the current state in the store |
| `initialState` | `UnwrapRef`<`S`\> | initialState |

#### 返回值

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
sidebar: "auto"
sidebar: 'auto'
editLinks: false
sidebarDepth: 3
---
Expand Down
12 changes: 6 additions & 6 deletions packages/docs/zh/api/interfaces/pinia.Pinia.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
sidebar: "auto"
sidebar: 'auto'
editLinks: false
sidebarDepth: 3
---
Expand Down Expand Up @@ -30,15 +30,15 @@ Every application must own its own pinia to be able to create stores

##### 参数

| Name | Type |
| :------ | :------ |
| Name | Type |
| :---- | :------------ |
| `app` | `App`<`any`\> |

##### 返回值

`void`

___
---

### state %{#state}%

Expand All @@ -56,8 +56,8 @@ ___

#### 参数 %{#paramters}%

| Name | Type | Description |
| :------ | :------ | :------ |
| Name | Type | Description |
| :------- | :------------------------------------ | :------------------ |
| `plugin` | [`PiniaPlugin`](pinia.PiniaPlugin.md) | store plugin to add |

#### 返回值
Expand Down
18 changes: 9 additions & 9 deletions packages/docs/zh/api/interfaces/pinia.PiniaCustomProperties.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
sidebar: "auto"
sidebar: 'auto'
editLinks: false
sidebarDepth: 3
---
Expand All @@ -14,12 +14,12 @@ sidebarDepth: 3

## 类型参数 %{#type-parameters}%

| 名称 | 类型 |
| :------ | :------ |
| `Id` | extends `string` = `string` |
| `S` | extends [`StateTree`](../modules/pinia.md#statetree) = [`StateTree`](../modules/pinia.md#statetree) |
| `G` | [`_GettersTree`](../modules/pinia.md#_getterstree)<`S`\> |
| `A` | [`_ActionsTree`](../modules/pinia.md#_actionstree) |
| 名称 | 类型 |
| :--- | :-------------------------------------------------------------------------------------------------- |
| `Id` | extends `string` = `string` |
| `S` | extends [`StateTree`](../modules/pinia.md#statetree) = [`StateTree`](../modules/pinia.md#statetree) |
| `G` | [`_GettersTree`](../modules/pinia.md#_getterstree)<`S`\> |
| `A` | [`_ActionsTree`](../modules/pinia.md#_actionstree) |

## Accessors %{#accessors}%

Expand All @@ -35,8 +35,8 @@ sidebarDepth: 3

#### 参数

| Name | Type |
| :------ | :------ |
| Name | Type |
| :------ | :------------------------------------------------------------------------- |
| `value` | `RouteLocationNormalizedLoaded` \| `Ref`<`RouteLocationNormalizedLoaded`\> |

#### 返回值
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
sidebar: "auto"
sidebar: 'auto'
editLinks: false
sidebarDepth: 3
---
Expand All @@ -14,6 +14,6 @@ sidebarDepth: 3

## 类型参数 %{#type-parameters}%

| 名称 | 类型 |
| :------ | :------ |
| `S` | extends [`StateTree`](../modules/pinia.md#statetree) = [`StateTree`](../modules/pinia.md#statetree) |
| 名称 | 类型 |
| :--- | :-------------------------------------------------------------------------------------------------- |
| `S` | extends [`StateTree`](../modules/pinia.md#statetree) = [`StateTree`](../modules/pinia.md#statetree) |
6 changes: 3 additions & 3 deletions packages/docs/zh/api/interfaces/pinia.PiniaPlugin.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
sidebar: "auto"
sidebar: 'auto'
editLinks: false
sidebarDepth: 3
---
Expand All @@ -21,8 +21,8 @@ sidebarDepth: 3

#### 参数

| 名称 | 类型 | 描述 |
| :------ | :------ | :------ |
| 名称 | 类型 | 描述 |
| :-------- | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | :------ |
| `context` | [`PiniaPluginContext`](pinia.PiniaPluginContext.md)<`string`, [`StateTree`](../modules/pinia.md#statetree), [`_GettersTree`](../modules/pinia.md#_getterstree)<[`StateTree`](../modules/pinia.md#statetree)\>, [`_ActionsTree`](../modules/pinia.md#_actionstree)\> | Context |

#### 返回值
Expand Down

0 comments on commit 947bf65

Please sign in to comment.