Skip to content

Commit 6a8ba06

Browse files
committed
divider update
1 parent e9876e1 commit 6a8ba06

File tree

5 files changed

+46
-15
lines changed

5 files changed

+46
-15
lines changed

.github/workflows/main.yml

+1
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ jobs:
6161
2024/3/17: 已支持课上隐藏课表,课上仅保留小窗倒计时,开机自动启动,鼠标靠近降低透明度
6262
2024/3/22: ~~已修复开机自动启动报错Bug~~,新增小窗口倒计时课程名称显示
6363
2024/3/23: 已修复workingDir未配置导致的开机自动启动报错Bug
64+
2024/3/29: 已支持配置课程间分隔线,在配置文件中有详细介绍
6465
喜欢本项目的话, 点击右上角的Star支持一下作者吧😘
6566
draft: false
6667
prerelease: false

css/style.css

+7
Original file line numberDiff line numberDiff line change
@@ -164,4 +164,11 @@
164164
font-family: JetB;
165165
color: #FFF;
166166
display: none;
167+
}
168+
169+
.divider {
170+
width: var(--divider-width);
171+
background-color: #aaa;
172+
border-radius: calc(var(--divider-width) / 2);
173+
margin: var(--divider-margin);
167174
}

index.html

+22-11
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@
4747
let weekCH = document.getElementById('weekCH')
4848
let countdownDays = document.getElementById('countdownDays')
4949
let miniCountdown = document.getElementById('miniCountdown')
50+
let root = document.querySelector(':root');
5051
let isClassCountdown = true
5152
let isClassHidden = true
5253
let lastScheduleData = {
@@ -57,7 +58,9 @@
5758
countdown: null,
5859
countdownText: null
5960
},
60-
scheduleArray: [null, null, null]
61+
scheduleArray: [null, null, null],
62+
timetable: null,
63+
divider: [null, null]
6164
}
6265

6366
function setScheduleClass() {
@@ -75,13 +78,15 @@
7578
else
7679
classHtml += `<div class="class">${scheduleData.scheduleArray[i]}</div>`
7780
}
81+
if (scheduleData.divider.indexOf(i) != -1)
82+
classHtml += '<div class="divider"></div>'
7883
}
7984
classContainer.innerHTML = classHtml
8085
}
8186

82-
function setBackgroundDisplay(){
87+
function setBackgroundDisplay() {
8388
let elements = document.getElementsByClassName('background')
84-
for (element of elements){
89+
for (element of elements) {
8590
element.style.visibility = (scheduleData.currentHighlight.type === 'current' && isClassHidden) ? 'hidden' : 'visible'
8691
}
8792
}
@@ -120,9 +125,16 @@
120125
y: classContainer.offsetHeight
121126
}
122127
} else if (scheduleData.currentHighlight.type === 'upcoming') {
123-
offset = {
124-
x: highlightElement.offsetLeft - countdownContainer.offsetWidth / 2 - Number(getComputedStyle(highlightElement).marginLeft.replace('px', '')),
125-
y: classContainer.offsetHeight
128+
if (scheduleData.currentHighlight.index != 0 && scheduleData.divider.indexOf((scheduleData.currentHighlight.index - 1)) != -1) {
129+
offset = {
130+
x: highlightElement.offsetLeft - countdownContainer.offsetWidth / 2 - Number(getComputedStyle(highlightElement).marginLeft.replace('px', '')) - getComputedStyle(root).getPropertyValue('--divider-width').replace('px', '') / 2 - getComputedStyle(root).getPropertyValue('--divider-margin').replace('px', ''),
131+
y: classContainer.offsetHeight
132+
}
133+
} else {
134+
offset = {
135+
x: highlightElement.offsetLeft - countdownContainer.offsetWidth / 2 - Number(getComputedStyle(highlightElement).marginLeft.replace('px', '')),
136+
y: classContainer.offsetHeight
137+
}
126138
}
127139
}
128140
if (scheduleData.currentHighlight.isEnd) {
@@ -162,13 +174,12 @@
162174

163175
let lastTickTime = new Date().getTime()
164176
setInterval(() => {
165-
if (new Date().getTime() - lastTickTime >= 1000){
177+
if (new Date().getTime() - lastTickTime >= 1000) {
166178
lastTickTime = new Date().getTime()
167179
tick()
168180
}
169181
}, 20);
170182

171-
const root = document.querySelector(':root');
172183
for (key in scheduleConfig.css_style) {
173184
root.style.setProperty(key, scheduleConfig.css_style[key])
174185
}
@@ -181,16 +192,16 @@
181192
timer = setTimeout(() => {
182193
root.style.opacity = '1'
183194
}, 5000);
184-
}else{
195+
} else {
185196
clearTimeout(timer)
186197
root.style.opacity = '1'
187-
}
198+
}
188199
if (event.target.className.indexOf('notIgnoreClick') == -1) {
189200
ipcRenderer.send('setIgnore', true)
190201
} else {
191202
ipcRenderer.send('setIgnore', false)
192203
}
193-
204+
194205
});
195206
ipcRenderer.send('setIgnore', true)
196207

js/index.js

+4-2
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,9 @@ function getScheduleData() {
8383
const currentTime = getCurrentTime();
8484
// let currentTime = '07:10:01';
8585
const dayOfWeek = getCurrentEditedDate().getDay();
86-
const dayTimetable = scheduleConfig.timetable[scheduleConfig.daily_class[dayOfWeek].timetable];
86+
const timetable = scheduleConfig.daily_class[dayOfWeek].timetable
87+
const dayTimetable = scheduleConfig.timetable[timetable];
88+
const divider = scheduleConfig.divider[timetable];
8789

8890
let scheduleArray = [];
8991
let currentHighlight = { index: null, type: null, fullName: null, countdown: null, countdownText: null };
@@ -136,7 +138,7 @@ function getScheduleData() {
136138
}
137139
});
138140

139-
return { scheduleArray, currentHighlight };
141+
return { scheduleArray, currentHighlight, timetable, divider };
140142
}
141143

142144

js/scheduleConfig.js

+12-2
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,10 @@ const _scheduleConfig = {
2121
'班': '班会',
2222
},
2323

24-
// 时间表: 每天课程安排的时间表,冒号前面为时间,后面为课程序号(从0开始的数字[不带'']) 或 课间具体名称(用''包裹中间写文字)
25-
// 这里的例子workday和weekend只是举例,你也可以自定义其名字(第一个字符不要为数字)
24+
// 时间表: 每天课程安排的时间表,内层冒号前面为时间,后面为课程序号(从0开始的数字[不带'']) 或 课间具体名称(用''包裹中间写文字)
25+
// 这里的例子workday和weekend(外层)只是举例,你也可以自定义其名字(第一个字符不要为数字)
2626
// 比如如果你的学校周三半天,你可以在这里单独添加一个wednesday: {...}
27+
// 注:时间段中-后的时间要减一分钟 比如某节课40分钟,时间段为08:00-08:40,但实际配置时要配置'08:00-08:39'
2728
timetable: {
2829
workday: {
2930
'00:00-07:39': '早自习',
@@ -73,6 +74,13 @@ const _scheduleConfig = {
7374
}
7475
},
7576

77+
// 分隔线: 课表中区分不同时段课程的分隔线配置,外层key(冒号前)部分与上面timeable相同
78+
// value(冒号后)为分隔线所在位置的前一个课程序号(从0开始的数字[不带''])
79+
divider: {
80+
workday: [4, 8],
81+
weekend: [3]
82+
},
83+
7684
// 每日课程:配置星期几对应第几堂课是什么课,星期顺序不可以更改(星期日/一/二/三/四/五/六),你可以对classList后面内容进行更改
7785
// 从classList后最外的中括号看起,里面的第几个元素的序号-1就是该元素的下标,这个下标对应你在上面timetable中配置的数字,课程用单引号包含,写入在subject_name中配置的简写
7886
// 如果该节课可能存在每周轮换,你可以用一个中括号把他们全部写进去如: ['(第一周课)物', '(第二周)化', '(第三周)地'](小括号及其内容无需填写, 最多支持三周轮换)
@@ -136,6 +144,8 @@ const _scheduleConfig = {
136144
'--container-space': '16px', // 上面三个框中间的间隔长度
137145
'--top-space': '16px', // 课表主体最顶端与电脑屏幕上边框的间隔长度
138146
'--main-horizontal-space': '8px', // 中间课表中的课程简写单字之间的间隔长度
147+
'--divider-width': '2px', // 分隔线宽度
148+
'--divider-margin': '6px', // 分隔线外边距
139149
}
140150
}
141151

0 commit comments

Comments
 (0)