From 2f5e30709177d27d37efa24ae4761e65257d0d02 Mon Sep 17 00:00:00 2001 From: journey-ad Date: Tue, 19 Dec 2023 01:51:03 +0800 Subject: [PATCH] =?UTF-8?q?to:=20=E5=AE=8C=E5=96=84=E4=B8=80=E4=BA=9B?= =?UTF-8?q?=E7=BB=86=E8=8A=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/layouts/MainLayout.vue | 4 +- src/router/index.js | 5 +- src/utils/index.js | 40 +++++ src/views/Artwork/components/ImageView.vue | 10 +- src/views/Novel/chapter.vue | 169 ++++++++++++--------- src/views/Search/index.vue | 2 +- src/views/Setting/index.vue | 9 ++ vue.config.js | 10 ++ 8 files changed, 172 insertions(+), 77 deletions(-) create mode 100644 src/utils/index.js diff --git a/src/layouts/MainLayout.vue b/src/layouts/MainLayout.vue index 1f227657..db43f2dc 100644 --- a/src/layouts/MainLayout.vue +++ b/src/layouts/MainLayout.vue @@ -32,7 +32,9 @@ export default { watch: { showNav: { handler(val) { - this.$root.$el.classList[val ? "add" : "remove"]("show-nav"); + this.$nextTick(() => { + this.$root.$el.classList[val ? "add" : "remove"]("show-nav"); + }); }, immediate: true, }, diff --git a/src/router/index.js b/src/router/index.js index c0ce810a..4e2b0c72 100644 --- a/src/router/index.js +++ b/src/router/index.js @@ -1,6 +1,6 @@ import Vue from 'vue' import VueRouter from 'vue-router' -// import Home from '../views/Home.vue' +import { setThemeColor } from '@/utils'; import BaseLayout from '@/layouts/BaseLayout' import MainLayout from '@/layouts/MainLayout' @@ -103,6 +103,9 @@ const router = new VueRouter({ router.beforeEach((to, from, next) => { document.title = to.meta.title || 'pixiv-viewer' + + setThemeColor(to.meta.themeColor || '#fff') + next() }) diff --git a/src/utils/index.js b/src/utils/index.js new file mode 100644 index 00000000..ddce6f9a --- /dev/null +++ b/src/utils/index.js @@ -0,0 +1,40 @@ +export const setThemeColor = (color) => { + if (!color) return + + let metaThemeColor = document.querySelector('meta[name="theme-color"]') + + if (!metaThemeColor) { + metaThemeColor = document.createElement('meta') + metaThemeColor.setAttribute('name', 'theme-color') + document.head.appendChild(metaThemeColor) + } + + metaThemeColor.setAttribute('content', color) +} + +export const dateFormat = (ts, fmt = 'yyyy-MM-dd hh:mm:ss') => { + if (!ts) ts = new Date() + + if (typeof ts === 'number' && ts.toString().length === 10) { + ts *= 1000 + } + + const date = ts instanceof Date ? ts : new Date(ts) + if (/(y+)/.test(fmt)) { + fmt = fmt.replace(RegExp.$1, `${date.getFullYear()}`) + } + const o = { + 'M+': date.getMonth() + 1, + 'd+': date.getDate(), + 'h+': date.getHours(), + 'm+': date.getMinutes(), + 's+': date.getSeconds() + } + for (const k in o) { + if (new RegExp(`(${k})`).test(fmt)) { + const str = o[k] + '' + fmt = fmt.replace(RegExp.$1, RegExp.$1.length === 1 ? str : `00${str}`.substr(str.length)) + } + } + return fmt +} \ No newline at end of file diff --git a/src/views/Artwork/components/ImageView.vue b/src/views/Artwork/components/ImageView.vue index 43ac0533..c64a3cf4 100644 --- a/src/views/Artwork/components/ImageView.vue +++ b/src/views/Artwork/components/ImageView.vue @@ -588,9 +588,9 @@ export default { .preview-action__wrapper { position: fixed; - right: 50px; - bottom: 60px; - bottom: calc(60px + env(safe-area-inset-bottom)); + right: 40px; + bottom: 40px; + bottom: calc(40px + env(safe-area-inset-bottom)); display: flex; flex-direction: column; justify-content: center; @@ -600,8 +600,8 @@ export default { font-size: 0; svg { - width: 70px; - height: 70px; + width: 100px; + height: 100px; } } } diff --git a/src/views/Novel/chapter.vue b/src/views/Novel/chapter.vue index c083a0d2..915c2312 100644 --- a/src/views/Novel/chapter.vue +++ b/src/views/Novel/chapter.vue @@ -1,5 +1,5 @@