| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106 |
- import { Toast } from 'vant'
- import { reactive, watchEffect } from 'vue'
- import { GradualNote } from './calcSpeed'
- import { IDifficulty } from './setting-state'
- type IRenderType = 'native' | 'cache'
- type IMode = 'homework' | 'contact' | 'evaluating'
- type URLSetting = {
- mode?: 'EVALUATING',
- resets?: ['SPEED'],
- difficulty?: IDifficulty,
- feeType?: 'FREE',
- submitData?: any
- }
- const state = reactive({
- sectionStatus: false,
- maskStatus: false,
- section: [] as any[],
- times: [] as any[],
- timesById: {} as any,
- sectionBoundingBoxs: [] as any[],
- activeTick: -1,
- activeTickRepeat: 1,
- showTick: false,
- isSpecialShapedScreen: false,
- notchHeight: 0,
- fixedKey: 0,
- renderLoading: false,
- evaluatings: {} as any,
- isPauseRecording: false,
- feeShow: false,
- vipShow: false,
- mode: 'contact' as IMode,
- subjectId: 0 as number,
- activeSpeed: 90 as number, // 当前速度
- baseSpeed: 90 as number, // 基准速度
- activeDetail: null as any,
- needTick: false, // 是否需要节拍器
- /** 跳过节拍器 */
- skipTick: false,
- /** 重复节拍 */
- repeatedBeats: true,
- sectionFlash: false,
- befireSection: null as any,
- /* 是否是打击乐 */
- isPercussion: false,
- enableEvaluation: true, // 是否开启评测
- isAppPlay: false, // 是否是app播放
- partListNames: [] as string[], // 当前曲谱中所有声部名字
- partIndex: 0, // 当前显示声部索引
- midiPlayIniting: false, // midi播放器是否初始化中
- isSpecialBookCategory: false, // 是否是特殊乐谱类型
- // 声部对应code
- code: '',
- /** 是否冻结模式 */
- frozenMode: false,
- /** 初次render结束 */
- initRendered: false,
- /** URL参数设置 */
- setting: null as null | URLSetting,
- /**当前激活的note */
- activeNote: '' as any,
- /** 免费试用比例,默认10% */
- freeRate: 0.1 as number,
- /** 渲染比例 */
- zoom: 1,
- /** 渲染模式*/
- renderType: 'native' as IRenderType,
- /** 渐变速度信息 */
- gradual: [] as GradualNote[],
- /** 渐变速度版本 */
- /** 渐变时间信息 */
- gradualTimes: null as GradualTimes
- })
- let toastItem: any = null
- watchEffect(() => {
- const data: any = {}
- for (const time of state.times) {
- if (time.id) {
- data[time.id] = time
- }
- }
- state.timesById = data
- if (state.subjectId > 0) {
- state.isPercussion = state.subjectId == 23 || state.subjectId == 113
- }
- if (state.renderLoading) {
- // toastItem = Toast({
- // duration: 0,
- // message: '加载中...',
- // })
- } else {
- if (toastItem) {
- toastItem.close()
- toastItem = null
- }
- }
- })
- export default state
- export type GradualTimes = null | {
- [key: string]: string
- }
|