|
@@ -1,5 +1,5 @@
|
|
|
import { defineComponent, nextTick, ref } from "vue";
|
|
|
-import { Config, PopoverDOM, State, driver } from "driver.js";
|
|
|
+import { Config, DriveStep, PopoverDOM, State, driver } from "driver.js";
|
|
|
import "driver.js/dist/driver.css";
|
|
|
import state from "/src/state";
|
|
|
import { getGuidance, setGuidance } from "../guide-page/api";
|
|
@@ -12,8 +12,9 @@ const endGuide = (guideInfo: any) => {
|
|
|
}
|
|
|
};
|
|
|
|
|
|
+/** 练习模式 */
|
|
|
export const PractiseDriver = defineComponent({
|
|
|
- name: "practise-driver",
|
|
|
+ name: "PractiseDriver",
|
|
|
setup() {
|
|
|
// 初始化部分引导位置
|
|
|
const driverInitialPosition = (popover: PopoverDOM, options: { config: Config; state: State }) => {
|
|
@@ -25,11 +26,30 @@ export const PractiseDriver = defineComponent({
|
|
|
} catch {}
|
|
|
};
|
|
|
|
|
|
+ // 乐器方向不一样引导位置不一样
|
|
|
+ const instrumentDirection: DriveStep = {
|
|
|
+ element: ".driver-7",
|
|
|
+ popover: {
|
|
|
+ title: "",
|
|
|
+ description: "",
|
|
|
+ popoverClass: `popoverClass ${state.fingeringInfo.direction === "transverse" ? "popoverClass7" : "popoverClass7-1"}`,
|
|
|
+ align: state.fingeringInfo.direction === "transverse" ? "start" : "center",
|
|
|
+ side: state.fingeringInfo.direction === "transverse" ? "top" : "left",
|
|
|
+ nextBtnText: "下一步7/9",
|
|
|
+ showButtons: ["next", "close"],
|
|
|
+ onPopoverRender: (popover: PopoverDOM, options: { config: Config; state: State }) => {
|
|
|
+ if (state.fingeringInfo.direction === "transverse") driverInitialPosition(popover, options);
|
|
|
+ },
|
|
|
+ onCloseClick: () => {
|
|
|
+ onDriverClose();
|
|
|
+ },
|
|
|
+ },
|
|
|
+ };
|
|
|
+
|
|
|
const driverObj = driver({
|
|
|
showProgress: false,
|
|
|
allowClose: false,
|
|
|
popoverOffset: 3,
|
|
|
- // stageRadius: 1000,
|
|
|
disableActiveInteraction: true,
|
|
|
steps: [
|
|
|
{
|
|
@@ -141,24 +161,7 @@ export const PractiseDriver = defineComponent({
|
|
|
},
|
|
|
},
|
|
|
},
|
|
|
- {
|
|
|
- element: ".driver-7",
|
|
|
- popover: {
|
|
|
- title: "",
|
|
|
- description: "",
|
|
|
- popoverClass: "popoverClass popoverClass7",
|
|
|
- align: "start",
|
|
|
- side: "top",
|
|
|
- nextBtnText: "下一步7/9",
|
|
|
- showButtons: ["next", "close"],
|
|
|
- onPopoverRender: (popover: PopoverDOM, options: { config: Config; state: State }) => {
|
|
|
- driverInitialPosition(popover, options);
|
|
|
- },
|
|
|
- onCloseClick: () => {
|
|
|
- onDriverClose();
|
|
|
- },
|
|
|
- },
|
|
|
- },
|
|
|
+ instrumentDirection,
|
|
|
{
|
|
|
element: ".driver-8",
|
|
|
popover: {
|
|
@@ -174,7 +177,7 @@ export const PractiseDriver = defineComponent({
|
|
|
options.config.stagePadding = 0;
|
|
|
try {
|
|
|
const rect = options.state.activeElement?.getBoundingClientRect();
|
|
|
- popover.wrapper.style.marginLeft = (rect?.width || 0) / 2 - 8 + "px";
|
|
|
+ popover.wrapper.style.marginLeft = (rect?.width || 0) / 2 - 4 + "px";
|
|
|
} catch {}
|
|
|
},
|
|
|
onCloseClick: () => {
|
|
@@ -187,10 +190,10 @@ export const PractiseDriver = defineComponent({
|
|
|
popover: {
|
|
|
title: "",
|
|
|
description: "",
|
|
|
- popoverClass: "popoverClass popoverClass9",
|
|
|
+ popoverClass: "popoverClass popoverClass9 popoverClose",
|
|
|
align: "end",
|
|
|
side: "bottom",
|
|
|
- prevBtnText: "在看一遍",
|
|
|
+ prevBtnText: "再看一遍",
|
|
|
doneBtnText: "完成",
|
|
|
showButtons: ["next", "previous", "close"],
|
|
|
onPopoverRender: (popover: PopoverDOM, options: { config: Config; state: State }) => {
|
|
@@ -201,7 +204,7 @@ export const PractiseDriver = defineComponent({
|
|
|
popover.wrapper.style.marginLeft = -((rect?.width || 0) / 2 - 8) + "px";
|
|
|
} catch {}
|
|
|
},
|
|
|
- onPrevClick: (element, step, options) => {
|
|
|
+ onPrevClick: () => {
|
|
|
driverObj.drive(0);
|
|
|
},
|
|
|
onNextClick: () => {
|
|
@@ -215,13 +218,6 @@ export const PractiseDriver = defineComponent({
|
|
|
],
|
|
|
});
|
|
|
|
|
|
- // watch(
|
|
|
- // () => state.audioDone,
|
|
|
- // () => {
|
|
|
- // driverObj.drive(0);
|
|
|
- // }
|
|
|
- // );
|
|
|
-
|
|
|
const guideInfo = ref({} as any);
|
|
|
const getAllGuidance = async () => {
|
|
|
try {
|
|
@@ -237,7 +233,7 @@ export const PractiseDriver = defineComponent({
|
|
|
}
|
|
|
if (!(guideInfo.value && guideInfo.value.practiseDriver)) {
|
|
|
nextTick(() => {
|
|
|
- driverObj.drive(7);
|
|
|
+ driverObj.drive(5);
|
|
|
});
|
|
|
}
|
|
|
} catch (e) {
|
|
@@ -261,3 +257,253 @@ export const PractiseDriver = defineComponent({
|
|
|
return () => <div></div>;
|
|
|
},
|
|
|
});
|
|
|
+
|
|
|
+/** 跟练模式 */
|
|
|
+export const FollowDriver = defineComponent({
|
|
|
+ name: "FollowDriver",
|
|
|
+ setup() {
|
|
|
+ // 初始化部分引导位置
|
|
|
+ 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 driverObj = driver({
|
|
|
+ showProgress: false,
|
|
|
+ allowClose: false,
|
|
|
+ popoverOffset: 3,
|
|
|
+ disableActiveInteraction: true,
|
|
|
+ steps: [
|
|
|
+ {
|
|
|
+ element: ".follow-1",
|
|
|
+ popover: {
|
|
|
+ title: "",
|
|
|
+ description: "",
|
|
|
+ popoverClass: "popoverClass popoverClass1",
|
|
|
+ align: "end",
|
|
|
+ side: "top",
|
|
|
+ nextBtnText: "下一步1/3",
|
|
|
+ showButtons: ["next", "close"],
|
|
|
+ onPopoverRender: (popover: PopoverDOM, options: { config: Config; state: State }) => {
|
|
|
+ options.config.stageRadius = 1000;
|
|
|
+ options.config.stagePadding = 0;
|
|
|
+ },
|
|
|
+ onCloseClick: () => {
|
|
|
+ onDriverClose();
|
|
|
+ },
|
|
|
+ },
|
|
|
+ },
|
|
|
+ {
|
|
|
+ element: ".driver-5",
|
|
|
+ popover: {
|
|
|
+ title: "",
|
|
|
+ description: "",
|
|
|
+ popoverClass: "popoverClass popoverClass5",
|
|
|
+ align: "start",
|
|
|
+ side: "top",
|
|
|
+ nextBtnText: "下一步2/3",
|
|
|
+ showButtons: ["next", "close"],
|
|
|
+ onPopoverRender: (popover: PopoverDOM, options: { config: Config; state: State }) => {
|
|
|
+ driverInitialPosition(popover, options);
|
|
|
+ },
|
|
|
+ onCloseClick: () => {
|
|
|
+ onDriverClose();
|
|
|
+ },
|
|
|
+ },
|
|
|
+ },
|
|
|
+ {
|
|
|
+ element: ".driver-6",
|
|
|
+ popover: {
|
|
|
+ title: "",
|
|
|
+ description: "",
|
|
|
+ popoverClass: "popoverClass popoverClass6 popoverClose",
|
|
|
+ align: "start",
|
|
|
+ side: "top",
|
|
|
+ prevBtnText: "再看一遍",
|
|
|
+ doneBtnText: "完成",
|
|
|
+ showButtons: ["next", "previous", "close"],
|
|
|
+ onPopoverRender: (popover: PopoverDOM, options: { config: Config; state: State }) => {
|
|
|
+ driverInitialPosition(popover, options);
|
|
|
+ },
|
|
|
+ onPrevClick: () => {
|
|
|
+ driverObj.drive(0);
|
|
|
+ },
|
|
|
+ onNextClick: () => {
|
|
|
+ onDriverClose();
|
|
|
+ },
|
|
|
+ onCloseClick: () => {
|
|
|
+ onDriverClose();
|
|
|
+ },
|
|
|
+ },
|
|
|
+ },
|
|
|
+ ],
|
|
|
+ });
|
|
|
+
|
|
|
+ const guideInfo = ref({} as any);
|
|
|
+ const getAllGuidance = async () => {
|
|
|
+ try {
|
|
|
+ if (state.guideInfo) {
|
|
|
+ guideInfo.value = state.guideInfo;
|
|
|
+ } else {
|
|
|
+ const res = await getGuidance({ guideTag: "guideInfo" });
|
|
|
+ if (res.data) {
|
|
|
+ guideInfo.value = JSON.parse(res.data?.guideValue) || null;
|
|
|
+ } else {
|
|
|
+ guideInfo.value = {};
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (!(guideInfo.value && guideInfo.value.followDriver)) {
|
|
|
+ nextTick(() => {
|
|
|
+ driverObj.drive(0);
|
|
|
+ });
|
|
|
+ }
|
|
|
+ } 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();
|
|
|
+ };
|
|
|
+
|
|
|
+ return () => <div></div>;
|
|
|
+ },
|
|
|
+});
|
|
|
+
|
|
|
+// 评测模式
|
|
|
+export const EvaluatingDriver = defineComponent({
|
|
|
+ name: "EvaluatingDriver",
|
|
|
+ setup() {
|
|
|
+ // 初始化部分引导位置
|
|
|
+ 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 driverObj = driver({
|
|
|
+ showProgress: false,
|
|
|
+ allowClose: false,
|
|
|
+ popoverOffset: 3,
|
|
|
+ disableActiveInteraction: true,
|
|
|
+ steps: [
|
|
|
+ {
|
|
|
+ element: ".follow-1",
|
|
|
+ popover: {
|
|
|
+ title: "",
|
|
|
+ description: "",
|
|
|
+ popoverClass: "popoverClass popoverClass1",
|
|
|
+ align: "end",
|
|
|
+ side: "top",
|
|
|
+ nextBtnText: "下一步1/3",
|
|
|
+ showButtons: ["next", "close"],
|
|
|
+ onPopoverRender: (popover: PopoverDOM, options: { config: Config; state: State }) => {
|
|
|
+ options.config.stageRadius = 1000;
|
|
|
+ options.config.stagePadding = 0;
|
|
|
+ },
|
|
|
+ onCloseClick: () => {
|
|
|
+ onDriverClose();
|
|
|
+ },
|
|
|
+ },
|
|
|
+ },
|
|
|
+ {
|
|
|
+ element: ".driver-5",
|
|
|
+ popover: {
|
|
|
+ title: "",
|
|
|
+ description: "",
|
|
|
+ popoverClass: "popoverClass popoverClass5",
|
|
|
+ align: "start",
|
|
|
+ side: "top",
|
|
|
+ nextBtnText: "下一步2/3",
|
|
|
+ showButtons: ["next", "close"],
|
|
|
+ onPopoverRender: (popover: PopoverDOM, options: { config: Config; state: State }) => {
|
|
|
+ driverInitialPosition(popover, options);
|
|
|
+ },
|
|
|
+ onCloseClick: () => {
|
|
|
+ onDriverClose();
|
|
|
+ },
|
|
|
+ },
|
|
|
+ },
|
|
|
+ {
|
|
|
+ element: ".driver-6",
|
|
|
+ popover: {
|
|
|
+ title: "",
|
|
|
+ description: "",
|
|
|
+ popoverClass: "popoverClass popoverClass6 popoverClose",
|
|
|
+ align: "start",
|
|
|
+ side: "top",
|
|
|
+ prevBtnText: "再看一遍",
|
|
|
+ doneBtnText: "完成",
|
|
|
+ showButtons: ["next", "previous", "close"],
|
|
|
+ onPopoverRender: (popover: PopoverDOM, options: { config: Config; state: State }) => {
|
|
|
+ driverInitialPosition(popover, options);
|
|
|
+ },
|
|
|
+ onPrevClick: () => {
|
|
|
+ driverObj.drive(0);
|
|
|
+ },
|
|
|
+ onNextClick: () => {
|
|
|
+ onDriverClose();
|
|
|
+ },
|
|
|
+ onCloseClick: () => {
|
|
|
+ onDriverClose();
|
|
|
+ },
|
|
|
+ },
|
|
|
+ },
|
|
|
+ ],
|
|
|
+ });
|
|
|
+
|
|
|
+ const guideInfo = ref({} as any);
|
|
|
+ const getAllGuidance = async () => {
|
|
|
+ try {
|
|
|
+ if (state.guideInfo) {
|
|
|
+ guideInfo.value = state.guideInfo;
|
|
|
+ } else {
|
|
|
+ const res = await getGuidance({ guideTag: "guideInfo" });
|
|
|
+ if (res.data) {
|
|
|
+ guideInfo.value = JSON.parse(res.data?.guideValue) || null;
|
|
|
+ } else {
|
|
|
+ guideInfo.value = {};
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (!(guideInfo.value && guideInfo.value.followDriver)) {
|
|
|
+ nextTick(() => {
|
|
|
+ driverObj.drive(0);
|
|
|
+ });
|
|
|
+ }
|
|
|
+ } 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();
|
|
|
+ };
|
|
|
+
|
|
|
+ return () => <div></div>;
|
|
|
+ },
|
|
|
+});
|