]> git.ipfire.org Git - thirdparty/vuejs/pinia.git/commitdiff
docs(zh): translation comments (#2079)
author苏杰豪 <Megasu@qq.com>
Mon, 3 Apr 2023 09:17:09 +0000 (17:17 +0800)
committerGitHub <noreply@github.com>
Mon, 3 Apr 2023 09:17:09 +0000 (11:17 +0200)
packages/docs/zh/cookbook/migration-vuex.md
packages/docs/zh/core-concepts/actions.md
packages/docs/zh/core-concepts/getters.md
packages/docs/zh/core-concepts/index.md
packages/docs/zh/core-concepts/plugins.md
packages/docs/zh/core-concepts/state.md
packages/docs/zh/introduction.md
packages/docs/zh/ssr/index.md

index 2ae236f4d9b4d3f4647a06dbadc90aa8f9607ae5..c29956118fb4d6be39a42a45dee9f993ebc13c3c 100644 (file)
@@ -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()
     }
index b930e43f4ec87849539eacdd3196c7e108a41821..e521dd644cbcc45585ee92070246d27fbf88fa6e 100644 (file)
@@ -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>
 ```
@@ -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>
 ```
index 97e52affa473f64f35dd6fe56757e4116fe92ea4..4ac6ba68a23d796df0ff0f11ea27c483004656df 100644 (file)
@@ -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>
index 344fd4c72941c3ae97e097c82cce1e9eeee00636..52907709c423e7bc927c5ec04db4fff9dd47b342 100644 (file)
@@ -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>
 ```
@@ -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>
 ```
@@ -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>
 ```
index 6bc1ba4a5b9cd3e9157a467e93646001262de516..80972f00b993d818c707dde7a37ff388ba2e6129 100644 (file)
@@ -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
   }
 }
index 5b1371bf9510dc48b32e860e294db49cf25bba1f..72613effbce75b7e00fa084d60b8f9784bc2e214 100644 (file)
@@ -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>
 ```
index bf43e5dd3f42bb0e172cf994f73b91a8060122e2..97ac8512fc0b665a258f77c5ee957b9e77f8e8cc 100644 (file)
@@ -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>
 ```
index b9a692a6100a10cea1db1db71845a9838b71018c..d12d4fe0f23cfd8e3b43aba45b1c8971de0bd667 100644 (file)
@@ -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>
 ```