Skip to content

Commit

Permalink
Merge branch 'main' of https://github.com/Moemu/FortuneUpUp
Browse files Browse the repository at this point in the history
  • Loading branch information
KJZH001 committed Sep 15, 2023
2 parents d06ccd7 + 2fa6ab2 commit bc4f196
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 38 deletions.
36 changes: 22 additions & 14 deletions FortuneUpUp.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// 设置项
var CustomFont = "小赖字体 等宽 SC"; //在此处修改字体

//今日的运势是?
function WhatisTodaysFortune() {
let options = [
Expand Down Expand Up @@ -87,6 +90,7 @@ function WhatisTodaysFortuneEvent(Fortune){
{Date:"L05.05",name:"来口粽子",good:"自己包的说不定更好吃",bad:null},
{Date:"L12.30",name:"吃年夜饭",good:"无论身在何处,我都希望各位能够和亲人欢度今宵",bad:null},
{Date:"06.01",name:"像个孩子一样",good:"有多久没有像个孩子一样天真,憧憬未来了",bad:null},
{Date:"06.07",name:"参加高考",good:"无论如何,你是最棒的☆",bad:null},
{Date:"07.21",name:"Ciallo ~ (∠・ω< )⌒☆",good:"无论如何,今天就是这样一个日子嘛",bad:null},
{Date:"08.31",name:"写作业",good:"创造奇迹",bad:"反正都写不完,不如开摆"},
{Date:"09.01",name:"思乡",good:"妈妈,我要回家",bad:null},
Expand Down Expand Up @@ -279,8 +283,13 @@ function mouseDownEvent(event) {
}

function CloseSignbox(){
document.getElementById("Signbox").style.display = "none";
document.getElementById("SignboxResult").style.display = "none";
PressShapeTime += 1;
if(PressShapeTime == 2){
document.getElementById("Signbox").style.display = "none";
document.getElementById("SignboxResult").style.display = "none";
}else{
Snackbar.show({text:"再按一次关闭",showAction:false,timeout:2000})
}
}

function WriteFortuneToImg(Fortune,GoodEventList,BadEventList) {
Expand All @@ -304,7 +313,7 @@ function WriteFortuneToImg(Fortune,GoodEventList,BadEventList) {
ctx.drawImage(Background, 0, 0); //插入背景
ctx.drawImage(GoodThingImg,35,105); //插入图标
//调整标题字体
ctx.font = "60px 小赖字体 等宽 SC"; //在此处修改运势字体大小和字体
ctx.font = "60px "+CustomFont; //在此处修改运势字体大小和字体
ctx.fillStyle = "#ee3f4d";
//定位标题
var FortuneWidth = ctx.measureText(Fortune).width;
Expand All @@ -313,10 +322,10 @@ function WriteFortuneToImg(Fortune,GoodEventList,BadEventList) {
ctx.fillText(Fortune, x, 100);
// 宜
for(let i = 0;i<GoodEventList.length;i++){
ctx.font = "30px 小赖字体 等宽 SC"; //在此处修改事件字体大小和字体
ctx.font = "30px "+CustomFont; //在此处修改事件字体大小和字体
ctx.fillStyle = "#ee3f4d"
ctx.fillText("· "+GoodEventList[i]["name"], 60, y);
ctx.font = "15px 小赖字体 等宽 SC"; //在此处修改备注字体大小和字体
ctx.font = "15px "+CustomFont; //在此处修改备注字体大小和字体
ctx.fillStyle = "#7a7374"
ctx.fillText(GoodEventList[i]["good"], 110, y+25);
y += 60;
Expand All @@ -327,10 +336,10 @@ function WriteFortuneToImg(Fortune,GoodEventList,BadEventList) {
ctx.drawImage(BadThingImg,35,y);
y += 28 + 30;
for(let i = 0;i<BadEventList.length;i++){
ctx.font = "30px 小赖字体 等宽 SC"; //在此处修改事件字体大小和字体
ctx.font = "30px "+CustomFont; //在此处修改事件字体大小和字体
ctx.fillStyle = "#ee3f4d"
ctx.fillText("· "+BadEventList[i]["name"], 60, y);
ctx.font = "15px 小赖字体 等宽 SC"; //在此处修改备注字体大小和字体
ctx.font = "15px "+CustomFont; //在此处修改备注字体大小和字体
ctx.fillStyle = "#7a7374"
ctx.fillText(BadEventList[i]["bad"], 110, y+25);
y += 60;
Expand Down Expand Up @@ -383,7 +392,7 @@ function loadDependency(url) {
});
}
// 加载第一部分: 加载Snackbar
function LoadSnackbar(Settings){
function LoadSnackbar(){
const Snackbardependencies = [
'https://cdn-js.moeworld.top/npm/node-snackbar@latest/src/js/snackbar.min.js',
'https://cdn-js.moeworld.top/npm/node-snackbar@latest/dist/snackbar.min.css'
Expand All @@ -392,7 +401,7 @@ function LoadSnackbar(Settings){
Promise.all(Snackbardependencies.map(loadDependency))
.then(() => {
Snackbar.show({text:"少女祈祷中..",showAction:false,timeout:10000})
LoadDependent(Settings);
LoadDependent();
})
.catch((error) => {
Snackbar.close();
Expand All @@ -403,13 +412,11 @@ function LoadSnackbar(Settings){

// 加载第二部分: 加载其他JS依赖与IMG依赖
function LoadDependent(){
const dependencies = [
let dependencies = [
'https://cdn-js.moeworld.top/gh/KJZH001/FortuneUpUp/js/LunarCalendar.js',
'https://cdn-js.moeworld.top/gh/KJZH001/FortuneUpUp/js/SignboxResultImg.js',
'https://cdn-js.moeworld.top/gh/KJZH001/FortuneUpUp/images/Signbox.png'
];
if(Settings["ThirdPartyFont"]){
dependencies.push('https://cdn.jsdelivr.net/gh/Moemu/FortuneUpUp@FontCompress/XiaolaiSC-Tiny.woff2')};
Promise.all(dependencies.map(loadDependency))
.then(() => {
Snackbar.close();
Expand All @@ -425,6 +432,7 @@ function AppendSignbox(){
var Signbox = document.createElement("div");
var SignboxResultShape = document.createElement("div");
var SignboxResult = document.createElement("div");
PressShapeTime = 0;
SignboxResult.id = "SignboxResult";
Signbox.id = "Signbox";
Signbox.addEventListener("mousedown", mouseDownEvent);
Expand All @@ -439,7 +447,7 @@ function AppendSignbox(){
}

// 总启动函数
function StartFortuneUpUp(Settings = {"ThirdPartyFont":true}){
LoadSnackbar(Settings);
function StartFortuneUpUp(){
LoadSnackbar();
AppendSignbox();
}
33 changes: 33 additions & 0 deletions Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@

FortuneUpUp里边的推荐你去做/不要做的事件大多都是基于业余程序员(也就是我)的一些日常生活而写出来的,有代码,博客,UP主,视频,游戏,应用,社交,网站,日常等这几大类,如果您有一些想法,欢迎您提出PR。

关于特性与近期更新目标:[FortuneUpUp To Do List](https://github.com/users/Moemu/projects/1)

​ 温馨提示: FortuneUpUp生成的内容仅供娱乐,请在面对占卜结果的时候慎重考虑到底要不要做还是不做,由此产生的后果作者概不负责。

# 🪄使用🪄
Expand All @@ -37,6 +39,37 @@ window.onload = function(){
}
```

# ⚒️自定义⚒️

我们鼓励用户folk此repo以自定义自己的FourtuneUpUp页面。

如果您对JavaScript不熟悉,那么本内容可能对您有所帮助。

**1. 自定义字体**

FortuneUpUp允许用户自定义自己的字体,在`FortuneUpUp.js`首行的设置项中找到`CustomFont`变量,将其中的内容换成你自己的字体即可。

温馨提示:您需要提前在您的CSS/HTML文件中加入您字体的CDN链接,并确保它在FortuneUpUp之前加载,不然会显示默认的微软雅黑。

**2. 自定义事件**

按照这个格式配置你的自定义事件。

对于`Events`中的普通事件,格式如下:

```javascript
{name:"(事件名/标题)",good:"(若这个事件被选为宜事件,下方显示的注释。)",bad:"(若这个事件被选为忌事件,下方显示的注释。输入null则不会被选为忌事件)",tag:"(事件标签,通常是职位或者是兴趣爱好名,在未来引入该特性)"}
```

对于`SpecialFestivalEvents`中的特别日事件,格式如下:

```javascript
{Date:"(触发日期。日期格式: (L)MM.DD 若日期前含有L,则为农历)",name:"(事件名/标题)",good:"(若这个事件被选为宜事件,下方显示的注释。)",bad:"(若这个事件被选为忌事件,下方显示的注释。输入null则不会被选为忌事件)"}
```

对于`NormalFestivalEvents`中的普通节假日事件,格式与`Events`一致(注意:`NormalFestivalDateList`不支持农历)


# 🎉示例🎉

博客示例页面: [运势UpUp](https://blog.moeworld.tech/fortuneupup:测测今天的运势吧/)
Expand Down
24 changes: 0 additions & 24 deletions font/Compress.py

This file was deleted.

0 comments on commit bc4f196

Please sign in to comment.