From fed74703f4f96589ab669f92a2e5134ec7205810 Mon Sep 17 00:00:00 2001 From: Composure Date: Wed, 22 Feb 2023 09:47:58 +0800 Subject: [PATCH 1/3] test: tsx --- src/views/testPage/filpper.tsx | 93 ++++++++++++++++++++++++++++++++++ 1 file changed, 93 insertions(+) create mode 100644 src/views/testPage/filpper.tsx diff --git a/src/views/testPage/filpper.tsx b/src/views/testPage/filpper.tsx new file mode 100644 index 0000000..77f6cfc --- /dev/null +++ b/src/views/testPage/filpper.tsx @@ -0,0 +1,93 @@ +import { defineComponent, ref } from "vue"; +import { propTypes } from "@/utils/propTypes"; +import "./filpper.css"; + +const props = { + // front paper text + // 前牌文字 + frontText: propTypes.number.def(0), + // back paper text + // 后牌文字 + backText: propTypes.number.def(1), + // flipping duration, please be consistent with the CSS animation-duration value. + // 翻牌动画时间,与CSS中设置的animation-duration保持一致 + duration: propTypes.number.def(600) +}; + +export default defineComponent({ + name: "ReFlop", + props, + setup(props) { + // eslint-disable-next-line vue/no-setup-props-destructure + const { frontText, backText, duration } = props; + const isFlipping = ref(false); + const flipType = ref("down"); + const frontTextFromData = ref(frontText); + const backTextFromData = ref(backText); + + const textClass = (number: number) => { + return "number" + number; + }; + + const flip = (type: string, front: number, back: number) => { + // 如果处于翻转中,则不执行 + if (isFlipping.value) return false; + frontTextFromData.value = front; + backTextFromData.value = back; + // 根据传递过来的type设置翻转方向 + flipType.value = type; + // 设置翻转状态为true + isFlipping.value = true; + + setTimeout(() => { + // 设置翻转状态为false + isFlipping.value = false; + frontTextFromData.value = back; + }, duration); + }; + + // 下翻牌 + const flipDown = (front: any, back: any): void => { + flip("down", front, back); + }; + + // 上翻牌 + const flipUp = (front: any, back: any): void => { + flip("up", front, back); + }; + + // 设置前牌文字 + function setFront(text: number): void { + frontTextFromData.value = text; + } + + // 设置后牌文字 + const setBack = (text: number): void => { + backTextFromData.value = text; + }; + + return { + flipType, + isFlipping, + frontTextFromData, + backTextFromData, + textClass, + flipDown, + flipUp, + setFront, + setBack + }; + }, + + render() { + const main = `m-flipper ${this.flipType} ${this.isFlipping ? "go" : ""}`; + const front = `digital front ${this.textClass(this.frontTextFromData)}`; + const back = `digital back ${this.textClass(this.backTextFromData)}`; + return ( +
+
+
+
+ ); + } +}); From 33c0ee8f4ff83059623002f27b77f916bd25a441 Mon Sep 17 00:00:00 2001 From: Composure Date: Fri, 24 Feb 2023 20:50:27 +0800 Subject: [PATCH 2/3] test: tsx --- .vscode/launch.json | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 .vscode/launch.json diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 0000000..b2a7bfc --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,15 @@ +{ + // 使用 IntelliSense 了解相关属性。 + // 悬停以查看现有属性的描述。 + // 欲了解更多信息,请访问: https://go.microsoft.com/fwlink/?linkid=830387 + "version": "0.2.0", + "configurations": [ + { + "type": "chrome", + "request": "launch", + "name": "Launch Chrome against localhost", + "url": "http://localhost:8848", + "webRoot": "${workspaceFolder}" + } + ] +} From f318cbaa9be92f27047250099ba47ebeffd59238 Mon Sep 17 00:00:00 2001 From: Composure Date: Fri, 24 Feb 2023 20:50:45 +0800 Subject: [PATCH 3/3] test: tsx --- src/router/modules/test.ts | 5 ++--- src/views/testPage/Countdown.vue | 32 ++++++++++++++++++++------------ src/views/testPage/Flippers.vue | 28 +++++++++++++++++++++++++--- 3 files changed, 47 insertions(+), 18 deletions(-) diff --git a/src/router/modules/test.ts b/src/router/modules/test.ts index 543ae63..065453d 100644 --- a/src/router/modules/test.ts +++ b/src/router/modules/test.ts @@ -1,6 +1,6 @@ export default { path: "/test", - redirect: "/test/403", + redirect: "/test/countdown", meta: { icon: "material-symbols:import-contacts-outline", title: "测试页面" @@ -11,8 +11,7 @@ export default { name: "Countdown", component: () => import("@/views/testPage/Countdown.vue"), meta: { - title: "倒计时", - keepAlive: false + title: "倒计时" } } ] diff --git a/src/views/testPage/Countdown.vue b/src/views/testPage/Countdown.vue index 1a82350..5566c38 100644 --- a/src/views/testPage/Countdown.vue +++ b/src/views/testPage/Countdown.vue @@ -1,21 +1,19 @@ diff --git a/src/views/testPage/Flippers.vue b/src/views/testPage/Flippers.vue index 705f667..8458fe8 100644 --- a/src/views/testPage/Flippers.vue +++ b/src/views/testPage/Flippers.vue @@ -1,11 +1,30 @@