Commit 63b2a589 authored by zhengke's avatar zhengke

字体放大缩小

parent 8b16992b
import { fa } from 'element-plus/es/locale';
import type { Ref } from 'vue'
import { storeToRefs } from 'pinia'
import { useMainStore, useSlidesStore, useKeyboardStore, useFontStore } from '@/store'
......@@ -404,29 +405,40 @@ export default (
}
}
let baseFontSize = 0
let baseFontSize = 0
let aaa = '<p style=""><span style="font-size: 97.62px;">日本旅游</span></p>'
// let arr = aaa.split(';')
let arr = el.content.split(';')
// console.log(el.content)
// console.log(arr,'====1111')
let fontSize = arr.filter((z:any)=>z.indexOf('font-size:')!=-1)
if(fontSize.length>0){
if(fontSize&&fontSize.length>0){
let arrs = fontSize[0].split(':')
let arrs2 = arrs[1].split('px')
baseFontSize = Number(arrs2[0])
}
const w = parseInt(Number(el.width)-Number(width))
for(let i=0;i<arr.length;i++){
if(arr[i].indexOf('font-size:')!=-1){
if((el.width-width)>2||(el.width-width)<-2){
if((el.width-width)>1) baseFontSize--
if(w>2||w<-2){
if(w>2) baseFontSize--
else baseFontSize++
arr[i] = `font-size:${baseFontSize}px`
arr[i] = `font-size: ${baseFontSize}px`
}
}
}
}
let content = ''
const last = arr.length-1
for(let i=0;i<arr.length;i++){
if(i<arr.length-1){
console.log(arr[i],`----${i}---1111`)
if(i!=last){
content+=arr[i]+';'
}else content+=arr[i]
}
console.log(arr)
console.log(content,'-0-----')
return { ...el, left, top, width, height, content}
})
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment