1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417 |
- import { PropType, Teleport, defineComponent, nextTick, onMounted, onUnmounted, ref } from "vue";
- import { Config, DriveStep, PopoverDOM, State, driver } from "driver.js";
- import "driver.js/dist/driver.css";
- import state, { IPlatform } from "/src/state";
- import { getGuidance, setGuidance } from "../guide-page/api";
- const endGuide = (guideInfo: any) => {
- try {
- // setGuidance({ guideTag: "guideInfo", guideValue: JSON.stringify(guideInfo) });
- localStorage.setItem("guideInfo", JSON.stringify(guideInfo));
- } catch (e) {
- console.log(e);
- }
- };
- /**
- * 按钮状态
- */
- type ButtonStatus = {
- /** 是否显示播放按钮 */
- playBtnStatus?: Boolean;
- /** 声部状态 */
- subjectStatus?: Boolean;
- /** 练习模式 */
- modelTypeStatus?: Boolean;
- /** 播放模式 演唱 演奏 */
- playType?: Boolean;
- /** 返回和标题 */
- backTitle?: Boolean;
- /** 返回显示的标题类型 文本 TEXT 按钮 IMG */
- titleType?: String;
- /** 原声 true 范唱 false */
- originPlayType?: Boolean;
- /** 是否显示原音 */
- originBtnStatus?: Boolean;
- };
- /** 练习模式 */
- export const PractiseDriver = defineComponent({
- name: "PractiseDriver",
- props: {
- // 按钮状态
- statusAll: {
- type: Object as PropType<ButtonStatus>,
- default: () => {},
- },
- },
- setup(props) {
- const driverNextStatus = ref(false);
- // 初始化部分引导位置
- const driverInitialPosition = (popover: PopoverDOM, options: { config: Config; state: State }) => {
- options.config.stageRadius = 5;
- options.config.stagePadding = 8;
- try {
- const rect = options.state.activeElement?.getBoundingClientRect();
- popover.wrapper.style.marginLeft = -(rect?.width || 0) / 2 + 4 + "px";
- } catch {}
- };
- const driverOptions = (): Config => {
- let length = 10;
- if (!props.statusAll.playBtnStatus) {
- length -= 1;
- }
- if (!props.statusAll.originBtnStatus) {
- length -= 1;
- }
- // 显示指法
- if (!state.setting.displayFingering) {
- length -= 1;
- }
- // 声部
- if (!props.statusAll.subjectStatus) {
- length -= 1;
- }
- if (!props.statusAll.playType) {
- length -= 1;
- }
- // pc端不显示标题和模式切换引导
- if (state.platform === IPlatform.PC) {
- length -= 2;
- } else {
- // 判断是否有标题
- if (!props.statusAll.backTitle || props.statusAll.titleType === "NONE") {
- length -= 1;
- }
- // 练习模式
- if (!props.statusAll.modelTypeStatus) {
- length -= 1;
- }
- }
- console.log(props.statusAll, "statusAll", length, state.setting.displayFingering);
- let options: Config = {
- showProgress: false,
- allowClose: false,
- popoverOffset: 3,
- disableActiveInteraction: true,
- onCloseClick: () => {
- onDriverClose();
- },
- onHighlightStarted: () => {
- driverNextStatus.value = true;
- },
- onHighlighted: () => {
- driverNextStatus.value = false;
- },
- steps: [] as DriveStep[],
- };
- if (props.statusAll.playBtnStatus) {
- options.steps?.push({
- element: ".driver-1",
- popover: {
- title: "",
- description: "",
- popoverClass: "popoverClass popoverClass1",
- align: "end",
- side: "top",
- nextBtnText: `下一步 (1/${length})`,
- showButtons: ["next"],
- onPopoverRender: (popover: PopoverDOM, options: { config: Config; state: State }) => {
- options.config.stageRadius = 1000;
- options.config.stagePadding = 0;
- },
- },
- });
- }
- options.steps?.push({
- element: ".driver-9",
- popover: {
- title: "",
- description: "",
- popoverClass: "popoverClass popoverClass9",
- align: "end",
- side: "bottom",
- nextBtnText: `下一步 (2/${length})`,
- showButtons: ["next"],
- onPopoverRender: (popover: PopoverDOM, options: { config: Config; state: State }) => {
- driverInitialPosition(popover, options);
- },
- },
- });
- if (props.statusAll.playType) {
- options.steps?.push({
- element: ".driver-2",
- popover: {
- title: "",
- description: "",
- popoverClass: "popoverClass popoverClass2",
- align: "start",
- side: "top",
- nextBtnText: `下一步 (${options.steps.length + 1}/${length})`,
- showButtons: ["next"],
- onPopoverRender: (popover: PopoverDOM, options: { config: Config; state: State }) => {
- driverInitialPosition(popover, options);
- },
- },
- });
- }
- if (props.statusAll.originBtnStatus) {
- options.steps?.push({
- element: ".driver-3",
- popover: {
- title: "",
- description: "",
- popoverClass: props.statusAll.originPlayType ? "popoverClass popoverClass3" : "popoverClass popoverClass11",
- align: "end",
- side: "bottom",
- nextBtnText: `下一步 (${options.steps.length + 1}/${length})`,
- showButtons: ["next"],
- onPopoverRender: (popover: PopoverDOM, options: { config: Config; state: State }) => {
- driverInitialPosition(popover, options);
- },
- },
- });
- }
- options.steps?.push(
- {
- element: ".driver-4",
- popover: {
- title: "",
- description: "",
- popoverClass: "popoverClass popoverClass4",
- align: "end",
- side: "bottom",
- nextBtnText: `下一步 (${options.steps.length + 1}/${length})`,
- showButtons: ["next"],
- onPopoverRender: (popover: PopoverDOM, options: { config: Config; state: State }) => {
- driverInitialPosition(popover, options);
- },
- },
- },
- {
- element: ".driver-5",
- popover: {
- title: "",
- description: "",
- popoverClass: "popoverClass popoverClass5",
- align: "end",
- side: "bottom",
- nextBtnText: `下一步 (${options.steps.length + 2}/${length})`,
- showButtons: ["next"],
- onPopoverRender: (popover: PopoverDOM, options: { config: Config; state: State }) => {
- driverInitialPosition(popover, options);
- },
- },
- }
- );
- if (props.statusAll.subjectStatus) {
- options.steps?.push({
- element: ".driver-10",
- popover: {
- title: "",
- description: "",
- popoverClass: "popoverClass popoverClass10",
- align: "end",
- side: "bottom",
- nextBtnText: `下一步 (${options.steps.length + 1}/${length})`,
- showButtons: ["next"],
- onPopoverRender: (popover: PopoverDOM, options: { config: Config; state: State }) => {
- driverInitialPosition(popover, options);
- },
- },
- });
- }
- options.steps?.push({
- element: ".driver-5-1",
- popover: {
- title: "",
- description: "",
- popoverClass: "popoverClass popoverClass5-1",
- align: "end",
- side: "bottom",
- nextBtnText: `下一步 (${options.steps.length + 1}/${length})`,
- showButtons: ["next"],
- onPopoverRender: (popover: PopoverDOM, options: { config: Config; state: State }) => {
- driverInitialPosition(popover, options);
- },
- },
- });
- if (state.platform === IPlatform.PC) {
- options.steps?.push({
- element: ".driver-6",
- popover: {
- title: "",
- description: "",
- popoverClass: "popoverClass popoverClass6",
- align: "end",
- side: "bottom",
- nextBtnText: `下一步 (${options.steps.length + 1}/${length})`, //"下一步6/" + length,
- showButtons: ["next"],
- onPopoverRender: (popover: PopoverDOM, options: { config: Config; state: State }) => {
- driverInitialPosition(popover, options);
- },
- },
- });
- } else {
- // 判断设置之后是否还有引导
- if (!state.setting.displayFingering && !props.statusAll.backTitle && !props.statusAll.modelTypeStatus) {
- options.steps?.push({
- element: ".driver-6",
- popover: {
- title: "",
- description: "",
- popoverClass: "popoverClass popoverClass6 popoverClose",
- align: "start",
- side: "top",
- prevBtnText: "再看一遍",
- doneBtnText: "完成",
- showButtons: ["next", "previous"],
- onPopoverRender: (popover: PopoverDOM, options: { config: Config; state: State }) => {
- driverInitialPosition(popover, options);
- },
- onPrevClick: () => {
- driverObj.drive(0);
- },
- onNextClick: () => {
- onDriverClose();
- },
- },
- });
- } else if (state.setting.displayFingering && !props.statusAll.backTitle && !props.statusAll.modelTypeStatus) {
- options.steps?.push({
- element: ".driver-6",
- popover: {
- title: "",
- description: "",
- popoverClass: "popoverClass popoverClass6",
- align: "end",
- side: "bottom",
- nextBtnText: `下一步 (${options.steps.length + 1}/${length})`, //"下一步6/" + length,
- showButtons: ["next"],
- onPopoverRender: (popover: PopoverDOM, options: { config: Config; state: State }) => {
- driverInitialPosition(popover, options);
- },
- },
- });
- } else if (props.statusAll.backTitle && !props.statusAll.modelTypeStatus) {
- options.steps?.push({
- element: ".driver-6",
- popover: {
- title: "",
- description: "",
- popoverClass: "popoverClass popoverClass6",
- align: "end",
- side: "bottom",
- nextBtnText: `下一步 (${options.steps.length + 1}/${length})`, //"下一步6/" + length,
- showButtons: ["next"],
- onPopoverRender: (popover: PopoverDOM, options: { config: Config; state: State }) => {
- driverInitialPosition(popover, options);
- },
- },
- });
- options.steps?.push({
- //props.statusAll.titleType === "TEXT" ? ".driver-8 .van-notice-bar__content" :
- element: ".driver-8",
- popover: {
- title: "",
- description: "",
- popoverClass: "popoverClass popoverClass8 popoverClose",
- align: "start",
- side: "bottom",
- prevBtnText: "再看一遍",
- doneBtnText: "完成",
- showButtons: ["next", "previous"],
- onPopoverRender: (popover: PopoverDOM, options: { config: Config; state: State }) => {
- driverInitialPosition(popover, options);
- const rect = options.state.activeElement?.getBoundingClientRect();
- popover.wrapper.style.marginLeft = (rect?.width || 0) / 2 + 4 + "px";
- },
- onPrevClick: () => {
- driverObj.drive(0);
- },
- onNextClick: () => {
- onDriverClose();
- },
- },
- });
- } else {
- options.steps?.push({
- element: ".driver-6",
- popover: {
- title: "",
- description: "",
- popoverClass: "popoverClass popoverClass6",
- align: "end",
- side: "bottom",
- nextBtnText: `下一步 (${options.steps.length + 1}/${length})`, //"下一步6/" + length,
- showButtons: ["next"],
- onPopoverRender: (popover: PopoverDOM, options: { config: Config; state: State }) => {
- driverInitialPosition(popover, options);
- },
- },
- });
- if (props.statusAll.backTitle) {
- options.steps?.push({
- // .van-notice-bar__content
- // element: ".driver-8 .van-notice-bar__content",
- // props.statusAll.titleType === "TEXT" ? ".driver-8 .van-notice-bar__content" :
- element: ".driver-8",
- popover: {
- title: "",
- description: "",
- popoverClass: "popoverClass popoverClass8 popoverClose",
- align: "start",
- side: "bottom",
- prevBtnText: "再看一遍",
- doneBtnText: "完成",
- showButtons: ["next", "previous"],
- onPopoverRender: (popover: PopoverDOM, options: { config: Config; state: State }) => {
- driverInitialPosition(popover, options);
- const rect = options.state.activeElement?.getBoundingClientRect();
- popover.wrapper.style.marginLeft = (rect?.width || 0) / 2 + 4 + "px";
- },
- onPrevClick: () => {
- driverObj.drive(0);
- },
- onNextClick: () => {
- onDriverClose();
- },
- },
- });
- }
- }
- }
- return options;
- };
- let driverObj: any;
- const handleClickOutside = (event: any) => {
- // 如果高亮没有结束则下进行下一步
- if (driverNextStatus.value) return;
- if (driverObj.isActive() && (event.target.nodeName === "path" || event.target.classList.contains("driver-popover") || event.target.classList.contains("driver-overlay"))) {
- if (driverObj.isLastStep()) {
- onDriverClose();
- } else {
- driverObj.moveNext(); // 跳转到下一步
- }
- }
- };
- const guideInfo = ref({} as any);
- const showCloseBtn = ref(false);
- const getAllGuidance = async () => {
- try {
- // const res = await getGuidance({ guideTag: "guideInfo" });
- const res = localStorage.getItem("guideInfo");
- if (res) {
- guideInfo.value = JSON.parse(res) || null;
- } else {
- guideInfo.value = {};
- }
- if (!(guideInfo.value && guideInfo.value.practiseDriver)) {
- document.addEventListener("click", handleClickOutside, true);
- driverObj = driver(driverOptions());
- nextTick(() => {
- driverObj.drive();
- showCloseBtn.value = true;
- state.hasDriverPop = true;
- });
- }
- } catch (e) {
- console.log(e);
- }
- };
- getAllGuidance();
- // 结束关闭弹窗
- const onDriverClose = () => {
- if (!guideInfo.value) {
- guideInfo.value = { practiseDriver: true };
- } else {
- guideInfo.value.practiseDriver = true;
- }
- endGuide(guideInfo.value);
- driverObj.destroy();
- document.querySelector(".driver-popover-close-btn-custom")?.remove();
- document.removeEventListener("click", handleClickOutside, true);
- state.hasDriverPop = false;
- };
- onUnmounted(() => {
- document.removeEventListener("click", handleClickOutside, true);
- });
- return () => (
- <Teleport to="body">
- {showCloseBtn.value && (
- <div
- class="driver-popover-close-btn-custom"
- onClick={(e: any) => {
- onDriverClose();
- }}
- ></div>
- )}
- </Teleport>
- );
- },
- });
- /** 跟练模式 */
- export const FollowDriver = defineComponent({
- name: "FollowDriver",
- props: {
- // 按钮状态
- statusAll: {
- type: Object as PropType<ButtonStatus>,
- default: () => {},
- },
- },
- setup(props) {
- const driverNextStatus = ref(false);
- // 初始化部分引导位置
- const driverInitialPosition = (popover: PopoverDOM, options: { config: Config; state: State }) => {
- options.config.stageRadius = 5;
- options.config.stagePadding = 8;
- try {
- const rect = options.state.activeElement?.getBoundingClientRect();
- popover.wrapper.style.marginLeft = -(rect?.width || 0) / 2 + 4 + "px";
- } catch {}
- };
- // 声部
- let length = props.statusAll.subjectStatus ? 5 : 4;
- const driverOptions: Config = {
- showProgress: false,
- allowClose: false,
- popoverOffset: 3,
- disableActiveInteraction: true,
- onCloseClick: () => {
- onDriverClose();
- },
- onHighlightStarted: () => {
- driverNextStatus.value = true;
- },
- onHighlighted: () => {
- driverNextStatus.value = false;
- },
- steps: [
- {
- element: ".follow-1",
- popover: {
- title: "",
- description: "",
- popoverClass: "popoverClass popoverClassF1",
- align: "end",
- side: "top",
- nextBtnText: `下一步 (1/${length})`,
- showButtons: ["next"],
- onPopoverRender: (popover: PopoverDOM, options: { config: Config; state: State }) => {
- options.config.stageRadius = 1000;
- options.config.stagePadding = 0;
- },
- },
- },
- {
- element: ".driver-5",
- popover: {
- title: "",
- description: "",
- popoverClass: "popoverClass popoverClassF2",
- align: "end",
- side: "bottom",
- nextBtnText: `下一步 (2/${length})`,
- showButtons: ["next"],
- onPopoverRender: (popover: PopoverDOM, options: { config: Config; state: State }) => {
- driverInitialPosition(popover, options);
- },
- },
- },
- ],
- };
- if (props.statusAll.subjectStatus) {
- driverOptions.steps?.push({
- element: ".driver-10",
- popover: {
- title: "",
- description: "",
- popoverClass: "popoverClass popoverClass10",
- align: "end",
- side: "bottom",
- nextBtnText: `下一步 (${driverOptions.steps.length + 1}/${length})`,
- showButtons: ["next"],
- onPopoverRender: (popover: PopoverDOM, options: { config: Config; state: State }) => {
- driverInitialPosition(popover, options);
- },
- },
- });
- }
- driverOptions.steps?.push({
- element: ".driver-5-1",
- popover: {
- title: "",
- description: "",
- popoverClass: "popoverClass popoverClass5-1",
- align: "end",
- side: "bottom",
- nextBtnText: `下一步 (${driverOptions.steps.length + 1}/${length})`,
- showButtons: ["next"],
- onPopoverRender: (popover: PopoverDOM, options: { config: Config; state: State }) => {
- driverInitialPosition(popover, options);
- },
- },
- });
- driverOptions.steps?.push({
- element: ".driver-6",
- popover: {
- title: "",
- description: "",
- popoverClass: "popoverClass popoverClassF3 popoverClose",
- align: "end",
- side: "bottom",
- prevBtnText: "再看一遍",
- doneBtnText: "完成",
- showButtons: ["next", "previous"],
- onPopoverRender: (popover: PopoverDOM, options: { config: Config; state: State }) => {
- driverInitialPosition(popover, options);
- },
- onPrevClick: () => {
- driverObj.drive(0);
- },
- onNextClick: () => {
- onDriverClose();
- },
- },
- });
- let driverObj: any;
- const handleClickOutside = (event: any) => {
- if (driverNextStatus.value) return;
- console.log(driverObj.getActiveIndex(), "driverObj.getActiveIndex()");
- if (driverObj.isActive() && (event.target.nodeName === "path" || event.target.classList.contains("driver-popover") || event.target.classList.contains("driver-overlay"))) {
- if (driverObj.isLastStep()) {
- onDriverClose();
- } else {
- // driverObj.moveNext(); // 跳转到下一步
- const index = driverObj.getActiveIndex();
- driverObj.moveTo(index + 1);
- }
- }
- };
- const guideInfo = ref({} as any);
- const showCloseBtn = ref(false);
- const getAllGuidance = async () => {
- try {
- const res = localStorage.getItem("guideInfo");
- if (res) {
- guideInfo.value = JSON.parse(res) || null;
- } else {
- guideInfo.value = {};
- }
- if (!(guideInfo.value && guideInfo.value.followDriver)) {
- document.addEventListener("click", handleClickOutside, true);
- nextTick(() => {
- driverObj = driver(driverOptions);
- driverObj.drive(0);
- showCloseBtn.value = true;
- state.hasDriverPop = true;
- });
- }
- } catch (e) {
- console.log(e);
- }
- };
- getAllGuidance();
- // 结束关闭弹窗
- const onDriverClose = () => {
- if (!guideInfo.value) {
- guideInfo.value = { followDriver: true };
- } else {
- guideInfo.value.followDriver = true;
- }
- endGuide(guideInfo.value);
- driverObj.destroy();
- document.querySelector(".driver-popover-close-btn-custom")?.remove();
- document.removeEventListener("click", handleClickOutside, true);
- state.hasDriverPop = false;
- };
- onUnmounted(() => {
- document.removeEventListener("click", handleClickOutside, true);
- });
- return () => (
- <Teleport to="body">
- {showCloseBtn.value && (
- <div
- class="driver-popover-close-btn-custom"
- onClick={(e: any) => {
- onDriverClose();
- }}
- ></div>
- )}
- </Teleport>
- );
- },
- });
- // 评测模式
- export const EvaluatingDriver = defineComponent({
- name: "EvaluatingDriver",
- props: {
- // 按钮状态
- statusAll: {
- type: Object as PropType<ButtonStatus>,
- default: () => {},
- },
- },
- setup(props) {
- const driverNextStatus = ref(false);
- // 初始化部分引导位置
- const driverInitialPosition = (popover: PopoverDOM, options: { config: Config; state: State }) => {
- options.config.stageRadius = 5;
- options.config.stagePadding = 8;
- try {
- const rect = options.state.activeElement?.getBoundingClientRect();
- popover.wrapper.style.marginLeft = -(rect?.width || 0) / 2 + 4 + "px";
- } catch {}
- };
- // 声部
- let length = props.statusAll.subjectStatus ? 6 : 5;
- const driverOptions: Config = {
- showProgress: false,
- allowClose: false,
- popoverOffset: 3,
- disableActiveInteraction: true,
- onCloseClick: () => {
- onDriverClose();
- },
- onHighlightStarted: () => {
- driverNextStatus.value = true;
- },
- onHighlighted: () => {
- driverNextStatus.value = false;
- },
- steps: [
- {
- element: ".evaluting-1",
- popover: {
- title: "",
- description: "",
- popoverClass: "popoverClass popoverClassE1",
- align: "end",
- side: "top",
- nextBtnText: `下一步 (1/${length})`,
- showButtons: ["next"],
- onPopoverRender: (popover: PopoverDOM, options: { config: Config; state: State }) => {
- options.config.stageRadius = 1000;
- options.config.stagePadding = 0;
- },
- },
- },
- {
- element: ".driver-4",
- popover: {
- title: "",
- description: "",
- popoverClass: "popoverClass popoverClassE2",
- align: "end",
- side: "bottom",
- nextBtnText: `下一步 (2/${length})`,
- showButtons: ["next"],
- onPopoverRender: (popover: PopoverDOM, options: { config: Config; state: State }) => {
- driverInitialPosition(popover, options);
- },
- },
- },
- {
- element: ".driver-5",
- popover: {
- title: "",
- description: "",
- popoverClass: "popoverClass popoverClassE3",
- align: "end",
- side: "bottom",
- nextBtnText: `下一步 (3/${length})`,
- showButtons: ["next"],
- onPopoverRender: (popover: PopoverDOM, options: { config: Config; state: State }) => {
- driverInitialPosition(popover, options);
- },
- },
- },
- ],
- };
- if (props.statusAll.subjectStatus) {
- driverOptions.steps?.push({
- element: ".driver-10",
- popover: {
- title: "",
- description: "",
- popoverClass: "popoverClass popoverClass10",
- align: "end",
- side: "bottom",
- nextBtnText: `下一步 (${driverOptions.steps.length + 1}/${length})`,
- showButtons: ["next"],
- onPopoverRender: (popover: PopoverDOM, options: { config: Config; state: State }) => {
- driverInitialPosition(popover, options);
- },
- },
- });
- }
- driverOptions.steps?.push({
- element: ".driver-5-1",
- popover: {
- title: "",
- description: "",
- popoverClass: "popoverClass popoverClass5-1",
- align: "end",
- side: "bottom",
- nextBtnText: `下一步 (${driverOptions.steps.length + 1}/${length})`,
- showButtons: ["next"],
- onPopoverRender: (popover: PopoverDOM, options: { config: Config; state: State }) => {
- driverInitialPosition(popover, options);
- },
- },
- });
- driverOptions.steps?.push({
- element: ".driver-6",
- popover: {
- title: "",
- description: "",
- popoverClass: "popoverClass popoverClassE4 popoverClose",
- align: "end",
- side: "bottom",
- prevBtnText: "再看一遍",
- doneBtnText: "完成",
- showButtons: ["next", "previous"],
- onPopoverRender: (popover: PopoverDOM, options: { config: Config; state: State }) => {
- driverInitialPosition(popover, options);
- },
- onPrevClick: () => {
- driverObj.drive(0);
- },
- onNextClick: () => {
- onDriverClose();
- },
- },
- });
- let driverObj: any;
- const handleClickOutside = (event: any) => {
- if (driverNextStatus.value) return;
- console.log(driverObj.getActiveIndex(), "driverObj.getActiveIndex()");
- if (driverObj.isActive() && (event.target.nodeName === "path" || event.target.classList.contains("driver-popover") || event.target.classList.contains("driver-overlay"))) {
- if (driverObj.isLastStep()) {
- onDriverClose();
- } else {
- driverObj.moveNext(); // 跳转到下一步
- }
- }
- };
- const guideInfo = ref({} as any);
- const showCloseBtn = ref(false);
- const getAllGuidance = async () => {
- try {
- const res = localStorage.getItem("guideInfo");
- if (res) {
- guideInfo.value = JSON.parse(res) || null;
- } else {
- guideInfo.value = {};
- }
- console.log(guideInfo.value, "guideInfo.value", showCloseBtn.value);
- if (!(guideInfo.value && guideInfo.value.evaluatingDriver)) {
- document.addEventListener("click", handleClickOutside, true);
- nextTick(() => {
- driverObj = driver(driverOptions);
- driverObj.drive();
- showCloseBtn.value = true;
- state.hasDriverPop = true;
- console.log(driverOptions, "driverOptions Evaluating", showCloseBtn.value);
- });
- } else {
- driverObj?.destroy();
- }
- } catch (e) {
- console.log(e);
- }
- };
- getAllGuidance();
- // 结束关闭弹窗
- const onDriverClose = () => {
- if (!guideInfo.value) {
- guideInfo.value = { evaluatingDriver: true };
- } else {
- guideInfo.value.evaluatingDriver = true;
- }
- endGuide(guideInfo.value);
- driverObj?.destroy();
- document.querySelector(".driver-popover-close-btn-custom")?.remove();
- document.removeEventListener("click", handleClickOutside, true);
- state.hasDriverPop = false;
- };
- onUnmounted(() => {
- document.removeEventListener("click", handleClickOutside, true);
- });
- return () => (
- <Teleport to="body">
- {showCloseBtn.value && (
- <div
- class="driver-popover-close-btn-custom"
- onClick={(e: any) => {
- onDriverClose();
- }}
- ></div>
- )}
- </Teleport>
- );
- },
- });
- // 评测模式 - 结果弹窗
- export const EvaluatingResultDriver = defineComponent({
- name: "EvaluatingResultDriver",
- props: {
- // 保存按钮状态
- saveBtn: {
- type: Boolean,
- default: true,
- },
- },
- setup(props) {
- let length = 4;
- if (!props.saveBtn) {
- length -= 1;
- }
- console.log(props.saveBtn, "props.saveBtn");
- const driverNextStatus = ref(false);
- // 初始化部分引导位置
- const driverInitialPosition = (popover: PopoverDOM, options: { config: Config; state: State }, position = 1) => {
- options.config.stageRadius = 1000;
- options.config.stagePadding = 0;
- try {
- const rect = options.state.activeElement?.getBoundingClientRect();
- popover.wrapper.style.marginLeft = ((rect?.width || 0) / 2) * position + 4 + "px";
- } catch {}
- };
- const driverOptionsFun = () => {
- const driverOptions: Config = {
- showProgress: false,
- allowClose: false,
- popoverOffset: 3,
- disableActiveInteraction: true,
- onCloseClick: () => {
- onDriverClose();
- },
- onHighlightStarted: () => {
- driverNextStatus.value = true;
- },
- onHighlighted: () => {
- driverNextStatus.value = false;
- },
- steps: [
- {
- element: ".evaluting-result-1",
- popover: {
- title: "",
- description: "",
- popoverClass: "popoverClass popoverClassER1",
- align: "start",
- side: "right",
- nextBtnText: `下一步 (1/${length})`,
- showButtons: ["next"],
- onPopoverRender: (popover: PopoverDOM, options: { config: Config; state: State }) => {
- options.config.stageRadius = 12;
- options.config.stagePadding = 10;
- },
- },
- },
- {
- element: ".evaluting-result-2",
- popover: {
- title: "",
- description: "",
- popoverClass: "popoverClass popoverClassER2",
- align: "start",
- side: "top",
- nextBtnText: `下一步 (2/${length})`,
- showButtons: ["next"],
- onPopoverRender: (popover: PopoverDOM, options: { config: Config; state: State }) => {
- options.config.stageRadius = 1000;
- options.config.stagePadding = 0;
- try {
- const rect = options.state.activeElement?.getBoundingClientRect();
- popover.wrapper.style.marginLeft = (rect?.width || 0) / 2 - 4 + "px";
- } catch {}
- },
- },
- },
- ],
- };
- if (props.saveBtn) {
- driverOptions.steps?.push({
- element: ".evaluting-result-3",
- popover: {
- title: "",
- description: "",
- popoverClass: "popoverClass popoverClassER3",
- align: "end",
- side: "top",
- nextBtnText: `下一步 (3/${length})`,
- showButtons: ["next"],
- onPopoverRender: (popover: PopoverDOM, options: { config: Config; state: State }) => {
- driverInitialPosition(popover, options, -1);
- },
- },
- });
- }
- driverOptions.steps?.push({
- element: ".evaluting-result-4",
- popover: {
- title: "",
- description: "",
- popoverClass: "popoverClass popoverClassER4 popoverClose",
- align: "end",
- side: "top",
- prevBtnText: "再看一遍",
- doneBtnText: "完成",
- showButtons: ["next", "previous"],
- onPopoverRender: (popover: PopoverDOM, options: { config: Config; state: State }) => {
- driverInitialPosition(popover, options, -1);
- },
- onPrevClick: () => {
- driverObj.drive();
- },
- onNextClick: () => {
- onDriverClose();
- },
- },
- });
- return driverOptions;
- };
- let driverObj: any;
- const handleClickOutside = (event: any) => {
- if (driverNextStatus.value) return;
- if (driverObj.isActive() && (event.target.nodeName === "path" || event.target.classList.contains("driver-popover") || event.target.classList.contains("driver-overlay"))) {
- if (driverObj.isLastStep()) {
- onDriverClose();
- } else {
- driverObj.moveNext(); // 跳转到下一步
- }
- }
- };
- const guideInfo = ref({} as any);
- const showCloseBtn = ref(false);
- const getAllGuidance = async () => {
- try {
- const res = localStorage.getItem("guideInfo");
- if (res) {
- guideInfo.value = JSON.parse(res) || null;
- } else {
- guideInfo.value = {};
- }
- if (!(guideInfo.value && guideInfo.value.evaluatingResultDriver)) {
- setTimeout(() => {
- document.addEventListener("click", handleClickOutside, true);
- nextTick(() => {
- driverObj = driver(driverOptionsFun());
- driverObj.drive();
- showCloseBtn.value = true;
- state.hasDriverPop = true;
- });
- }, 100);
- }
- } catch (e) {
- console.log(e);
- }
- };
- onMounted(() => {
- getAllGuidance();
- });
- // 结束关闭弹窗
- const onDriverClose = () => {
- if (!guideInfo.value) {
- guideInfo.value = { evaluatingResultDriver: true };
- } else {
- guideInfo.value.evaluatingResultDriver = true;
- }
- endGuide(guideInfo.value);
- driverObj.destroy();
- document.querySelector(".driver-popover-close-btn-custom")?.remove();
- document.removeEventListener("click", handleClickOutside, true);
- state.hasDriverPop = false;
- };
- onUnmounted(() => {
- document.removeEventListener("click", handleClickOutside, true);
- });
- return () => (
- <Teleport to="body">
- {showCloseBtn.value && (
- <div
- class="driver-popover-close-btn-custom"
- onClick={(e: any) => {
- onDriverClose();
- }}
- ></div>
- )}
- </Teleport>
- );
- },
- });
- // 评测报告
- export const EvaluatingReportDriver = defineComponent({
- name: "EvaluatingReportDriver",
- props: {
- /** 视屏地址 */
- videoFilePath: {
- type: String,
- default: "",
- },
- },
- setup(props) {
- const driverNextStatus = ref(false);
- // state.isPercussion 是否为打击乐
- // 初始化部分引导位置
- const driverInitialPosition = (popover: PopoverDOM, options: { config: Config; state: State }, position = 1) => {
- options.config.stageRadius = 12;
- options.config.stagePadding = 0;
- try {
- const rect = options.state.activeElement?.getBoundingClientRect();
- popover.wrapper.style.marginLeft = -(rect?.width || 0) / 2 + 34 + "px";
- } catch {}
- };
- // 判断是否为打击乐
- let steps: DriveStep[] = [];
- if (state.isPercussion) {
- if (props.videoFilePath) {
- steps = [
- {
- element: ".evaluting-report-2",
- popover: {
- title: "",
- description: "",
- popoverClass: "popoverClass popoverClassReport2",
- align: "end",
- side: "bottom",
- nextBtnText: "下一步 (1/2)",
- showButtons: ["next"],
- onPopoverRender: (popover: PopoverDOM, options: { config: Config; state: State }) => {
- options.config.stageRadius = 12;
- options.config.stagePadding = 0;
- try {
- const rect = options.state.activeElement?.getBoundingClientRect();
- popover.wrapper.style.marginLeft = ((rect?.width || 0) / 2) * -1 + 34 + "px";
- } catch {}
- },
- },
- },
- {
- element: ".evaluting-report-4",
- popover: {
- title: "",
- description: "",
- popoverClass: "popoverClass popoverClassReport4 popoverClose",
- align: "end",
- side: "bottom",
- prevBtnText: "再看一遍",
- doneBtnText: "完成",
- showButtons: ["next", "previous"],
- onPopoverRender: (popover: PopoverDOM, options: { config: Config; state: State }) => {
- options.config.stageRadius = 8;
- options.config.stagePadding = 5;
- try {
- const rect = options.state.activeElement?.getBoundingClientRect();
- popover.wrapper.style.marginLeft = ((rect?.width || 0) / 2) * -1 + 34 + "px";
- } catch {}
- },
- onPrevClick: () => {
- driverObj.drive(0);
- },
- onNextClick: () => {
- onDriverClose();
- },
- },
- },
- ];
- } else {
- steps = [
- {
- element: ".evaluting-report-2",
- popover: {
- title: "",
- description: "",
- popoverClass: "popoverClass popoverClassReport2 popoverClose",
- align: "end",
- side: "bottom",
- doneBtnText: "完成",
- showButtons: ["next"],
- onPopoverRender: (popover: PopoverDOM, options: { config: Config; state: State }) => {
- options.config.stageRadius = 12;
- options.config.stagePadding = 0;
- try {
- const rect = options.state.activeElement?.getBoundingClientRect();
- popover.wrapper.style.marginLeft = ((rect?.width || 0) / 2) * -1 + 34 + "px";
- } catch {}
- },
- onPrevClick: () => {
- driverObj.drive(0);
- },
- onNextClick: () => {
- onDriverClose();
- },
- },
- },
- ];
- }
- } else {
- const count = props.videoFilePath ? 4 : 3;
- steps = [
- {
- element: ".evaluting-report-1",
- popover: {
- title: "",
- description: "",
- popoverClass: "popoverClass popoverClassReport1",
- align: "end",
- side: "bottom",
- nextBtnText: `下一步 (1/${count})`,
- showButtons: ["next"],
- onPopoverRender: (popover: PopoverDOM, options: { config: Config; state: State }) => {
- driverInitialPosition(popover, options);
- },
- },
- },
- {
- element: ".evaluting-report-2",
- popover: {
- title: "",
- description: "",
- popoverClass: "popoverClass popoverClassReport2",
- align: "end",
- side: "bottom",
- nextBtnText: `下一步 (2/${count})`,
- showButtons: ["next"],
- onPopoverRender: (popover: PopoverDOM, options: { config: Config; state: State }) => {
- options.config.stageRadius = 12;
- options.config.stagePadding = 0;
- try {
- const rect = options.state.activeElement?.getBoundingClientRect();
- popover.wrapper.style.marginLeft = ((rect?.width || 0) / 2) * -1 + 34 + "px";
- } catch {}
- },
- },
- },
- ];
- if (props.videoFilePath) {
- steps.push(
- {
- element: ".evaluting-report-3",
- popover: {
- title: "",
- description: "",
- popoverClass: "popoverClass popoverClassReport3",
- align: "end",
- side: "bottom",
- nextBtnText: "下一步 (3/4)",
- showButtons: ["next"],
- onPopoverRender: (popover: PopoverDOM, options: { config: Config; state: State }) => {
- // driverInitialPosition(popover, options, -1);
- options.config.stageRadius = 12;
- options.config.stagePadding = 0;
- try {
- const rect = options.state.activeElement?.getBoundingClientRect();
- popover.wrapper.style.marginLeft = ((rect?.width || 0) / 2) * -1 + 34 + "px";
- } catch {}
- },
- },
- },
- {
- element: ".evaluting-report-4",
- popover: {
- title: "",
- description: "",
- popoverClass: "popoverClass popoverClassReport4 popoverClose",
- align: "end",
- side: "bottom",
- prevBtnText: "再看一遍",
- doneBtnText: "完成",
- showButtons: ["next", "previous"],
- onPopoverRender: (popover: PopoverDOM, options: { config: Config; state: State }) => {
- options.config.stageRadius = 8;
- options.config.stagePadding = 5;
- try {
- const rect = options.state.activeElement?.getBoundingClientRect();
- popover.wrapper.style.marginLeft = ((rect?.width || 0) / 2) * -1 + 34 + "px";
- } catch {}
- },
- onPrevClick: () => {
- driverObj.drive(0);
- },
- onNextClick: () => {
- onDriverClose();
- },
- },
- }
- );
- } else {
- steps.push({
- element: ".evaluting-report-3",
- popover: {
- title: "",
- description: "",
- popoverClass: "popoverClass popoverClassReport3 popoverClose",
- align: "start",
- side: "bottom",
- prevBtnText: "再看一遍",
- doneBtnText: "完成",
- showButtons: ["next", "previous"],
- onPopoverRender: (popover: PopoverDOM, options: { config: Config; state: State }) => {
- driverInitialPosition(popover, options);
- },
- onPrevClick: () => {
- driverObj.drive(0);
- },
- onNextClick: () => {
- onDriverClose();
- },
- },
- });
- }
- }
- const driverOptions: Config = {
- showProgress: false,
- allowClose: false,
- popoverOffset: 3,
- disableActiveInteraction: true,
- onCloseClick: () => {
- onDriverClose();
- },
- onHighlightStarted: () => {
- driverNextStatus.value = true;
- },
- onHighlighted: () => {
- driverNextStatus.value = false;
- },
- steps: steps,
- };
- let driverObj: any;
- const guideInfo = ref({} as any);
- const handleClickOutside = (event: any) => {
- if (driverNextStatus.value) return;
- if (driverObj.isActive() && (event.target.nodeName === "path" || event.target.classList.contains("driver-popover") || event.target.classList.contains("driver-overlay"))) {
- if (driverObj.isLastStep()) {
- onDriverClose();
- } else {
- driverObj.moveNext(); // 跳转到下一步
- }
- }
- };
- const showCloseBtn = ref(false);
- const getAllGuidance = async () => {
- try {
- const res = localStorage.getItem("guideInfo");
- if (res) {
- guideInfo.value = JSON.parse(res) || null;
- } else {
- guideInfo.value = {};
- }
- if (!(guideInfo.value && guideInfo.value.evaluatingReportDriver)) {
- // 监听点击事件以实现点击空白区域跳转到下一步
- document.addEventListener("click", handleClickOutside, true);
- nextTick(() => {
- driverObj = driver(driverOptions);
- driverObj.drive();
- state.hasDriverPop = true;
- showCloseBtn.value = true;
- });
- }
- } catch (e) {
- console.log(e);
- }
- };
- getAllGuidance();
- // 结束关闭弹窗
- const onDriverClose = () => {
- if (!guideInfo.value) {
- guideInfo.value = { evaluatingReportDriver: true };
- } else {
- guideInfo.value.evaluatingReportDriver = true;
- }
- endGuide(guideInfo.value);
- driverObj.destroy();
- document.querySelector(".driver-popover-close-btn-custom")?.remove();
- document.removeEventListener("click", handleClickOutside, true);
- state.hasDriverPop = false;
- };
- onUnmounted(() => {
- document.removeEventListener("click", handleClickOutside, true);
- });
- return () => (
- <Teleport to="body">
- {showCloseBtn.value && (
- <div
- class="driver-popover-close-btn-custom"
- onClick={(e: any) => {
- onDriverClose();
- }}
- ></div>
- )}
- </Teleport>
- );
- },
- });
|