Skip to content

Commit

Permalink
feat: add 'video muted' and 'auto answer'
Browse files Browse the repository at this point in the history
  • Loading branch information
Xu22Web committed Jul 12, 2023
1 parent d1702c2 commit 8437567
Show file tree
Hide file tree
Showing 23 changed files with 811 additions and 170 deletions.
8 changes: 3 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,13 +76,11 @@

### 更新与维护 Update and Maintenance

1. 新增重置配置,修复版本迭代造成配置不一致的问题
1. 提升运行稳定性,修复专项答题未登录显示的问题

2. 新增`B站粉``知乎蓝`主题色,缤纷颜色,多彩体验
2. 新增视频静音、自动答题选项,灵活自由配置,避免被封

3. 新增版本号显示,直观展示版本信息

4. 与此同时,提供更加便捷的版本选择
3. 与此同时,提供更加便捷的版本选择

- [Node.js 版](https://github.com/Xu22Web/tech-study-node 'Node.js 版')

Expand Down
2 changes: 1 addition & 1 deletion cache.json

Large diffs are not rendered by default.

46 changes: 43 additions & 3 deletions src/component/ExamBtn.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
import { examPause } from '../shared';
import { watchEffectRef } from '../utils/composition';
import { examPause, settings } from '../shared';
import { SettingType } from '../types';
import { watchEffect, watchEffectRef } from '../utils/composition';
import { createElementNode, createTextNode } from '../utils/element';

/**
* @description 答题按钮
*/
function ExamBtn() {
// 设置初始状态
watchEffect(() => (examPause.value = !settings[SettingType.AUTO_ANSWER]));
return createElementNode(
'button',
undefined,
Expand All @@ -14,9 +17,46 @@ function ExamBtn() {
() => `egg_exam_btn${examPause.value ? ' manual' : ''}`
),
type: 'button',
onclick: () => {
onclick(e: Event) {
e.stopPropagation();
examPause.value = !examPause.value;
},
onmousedown(e: Event) {
e.stopPropagation();
},
onmousemove(e: Event) {
e.stopPropagation();
},
onmouseup(e: Event) {
e.stopPropagation();
},
onmouseenter(e: Event) {
e.stopPropagation();
},
onmouseleave(e: Event) {
e.stopPropagation();
},
onmouseover(e: Event) {
e.stopPropagation();
},
ontouchstart(e: Event) {
e.stopPropagation();
},
ontouchmove(e: Event) {
e.stopPropagation();
},
ontouchend(e: Event) {
e.stopPropagation();
},
oninput(e: Event) {
e.stopPropagation();
},
onchange(e: Event) {
e.stopPropagation();
},
onblur(e: Event) {
e.stopPropagation();
},
},
createTextNode(
watchEffectRef(
Expand Down
39 changes: 39 additions & 0 deletions src/component/Frame.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,45 @@ function Frame() {
undefined,
{
class: watchEffectRef(() => `egg_frame_wrap${frame.show ? '' : ' hide'}`),
onclick(e: Event) {
e.stopPropagation();
},
onmousedown(e: Event) {
e.stopPropagation();
},
onmousemove(e: Event) {
e.stopPropagation();
},
onmouseup(e: Event) {
e.stopPropagation();
},
onmouseenter(e: Event) {
e.stopPropagation();
},
onmouseleave(e: Event) {
e.stopPropagation();
},
onmouseover(e: Event) {
e.stopPropagation();
},
ontouchstart(e: Event) {
e.stopPropagation();
},
ontouchmove(e: Event) {
e.stopPropagation();
},
ontouchend(e: Event) {
e.stopPropagation();
},
oninput(e: Event) {
e.stopPropagation();
},
onchange(e: Event) {
e.stopPropagation();
},
onblur(e: Event) {
e.stopPropagation();
},
},
watchRef(
() => [login.value, settings[SettingType.SAME_TAB]],
Expand Down
107 changes: 86 additions & 21 deletions src/component/Panel.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { doExamPaper } from '../controller/exam';
import { createTip } from '../controller/tip';
import { frame, running, settings, taskStatus } from '../shared';
import { frame, login, running, settings, taskStatus } from '../shared';
import { SettingType, TaskStatusType } from '../types';
import { ref, watchEffectRef, watchRef } from '../utils/composition';
import {
Expand Down Expand Up @@ -45,6 +45,11 @@ function Panel() {
tip: '定时刷新页面,重新进行任务,此功能需要长时间占用浏览器',
type: SettingType.SCHEDULE_RUN,
},
{
title: '视频静音',
tip: '视听学习时,静音播放视频',
type: SettingType.VIDEO_MUTED,
},
];
// 运行设置标签
const examLabels = [
Expand All @@ -53,6 +58,11 @@ function Panel() {
tip: '无答案时, 随机选择或者填入答案, 不保证正确',
type: SettingType.RANDOM_EXAM,
},
{
title: '自动答题',
tip: '进入答题页面时,自动答题并提交答案',
type: SettingType.AUTO_ANSWER,
},
];
// 推送设置标签
const pushLabels = [
Expand Down Expand Up @@ -83,6 +93,45 @@ function Panel() {
undefined,
{
class: `egg_panel_wrap${hasMobile() ? ' mobile' : ''}`,
onclick(e: Event) {
e.stopPropagation();
},
onmousedown(e: Event) {
e.stopPropagation();
},
onmousemove(e: Event) {
e.stopPropagation();
},
onmouseup(e: Event) {
e.stopPropagation();
},
onmouseenter(e: Event) {
e.stopPropagation();
},
onmouseleave(e: Event) {
e.stopPropagation();
},
onmouseover(e: Event) {
e.stopPropagation();
},
ontouchstart(e: Event) {
e.stopPropagation();
},
ontouchmove(e: Event) {
e.stopPropagation();
},
ontouchend(e: Event) {
e.stopPropagation();
},
oninput(e: Event) {
e.stopPropagation();
},
onchange(e: Event) {
e.stopPropagation();
},
onblur(e: Event) {
e.stopPropagation();
},
},
createElementNode(
'div',
Expand Down Expand Up @@ -155,26 +204,42 @@ function Panel() {
),
// 提示部分
Hr({ text: '提示' }),
createElementNode('div', undefined, { class: 'egg_tip_list' }, [
createTextNode('专项练习已被移除, 如需使用, 请点击'),
createElementNode(
'button',
undefined,
{
class: 'egg_tip_btn',
type: 'button',
onclick: debounce(doExamPaper, 300),
disabled: watchRef(
() => [running.value, taskStatus.value],
() =>
running.value ||
taskStatus.value === TaskStatusType.START ||
taskStatus.value === TaskStatusType.PAUSE
),
},
createTextNode('去完成')
),
]),
createElementNode(
'div',
undefined,
{ class: 'egg_tip_list' },
watchRef(login, () =>
login.value
? [
createTextNode('专项练习已被移除, 如需使用, 请点击'),
createElementNode(
'button',
undefined,
{
class: 'egg_tip_btn',
type: 'button',
onclick: debounce(doExamPaper, 300),
disabled: watchRef(
() => [running.value, taskStatus.value],
() =>
running.value ||
taskStatus.value === TaskStatusType.START ||
taskStatus.value === TaskStatusType.PAUSE
),
},
createTextNode('去完成')
),
]
: [
createElementNode(
'div',
undefined,
{ class: 'egg_tip_content' },
createTextNode('请先登录!')
),
]
)
),
// 按钮集合
createElementNode(
'div',
Expand Down
6 changes: 5 additions & 1 deletion src/component/TaskBtn.ts
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,11 @@ function TaskBtn() {
`当天积分: ${getHighlightHTML(todayScore.value)} 分`,
`总积分: ${getHighlightHTML(totalScore.value)} 分`,
...taskConfig.map((task) =>
getProgressHTML(task.title, task.percent)
getProgressHTML(
task.title,
task.currentScore,
task.dayMaxScore
)
),
],
type: 'success',
Expand Down
11 changes: 7 additions & 4 deletions src/component/TaskItem.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ function TaskItem({
title,
tip,
checked,
percent,
currentScore,
dayMaxScore,
onchange,
Expand All @@ -18,7 +17,6 @@ function TaskItem({
title: string;
tip: string;
checked: Ref<boolean>;
percent: Ref<number>;
currentScore: Ref<number>;
dayMaxScore: Ref<number>;
onchange: (...args: any[]) => void;
Expand Down Expand Up @@ -70,7 +68,13 @@ function TaskItem({
{ class: 'egg_track' },
createElementNode('div', undefined, {
class: 'egg_bar',
style: watchEffectRef(() => `width: ${percent.value}%;`),
style: watchEffectRef(
() =>
`width: ${(
(100 * currentScore.value) /
dayMaxScore.value
).toFixed(1)}%;`
),
})
),
]),
Expand All @@ -88,4 +92,3 @@ function TaskItem({
}

export { TaskItem };

2 changes: 0 additions & 2 deletions src/component/TaskList.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ function TaskList() {
title: label.title,
tip: label.tip,
checked: watchEffectRef(() => label.active),
percent: watchEffectRef(() => label.percent),
currentScore: watchEffectRef(() => label.currentScore),
dayMaxScore: watchEffectRef(() => label.dayMaxScore),
onchange: debounce((e) => {
Expand All @@ -68,7 +67,6 @@ function TaskList() {
title: label.title,
tip: label.tip,
checked: watchEffectRef(() => label.active),
percent: watchEffectRef(() => label.percent),
currentScore: watchEffectRef(() => label.currentScore),
dayMaxScore: watchEffectRef(() => label.dayMaxScore),
onchange: debounce((e) => {
Expand Down
1 change: 1 addition & 0 deletions src/config/script.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ const SCRIPT_CONFIG = {
'GM_setValue',
'GM_getValue',
'GM_openInTab',
'GM_addValueChangeListener',
'unsafeWindow',
],
updateURL:
Expand Down
12 changes: 1 addition & 11 deletions src/config/task.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,5 @@ const maxRefreshCount = 10;
* @description 二维码自动刷新间隔
*/
const autoRefreshQRCodeInterval = 100000;
/**
* @description 视频静音
*/
const muted = true;

export {
maxNewsNum,
maxVideoNum,
maxRefreshCount,
autoRefreshQRCodeInterval,
muted,
};
export { maxNewsNum, maxVideoNum, maxRefreshCount, autoRefreshQRCodeInterval };
2 changes: 1 addition & 1 deletion src/config/version.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/**
* @description 版本号
*/
const version = '1.7.0';
const version = '1.7.3';

export { version };
4 changes: 2 additions & 2 deletions src/controller/login.ts
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ async function handleLogin() {
`当天积分: ${getHighlightHTML(todayScore.value)} 分`,
`总积分: ${getHighlightHTML(totalScore.value)} 分`,
...taskConfig.map((task) =>
getProgressHTML(task.title, task.percent)
getProgressHTML(task.title, task.currentScore,task.dayMaxScore)
),
],
type: 'success',
Expand Down Expand Up @@ -262,7 +262,7 @@ function handleLogout() {
todayScore.value = 0;
// 任务进度重置
taskConfig.forEach((task) => {
task.percent = 0;
task.currentScore = 0;
});
taskStatus.value = TaskStatusType.LOADING;
// 退出登录
Expand Down
Loading

0 comments on commit 8437567

Please sign in to comment.