index.ts
4.18 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
import { defineStore } from 'pinia';
import { Selection } from '@/store/modules/selection/type';
import { SystemConfig } from '@/types/system-config';
import { Tag } from '@/types/tag';
import { Project } from '@/types/project';
import useProjectApi from '@/http/project';
import useUserApi from '@/http/user';
import useTagApi from '@/http/Tag';
import useConfigApi from '@/http/config';
import { User } from '@/utils/model';
const useSelectionStore = defineStore('selection', {
state: (): Selection => ({ user: [], project: [], tag: [], config: [] }),
getters: {
getUserOptions(state): User[] {
return state.user;
},
getProjectOptions(state) {
return state.project;
},
getTagOptions(state) {
return state.tag;
},
projectOptions(state) {
return state.project;
},
getConfigOption(state) {
return state.config;
},
lyricTool(state): string {
return state.config.find((item) => item.identifier === 'activity_lyric_tool')?.content || '';
},
activityLang(state): SystemConfig | undefined {
return state.config.find((item) => item.identifier === 'activity_lang');
},
activityLangOptions(state): SystemConfig[] {
return state.config.filter((item) => item.parent_id === this.activityLang?.id);
},
activitySpeed(state): SystemConfig | undefined {
return state.config.find((item) => item.identifier === 'activity_speed');
},
activitySpeedOptions(state): SystemConfig[] {
return state.config.filter((item) => item.parent_id === this.activitySpeed?.id);
},
activitySex(state): SystemConfig | undefined {
return state.config.find((item) => item.identifier === 'activity_sex');
},
activitySexOptions(state): SystemConfig[] {
return state.config.filter((item) => item.parent_id === this.activitySex?.id);
},
activityMark(state): SystemConfig | undefined {
return state.config.find((item) => item.identifier === 'activity_mark');
},
activityMarkOptions(state): SystemConfig[] {
return state.config.filter((item) => item.parent_id === this.activityMark?.id);
},
activityAudioAccept(state): string {
return state.config.find((item) => item.identifier === 'activity_audio_accept')?.content || 'audio/*';
},
activityTrackAccept(state): string {
return state.config.find((item) => item.identifier === 'activity_track_accept')?.content || '*';
},
activityTagOptions(state): Pick<Tag, 'id' | 'name' | 'type'>[] {
return state.tag.filter((item) => item.type === 1);
},
activityProjectOptions(state): Pick<Project, 'id' | 'name'>[] {
return state.project;
},
activityAuditIds(state): string[] {
return state.config.find((item) => item.identifier === 'activity_audit_ids')?.content?.split(',') || [];
},
appleDemoCover(state): string {
return state.config.find((item) => item.identifier === 'activity_demo_cover')?.content || '';
},
userAuthTag(state) {
return state.tag.filter((item) => item.type === 4);
},
},
actions: {
queryUser() {
useUserApi
.get({ fetchType: 'all', setColumn: ['id', 'nick_name', 'real_name', 'avatar'], sortBy: 'id', sortType: 'desc' })
.then(({ data }) => {
this.user = data;
});
},
queryProject() {
useProjectApi
.get({ fetchType: 'all', setColumn: ['id', 'is_can_apply', 'is_can_demo_apply', 'name'], sortBy: 'id', sortType: 'desc' })
.then(({ data }) => {
this.project = data;
});
},
queryTag() {
useTagApi.get({ fetchType: 'all', setColumn: ['id', 'name', 'type'], sortBy: 'weight', sortType: 'desc' }).then(({ data }) => {
this.tag = data;
});
},
queryConfig() {
useConfigApi
.get({
fetchType: 'all',
parent_id: '',
setColumn: ['id', 'parent_id', 'name', 'identifier', 'content'],
sortBy: 'weight',
sortType: 'desc',
})
.then(({ data }) => {
this.config = data;
});
},
queryAll() {
this.queryConfig();
this.queryUser();
this.queryProject();
this.queryTag();
},
},
});
export default useSelectionStore;