finish schedule

This commit is contained in:
RainSun 2020-09-12 09:40:47 +08:00
parent ca711afa57
commit e10b5b76f3
5 changed files with 131 additions and 32 deletions

View File

@ -16,6 +16,7 @@
<meta itemprop="name" content="Cherry" />
<!-- 描述 -->
<meta itemprop="description" content="为长理同学提供课表代理查询服务" />
<meta name="referrer" content="no-referrer">
<script>
var _hmt = _hmt || [];

View File

@ -1,6 +1,5 @@
<template>
<div id="app">
<div class="bg"></div>
<Drawer></Drawer>
<!-- 缓存 -->
<keep-alive>
@ -141,18 +140,6 @@ button {
-khtml-user-select: none;
user-select: none;
}
.bg {
position: fixed;
top: 0;
left: 0;
z-index: -100;
height: 100%;
width: 100%;
object-fit: cover;
background-image: linear-gradient(to bottom, #eaeaea, #ababab);
background-repeat: no-repeat;
background-size: 100% 100%;
}
.icon {
fill: currentColor;
overflow: hidden;

View File

@ -1,11 +1,25 @@
// 刷新本页vuex
export function replaceState() {
let state = {}
for(let key of Object.keys(this.$store.state)) {
for (let key of Object.keys(this.$store.state)) {
let content = JSON.parse(localStorage.getItem("cherry_" + key))
if(key == 'user_info' && content == null) content = {}
if(key == 'personal_class' && content == null) content = {}
if(key == 'drawer_state' && content == null) content = false
if (key == 'user_info' && content == null) content = {}
if (key == 'personal_class' && content == null) content = {}
if (key == 'drawer_state' && content == null) content = false
if (key == 'settings' && content == null) content = {
// 隐藏周末
hide_weekend: false,
// 课表背景链接
user_bg_url: '',
// 是否开启了背景
user_bg_switch: false,
// 课程透明度
lesson_opacity: 1,
// 背景主题
user_bg_is_dark: false,
// 课程以及节数的显示方式 无 衬底 阴影 => 0 1 2
bar_show_style: 0,
}
state[key] = content
}
this.$store.replaceState(

View File

@ -21,6 +21,21 @@ export default new Vuex.Store({
personal_class: {},
// 源课表信息
row_lesson_info: null,
// 用户设置
settings: {
// 隐藏周末
hide_weekend: false,
// 课表背景链接
user_bg_url: '',
// 是否开启了背景
user_bg_switch: false,
// 课程透明度
lesson_opacity: 1,
// 背景主题
user_bg_is_dark: false,
// 课程以及节数的显示方式 无 衬底 阴影 => 0 1 2
bar_show_style: 0,
}
},
mutations: {
// 设置用户信息
@ -54,6 +69,10 @@ export default new Vuex.Store({
// 设置源课表信息
SET_ROW_LESSON_INFO(state, row_lesson_info) {
state.row_lesson_info = row_lesson_info
},
// 设置源课表信息
SET_SETTINGS(state, settings) {
state.settings = settings
}
},
actions: {
@ -96,6 +115,11 @@ export default new Vuex.Store({
setRowLessonInfo({ commit }, arg) {
commit('SET_ROW_LESSON_INFO', arg[0]);
setItem.call(arg[1])
},
// 设置课表源数据
setSettings({ commit }, arg) {
commit('SET_SETTINGS', arg[0]);
setItem.call(arg[1])
},
},
modules: {

View File

@ -19,11 +19,14 @@
</div>
</header>
<div style="height: 1.2rem;"></div>
<div class="user-bg">
<div class="bg-content" :style="userBgUrl"></div>
</div>
<template v-if="schedule">
<nav>
<nav :class="textClass">
<div
class="week-title"
v-for="i in hide_weekend? 5:7"
v-for="i in settings.hide_weekend? 5:7"
:class="highlightWeek == i%7? 'highlight':''"
:key="i"
>
@ -33,7 +36,7 @@
</nav>
<div class="main">
<v-touch :swipe-options="{direction: 'horizontal'}" @swiperight="openDrawer">
<aside>
<aside :class="textClass">
<div class="lesson-title" v-for="i in 12" :key="i">{{i}}</div>
</aside>
</v-touch>
@ -43,9 +46,9 @@
@swipeleft="swipeRight"
@swiperight="swipeLeft"
>
<div class="lesson-warp">
<div class="lesson-warp" :style="`opacity: ${settings.user_bg_switch ? settings.lesson_opacity : 1};`">
<!-- 周一至周日的列 -->
<div class="day-box" v-for="d in hide_weekend ? 5:7" :key="d">
<div class="day-box" v-for="d in settings.hide_weekend ? 5:7" :key="d">
<!-- 一天六节课 -->
<div class="lesson-box" v-for="i in 6" :key="i">
<!-- 如果所有周的这一节都没有课就是0 -->
@ -56,12 +59,12 @@
v-if="schedule.lesson[show_week-1][d-1][i-1]"
>
<p class="info">
<span :class="hide_weekend ? '' : 'long'">{{schedule.lesson[show_week-1][d-1][i-1].Lesson}}</span>
<span :class="settings.hide_weekend ? '' : 'long'">{{schedule.lesson[show_week-1][d-1][i-1].Lesson}}</span>
<br />
<span v-if="hide_weekend">{{schedule.lesson[show_week-1][d-1][i-1].Room}}</span>
<span v-if="settings.hide_weekend">{{schedule.lesson[show_week-1][d-1][i-1].Room}}</span>
<span v-else>{{schedule.lesson[show_week-1][d-1][i-1].Room.replace(/\[.+\]/, "")}}</span>
<br />
<span v-if="hide_weekend">{{schedule.lesson[show_week-1][d-1][i-1].Teacher}}</span>
<span v-if="settings.hide_weekend">{{schedule.lesson[show_week-1][d-1][i-1].Teacher}}</span>
</p>
</div>
</div>
@ -149,7 +152,7 @@ import { mapState, mapActions } from "vuex";
import { decryptMainCode } from "@/lib/aes.js";
import { interceptTime } from "@/lib/utils.js";
import { manageSchedule } from "@/lib/schedule.js";
import { Loading } from "element-ui";
import { Loading, TimeSelect } from "element-ui";
import { login } from "@/axios/api.js";
import { replaceState } from "@/lib/getStore.js";
export default {
@ -164,8 +167,6 @@ export default {
max_week: 22,
// dialog
detail: false,
//
hide_weekend: false,
//
week_day: ["周一", "周二", "周三", "周四", "周五", "周六", "周日"],
//
@ -209,7 +210,8 @@ export default {
"schedule",
"grade",
"personal_class",
"row_lesson_info"
"row_lesson_info",
"settings"
]),
//
highlightWeek: function() {
@ -223,6 +225,28 @@ export default {
} else {
return -1;
}
},
//
userBgUrl: function() {
if (!this.settings.user_bg_switch) return ''
return `background-image: url('${this.settings.user_bg_url}')`
},
//
textClass: function() {
if (!this.settings.user_bg_switch) return 'dark-word'
let res = ''
res += this.settings.user_bg_is_dark ? 'light-word' : 'dark-word'
switch (this.settings.bar_show_style) {
case 0:
break;
case 1:
res += this.settings.user_bg_is_dark ? ' light-word-matting' : ' dark-word-matting'
break;
case 2:
res += this.settings.user_bg_is_dark ? ' light-word-shadow' : ' dark-word-shadow'
break;
}
return res
}
},
methods: {
@ -233,7 +257,8 @@ export default {
"setCurrentPage",
"setDrawerState",
"setRowLessonInfo",
"setPersonalClass"
"setPersonalClass",
"setSettings"
]),
//
@ -274,6 +299,7 @@ export default {
this.show_week = lock ? this.current_week : this.show_week;
if(this.user_info.cid == '2020') this.show_week = lock ? 1 : this.show_week;
this.getDays();
this.setSetting();
return;
}
}
@ -283,6 +309,18 @@ export default {
this.$router.replace("/login");
},
setSetting() {
let settings = {
...this.settings,
user_bg_switch: true,
user_bg_url:'https://ss3.bdstatic.com/70cFv8Sh_Q1YnxGkpoWK1HF6hhy/it/u=3256812185,612138532&fm=26&gp=0.jpg',
user_bg_is_dark: true,
lesson_opacity: .7,
bar_show_style: 0,
}
this.setSettings([settings, this])
},
//
changeWeek(dirction) {
if (dirction == "left") this.swipeLeft();
@ -313,7 +351,7 @@ export default {
lessonStyle(item) {
return `background:#${this.bg_color[item.color]};color:#${
this.font_color[item.color]
}`;
};`;
},
//
@ -488,7 +526,7 @@ export default {
width: 100%;
max-width: 500px;
margin: 0 auto;
background-color: #f8f8f8;
// background-color: #f8f8f8;
min-height: 100%;
position: relative;
overflow: hidden;
@ -562,6 +600,41 @@ export default {
}
}
}
.user-bg {
position: fixed;
top: 0;
left: 0;
height: 100%;
width: 100%;
padding-top: 1.2rem;
padding-bottom: 1.3rem;
box-sizing: border-box;
z-index: -50;
.bg-content {
height: 100%;
max-width: 500px;
margin: 0 auto;
background-size: cover;
}
}
.dark-word {
color: #333;
}
.light-word {
color: #fff;
}
.dark-word-shadow {
text-shadow:1px 1px 1px #fff;
}
.light-word-shadow {
text-shadow:1px 1px 1px #000;
}
.dark-word-matting {
background: rgba($color: #fff, $alpha: .3);
}
.light-word-matting {
background: rgba($color: #000, $alpha: .3);
}
nav {
height: 1rem;
padding-left: 0.7rem;