feat: 将存储的按照功能分离
This commit is contained in:
@@ -68,8 +68,8 @@
|
||||
<script setup>
|
||||
import { ref, computed, nextTick } from "vue";
|
||||
import { zniconsMap } from "@/static/fonts/znicons.js";
|
||||
import { useAppStore } from "@/store";
|
||||
const appStore = useAppStore();
|
||||
import { usePictureStore } from "@/store";
|
||||
const pictureStore = usePictureStore();
|
||||
|
||||
// Props定义
|
||||
const props = defineProps({
|
||||
@@ -170,7 +170,7 @@ const handleSwiperChange = (e) => {
|
||||
};
|
||||
|
||||
const handlePreviewClick = () => {
|
||||
appStore.setPreviewImageData(thumbnails.value);
|
||||
pictureStore.setPreviewImageData(thumbnails.value);
|
||||
uni.navigateTo({
|
||||
url: `/pages/goods/album/index`,
|
||||
});
|
||||
|
||||
@@ -35,14 +35,14 @@
|
||||
import { ref } from "vue";
|
||||
import TopNavBar from "@/components/TopNavBar/index.vue";
|
||||
import { onLoad } from "@dcloudio/uni-app";
|
||||
import { useAppStore } from "@/store";
|
||||
const appStore = useAppStore();
|
||||
import { usePictureStore } from "@/store";
|
||||
const pictureStore = usePictureStore();
|
||||
|
||||
const albumList = ref([]);
|
||||
|
||||
onLoad(() => {
|
||||
albumList.value = appStore.previewImageData;
|
||||
appStore.setPreviewImageData([]);
|
||||
albumList.value = pictureStore.previewImageData;
|
||||
pictureStore.setPreviewImageData([]);
|
||||
});
|
||||
|
||||
// 处理图片预览
|
||||
|
||||
@@ -4,9 +4,7 @@ import { devUrl, wssDevUrl } from "../../request/base/baseUrl";
|
||||
export const useAppStore = defineStore("app", {
|
||||
state() {
|
||||
return {
|
||||
title: "",
|
||||
sceneId: "", // 分身场景id
|
||||
previewImageData: [], // 预览图片数据
|
||||
serverConfig: { // 服务器配置
|
||||
baseUrl: devUrl, // 服务器基础地址
|
||||
wssUrl: wssDevUrl, // 服务器ws地址
|
||||
@@ -16,15 +14,9 @@ export const useAppStore = defineStore("app", {
|
||||
getters: {},
|
||||
|
||||
actions: {
|
||||
setData(data) {
|
||||
this.title = data;
|
||||
},
|
||||
setSceneId(data) {
|
||||
this.sceneId = data;
|
||||
},
|
||||
setPreviewImageData(data) {
|
||||
this.previewImageData = data;
|
||||
},
|
||||
setServerConfig(data) {
|
||||
this.serverConfig = data;
|
||||
},
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { useAppStore } from "./app";
|
||||
import { useSelectedDateStore } from "./selectedDate";
|
||||
import { usePictureStore } from "./picture";
|
||||
|
||||
export { useAppStore, useSelectedDateStore };
|
||||
export { useAppStore, useSelectedDateStore, usePictureStore };
|
||||
17
src/store/modules/picture.js
Normal file
17
src/store/modules/picture.js
Normal file
@@ -0,0 +1,17 @@
|
||||
import { defineStore } from "pinia";
|
||||
|
||||
export const usePictureStore = defineStore("picture", {
|
||||
state() {
|
||||
return {
|
||||
previewImageData: [], // 预览图片数据
|
||||
};
|
||||
},
|
||||
|
||||
actions: {
|
||||
setPreviewImageData(data) {
|
||||
this.previewImageData = data;
|
||||
},
|
||||
},
|
||||
|
||||
unistorage: true,
|
||||
});
|
||||
Reference in New Issue
Block a user