Skip to content

Commit e361e76

Browse files
committed
feat: 全部页面适配ACG MODE
1 parent 5d1f1b3 commit e361e76

9 files changed

Lines changed: 120 additions & 41 deletions

File tree

src/components/class.vue

Lines changed: 31 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
<template>
2-
<div class="lesson" @click="floatWindow">
2+
<div class="lesson" @click="floatWindow" ref="lessonRoot">
33
<p class="txt">{{ course_name }}</p>
44
<p class="txt2">{{ "@" + base_room_name }}</p>
55
<van-popup
66
v-model:show="show"
77
position="bottom"
8-
:style="{ height: '45%' }"
8+
:style="{ height: '45%', backdropFilter: 'blur(2px)' }"
99
closeable
1010
round
1111
teleport="#app"
@@ -44,15 +44,39 @@
4444
<script>
4545
export default {
4646
name: "lesson",
47-
props: ["course_name", "base_room_name", "week", "teacher", "week_day", "start", "end", "course_code"],
47+
props: ["course_name", "base_room_name", "week", "teacher", "week_day", "start", "end", "course_code", "acgMode", "blur"],
48+
mounted() {
49+
let style = this.$refs.lessonRoot.style;
50+
style.cssText += `top: ${this.computeTop(this.start)}; left: ${this.computeLeft(this.week_day)}; background-color: ${this.randomColor(this.start + this.week_day)}`;
51+
},
4852
data() {
4953
return {
5054
show: false,
55+
colors: ["#f44336", "#e91e63", "#9c27b0", "#673ab7", "#3f51b5", "#2196f3", "#03a9f4", "#00bcd4", "#009688", "#4caf50", "#8bc34a", "#795548", "#607d8b"]
5156
}
5257
},
5358
methods: {
5459
floatWindow: function () {
5560
this.show = !this.show;
61+
},
62+
// 计算课程方块的位置
63+
computeTop: function (num) {
64+
return ((num - 1) * 8.3).toString() + "%";
65+
},
66+
computeLeft: function (num) {
67+
return ((num - 1) * 14.2857).toString() + "%";
68+
},
69+
70+
// 随机课程方块的颜色
71+
randomColor: function (num) {
72+
let color = this.colors[num % this.colors.length];
73+
if (this.acgMode) {
74+
color = color + Math.floor(0.7 * 255).toString(16);
75+
if (this.blur) {
76+
this.$nextTick(() => this.$refs.lessonRoot.style.cssText += "backdrop-filter: blur(2px); transform: translateZ(0);");
77+
}
78+
}
79+
return color;
5680
}
5781
}
5882
}
@@ -62,13 +86,11 @@ export default {
6286
.lesson {
6387
position: absolute;
6488
padding: 1% 0.3%;
65-
height: 15.6%;
89+
height: 16.1%;
6690
background-color: #588505;
67-
width: 12.5717%;
68-
border-radius: 10px;
69-
margin-right: 0.857%;
70-
margin-left: 0.857%;
71-
margin-top: 1%;
91+
width: 11.75vw;
92+
border-radius: 8px;
93+
margin-top: 0.5%;
7294
}
7395
7496
.txt {

src/js/ThemeUtils.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
export function setAcgTheme(el) {
2+
let acgMode = localStorage.getItem('ACG_MODE') === 'true';
3+
if (acgMode) {
4+
let custBg = localStorage.getItem('customBg');
5+
if (custBg !== "" && custBg != null) {
6+
el.style.cssText += `background-image: url("${custBg}");`
7+
} else {
8+
let bgUrl = localStorage.getItem("ramdonBg");
9+
el.style.cssText += `background-image: url("${bgUrl}");`;
10+
}
11+
el.style.cssText += "background-position: center;" + "background-repeat: no-repeat;" + "background-size: cover;"
12+
}
13+
}

src/views/Exam.vue

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
import TableVant from "../components/table.vue"
3131
import {closeDialog, showConfirmDialog, showFailToast, showNotify, showToast} from "vant";
3232
import {getExam} from "@/api/getExam";
33+
import {setAcgTheme} from "@/js/ThemeUtils";
3334
3435
3536
export default {
@@ -47,6 +48,7 @@ export default {
4748
} else {
4849
this.loadExam();
4950
}
51+
setAcgTheme(document.querySelector("#exam"));
5052
},
5153
components: {TableVant},
5254
name: "exam",

src/views/about.vue

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,12 +50,19 @@
5050
<p>群里面反馈一下,部分账号确实存在这个问题</p>
5151
</van-collapse-item>
5252
<van-collapse-item title="SWUST 二次元最速传说と绝凶の猛虎!">
53-
<van-switch v-model="status" @update:model-value="recordInfo"/>
53+
<div style="align-items: center; display: flex; justify-content: space-between">
54+
<div style="margin-right: 10px; color: #1c1c1e">ACG模式</div>
55+
<van-switch v-model="status" @update:model-value="recordInfo"/>
56+
</div>
57+
<div style="align-items: center; display: flex; margin-top: 10px; margin-bottom: 10px; justify-content: space-between">
58+
<div style="margin-right: 10px; color: #1c1c1e">课程表方块高斯模糊 (性能开销大)</div>
59+
<van-switch v-model="lessonBlur" @update:model-value="blurInfo"/>
60+
</div>
5461
<van-field
5562
placeholder="自定义背景URL (https://...),留空不使用"
5663
v-model="customBg"
5764
clearable
58-
style="padding: 0; background: transparent"
65+
style="padding: 5px; border-radius: 8px;"
5966
v-if="status"
6067
>
6168
<template #button>
@@ -72,6 +79,7 @@
7279
import {UPDATE_LOG, OPEN_SOURCE, PRIVACY_POLICY} from "@/common/doc";
7380
import {showConfirmDialog, showLoadingToast, showSuccessToast} from "vant";
7481
import {deleteLocalCourse} from "@/api/getCourse";
82+
import {setAcgTheme} from "@/js/ThemeUtils";
7583
7684
export default {
7785
name: "aboutUs",
@@ -82,11 +90,13 @@ export default {
8290
updateLog: UPDATE_LOG,
8391
privacy: PRIVACY_POLICY,
8492
status: localStorage.getItem('ACG_MODE') === 'true',
85-
customBg: ""
93+
customBg: "",
94+
lessonBlur: localStorage.getItem('lessonBlur') === 'true'
8695
}
8796
},
8897
mounted() {
8998
this.customBg = localStorage.getItem('customBg') || '';
99+
setAcgTheme(document.querySelector("#about"));
90100
},
91101
methods: {
92102
goBack: function () {
@@ -122,6 +132,17 @@ export default {
122132
localStorage.setItem('ACG_MODE', 'false')
123133
}
124134
},
135+
blurInfo: async function (status) {
136+
if (status) {
137+
const data = await showConfirmDialog({
138+
title: '警告',
139+
message: '打开课程方块高斯模糊可能导致卡顿掉帧,是否继续?',
140+
}).then(() => 'true').catch(() => 'false')
141+
localStorage.setItem('lessonBlur', data)
142+
} else {
143+
localStorage.setItem('lessonBlur', 'false')
144+
}
145+
},
125146
setBg: function () {
126147
localStorage.setItem("customBg", this.customBg);
127148
showSuccessToast("设置成功 (过大的图片可能导致加载缓慢)");

src/views/course.vue

Lines changed: 34 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<template>
2-
<div id="grid1">
2+
<div id="grid1" ref="grid1">
33
<!-- 加载效果 -->
44
<LoadingView :show="show"/>
55
<!-- 导航栏 -->
@@ -23,13 +23,13 @@
2323
<!-- 导航栏底下的星期条 -->
2424
<van-row class="week-bar">
2525
<van-col span="3"><p class="time">{{ curWeek }}周</p></van-col>
26-
<van-col span="3"><p class="time" :class="{ active: activeDay[1] }">周一</p></van-col>
27-
<van-col span="3"><p class="time" :class="{ active: activeDay[2] }">周二</p></van-col>
28-
<van-col span="3"><p class="time" :class="{ active: activeDay[3] }">周三</p></van-col>
29-
<van-col span="3"><p class="time" :class="{ active: activeDay[4] }">周四</p></van-col>
30-
<van-col span="3"><p class="time" :class="{ active: activeDay[5] }">周五</p></van-col>
31-
<van-col span="3"><p class="time" :class="{ active: activeDay[6] }">周六</p></van-col>
32-
<van-col span="3"><p class="time" :class="{ active: activeDay[0] }">周日</p></van-col>
26+
<van-col span="3"><p class="time" :class="{ active: activeDay[1] }"></p></van-col>
27+
<van-col span="3"><p class="time" :class="{ active: activeDay[2] }"></p></van-col>
28+
<van-col span="3"><p class="time" :class="{ active: activeDay[3] }"></p></van-col>
29+
<van-col span="3"><p class="time" :class="{ active: activeDay[4] }"></p></van-col>
30+
<van-col span="3"><p class="time" :class="{ active: activeDay[5] }"></p></van-col>
31+
<van-col span="3"><p class="time" :class="{ active: activeDay[6] }"></p></van-col>
32+
<van-col span="3"><p class="time" :class="{ active: activeDay[0] }"></p></van-col>
3333
</van-row>
3434

3535
<van-row>
@@ -55,11 +55,12 @@
5555
<p class="num">12</p>
5656
</div>
5757
</div>
58-
<div style="max-height: 100%; width: 87.5vw;">
58+
<div style="max-height: 100%; width: 85.75vw; margin-left: 1%">
5959
<!-- 渲染课表 -->
6060
<lesson
6161
v-for="l in lessons"
6262
:course_name="l.jw_course_name"
63+
:acg-mode="acgMode"
6364
:base_room_name="l.base_room_name"
6465
:week="l.week"
6566
:key="l.jw_task_book_no"
@@ -68,7 +69,8 @@
6869
:start="l.section_start"
6970
:end="l.section_end"
7071
:course_code="l.jw_course_code"
71-
:style='{ "top": computeTop(l.section_start), "left": computeLeft(l.week_day), "background-color": randomColor(l.section_start + l.week_day)}'>
72+
:blur="lessonBlur"
73+
>
7274
</lesson>
7375
</div>
7476
</van-row>
@@ -93,6 +95,21 @@ export default {
9395
lesson
9496
},
9597
mounted() {
98+
let grid1 = this.$refs.grid1;
99+
const opacity = 0.7;
100+
this.acgMode = localStorage.getItem('ACG_MODE') === 'true';
101+
if (this.acgMode && grid1.offsetWidth > 0) {
102+
let custBg = localStorage.getItem('customBg');
103+
if (custBg !== "" && custBg != null) {
104+
grid1.style.cssText = `background-image: url("${custBg}");`
105+
} else {
106+
let bgUrl = localStorage.getItem("ramdonBg");
107+
grid1.style.cssText = `background-image: url("${bgUrl}");`;
108+
}
109+
document.querySelector(".week-bar").style.cssText += `background-color: rgba(255, 255, 255, ${opacity});`
110+
document.documentElement.style.setProperty("--van-pagination-background", "none");
111+
document.documentElement.style.setProperty("--van-pagination-item-disabled-background", "none");
112+
}
96113
// 删掉边框
97114
let items = document.getElementsByTagName("ul");
98115
for (const item of items) {
@@ -122,7 +139,9 @@ export default {
122139
show: false,
123140
local: false,
124141
activeDay: [false, false, false, false, false, false, false],
125-
initial: 0
142+
initial: 0,
143+
acgMode: false,
144+
lessonBlur: localStorage.getItem('lessonBlur') === 'true'
126145
}
127146
},
128147
computed: {
@@ -234,20 +253,6 @@ export default {
234253
this.activeDay[weekday] = true;
235254
},
236255
237-
// 计算课程方块的位置
238-
computeTop: function (num) {
239-
return ((num - 1) * 8.3).toString() + "%";
240-
},
241-
computeLeft: function (num) {
242-
return ((num - 1) * 14.2857).toString() + "%";
243-
},
244-
245-
// 随机课程方块的颜色
246-
randomColor: function (num) {
247-
const colors = ["#f44336", "#e91e63", "#9c27b0", "#673ab7", "#3f51b5", "#2196f3", "#03a9f4", "#00bcd4", "#009688", "#4caf50", "#8bc34a", "#795548", "#607d8b"];
248-
return colors[num % colors.length];
249-
},
250-
251256
validateLocalCache: function () {
252257
let normStamp = localStorage.getItem("normStamp");
253258
let expStamp = localStorage.getItem("expStamp");
@@ -274,11 +279,14 @@ export default {
274279
width: 100%;
275280
height: 100%;
276281
max-height: 100%;
282+
background-position: center;
283+
background-repeat: no-repeat;
284+
background-size: cover;
277285
}
278286
279287
.week-bar {
280288
height: 4.5vh;
281-
padding: 1%;
289+
padding: 1vw;
282290
top: 0;
283291
background-color: white;
284292
//box-shadow: 0 2px 6px 0 rgba(0, 0, 0, 0.05), 0 2px 6px 0 rgba(0, 0, 0, 0.05);

src/views/index.vue

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,9 +127,11 @@ export default {
127127
const el = document.querySelector('#mask')
128128
const custBg = localStorage.getItem('customBg');
129129
if (custBg !== "" && custBg != null) {
130-
el.style.cssText = `background-image: url("${custBg}");`
130+
el.style.cssText += `background-image: url("${custBg}");`
131131
} else {
132-
el.style.cssText = `background-image: url("/sercet/${Math.floor(Math.random() * 5) + 1}.jpg");`
132+
let bgUrl = `/sercet/${Math.floor(Math.random() * 5) + 1}.jpg`;
133+
localStorage.setItem("ramdonBg", bgUrl);
134+
el.style.cssText += `background-image: url("${bgUrl}");`;
133135
}
134136
const opacity = "0.7";
135137
document.documentElement.style.setProperty("--van-background-2", "rgba(255, 255, 255, " + opacity + ")");

src/views/library.vue

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ import {ref} from 'vue';
7676
import {queryBooks} from "@/api/queryBooks";
7777
import {queryBookLocation} from "@/api/queryBookLocation"
7878
import {library} from "@/api/getLibrary";
79+
import {setAcgTheme} from "@/js/ThemeUtils";
7980
8081
export default {
8182
components: {TableVant},
@@ -125,6 +126,7 @@ export default {
125126
name: "library",
126127
mounted() {
127128
this.getLibrary();
129+
setAcgTheme(document.querySelector("#library"));
128130
},
129131
data() {
130132
return {
@@ -212,6 +214,9 @@ export default {
212214
overflow-x: auto;
213215
overflow-y: auto;
214216
-webkit-overflow-scrolling: touch;
217+
background-position: center;
218+
background-repeat: no-repeat;
219+
background-size: cover;
215220
}
216221
217222
#loading2 {

src/views/login.vue

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
<script>
3636
import PwdLoginPanel from "@/components/PwdLoginPanel.vue";
3737
import PhoneLoginPanel from "@/components/PhoneLoginPanel.vue";
38+
import {setAcgTheme} from "@/js/ThemeUtils";
3839
3940
export default {
4041
name: "loginPanel",
@@ -46,7 +47,7 @@ export default {
4647
}
4748
},
4849
mounted() {
49-
// this.getPwd();
50+
setAcgTheme(document.querySelector("#login"));
5051
},
5152
methods: {
5253
login: function () {

src/views/score.vue

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ import axios from "axios"
8888
import {showFailToast} from "vant";
8989
import {BASE_URL} from "@/common/final"
9090
import {ref} from "vue";
91+
import {setAcgTheme} from "@/js/ThemeUtils";
9192
9293
9394
export default {
@@ -119,6 +120,7 @@ export default {
119120
},
120121
mounted() {
121122
this.getGPA();
123+
setAcgTheme(document.querySelector("#score"));
122124
},
123125
name: "score",
124126
methods: {
@@ -214,6 +216,9 @@ export default {
214216
overflow-x: hidden;
215217
overflow-y: auto;
216218
-webkit-overflow-scrolling: touch;
219+
background-position: center;
220+
background-repeat: no-repeat;
221+
background-size: cover;
217222
}
218223
219224
#loading {

0 commit comments

Comments
 (0)