From ff6f4c3515d691ffee49613c57d392a090e091d6 Mon Sep 17 00:00:00 2001 From: journey-ad Date: Thu, 21 Dec 2023 18:36:58 +0800 Subject: [PATCH] =?UTF-8?q?chore:=20=E5=87=8F=E5=B0=8F=E5=8C=85=E4=BD=93?= =?UTF-8?q?=E5=A4=A7=E5=B0=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package.json | 8 +- src/api/index.js | 6 +- src/components/dayjs.js | 14 + src/main.js | 4 +- src/views/Artwork/components/Meta.vue | 2 +- src/views/Artwork/components/Related.vue | 13 +- src/views/Home/components/Daily.vue | 6 +- src/views/Home/components/Moments.vue | 20 +- src/views/Novel/components/novel-reader.vue | 42 +- src/views/Rank/index.vue | 16 +- src/views/Search/components/ImageSearch.vue | 6 +- src/views/Search/index.vue | 6 +- src/views/Users/components/AuthorIllusts.vue | 6 +- src/views/Users/components/AuthorNovels.vue | 6 +- .../Users/components/FavoriteIllusts.vue | 6 +- yarn.lock | 19476 ++++++++-------- 16 files changed, 9708 insertions(+), 9929 deletions(-) create mode 100644 src/components/dayjs.js diff --git a/package.json b/package.json index 404772d8..a1f65cfd 100644 --- a/package.json +++ b/package.json @@ -4,7 +4,8 @@ "private": true, "scripts": { "serve": "vue-cli-service serve", - "build": "vue-cli-service build", + "build": "vue-cli-service build --modern", + "analyze": "vue-cli-service build --modern --report", "lint": "vue-cli-service lint" }, "dependencies": { @@ -12,6 +13,7 @@ "@vue/cli-plugin-pwa": "^4.5.19", "axios": "^0.19.2", "core-js": "^3.34.0", + "dayjs": "^1.11.10", "file-saver": "^2.0.2", "gif.js": "^0.2.0", "gifshot": "^0.4.5", @@ -19,9 +21,8 @@ "js-base64": "^2.5.2", "jszip": "^3.4.0", "localforage": "^1.10.0", - "lodash": "^4.17.15", + "lodash-es": "^4.17.21", "mobile-device-detect": "^0.4.3", - "moment": "^2.24.0", "opencc-js": "^1.0.5", "register-service-worker": "^1.7.2", "swiper": "^5.3.6", @@ -30,7 +31,6 @@ "vue": "^2.7.15", "vue-awesome-swiper": "^4.1.0", "vue-concise-slider": "^3.4.4", - "vue-moment": "^4.1.0", "vue-router": "^3.6.5", "vue-waterfall2": "1.10.6", "vuex": "^3.6.2", diff --git a/src/api/index.js b/src/api/index.js index ee26c056..5c2ae861 100644 --- a/src/api/index.js +++ b/src/api/index.js @@ -1,6 +1,6 @@ import { get } from './http' import { DBStorage, Expires } from '@/utils/storage' -import moment from 'moment' +import dayjs from 'dayjs' import { Base64 } from 'js-base64'; const isSupportWebP = (() => { @@ -241,8 +241,8 @@ const api = { * @param {Number} page 页数 * @param {String} date YYYY-MM-DD 默认为「前天」 */ - async getRankList(mode = 'weekly', page = 1, date = moment().subtract(2, 'days').format('YYYY-MM-DD')) { - date = moment(date).format('YYYY-MM-DD') + async getRankList(mode = 'weekly', page = 1, date = dayjs().subtract(2, 'days').format('YYYY-MM-DD')) { + date = dayjs(date).format('YYYY-MM-DD') const cache_key = `rankList_${mode}_${date}_${page}` let rankList = await DBStorage.get(cache_key) diff --git a/src/components/dayjs.js b/src/components/dayjs.js new file mode 100644 index 00000000..c1257464 --- /dev/null +++ b/src/components/dayjs.js @@ -0,0 +1,14 @@ +import dayjs from 'dayjs' +const customParseFormat = require('dayjs/plugin/customParseFormat') +dayjs.extend(customParseFormat) + +export default { + install(Vue) { + Vue.dayjs = dayjs + Vue.prototype.$dayjs = dayjs + + Vue.filter('dayjs', function (value, format = 'YYYY-MM-DD HH:mm:ss') { + return dayjs(value).format(format) + }) + } +} \ No newline at end of file diff --git a/src/main.js b/src/main.js index edeb6e0a..bfa8ca27 100644 --- a/src/main.js +++ b/src/main.js @@ -2,7 +2,7 @@ import Vue from 'vue' import App from './App.vue' import router from './router' import store from './store' -import Moment from 'vue-moment' +import Dayjs from '@/components/dayjs' import Icon from 'vue-svg-icon/Icon.vue' import { Toast, Lazyload, ImagePreview } from 'vant'; import '@vant/touch-emulator'; @@ -20,7 +20,7 @@ import './polyfill' import './registerServiceWorker' -Vue.use(Moment); +Vue.use(Dayjs); Vue.use(Toast); Vue.use(Lazyload, { lazyComponent: true, diff --git a/src/views/Artwork/components/Meta.vue b/src/views/Artwork/components/Meta.vue index 01fd719b..ef81c1ad 100644 --- a/src/views/Artwork/components/Meta.vue +++ b/src/views/Artwork/components/Meta.vue @@ -27,7 +27,7 @@
{{ - artwork.created | moment("YYYY-MM-DD hh:mm") + artwork.created | dayjs("YYYY-MM-DD hh:mm") }} diff --git a/src/views/Artwork/components/Related.vue b/src/views/Artwork/components/Related.vue index d9b55b7a..942e61ef 100644 --- a/src/views/Artwork/components/Related.vue +++ b/src/views/Artwork/components/Related.vue @@ -15,12 +15,7 @@ @load="getRelated()" >
- + - +
- + import { Slider } from "vant"; -import { debounce } from "lodash"; +import { debounce } from "lodash-es"; import gsap from "gsap"; -import * as OpenCC from "opencc-js"; import { LocalStorage } from "@/utils/storage"; import { setThemeColor } from "@/utils"; +const loadOpenCC = () => import("opencc-js"); const _READER_SETTING_KEY = "__PIXIV_readerSetting"; @@ -148,16 +148,29 @@ let readerSetting = LocalStorage.get(_READER_SETTING_KEY, { zhTrans: 0, }); -const converter = { - s2t: new OpenCC.Converter({ - from: "cn", - to: "tw", - }), - t2s: new OpenCC.Converter({ - from: "tw", - to: "cn", - }), -}; +class Converter { + constructor() { + this.inited = false; + } + + async init() { + const OpenCC = await loadOpenCC(); + + this.s2t = new OpenCC.Converter({ + from: "cn", + to: "tw", + }); + + this.t2s = new OpenCC.Converter({ + from: "tw", + to: "cn", + }); + + this.inited = true; + } +} + +const converter = new Converter(); export default { name: "novel-reader", @@ -309,13 +322,16 @@ export default { } setThemeColor(this.viewerStyle.backgroundColor); }, - parseNovel() { + async parseNovel() { if (!this.content) return; let content = this.content; // content = "载".repeat(10000); const _now = Date.now(); + if (!converter.inited && this.readerConfig.zhTrans.value > 0) { + await converter.init(); + } switch (this.readerConfig.zhTrans.value) { case 1: { content = converter.t2s(content); diff --git a/src/views/Rank/index.vue b/src/views/Rank/index.vue index ec6c6603..283b3a9d 100644 --- a/src/views/Rank/index.vue +++ b/src/views/Rank/index.vue @@ -66,12 +66,12 @@