update login_time and rewrite schedule

This commit is contained in:
RainSun 2020-05-29 14:02:20 +08:00
parent a9e730331c
commit 41ddb89ef3
8 changed files with 127 additions and 40 deletions

View File

@ -35,4 +35,6 @@ See [Configuration Reference](https://cli.vuejs.org/config/).
## 本地缓存
* `localStorage.setItem("cherry",JSON.stringify(this.$store.state))`
* `this.$store.replaceState(Object.assign(this.$store.state,JSON.parse(localStorage.getItem("cherry"))));`
* `this.$store.replaceState(Object.assign(this.$store.state,JSON.parse(localStorage.getItem("cherry"))));`
* 旋转色值filter: hue-rotate(290deg);

View File

@ -2,8 +2,8 @@ import axios from 'axios'
export const api = axios.create({
// baseURL: 'https://beta.powerrain.cn/api/',
// baseURL: 'https://coc.powerrain.cn/api/',
baseURL: window.location.origin + '/api/',
baseURL: 'https://coc.powerrain.cn/api/',
// baseURL: window.location.origin + '/api/',
// baseURL: 'http://beta.lacus.site' + '/api/',
//baseURL: 'http://127.0.0.1:5000/api',
headers: {

View File

@ -9,7 +9,7 @@
<img src="../assets/logo.png" alt />
</div>
<p class="app-name">Cherry</p>
<p class="version">Version 3.0</p>
<p class="version">Version 3.1</p>
</div>
<div class="list">
<!-- <div class="list-item">

35
src/lib/schedule.js Normal file
View File

@ -0,0 +1,35 @@
// 处理课表
export function manageSchedule(all_lesson) {
// 处理完的课表
let after_process = []
// 遍历
for(let week = 0; week < 22; week++) {
// 周
after_process.push([])
for(let day = 0; day < 7; day++) {
// 日
after_process[week].push([])
for(let lesson = 0; lesson < 6; lesson++) {
// 节
let after_process_lesson = undefined
let cache = []
if(all_lesson[day][lesson]) {
// 这节课有内容
for(let cur_lesson of all_lesson[day][lesson]) {
if(cur_lesson.Time_split[week+1]){
cache.push(cur_lesson)
}
}
}
if(cache.length !== 0) {
// 里边有课程
after_process_lesson = cache[0]
cache.shift()
after_process_lesson.hide = cache
}
after_process[week][day].push(after_process_lesson)
}
}
}
return after_process
}

View File

@ -85,4 +85,4 @@ export function getGameInitData() {
}]
}
export var interceptTime = 0
export var interceptTime = 1590584094308

View File

@ -120,6 +120,7 @@ import GradeCard from "./components/GradeCard.vue";
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 { login } from "@/axios/api.js";
@ -168,8 +169,11 @@ export default {
this.user_info.login_time > interceptTime
) {
// 7
//
// activated使keepalive
//
let user_info = this.user_info;
user_info.login_time = new Date().getTime();
this.setUserInfo([user_info, this]);
console.log("用户登录时间刷新完成");
if (this.grade) {
//grade
this.split = this.grade.split;
@ -233,6 +237,9 @@ export default {
user_info.login_time = new Date().getTime();
let grade = data.grade ? data.grade : this.grade;
let schedule = data.schedule ? data.schedule : this.schedule;
if(schedule) {
schedule.lesson = manageSchedule(schedule.lesson)
}
// localStorage
this.setUserInfo([user_info, this]);
this.setGrade([grade, this]);
@ -243,6 +250,11 @@ export default {
message: "信息刷新成功",
type: "success"
});
},
//
open(url) {
window.open(url)
}
},
created() {

View File

@ -18,7 +18,7 @@
</div>
<div class="submit-box"><div class="submit" @click="submit()">登录</div></div>
<div class="copyRight">
<p>Version&nbsp;3.0</p>
<p>Version&nbsp;3.1</p>
<p>Inspire Studio</p>
<p>&copy;2020 All Rights Reserved.</p>
</div>
@ -43,6 +43,7 @@ import { login } from '@/axios/api.js';
import { Loading } from 'element-ui';
import FooterSpace from '@/components/FooterSpace.vue';
import { encryptMainCode } from '@/lib/aes.js'
import { manageSchedule } from "@/lib/schedule.js";
export default {
name: 'login',
@ -121,6 +122,9 @@ export default {
};
let grade = data.grade ? data.grade : this.grade
let schedule = data.schedule ? data.schedule : this.schedule
if(schedule) {
schedule.lesson = manageSchedule(schedule.lesson)
}
// localStorage
this.setUserInfo([user_info, this]);
this.setGrade([grade, this]);
@ -137,7 +141,7 @@ export default {
//
turnToHome() {
this.$router.replace('/');
this.$router.replace({path: '/', query: {from_login: true}});
},
// qq

View File

@ -32,13 +32,10 @@
</div>
</nav>
<div class="main">
<v-touch
:swipe-options="{direction: 'horizontal'}"
@swiperight="openDrawer"
>
<aside>
<div class="lesson-title" v-for="i in 12" :key="i">{{i}}</div>
</aside>
<v-touch :swipe-options="{direction: 'horizontal'}" @swiperight="openDrawer">
<aside>
<div class="lesson-title" v-for="i in 12" :key="i">{{i}}</div>
</aside>
</v-touch>
<v-touch
class="lesson-warp"
@ -47,28 +44,23 @@
@swiperight="swipeLeft"
>
<div class="lesson-warp">
<!-- 周一至周日的列 -->
<div class="day-box" v-for="d in hide_weekend ? 5:7" :key="d">
<!-- 一天六节课 -->
<div class="lesson-box" v-for="i in 6" :key="i">
<template
v-if="schedule && schedule.lesson[d-1][i-1] !== 0"
<!-- 如果所有周的这一节都没有课就是0 -->
<div
class="lesson"
:style="lessonStyle(schedule.lesson[show_week-1][d-1][i-1])"
@click="openDialog(schedule.lesson[show_week-1][d-1][i-1])"
v-if="schedule.lesson[show_week-1][d-1][i-1]"
>
<template v-for="(item, index) in schedule.lesson[d-1][i-1]">
<template v-if="item.Time_split[show_week]">
<div
class="lesson"
:style="lessonStyle(item)"
:key="index"
@click="openDialog(item)"
>
<p class="info">
{{item.Lesson}}
<br />
{{item.Room.replace(/\[.+\]/, "")}}
</p>
</div>
</template>
</template>
</template>
<p class="info">
{{schedule.lesson[show_week-1][d-1][i-1].Lesson}}
<br />
{{schedule.lesson[show_week-1][d-1][i-1].Room.replace(/\[.+\]/, "")}}
</p>
</div>
</div>
</div>
</div>
@ -100,6 +92,25 @@
任课教师
<span>{{detail.Teacher}}</span>
</p>
<div class="more-box" v-for="(lesson, index) in detail.hide" :key="index">
<div class="line"></div>
<p>
课程名
<span>{{lesson.Lesson}}</span>
</p>
<p>
周数
<span>{{lesson.Time}}</span>
</p>
<p>
上课地点
<span>{{lesson.Room}}</span>
</p>
<p>
任课教师
<span>{{lesson.Teacher}}</span>
</p>
</div>
</div>
</div>
</div>
@ -126,6 +137,7 @@ import FooterSpace from "@/components/FooterSpace.vue";
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 { login } from "@/axios/api.js";
@ -178,7 +190,7 @@ export default {
};
},
computed: {
...mapState(["user_info", "current_page", "schedule"]),
...mapState(["user_info", "current_page", "schedule", "grade"]),
//
highlightWeek: function() {
if (this.show_week == this.current_week) {
@ -203,6 +215,9 @@ export default {
//
if (this.init_lock) return;
this.init_lock = lock;
if (this.$route.query.from_login) {
this.init_lock = true;
}
// vuex
this.$store.replaceState(
Object.assign(
@ -227,15 +242,20 @@ export default {
this.user_info.login_time > interceptTime
) {
// 7
//
let user_info = this.user_info;
user_info.login_time = new Date().getTime();
this.setUserInfo([user_info, this]);
console.log("用户登录时间刷新完成");
//
// activated使keepalive
this.getCurrentWeek();
// activated使keepalive
this.show_week = lock ? this.current_week : this.show_week;
this.getDays();
return;
}
}
console.log('未登录拦截')
console.log("未登录拦截");
this.setUserInfo([{}, this]);
this.$router.replace("/login");
},
@ -361,6 +381,9 @@ export default {
user_info.login_time = new Date().getTime();
let grade = data.grade ? data.grade : this.grade;
let schedule = data.schedule ? data.schedule : this.schedule;
if (schedule) {
schedule.lesson = manageSchedule(schedule.lesson);
}
// localStorage
this.setUserInfo([user_info, this]);
this.setGrade([grade, this]);
@ -548,7 +571,6 @@ export default {
.w {
width: 70%;
max-width: 350px;
height: 5rem;
background: #fff;
border-radius: 0.1rem;
overflow: hidden;
@ -575,11 +597,12 @@ export default {
}
}
.dialog-main {
height: 4rem;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
padding-top: 0.3rem;
padding-bottom: 0.6rem;
p {
margin-bottom: 0.2rem;
text-align: center;
@ -589,6 +612,17 @@ export default {
color: $red;
}
}
p:first-of-type {
margin-top: 0.3rem;
}
.line {
height: 1px;
background: #eee;
width: 100%;
}
.more-box {
width: 100%;
}
}
}
}