From 0937dc0eacb9659432ff11ce092cb271ac7d9bb7 Mon Sep 17 00:00:00 2001
From: suguo <25950955@qq.com>
Date: Fri, 2 May 2025 15:25:49 +0800
Subject: [PATCH] UP
---
src/store/product.js | 23 +++++++++++++++++++++++
src/views/about.vue | 8 ++++----
src/views/home.vue | 25 ++++++++++++-------------
test.http | 1 +
4 files changed, 40 insertions(+), 17 deletions(-)
create mode 100644 src/store/product.js
create mode 100644 test.http
diff --git a/src/store/product.js b/src/store/product.js
new file mode 100644
index 0000000..91dea69
--- /dev/null
+++ b/src/store/product.js
@@ -0,0 +1,23 @@
+import {defineStore} from 'pinia'
+
+
+export const useProductStore = defineStore('product', {
+ state: () => ({
+ products: [],
+ total: 0,
+ }),
+ actions: {
+ productSet(data,total) {
+ this.products = data;
+ // this.products.push(...data); //追加数据
+ this.total=total; //这里会更新
+ },
+ productTotalSet(total){
+ this.total=total
+ }
+ },
+ getters: {
+ count: (state) => state.products.length,
+ total: (state) => state.total,
+ }
+ })
\ No newline at end of file
diff --git a/src/views/about.vue b/src/views/about.vue
index 677b87d..ee12c8d 100644
--- a/src/views/about.vue
+++ b/src/views/about.vue
@@ -2,7 +2,7 @@
hello about
-Count: {{ tokenStore.count }}
+Count: {{ productStore.count }}