feat: fork同步代码
This commit is contained in:
File diff suppressed because one or more lines are too long
@@ -1,258 +1,271 @@
|
||||
import { defineStore } from 'pinia';
|
||||
import { defaultMusicList, defaultImageList, defaultPatternList } from './data'
|
||||
import { IMusic, IImage } from '@/types/storeType';
|
||||
import type { IImage, IMusic } from '@/types/storeType'
|
||||
import i18n, { browserLanguage } from '@/locales/i18n'
|
||||
import { defineStore } from 'pinia'
|
||||
import { defaultImageList, defaultMusicList, defaultPatternList } from './data'
|
||||
// import { IPrizeConfig } from '@/types/storeType';
|
||||
export const useGlobalConfig = defineStore('global', {
|
||||
state() {
|
||||
return {
|
||||
globalConfig: {
|
||||
rowCount: 17,
|
||||
isSHowPrizeList: true,
|
||||
isShowAvatar: true,
|
||||
topTitle: '大明内阁六部御前奏对',
|
||||
theme: {
|
||||
name: 'dracula',
|
||||
detail: { primary: '#0f5fd3' },
|
||||
cardColor: '#ff79c6',
|
||||
cardWidth: 140,
|
||||
cardHeight: 200,
|
||||
textColor: '#ffffff',
|
||||
luckyCardColor: '#ECB1AC',
|
||||
textSize: 30,
|
||||
patternColor: '#1b66c9',
|
||||
patternList: defaultPatternList as number[],
|
||||
},
|
||||
musicList: defaultMusicList as IMusic[],
|
||||
imageList: defaultImageList as IImage[],
|
||||
},
|
||||
currentMusic: {
|
||||
item: defaultMusicList[0],
|
||||
paused: true,
|
||||
},
|
||||
};
|
||||
state() {
|
||||
return {
|
||||
globalConfig: {
|
||||
rowCount: 17,
|
||||
isSHowPrizeList: true,
|
||||
topTitle: i18n.global.t('data.defaultTitle'),
|
||||
language: browserLanguage,
|
||||
theme: {
|
||||
name: 'dracula',
|
||||
detail: { primary: '#0f5fd3' },
|
||||
cardColor: '#ff79c6',
|
||||
cardWidth: 140,
|
||||
cardHeight: 200,
|
||||
textColor: '#ffffff',
|
||||
luckyCardColor: '#ECB1AC',
|
||||
textSize: 30,
|
||||
patternColor: '#1b66c9',
|
||||
patternList: defaultPatternList as number[],
|
||||
background: {}, // 背景颜色或图片
|
||||
},
|
||||
musicList: defaultMusicList as IMusic[],
|
||||
imageList: defaultImageList as IImage[],
|
||||
},
|
||||
currentMusic: {
|
||||
item: defaultMusicList[0],
|
||||
paused: true,
|
||||
},
|
||||
}
|
||||
},
|
||||
getters: {
|
||||
// 获取全部配置
|
||||
getGlobalConfig(state) {
|
||||
return state.globalConfig
|
||||
},
|
||||
getters: {
|
||||
// 获取全部配置
|
||||
getGlobalConfig(state) {
|
||||
return state.globalConfig;
|
||||
},
|
||||
// 获取标题
|
||||
getTopTitle(state) {
|
||||
return state.globalConfig.topTitle;
|
||||
},
|
||||
// 获取行数
|
||||
getRowCount(state) {
|
||||
return state.globalConfig.rowCount;
|
||||
},
|
||||
// 获取主题
|
||||
getTheme(state) {
|
||||
return state.globalConfig.theme;
|
||||
},
|
||||
// 获取卡片颜色
|
||||
getCardColor(state) {
|
||||
return state.globalConfig.theme.cardColor;
|
||||
},
|
||||
// 获取中奖颜色
|
||||
getLuckyColor(state) {
|
||||
return state.globalConfig.theme.luckyCardColor;
|
||||
},
|
||||
// 获取文字颜色
|
||||
getTextColor(state) {
|
||||
return state.globalConfig.theme.textColor;
|
||||
},
|
||||
// 获取卡片宽高
|
||||
getCardSize(state) {
|
||||
return {
|
||||
width: state.globalConfig.theme.cardWidth,
|
||||
height: state.globalConfig.theme.cardHeight
|
||||
}
|
||||
},
|
||||
// 获取文字大小
|
||||
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;
|
||||
},
|
||||
// 获取当前音乐
|
||||
getCurrentMusic(state) {
|
||||
return state.currentMusic;
|
||||
},
|
||||
// 获取图片列表
|
||||
getImageList(state) {
|
||||
return state.globalConfig.imageList;
|
||||
},
|
||||
// 获取是否显示奖品列表
|
||||
getIsShowPrizeList(state) {
|
||||
return state.globalConfig.isSHowPrizeList;
|
||||
},
|
||||
// 获取是否显示头像
|
||||
getIsShowAvatar(state) {
|
||||
return state.globalConfig.isShowAvatar;
|
||||
// 获取标题
|
||||
getTopTitle(state) {
|
||||
return state.globalConfig.topTitle
|
||||
},
|
||||
// 获取行数
|
||||
getRowCount(state) {
|
||||
return state.globalConfig.rowCount
|
||||
},
|
||||
// 获取主题
|
||||
getTheme(state) {
|
||||
return state.globalConfig.theme
|
||||
},
|
||||
// 获取卡片颜色
|
||||
getCardColor(state) {
|
||||
return state.globalConfig.theme.cardColor
|
||||
},
|
||||
// 获取中奖颜色
|
||||
getLuckyColor(state) {
|
||||
return state.globalConfig.theme.luckyCardColor
|
||||
},
|
||||
// 获取文字颜色
|
||||
getTextColor(state) {
|
||||
return state.globalConfig.theme.textColor
|
||||
},
|
||||
// 获取卡片宽高
|
||||
getCardSize(state) {
|
||||
return {
|
||||
width: state.globalConfig.theme.cardWidth,
|
||||
height: state.globalConfig.theme.cardHeight,
|
||||
}
|
||||
},
|
||||
// 获取文字大小
|
||||
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
|
||||
},
|
||||
// 获取当前音乐
|
||||
getCurrentMusic(state) {
|
||||
return state.currentMusic
|
||||
},
|
||||
// 获取图片列表
|
||||
getImageList(state) {
|
||||
return state.globalConfig.imageList
|
||||
},
|
||||
// 获取是否显示奖品列表
|
||||
getIsShowPrizeList(state) {
|
||||
return state.globalConfig.isSHowPrizeList
|
||||
},
|
||||
// 获取当前语言
|
||||
getLanguage(state) {
|
||||
return state.globalConfig.language
|
||||
},
|
||||
// 获取背景图片设置
|
||||
getBackground(state) {
|
||||
return state.globalConfig.theme.background
|
||||
},
|
||||
},
|
||||
actions: {
|
||||
// 设置rowCount
|
||||
setRowCount(rowCount: number) {
|
||||
this.globalConfig.rowCount = rowCount
|
||||
},
|
||||
// 设置标题
|
||||
setTopTitle(topTitle: string) {
|
||||
this.globalConfig.topTitle = topTitle
|
||||
},
|
||||
// 设置主题
|
||||
setTheme(theme: any) {
|
||||
const { name, detail } = theme
|
||||
this.globalConfig.theme.name = name
|
||||
this.globalConfig.theme.detail = detail
|
||||
},
|
||||
// 设置卡片颜色
|
||||
setCardColor(cardColor: string) {
|
||||
this.globalConfig.theme.cardColor = cardColor
|
||||
},
|
||||
// 设置中奖颜色
|
||||
setLuckyCardColor(luckyCardColor: string) {
|
||||
this.globalConfig.theme.luckyCardColor = luckyCardColor
|
||||
},
|
||||
// 设置文字颜色
|
||||
setTextColor(textColor: string) {
|
||||
this.globalConfig.theme.textColor = textColor
|
||||
},
|
||||
// 设置卡片宽高
|
||||
setCardSize(cardSize: { width: number, height: number }) {
|
||||
this.globalConfig.theme.cardWidth = cardSize.width
|
||||
this.globalConfig.theme.cardHeight = cardSize.height
|
||||
},
|
||||
// 设置文字大小
|
||||
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字段
|
||||
for (let i = 0; i < this.globalConfig.musicList.length; i++) {
|
||||
if (this.globalConfig.musicList[i].name === music.name) {
|
||||
return
|
||||
}
|
||||
}
|
||||
this.globalConfig.musicList.push(music)
|
||||
},
|
||||
actions: {
|
||||
// 设置rowCount
|
||||
setRowCount(rowCount: number) {
|
||||
this.globalConfig.rowCount = rowCount;
|
||||
},
|
||||
// 设置标题
|
||||
setTopTitle(topTitle: string) {
|
||||
this.globalConfig.topTitle = topTitle;
|
||||
},
|
||||
// 设置主题
|
||||
setTheme(theme: any) {
|
||||
const { name, detail } = theme;
|
||||
this.globalConfig.theme.name = name;
|
||||
this.globalConfig.theme.detail = detail;
|
||||
},
|
||||
// 设置卡片颜色
|
||||
setCardColor(cardColor: string) {
|
||||
this.globalConfig.theme.cardColor = cardColor;
|
||||
},
|
||||
// 设置中奖颜色
|
||||
setLuckyCardColor(luckyCardColor: string) {
|
||||
this.globalConfig.theme.luckyCardColor = luckyCardColor;
|
||||
},
|
||||
// 设置文字颜色
|
||||
setTextColor(textColor: string) {
|
||||
this.globalConfig.theme.textColor = textColor;
|
||||
},
|
||||
// 设置卡片宽高
|
||||
setCardSize(cardSize: { width: number, height: number }) {
|
||||
this.globalConfig.theme.cardWidth = cardSize.width;
|
||||
this.globalConfig.theme.cardHeight = cardSize.height;
|
||||
},
|
||||
// 设置文字大小
|
||||
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字段
|
||||
for (let i = 0; i < this.globalConfig.musicList.length; i++) {
|
||||
if (this.globalConfig.musicList[i].name === music.name) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
this.globalConfig.musicList.push(music);
|
||||
},
|
||||
// 删除音乐
|
||||
removeMusic(musicId: string) {
|
||||
for (let i = 0; i < this.globalConfig.musicList.length; i++) {
|
||||
if (this.globalConfig.musicList[i].id === musicId) {
|
||||
this.globalConfig.musicList.splice(i, 1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
},
|
||||
// 设置当前播放音乐
|
||||
setCurrentMusic(musicItem: IMusic, paused: boolean = true) {
|
||||
this.currentMusic = {
|
||||
item: musicItem,
|
||||
paused: paused,
|
||||
}
|
||||
},
|
||||
// 重置音乐列表
|
||||
resetMusicList() {
|
||||
this.globalConfig.musicList = defaultMusicList as IMusic[];
|
||||
},
|
||||
// 清空音乐列表
|
||||
clearMusicList() {
|
||||
this.globalConfig.musicList = [] as IMusic[];
|
||||
},
|
||||
// 添加图片
|
||||
addImage(image: IImage) {
|
||||
for (let i = 0; i < this.globalConfig.imageList.length; i++) {
|
||||
if (this.globalConfig.imageList[i].name === image.name) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
this.globalConfig.imageList.push(image);
|
||||
},
|
||||
// 删除图片
|
||||
removeImage(imageId: string) {
|
||||
for (let i = 0; i < this.globalConfig.imageList.length; i++) {
|
||||
if (this.globalConfig.imageList[i].id === imageId) {
|
||||
this.globalConfig.imageList.splice(i, 1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
},
|
||||
// 重置图片列表
|
||||
resetImageList() {
|
||||
this.globalConfig.imageList = defaultImageList as IImage[];
|
||||
},
|
||||
// 清空图片列表
|
||||
clearImageList() {
|
||||
this.globalConfig.imageList = [] as IImage[]
|
||||
},
|
||||
// 设置是否显示奖品列表
|
||||
setIsShowPrizeList(isShowPrizeList: boolean) {
|
||||
this.globalConfig.isSHowPrizeList = isShowPrizeList;
|
||||
},
|
||||
// 设置是否显示头像
|
||||
setIsShowAvatar(isShowAvatar: boolean) {
|
||||
this.globalConfig.isShowAvatar = isShowAvatar;
|
||||
},
|
||||
// 重置所有配置
|
||||
reset() {
|
||||
this.globalConfig = {
|
||||
rowCount: 17,
|
||||
isSHowPrizeList: true,
|
||||
isShowAvatar: false,
|
||||
topTitle: '大明内阁六部御前奏对',
|
||||
theme: {
|
||||
name: 'dracula',
|
||||
detail: { primary: '#0f5fd3' },
|
||||
cardColor: '#ff79c6',
|
||||
cardWidth: 140,
|
||||
cardHeight: 200,
|
||||
textColor: '#ffffff',
|
||||
luckyCardColor: '#ECB1AC',
|
||||
textSize: 30,
|
||||
patternColor: '#1b66c9',
|
||||
patternList: defaultPatternList as number[],
|
||||
},
|
||||
musicList: defaultMusicList as IMusic[],
|
||||
imageList: defaultImageList as IImage[],
|
||||
},
|
||||
this.currentMusic = {
|
||||
item: defaultMusicList[0],
|
||||
paused: true,
|
||||
}
|
||||
// 删除音乐
|
||||
removeMusic(musicId: string) {
|
||||
for (let i = 0; i < this.globalConfig.musicList.length; i++) {
|
||||
if (this.globalConfig.musicList[i].id === musicId) {
|
||||
this.globalConfig.musicList.splice(i, 1)
|
||||
break
|
||||
}
|
||||
}
|
||||
},
|
||||
persist: {
|
||||
enabled: true,
|
||||
strategies: [
|
||||
{
|
||||
// 如果要存储在localStorage中
|
||||
storage: localStorage,
|
||||
key: 'globalConfig',
|
||||
paths: ['globalConfig'],
|
||||
},
|
||||
],
|
||||
// 设置当前播放音乐
|
||||
setCurrentMusic(musicItem: IMusic, paused: boolean = true) {
|
||||
this.currentMusic = {
|
||||
item: musicItem,
|
||||
paused,
|
||||
}
|
||||
},
|
||||
// 重置音乐列表
|
||||
resetMusicList() {
|
||||
this.globalConfig.musicList =JSON.parse(JSON.stringify(defaultMusicList)) as IMusic[]
|
||||
},
|
||||
// 清空音乐列表
|
||||
clearMusicList() {
|
||||
this.globalConfig.musicList = [] as IMusic[]
|
||||
},
|
||||
// 添加图片
|
||||
addImage(image: IImage) {
|
||||
for (let i = 0; i < this.globalConfig.imageList.length; i++) {
|
||||
if (this.globalConfig.imageList[i].name === image.name) {
|
||||
return
|
||||
}
|
||||
}
|
||||
this.globalConfig.imageList.push(image)
|
||||
},
|
||||
// 删除图片
|
||||
removeImage(imageId: string) {
|
||||
for (let i = 0; i < this.globalConfig.imageList.length; i++) {
|
||||
if (this.globalConfig.imageList[i].id === imageId) {
|
||||
this.globalConfig.imageList.splice(i, 1)
|
||||
break
|
||||
}
|
||||
}
|
||||
},
|
||||
// 重置图片列表
|
||||
resetImageList() {
|
||||
this.globalConfig.imageList = defaultImageList as IImage[]
|
||||
},
|
||||
// 清空图片列表
|
||||
clearImageList() {
|
||||
this.globalConfig.imageList = [] as IImage[]
|
||||
},
|
||||
// 设置是否显示奖品列表
|
||||
setIsShowPrizeList(isShowPrizeList: boolean) {
|
||||
this.globalConfig.isSHowPrizeList = isShowPrizeList
|
||||
},
|
||||
// 设置
|
||||
setLanguage(language: string) {
|
||||
this.globalConfig.language = language
|
||||
i18n.global.locale.value = language
|
||||
},
|
||||
// 设置背景图片
|
||||
setBackground(background: any) {
|
||||
this.globalConfig.theme.background = background
|
||||
},
|
||||
// 重置所有配置
|
||||
reset() {
|
||||
this.globalConfig = {
|
||||
rowCount: 17,
|
||||
isSHowPrizeList: true,
|
||||
topTitle: i18n.global.t('data.defaultTitle'),
|
||||
language: browserLanguage,
|
||||
theme: {
|
||||
name: 'dracula',
|
||||
detail: { primary: '#0f5fd3' },
|
||||
cardColor: '#ff79c6',
|
||||
cardWidth: 140,
|
||||
cardHeight: 200,
|
||||
textColor: '#ffffff',
|
||||
luckyCardColor: '#ECB1AC',
|
||||
textSize: 30,
|
||||
patternColor: '#1b66c9',
|
||||
patternList: defaultPatternList as number[],
|
||||
background: {}, // 背景颜色或图片
|
||||
},
|
||||
musicList: defaultMusicList as IMusic[],
|
||||
imageList: defaultImageList as IImage[],
|
||||
}
|
||||
this.currentMusic = {
|
||||
item: defaultMusicList[0],
|
||||
paused: true,
|
||||
}
|
||||
},
|
||||
},
|
||||
persist: {
|
||||
enabled: true,
|
||||
strategies: [
|
||||
{
|
||||
// 如果要存储在localStorage中
|
||||
storage: localStorage,
|
||||
key: 'globalConfig',
|
||||
paths: ['globalConfig'],
|
||||
},
|
||||
],
|
||||
},
|
||||
})
|
||||
|
||||
@@ -1,12 +1,13 @@
|
||||
import {usePersonConfig} from './personConfig';
|
||||
import { usePrizeConfig } from './prizeConfig';
|
||||
import {useGlobalConfig} from './globalConfig';
|
||||
import {useSystem} from './system';
|
||||
import { useGlobalConfig } from './globalConfig'
|
||||
import { usePersonConfig } from './personConfig'
|
||||
import { usePrizeConfig } from './prizeConfig'
|
||||
import { useSystem } from './system'
|
||||
|
||||
export default function useStore() {
|
||||
return {
|
||||
personConfig:usePersonConfig(),
|
||||
prizeConfig:usePrizeConfig(),
|
||||
globalConfig:useGlobalConfig(),
|
||||
system:useSystem(),
|
||||
};
|
||||
personConfig: usePersonConfig(),
|
||||
prizeConfig: usePrizeConfig(),
|
||||
globalConfig: useGlobalConfig(),
|
||||
system: useSystem(),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,158 +1,159 @@
|
||||
import { defineStore } from 'pinia';
|
||||
import { IPersonConfig } from '@/types/storeType';
|
||||
import { IPrizeConfig } from '@/types/storeType';
|
||||
import { defaultPersonList } from './data'
|
||||
import { usePrizeConfig } from './prizeConfig';
|
||||
import type { IPersonConfig, IPrizeConfig } from '@/types/storeType'
|
||||
|
||||
import dayjs from 'dayjs'
|
||||
import { defineStore } from 'pinia'
|
||||
import { defaultPersonList } from './data'
|
||||
import { usePrizeConfig } from './prizeConfig'
|
||||
|
||||
export const usePersonConfig = defineStore('person', {
|
||||
state() {
|
||||
return {
|
||||
personConfig: {
|
||||
allPersonList: [] as IPersonConfig[],
|
||||
alreadyPersonList: [] as IPersonConfig[],
|
||||
}
|
||||
};
|
||||
state() {
|
||||
return {
|
||||
personConfig: {
|
||||
allPersonList: [] as IPersonConfig[],
|
||||
alreadyPersonList: [] as IPersonConfig[],
|
||||
},
|
||||
}
|
||||
},
|
||||
getters: {
|
||||
// 获取全部配置
|
||||
getPersonConfig(state) {
|
||||
return state.personConfig
|
||||
},
|
||||
getters: {
|
||||
// 获取全部配置
|
||||
getPersonConfig(state) {
|
||||
return state.personConfig;
|
||||
},
|
||||
// 获取全部人员名单
|
||||
getAllPersonList(state) {
|
||||
return state.personConfig.allPersonList.filter((item: IPersonConfig) => {
|
||||
return item
|
||||
});
|
||||
},
|
||||
// 获取未获此奖的人员名单
|
||||
getNotThisPrizePersonList(state: any) {
|
||||
const currentPrize = usePrizeConfig().prizeConfig.currentPrize;
|
||||
const data = state.personConfig.allPersonList.filter((item: IPersonConfig) => {
|
||||
return !item.prizeId.includes(currentPrize.id as string);
|
||||
});
|
||||
|
||||
return data
|
||||
},
|
||||
// 获取已中奖人员名单
|
||||
getAlreadyPersonList(state) {
|
||||
return state.personConfig.allPersonList.filter((item: IPersonConfig) => {
|
||||
return item.isWin === true;
|
||||
});
|
||||
},
|
||||
// 获取中奖人员详情
|
||||
getAlreadyPersonDetail(state) {
|
||||
return state.personConfig.alreadyPersonList
|
||||
},
|
||||
// 获取未中奖人员名单
|
||||
getNotPersonList(state) {
|
||||
return state.personConfig.allPersonList.filter((item: IPersonConfig) => {
|
||||
return item.isWin === false;
|
||||
});
|
||||
},
|
||||
// 获取全部人员名单
|
||||
getAllPersonList(state) {
|
||||
return state.personConfig.allPersonList.filter((item: IPersonConfig) => {
|
||||
return item
|
||||
})
|
||||
},
|
||||
actions: {
|
||||
// 添加未中奖人员
|
||||
addNotPersonList(personList: IPersonConfig[]) {
|
||||
if (personList.length <= 0) {
|
||||
return
|
||||
}
|
||||
personList.forEach((item: IPersonConfig) => {
|
||||
this.personConfig.allPersonList.push(item);
|
||||
});
|
||||
},
|
||||
// 添加已中奖人员
|
||||
addAlreadyPersonList(personList: IPersonConfig[], prize: IPrizeConfig | null) {
|
||||
if (personList.length <= 0) {
|
||||
return
|
||||
}
|
||||
personList.forEach((person: IPersonConfig) => {
|
||||
this.personConfig.allPersonList.map((item: IPersonConfig) => {
|
||||
if (item.id === person.id && prize != null) {
|
||||
item.isWin = true
|
||||
// person.isWin = true
|
||||
item.prizeName.push(prize.name)
|
||||
// person.prizeName += prize.name
|
||||
item.prizeTime.push(dayjs(new Date()).format('YYYY-MM-DD HH:mm:ss'))
|
||||
// person.prizeTime = new Date().toString()
|
||||
item.prizeId.push(prize.id as string)
|
||||
}
|
||||
// 获取未获此奖的人员名单
|
||||
getNotThisPrizePersonList(state: any) {
|
||||
const currentPrize = usePrizeConfig().prizeConfig.currentPrize
|
||||
const data = state.personConfig.allPersonList.filter((item: IPersonConfig) => {
|
||||
return !item.prizeId.includes(currentPrize.id as string)
|
||||
})
|
||||
|
||||
return item
|
||||
});
|
||||
this.personConfig.alreadyPersonList.push(person);
|
||||
});
|
||||
},
|
||||
// 从已中奖移动到未中奖
|
||||
moveAlreadyToNot(person: IPersonConfig) {
|
||||
if (person.id == undefined || person.id == null) {
|
||||
return
|
||||
}
|
||||
const alreadyPersonListLength = this.personConfig.alreadyPersonList.length
|
||||
for (let i = 0; i < this.personConfig.allPersonList.length; i++) {
|
||||
if (person.id === this.personConfig.allPersonList[i].id) {
|
||||
this.personConfig.allPersonList[i].isWin = false
|
||||
this.personConfig.allPersonList[i].prizeName = []
|
||||
this.personConfig.allPersonList[i].prizeTime = []
|
||||
this.personConfig.allPersonList[i].prizeId = []
|
||||
|
||||
break
|
||||
}
|
||||
}
|
||||
for (let i = 0; i < alreadyPersonListLength; i++) {
|
||||
this.personConfig.alreadyPersonList = this.personConfig.alreadyPersonList.filter((item: IPersonConfig) =>
|
||||
item.id !== person.id
|
||||
)
|
||||
}
|
||||
},
|
||||
// 删除指定人员
|
||||
deletePerson(person: IPersonConfig) {
|
||||
if (person.id != undefined || person.id != null) {
|
||||
this.personConfig.allPersonList = this.personConfig.allPersonList.filter((item: IPersonConfig) => item.id !== person.id);
|
||||
this.personConfig.alreadyPersonList = this.personConfig.alreadyPersonList.filter((item: IPersonConfig) => item.id !== person.id);
|
||||
}
|
||||
},
|
||||
// 删除所有人员
|
||||
deleteAllPerson() {
|
||||
this.personConfig.allPersonList = [];
|
||||
this.personConfig.alreadyPersonList = [];
|
||||
},
|
||||
|
||||
// 删除所有人员
|
||||
resetPerson() {
|
||||
this.personConfig.allPersonList = [];
|
||||
this.personConfig.alreadyPersonList = [];
|
||||
},
|
||||
// 重置已中奖人员
|
||||
resetAlreadyPerson() {
|
||||
// 把已中奖人员合并到未中奖人员,要验证是否已存在
|
||||
this.personConfig.allPersonList.forEach((item: IPersonConfig) => {
|
||||
item.isWin = false;
|
||||
item.prizeName = [];
|
||||
item.prizeTime = [];
|
||||
item.prizeId = []
|
||||
});
|
||||
this.personConfig.alreadyPersonList = [];
|
||||
},
|
||||
setDefaultPersonList() {
|
||||
this.personConfig.allPersonList = defaultPersonList;
|
||||
this.personConfig.alreadyPersonList = [];
|
||||
},
|
||||
// 重置所有配置
|
||||
reset() {
|
||||
this.personConfig = {
|
||||
allPersonList: [] as IPersonConfig[],
|
||||
alreadyPersonList: [] as IPersonConfig[],
|
||||
}
|
||||
},
|
||||
return data
|
||||
},
|
||||
persist: {
|
||||
enabled: true,
|
||||
strategies: [
|
||||
{
|
||||
// 如果要存储在localStorage中
|
||||
storage: localStorage,
|
||||
key: 'personConfig',
|
||||
},
|
||||
],
|
||||
// 获取已中奖人员名单
|
||||
getAlreadyPersonList(state) {
|
||||
return state.personConfig.allPersonList.filter((item: IPersonConfig) => {
|
||||
return item.isWin === true
|
||||
})
|
||||
},
|
||||
});
|
||||
// 获取中奖人员详情
|
||||
getAlreadyPersonDetail(state) {
|
||||
return state.personConfig.alreadyPersonList
|
||||
},
|
||||
// 获取未中奖人员名单
|
||||
getNotPersonList(state) {
|
||||
return state.personConfig.allPersonList.filter((item: IPersonConfig) => {
|
||||
return item.isWin === false
|
||||
})
|
||||
},
|
||||
},
|
||||
actions: {
|
||||
// 添加未中奖人员
|
||||
addNotPersonList(personList: IPersonConfig[]) {
|
||||
if (personList.length <= 0) {
|
||||
return
|
||||
}
|
||||
personList.forEach((item: IPersonConfig) => {
|
||||
this.personConfig.allPersonList.push(item)
|
||||
})
|
||||
},
|
||||
// 添加已中奖人员
|
||||
addAlreadyPersonList(personList: IPersonConfig[], prize: IPrizeConfig | null) {
|
||||
if (personList.length <= 0) {
|
||||
return
|
||||
}
|
||||
personList.forEach((person: IPersonConfig) => {
|
||||
this.personConfig.allPersonList.map((item: IPersonConfig) => {
|
||||
if (item.id === person.id && prize != null) {
|
||||
item.isWin = true
|
||||
// person.isWin = true
|
||||
item.prizeName.push(prize.name)
|
||||
// person.prizeName += prize.name
|
||||
item.prizeTime.push(dayjs(new Date()).format('YYYY-MM-DD HH:mm:ss'))
|
||||
// person.prizeTime = new Date().toString()
|
||||
item.prizeId.push(prize.id as string)
|
||||
}
|
||||
|
||||
return item
|
||||
})
|
||||
this.personConfig.alreadyPersonList.push(person)
|
||||
})
|
||||
},
|
||||
// 从已中奖移动到未中奖
|
||||
moveAlreadyToNot(person: IPersonConfig) {
|
||||
if (person.id === undefined || person.id == null) {
|
||||
return
|
||||
}
|
||||
const alreadyPersonListLength = this.personConfig.alreadyPersonList.length
|
||||
for (let i = 0; i < this.personConfig.allPersonList.length; i++) {
|
||||
if (person.id === this.personConfig.allPersonList[i].id) {
|
||||
this.personConfig.allPersonList[i].isWin = false
|
||||
this.personConfig.allPersonList[i].prizeName = []
|
||||
this.personConfig.allPersonList[i].prizeTime = []
|
||||
this.personConfig.allPersonList[i].prizeId = []
|
||||
|
||||
break
|
||||
}
|
||||
}
|
||||
for (let i = 0; i < alreadyPersonListLength; i++) {
|
||||
this.personConfig.alreadyPersonList = this.personConfig.alreadyPersonList.filter((item: IPersonConfig) =>
|
||||
item.id !== person.id,
|
||||
)
|
||||
}
|
||||
},
|
||||
// 删除指定人员
|
||||
deletePerson(person: IPersonConfig) {
|
||||
if (person.id !== undefined || person.id != null) {
|
||||
this.personConfig.allPersonList = this.personConfig.allPersonList.filter((item: IPersonConfig) => item.id !== person.id)
|
||||
this.personConfig.alreadyPersonList = this.personConfig.alreadyPersonList.filter((item: IPersonConfig) => item.id !== person.id)
|
||||
}
|
||||
},
|
||||
// 删除所有人员
|
||||
deleteAllPerson() {
|
||||
this.personConfig.allPersonList = []
|
||||
this.personConfig.alreadyPersonList = []
|
||||
},
|
||||
|
||||
// 删除所有人员
|
||||
resetPerson() {
|
||||
this.personConfig.allPersonList = []
|
||||
this.personConfig.alreadyPersonList = []
|
||||
},
|
||||
// 重置已中奖人员
|
||||
resetAlreadyPerson() {
|
||||
// 把已中奖人员合并到未中奖人员,要验证是否已存在
|
||||
this.personConfig.allPersonList.forEach((item: IPersonConfig) => {
|
||||
item.isWin = false
|
||||
item.prizeName = []
|
||||
item.prizeTime = []
|
||||
item.prizeId = []
|
||||
})
|
||||
this.personConfig.alreadyPersonList = []
|
||||
},
|
||||
setDefaultPersonList() {
|
||||
this.personConfig.allPersonList = defaultPersonList
|
||||
this.personConfig.alreadyPersonList = []
|
||||
},
|
||||
// 重置所有配置
|
||||
reset() {
|
||||
this.personConfig = {
|
||||
allPersonList: [] as IPersonConfig[],
|
||||
alreadyPersonList: [] as IPersonConfig[],
|
||||
}
|
||||
},
|
||||
},
|
||||
persist: {
|
||||
enabled: true,
|
||||
strategies: [
|
||||
{
|
||||
// 如果要存储在localStorage中
|
||||
storage: localStorage,
|
||||
key: 'personConfig',
|
||||
},
|
||||
],
|
||||
},
|
||||
})
|
||||
|
||||
@@ -1,176 +1,177 @@
|
||||
import { defineStore } from 'pinia';
|
||||
import { IPrizeConfig } from '@/types/storeType';
|
||||
import { defaultPrizeList, defaultCurrentPrize } from './data';
|
||||
import type { IPrizeConfig } from '@/types/storeType'
|
||||
import { defineStore } from 'pinia'
|
||||
import { defaultCurrentPrize, defaultPrizeList } from './data'
|
||||
|
||||
export const usePrizeConfig = defineStore('prize', {
|
||||
state() {
|
||||
return {
|
||||
prizeConfig: {
|
||||
prizeList: defaultPrizeList,
|
||||
currentPrize: defaultCurrentPrize,
|
||||
temporaryPrize: {
|
||||
id: '',
|
||||
name: '',
|
||||
sort: 0,
|
||||
isAll: false,
|
||||
count: 1,
|
||||
isUsedCount: 0,
|
||||
picture: {
|
||||
id: '-1',
|
||||
name: '',
|
||||
url: ''
|
||||
},
|
||||
separateCount: {
|
||||
enable: true,
|
||||
countList: []
|
||||
},
|
||||
desc: '',
|
||||
isShow: false,
|
||||
isUsed: false,
|
||||
frequency: 1,
|
||||
} as IPrizeConfig
|
||||
}
|
||||
};
|
||||
state() {
|
||||
return {
|
||||
prizeConfig: {
|
||||
prizeList: defaultPrizeList,
|
||||
currentPrize: defaultCurrentPrize,
|
||||
temporaryPrize: {
|
||||
id: '',
|
||||
name: '',
|
||||
sort: 0,
|
||||
isAll: false,
|
||||
count: 1,
|
||||
isUsedCount: 0,
|
||||
picture: {
|
||||
id: '-1',
|
||||
name: '',
|
||||
url: '',
|
||||
},
|
||||
separateCount: {
|
||||
enable: true,
|
||||
countList: [],
|
||||
},
|
||||
desc: '',
|
||||
isShow: false,
|
||||
isUsed: false,
|
||||
frequency: 1,
|
||||
} as IPrizeConfig,
|
||||
},
|
||||
}
|
||||
},
|
||||
getters: {
|
||||
// 获取全部配置
|
||||
getPrizeConfigAll(state) {
|
||||
return state.prizeConfig
|
||||
},
|
||||
getters: {
|
||||
// 获取全部配置
|
||||
getPrizeConfigAll(state) {
|
||||
return state.prizeConfig;
|
||||
},
|
||||
// 获取奖品列表
|
||||
getPrizeConfig(state) {
|
||||
return state.prizeConfig.prizeList;
|
||||
},
|
||||
// 根据id获取配置
|
||||
getPrizeConfigById(state) {
|
||||
return (id: number | string) => {
|
||||
return state.prizeConfig.prizeList.find(item => item.id === id);
|
||||
}
|
||||
},
|
||||
// 获取当前奖项
|
||||
getCurrentPrize(state) {
|
||||
return state.prizeConfig.currentPrize;
|
||||
},
|
||||
// 获取临时的奖项
|
||||
getTemporaryPrize(state) {
|
||||
return state.prizeConfig.temporaryPrize;
|
||||
},
|
||||
|
||||
// 获取奖品列表
|
||||
getPrizeConfig(state) {
|
||||
return state.prizeConfig.prizeList
|
||||
},
|
||||
// 根据id获取配置
|
||||
getPrizeConfigById(state) {
|
||||
return (id: number | string) => {
|
||||
return state.prizeConfig.prizeList.find(item => item.id === id)
|
||||
}
|
||||
},
|
||||
// 获取当前奖项
|
||||
getCurrentPrize(state) {
|
||||
return state.prizeConfig.currentPrize
|
||||
},
|
||||
// 获取临时的奖项
|
||||
getTemporaryPrize(state) {
|
||||
return state.prizeConfig.temporaryPrize
|
||||
},
|
||||
actions: {
|
||||
// 设置奖项
|
||||
setPrizeConfig(prizeList: IPrizeConfig[]) {
|
||||
this.prizeConfig.prizeList = prizeList;
|
||||
},
|
||||
// 添加奖项
|
||||
addPrizeConfig(prizeConfigItem: IPrizeConfig) {
|
||||
this.prizeConfig.prizeList.push(prizeConfigItem);
|
||||
},
|
||||
// 删除奖项
|
||||
deletePrizeConfig(prizeConfigItemId: number | string) {
|
||||
this.prizeConfig.prizeList = this.prizeConfig.prizeList.filter(item => item.id !== prizeConfigItemId);
|
||||
},
|
||||
// 更新奖项数据
|
||||
updatePrizeConfig(prizeConfigItem: IPrizeConfig) {
|
||||
const prizeListLength = this.prizeConfig.prizeList.length;
|
||||
if (prizeConfigItem.isUsed && prizeListLength) {
|
||||
for (let i = 0; i < prizeListLength; i++) {
|
||||
if (!this.prizeConfig.prizeList[i].isUsed) {
|
||||
this.setCurrentPrize(this.prizeConfig.prizeList[i]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
return
|
||||
}
|
||||
this.resetTemporaryPrize()
|
||||
},
|
||||
// 删除全部奖项
|
||||
deleteAllPrizeConfig() {
|
||||
this.prizeConfig.prizeList = [] as IPrizeConfig[];
|
||||
},
|
||||
// 设置当前奖项
|
||||
setCurrentPrize(prizeConfigItem: IPrizeConfig) {
|
||||
this.prizeConfig.currentPrize = prizeConfigItem
|
||||
},
|
||||
// 设置临时奖项
|
||||
setTemporaryPrize(prizeItem: IPrizeConfig) {
|
||||
if (prizeItem.isShow == false) {
|
||||
for (let i = 0; i < this.prizeConfig.prizeList.length; i++) {
|
||||
if (this.prizeConfig.prizeList[i].isUsed == false) {
|
||||
this.setCurrentPrize(this.prizeConfig.prizeList[i]);
|
||||
|
||||
break
|
||||
}
|
||||
}
|
||||
this.resetTemporaryPrize()
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
this.prizeConfig.temporaryPrize = prizeItem
|
||||
},
|
||||
// 重置临时奖项
|
||||
resetTemporaryPrize() {
|
||||
this.prizeConfig.temporaryPrize = {
|
||||
id: '',
|
||||
name: '',
|
||||
sort: 0,
|
||||
isAll: false,
|
||||
count: 1,
|
||||
isUsedCount: 0,
|
||||
picture: {
|
||||
id: '-1',
|
||||
name: '',
|
||||
url: ''
|
||||
},
|
||||
separateCount: {
|
||||
enable: true,
|
||||
countList: []
|
||||
},
|
||||
desc: '',
|
||||
isShow: false,
|
||||
isUsed: false,
|
||||
frequency: 1,
|
||||
} as IPrizeConfig;
|
||||
},
|
||||
// 重置所有配置
|
||||
resetDefault() {
|
||||
this.prizeConfig = {
|
||||
prizeList: defaultPrizeList,
|
||||
currentPrize: defaultCurrentPrize,
|
||||
temporaryPrize: {
|
||||
id: '',
|
||||
name: '',
|
||||
sort: 0,
|
||||
isAll: false,
|
||||
count: 1,
|
||||
isUsedCount: 0,
|
||||
picture: {
|
||||
id: '-1',
|
||||
name: '',
|
||||
url: ''
|
||||
},
|
||||
separateCount: {
|
||||
enable: true,
|
||||
countList: []
|
||||
},
|
||||
desc: '',
|
||||
isShow: false,
|
||||
isUsed: false,
|
||||
frequency: 1,
|
||||
} as IPrizeConfig
|
||||
}
|
||||
},
|
||||
actions: {
|
||||
// 设置奖项
|
||||
setPrizeConfig(prizeList: IPrizeConfig[]) {
|
||||
this.prizeConfig.prizeList = prizeList
|
||||
},
|
||||
// 添加奖项
|
||||
addPrizeConfig(prizeConfigItem: IPrizeConfig) {
|
||||
this.prizeConfig.prizeList.push(prizeConfigItem)
|
||||
},
|
||||
// 删除奖项
|
||||
deletePrizeConfig(prizeConfigItemId: number | string) {
|
||||
this.prizeConfig.prizeList = this.prizeConfig.prizeList.filter(item => item.id !== prizeConfigItemId)
|
||||
},
|
||||
// 更新奖项数据
|
||||
updatePrizeConfig(prizeConfigItem: IPrizeConfig) {
|
||||
const prizeListLength = this.prizeConfig.prizeList.length
|
||||
if (prizeConfigItem.isUsed && prizeListLength) {
|
||||
for (let i = 0; i < prizeListLength; i++) {
|
||||
if (!this.prizeConfig.prizeList[i].isUsed) {
|
||||
this.setCurrentPrize(this.prizeConfig.prizeList[i])
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
return
|
||||
}
|
||||
this.resetTemporaryPrize()
|
||||
},
|
||||
persist: {
|
||||
enabled: true,
|
||||
strategies: [
|
||||
{
|
||||
// 如果要存储在localStorage中
|
||||
storage: localStorage,
|
||||
key: 'prizeConfig',
|
||||
},
|
||||
],
|
||||
// 删除全部奖项
|
||||
deleteAllPrizeConfig() {
|
||||
this.prizeConfig.prizeList = [] as IPrizeConfig[]
|
||||
},
|
||||
});
|
||||
// 设置当前奖项
|
||||
setCurrentPrize(prizeConfigItem: IPrizeConfig) {
|
||||
this.prizeConfig.currentPrize = prizeConfigItem
|
||||
},
|
||||
// 设置临时奖项
|
||||
setTemporaryPrize(prizeItem: IPrizeConfig) {
|
||||
if (prizeItem.isShow === false) {
|
||||
for (let i = 0; i < this.prizeConfig.prizeList.length; i++) {
|
||||
if (this.prizeConfig.prizeList[i].isUsed === false) {
|
||||
this.setCurrentPrize(this.prizeConfig.prizeList[i])
|
||||
|
||||
break
|
||||
}
|
||||
}
|
||||
this.resetTemporaryPrize()
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
this.prizeConfig.temporaryPrize = prizeItem
|
||||
},
|
||||
// 重置临时奖项
|
||||
resetTemporaryPrize() {
|
||||
this.prizeConfig.temporaryPrize = {
|
||||
id: '',
|
||||
name: '',
|
||||
sort: 0,
|
||||
isAll: false,
|
||||
count: 1,
|
||||
isUsedCount: 0,
|
||||
picture: {
|
||||
id: '-1',
|
||||
name: '',
|
||||
url: '',
|
||||
},
|
||||
separateCount: {
|
||||
enable: true,
|
||||
countList: [],
|
||||
},
|
||||
desc: '',
|
||||
isShow: false,
|
||||
isUsed: false,
|
||||
frequency: 1,
|
||||
} as IPrizeConfig
|
||||
},
|
||||
// 重置所有配置
|
||||
resetDefault() {
|
||||
this.prizeConfig = {
|
||||
prizeList: defaultPrizeList,
|
||||
currentPrize: defaultCurrentPrize,
|
||||
temporaryPrize: {
|
||||
id: '',
|
||||
name: '',
|
||||
sort: 0,
|
||||
isAll: false,
|
||||
count: 1,
|
||||
isUsedCount: 0,
|
||||
picture: {
|
||||
id: '-1',
|
||||
name: '',
|
||||
url: '',
|
||||
},
|
||||
separateCount: {
|
||||
enable: true,
|
||||
countList: [],
|
||||
},
|
||||
desc: '',
|
||||
isShow: false,
|
||||
isUsed: false,
|
||||
frequency: 1,
|
||||
} as IPrizeConfig,
|
||||
}
|
||||
},
|
||||
},
|
||||
persist: {
|
||||
enabled: true,
|
||||
strategies: [
|
||||
{
|
||||
// 如果要存储在localStorage中
|
||||
storage: localStorage,
|
||||
key: 'prizeConfig',
|
||||
},
|
||||
],
|
||||
},
|
||||
})
|
||||
|
||||
@@ -1,37 +1,37 @@
|
||||
import { defineStore } from 'pinia';
|
||||
import { defineStore } from 'pinia'
|
||||
// import { IPrizeConfig } from '@/types/storeType';
|
||||
export const useSystem = defineStore('system', {
|
||||
state() {
|
||||
return {
|
||||
isMobile:false,
|
||||
isChrome:true
|
||||
};
|
||||
state() {
|
||||
return {
|
||||
isMobile: false,
|
||||
isChrome: true,
|
||||
}
|
||||
},
|
||||
getters: {
|
||||
getIsMobile(state) {
|
||||
return state.isMobile
|
||||
},
|
||||
getters: {
|
||||
getIsMobile(state) {
|
||||
return state.isMobile;
|
||||
},
|
||||
getIsChrome(state) {
|
||||
return state.isChrome;
|
||||
},
|
||||
getIsChrome(state) {
|
||||
return state.isChrome
|
||||
},
|
||||
actions: {
|
||||
setIsMobile(isMobile: boolean) {
|
||||
this.isMobile = isMobile;
|
||||
},
|
||||
setIsChrome(isChrome: boolean) {
|
||||
this.isChrome = isChrome;
|
||||
},
|
||||
},
|
||||
actions: {
|
||||
setIsMobile(isMobile: boolean) {
|
||||
this.isMobile = isMobile
|
||||
},
|
||||
persist: {
|
||||
enabled: true,
|
||||
strategies: [
|
||||
{
|
||||
// 如果要存储在localStorage中
|
||||
// storage: localStorage,
|
||||
// key: 'globalConfig',
|
||||
// paths: ['globalConfig'],
|
||||
},
|
||||
],
|
||||
setIsChrome(isChrome: boolean) {
|
||||
this.isChrome = isChrome
|
||||
},
|
||||
},
|
||||
persist: {
|
||||
enabled: true,
|
||||
strategies: [
|
||||
{
|
||||
// 如果要存储在localStorage中
|
||||
// storage: localStorage,
|
||||
// key: 'globalConfig',
|
||||
// paths: ['globalConfig'],
|
||||
},
|
||||
],
|
||||
},
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user