diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index c9cda78..7aa8dd3 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -29,6 +29,9 @@ importers: localforage: specifier: ^1.10.0 version: 1.10.0 + lodash-es: + specifier: ^4.17.21 + version: 4.17.21 markdown-it: specifier: ^14.1.0 version: 14.1.0 diff --git a/src/utils/index.ts b/src/utils/index.ts index 0e714f0..046d246 100644 --- a/src/utils/index.ts +++ b/src/utils/index.ts @@ -1,50 +1,56 @@ import dayjs from 'dayjs' -// 筛选人员数据 -export function filterData(tableData: any[], localRowCount: number) { - const dataLength = tableData.length - let j = 0 - for (let i = 0; i < dataLength; i++) { - if (i % localRowCount === 0) { - j++ - } - tableData[i].x = i % localRowCount + 1 - tableData[i].y = j - tableData[i].id = i - // 是否中奖 - } - return tableData +/** + * @description: 处理表格数据,添加x,y,id等信息 + * @param tableData 表格数据 + * @param localRowCount 每一行有多少个元素 + * @returns 处理后的表格数据 + */ +export function filterData(tableData: any[], localRowCount: number) { + const dataLength = tableData.length + let j = 0 + for (let i = 0; i < dataLength; i++) { + if (i % localRowCount === 0) { + j++ + } + tableData[i].x = i % localRowCount + 1 + tableData[i].y = j + tableData[i].id = i + // 是否中奖 + } + + return tableData } export function addOtherInfo(personList: any[]) { - const len = personList.length - for (let i = 0; i < len; i++) { - personList[i].id = i - personList[i].createTime = dayjs(new Date()).format('YYYY-MM-DD HH:mm:ss') - personList[i].updateTime = dayjs(new Date()).format('YYYY-MM-DD HH:mm:ss') - personList[i].prizeName = [] as string[] - personList[i].prizeTime = [] as string[] - personList[i].prizeId = [] - personList[i].isWin = false - } + const len = personList.length + for (let i = 0; i < len; i++) { + personList[i].id = i + personList[i].createTime = dayjs(new Date()).format('YYYY-MM-DD HH:mm:ss') + personList[i].updateTime = dayjs(new Date()).format('YYYY-MM-DD HH:mm:ss') + personList[i].prizeName = [] as string[] + personList[i].prizeTime = [] as string[] + personList[i].prizeId = [] + personList[i].isWin = false + } - return personList + return personList } export function selectCard(cardIndexArr: number[], tableLength: number, personId: number): number { - const cardIndex = Math.floor(Math.random() * (tableLength - 1)) - if (cardIndexArr.includes(cardIndex)) { - return selectCard(cardIndexArr, tableLength, personId) - } + const cardIndex = Math.floor(Math.random() * (tableLength - 1)) + if (cardIndexArr.includes(cardIndex)) { + return selectCard(cardIndexArr, tableLength, personId) + } - return cardIndex + return cardIndex } export function themeChange(theme: string) { - // 获取根html - const html = document.querySelectorAll('html') - if (html) { - html[0].setAttribute('data-theme', theme) - localStorage.setItem('theme', theme) - } + // 获取根html + const html = document.querySelectorAll('html') + if (html) { + html[0].setAttribute('data-theme', theme) + localStorage.setItem('theme', theme) + } } diff --git a/src/views/Home/components/PrizeList/index.scss b/src/views/Home/components/PrizeList/index.scss new file mode 100644 index 0000000..1d63d31 --- /dev/null +++ b/src/views/Home/components/PrizeList/index.scss @@ -0,0 +1,138 @@ +.label { + width: 120px; +} + +.prize-list-enter-active { + -webkit-animation: slide-right 0.5s cubic-bezier(0.250, 0.460, 0.450, 0.940) both; + animation: slide-right 0.5s cubic-bezier(0.250, 0.460, 0.450, 0.940) both; +} + +.prize-list-leave-active { + -webkit-animation: slide-left 0.5s cubic-bezier(0.250, 0.460, 0.450, 0.940) both; + animation: slide-left 0.5s cubic-bezier(0.250, 0.460, 0.450, 0.940) both; +} + +.prize-operate-enter-active { + // 延时显示 + animation: show-operate 0.6s; + -webkit-animation: show-operate 0.6s; +} + +.current-prize { + position: relative; + display: block; + overflow: hidden; + isolation: isolate; + + border-radius: 20px; + padding: 3px; +} + +.current-prize::before { + content: ""; + position: absolute; + top: 0; + left: 0; + width: 400%; + height: 100%; + background: linear-gradient(115deg, #4fcf70, #fad648, #a767e5, #12bcfe, #44ce7b); + background-size: 25% 100%; + animation: an-at-keyframe-css-at-rule-that-translates-via-the-transform-property-the-background-by-negative-25-percent-of-its-width-so-that-it-gives-a-nice-border-animation_-We-use-the-translate-property-to-have-a-nice-transition-so-it_s-not-a-jerk-of-a-start-or-stop .75s linear infinite; + // animation-play-state: paused; + translate: -5% 0%; + transition: translate 0.25s ease-out; + animation-play-state: running; + transition-duration: 0.75s; + translate: 0% 0%; +} + +.current-prize::after { + content: ""; + position: absolute; + inset: 4px; + border-top-left-radius: 20px; + border-bottom-right-radius: 20px; + z-index: -1; +} + +@keyframes an-at-keyframe-css-at-rule-that-translates-via-the-transform-property-the-background-by-negative-25-percent-of-its-width-so-that-it-gives-a-nice-border-animation_-We-use-the-translate-property-to-have-a-nice-transition-so-it_s-not-a-jerk-of-a-start-or-stop { + to { + transform: translateX(-25%); + } +} + +@-webkit-keyframes slide-right { + 0% { + -webkit-transform: translateX(0); + transform: translateX(0); + } + + 100% { + -webkit-transform: translateX(30px); + transform: translateX(30px); + } +} + +@keyframes slide-right { + 0% { + -webkit-transform: translateX(-200px); + transform: translateX(-200px); + } + + 100% { + -webkit-transform: translateX(0); + transform: translateX(0); + } +} + +@-webkit-keyframes slide-left { + 0% { + -webkit-transform: translateX(0); + transform: translateX(0); + } + + 100% { + -webkit-transform: translateX(-100px); + transform: translateX(-100px); + } +} + +@keyframes slide-left { + 0% { + -webkit-transform: translateX(0); + transform: translateX(0); + } + + 100% { + -webkit-transform: translateX(-400px); + transform: translateX(-400px); + } +} + +@-webkit-keyframes show-operate { + 0% { + opacity: 0; + } + + 99% { + opacity: 0; + } + + 100% { + opacity: 1; + } +} + +@keyframes show-operate { + 0% { + opacity: 0; + } + + 99% { + opacity: 0; + } + + 100% { + opacity: 1; + } +} \ No newline at end of file diff --git a/src/views/Home/PrizeList.vue b/src/views/Home/components/PrizeList/index.vue similarity index 80% rename from src/views/Home/PrizeList.vue rename to src/views/Home/components/PrizeList/index.vue index ea9cfcd..ac745aa 100644 --- a/src/views/Home/PrizeList.vue +++ b/src/views/Home/components/PrizeList/index.vue @@ -1,17 +1,17 @@