From 101e830a054e2a8cff34eca377220bbee5b66f7d Mon Sep 17 00:00:00 2001 From: Doubley Yang Date: Mon, 23 Sep 2024 22:27:45 +0800 Subject: [PATCH] chore(vue): refore to vue --- etc/build/monkey.ts | 2 +- etc/build/monkey.utils.ts | 1 + package-lock.json | 84 +++++++++++++++++++ package.json | 2 + src/monkey/copymanga-enhance/index.ts | 18 ++-- .../scripts/components/HeaderTitle/index.ts | 13 +++ .../components/HeaderTitle/template.html | 7 ++ .../scripts/components/SwitchMode/index.ts | 24 ++++++ .../components/SwitchMode/template.html | 7 ++ .../components/ToggleWhitePage/index.ts | 29 +++++++ .../components/ToggleWhitePage/template.html | 6 ++ .../scripts/hooks/useImagesInfo.ts | 29 +++++++ .../scripts/hooks/useMode.ts | 17 ++++ .../scripts/hooks/usePageInfo.ts | 9 ++ .../scripts/hooks/useUserAgent.ts | 20 +++++ .../scripts/hooks/useWhitePage.ts | 19 +++++ .../copymanga-enhance/scripts/library/vue.ts | 17 ++++ .../scripts/new-vue-mixin/mode.ts | 27 ------ src/monkey/copymanga-enhance/scripts/new.ts | 20 +++-- .../scripts/store/hasWhitePage.ts | 11 +++ .../copymanga-enhance/scripts/store/index.ts | 11 +++ .../copymanga-enhance/scripts/store/info.ts | 18 ++++ .../copymanga-enhance/scripts/store/mode.ts | 12 +++ src/monkey/copymanga-enhance/style.css | 2 +- src/monkey/copymanga-enhance/template.html | 13 ++- 25 files changed, 363 insertions(+), 55 deletions(-) create mode 100644 src/monkey/copymanga-enhance/scripts/components/HeaderTitle/index.ts create mode 100644 src/monkey/copymanga-enhance/scripts/components/HeaderTitle/template.html create mode 100644 src/monkey/copymanga-enhance/scripts/components/SwitchMode/index.ts create mode 100644 src/monkey/copymanga-enhance/scripts/components/SwitchMode/template.html create mode 100644 src/monkey/copymanga-enhance/scripts/components/ToggleWhitePage/index.ts create mode 100644 src/monkey/copymanga-enhance/scripts/components/ToggleWhitePage/template.html create mode 100644 src/monkey/copymanga-enhance/scripts/hooks/useImagesInfo.ts create mode 100644 src/monkey/copymanga-enhance/scripts/hooks/useMode.ts create mode 100644 src/monkey/copymanga-enhance/scripts/hooks/usePageInfo.ts create mode 100644 src/monkey/copymanga-enhance/scripts/hooks/useUserAgent.ts create mode 100644 src/monkey/copymanga-enhance/scripts/hooks/useWhitePage.ts create mode 100644 src/monkey/copymanga-enhance/scripts/library/vue.ts delete mode 100644 src/monkey/copymanga-enhance/scripts/new-vue-mixin/mode.ts create mode 100644 src/monkey/copymanga-enhance/scripts/store/hasWhitePage.ts create mode 100644 src/monkey/copymanga-enhance/scripts/store/index.ts create mode 100644 src/monkey/copymanga-enhance/scripts/store/info.ts create mode 100644 src/monkey/copymanga-enhance/scripts/store/mode.ts diff --git a/etc/build/monkey.ts b/etc/build/monkey.ts index ee3cce5..18378ed 100644 --- a/etc/build/monkey.ts +++ b/etc/build/monkey.ts @@ -44,7 +44,7 @@ if (matchValueIndex > 0) { const metaPath = path.resolve(outPath, meta) fs.writeFileSync(path.resolve(outPath, deployJson), JSON.stringify(deployInfo, null, 2), 'utf-8') fs.writeFileSync(metaPath, banner, 'utf-8') - logger.log(`Building ${path.relative(ROOT_PATH, sourcePath)} --outfile=${path.relative(ROOT_PATH, targetPath)} ... Done!`) + logger.log(`Building ${path.relative(ROOT_PATH, sourcePath)} --outfile ${path.relative(ROOT_PATH, targetPath)} ... Done!`) }) } })() diff --git a/etc/build/monkey.utils.ts b/etc/build/monkey.utils.ts index 20cb49b..5cce5a9 100644 --- a/etc/build/monkey.utils.ts +++ b/etc/build/monkey.utils.ts @@ -155,6 +155,7 @@ export const buildScript = (filepath: string, extraConfig: esbuild.BuildOptions= entryPoints: [filepath], bundle: true, treeShaking: true, + external: Object.keys(require(path.resolve(ROOT_PATH, 'package.json')).devDependencies), ...extraConfig, ...(isCI ? { plugins: [ diff --git a/package-lock.json b/package-lock.json index 7f0acae..9018510 100644 --- a/package-lock.json +++ b/package-lock.json @@ -26,6 +26,8 @@ "ts-node": "^10.9.2", "typescript": "^5.4.5", "vitest": "^1.6.0", + "vue": "2.7", + "vue-demi": "^0.14.10", "yn": "^4.0.0" } }, @@ -1147,6 +1149,20 @@ "url": "https://opencollective.com/vitest" } }, + "node_modules/@vue/compiler-sfc": { + "version": "2.7.16", + "resolved": "https://registry.npmmirror.com/@vue/compiler-sfc/-/compiler-sfc-2.7.16.tgz", + "integrity": "sha512-KWhJ9k5nXuNtygPU7+t1rX6baZeqOYLEforUPjgNDBnLicfHCoi48H87Q8XyLZOrNNsmhuwKqtpDQWjEFe6Ekg==", + "dev": true, + "dependencies": { + "@babel/parser": "^7.23.5", + "postcss": "^8.4.14", + "source-map": "^0.6.1" + }, + "optionalDependencies": { + "prettier": "^1.18.2 || ^2.0.0" + } + }, "node_modules/acorn": { "version": "8.11.3", "resolved": "https://registry.npmmirror.com/acorn/-/acorn-8.11.3.tgz", @@ -1703,6 +1719,12 @@ "node": "*" } }, + "node_modules/csstype": { + "version": "3.1.3", + "resolved": "https://registry.npmmirror.com/csstype/-/csstype-3.1.3.tgz", + "integrity": "sha512-M1uQkMl8rQK/szD0LNhtqxIPLpimGm8sOBwU7lLnCpSbTyY3yeU1Vc7l4KT5zT4s/yOxHH5O7tIuuLOCnLADRw==", + "dev": true + }, "node_modules/date-fns": { "version": "2.30.0", "resolved": "https://registry.npmmirror.com/date-fns/-/date-fns-2.30.0.tgz", @@ -3432,6 +3454,22 @@ "node": ">=4" } }, + "node_modules/prettier": { + "version": "2.8.8", + "resolved": "https://registry.npmmirror.com/prettier/-/prettier-2.8.8.tgz", + "integrity": "sha512-tdN8qQGvNjw4CHbY+XXk0JgCXn9QiF21a55rBe5LJAU+kDyC4WQn4+awm2Xfk2lQMk5fKup9XgzTZtGkjBdP9Q==", + "dev": true, + "optional": true, + "bin": { + "prettier": "bin-prettier.js" + }, + "engines": { + "node": ">=10.13.0" + }, + "funding": { + "url": "https://github.com/prettier/prettier?sponsor=1" + } + }, "node_modules/pretty-format": { "version": "29.7.0", "resolved": "https://registry.npmjs.org/pretty-format/-/pretty-format-29.7.0.tgz", @@ -3732,6 +3770,15 @@ "node": ">=0.10.0" } }, + "node_modules/source-map": { + "version": "0.6.1", + "resolved": "https://registry.npmmirror.com/source-map/-/source-map-0.6.1.tgz", + "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==", + "dev": true, + "engines": { + "node": ">=0.10.0" + } + }, "node_modules/source-map-js": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/source-map-js/-/source-map-js-1.2.0.tgz", @@ -4366,6 +4413,43 @@ } } }, + "node_modules/vue": { + "version": "2.7.16", + "resolved": "https://registry.npmmirror.com/vue/-/vue-2.7.16.tgz", + "integrity": "sha512-4gCtFXaAA3zYZdTp5s4Hl2sozuySsgz4jy1EnpBHNfpMa9dK1ZCG7viqBPCwXtmgc8nHqUsAu3G4gtmXkkY3Sw==", + "deprecated": "Vue 2 has reached EOL and is no longer actively maintained. See https://v2.vuejs.org/eol/ for more details.", + "dev": true, + "dependencies": { + "@vue/compiler-sfc": "2.7.16", + "csstype": "^3.1.0" + } + }, + "node_modules/vue-demi": { + "version": "0.14.10", + "resolved": "https://registry.npmmirror.com/vue-demi/-/vue-demi-0.14.10.tgz", + "integrity": "sha512-nMZBOwuzabUO0nLgIcc6rycZEebF6eeUfaiQx9+WSk8e29IbLvPU9feI6tqW4kTo3hvoYAJkMh8n8D0fuISphg==", + "dev": true, + "hasInstallScript": true, + "bin": { + "vue-demi-fix": "bin/vue-demi-fix.js", + "vue-demi-switch": "bin/vue-demi-switch.js" + }, + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/sponsors/antfu" + }, + "peerDependencies": { + "@vue/composition-api": "^1.0.0-rc.1", + "vue": "^3.0.0-0 || ^2.6.0" + }, + "peerDependenciesMeta": { + "@vue/composition-api": { + "optional": true + } + } + }, "node_modules/which": { "version": "2.0.2", "resolved": "https://mirrors.cloud.tencent.com/npm/which/-/which-2.0.2.tgz", diff --git a/package.json b/package.json index 50c0d74..d0fe939 100644 --- a/package.json +++ b/package.json @@ -37,6 +37,8 @@ "ts-node": "^10.9.2", "typescript": "^5.4.5", "vitest": "^1.6.0", + "vue": "2.7", + "vue-demi": "^0.14.10", "yn": "^4.0.0" } } diff --git a/src/monkey/copymanga-enhance/index.ts b/src/monkey/copymanga-enhance/index.ts index cb1ac17..d54060b 100644 --- a/src/monkey/copymanga-enhance/index.ts +++ b/src/monkey/copymanga-enhance/index.ts @@ -1,10 +1,8 @@ import css from './style.css' import html from './template.html' -import { chapter, comic } from './scripts/common' import { render } from './scripts/new' import { getPageInfo, refreshImage, windowScrollTo } from './scripts/old' - -const sessionStorageKey = `${comic}.info.${chapter}` +import store from './scripts/store' const renderNewPage = (info: any) => render({ info, @@ -15,20 +13,14 @@ const renderNewPage = (info: any) => render({ }) setTimeout(() => { - let cacheContent = sessionStorage.getItem(sessionStorageKey) + const cacheContent = store.info.get() if (cacheContent) { - const info = { - prevUrl: void 0, - nextUrl: void 0, - menuUrl: void 0, - ...JSON.parse(cacheContent), - } - return renderNewPage(info) + return renderNewPage(cacheContent) } refreshImage(() => { windowScrollTo(0) - const info = getPageInfo() - sessionStorage.setItem(sessionStorageKey, JSON.stringify(info)) + const info = getPageInfo() + store.info.save(info) renderNewPage(info) }) }, 25) diff --git a/src/monkey/copymanga-enhance/scripts/components/HeaderTitle/index.ts b/src/monkey/copymanga-enhance/scripts/components/HeaderTitle/index.ts new file mode 100644 index 0000000..c2af067 --- /dev/null +++ b/src/monkey/copymanga-enhance/scripts/components/HeaderTitle/index.ts @@ -0,0 +1,13 @@ +import usePageInfo from "../../hooks/usePageInfo"; +import { defineComponent, unref } from "../../library/vue"; +import htmlContent from "./template.html"; + +export default defineComponent({ + template: htmlContent, + setup () { + const { valueRef } = usePageInfo() + return { + ...unref(valueRef) + } + }, +}) diff --git a/src/monkey/copymanga-enhance/scripts/components/HeaderTitle/template.html b/src/monkey/copymanga-enhance/scripts/components/HeaderTitle/template.html new file mode 100644 index 0000000..ca5c69a --- /dev/null +++ b/src/monkey/copymanga-enhance/scripts/components/HeaderTitle/template.html @@ -0,0 +1,7 @@ + diff --git a/src/monkey/copymanga-enhance/scripts/components/SwitchMode/index.ts b/src/monkey/copymanga-enhance/scripts/components/SwitchMode/index.ts new file mode 100644 index 0000000..cd2b1e9 --- /dev/null +++ b/src/monkey/copymanga-enhance/scripts/components/SwitchMode/index.ts @@ -0,0 +1,24 @@ +import useMode from "../../hooks/useMode"; +import { ComicDirection } from "../../constant"; +import htmlContent from "./template.html"; +import { defineComponent } from "../../library/vue"; + +export default defineComponent({ + template: htmlContent, + setup () { + const { + valueRef: modeRef, + switch: switchMode, + } = useMode() + const selectMode = (evt: InputEvent) => { + const value = (evt.target as HTMLSelectElement)?.value as ComicDirection + switchMode(value) + } + return { + selectMode, + switchMode, + ComicDirection, + mode: modeRef, + } + }, +}) diff --git a/src/monkey/copymanga-enhance/scripts/components/SwitchMode/template.html b/src/monkey/copymanga-enhance/scripts/components/SwitchMode/template.html new file mode 100644 index 0000000..c06c30d --- /dev/null +++ b/src/monkey/copymanga-enhance/scripts/components/SwitchMode/template.html @@ -0,0 +1,7 @@ + diff --git a/src/monkey/copymanga-enhance/scripts/components/ToggleWhitePage/index.ts b/src/monkey/copymanga-enhance/scripts/components/ToggleWhitePage/index.ts new file mode 100644 index 0000000..4e0e059 --- /dev/null +++ b/src/monkey/copymanga-enhance/scripts/components/ToggleWhitePage/index.ts @@ -0,0 +1,29 @@ +import { ComicDirection } from "../../constant"; +import useImagesInfo from "../../hooks/useImagesInfo"; +import useMode from "../../hooks/useMode"; +import useWhitePage from "../../hooks/useWhitePage"; +import { computed, defineComponent, unref } from "../../library/vue"; +import htmlContent from "./template.html"; + +export default defineComponent({ + template: htmlContent, + setup () { + const { valueRef: modeRef } = useMode() + const { + valueRef: hasWhitePage, + toggle: toggleWhitePage, + } = useWhitePage() + const { loaded } = useImagesInfo() + const canWhitePage = computed(() => { + if (![ComicDirection.LTR, ComicDirection.RTL].includes(unref(modeRef))) { + return false + } + return unref(loaded) + }) + return { + hasWhitePage, + toggleWhitePage, + canWhitePage, + } + }, +}) diff --git a/src/monkey/copymanga-enhance/scripts/components/ToggleWhitePage/template.html b/src/monkey/copymanga-enhance/scripts/components/ToggleWhitePage/template.html new file mode 100644 index 0000000..6acb567 --- /dev/null +++ b/src/monkey/copymanga-enhance/scripts/components/ToggleWhitePage/template.html @@ -0,0 +1,6 @@ + diff --git a/src/monkey/copymanga-enhance/scripts/hooks/useImagesInfo.ts b/src/monkey/copymanga-enhance/scripts/hooks/useImagesInfo.ts new file mode 100644 index 0000000..0aa57ff --- /dev/null +++ b/src/monkey/copymanga-enhance/scripts/hooks/useImagesInfo.ts @@ -0,0 +1,29 @@ +import { computed, ref, unref } from "../library/vue"; +import store from "../store"; +import usePageInfo from "./usePageInfo"; + +const imagesRef = ref(Array(store.info.get().images.length).fill(undefined)) + +const useImagesInfo = () => { + const { valueRef: pageInfoRef } = usePageInfo() + const loadedCount = computed(() => unref(imagesRef).filter(Boolean).length) + const total = computed(() => unref(pageInfoRef).images.length) + const loading = computed(() => unref(loadedCount) !== unref(total)) + const loaded = computed(() => unref(loadedCount) === unref(total)) + + const loadFinish = (index: number, content: any = {}) => { + if (unref(total) <= index) { + return console.error('index out of range') + } + imagesRef.value.splice(index, 1, content) + } + return { + valueRef: imagesRef, + total, + loading, + loaded, + loadFinish, + } +} + +export default useImagesInfo; diff --git a/src/monkey/copymanga-enhance/scripts/hooks/useMode.ts b/src/monkey/copymanga-enhance/scripts/hooks/useMode.ts new file mode 100644 index 0000000..fb3c20c --- /dev/null +++ b/src/monkey/copymanga-enhance/scripts/hooks/useMode.ts @@ -0,0 +1,17 @@ +import { ComicDirection } from "../constant"; +import { ref } from "../library/vue"; +import store from '../store' + +const cacheValueRef = ref(store.mode.get()) + +const useMode = () => { + return { + valueRef: cacheValueRef, + switch (mode: ComicDirection) { + cacheValueRef.value = mode + store.mode.save(mode) + }, + } +} + +export default useMode diff --git a/src/monkey/copymanga-enhance/scripts/hooks/usePageInfo.ts b/src/monkey/copymanga-enhance/scripts/hooks/usePageInfo.ts new file mode 100644 index 0000000..d38b43c --- /dev/null +++ b/src/monkey/copymanga-enhance/scripts/hooks/usePageInfo.ts @@ -0,0 +1,9 @@ +import store from "../store" + +const usePageInfo = () => { + return { + valueRef: store.info.get(), + } +} + +export default usePageInfo diff --git a/src/monkey/copymanga-enhance/scripts/hooks/useUserAgent.ts b/src/monkey/copymanga-enhance/scripts/hooks/useUserAgent.ts new file mode 100644 index 0000000..2a8837d --- /dev/null +++ b/src/monkey/copymanga-enhance/scripts/hooks/useUserAgent.ts @@ -0,0 +1,20 @@ +import { computed, unref } from "../library/vue" + +const useUserAgent = () => { + const valueRef = computed(() => navigator.userAgent) + const isWindows = computed(() => valueRef.value.includes('Windows NT')) + const isMac = computed(() => valueRef.value.includes(' Mac OS ')) + const platform = computed(() => { + if (unref(isWindows)) return 'windows' + if (unref(isMac)) return 'mac' + return 'unknown-platform' + }) + return { + valueRef, + isWindows, + isMac, + platform, + } +} + +export default useUserAgent diff --git a/src/monkey/copymanga-enhance/scripts/hooks/useWhitePage.ts b/src/monkey/copymanga-enhance/scripts/hooks/useWhitePage.ts new file mode 100644 index 0000000..2dce705 --- /dev/null +++ b/src/monkey/copymanga-enhance/scripts/hooks/useWhitePage.ts @@ -0,0 +1,19 @@ +import { ref } from "../library/vue"; +import store from '../store' + +const cacheValueRef = ref(store.hasWhitePage.get()) + +const useWhitePage = () => { + return { + valueRef: cacheValueRef, + toggle: (nextValue?: boolean) => { + const value = typeof nextValue === 'undefined' + ? !cacheValueRef.value + : nextValue + cacheValueRef.value = value + store.hasWhitePage.save(value) + }, + } +} + +export default useWhitePage diff --git a/src/monkey/copymanga-enhance/scripts/library/vue.ts b/src/monkey/copymanga-enhance/scripts/library/vue.ts new file mode 100644 index 0000000..67d28ff --- /dev/null +++ b/src/monkey/copymanga-enhance/scripts/library/vue.ts @@ -0,0 +1,17 @@ +import type VueType from "vue" +import type { + unref as unrefType, + ref as refType, + computed as computedType, + provide as provideType, + inject as injectType, + defineComponent as defineComponentType, +} from "vue-demi" + +export const Vue = window.Vue as typeof VueType +export const unref = (Vue as any).unref as typeof unrefType +export const ref = (Vue as any).ref as typeof refType +export const computed = (Vue as any).computed as typeof computedType +export const provide = (Vue as any).provide as typeof provideType +export const inject = (Vue as any).inject as typeof injectType +export const defineComponent = (Vue as any).defineComponent as typeof defineComponentType diff --git a/src/monkey/copymanga-enhance/scripts/new-vue-mixin/mode.ts b/src/monkey/copymanga-enhance/scripts/new-vue-mixin/mode.ts deleted file mode 100644 index fdb82c5..0000000 --- a/src/monkey/copymanga-enhance/scripts/new-vue-mixin/mode.ts +++ /dev/null @@ -1,27 +0,0 @@ -import { comic } from "../common"; -import { ComicDirection } from "../constant"; -import { MixinThis } from "../types"; - -const ModeMixin = () => ({ - data: { - mode: GM_getValue(`${comic}.direction.mode`, ComicDirection.RTL), - }, - computed: { - ComicDirection: () => ComicDirection, - }, - methods: { - selectMode (evt: InputEvent) { - const value = (evt.target as HTMLSelectElement)?.value - this.switchMode(value) - GM_setValue(`${comic}.direction.mode`, value) - }, - switchMode (mode: string) { - const that = (this as any) - that.mode = mode - }, - } -}) - -export type ModeMixinThis = MixinThis> - -export default ModeMixin diff --git a/src/monkey/copymanga-enhance/scripts/new.ts b/src/monkey/copymanga-enhance/scripts/new.ts index cdd25d5..f28bb78 100644 --- a/src/monkey/copymanga-enhance/scripts/new.ts +++ b/src/monkey/copymanga-enhance/scripts/new.ts @@ -1,20 +1,30 @@ import ActionMixin from "./new-vue-mixin/action" import ImageMixin from "./new-vue-mixin/image" import InitMixin from "./new-vue-mixin/init" -import ModeMixin from "./new-vue-mixin/mode" import { PageInfo } from "./types" +import SwitchMode from './components/SwitchMode' +import ToggleWhitePage from './components/ToggleWhitePage' +import { Vue } from "./library/vue" +import useUserAgent from "./hooks/useUserAgent" -declare const Vue: any - -export const render = ({ info, preFn = Function }: { info: PageInfo, preFn: Function }) => { +export const render = ({ info, preFn = (() => {}) }: { info: PageInfo, preFn: Function }) => { preFn() new Vue({ el: '#app', + components: { + SwitchMode, + ToggleWhitePage, + }, mixins: [ InitMixin(info), - ModeMixin(), ActionMixin(), ImageMixin(info), ] as const, + setup () { + const { platform } = useUserAgent() + return { + platform, + } + }, }) } diff --git a/src/monkey/copymanga-enhance/scripts/store/hasWhitePage.ts b/src/monkey/copymanga-enhance/scripts/store/hasWhitePage.ts new file mode 100644 index 0000000..894e287 --- /dev/null +++ b/src/monkey/copymanga-enhance/scripts/store/hasWhitePage.ts @@ -0,0 +1,11 @@ +import { chapter, comic } from "../common" + +const CACHE_KEY = `${comic}.hasWhitePage.${chapter}` + +export function get (): boolean { + return JSON.parse(GM_getValue(CACHE_KEY, JSON.stringify(false))) +} + +export function save (value: boolean) { + GM_setValue(CACHE_KEY, JSON.stringify(value)) +} diff --git a/src/monkey/copymanga-enhance/scripts/store/index.ts b/src/monkey/copymanga-enhance/scripts/store/index.ts new file mode 100644 index 0000000..0e0ccb2 --- /dev/null +++ b/src/monkey/copymanga-enhance/scripts/store/index.ts @@ -0,0 +1,11 @@ +import * as info from './info' +import * as mode from './mode' +import * as hasWhitePage from './hasWhitePage' + +const store = { + info, + mode, + hasWhitePage, +} + +export default store diff --git a/src/monkey/copymanga-enhance/scripts/store/info.ts b/src/monkey/copymanga-enhance/scripts/store/info.ts new file mode 100644 index 0000000..e9f3c45 --- /dev/null +++ b/src/monkey/copymanga-enhance/scripts/store/info.ts @@ -0,0 +1,18 @@ +import { chapter, comic } from "../common" +import { PageInfo } from "../types" + +const CACHE_KEY = `${comic}.info.${chapter}` + +export function get () { + const content = sessionStorage.getItem(CACHE_KEY) + return Object.assign({ + prevUrl: void 0, + nextUrl: void 0, + menuUrl: void 0, + title: void 0, + }, content ? JSON.parse(content) : undefined) as PageInfo +} + +export function save (info: PageInfo) { + sessionStorage.setItem(CACHE_KEY, JSON.stringify(info)) +} diff --git a/src/monkey/copymanga-enhance/scripts/store/mode.ts b/src/monkey/copymanga-enhance/scripts/store/mode.ts new file mode 100644 index 0000000..14ee5c5 --- /dev/null +++ b/src/monkey/copymanga-enhance/scripts/store/mode.ts @@ -0,0 +1,12 @@ +import { comic } from "../common" +import { ComicDirection } from "../constant" + +const CACHE_KEY = `${comic}.direction.mode` + +export function get (): ComicDirection { + return GM_getValue(CACHE_KEY, ComicDirection.RTL) +} + +export function save (value: ComicDirection) { + GM_setValue(CACHE_KEY, value) +} diff --git a/src/monkey/copymanga-enhance/style.css b/src/monkey/copymanga-enhance/style.css index 24a2ba5..35970ef 100644 --- a/src/monkey/copymanga-enhance/style.css +++ b/src/monkey/copymanga-enhance/style.css @@ -86,7 +86,7 @@ justify-content: flex-end; } -#app .hint-container.windows.right { +#app.windows .hint-container.right { right: 16px; } diff --git a/src/monkey/copymanga-enhance/template.html b/src/monkey/copymanga-enhance/template.html index 0d6efcc..a31c350 100644 --- a/src/monkey/copymanga-enhance/template.html +++ b/src/monkey/copymanga-enhance/template.html @@ -1,17 +1,14 @@ -
+
上一话 {{ title }} 下一话 - -