From 629271d67f86113dfa74d1734321bbb72f98d6f3 Mon Sep 17 00:00:00 2001 From: Waset Date: Sat, 22 Oct 2022 22:13:19 +0800 Subject: [PATCH] =?UTF-8?q?perf(store):=20=F0=9F=9A=80=20=E6=80=A7?= =?UTF-8?q?=E8=83=BD=E4=BC=98=E5=8C=96=20(#12)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * perf(store): :rocket: 背景图片地址 http 转 https * perf(store): :rocket: 修改插件引入方式 --- composables/useIndex.ts | 4 +++- composables/useSet.ts | 2 +- plugins/pinia.client.ts | 13 +++++-------- 3 files changed, 9 insertions(+), 10 deletions(-) diff --git a/composables/useIndex.ts b/composables/useIndex.ts index 3a2203c..380397c 100644 --- a/composables/useIndex.ts +++ b/composables/useIndex.ts @@ -90,7 +90,9 @@ export const useIndexStore = definePiniaStore({ }, wallpaperImg(): string { - return `url(${this.list[Math.floor(Math.random() * this.list.length)].img_1024_768})` + let url = this.list[Math.floor(Math.random() * this.list.length)].img_1024_768 + url = url.replace(/^http:\/\//i, 'https://') + return `url(${url})` }, searchWebisteListHeight() { diff --git a/composables/useSet.ts b/composables/useSet.ts index 7f67d70..3e8136e 100644 --- a/composables/useSet.ts +++ b/composables/useSet.ts @@ -63,5 +63,5 @@ export const useSetStore = definePiniaStore({ * * @see https://github.com/prazdevs/pinia-plugin-persistedstate */ - persist: false, + persist: true, }) diff --git a/plugins/pinia.client.ts b/plugins/pinia.client.ts index d92388a..f1bad63 100644 --- a/plugins/pinia.client.ts +++ b/plugins/pinia.client.ts @@ -1,10 +1,7 @@ +import piniaPluginPersistedstate from 'pinia-plugin-persistedstate' /** - * 在客户端引入 pinia 持续化存储插件 + * 客户端引入 pinia 持续化存储插件 */ -import piniaPluginPersistedstate from 'pinia-plugin-persistedstate' - -const pinia = ({ $pinia }) => { - $pinia.use(piniaPluginPersistedstate) -} - -export default pinia +export default defineNuxtPlugin(({ $pinia }) => { + $pinia?.use(piniaPluginPersistedstate) +})