import { defineComponent, nextTick, reactive, watch } from "vue"; import styles from "./index.module.less"; import iconClose from "../image/close2.svg"; import { Cell, Field, NoticeBar, Popup, Radio, RadioGroup, Slider, Switch, Tab, Tabs, closeToast, showLoadingToast, showToast, } from "vant"; import state, { IPlatform } from "/src/state"; import { api_closeCamera, api_openCamera, api_savePicture } from "/src/helpers/communication"; import iconInfo from "../image/info.svg"; import iconDown from "../image/down.svg"; import iconTv from "../image/tv.svg"; import iconYijian from "../image/yijian.svg"; import iconSubtract from "../image/subtract.png"; import iconAdd from "../image/add.png"; import ScreenModel from "../../custom-plugins/helper-model/screen-model"; import Recommendation from "../../custom-plugins/helper-model/recommendation"; import { svg2canvas } from "/src/utils/svg2canvas"; import { getQuery } from "/src/utils/queryString"; import { browser } from "/src/utils"; export default defineComponent({ name: "header-settting", setup() { const query = getQuery(); const helperData = reactive({ show: false, recommendationShow: false, // 建议 }); const downPng = () => { showLoadingToast({ message: "下载中", duration: 0 }); setTimeout(async () => { const svg: any = document.getElementById("osmdSvgPage1")?.cloneNode(true); if (!svg) return showToast({ message: "保存失败", type: "fail" }); const cw = svg.width.animVal.value; const ch = svg.height.animVal.value; const rect = document.createElementNS("http://www.w3.org/2000/svg", "rect"); rect.setAttribute("x", "0"); rect.setAttribute("y", "0"); rect.setAttribute("width", `${cw * 2}`); rect.setAttribute("height", `${ch * 2}`); rect.setAttribute("fill", "#fff"); svg.prepend(rect); if (svg) { const _canvas = svg2canvas(svg.outerHTML); const browserInfo = browser(); if (state.platform === IPlatform.PC || !browserInfo.isApp) { let el: any = document.createElement("a"); // 设置 href 为图片经过 base64 编码后的字符串,默认为 png 格式 el.href = _canvas.toDataURL(); el.download = state.examSongName; // 创建一个点击事件并对 a 标签进行触发 const event = new MouseEvent("click"); el.dispatchEvent(event); setTimeout(() => { showToast({ message: "保存成功", type: "success" }); el = null; }, 300); } else { const base64 = _canvas.toDataURL("image/png", 1); const res = await api_savePicture({ base64, }); if (res?.content?.status === "success") { showToast({ message: "保存成功", type: "success" }); } else { showToast({ message: "保存失败", type: "fail" }); } } } }, 500); }; const formatterTimeMs = (value: any) => value = String(Math.min(3000, value)); // 加减评测频率 const operateHz = (type: number) => { const minFrequency = state.baseFrequency - 10, maxFrequency = state.baseFrequency + 10 let currentFrequency = state.setting.frequency if (type === 1) { if (currentFrequency - 1 < minFrequency) return showToast({ message: `最低标准音高${minFrequency}HZ` }) currentFrequency = currentFrequency - 1 } else { if (currentFrequency + 1 > maxFrequency) return showToast({ message: `最高标准音高${maxFrequency}HZ` }) currentFrequency = currentFrequency + 1 } state.setting.frequency = currentFrequency >= 0 ? currentFrequency : 0 } return () => (
{{ extra: () => , }} {{ extra: () => ( {{ button: () =>
{state.setting.beatVolume}
, }}
), }}
{/*
下载曲谱
*/}
(helperData.show = true)}> 投屏帮助
(helperData.recommendationShow = true)}> 意见反馈
{{ extra: () => , }} {{ extra: () => , }} {{ extra: () => ( 入门 进阶 大师 ), }} {{ extra: () => , }} {{ extra: () => ( { if (value) { const res = await api_openCamera(); // 没有授权 if (res?.content?.reson) { state.setting.camera = false } } else { api_closeCamera(); } }} > ), }} {{ extra: () => ( {{ button: () =>
{state.setting.cameraOpacity}
, }}
), }}
{/* {{ extra: () => , }} */} {{ extra: () => , }} {/* {{ extra: () => ( 440Hz 442Hz ), }} */} {{ extra: () => (
operateHz(1)} /> {state.setting.frequency}HZ operateHz(2)} />
) }}
{ helperData.show = false; }} position="right" teleport="body" > { helperData.show = false; }} /> { helperData.recommendationShow = false; }} />
); }, });