Merge branch 'add-user-bg' into 'v3' (merge request !10)

add-user-bg
This commit is contained in:
RainSun 2020-09-13 03:35:15 +00:00
commit c54bee149b
19 changed files with 1007 additions and 134 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>
@ -9,17 +8,20 @@
<!-- 非缓存 -->
<router-view v-if="!this.$route.meta.keepAlive"></router-view>
<FooterNav></FooterNav>
<DrawerAct></DrawerAct>
</div>
</template>
<script>
import FooterNav from "@/components/FooterNav.vue";
import Drawer from "@/components/Drawer.vue";
import DrawerAct from "@/components/DrawerAct.vue";
export default {
name: "grade",
name: "App",
components: {
FooterNav,
Drawer
Drawer,
DrawerAct
}
};
</script>
@ -141,18 +143,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,59 +1,56 @@
<template>
<div class="drawer">
<div class="mask" :class="mask_class" @click="closeDrawer()" v-if="drawer_state">
<div class="w">
<!-- 抽屉主体 -->
<div class="main" :class="main_class" @click.stop>
<div class="title">
<div class="logo-box">
<img src="../assets/logo.png" alt />
</div>
<p class="app-name">Cherry</p>
<p class="version">Version 3.1</p>
</div>
<div class="list">
<!-- <div class="list-item">
<div class="drawer">
<div class="mask" :class="mask_class" @click="closeDrawer()" v-if="drawer_state">
<div class="w">
<!-- 抽屉主体 -->
<div class="main" :class="main_class" @click.stop>
<div class="title">
<div class="logo-box">
<img src="../assets/logo.png" alt />
</div>
<p class="app-name">Cherry</p>
<p class="version">Version 3.5</p>
</div>
<div class="list">
<!-- <div class="list-item">
<icon class="info" name="info"></icon>
<p>账户设置</p>
</div> -->
<div class="list-item" @click="goToGame()">
<icon class="game" name="game"></icon>
<p>课表小游戏</p>
</div>
<div class="list-item"
v-clipboard:copy="'https://canary.lacus.site'"
v-clipboard:success="onCopyUrl"
v-clipboard:error="onErrorUrl">
<icon class="game" name="canary"></icon>
<p>Canary密码本</p>
</div>
</div>
<div class="bottom-box" v-if="user_info">
<div class="logout-dialog to-show" v-if="dialog_state">
<p class="label">警告</p>
<p class="content">该操作将清除您所有的个人信息是否继续</p>
<div class="confirm-box">
<p class="cancel" @click="dialog_state = false">取消</p>
<p class="confirm" @click="logout">继续</p>
</div>
</div>
<div class="bottom-button" @click="dialog_state = true">
<icon class="logout" name="logout"></icon>
<p>退出登录</p>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="list-item" @click="goToGame()">
<icon class="game" name="game"></icon>
<p>课表小游戏</p>
</div>
<div class="list-item" @click="goToCanary()">
<icon class="game" name="canary"></icon>
<p>Canary密码本</p>
</div>
</div>
<div class="bottom-box" v-if="user_info">
<div class="logout-dialog to-show" v-if="dialog_state">
<p class="label">警告</p>
<p class="content">该操作将清除您所有的个人信息是否继续</p>
<div class="confirm-box">
<p class="cancel" @click="dialog_state = false">取消</p>
<p class="confirm" @click="logout">继续</p>
</div>
</div>
<div class="bottom-button" @click="dialog_state = true">
<icon class="logout" name="logout"></icon>
<p>退出登录</p>
</div>
</div>
</div>
</div>
</div>
</div>
</template>
<script>
import { mapState, mapActions } from "vuex";
import { mapState, mapActions } from "vuex";
import { getGradeInitData } from '@/lib/utils.js'
import { replaceState } from '@/lib/getStore.js'
export default {
name: "footerNav",
name: "Drawer",
data() {
return {
mask_class: '',
@ -66,12 +63,7 @@ export default {
},
methods: {
...mapActions(["setDrawerState","setUserInfo",'setGrade','setSchedule']),
//
init() {
// vuex
this.$store.replaceState(Object.assign(this.$store.state,JSON.parse(localStorage.getItem("cherry"))));
},
//
closeDrawer() {
this.dialog_state = false
this.mask_class = 'to-shallow'
@ -80,10 +72,8 @@ export default {
this.setDrawerState([false, this])
}, 300)
},
//
reflash() {
this.setDrawerState([false, this])
this.$router.push({ name: "login" });
goToCanary() {
window.open('https://canary.lacus.icu')
},
//
goToGame() {
@ -92,37 +82,27 @@ export default {
},
// 退
logout() {
this.setUserInfo([{}, this])
this.setGrade([null, this])
this.setSchedule([null, this])
this.closeDrawer()
localStorage.clear();
replaceState.call(this);
this.$router.replace('/login')
},
onCopyUrl(e) {
this.$message.success("网址复制成功!");
},
onErrorUrl(e) {
this.$message.success("网址复制失败!");
}
},
created() {
this.init()
},
watch: {
drawer_state: function() {
if(this.drawer_state) {
if(this.drawer_state) {
//
this.init()
this.mask_class = 'to-deep'
this.main_class = 'to-right'
}
},
},
}
};
</script>
<style scoped lang="scss" type="text/scss">
@import "../style/main";
@import "../style/main";
.drawer {
.mask {
position: fixed;
@ -326,4 +306,4 @@ export default {
opacity: 1;
}
}
</style>
</style>

View File

@ -0,0 +1,48 @@
<template>
<div class="drawer-act">
<div class="drawer-warp">
<v-touch :swipe-options="{direction: 'horizontal'}" @swiperight="openDrawer">
<div class="act"></div>
</v-touch>
</div>
</div>
</template>
<script>
import { mapState, mapActions } from "vuex";
export default {
name: "DrawerAct",
methods: {
...mapActions(["setDrawerState"]),
openDrawer() {
this.setDrawerState([true, this])
},
},
created() {
},
};
</script>
<style scoped lang="scss" type="text/scss">
@import "../style/main";
.drawer-act {
position: fixed;
top: 0;
left: 0;
width: 100%;
z-index: 50;
.drawer-warp {
max-width: 500px;
margin: 0 auto;
.act {
position: absolute;
width: 0.7rem;
height: calc(100vh);
}
}
}
</style>

View File

@ -3,25 +3,25 @@
<div class="w">
<div class="content" @click="goToAddress('/schedule')">
<i :class="current_page == 'schedule'? 'select' : ''" class="el-icon-message-solid"></i>
<p :class="current_page == 'schedule'? 'select' : ''">课表</p>
<p v-if="!settings.hide_tab_text" :class="current_page == 'schedule'? 'select' : ''">课表</p>
</div>
<div class="content" @click="goToAddress('/grade')">
<i :class="current_page == 'grade'? 'select' : ''" class="el-icon-s-claim"></i>
<p :class="current_page == 'grade'? 'select' : ''">成绩</p>
<p v-if="!settings.hide_tab_text" :class="current_page == 'grade'? 'select' : ''">成绩</p>
</div>
<div class="content" @click="goToAddress('/myaccount')">
<i :class="current_page == 'myaccount'? 'select' : ''" class="el-icon-s-custom"></i>
<p :class="current_page == 'myaccount'? 'select' : ''">我的</p>
<p v-if="!settings.hide_tab_text" :class="current_page == 'myaccount'? 'select' : ''">我的</p>
</div>
</div>
</footer>
</template>
<script>
import { mapState, mapActions } from "vuex";
import { mapState } from "vuex";
export default {
name: "footerNav",
name: "FooterNav",
computed: {
...mapState(["current_page"])
...mapState(["current_page", "settings"])
},
methods: {
goToAddress(url) {

View File

@ -3,7 +3,7 @@
</template>
<script>
export default {
name: "footerspace",
name: "FooterSpace",
data() {
return {};
}

92
src/components/Input.vue Normal file
View File

@ -0,0 +1,92 @@
<template>
<div class="input">
<label :class="{'placeholder': input_focus ? false : value ? false : true}" for="input">{{label}}</label>
<input type="text" :value="value" @change="$emit('change', $event.target.value)" @focus="input_focus = true" @blur="input_focus = false" id="input"/>
<div class="line"></div>
</div>
</template>
<script>
export default {
name: "Input",
data: () => {
return {
input_focus: false,
}
},
model: {
prop: "value",
event: "change",
},
props: {
value: {
type: String,
default: "",
},
label: {
type: String,
default: "标题",
},
},
};
</script>
<style scoped lang="scss" type="text/scss">
@import "../style/main";
.input {
display: flex;
align-items: center;
flex: 1;
height: 1.8rem;
position: relative;
label {
position: absolute;
top: 0;
left: 0;
font-size: 0.35rem;
height: 0.5rem;
line-height: 0.5rem;
color: #989898;
transition: all 0.25s;
}
.placeholder {
top: .8rem;
font-size: 0.45rem;
height: 1rem;
line-height: 1rem;
line-height: 0.5rem;
}
input {
border: none;
border-bottom: 1px #333 solid;
outline: none;
flex: 1;
font-size: 0.45rem;
height: 1rem;
line-height: 1rem;
margin-top: 0.15rem;
appearance: none;
-moz-appearance: none; /* Firefox */
-webkit-appearance: none; /* Safari 和 Chrome */
-webkit-tap-highlight-color: rgba(255, 255, 255, 0);
}
input:focus {
& + .line {
width: 100%;
}
border: none;
}
.line {
position: absolute;
width: 0;
top: 1.45rem;
height: 2px;
background: $gradualGreen;
transition: width 0.25s;
}
.spread {
width: 100%;
}
}
</style>

162
src/components/Select.vue Normal file
View File

@ -0,0 +1,162 @@
<template>
<div class="select">
<label>{{label}}</label>
<input type="text" readonly :value="input_value" :class="{'border': !open_options}"
@click="openOptions"
@keydown.down="openOptions"
@keydown.enter="openOptions"
@keydown.space="openOptions"/>
<div class="line" :class="{'spread': open_options}"></div>
<i class="el-icon-caret-bottom icon"></i>
<div class="options-table" v-if="open_options" :style="`top: ${top}rem;`">
<div class="options" v-for="(item, index) in options" @click="choseContent(item.value)" :key="index">{{item.text}}</div>
</div>
<div class="mask" v-if="open_options" @click="closeTable"></div>
</div>
</template>
<script>
export default {
name: "Select",
data: () => {
return {
open_options: false,
top: 0.2
}
},
model: {
prop: 'value',
event: 'change'
},
props: {
options: {
type: Array,
default: []
},
value: {
type: Number,
default: ''
},
label: {
type: String,
default: '标题'
}
},
computed: {
input_value: function() {
for(let item of this.options) {
if(item.value == this.value) return item.text
}
}
},
methods:{
openOptions() {
let i = -1
for(let item of this.options) {
i++
if(item.value == this.value) break
}
this.top = 0.2 - i * 1.3
this.open_options = true
},
choseContent(value) {
this.open_options = false
this.$emit('change', value)
},
closeTable() {
this.open_options = false
}
}
}
</script>
<style scoped lang="scss" type="text/scss">
@import "../style/main";
.select {
display: flex;
align-items: center;
flex: 1;
height: 1.8rem;
position: relative;
label {
position: absolute;
top: 0;
left: 0;
font-size: .35rem;
height: .5rem;
line-height: .5rem;
color: #989898;
}
input {
border: none;
cursor: pointer;
outline: none;
flex: 1;
font-size: .45rem;
height: 1rem;
line-height: 1rem;
margin-top: .15rem;
appearance:none;
-moz-appearance:none; /* Firefox */
-webkit-appearance:none; /* Safari 和 Chrome */
-webkit-tap-highlight-color: rgba(255, 255, 255, 0);
-webkit-user-select: none;
}
.border {
border-bottom: 1px #333 solid;
}
.line {
position: absolute;
width: 0;
top: 1.45rem;
height: 2px;
background: $gradualGreen;
transition: width .25s;
}
.spread {
width: 100%;
}
.icon {
position: absolute;
font-size: .4rem;
right: .2rem;
color: #989898;
}
.options-table {
position: absolute;
top: .2rem;
left: -.3rem;
background-color: #fff;
min-width: 7rem;
box-shadow: 1px 1px 15px #ababab;
padding-left: .3rem;
padding-top: .3rem;
z-index: 151;
opacity: 0;
.options {
font-size: .45rem;
height: 1rem;
line-height: 1rem;
margin-bottom: .3rem;
}
animation: toShow 0.25s ease .1s;
animation-fill-mode: forwards;
}
.mask {
position: fixed;
top: 0;
left: 0;
height: 100%;
width: 100%;
z-index: 150;
}
}
@keyframes toShow {
0% {
opacity: 0;
}
100% {
opacity: 1;
}
}
</style>

62
src/components/Slider.vue Normal file
View File

@ -0,0 +1,62 @@
<template>
<div class="slider">
<input
:value="value"
type="range"
@change="$emit('change', $event.target.value)"
max="1"
min="0"
step="0.1"
/>
</div>
</template>
<script>
export default {
name: "Slider",
model: {
prop: "value",
event: "change",
},
props: {
value: {
type: Number,
default: 1,
},
},
};
</script>
<style scoped lang="scss" type="text/scss">
@import "../style/main";
.slider {
display: flex;
align-items: center;
justify-content: center;
input {
width: 4rem;
background-size: 98% 3px;
background: $gradualGreen;
outline: none;
appearance: none;
-moz-appearance: none; /* Firefox */
-webkit-appearance: none; /* Safari 和 Chrome */
height: 3px; /*横条的高度*/
}
input[type="range"]::-webkit-slider-thumb {
width: 20px;
height: 20px;
border-radius: 50%;
background-color: #fff;
box-shadow: 0 0 4px $olive;
cursor: pointer;
appearance: none;
-moz-appearance: none; /* Firefox */
-webkit-appearance: none; /* Safari 和 Chrome */
border: 0;
}
input[type="range"]:focus {
outline: none;
}
}
</style>

View File

@ -0,0 +1,86 @@
<template>
<div class="snake-bar" :class="snack_bar_class">
<div class="warp">
<div class="content">{{msg}}</div>
</div>
</div>
</template>
<script>
export default {
name: "SnakeBar",
props: ["msg"],
data() {
return {
snack_bar_class: ""
};
},
computed: {},
methods: {
openSnackBar(content) {
this.snack_bar_class = "higher-snake-bar";
setTimeout(() => {
this.snack_bar_class = "lower-snake-bar";
}, 1000);
},
},
created() {
this.openSnackBar();
},
mounted() {},
watch: {},
beforeDestroy() {},
components: {},
activated() {}
};
</script>
<style scoped lang="scss" type="text/scss">
@import "../../style/main";
.snake-bar {
position: fixed;
left: 0;
bottom: -1.2rem;
width: 100%;
.warp {
width: 100%;
max-width: 500px;
margin: 0 auto;
height: 1.2rem;
background: $gradualGreen;
.content {
margin-left: 0.3rem;
padding-left: 0.3rem;
font-size: 0.35rem;
line-height: 1.2rem;
letter-spacing: 2px;
color: #fff;
}
}
}
.higher-snake-bar {
animation: snakeToHigh 0.5s ease;
animation-fill-mode: forwards;
}
.lower-snake-bar {
animation: snakeToLow 0.5s ease;
animation-fill-mode: forwards;
}
@keyframes snakeToHigh {
0% {
bottom: -1.2rem;
}
100% {
bottom: 0rem;
}
}
@keyframes snakeToLow {
0% {
bottom: 0rem;
}
100% {
bottom: -1.2rem;
}
}
</style>

View File

@ -0,0 +1,31 @@
import SnakeBar from './SnakeBar.vue'
import Vue from 'vue'
let SnakeBarConstructor = Vue.extend(SnakeBar)
let instance
let seed = 1
let index = 2000
let eleList = []
const install = () => {
Object.defineProperty(Vue.prototype, '$snakebar', {
get () {
let id = 'snakebar_' + seed++
const alertMsg = options => {
instance = new SnakeBarConstructor({
propsData: {msg:options}
})
index++
instance.id = id
instance.vm = instance.$mount()
document.body.appendChild(instance.vm.$el)
eleList.push(instance.vm.$el)
setTimeout(()=> {
document.body.removeChild(eleList.shift())
},1500)
instance.vm.$el.style.zIndex = index
return instance.vm
}
return alertMsg
}
})
}
export default install

View File

@ -1,11 +1,29 @@
// 刷新本页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,
// 黑暗模式
dark_mode: false,
// 隐藏tab文字
hide_tab_text: false,
}
state[key] = content
}
this.$store.replaceState(

View File

@ -33,6 +33,10 @@ Vue.use(VueTouch, {name: 'v-touch'})
import VueClipboard from "vue-clipboard2";
Vue.use(VueClipboard);
// 自己写的snakebar组件
import SnakeBar from '@/components/SnakeBar/index'
Vue.use(SnakeBar)
Vue.component('icon', Icon);
new Vue({
router,

View File

@ -59,6 +59,14 @@ const routes = [
keepAlive:false
},
},
{
path: '/personal',
name: 'Personal',
component: () => import(/* webpackChunkName: "personal" */ '../views/Personal/Personal.vue'),
meta:{
keepAlive:false
},
},
{
path: '*', // 页面不存在的情况下会跳到schedule
redirect: '/schedule',

View File

@ -21,6 +21,25 @@ 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,
// 黑暗模式
dark_mode: false,
// 隐藏tab文字
hide_tab_text: false,
}
},
mutations: {
// 设置用户信息
@ -54,6 +73,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 +119,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

@ -23,7 +23,7 @@
<div class="submit" @click="submit()">登录</div>
</div>
<div class="copyRight">
<p>Version&nbsp;3.3</p>
<p>Version&nbsp;3.5</p>
<p>Inspire Studio</p>
<p>&copy;2020 All Rights Reserved.</p>
</div>

View File

@ -4,11 +4,10 @@
<img src="../../assets/logo_nobg.png" alt="logo" />
<p>
Cherry
<span>v3.3</span>
<span>v3.5</span>
</p>
<div class="auth">By:Inspire Studio</div>
<!-- <img src="../assets/wave.gif" mode="scaleToFill" class="gif-wave"/> -->
<!-- <image src="https://raw.githubusercontent.com/weilanwl/ColorUI/master/demo/images/wave.gif" mode="scaleToFill" class="gif-wave"></image> -->
<img src="../../assets/wave.gif" mode="scaleToFill" class="gif-wave"/>
</header>
<div class="user-box shadow-warp" v-if="Object.keys(this.user_info).length != 0">
<div class="cid-box">
@ -26,9 +25,9 @@
</div>
</div>
<div class="functions-box">
<div class="item" @click="goTo('/addclass')">
<i class="el-icon-paperclip first-function-icon"></i>
<p>自定义课程</p>
<div class="item" @click="goTo('/personal')">
<i class="el-icon-s-operation first-function-icon"></i>
<p>个性化</p>
<i class="el-icon-arrow-right arrow-right"></i>
</div>
</div>
@ -47,6 +46,7 @@
coc主站地址=>
<span>cherry.lacus.site</span>
</div>
<div style="height: 1.5rem;"></div>
<FooterSpace></FooterSpace>
</div>
</template>
@ -69,7 +69,7 @@ export default {
...mapState(["user_info"])
},
methods: {
...mapActions(["setCurrentPage", "setGrade", "setSchedule", "setUserInfo"]),
...mapActions(["setCurrentPage"]),
init() {
// vuex
replaceState.call(this)
@ -77,9 +77,8 @@ export default {
},
//
logout() {
this.setUserInfo([{}, this]);
this.setGrade([null, this]);
this.setSchedule([null, this]);
localStorage.clear();
replaceState.call(this);
this.$message({
message: "本地数据清除完成",
type: "success"
@ -151,7 +150,15 @@ export default {
font-size: 0.5rem;
margin-top: 0.3rem;
font-weight: 300;
margin-bottom: 1rem;
}
.gif-wave {
position: absolute;
bottom: 0;
mix-blend-mode: screen;
height: 2rem;
width: 100%;
}
}
.user-box {

View File

@ -0,0 +1,295 @@
<template>
<div class="personal">
<header>
<div class="w">
<div class="icon-box">
<i class="el-icon-back title-icon" @click="back()"></i>
</div>
<div class="title-box">个性化</div>
</div>
</header>
<div style="height: 1.2rem;"></div>
<div class="main">
<div class="topic">课表设置</div>
<div class="option">
<icon name="firstPrize" class="option-icon"></icon>
<div class="label">隐藏周末</div>
<div class="handle-space">
<el-switch v-model="hide_weekend" active-color="#39b54a" @change="modifyConfig()"></el-switch>
</div>
</div>
<div class="option">
<icon name="firstPrize" class="option-icon"></icon>
<div class="label">开启背景图</div>
<div class="handle-space">
<el-switch v-model="user_bg_switch" active-color="#39b54a" @change="modifyConfig()"></el-switch>
</div>
</div>
<div class="option">
<icon name="firstPrize" class="option-icon"></icon>
<div class="label">深色背景适配</div>
<div class="handle-space">
<el-switch v-model="user_bg_is_dark" active-color="#39b54a" @change="modifyConfig()"></el-switch>
</div>
</div>
<div class="option">
<icon name="firstPrize" class="option-icon"></icon>
<div class="label">课表透明度</div>
<div class="handle-space">
<Slider :value="settings.lesson_opacity" @change="modifyOpacity"></Slider>
</div>
</div>
<div class="option">
<icon name="firstPrize" class="option-icon"></icon>
<Select
label="时间显示类型"
:options="bar_show_style_list"
:value="settings.bar_show_style"
@change="modifyBarShowStyle"
></Select>
</div>
<div class="option">
<icon name="firstPrize" class="option-icon"></icon>
<Input label="图片网络地址" :value="settings.user_bg_url" @change="modifyUserBgUrl" />
</div>
<div class="topic">应用设置</div>
<div class="option">
<icon name="firstPrize" class="option-icon"></icon>
<div class="label">关闭TAB文字</div>
<div class="handle-space">
<el-switch v-model="hide_tab_text" active-color="#39b54a" @change="modifyConfig()"></el-switch>
</div>
</div>
</div>
<FooterSpace></FooterSpace>
</div>
</template>
<script>
// @ is an alias to /src
import FooterSpace from "@/components/FooterSpace.vue";
import Slider from "@/components/Slider.vue";
import Select from "@/components/Select.vue";
import Input from "@/components/Input.vue";
import { mapState, mapActions } from "vuex";
import { replaceState } from "@/lib/getStore.js";
import { Loading } from "element-ui";
import { interceptTime } from "@/lib/utils.js";
export default {
name: "personal",
data() {
return {
//
hide_weekend: false,
//
user_bg_switch: false,
//
user_bg_is_dark: false,
// tab
hide_tab_text: false,
// => 0 1 2
bar_show_style: 0,
bar_show_style_list: [
{
value: 0,
text: "正常",
},
{
value: 1,
text: "衬底",
},
{
value: 2,
text: "阴影",
},
],
//
dark_mode: false,
};
},
computed: {
...mapState(["user_info", "settings"]),
},
methods: {
...mapActions(["setUserInfo", "setCurrentPage", "setSettings"]),
//
init() {
// vuex
replaceState.call(this);
// footerNav
this.setCurrentPage(["None", this]);
//
if (Object.keys(this.user_info).length != 0) {
let now = new Date().getTime(); //
if (
now - this.user_info.login_time < 1000 * 60 * 60 * 24 * 7 &&
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("用户登录时间刷新完成");
this.initData();
return;
}
}
localStorage.clear();
replaceState.call(this);
console.log("未登录拦截");
this.$router.replace("/login");
},
initData() {
this.hide_weekend = this.settings.hide_weekend;
this.user_bg_switch = this.settings.user_bg_switch;
this.user_bg_is_dark = this.settings.user_bg_is_dark;
this.bar_show_style = this.settings.bar_show_style;
this.hide_tab_text = this.settings.hide_tab_text;
},
back() {
this.$router.go(-1);
},
modifyConfig() {
let new_settings = {
...this.settings,
hide_weekend: this.hide_weekend,
user_bg_switch: this.user_bg_switch,
user_bg_is_dark: this.user_bg_is_dark,
hide_tab_text: this.hide_tab_text,
};
this.setSettings([new_settings, this]);
console.log("设置信息写入完成");
this.$snakebar('个性化设置成功')
},
modifyOpacity(e) {
let new_settings = {
...this.settings,
lesson_opacity: Number(e),
};
this.setSettings([new_settings, this]);
console.log("设置信息写入完成");
this.$snakebar('个性化设置成功')
},
modifyBarShowStyle(e) {
let new_settings = {
...this.settings,
bar_show_style: Number(e),
};
this.setSettings([new_settings, this]);
console.log("设置信息写入完成");
this.$snakebar('个性化设置成功')
},
modifyUserBgUrl(e) {
let new_settings = {
...this.settings,
user_bg_url: e,
};
this.setSettings([new_settings, this]);
console.log("设置信息写入完成");
this.$snakebar('个性化设置成功')
},
},
created() {
this.init();
},
components: {
FooterSpace,
Slider,
Select,
Input,
},
watch: {},
};
</script>
<style scoped lang="scss" type="text/scss">
@import "../../style/main";
.personal {
width: 100%;
max-width: 500px;
margin: 0 auto;
background-color: #fff;
min-height: 100%;
position: relative;
overflow: hidden;
header {
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 1.2rem;
z-index: 100;
.w {
height: 1.2rem;
width: 100%;
max-width: 500px;
margin: 0 auto;
display: flex;
align-items: center;
justify-content: center;
background-image: $gradualGreen;
color: #fff;
position: relative;
.title-box {
font-size: 0.5rem;
}
.icon-box {
height: 1.2rem;
width: 1.2rem;
display: flex;
align-items: center;
justify-content: center;
position: absolute;
top: 0;
left: 0;
.title-icon {
font-size: 0.6rem;
}
}
}
}
.main {
max-width: 425px;
margin: 0 0.7rem;
.topic {
margin-top: .5rem;
font-size: 0.35rem;
color: $green;
margin-bottom: 0.5rem;
}
.option {
display: flex;
align-items: center;
justify-content: flex-start;
min-height: 1.5rem;
.option-icon {
height: 0.6rem;
width: 0.6rem;
margin-right: 0.7rem;
}
.label {
font-size: 0.45rem;
}
.handle-space {
flex: 1;
min-height: 1.5rem;
display: flex;
align-items: center;
justify-content: flex-end;
}
}
}
}
</style>

View File

@ -3,7 +3,7 @@
<header>
<div class="w">
<template v-if="schedule">
<i class="el-icon-s-operation more" @click="openDrawer()"></i>
<i class="el-icon-plus plus" @click="goTo('/addclass')"></i>
<div class="left-box" @click="changeWeek('left')">
<i class="el-icon-arrow-left icon" v-show="show_week!==1"></i>
</div>
@ -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"
>
@ -32,20 +35,19 @@
</div>
</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>
<v-touch
class="lesson-warp"
:swipe-options="{direction: 'horizontal'}"
@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 +58,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="{'long': settings.hide_weekend}">{{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 +151,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 +166,6 @@ export default {
max_week: 22,
// dialog
detail: false,
//
hide_weekend: false,
//
week_day: ["周一", "周二", "周三", "周四", "周五", "周六", "周日"],
//
@ -209,7 +209,8 @@ export default {
"schedule",
"grade",
"personal_class",
"row_lesson_info"
"row_lesson_info",
"settings"
]),
//
highlightWeek: function() {
@ -223,6 +224,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 +256,8 @@ export default {
"setCurrentPage",
"setDrawerState",
"setRowLessonInfo",
"setPersonalClass"
"setPersonalClass",
"setSettings"
]),
//
@ -313,13 +337,18 @@ export default {
lessonStyle(item) {
return `background:#${this.bg_color[item.color]};color:#${
this.font_color[item.color]
}`;
};`;
},
//
goToGame() {
this.$router.push("/game");
},
//
goTo(url) {
this.$router.push(url);
},
//
getCurrentWeek() {
@ -358,11 +387,6 @@ export default {
}
},
//
openDrawer() {
this.setDrawerState([true, this]);
},
//
reflash() {
if(this.user_info && this.user_info.cid == '2020') {
@ -488,7 +512,7 @@ export default {
width: 100%;
max-width: 500px;
margin: 0 auto;
background-color: #f8f8f8;
// background-color: #f8f8f8;
min-height: 100%;
position: relative;
overflow: hidden;
@ -545,7 +569,7 @@ export default {
.week-box {
font-size: 0.5rem;
}
.more {
.plus {
font-size: 0.6rem;
position: absolute;
left: 0.3rem;
@ -562,6 +586,43 @@ 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;
background-repeat: no-repeat;
background-position: center top;
}
}
.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;