generated from diego3g/electron-typescript-react
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3ef20cb
commit e703569
Showing
12 changed files
with
193 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
{"randomType":1,"names":["test1","test2","test3","test4"],"date":1111111111111,"cardType":{"number1":"13","number2":8,"number3":6,"number4":4,"number5":2},"noSpecial":true} | ||
{"randomType":1,"names":["test1","test2","test3","test4"],"date":1655942400000,"cardType":{"number1":"13","number2":8,"number3":6,"number4":4,"number5":2},"noSpecial":true,"transparent":false} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
import { useState, useEffect } from 'react' | ||
import './style.css' | ||
|
||
export function Calendar2() { | ||
const [date, setDate] = useState(window.Main.getConfigData().date) | ||
const [transparent, setTransparent] = useState(window.Main.getConfigData().transparent) | ||
const [left, setLeft] = useState({day: "942", hour: "22", minute: "45", second: "56"}) | ||
const [trigger, setTrigger] = useState(false) | ||
|
||
function toggleTrigger() { | ||
setTrigger(!trigger) | ||
} | ||
|
||
function getNowDate() { | ||
const nowDate = new Date(window.Main.getConfigData().date) | ||
return `${nowDate.getFullYear()}年${getLengthChar(2, nowDate.getMonth() + 1)}月${getLengthChar(2, nowDate.getDate())}日` | ||
} | ||
|
||
function getLengthChar(length: number, char: number) { | ||
if (char < 0) { | ||
if (length < char.toString().length - 1) { | ||
return char.toString() | ||
} | ||
let _result = "-" | ||
for (let i = 0;i < length - (char.toString().length - 1);i++) { | ||
_result += "0" | ||
} | ||
_result += char.toString().substring(1) | ||
return _result | ||
} else { | ||
if (length < char.toString().length) { | ||
return char.toString() | ||
} | ||
let _result = "" | ||
for (let i = 0;i < length - char.toString().length;i++) { | ||
_result += "0" | ||
} | ||
_result += char.toString() | ||
return _result | ||
} | ||
} | ||
|
||
useEffect(() => { | ||
let date1 = new Date(date); //开始时间 | ||
let date2 = new Date(); //结束时间 | ||
let date3 = date2.getTime() - date1.getTime(); //时间差的毫秒数 | ||
|
||
// 计算相差天数 | ||
let days = Math.floor(date3 / (24 * 3600 * 1000)) | ||
let leave1 = date3 % (24 * 3600 * 1000) //计算天数后剩余的毫秒数 | ||
let hours = Math.floor(leave1 / (3600*1000)) | ||
//计算相差分钟数 | ||
let leave2 = leave1%(3600*1000) //计算小时数后剩余的毫秒数 | ||
let minutes = Math.floor(leave2 / (60*1000)) | ||
//计算相差秒数 | ||
let leave3 = leave2 % (60 * 1000) //计算分钟数后剩余的毫秒数 | ||
let seconds = Math.round(leave3 / 1000) | ||
|
||
console.log(-days, -hours, -minutes, -seconds) | ||
|
||
setLeft({ | ||
day: getLengthChar(3, -days), | ||
hour: getLengthChar(2, -hours), | ||
minute: getLengthChar(2, -minutes), | ||
second: getLengthChar(2, -seconds) | ||
}) | ||
setTimeout(toggleTrigger, 1000) | ||
}, [trigger]) | ||
|
||
return ( | ||
<div className={transparent ? "transparent-calendar2" : "calendar2"}> | ||
<p>倒计时:<span className="day">{left.day}</span>天<span className="hour">{left.hour}</span>时<span className="minute">{left.minute}</span>分<span className="second">{left.second}</span>秒</p> | ||
</div> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
|
||
body { | ||
padding: 0; | ||
margin: 0; | ||
} | ||
|
||
.transparent-calendar2 { | ||
-webkit-app-region: drag; | ||
user-select: none; | ||
} | ||
|
||
.calendar2 { | ||
user-select: none; | ||
width: calc(100% - 40px); | ||
height: calc(100vh - 30px); | ||
-webkit-app-region: drag; | ||
overflow: hidden; | ||
background-color: #31574f; | ||
border: 15px solid #d3b78e; | ||
padding-left: 10px; | ||
/* padding-right: 10px; */ | ||
} | ||
|
||
.calendar2 p { | ||
color: white; | ||
font-size: 1.2rem; | ||
} | ||
|
||
.transparent-calendar2 p { | ||
color: black; | ||
font-size: 1.2rem; | ||
} | ||
|
||
.calendar2 p span, .transparent-calendar2 p span { | ||
color: red; | ||
background-color: white; | ||
padding: 2px; | ||
margin-left: 4px; | ||
font-size: 1.6rem; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters