|
@@ -25,7 +25,7 @@ export default defineComponent({
|
|
|
props: {
|
|
|
isSoundEffect: {
|
|
|
type: Boolean,
|
|
|
- default: false
|
|
|
+ default: false,
|
|
|
},
|
|
|
score: {
|
|
|
type: String,
|
|
@@ -72,49 +72,50 @@ export default defineComponent({
|
|
|
svgEL?.setAttribute('width', _w)
|
|
|
svgEL?.setAttribute('height', _w * ratio + '')
|
|
|
}
|
|
|
- emit('loaddingEnd')
|
|
|
}
|
|
|
}
|
|
|
+ const getNotePosition = (times: any[]) => {
|
|
|
+ for (let i = 0; i < times.length; i++) {
|
|
|
+ const item = times[i]
|
|
|
+
|
|
|
+ if (item?.svgElelent?.bbox) {
|
|
|
+ item.svgElelent.bbox.x *= detailState.zoom
|
|
|
+ item.svgElelent.bbox.y *= detailState.zoom
|
|
|
+ item.svgElelent.bbox.w *= detailState.zoom
|
|
|
+ item.svgElelent.bbox.h *= detailState.zoom
|
|
|
+ }
|
|
|
+ if (item.noteElement?.sourceMeasure?.verticalMeasureList?.[0]?.boundingBox) {
|
|
|
+ item.noteElement.sourceMeasure.verticalMeasureList[0].boundingBox.absolutePosition.x *= detailState.zoom
|
|
|
+ item.noteElement.sourceMeasure.verticalMeasureList[0].boundingBox.absolutePosition.y *= detailState.zoom
|
|
|
+ item.noteElement.sourceMeasure.verticalMeasureList[0].boundingBox.size.width *= detailState.zoom
|
|
|
+ item.noteElement.sourceMeasure.verticalMeasureList[0].boundingBox.size.height *= detailState.zoom
|
|
|
+ }
|
|
|
+ if (item.noteElement?.sourceMeasure?.verticalMeasureList?.[0]?.stave) {
|
|
|
+ item.noteElement.sourceMeasure.verticalMeasureList[0].stave.x *= detailState.zoom
|
|
|
+ item.noteElement.sourceMeasure.verticalMeasureList[0].stave.y *= detailState.zoom
|
|
|
+ item.noteElement.sourceMeasure.verticalMeasureList[0].stave.width *= detailState.zoom
|
|
|
+ item.noteElement.sourceMeasure.verticalMeasureList[0].stave.height *= detailState.zoom
|
|
|
+ item.noteElement.sourceMeasure.verticalMeasureList[0].stave.start_x *= detailState.zoom
|
|
|
+ item.noteElement.sourceMeasure.verticalMeasureList[0].stave.end_x *= detailState.zoom
|
|
|
+ }
|
|
|
+ if (item?.cursorBox?.move) {
|
|
|
+ console.log(detailState.zoom)
|
|
|
+ // console.log("🚀 ~ item.cursorBox.x", item.cursorBox.x * detailState.zoom, item?.svgElelent?.bbox?.x)
|
|
|
+ // item.cursorBox.x = item?.svgElelent?.bbox?.x ? formatZoom(item.svgElelent.bbox.x) : item.cursorBox.x * detailState.zoom
|
|
|
+ item.cursorBox.x *= detailState.zoom
|
|
|
+ item.cursorBox.y = item.cursorBox.y * detailState.zoom + 10
|
|
|
+ item.cursorBox.w *= detailState.zoom
|
|
|
+ item.cursorBox.h *= detailState.zoom
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return times
|
|
|
+ }
|
|
|
// 获取json数据
|
|
|
const getMusicJson = async (url: string) => {
|
|
|
const res = await axios.get(url)
|
|
|
SettingState.sett.scoreSize = res?.osmd?.scoreSize || 'middle'
|
|
|
if (res && Array.isArray(res.times)) {
|
|
|
- for (let i = 0; i < res.times.length; i++) {
|
|
|
- const item = res.times[i]
|
|
|
-
|
|
|
- if (item?.svgElelent?.bbox) {
|
|
|
- item.svgElelent.bbox.x *= detailState.zoom
|
|
|
- item.svgElelent.bbox.y *= detailState.zoom
|
|
|
- item.svgElelent.bbox.w *= detailState.zoom
|
|
|
- item.svgElelent.bbox.h *= detailState.zoom
|
|
|
- }
|
|
|
- if (item.noteElement?.sourceMeasure?.verticalMeasureList?.[0]?.boundingBox) {
|
|
|
- item.noteElement.sourceMeasure.verticalMeasureList[0].boundingBox.absolutePosition.x *= detailState.zoom
|
|
|
- item.noteElement.sourceMeasure.verticalMeasureList[0].boundingBox.absolutePosition.y *= detailState.zoom
|
|
|
- item.noteElement.sourceMeasure.verticalMeasureList[0].boundingBox.size.width *= detailState.zoom
|
|
|
- item.noteElement.sourceMeasure.verticalMeasureList[0].boundingBox.size.height *= detailState.zoom
|
|
|
- }
|
|
|
- if (item.noteElement?.sourceMeasure?.verticalMeasureList?.[0]?.stave) {
|
|
|
- item.noteElement.sourceMeasure.verticalMeasureList[0].stave.x *= detailState.zoom
|
|
|
- item.noteElement.sourceMeasure.verticalMeasureList[0].stave.y *= detailState.zoom
|
|
|
- item.noteElement.sourceMeasure.verticalMeasureList[0].stave.width *= detailState.zoom
|
|
|
- item.noteElement.sourceMeasure.verticalMeasureList[0].stave.height *= detailState.zoom
|
|
|
- item.noteElement.sourceMeasure.verticalMeasureList[0].stave.start_x *= detailState.zoom
|
|
|
- item.noteElement.sourceMeasure.verticalMeasureList[0].stave.end_x *= detailState.zoom
|
|
|
- }
|
|
|
- if (item?.cursorBox?.move) {
|
|
|
- // console.log(detailState.zoom)
|
|
|
- // console.log("🚀 ~ item.cursorBox.x", item.cursorBox.x * detailState.zoom, item?.svgElelent?.bbox?.x)
|
|
|
- // item.cursorBox.x = item?.svgElelent?.bbox?.x ? formatZoom(item.svgElelent.bbox.x) : item.cursorBox.x * detailState.zoom
|
|
|
- item.cursorBox.x *= detailState.zoom
|
|
|
- item.cursorBox.y = item.cursorBox.y * detailState.zoom + 10
|
|
|
- item.cursorBox.w *= detailState.zoom
|
|
|
- item.cursorBox.h *= detailState.zoom
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- detailState.times = res.times
|
|
|
+ detailState.times = getNotePosition(res.times) // res.times
|
|
|
if (detailState.times?.[0]?.cursorBox?.move) {
|
|
|
// 初始化cursor
|
|
|
res.osmd.cursor = new Cursor({ ...detailState.times?.[0]?.cursorBox })
|
|
@@ -157,8 +158,12 @@ export default defineComponent({
|
|
|
// console.log( SettingState.sett.keySignature, detailState.activeDetail)
|
|
|
if (
|
|
|
(SettingState.sett.type === 'staff' && !detailState?.activeDetail?.musicSvg) || // 没有五线谱缓存数据
|
|
|
- (SettingState.sett.type === 'jianpu' && SettingState.sett.keySignature && !detailState?.activeDetail?.musicFirstSvg) || // 没有固定调缓存数据
|
|
|
- (SettingState.sett.type === 'jianpu' && !SettingState.sett.keySignature && !detailState?.activeDetail?.musicJianSvg) // 没有首调缓存数据
|
|
|
+ (SettingState.sett.type === 'jianpu' &&
|
|
|
+ SettingState.sett.keySignature &&
|
|
|
+ !detailState?.activeDetail?.musicFirstSvg) || // 没有固定调缓存数据
|
|
|
+ (SettingState.sett.type === 'jianpu' &&
|
|
|
+ !SettingState.sett.keySignature &&
|
|
|
+ !detailState?.activeDetail?.musicJianSvg) // 没有首调缓存数据
|
|
|
) {
|
|
|
setOsdm()
|
|
|
return
|
|
@@ -168,10 +173,12 @@ export default defineComponent({
|
|
|
if (SettingState.sett.type === 'staff' && detailState.activeDetail?.musicSvg) {
|
|
|
renderData = JSON.parse(detailState.activeDetail.musicSvg)
|
|
|
} else {
|
|
|
- if (SettingState.sett.keySignature && detailState.activeDetail?.musicFirstSvg) { //固定调
|
|
|
+ if (SettingState.sett.keySignature && detailState.activeDetail?.musicFirstSvg) {
|
|
|
+ //固定调
|
|
|
renderData = JSON.parse(detailState.activeDetail.musicFirstSvg)
|
|
|
- } else { // 首调
|
|
|
- if(detailState.activeDetail?.musicJianSvg){
|
|
|
+ } else {
|
|
|
+ // 首调
|
|
|
+ if (detailState.activeDetail?.musicJianSvg) {
|
|
|
renderData = JSON.parse(detailState.activeDetail.musicJianSvg)
|
|
|
}
|
|
|
}
|
|
@@ -180,7 +187,7 @@ export default defineComponent({
|
|
|
console.error(error)
|
|
|
detailState.renderType = 'native'
|
|
|
}
|
|
|
- if (renderData && !props.isSoundEffect){
|
|
|
+ if (renderData && !props.isSoundEffect) {
|
|
|
productJsonAndSvg(renderData)
|
|
|
} else {
|
|
|
setOsdm()
|
|
@@ -217,7 +224,7 @@ export default defineComponent({
|
|
|
const setRender = async ({ score: s }: SetRenderOptions = {}) => {
|
|
|
const renderScore = s || score.value
|
|
|
// console.log(renderScore)
|
|
|
- Toast('加载中,请稍后...')
|
|
|
+ // Toast('加载中,请稍后...')
|
|
|
setTimeout(async () => {
|
|
|
if (osmd && osmd.value && renderScore) {
|
|
|
await osmd.value.clear()
|
|
@@ -238,14 +245,10 @@ export default defineComponent({
|
|
|
}
|
|
|
|
|
|
const reRender = async () => {
|
|
|
+ // if (detailState.renderType == 'cache'){
|
|
|
+ // detailState.times = getNotePosition(detailState.times)
|
|
|
+ // }
|
|
|
await osmd.value?.render()
|
|
|
- // postMessage({
|
|
|
- // api: 'cloudLoading',
|
|
|
- // content: {
|
|
|
- // show: false,
|
|
|
- // type: 'fullscreen',
|
|
|
- // },
|
|
|
- // })
|
|
|
}
|
|
|
|
|
|
const resetFormate = () => {
|
|
@@ -616,7 +619,11 @@ export default defineComponent({
|
|
|
|
|
|
return () => {
|
|
|
return (
|
|
|
- <div id="svgContainer" class={styles.container} style={{ position: 'relative' }}>
|
|
|
+ <div
|
|
|
+ id="svgContainer"
|
|
|
+ class={styles.container}
|
|
|
+ style={{ position: 'relative', display: 'flex', justifyContent: 'center' }}
|
|
|
+ >
|
|
|
<div ref={container}></div>
|
|
|
{/* 小节覆盖层 */}
|
|
|
{props.showSection && (
|