feat: pattern config

This commit is contained in:
ex_zhangwenlei@exiot.cmcc
2024-01-11 23:53:53 +08:00
parent 53af03648e
commit 2ba3bb036b
18 changed files with 621 additions and 147 deletions

View File

@@ -175,3 +175,4 @@ export const defaultImageList = [
url: 'https://24years.top/resource/image/image5.png'
}
]
export const defaultPatternList=[19,20,21,38,55,54,53,70,87,88,89,23,40,57,74,91,92,93,76,59,42,25,24,27,28,29,46,63,62,61,78,95,96,97,31,48,65,66,67,33,50,84,101]

View File

@@ -1,5 +1,5 @@
import { defineStore } from 'pinia';
import { defaultMusicList,defaultImageList } from './data'
import { defaultMusicList,defaultImageList,defaultPatternList } from './data'
import {IMusic,IImage} from '@/types/storeType';
// import { IPrizeConfig } from '@/types/storeType';
export const useGlobalConfig = defineStore('global', {
@@ -17,7 +17,9 @@ export const useGlobalConfig = defineStore('global', {
cardHeight: 200,
textColor: '#ffffff',
luckyCardColor:'#ECB1AC',
textSize: 30
textSize: 30,
patternColor:'#1b66c9',
patternList:defaultPatternList as number[],
},
musicList: defaultMusicList as IMusic[],
imageList:defaultImageList as IImage[],
@@ -68,6 +70,14 @@ export const useGlobalConfig = defineStore('global', {
getTextSize(state) {
return state.globalConfig.theme.textSize;
},
// 获取图案颜色
getPatterColor(state){
return state.globalConfig.theme.patternColor;
},
// 获取图案列表
getPatternList(state){
return state.globalConfig.theme.patternList;
},
// 获取音乐列表
getMusicList(state) {
return state.globalConfig.musicList;
@@ -122,6 +132,18 @@ export const useGlobalConfig = defineStore('global', {
setTextSize(textSize: number) {
this.globalConfig.theme.textSize = textSize;
},
// 设置图案颜色
setPatterColor(patterColor: string) {
this.globalConfig.theme.patternColor = patterColor;
},
// 设置图案列表
setPatternList(patternList: number[]) {
this.globalConfig.theme.patternList = patternList;
},
// 重置图案列表
resetPatternList() {
this.globalConfig.theme.patternList = defaultPatternList;
},
// 添加音乐
addMusic(music: IMusic) {
// 验证音乐是否已存在看name字段
@@ -200,7 +222,9 @@ export const useGlobalConfig = defineStore('global', {
cardWidth: 200,
cardHeight: 140,
textColor: '#ffffff',
textSize: 30
textSize: 30,
patternColor: '#1b66c9',
patternList:defaultPatternList,
},
musicList: defaultMusicList as IMusic[],

View File

@@ -1,10 +1,12 @@
import {usePersonConfig} from './personConfig';
import { usePrizeConfig } from './prizeConfig';
import {useGlobalConfig} from './globalConfig';
import {useSystem} from './system';
export default function useStore() {
return {
personConfig:usePersonConfig(),
prizeConfig:usePrizeConfig(),
globalConfig:useGlobalConfig()
globalConfig:useGlobalConfig(),
system:useSystem(),
};
}

View File

@@ -63,7 +63,6 @@ export const usePersonConfig = defineStore('person', {
// person.prizeTime = new Date().toString()
}
});
console.log('person;;',person)
this.personConfig.alreadyPersonList.push(person);
});
},

30
src/store/system.ts Normal file
View File

@@ -0,0 +1,30 @@
import { defineStore } from 'pinia';
// import { IPrizeConfig } from '@/types/storeType';
export const useSystem = defineStore('system', {
state() {
return {
isMobile:false
};
},
getters: {
getIsMobile(state) {
return state.isMobile;
},
},
actions: {
setIsMobile(isMobile: boolean) {
this.isMobile = isMobile;
},
},
persist: {
enabled: true,
strategies: [
{
// 如果要存储在localStorage中
// storage: localStorage,
// key: 'globalConfig',
// paths: ['globalConfig'],
},
],
},
})