修改:网站样式

This commit is contained in:
jmal 2020-11-09 17:59:59 +08:00
parent 6ee799c842
commit 345be49633
12 changed files with 179 additions and 63 deletions

View File

@ -1,6 +1,6 @@
<template> <template>
<div id="app"> <div id="app">
<router-view /> <router-view></router-view>
</div> </div>
</template> </template>

View File

@ -64,19 +64,19 @@
this.throttledScrollHandler = throttle(300, this.onScroll); this.throttledScrollHandler = throttle(300, this.onScroll);
this.container.addEventListener('scroll', this.throttledScrollHandler); this.container.addEventListener('scroll', this.throttledScrollHandler);
window.onbeforeunload = function () { // window.onbeforeunload = function () {
let scrollPos; // let scrollPos;
if (typeof window.pageYOffset != 'undefined') { // if (typeof window.pageYOffset != 'undefined') {
scrollPos = window.pageYOffset; // scrollPos = window.pageYOffset;
} // }
else if (typeof document.compatMode != 'undefined' && document.compatMode !== 'BackCompat') { // else if (typeof document.compatMode != 'undefined' && document.compatMode !== 'BackCompat') {
scrollPos = document.documentElement.scrollTop; // scrollPos = document.documentElement.scrollTop;
} // }
else if (typeof document.body != 'undefined') { // else if (typeof document.body != 'undefined') {
scrollPos = document.body.scrollTop; // scrollPos = document.body.scrollTop;
} // }
document.cookie = "scrollTop=" + scrollPos; //存储滚动条位置到cookies中 // document.cookie = "scrollTop=" + scrollPos; //存储滚动条位置到cookies中
} // }
}, },
@ -103,6 +103,9 @@
this.scrollToTop(); this.scrollToTop();
this.$emit('click', e); this.$emit('click', e);
}, },
nextPageScrollTop() {
this.el.scrollTop = document.body.clientHeight * 0.7 - 150
},
scrollToTop() { scrollToTop() {
const el = this.el; const el = this.el;
const beginTime = Date.now(); const beginTime = Date.now();

View File

@ -1,7 +1,10 @@
<template> <template>
<section class="app-main"> <section class="app-main">
<transition name="fade-transform" mode="out-in"> <transition name="fade-transform" mode="out-in">
<router-view :key="key" /> <keep-alive v-if="$route.meta.keepAlive">
<router-view :key="key" />
</keep-alive>
<router-view v-else :key="key" />
</transition> </transition>
</section> </section>
</template> </template>

View File

@ -200,6 +200,8 @@ export const constantRoutes = [
path: '', path: '',
name: 'article', name: 'article',
component: () => import('@/views/public/article/index'), component: () => import('@/views/public/article/index'),
hidden: true,
meta: { keepAlive: true }
} }
] ]
}, },
@ -209,7 +211,7 @@ export const constantRoutes = [
children: [ children: [
{ {
path: `${document.location.protocol}//${window.location.host}/articles`, path: `${document.location.protocol}//${window.location.host}/articles`,
meta: { title: '关联博客', icon: 'link' } meta: { title: '关联博客', icon: 'link', keepAlive: true }
} }
] ]
}, },
@ -261,7 +263,7 @@ export const constantRoutes = [
path: '', path: '',
name: 'articles', name: 'articles',
component: () => import('@/views/public/articles/index'), component: () => import('@/views/public/articles/index'),
meta: { title: '文档列表', icon: 'md-list' } meta: { title: '文档列表', icon: 'md-list', keepAlive: true }
} }
] ]
}, },
@ -330,7 +332,13 @@ export const dynamicRouters = [
const createRouter = () => new Router({ const createRouter = () => new Router({
mode: 'history', // require service support mode: 'history', // require service support
scrollBehavior: () => ({ y: 0 }), // scrollBehavior (to, from, savedPosition) {
// if (savedPosition) {
// return savedPosition
// } else {
// return { x: 0, y: 0 }
// }
// },
routes: constantRoutes routes: constantRoutes
}) })

View File

@ -59,7 +59,7 @@
@media not all, screen and (-webkit-min-device-pixel-ratio: 1.5), not all, not all { @media not all, screen and (-webkit-min-device-pixel-ratio: 1.5), not all, not all {
.blog-description.font-mono { .blog-description.font-mono {
font-family: Consolas,Menlo,Monaco,"lucida console","Liberation Mono","Courier New","andale mono",monospaceX,monospace,sans-serif; font-family: Consolas,Menlo,Monaco,"lucida console","Liberation Mono","Courier New","andale mono",monospaceX,monospace,sans-serif;
font-size: 1.1125rem; font-size: 1rem;
} }
} }
@ -76,9 +76,7 @@
} }
@media (min-width: 576px) { @media (min-width: 576px) {
.navbar>.container-fluid {
max-width: 540px;
}
} }
@media screen and (max-width: 768px) { @media screen and (max-width: 768px) {
@ -88,6 +86,10 @@
margin-bottom: .5rem; margin-bottom: .5rem;
} }
//.blog-description {
// font-size: .8125rem;
//}
.cover-wrapper .cover .cover-body { .cover-wrapper .cover .cover-body {
padding-bottom: 68px; padding-bottom: 68px;
.title { .title {
@ -102,9 +104,7 @@
} }
@media (min-width: 768px){ @media (min-width: 768px){
.navbar>.container-fluid {
max-width: 720px;
}
} }
@media (min-width: 992px) { @media (min-width: 992px) {

View File

@ -218,6 +218,12 @@
transform: translateY(-100%); transform: translateY(-100%);
} }
.animateLeft {
transform: translateX(-10rem);
}
.animateRight {
transform: translateX(0rem);
}
.body-wrapper { .body-wrapper {
position: relative; position: relative;
@ -500,19 +506,19 @@
/deep/ .right-menu > div.titleList { /deep/ .right-menu > div.titleList {
.h-1 { .h-1 {
padding-left: 10px; padding-left: 10px;
font-size: 1.3rem; font-size: 1.125rem;
} }
.h-2 { .h-2 {
padding-left: 20px; padding-left: 20px;
font-size: 1.25rem; font-size: 1.1rem;
} }
.h-3 { .h-3 {
padding-left: 30px; padding-left: 30px;
font-size: 1.125rem; font-size: 1rem;
} }
.h-4 { .h-4 {
padding-left: 40px; padding-left: 40px;
font-size: 0.95rem; font-size: 0.925rem;
} }
.h-5 { .h-5 {
padding-left: 50px; padding-left: 50px;
@ -663,10 +669,11 @@
#toggle-nav { #toggle-nav {
display: none; display: none;
position: fixed;
top: .625rem; top: .625rem;
left: .625rem; left: .625rem;
z-index: 891; font-size: .75rem;
position: fixed;
z-index: 899;
-webkit-transition: 0.5s ease all; -webkit-transition: 0.5s ease all;
-moz-transition: 0.5s ease all; -moz-transition: 0.5s ease all;
-ms-transition: 0.5s ease all; -ms-transition: 0.5s ease all;
@ -675,10 +682,10 @@
} }
#sidebar-nav { #sidebar-nav {
width: 20rem; width: 17.5rem;
height: 100%; height: 100%;
position: absolute; position: fixed;
left: -20rem; left: -17.5rem;
top: 0; top: 0;
bottom: 0; bottom: 0;
overflow-y: auto; overflow-y: auto;
@ -748,5 +755,9 @@
} }
#toggle-nav { #toggle-nav {
display: block; display: block;
.nav-button {
backdrop-filter: saturate(180%) blur(20px);
background-color: #ffffffb3;
}
} }
} }

View File

@ -1,5 +1,5 @@
<template> <template>
<div> <div v-wechat-title="'编辑'+filename">
<dir-tree ref="dirTree"> <dir-tree ref="dirTree">
<el-button slot="footer" size="small" type="primary" @click="confirmSelectDir">确 定</el-button> <el-button slot="footer" size="small" type="primary" @click="confirmSelectDir">确 定</el-button>
</dir-tree> </dir-tree>

View File

@ -53,9 +53,14 @@ export default {
setting.operatingButtons.split(/[\n]/).forEach(button => { setting.operatingButtons.split(/[\n]/).forEach(button => {
let operatingButton = {} let operatingButton = {}
const splitIndex = button.indexOf(":") const splitIndex = button.indexOf(":")
operatingButton.fontHtml = button.substring(0, splitIndex) const ihtml = button.substring(0, splitIndex)
// 获取标签里的内容
let regLabel = /[^><]+(?=<\/i>)/img
const title = ihtml.match(regLabel)
operatingButton.title = title ? title[0] : ''
// 去掉标签里的内容
operatingButton.fontHtml = ihtml.replace(regLabel, '')
operatingButton.url = button.substring(splitIndex + 1, button.length) operatingButton.url = button.substring(splitIndex + 1, button.length)
operatingButton.title = button.match(/fa-(\S*?)"/)[1]
this.operatingButtons.push(operatingButton) this.operatingButtons.push(operatingButton)
}) })
} }

View File

@ -1,7 +1,7 @@
<template> <template>
<div> <div>
<div id="toggle-nav"> <div id="toggle-nav">
<el-button round @click="toggle">MENU</el-button> <el-button class="nav-button" round size="small" @click="toggle">MENU</el-button>
</div> </div>
<div id="sidebar-nav"> <div id="sidebar-nav">
<div class="author navbar-header"> <div class="author navbar-header">
@ -59,9 +59,14 @@ export default {
setting.operatingButtons.split(/[\n]/).forEach(button => { setting.operatingButtons.split(/[\n]/).forEach(button => {
let operatingButton = {} let operatingButton = {}
const splitIndex = button.indexOf(":") const splitIndex = button.indexOf(":")
operatingButton.fontHtml = button.substring(0, splitIndex) const ihtml = button.substring(0, splitIndex)
// 获取标签里的内容
let regLabel = /[^><]+(?=<\/i>)/img
const title = ihtml.match(regLabel)
operatingButton.title = title ? title[0] : ''
// 去掉标签里的内容
operatingButton.fontHtml = ihtml.replace(regLabel, '')
operatingButton.url = button.substring(splitIndex + 1, button.length) operatingButton.url = button.substring(splitIndex + 1, button.length)
operatingButton.title = button.match(/fa-(\S*?)"/)[1]
this.operatingButtons.push(operatingButton) this.operatingButtons.push(operatingButton)
}) })
} }
@ -77,9 +82,9 @@ export default {
toggleNav.style.transform = '' toggleNav.style.transform = ''
sidebarNav.style.transform = '' sidebarNav.style.transform = ''
} else { } else {
body.style.transform = 'translateX(20rem)' body.style.transform = 'translateX(17.5rem)'
toggleNav.style.transform = 'translateX(17.5rem)' toggleNav.style.transform = 'translateX(14.5rem)'
sidebarNav.style.transform = 'translateX(20rem)' sidebarNav.style.transform = 'translateX(17.5rem)'
} }
}, },
} }

View File

@ -6,7 +6,7 @@
<al-back-top></al-back-top> <al-back-top></al-back-top>
<!--SideBar menu--> <!--SideBar menu-->
<SidebarNav/> <SidebarNav :setting="userSetting"/>
<div id="body"> <div id="body">
<div id="top" class="animateIn"> <div id="top" class="animateIn">
@ -20,6 +20,9 @@
<div class="blog-description font-mono"> <div class="blog-description font-mono">
<a itemprop="name" href="https://www.jmal.top/author/1/" rel="author">{{file.username}}</a> <a itemprop="name" href="https://www.jmal.top/author/1/" rel="author">{{file.username}}</a>
· {{file.uploadDate}} · {{file.uploadDate}}
<span v-if="isEditor">
· <a :href="'/markdown/editor?id='+file.id" target="_blank">编辑</a>
</span>
</div> </div>
</div> </div>
</div> </div>
@ -85,7 +88,8 @@ export default {
tocMaxHeight: 500, tocMaxHeight: 500,
befterScrollTop: 0, befterScrollTop: 0,
maxMenuHeight: document.documentElement.clientHeight - 155, maxMenuHeight: document.documentElement.clientHeight - 155,
top: 70 top: 70,
isEditor : false,
} }
}, },
mounted() { mounted() {
@ -99,6 +103,17 @@ export default {
that.maxMenuHeight= document.documentElement.clientHeight - 155 that.maxMenuHeight= document.documentElement.clientHeight - 155
} }
}, },
// beforeRouteLeave(to, from, next) {
// to.meta.keepAlive = true;
// next();
// },
activated() {
console.log('activated', 'article')
},
deactivated() {
console.log('deactivated')
// this.scrollTop = document.documentElement.scrollTop || document.body.scrollTop
},
methods: { methods: {
getSetting() { getSetting() {
getSetting({userId: this.$store.state.user.userId}).then((res) => { getSetting({userId: this.$store.state.user.userId}).then((res) => {
@ -130,6 +145,9 @@ export default {
mark: this.$route.query.mark mark: this.$route.query.mark
}).then((res) => { }).then((res) => {
this.file = res.data this.file = res.data
if(this.file.userId === this.$store.state.user.userId) {
this.isEditor = true
}
const filename = res.data.name const filename = res.data.name
this.pageTitle = filename.substring(0,filename.length - res.data.suffix.length-1) this.pageTitle = filename.substring(0,filename.length - res.data.suffix.length-1)
this.content = res.data.contentText this.content = res.data.contentText
@ -156,6 +174,8 @@ export default {
a[i] = a[i].replace(/id="/g, 'href="#') a[i] = a[i].replace(/id="/g, 'href="#')
if (i ===0 && a[i].indexOf('h1') !== -1) { if (i ===0 && a[i].indexOf('h1') !== -1) {
a[i] = '<li first class="h-1">' + a[i].replace(/<h1>|<\/h1>/g, '') + '</li>' a[i] = '<li first class="h-1">' + a[i].replace(/<h1>|<\/h1>/g, '') + '</li>'
}else if (a[i].indexOf('h1') !== -1) {
a[i] = '<li first class="pl h-1">' + a[i].replace(/<h1>|<\/h1>/g, '') + '</li>'
}else if (a[i].indexOf('h2') !== -1) { }else if (a[i].indexOf('h2') !== -1) {
a[i] = '<li class="pl h-2">' + a[i].replace(/<h2>|<\/h2>/g, '') + '</li>' a[i] = '<li class="pl h-2">' + a[i].replace(/<h2>|<\/h2>/g, '') + '</li>'
}else if (a[i].indexOf('h3') !== -1) { }else if (a[i].indexOf('h3') !== -1) {
@ -181,13 +201,27 @@ export default {
let beforeScrollTop = document.documentElement.scrollTop; let beforeScrollTop = document.documentElement.scrollTop;
let fn = fn || function (direction) { let fn = fn || function (direction) {
// 判断是上滑显示,下滑隐藏 // 判断是上滑显示,下滑隐藏
const top = $('#top')
const toogleNav = $('#toggle-nav')
const body = document.getElementById("body")
if(direction === 'down'){ if(direction === 'down'){
$('#top').removeClass('animateIn') top.removeClass('animateIn')
$('#top').addClass('animateOut') top.addClass('animateOut')
toogleNav.removeClass('animateRight')
toogleNav.addClass('animateLeft')
if(body.style.transform.length > 0) {
document.getElementById("sidebar-nav").style.transform = ''
body.style.transform = ''
document.getElementById("toggle-nav").style.transform = ''
}
} }
if(direction === 'up'){ if(direction === 'up'){
$('#top').removeClass('animateOut') top.removeClass('animateOut')
$('#top').addClass('animateIn') top.addClass('animateIn')
toogleNav.removeClass('animateLeft')
toogleNav.addClass('animateRight')
} }
}; };

View File

@ -3,7 +3,7 @@
<transition name="fade"> <transition name="fade">
<al-loading v-if="isLoading"></al-loading> <al-loading v-if="isLoading"></al-loading>
</transition> </transition>
<al-back-top></al-back-top> <al-back-top ref="alBackTop"></al-back-top>
<SidebarNav :setting="userSetting"/> <SidebarNav :setting="userSetting"/>
@ -34,7 +34,7 @@
<section class="meta"> <section class="meta">
<div class="meta" id="header-meta"> <div class="meta" id="header-meta">
<h2 class="title"> <h2 class="title">
<a :href="$route.path+'/article?mark='+article.id">{{article.name}}</a> <router-link :to="$route.path+'/article?mark='+article.id">{{article.name}}</router-link>
</h2> </h2>
<div class="new-meta-box"> <div class="new-meta-box">
<div class="new-meta-item author"> <div class="new-meta-item author">
@ -46,7 +46,7 @@
<div class="new-meta-item date"> <div class="new-meta-item date">
<a class="notlink"> <a class="notlink">
<svg-icon icon-class="release"></svg-icon> <svg-icon icon-class="release"></svg-icon>
<p>发布于 {{article.uploadTime}}</p> <p>发布于 {{article.uploadDate}}</p>
</a> </a>
</div> </div>
</div> </div>
@ -54,15 +54,25 @@
</div> </div>
</section> </section>
<section class="article typo"> <section class="article typo">
<a :href="$route.path+'/article?mark='+article.id"> <router-link :to="$route.path+'/article?mark='+article.id">
<div class="article-entry" itemprop="articleBody"> <div class="article-entry" itemprop="articleBody">
<p><img class="blog-background articles-list" :src="article.cover" onerror="this.src='https://images.unsplash.com/photo-1582230587856-7fec01506148?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=800&q=60'"/></p> <p><img v-if="article.cover" class="blog-background articles-list" :src="article.cover" onerror="this.src='https://images.unsplash.com/photo-1582230587856-7fec01506148?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=800&q=60'"/></p>
</div> </div>
</a> </router-link>
</section> </section>
</article> </article>
</div> </div>
</section> </section>
<el-pagination
style="text-align: center"
:hide-on-single-page="true"
:current-page.sync="pagination.pageIndex"
:page-sizes="pagination.pageSizes"
:page-size="pagination.pageSize"
:total="pagination.total"
@current-change="currentChange"
layout="prev, pager, next">
</el-pagination>
</el-main> </el-main>
</div> </div>
</div> </div>
@ -92,14 +102,40 @@ import { getSetting } from '@/api/user'
articleList: [], articleList: [],
backImageSrc: "~@/assets/img/widget-img1.jpg", backImageSrc: "~@/assets/img/widget-img1.jpg",
userSetting: {}, userSetting: {},
pagination: {
pageIndex: this.$route.query.page ? parseInt(decodeURI(this.$route.query.page)) : 1,
pageSize: 10,
total: 0,
},
scrollTop: 0
} }
}, },
mounted() { mounted() {
this.getSetting() this.getSetting()
this.getMarkDown() this.getMarkDown()
const that = this console.log('mounted')
window.onresize = function() { },
} // beforeRouteEnter (to, from, next) {
// console.log('beforeRouteEnter')
// next(vm => {
// console.log(vm.scrollTop)
// document.body.scrollTop = vm.scrollTop
// })
// },
// // beforeRouteUpdate (to, from, next) {
// // console.log('beforeRouteUpdate')
// // next()
// // },
// beforeRouteLeave(to, from, next) {
// to.meta.keepAlive = false;
// next();
// },
activated() {
console.log('activated',this.scrollTop)
},
deactivated() {
console.log('deactivated')
// this.scrollTop = document.documentElement.scrollTop || document.body.scrollTop
}, },
methods: { methods: {
getSetting() { getSetting() {
@ -131,13 +167,18 @@ import { getSetting } from '@/api/user'
else else
return null; return null;
}, },
onScroll() { currentChange() {
this.$router.push(`?page=${this.pagination.pageIndex}`)
this.getMarkDown()
this.$refs.alBackTop.nextPageScrollTop()
}, },
getMarkDown() { getMarkDown() {
markdownApi.getMarkdown().then((res) => { markdownApi.getMarkdown({pageIndex: this.pagination.pageIndex, pageSize: this.pagination.pageSize}).then((res) => {
this.articleList = res.data this.articleList = res.data
this.pagination.total = res.count
this.$nextTick(() => { this.$nextTick(() => {
this.isLoading = false this.isLoading = false
this.pagination.pageIndex = parseInt(decodeURI(this.$route.query.page))
}) })
}) })
}, },

View File

@ -27,8 +27,14 @@
<span class="instruction">配置网站的 Logo,该选项仅作用于顶部导航条</span> <span class="instruction">配置网站的 Logo,该选项仅作用于顶部导航条</span>
<div class="config-itme-label">导航栏操作按钮:</div> <div class="config-itme-label">导航栏操作按钮:</div>
<el-input :autosize="{ minRows: 4, maxRows: 6}" type="textarea" width="100%" v-model="form.operatingButtons"></el-input> <el-input type="textarea" width="100%" v-model="form.operatingButtons" :autosize="{ minRows: 4, maxRows: 6 }" ></el-input>
<span class="instruction">一个操作按钮包含两个部分:<a href="https://fontawesome.com/icons?d=gallery" target="_blank">Font-awesome</a>图标标签和链接,使用':'隔开。列如:{{example}}:https://github.com/jamebal</span> <span class="instruction">
一个操作按钮包含两个部分:
<a href="https://fontawesome.com/icons?d=gallery" target="_blank">Font-awesome</a>
图标标签和链接,使用':'隔开(标签里的内容为该图标的简述)。
<br>
列如:{{example}}:https://github.com/jamebal (建议不超过5项)
</span>
</el-collapse-item> </el-collapse-item>
</el-collapse> </el-collapse>
</el-card> </el-card>
@ -46,7 +52,7 @@ export default {
data() { data() {
return { return {
activeNames: ['1'], activeNames: ['1'],
example: '<i class="fab fa-github"></i>', example: '<i class="fab fa-github">github</i>',
form: { form: {
backgroundSite: '', backgroundSite: '',
backgroundTextSite: '', backgroundTextSite: '',