Skip to content

Commit

Permalink
docs(zh): translation comments (#2079)
Browse files Browse the repository at this point in the history
  • Loading branch information
Megasu committed Apr 3, 2023
1 parent c095ccf commit ccdbf38
Show file tree
Hide file tree
Showing 8 changed files with 24 additions and 24 deletions.
2 changes: 1 addition & 1 deletion packages/docs/zh/cookbook/migration-vuex.md
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ export const useAuthUserStore = defineStore('auth/user', {
this.lastName = payload.lastName
this.userId = payload.userId
},
// easily reset state using `$reset`
// 使用 `$reset` 可以轻松重置 state
clearUser () {
this.$reset()
}
Expand Down
6 changes: 3 additions & 3 deletions packages/docs/zh/core-concepts/actions.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,11 @@ Action 可以像函数或者通常意义上的方法一样被调用:
```vue
<script setup>
const store = useCounterStore()
// call the action as a method of the store
// action 作为 store 的方法进行调用
store.randomizeCounter()
</script>
<template>
<!-- Even on the template -->
<!-- 即使在模板中也可以 -->
<button @click="store.randomizeCounter()">Randomize</button>
</template>
```
Expand Down Expand Up @@ -208,7 +208,7 @@ unsubscribe()
```vue
<script setup>
const someStore = useSomeStore()
// this subscription will be kept even after the component is unmounted
// 该订阅器将被保留,即使组件被卸载
someStore.$onAction(callback, true)
</script>
```
4 changes: 2 additions & 2 deletions packages/docs/zh/core-concepts/getters.md
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,8 @@ export const useStore = defineStore('main', {
import { useUserListStore } from './store'
const userList = useUserListStore()
const { getUserById } = storeToRefs(userList)
// note you will have to use `getUserById.value` to access
// the function within the <script setup>
// 请注意,你需要使用 `getUserById.value` 来访问
// <script setup> 中的函数
</script>
<template>
Expand Down
22 changes: 11 additions & 11 deletions packages/docs/zh/core-concepts/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ Setup store 比 [Option Store](#option-stores) 带来了更多的灵活性,因
```vue
<script setup>
import { useCounterStore } from '@/stores/counter'
// access the `store` variable anywhere in the component
// 在组件的任何地方访问 `store` 变量
const store = useCounterStore()
</script>
```
Expand All @@ -93,16 +93,16 @@ const store = useCounterStore()
```vue
<script setup>
const store = useCounterStore()
// ❌ This won't work because it breaks reactivity
// it's the same as destructuring from `props`
// ❌ 这样是不可行的,因为它会破坏响应性
// 就与直接解构 `props` 一样
const { name, doubleCount } = store // [!code warning]
name // will always be "Eduardo" // [!code warning]
doubleCount // will always be 0 // [!code warning]
name // 将始终是 "Eduardo" // [!code warning]
doubleCount // 将始终是 0 // [!code warning]
setTimeout(() => {
store.increment()
}, 1000)
// ✅ this one will be reactive
// 💡 but you could also just use `store.doubleCount` directly
// ✅ 这样写是响应式的
// 💡 当然你也可以直接使用 `store.doubleCount`
const doubleValue = computed(() => store.doubleCount)
</script>
```
Expand All @@ -113,11 +113,11 @@ const doubleValue = computed(() => store.doubleCount)
<script setup>
import { storeToRefs } from 'pinia'
const store = useCounterStore()
// `name` and `doubleCount` are reactive refs
// This will also extract refs for properties added by plugins
// but skip any action or non reactive (non ref/reactive) property
// `name` `doubleCount` 都是响应式的 ref
// 这也会提取插件添加的 ref 属性
// 但会跳过任何 action 或非响应式(非 ref/reactive)属性
const { name, doubleCount } = storeToRefs(store)
// the increment action can just be destructured
// 作为 action 的 increment 可以直接解构
const { increment } = store
</script>
```
2 changes: 1 addition & 1 deletion packages/docs/zh/core-concepts/plugins.md
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ declare module 'pinia' {
// 你也可以定义更简单的值
simpleNumber: number

// type the router added by the plugin above (#adding-new-external-properties)
// 添加路由(#adding-new-external-properties)
router: Router
}
}
Expand Down
2 changes: 1 addition & 1 deletion packages/docs/zh/core-concepts/state.md
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ cartStore.$subscribe((mutation, state) => {
```vue
<script setup>
const someStore = useSomeStore()
// this subscription will be kept even after the component is unmounted
// 该订阅器将被保留,即使组件被卸载
someStore.$subscribe(callback, { detached: true })
</script>
```
Expand Down
6 changes: 3 additions & 3 deletions packages/docs/zh/introduction.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,13 @@ export const useCounterStore = defineStore('counter', {
import { useCounterStore } from '@/stores/counter'
const counter = useCounterStore()
counter.count++
// with autocompletion
// 自动补全!
counter.$patch({ count: counter.count + 1 })
// or using an action instead
// 或使用 action 代替
counter.increment()
</script>
<template>
<!-- Access the state directly from the store -->
<!-- 直接从 store 中访问 state -->
<div>Current Count: {{ counter.count }}</div>
</template>
```
Expand Down
4 changes: 2 additions & 2 deletions packages/docs/zh/ssr/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@

```vue
<script setup>
// this works because pinia knows what application is running inside of
// `setup`
// 这是可行的,
// 因为 pinia 知道在 `setup` 中运行的是什么程序。
const main = useMainStore()
</script>
```
Expand Down

0 comments on commit ccdbf38

Please sign in to comment.