-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
25 changed files
with
363 additions
and
55 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 13 additions & 0 deletions
13
src/monkey/copymanga-enhance/scripts/components/HeaderTitle/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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) | ||
} | ||
}, | ||
}) |
7 changes: 7 additions & 0 deletions
7
src/monkey/copymanga-enhance/scripts/components/HeaderTitle/template.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<template> | ||
<div> | ||
<a :href="prevUrl" :class="{'no-action': !prevUrl}" class="btn"><span>上一话</span></a> | ||
<a :href="menuUrl" class="title"><span>{{ title }}</span></a> | ||
<a :href="nextUrl" :class="{'no-action': !nextUrl}" class="btn"><span>下一话</span></a> | ||
</div> | ||
</template> |
24 changes: 24 additions & 0 deletions
24
src/monkey/copymanga-enhance/scripts/components/SwitchMode/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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, | ||
} | ||
}, | ||
}) |
7 changes: 7 additions & 0 deletions
7
src/monkey/copymanga-enhance/scripts/components/SwitchMode/template.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<template> | ||
<select v-model="mode" @change="selectMode"> | ||
<option :value="ComicDirection.LTR">正常模式</option> | ||
<option :value="ComicDirection.RTL">日漫模式</option> | ||
<option :value="ComicDirection.TTB">条漫模式</option> | ||
</select> | ||
</template> |
29 changes: 29 additions & 0 deletions
29
src/monkey/copymanga-enhance/scripts/components/ToggleWhitePage/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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, | ||
} | ||
}, | ||
}) |
6 changes: 6 additions & 0 deletions
6
src/monkey/copymanga-enhance/scripts/components/ToggleWhitePage/template.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<template> | ||
<template v-if="canWhitePage"> | ||
<a v-if="!hasWhitePage" class="btn" @click="() => toggleWhitePage()"><span>增加空白页</span></a> | ||
<a v-else class="btn" @click="() => toggleWhitePage()"><span>移除空白页</span></a> | ||
</template> | ||
</template> |
29 changes: 29 additions & 0 deletions
29
src/monkey/copymanga-enhance/scripts/hooks/useImagesInfo.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import store from "../store" | ||
|
||
const usePageInfo = () => { | ||
return { | ||
valueRef: store.info.get(), | ||
} | ||
} | ||
|
||
export default usePageInfo |
20 changes: 20 additions & 0 deletions
20
src/monkey/copymanga-enhance/scripts/hooks/useUserAgent.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
19 changes: 19 additions & 0 deletions
19
src/monkey/copymanga-enhance/scripts/hooks/useWhitePage.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
Oops, something went wrong.