feat: new
This commit is contained in:
58
src/store/data.ts
Normal file
58
src/store/data.ts
Normal file
@@ -0,0 +1,58 @@
|
||||
export const defaultMusicList=[
|
||||
{
|
||||
id:'Geoff Knorr - China (The Industrial Era).ogg'+new Date().getTime().toString(),
|
||||
name:'Geoff Knorr - China (The Industrial Era).ogg',
|
||||
url:'https://24years.top/resource/audio/Geoff Knorr - China (The Industrial Era).ogg'
|
||||
},
|
||||
{
|
||||
id:'Geoff Knorr&Phill Boucher - China (The Atomic Era).ogg'+new Date().getTime().toString(),
|
||||
name:'Geoff Knorr&Phill Boucher - China (The Atomic Era).ogg',
|
||||
url:'https://24years.top/resource/audio/Geoff Knorr&Phill Boucher - China (The Atomic Era).ogg'
|
||||
},
|
||||
{
|
||||
id:'Radetzky March.mp3'+new Date().getTime().toString(),
|
||||
name:'Radetzky March.mp3',
|
||||
url:'https://24years.top/resource/audio/Radetzky March.mp3'
|
||||
},
|
||||
{
|
||||
id:'Shanghai.mp3'+new Date().getTime().toString(),
|
||||
name:'Shanghai.mp3',
|
||||
url:'https://24years.top/resource/audio/Shanghai.mp3'
|
||||
},
|
||||
{
|
||||
id:'Waltz No.2.mp3'+new Date().getTime().toString(),
|
||||
name:'Waltz No.2.mp3',
|
||||
url:'https://24years.top/resource/audio/Waltz No.2.mp3'
|
||||
},
|
||||
{
|
||||
id:'WildChinaTheme.mp3'+new Date().getTime().toString(),
|
||||
name:'WildChinaTheme.mp3',
|
||||
url:'https://24years.top/resource/audio/WildChinaTheme.mp3'
|
||||
},
|
||||
{
|
||||
id:'边程&房东的猫 - 美好事物-再遇少年.ogg'+new Date().getTime().toString(),
|
||||
name:'边程&房东的猫 - 美好事物-再遇少年.ogg',
|
||||
url:'https://24years.top/resource/audio/边程&房东的猫 - 美好事物-再遇少年.ogg'
|
||||
},
|
||||
{
|
||||
id:'大乔小乔 - 相见难别亦难.ogg'+new Date().getTime().toString(),
|
||||
name:'大乔小乔 - 相见难别亦难.ogg',
|
||||
url:'https://24years.top/resource/audio/大乔小乔 - 相见难别亦难.ogg'
|
||||
},
|
||||
{
|
||||
id:'你要跳舞吗-新裤子.mp3'+new Date().getTime().toString(),
|
||||
name:'你要跳舞吗-新裤子.mp3',
|
||||
url:'https://24years.top/resource/audio/你要跳舞吗-新裤子.mp3'
|
||||
},
|
||||
{
|
||||
id:'生命-声音玩具.mp3'+new Date().getTime().toString(),
|
||||
name:'生命-声音玩具.mp3',
|
||||
url:'https://24years.top/resource/audio/生命-声音玩具.mp3'
|
||||
},
|
||||
{
|
||||
id:'与非门 - Happy New Year.ogg'+new Date().getTime().toString(),
|
||||
name:'与非门 - Happy New Year.ogg',
|
||||
url:'https://24years.top/resource/audio/与非门 - Happy New Year.ogg'
|
||||
},
|
||||
|
||||
]
|
||||
143
src/store/globalConfig.ts
Normal file
143
src/store/globalConfig.ts
Normal file
@@ -0,0 +1,143 @@
|
||||
import { defineStore } from 'pinia';
|
||||
import { defaultMusicList } from './data'
|
||||
// import { IPrizeConfig } from '@/types/prizeConfig';
|
||||
export const useGlobalConfig = defineStore('global', {
|
||||
state() {
|
||||
return {
|
||||
globalConfig: {
|
||||
rowCount: 12,
|
||||
theme: {
|
||||
name: 'dark',
|
||||
detail: { primary: '#0f5fd3' },
|
||||
cardColor: 'rgba(0, 255, 255)',
|
||||
cardWidth: 140,
|
||||
cardHeight: 200,
|
||||
textColor: '#ffffff',
|
||||
textSize: 30
|
||||
},
|
||||
musicList: defaultMusicList,
|
||||
}
|
||||
};
|
||||
},
|
||||
getters: {
|
||||
// 获取全部配置
|
||||
getGlobalConfig(state) {
|
||||
return state.globalConfig;
|
||||
},
|
||||
// 获取行数
|
||||
getRowCount(state) {
|
||||
return state.globalConfig.rowCount;
|
||||
},
|
||||
// 获取主题
|
||||
getTheme(state) {
|
||||
return state.globalConfig.theme;
|
||||
},
|
||||
// 获取卡片颜色
|
||||
getCardColor(state) {
|
||||
return state.globalConfig.theme.cardColor;
|
||||
},
|
||||
// 获取文字颜色
|
||||
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;
|
||||
},
|
||||
// 获取音乐列表
|
||||
getMusicList(state) {
|
||||
return state.globalConfig.musicList;
|
||||
}
|
||||
|
||||
},
|
||||
actions: {
|
||||
// 设置rowCount
|
||||
setRowCount(rowCount: number) {
|
||||
this.globalConfig.rowCount = rowCount;
|
||||
},
|
||||
// 设置主题
|
||||
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;
|
||||
},
|
||||
// 设置文字颜色
|
||||
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;
|
||||
},
|
||||
// 添加音乐
|
||||
addMusic(music: any) {
|
||||
// 验证音乐是否已存在,看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;
|
||||
}
|
||||
}
|
||||
},
|
||||
// 重置音乐列表
|
||||
resetMusicList() {
|
||||
this.globalConfig.musicList = defaultMusicList;
|
||||
},
|
||||
// 清空音乐列表
|
||||
clearMusicList() {
|
||||
this.globalConfig.musicList = [];
|
||||
},
|
||||
// 重置所有配置
|
||||
reset() {
|
||||
this.globalConfig = {
|
||||
rowCount: 12,
|
||||
theme: {
|
||||
name: 'dark',
|
||||
detail: { primary: '#0f5fd3' },
|
||||
cardColor: 'rgba(0, 255, 255)',
|
||||
cardWidth: 200,
|
||||
cardHeight: 140,
|
||||
textColor: '#ffffff',
|
||||
textSize: 30
|
||||
|
||||
},
|
||||
musicList: defaultMusicList
|
||||
}
|
||||
}
|
||||
},
|
||||
persist: {
|
||||
enabled: true,
|
||||
strategies: [
|
||||
{
|
||||
// 如果要存储在localStorage中
|
||||
storage: localStorage,
|
||||
key: 'globalConfig',
|
||||
},
|
||||
],
|
||||
},
|
||||
})
|
||||
@@ -1,10 +1,12 @@
|
||||
import { useUserStore } from './user';
|
||||
import {usePersonConfig} from './personConfig';
|
||||
import { usePrizeConfig } from './prizeConfig';
|
||||
import {useGlobalConfig} from './globalConfig';
|
||||
export default function useStore() {
|
||||
return {
|
||||
user: useUserStore(),
|
||||
personConfig:usePersonConfig(),
|
||||
prizeConfig:usePrizeConfig()
|
||||
prizeConfig:usePrizeConfig(),
|
||||
globalConfig:useGlobalConfig()
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user