From f741bfcbaa06a7bf0de13ab55af894a06895cd62 Mon Sep 17 00:00:00 2001 From: "WORK\\cirry" Date: Thu, 28 Apr 2022 12:32:20 +0800 Subject: [PATCH] =?UTF-8?q?feature:=20pinia=E6=B7=BB=E5=8A=A0=E6=8C=81?= =?UTF-8?q?=E4=B9=85=E5=8C=96=E5=AD=98=E5=82=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package.json | 1 + public/product.json | 0 src/main.ts | 2 ++ src/store/cart.ts | 5 ++- src/store/product.ts | 5 ++- tsconfig.json | 73 ++++++++++++++++++++++---------------------- yarn.lock | 9 +++++- 7 files changed, 56 insertions(+), 39 deletions(-) delete mode 100644 public/product.json diff --git a/package.json b/package.json index 3d55843..d95be4b 100644 --- a/package.json +++ b/package.json @@ -10,6 +10,7 @@ "dependencies": { "core-js": "^3.8.3", "pinia": "^2.0.13", + "pinia-plugin-persist": "^1.0.0", "vue": "^3.2.13" }, "devDependencies": { diff --git a/public/product.json b/public/product.json deleted file mode 100644 index e69de29..0000000 diff --git a/src/main.ts b/src/main.ts index e766dee..80f34a0 100644 --- a/src/main.ts +++ b/src/main.ts @@ -1,9 +1,11 @@ import { createApp } from 'vue' import App from './App.vue' import { createPinia } from "pinia"; +import piniaPersist from 'pinia-plugin-persist' // 1. 实例化pinia const pinia = createPinia() +pinia.use(piniaPersist) const app = createApp(App) diff --git a/src/store/cart.ts b/src/store/cart.ts index c1d35e6..a84df00 100644 --- a/src/store/cart.ts +++ b/src/store/cart.ts @@ -53,5 +53,8 @@ export const useCartStore = defineStore('cart', { this.checkStatus = checkoutStatus.FALSE } } - } + }, + // persist: { + // enabled: true + // } }) diff --git a/src/store/product.ts b/src/store/product.ts index f6068f3..de2f605 100644 --- a/src/store/product.ts +++ b/src/store/product.ts @@ -16,5 +16,8 @@ export const useProductStore = defineStore('product', { productItem.inventory-- } } - } + }, + // persist: { + // enabled: true + // } }) diff --git a/tsconfig.json b/tsconfig.json index 9772821..898c17e 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,40 +1,41 @@ { - "compilerOptions": { - "target": "esnext", - "module": "esnext", - "strict": true, - "jsx": "preserve", - "moduleResolution": "node", - "skipLibCheck": true, - "esModuleInterop": true, - "allowSyntheticDefaultImports": true, - "forceConsistentCasingInFileNames": true, - "useDefineForClassFields": true, - "sourceMap": true, - "baseUrl": ".", - "types": [ - "webpack-env" - ], - "paths": { - "@/*": [ - "src/*" - ] + "compilerOptions": { + "target": "esnext", + "module": "esnext", + "strict": true, + "jsx": "preserve", + "moduleResolution": "node", + "skipLibCheck": true, + "esModuleInterop": true, + "allowSyntheticDefaultImports": true, + "forceConsistentCasingInFileNames": true, + "useDefineForClassFields": true, + "sourceMap": true, + "baseUrl": ".", + "types": [ + "webpack-env", + "pinia-plugin-persist" + ], + "paths": { + "@/*": [ + "src/*" + ] + }, + "lib": [ + "esnext", + "dom", + "dom.iterable", + "scripthost" + ] }, - "lib": [ - "esnext", - "dom", - "dom.iterable", - "scripthost" + "include": [ + "src/**/*.ts", + "src/**/*.tsx", + "src/**/*.vue", + "tests/**/*.ts", + "tests/**/*.tsx" + ], + "exclude": [ + "node_modules" ] - }, - "include": [ - "src/**/*.ts", - "src/**/*.tsx", - "src/**/*.vue", - "tests/**/*.ts", - "tests/**/*.tsx" - ], - "exclude": [ - "node_modules" - ] } diff --git a/yarn.lock b/yarn.lock index 239d931..ed7af7d 100644 --- a/yarn.lock +++ b/yarn.lock @@ -4657,6 +4657,13 @@ picomatch@^2.0.4, picomatch@^2.2.1, picomatch@^2.3.1: resolved "https://registry.npmmirror.com/picomatch/-/picomatch-2.3.1.tgz#3ba3833733646d9d3e4995946c1365a67fb07a42" integrity sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA== +pinia-plugin-persist@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/pinia-plugin-persist/-/pinia-plugin-persist-1.0.0.tgz#fc696f225527f30bd5955109fafadd43c725e888" + integrity sha512-M4hBBd8fz/GgNmUPaaUsC29y1M09lqbXrMAHcusVoU8xlQi1TqgkWnnhvMikZwr7Le/hVyMx8KUcumGGrR6GVw== + dependencies: + vue-demi "^0.12.1" + pinia@^2.0.13: version "2.0.13" resolved "https://registry.yarnpkg.com/pinia/-/pinia-2.0.13.tgz#6656fc290dae120a9f0cb2f5c520df400d41b8c5" @@ -5938,7 +5945,7 @@ vary@~1.1.2: resolved "https://registry.npmmirror.com/vary/-/vary-1.1.2.tgz#2299f02c6ded30d4a5961b0b9f74524a18f634fc" integrity sha512-BNGbWLfd0eUPabhkXUVm0j8uuvREyTh5ovRa/dyow/BqAbZJyC+5fU+IzQOzmAKzYqYRAISoRhdQr3eIZ/PXqg== -vue-demi@*: +vue-demi@*, vue-demi@^0.12.1: version "0.12.5" resolved "https://registry.yarnpkg.com/vue-demi/-/vue-demi-0.12.5.tgz#8eeed566a7d86eb090209a11723f887d28aeb2d1" integrity sha512-BREuTgTYlUr0zw0EZn3hnhC3I6gPWv+Kwh4MCih6QcAeaTlaIX0DwOVN0wHej7hSvDPecz4jygy/idsgKfW58Q==