├── client ├── src │ ├── vite-env.d.ts │ ├── assets │ │ ├── logo.png │ │ ├── logo-dark.png │ │ └── iconfont │ │ │ ├── iconfont.ttf │ │ │ ├── iconfont.woff │ │ │ ├── iconfont.woff2 │ │ │ └── iconfont.css │ ├── utils.ts │ ├── components │ │ ├── Loading │ │ │ └── index.tsx │ │ ├── BackTop │ │ │ └── index.tsx │ │ ├── Header │ │ │ └── index.tsx │ │ └── Search │ │ │ └── index.tsx │ ├── hooks │ │ ├── useScrollToTop.ts │ │ ├── useLocalStorage.ts │ │ └── useTheme.ts │ ├── main.tsx │ ├── router.tsx │ ├── constant.ts │ ├── globals.css │ ├── pages │ │ ├── Home │ │ │ ├── index.tsx │ │ │ └── BookList │ │ │ │ └── index.tsx │ │ ├── Chapter │ │ │ ├── Provider.tsx │ │ │ ├── ChapterHeader │ │ │ │ └── index.tsx │ │ │ ├── index.tsx │ │ │ ├── ChapterContent │ │ │ │ └── index.tsx │ │ │ ├── ComicWarp │ │ │ │ └── index.tsx │ │ │ └── ChapterFooter │ │ │ │ └── index.tsx │ │ └── Detail │ │ │ ├── index.tsx │ │ │ └── ChapterList │ │ │ └── index.tsx │ └── api │ │ └── index.ts ├── vite.config.d.ts ├── public │ └── favicon.ico ├── postcss.config.js ├── tsconfig.node.json ├── tsconfig.json ├── index.html ├── vite.config.ts ├── tailwind.config.js └── tsconfig.node.tsbuildinfo ├── docs ├── logo.png ├── view-1.png ├── view-2.png ├── view-3.png ├── view-4.png └── view-5.png ├── bin └── index.js ├── server ├── src │ ├── constant.ts │ ├── routes │ │ ├── index.ts │ │ └── api │ │ │ ├── comicBookList.ts │ │ │ ├── comicBook.ts │ │ │ ├── comicChapter.ts │ │ │ ├── index.ts │ │ │ └── core.ts │ ├── utils │ │ ├── log.ts │ │ ├── index.ts │ │ └── cache.ts │ ├── cli.ts │ └── index.ts └── tsconfig.json ├── .prettierrc.js ├── .vscode └── settings.json ├── .npmignore ├── .editorconfig ├── .gitignore ├── .eslintrc.cjs ├── package.json ├── README.md └── LICENSE.txt /client/src/vite-env.d.ts: -------------------------------------------------------------------------------- 1 | /// 2 | -------------------------------------------------------------------------------- /client/vite.config.d.ts: -------------------------------------------------------------------------------- 1 | declare const _default: any; 2 | export default _default; 3 | -------------------------------------------------------------------------------- /docs/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gxr404/comic-book-browser/HEAD/docs/logo.png -------------------------------------------------------------------------------- /docs/view-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gxr404/comic-book-browser/HEAD/docs/view-1.png -------------------------------------------------------------------------------- /docs/view-2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gxr404/comic-book-browser/HEAD/docs/view-2.png -------------------------------------------------------------------------------- /docs/view-3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gxr404/comic-book-browser/HEAD/docs/view-3.png -------------------------------------------------------------------------------- /docs/view-4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gxr404/comic-book-browser/HEAD/docs/view-4.png -------------------------------------------------------------------------------- /docs/view-5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gxr404/comic-book-browser/HEAD/docs/view-5.png -------------------------------------------------------------------------------- /client/public/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gxr404/comic-book-browser/HEAD/client/public/favicon.ico -------------------------------------------------------------------------------- /client/src/assets/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gxr404/comic-book-browser/HEAD/client/src/assets/logo.png -------------------------------------------------------------------------------- /bin/index.js: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | 3 | function run() { 4 | return import('../server-dist/cli.js') 5 | } 6 | run() -------------------------------------------------------------------------------- /client/src/assets/logo-dark.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gxr404/comic-book-browser/HEAD/client/src/assets/logo-dark.png -------------------------------------------------------------------------------- /server/src/constant.ts: -------------------------------------------------------------------------------- 1 | export enum STATUS_CODE { 2 | /** 成功 */ 3 | SUCCESS = 0, 4 | /** 缺少参数 */ 5 | MISSING_PARAM = -1, 6 | } 7 | -------------------------------------------------------------------------------- /client/src/assets/iconfont/iconfont.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gxr404/comic-book-browser/HEAD/client/src/assets/iconfont/iconfont.ttf -------------------------------------------------------------------------------- /client/src/assets/iconfont/iconfont.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gxr404/comic-book-browser/HEAD/client/src/assets/iconfont/iconfont.woff -------------------------------------------------------------------------------- /client/src/assets/iconfont/iconfont.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gxr404/comic-book-browser/HEAD/client/src/assets/iconfont/iconfont.woff2 -------------------------------------------------------------------------------- /.prettierrc.js: -------------------------------------------------------------------------------- 1 | export default { 2 | semi: false, 3 | endOfLine: 'lf', 4 | singleQuote: true, 5 | tabWidth: 2, 6 | useTabs: false, 7 | } 8 | -------------------------------------------------------------------------------- /.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "cSpell.words": [ 3 | "ahooks", 4 | "antd", 5 | "iconfont", 6 | "qrcode", 7 | "tailwindcss" 8 | ] 9 | } -------------------------------------------------------------------------------- /client/src/utils.ts: -------------------------------------------------------------------------------- 1 | export function toReversed(arr: T[]) { 2 | const newArr: T[] = [] 3 | arr.forEach(item => newArr.unshift(item)) 4 | return newArr 5 | } -------------------------------------------------------------------------------- /client/postcss.config.js: -------------------------------------------------------------------------------- 1 | export default { 2 | plugins: { 3 | tailwindcss: { 4 | config: 'client/tailwind.config.js' 5 | }, 6 | autoprefixer: {}, 7 | }, 8 | } 9 | -------------------------------------------------------------------------------- /server/src/routes/index.ts: -------------------------------------------------------------------------------- 1 | 2 | import Router from '@koa/router' 3 | import api from './api/index' 4 | 5 | const router = new Router() 6 | 7 | router.use('/api', api.routes()) 8 | 9 | export default router -------------------------------------------------------------------------------- /.npmignore: -------------------------------------------------------------------------------- 1 | src 2 | node_modules 3 | test 4 | temp 5 | .vscode 6 | .np-config.js 7 | .eslintrc.cjs 8 | .eslintignore 9 | .editorconfig 10 | .prettierrc.js 11 | 12 | server 13 | client 14 | *.log 15 | docs -------------------------------------------------------------------------------- /client/tsconfig.node.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "composite": true, 4 | "skipLibCheck": true, 5 | "module": "ESNext", 6 | "moduleResolution": "bundler", 7 | "allowSyntheticDefaultImports": true 8 | }, 9 | "include": ["vite.config.ts"] 10 | } 11 | -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | # http://editorconfig.org 2 | 3 | root = true 4 | 5 | [*] 6 | charset = utf-8 7 | indent_style = space 8 | indent_size = 2 9 | end_of_line = lf 10 | # 最后一行换行 取消掉 11 | insert_final_newline = false 12 | trim_trailing_whitespace = true 13 | 14 | [*.md] 15 | insert_final_newline = false 16 | trim_trailing_whitespace = false 17 | -------------------------------------------------------------------------------- /client/src/components/Loading/index.tsx: -------------------------------------------------------------------------------- 1 | export default function Loading() { 2 | return ( 3 |
4 |

5 | 6 | Loading . . . 7 |

8 |
9 | ) 10 | } -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Logs 2 | logs 3 | *.log 4 | npm-debug.log* 5 | yarn-debug.log* 6 | yarn-error.log* 7 | pnpm-debug.log* 8 | lerna-debug.log* 9 | 10 | node_modules 11 | dist 12 | dist-ssr 13 | *.local 14 | 15 | # Editor directories and files 16 | !.vscode/extensions.json 17 | .idea 18 | .DS_Store 19 | *.suo 20 | *.ntvs* 21 | *.njsproj 22 | *.sln 23 | *.sw? 24 | 25 | client-dist 26 | server-dist 27 | visualizer.html 28 | temp 29 | -------------------------------------------------------------------------------- /client/src/hooks/useScrollToTop.ts: -------------------------------------------------------------------------------- 1 | import { useEffect } from 'react' 2 | import { useLocation } from 'react-router-dom' 3 | 4 | export default function useScrollToTop(callback: () => void) { 5 | const { pathname } = useLocation() 6 | 7 | useEffect(() => { 8 | if (typeof callback === 'function') { 9 | callback() 10 | } 11 | window.scrollTo({ 12 | top: 0 13 | }) 14 | }, [pathname, callback]) 15 | } -------------------------------------------------------------------------------- /client/src/hooks/useLocalStorage.ts: -------------------------------------------------------------------------------- 1 | import { useEffect, useState } from 'react' 2 | 3 | export default function useLocalStorage(key: string, initStorage: T): [T, (arg: T) => void] { 4 | const [storage, setStorage] = useState(initStorage) 5 | 6 | function updateStorage(data: T) { 7 | const dataStr = JSON.stringify(data) 8 | setStorage(data) 9 | localStorage.setItem(key, dataStr) 10 | } 11 | 12 | useEffect(() => { 13 | const dataStr = localStorage.getItem(key) ?? '{}' 14 | try { 15 | const data = JSON.parse(dataStr) 16 | setStorage(data) 17 | } catch(e) { 18 | console.log(e) 19 | } 20 | }, [key]) 21 | 22 | return [storage, updateStorage] 23 | } -------------------------------------------------------------------------------- /client/src/main.tsx: -------------------------------------------------------------------------------- 1 | import React from 'react' 2 | import ReactDOM from 'react-dom/client' 3 | import { RouterProvider } from 'react-router-dom' 4 | import { ConfigProvider } from 'antd' 5 | import router from './router' 6 | 7 | import './assets/iconfont/iconfont.css' 8 | import './globals.css' 9 | 10 | const antTheme = { 11 | components: { 12 | Message: { 13 | contentBg: 'rgba(0,0,0,0.8)' 14 | } 15 | } 16 | } 17 | 18 | ReactDOM.createRoot(document.getElementById('root')!).render( 19 |
20 | 21 | 22 | 23 | 24 | 25 |
26 | ) 27 | -------------------------------------------------------------------------------- /client/src/router.tsx: -------------------------------------------------------------------------------- 1 | import { Navigate, createHashRouter } from 'react-router-dom' 2 | import Home from '@/pages/Home' 3 | 4 | const router = createHashRouter([ 5 | { 6 | path: '/', 7 | element: , 8 | }, 9 | { 10 | path: '/detail/:bookName', 11 | lazy: async () => { 12 | const Detail = await import('@/pages/Detail') 13 | return {Component: Detail.default} 14 | } 15 | }, 16 | { 17 | path: '/detail/:bookName/:chapterName', 18 | lazy: async () => { 19 | const Chapter = await import('@/pages/Chapter') 20 | return {Component: Chapter.default} 21 | } 22 | }, 23 | { 24 | path: '*', 25 | element: 26 | } 27 | ]) 28 | 29 | export default router 30 | -------------------------------------------------------------------------------- /server/src/utils/log.ts: -------------------------------------------------------------------------------- 1 | import log4js from 'log4js' 2 | 3 | /** 4 | * log 初始化 5 | */ 6 | const getLogger = () => { 7 | log4js.configure({ 8 | appenders: { 9 | // cheeseLog: { type: 'file', filename: 'cheese.log' }, 10 | cheese: { 11 | type: 'console', 12 | layout: { 13 | // type: 'messagePassThrough', 14 | type: 'pattern', 15 | // pattern: '%[%d{yyyy-MM-dd hh:mm:ss} [%p] %c -%] %m%n' 16 | pattern: '%[%c [%p]:%] %m%n' 17 | } 18 | } 19 | }, 20 | categories: { default: { appenders: ['cheese'], level: 'trace' } } 21 | }) 22 | return log4js.getLogger('comic-book-browser') 23 | } 24 | 25 | const logger = getLogger() 26 | 27 | export { 28 | logger, 29 | getLogger 30 | } 31 | -------------------------------------------------------------------------------- /client/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "ES2020", 4 | "useDefineForClassFields": true, 5 | "lib": ["ES2020", "DOM", "DOM.Iterable"], 6 | "module": "ESNext", 7 | "skipLibCheck": true, 8 | 9 | /* Bundler mode */ 10 | "moduleResolution": "bundler", 11 | "allowImportingTsExtensions": true, 12 | "resolveJsonModule": true, 13 | "isolatedModules": true, 14 | "noEmit": true, 15 | "jsx": "react-jsx", 16 | 17 | /* Linting */ 18 | "strict": true, 19 | "noUnusedLocals": true, 20 | "noUnusedParameters": true, 21 | "noFallthroughCasesInSwitch": true, 22 | "paths": { 23 | "@/*": ["./src/*"] 24 | } 25 | }, 26 | "include": ["src"], 27 | "references": [{ "path": "./tsconfig.node.json" }] 28 | } 29 | -------------------------------------------------------------------------------- /server/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "ES2020", 4 | "useDefineForClassFields": true, 5 | "lib": ["ES2020", "DOM", "DOM.Iterable"], 6 | "module": "ESNext", 7 | "skipLibCheck": true, 8 | "strict": true, 9 | "allowSyntheticDefaultImports": true, 10 | "outDir": "../server-dist", 11 | "moduleResolution": "Node", 12 | "removeComments": true, 13 | // "allowImportingTsExtensions": true, 14 | // "isolatedModules": true, 15 | // "noUnusedLocals": true, 16 | // "noUnusedParameters": true, 17 | // "noFallthroughCasesInSwitch": true 18 | "paths": { 19 | "@/*": ["./src/*"] 20 | } 21 | }, 22 | "include": [ 23 | "src/**/*" 24 | ], 25 | "tsc-alias": { 26 | "resolveFullPaths": true, 27 | "verbose": false 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /client/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | Comic Browser 9 | 18 | 19 | 20 |
21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /.eslintrc.cjs: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | root: true, 3 | env: { browser: true, es2020: true }, 4 | ignorePatterns: [ 5 | 'client-dist', 6 | 'server-dist', 7 | 'types', 8 | 'node_modules', 9 | 'bin', 10 | 'temp', 11 | '*.d.ts', 12 | '*.html', 13 | '.eslintrc.cjs', 14 | 'docs' 15 | ], 16 | extends: [ 17 | 'eslint:recommended', 18 | 'plugin:@typescript-eslint/recommended', 19 | 'plugin:react-hooks/recommended', 20 | ], 21 | parser: '@typescript-eslint/parser', 22 | plugins: ['react-refresh'], 23 | rules: { 24 | 'react-refresh/only-export-components': [ 25 | 'warn', 26 | { allowConstantExport: true }, 27 | ], 28 | semi: ['error', 'never'], 29 | quotes: ['error', 'single'], 30 | "@typescript-eslint/no-explicit-any": "warn" 31 | }, 32 | } 33 | -------------------------------------------------------------------------------- /server/src/cli.ts: -------------------------------------------------------------------------------- 1 | import { readFileSync } from 'node:fs' 2 | import { cac } from 'cac' 3 | import { run } from './index' 4 | import { logger } from './utils/log' 5 | 6 | const cli = cac('comic-book-browser') 7 | 8 | export interface IOptions { 9 | bookPath: string 10 | port: number 11 | } 12 | 13 | const { version } = JSON.parse( 14 | readFileSync(new URL('../package.json', import.meta.url)).toString(), 15 | ) 16 | 17 | cli 18 | .option('-d, --bookPath ', '漫画目录(comic-book所在的目录) eg: -d .', { 19 | default: '.', 20 | }) 21 | .option('-p, --port ', '服务启动的端口号 eg: -p 3000', { 22 | default: 3000 23 | }) 24 | 25 | cli.help() 26 | cli.version(version) 27 | 28 | try { 29 | const { options } = cli.parse() 30 | // help version 不执行 31 | if (!options.help && !options.version) { 32 | run(options as IOptions) 33 | } 34 | } catch (err: any) { 35 | logger.error(err.message || 'unknown exception') 36 | process.exit(1) 37 | } 38 | -------------------------------------------------------------------------------- /server/src/utils/index.ts: -------------------------------------------------------------------------------- 1 | import os from 'node:os' 2 | 3 | export function notEmpty(value: TValue | null | undefined): value is TValue { 4 | return value !== null && value !== undefined 5 | } 6 | 7 | /** 8 | * 对源对象排除某些字段返回新对象(字段浅拷贝) 9 | */ 10 | export function excludeProperty(obj: any, propertyArr: string[]) { 11 | const res: any = {} 12 | for (const [key,value] of Object.entries(obj)) { 13 | if (!propertyArr.includes(key)) { 14 | res[key] = value 15 | } 16 | } 17 | return res 18 | } 19 | 20 | /** 获取本机ip地址 */ 21 | export function getIPAdress() { 22 | const interfaces = os.networkInterfaces() 23 | for (const [, iface] of Object.entries(interfaces)) { 24 | if (!iface) continue 25 | for (const alias of iface) { 26 | if (alias.family === 'IPv4' 27 | && alias.address !== '127.0.0.1' 28 | && !alias.internal) { 29 | return alias.address 30 | } 31 | } 32 | } 33 | return '127.0.0.1' 34 | } 35 | -------------------------------------------------------------------------------- /server/src/routes/api/comicBookList.ts: -------------------------------------------------------------------------------- 1 | import { mementoFn } from '@/utils/cache' 2 | import { scanFolder } from '@/routes/api/core' 3 | import type { RawBookInfo } from '@/routes/api/core' 4 | import { excludeProperty } from '@/utils/index' 5 | 6 | /** 排除掉 chapters coverUrl, 添加lastChapter最新章节内容 */ 7 | interface BookInfo extends Omit { 8 | lastChapter: { 9 | rawName: string | undefined 10 | } 11 | } 12 | type GetComicBookListRes = BookInfo[] 13 | 14 | async function getComicBookList(bookPath: string): Promise { 15 | const bookInfoList = await scanFolder(bookPath) 16 | return bookInfoList.map(bookInfo => { 17 | const lastChapter = bookInfo.chapters.at(-1) 18 | const bookInfoItem = excludeProperty(bookInfo, ['chapters', 'coverUrl']) 19 | bookInfoItem.lastChapter = { 20 | rawName: lastChapter?.rawName 21 | } 22 | return bookInfoItem 23 | }) 24 | } 25 | 26 | const cacheGetComicBookList = mementoFn(getComicBookList) 27 | 28 | export { 29 | cacheGetComicBookList as getComicBookList, 30 | } 31 | -------------------------------------------------------------------------------- /server/src/routes/api/comicBook.ts: -------------------------------------------------------------------------------- 1 | import { mementoFn } from '@/utils/cache' 2 | import { scanBookFolder } from '@/routes/api/core' 3 | import type { RawBookInfo, RawChaptersItem } from '@/routes/api/core' 4 | import { excludeProperty } from '@/utils/index' 5 | 6 | 7 | type OmitChapterItem = Omit 8 | interface GetComicBookRes extends Omit { 9 | chapters: OmitChapterItem[] 10 | } 11 | 12 | async function getComicBook(bookPath: string, comicBookName: string): Promise { 13 | const bookInfo = await scanBookFolder(bookPath, comicBookName) 14 | if (!bookInfo) return null 15 | const resBookInfo = excludeProperty(bookInfo, ['chapters', 'coverUrl']) 16 | resBookInfo.chapters = bookInfo.chapters.map(chapter => { 17 | return excludeProperty(chapter, ['imageList', 'imageListPath', 'preChapter', 'nextChapter', 'href']) 18 | }) 19 | return resBookInfo 20 | } 21 | 22 | const cacheGetComicBook = mementoFn(getComicBook) 23 | 24 | export { 25 | cacheGetComicBook as getComicBook 26 | } 27 | -------------------------------------------------------------------------------- /server/src/utils/cache.ts: -------------------------------------------------------------------------------- 1 | type anyFn = (...args: any[]) => any 2 | 3 | const caches = new Map>() 4 | 5 | function mementoFn (fn:T): T { 6 | const resFn = (...args: any[]) => { 7 | let currentCache = caches.get(fn) 8 | if (!currentCache) { 9 | currentCache = new Map() 10 | caches.set(fn, currentCache) 11 | } 12 | 13 | let cacheKey: any = args.join('_') 14 | if (args.length == 0) { 15 | cacheKey = fn 16 | } 17 | const cacheRes = currentCache.get(cacheKey) 18 | if (cacheRes) { 19 | return cacheRes 20 | } 21 | 22 | const res = fn(...args) 23 | if (res instanceof Promise) { 24 | const resPromise = res.then(function(value) { 25 | currentCache!.set(cacheKey, Promise.resolve(value)) 26 | return value 27 | }) 28 | currentCache.set(cacheKey, resPromise) 29 | return res 30 | } 31 | currentCache.set(cacheKey, res) 32 | return res 33 | } 34 | return resFn as T 35 | } 36 | 37 | function cleanCache() { 38 | caches.clear() 39 | } 40 | 41 | export { 42 | caches, 43 | mementoFn, 44 | cleanCache 45 | } -------------------------------------------------------------------------------- /client/src/constant.ts: -------------------------------------------------------------------------------- 1 | export const LOCAL_STORAGE_HISTORY = 'local_history' 2 | 3 | export interface ILocalHistoryItem { 4 | bookName: string, 5 | chapterName: string, 6 | rawChapterName: string 7 | } 8 | 9 | // 请求缓存30s 10 | export const REQUEST_CACHE_TIME = 1000 * 30 11 | 12 | // 请求缓存的key 13 | export const CACHE_KEY = { 14 | comicBookList: () => 'cache-comic-book-list', 15 | comicBook: (bookName: string) => `cache-${bookName}`, 16 | comicChapter: (bookName: string, chapterName: string) => `cache-${bookName}-${chapterName}`, 17 | } 18 | 19 | export const CACHE_OPTIONS = { 20 | comicBookList() { 21 | return { 22 | cacheKey: CACHE_KEY.comicBookList(), 23 | staleTime: REQUEST_CACHE_TIME, 24 | manual: true 25 | } 26 | }, 27 | comicBook(bookName: string) { 28 | return { 29 | cacheKey: CACHE_KEY.comicBook(bookName), 30 | staleTime: REQUEST_CACHE_TIME, 31 | manual: true 32 | } 33 | }, 34 | comicChapter(bookName: string, chapterName: string) { 35 | return { 36 | cacheKey: CACHE_KEY.comicChapter(bookName, chapterName), 37 | staleTime: REQUEST_CACHE_TIME, 38 | manual: true 39 | } 40 | } 41 | } -------------------------------------------------------------------------------- /server/src/routes/api/comicChapter.ts: -------------------------------------------------------------------------------- 1 | import { mementoFn } from '@/utils/cache' 2 | import { scanBookFolder } from '@/routes/api/core' 3 | import type { RawChaptersItem } from '@/routes/api/core' 4 | import { excludeProperty } from '@/utils' 5 | 6 | type GetComicChapterRes = Omit 7 | 8 | type GetComicChapter= (bookPath: string, bookName: string, chapterName: string) => Promise 9 | const getComicChapter: GetComicChapter = async (bookPath, bookName, chapterName) => { 10 | const bookInfo = await scanBookFolder(bookPath, bookName) 11 | if (!bookInfo) return null 12 | let res = bookInfo.chapters.find(chapter => { 13 | return chapter.name == chapterName 14 | }) ?? null 15 | if (res) { 16 | res = excludeProperty(res, ['imageList', 'href']) 17 | if (res?.nextChapter) { 18 | res.nextChapter = excludeProperty(res.nextChapter, ['href']) 19 | } 20 | if (res?.preChapter) { 21 | res.preChapter = excludeProperty(res.preChapter, ['href']) 22 | } 23 | } 24 | return res 25 | } 26 | 27 | const cacheGetComicChapter = mementoFn(getComicChapter) 28 | 29 | export { 30 | cacheGetComicChapter as getComicChapter 31 | } 32 | -------------------------------------------------------------------------------- /client/src/hooks/useTheme.ts: -------------------------------------------------------------------------------- 1 | import { useLayoutEffect, useRef, useState } from 'react' 2 | 3 | const LOCAL_THEME_KEY = 'theme' 4 | 5 | export enum THEME { 6 | LIGHT = 'light', 7 | DARK = 'dark' 8 | } 9 | 10 | interface Actions { 11 | switchTheme: () => void, 12 | } 13 | 14 | export function useTheme(): [string, Actions] { 15 | const [theme, setTheme] = useState(THEME.LIGHT) 16 | const initial = useRef(true) 17 | 18 | useLayoutEffect(() => { 19 | const newTheme = localStorage.getItem(LOCAL_THEME_KEY) as THEME || THEME.LIGHT 20 | setTheme(newTheme) 21 | }, []) 22 | 23 | useLayoutEffect(() => { 24 | if (initial.current) { 25 | initial.current = false 26 | } else { 27 | document.documentElement.classList.remove(THEME.DARK) 28 | document.documentElement.classList.remove(THEME.LIGHT) 29 | document.documentElement.classList.add(theme) 30 | localStorage.setItem(LOCAL_THEME_KEY, theme) 31 | } 32 | }, [theme]) 33 | 34 | function switchTheme() { 35 | const newTheme = theme === THEME.LIGHT ? THEME.DARK : THEME.LIGHT 36 | setTheme(newTheme) 37 | } 38 | return [ 39 | theme, 40 | { 41 | switchTheme 42 | } 43 | ] 44 | } 45 | -------------------------------------------------------------------------------- /client/vite.config.ts: -------------------------------------------------------------------------------- 1 | import path from 'path' 2 | import { defineConfig } from 'vite' 3 | import { fileURLToPath, URL } from 'url' 4 | import react from '@vitejs/plugin-react-swc' 5 | import { viteVConsole } from 'vite-plugin-vconsole' 6 | // import { visualizer } from "rollup-plugin-visualizer" 7 | // https://vitejs.dev/config/ 8 | export default defineConfig({ 9 | plugins: [ 10 | react(), 11 | { 12 | ...viteVConsole({ 13 | entry: path.resolve('client/src/main.tsx'), // or you can use entry: [path.resolve('src/main.ts')] 14 | enabled: true, 15 | config: { 16 | maxLogNumber: 1000, 17 | theme: 'dark' 18 | } 19 | }), 20 | apply: 'serve' 21 | } 22 | // visualizer({ 23 | // gzipSize: true, 24 | // brotliSize: true, 25 | // emitFile: false, 26 | // filename: "visualizer.html", 27 | // open:true 28 | // }) 29 | ], 30 | build: { 31 | outDir: '../client-dist', 32 | emptyOutDir: true 33 | }, 34 | resolve: { 35 | alias: { 36 | '@': fileURLToPath(new URL('./src', import.meta.url)), 37 | } 38 | }, 39 | 40 | server: { 41 | host: '0.0.0.0', 42 | proxy: { 43 | '/api': { 44 | target: 'http://localhost:3000', 45 | changeOrigin: true 46 | }, 47 | '/public': { 48 | target: 'http://localhost:3000', 49 | changeOrigin: true 50 | } 51 | } 52 | } 53 | }) 54 | -------------------------------------------------------------------------------- /client/src/globals.css: -------------------------------------------------------------------------------- 1 | @tailwind base; 2 | @tailwind components; 3 | @tailwind utilities; 4 | 5 | :root { 6 | color-scheme: light; 7 | --foreground-rgb: 0, 0, 0; 8 | --background-start-rgb: 214, 219, 220; 9 | --background-end-rgb: 255, 255, 255; 10 | 11 | /* primary */ 12 | /* #fff */ 13 | --c-p-1: 248 248 248; 14 | /* rgb(245 248 252) */ 15 | /* rgb(250 250 251) */ 16 | --c-p-2: 255 255 255; 17 | /* sky-400 rgb(245 127 23) */ 18 | --c-p-3: 245 127 23; 19 | /* sky-200 rgb(249 202 113) */ 20 | --c-p-4: 249 202 113; 21 | --c-br: rgb(15 23 42 / 10%); 22 | /* secondary */ 23 | --c-s-1: #000; 24 | /* background-color: #0f172abf; */ 25 | } 26 | 27 | :root.dark { 28 | color-scheme: dark; 29 | color: white; 30 | --foreground-rgb: 255, 255, 255; 31 | --background-start-rgb: 0, 0, 0; 32 | --background-end-rgb: 0, 0, 0; 33 | 34 | /* primary */ 35 | /* #0f172a */ 36 | --c-p-1: 15 23 42; 37 | /* #1e293b */ 38 | --c-p-2: 30 41 59; 39 | /* sky-400 #38bdf8 */ 40 | --c-p-3: 56 189 248; 41 | /* sky-200 #bae6fd */ 42 | --c-p-4: 186 230 253; 43 | --c-br: rgb(203 213 225 / 10%); 44 | /* secondary */ 45 | --c-s-1: #fff; 46 | /* bg-slate-900\/75 */ 47 | } 48 | 49 | body { 50 | -webkit-overflow-scrolling: touch; 51 | } 52 | 53 | @layer base { 54 | a:active { 55 | @apply text-p-4; 56 | } 57 | a:hover { 58 | @apply text-p-3; 59 | } 60 | img { 61 | @apply pointer-events-none 62 | } 63 | } -------------------------------------------------------------------------------- /client/tailwind.config.js: -------------------------------------------------------------------------------- 1 | /** @type {import('tailwindcss').Config} */ 2 | 3 | export default { 4 | important: true, 5 | darkMode: 'class', 6 | content: [ 7 | 'client/index.html', 8 | 'client/src/**/*.{js,ts,jsx,tsx}', 9 | ], 10 | theme: { 11 | extend: { 12 | colors: { 13 | 'p-1': 'rgb(var(--c-p-1) / )', 14 | 'p-2': 'rgb(var(--c-p-2) / )', 15 | 'p-3': 'rgb(var(--c-p-3) / )', 16 | 'p-4': 'rgb(var(--c-p-4) / )', 17 | 's-1': 'rgb(var(--c-s-1) / )' 18 | }, 19 | boxShadow: { 20 | 'br': 'inset 0 0 0 1px var(--c-br)', 21 | 'top': '0 -4px 20px rgba(88, 99, 148, 0.17)', 22 | 'bottom': '0 4px 20px rgba(88, 99, 148, 0.17)', 23 | 'cover-1': '0 0 20px 5px #ddd', 24 | 'cover-2': '0 0 20px 5px rgb(0 0 0 / 14%)' 25 | } 26 | }, 27 | }, 28 | plugins: [ 29 | function ({ addVariant }) { 30 | addVariant( 31 | 'supports-backdrop-blur', 32 | '@supports (backdrop-filter: blur(0)) or (-webkit-backdrop-filter: blur(0))' 33 | ) 34 | addVariant('supports-scrollbars', '@supports selector(::-webkit-scrollbar)') 35 | addVariant('children', '& > *') 36 | addVariant('scrollbar', '&::-webkit-scrollbar') 37 | addVariant('scrollbar-track', '&::-webkit-scrollbar-track') 38 | addVariant('scrollbar-thumb', '&::-webkit-scrollbar-thumb') 39 | addVariant('demo-dark', '.demo-dark &') 40 | }, 41 | // require('@tailwindcss/line-clamp'), 42 | ] 43 | } -------------------------------------------------------------------------------- /client/src/components/BackTop/index.tsx: -------------------------------------------------------------------------------- 1 | import { useCallback, useEffect, useState } from 'react' 2 | import { useDebounceFn, useEventListener } from 'ahooks' 3 | 4 | interface BackTopProps { 5 | /** 是否显示(show 优先判断) */ 6 | show?: boolean; 7 | /** 距离多少高度显示 */ 8 | visibilityHeight?: number 9 | } 10 | 11 | export default function BackTop(props: Readonly) { 12 | const { 13 | show: propShow = true, 14 | visibilityHeight = 2000 15 | } = props 16 | const [show, setShow] = useState(false) 17 | 18 | const checkShow = useCallback(() => { 19 | const { scrollTop } = document.documentElement 20 | setShow(scrollTop >= visibilityHeight && propShow) 21 | }, [propShow, visibilityHeight]) 22 | 23 | useEffect(() => { 24 | checkShow() 25 | }, [propShow, checkShow]) 26 | 27 | const onScroll = checkShow 28 | const {run} = useDebounceFn(onScroll,{wait: 100}) 29 | useEventListener('scroll', run, {passive: true}) 30 | 31 | const backTop = () => { 32 | window.scrollTo({ 33 | top: 0, 34 | behavior: 'smooth' 35 | }) 36 | } 37 | 38 | return ( 39 | 49 | ) 50 | } -------------------------------------------------------------------------------- /client/src/pages/Home/index.tsx: -------------------------------------------------------------------------------- 1 | import { useEffect, useState } from 'react' 2 | import { useRequest } from 'ahooks' 3 | import * as api from '@/api' 4 | import type { BookInfo } from '@/api' 5 | import BookList from '@/pages/Home/BookList' 6 | import Header from '@/components/Header' 7 | import { CACHE_OPTIONS } from '@/constant' 8 | import Loading from '@/components/Loading' 9 | 10 | export default function Home() { 11 | const [bookInfoList, setBookInfoList] = useState([]) 12 | const { runAsync: runComicBookList } = useRequest(api.comicBookList, CACHE_OPTIONS.comicBookList()) 13 | const [loading, setLoading] = useState(false) 14 | 15 | const init = async function () { 16 | setLoading(true) 17 | const newBookInfoList = await runComicBookList() 18 | setBookInfoList(newBookInfoList) 19 | setLoading(false) 20 | } 21 | 22 | useEffect(() => { 23 | init() 24 | }, []) 25 | 26 | return loading ? 27 | : 28 | (<> 29 |
30 |
31 | { bookInfoList.length > 0 ? 32 | ( 33 |
34 | 35 |
36 | ) : ( 37 |
38 | Not Found 39 |
40 | ) 41 | } 42 |
43 | ) 44 | } -------------------------------------------------------------------------------- /client/src/pages/Chapter/Provider.tsx: -------------------------------------------------------------------------------- 1 | import { createContext } from 'react' 2 | import type { ComicBookRes, ComicChapterRes } from '@/api' 3 | 4 | interface BookInfoProviderProps { 5 | children: React.ReactNode 6 | bookInfo: ComicBookRes | null 7 | } 8 | 9 | const defaultBookInfo = { 10 | name: '', 11 | pathName: '', 12 | author: '', 13 | desc: '', 14 | coverUrl: '', 15 | coverPath: '', 16 | chapters: [], 17 | url: '', 18 | language: '', 19 | rawUrl: '' 20 | } 21 | const BookInfoContext = createContext(defaultBookInfo) 22 | 23 | function BookInfoProvider ({ children, bookInfo }: Readonly) { 24 | if (bookInfo) { 25 | return ( 26 | 27 | {children} 28 | 29 | ) 30 | } 31 | return <>{children} 32 | } 33 | 34 | 35 | interface ChapterInfoProviderProps { 36 | children: React.ReactNode 37 | chapterInfo: ComicChapterRes | null | undefined 38 | } 39 | 40 | const defaultComicChapter = { 41 | name: '', 42 | imageListPath: [], 43 | rawName: '', 44 | index: -1 45 | } 46 | 47 | const ChapterInfoContext = createContext(defaultComicChapter) 48 | 49 | function ChapterInfoProvider ({ children, chapterInfo }: Readonly) { 50 | if (chapterInfo) { 51 | return ( 52 | 53 | {children} 54 | 55 | ) 56 | } 57 | return <>{children} 58 | } 59 | 60 | export { 61 | BookInfoContext, 62 | BookInfoProvider, 63 | ChapterInfoContext, 64 | ChapterInfoProvider 65 | } -------------------------------------------------------------------------------- /client/src/assets/iconfont/iconfont.css: -------------------------------------------------------------------------------- 1 | @font-face { 2 | font-family: "iconfont"; /* Project id 4392098 */ 3 | src: url('iconfont.woff2?t=1704681415578') format('woff2'), 4 | url('iconfont.woff?t=1704681415578') format('woff'), 5 | url('iconfont.ttf?t=1704681415578') format('truetype'); 6 | } 7 | 8 | .iconfont { 9 | font-family: "iconfont" !important; 10 | font-size: 16px; 11 | font-style: normal; 12 | -webkit-font-smoothing: antialiased; 13 | -moz-osx-font-smoothing: grayscale; 14 | } 15 | 16 | .icon-github:before { 17 | content: "\e811"; 18 | } 19 | 20 | .icon-search:before { 21 | content: "\e82e"; 22 | } 23 | 24 | .icon-search1:before { 25 | content: "\e67d"; 26 | } 27 | 28 | .icon-clean:before { 29 | content: "\e611"; 30 | } 31 | 32 | .icon-refresh:before { 33 | content: "\e61d"; 34 | } 35 | 36 | .icon-history1:before { 37 | content: "\e675"; 38 | } 39 | 40 | .icon-history:before { 41 | content: "\e834"; 42 | } 43 | 44 | .icon-home:before { 45 | content: "\e674"; 46 | } 47 | 48 | .icon-back-top:before { 49 | content: "\e613"; 50 | } 51 | 52 | .icon-loading:before { 53 | content: "\e891"; 54 | } 55 | 56 | .icon-sort:before { 57 | content: "\e6b7"; 58 | } 59 | 60 | .icon-link:before { 61 | content: "\e600"; 62 | } 63 | 64 | .icon-close:before { 65 | content: "\e685"; 66 | } 67 | 68 | .icon-catalog:before { 69 | content: "\e60b"; 70 | } 71 | 72 | .icon-left:before { 73 | content: "\e952"; 74 | } 75 | 76 | .icon-right:before { 77 | content: "\e955"; 78 | } 79 | 80 | .icon-sun:before { 81 | content: "\e789"; 82 | } 83 | 84 | .icon-moon:before { 85 | content: "\e867"; 86 | } 87 | 88 | .icon-logout:before { 89 | content: "\e653"; 90 | } 91 | 92 | -------------------------------------------------------------------------------- /server/src/routes/api/index.ts: -------------------------------------------------------------------------------- 1 | import Router from '@koa/router' 2 | import { STATUS_CODE } from '@/constant' 3 | import { cleanCache } from '@/utils/cache' 4 | import { getComicBookList } from './comicBookList' 5 | import { getComicBook } from './comicBook' 6 | import { getComicChapter } from './comicChapter' 7 | 8 | const router = new Router() 9 | 10 | // 获取漫画列表 11 | router.get('/comicBookList',async (ctx) => { 12 | const data = await getComicBookList(ctx.G.bookPath) 13 | ctx.body = { 14 | code: STATUS_CODE.SUCCESS, 15 | data 16 | } 17 | }) 18 | 19 | // 获取某本漫画(含 Chapter章节内容 不含imageList) 20 | router.get('/comicBook',async (ctx) => { 21 | const { bookPath } = ctx.G 22 | const { name } = ctx.query 23 | if (!bookPath || !name || Array.isArray(name)) { 24 | ctx.body = { 25 | code: STATUS_CODE.MISSING_PARAM 26 | } 27 | return 28 | } 29 | const data = await getComicBook(bookPath, name) 30 | ctx.body = { 31 | code: STATUS_CODE.SUCCESS, 32 | data 33 | } 34 | }) 35 | 36 | // 获取漫画某章节具体内容(含imageList) 37 | router.get('/comicChapter',async (ctx) => { 38 | const { bookPath } = ctx.G 39 | const { name, chapter } = ctx.query 40 | 41 | if (!bookPath || 42 | !name || Array.isArray(name) || 43 | !chapter || Array.isArray(chapter)) { 44 | ctx.body = { 45 | code: STATUS_CODE.MISSING_PARAM 46 | } 47 | return 48 | } 49 | const data = await getComicChapter(bookPath, name, chapter) 50 | 51 | ctx.body = { 52 | code: STATUS_CODE.SUCCESS, 53 | data 54 | } 55 | }) 56 | 57 | // 清理服务端扫描文件缓存 58 | router.get('/cleanCache', (ctx) => { 59 | cleanCache() 60 | ctx.body = { 61 | code: STATUS_CODE.SUCCESS 62 | } 63 | }) 64 | 65 | export default router -------------------------------------------------------------------------------- /client/src/pages/Chapter/ChapterHeader/index.tsx: -------------------------------------------------------------------------------- 1 | import { useContext } from 'react' 2 | import { Link } from 'react-router-dom' 3 | import { useTheme } from '@/hooks/useTheme' 4 | import { BookInfoContext } from '@/pages/Chapter/Provider' 5 | 6 | interface ChapterHeaderProps { 7 | show: boolean, 8 | chapterName: string 9 | } 10 | 11 | export default function ChapterHeader(props: Readonly) { 12 | const { show, chapterName } = props 13 | const [, {switchTheme}] = useTheme() 14 | const bookInfo = useContext(BookInfoContext) 15 | const chapterInfo = bookInfo.chapters.find(item => item.name === chapterName) 16 | return ( 17 |
24 |
25 |
26 |
27 |
28 | 29 | 30 | 31 |
32 |

33 | {chapterInfo?.rawName} 34 |

35 |
36 | 40 |
41 |
42 |
43 |
44 |
45 | ) 46 | } 47 | -------------------------------------------------------------------------------- /client/src/pages/Chapter/index.tsx: -------------------------------------------------------------------------------- 1 | import { useEffect, useState } from 'react' 2 | import { useParams } from 'react-router-dom' 3 | import { useRequest, useTitle } from 'ahooks' 4 | import { BookInfoProvider, ChapterInfoProvider } from '@/pages/Chapter/Provider' 5 | import ChapterContent from '@/pages/Chapter/ChapterContent' 6 | import ComicWarp from '@/pages/Chapter/ComicWarp' 7 | import * as api from '@/api' 8 | import type {ComicBookRes, ComicChapterRes} from '@/api' 9 | import { CACHE_OPTIONS } from '@/constant' 10 | import Loading from '@/components/Loading' 11 | 12 | export default function Chapter() { 13 | const { bookName = '', chapterName = '' } = useParams() 14 | useTitle(`${bookName} - ${chapterName} - Comic Browser`) 15 | const [loading, setLoading] = useState(false) 16 | const [bookInfo, setBookInfo] = useState(null) 17 | const [chapterInfo, setChapterInfo] = useState() 18 | 19 | const { runAsync: runComicChapter } = useRequest( 20 | api.comicChapter, 21 | CACHE_OPTIONS.comicChapter(bookName, chapterName) 22 | ) 23 | const { runAsync: runComicBook } = useRequest( 24 | api.comicBook, 25 | CACHE_OPTIONS.comicBook(bookName) 26 | ) 27 | 28 | async function init() { 29 | setLoading(true) 30 | 31 | const bookInfo = await runComicBook(bookName) 32 | setBookInfo(bookInfo) 33 | const chapterInfo = await runComicChapter(bookName, chapterName) 34 | setChapterInfo(chapterInfo) 35 | 36 | setLoading(false) 37 | } 38 | 39 | useEffect(() => { 40 | init() 41 | }, [bookName, chapterName]) 42 | 43 | return ( 44 | loading ? 45 | : 46 | 47 | 48 | 51 | 54 | 55 | 56 | 57 | ) 58 | } -------------------------------------------------------------------------------- /server/src/index.ts: -------------------------------------------------------------------------------- 1 | import path from 'node:path' 2 | import fs from 'node:fs' 3 | import { fileURLToPath } from 'node:url' 4 | import Koa from 'koa' 5 | import serve from 'koa-static' 6 | import mount from 'koa-mount' 7 | import qrcode from 'qrcode-terminal' 8 | import router from './routes/index' 9 | import { IOptions } from './cli' 10 | import { logger } from './utils/log' 11 | import { scanFolder } from './routes/api/core' 12 | import { getIPAdress } from './utils' 13 | 14 | export function run(config: IOptions) { 15 | const staticPath = path.resolve(config.bookPath) 16 | const bookPath = path.join(staticPath, 'comic-book') 17 | 18 | const isExists = fs.existsSync(bookPath) 19 | if (!isExists) { 20 | logger.error('× 不存在 comic-book 目录') 21 | return 22 | } 23 | 24 | const clientPath = path.join( 25 | fileURLToPath(import.meta.url), 26 | '../../client-dist' 27 | ) 28 | 29 | const app = new Koa() 30 | // 设置全局上下文 后续路由可取 31 | app.context.G = { 32 | staticPath, 33 | bookPath: bookPath 34 | } 35 | app.use(router.routes()) 36 | // 挂载静态资源目录 37 | app.use(mount('/public', serve(staticPath))) 38 | // 挂载客户端目录 39 | app.use(mount('/', serve(clientPath))) 40 | app.listen(config.port, () => { 41 | logger.info('(つ•̀ω•́)つ 欢迎star: https://github.com/gxr404/comic-book-browser') 42 | const ip = getIPAdress() 43 | let internalNetwork = '' 44 | const localNetwork = `http://127.0.0.1:${config.port}` 45 | let infoStr = '√ 服务已启动,请用浏览器打开' 46 | if (ip !== '127.0.0.1') { 47 | internalNetwork = `http://${ip}:${config.port}` 48 | infoStr += `${internalNetwork} or` 49 | } 50 | infoStr += ` ${localNetwork}` 51 | logger.info(infoStr) 52 | echoQRcode(internalNetwork || localNetwork) 53 | // 提前扫描目录 54 | scanFolder(bookPath) 55 | }) 56 | } 57 | 58 | export function echoQRcode(url: string) { 59 | return new Promise((resolve, reject) => { 60 | try { 61 | qrcode.generate(url, { small: true }, (qrcode: string) => { 62 | console.log(qrcode) 63 | resolve(qrcode) 64 | }) 65 | } catch(e) { 66 | reject(e) 67 | } 68 | }) 69 | } 70 | -------------------------------------------------------------------------------- /client/src/pages/Chapter/ChapterContent/index.tsx: -------------------------------------------------------------------------------- 1 | import { useContext, useRef, useState } from 'react' 2 | import { BookInfoContext, ChapterInfoContext } from '@/pages/Chapter/Provider' 3 | 4 | interface FCProps { 5 | bookName: string, 6 | chapterName: string 7 | } 8 | 9 | interface ComicImageProps { 10 | imagePath: string, 11 | index: number, 12 | bookName: string 13 | } 14 | function ComicImage(props: Readonly) { 15 | const {imagePath} = props 16 | const [loading, setLoading] = useState(true) 17 | const imgRef = useRef(null) 18 | // const warpImgRef = useRef(null) 19 | 20 | const onLoad = (e: any) => { 21 | setLoading(false) 22 | if (e?.target?.naturalHeight && imgRef.current) { 23 | imgRef.current.style.setProperty('min-height', 'initial', 'important') 24 | // warpImgRef.current.style.setProperty('min-height', 'initial', 'important') 25 | } 26 | } 27 | return ( 28 |
  • 29 | { 30 | loading && 31 |
    32 | 33 |
    34 | } 35 | {imagePath}/ 42 |
  • 43 | ) 44 | } 45 | 46 | interface ListProps { 47 | bookName: string, 48 | imageListPath: string[] 49 | } 50 | function List({bookName, imageListPath}: Readonly) { 51 | return ( 52 |
      53 | {imageListPath.map((imagePath, index) => { 54 | return 55 | })} 56 |
    57 | ) 58 | } 59 | 60 | const ChapterContent: React.FC = ({ bookName }) => { 61 | const bookInfo = useContext(BookInfoContext) 62 | const chapterInfo = useContext(ChapterInfoContext) 63 | const imageListPath = chapterInfo.imageListPath 64 | return ( 65 |
    66 | {(bookInfo && imageListPath.length>0) 67 | ? 68 | :
    69 | Not Found 70 |
    } 71 |
    72 | ) 73 | } 74 | 75 | export default ChapterContent -------------------------------------------------------------------------------- /client/src/components/Header/index.tsx: -------------------------------------------------------------------------------- 1 | import { useState } from 'react' 2 | import { Link } from 'react-router-dom' 3 | import Search from '@/components/Search' 4 | import { useTheme } from '@/hooks/useTheme' 5 | import type { ComicBookListRes } from '@/api' 6 | 7 | import Logo from '@/assets/logo.png' 8 | import LogoDark from '@/assets/logo-dark.png' 9 | import { useEventListener } from 'ahooks' 10 | 11 | interface HeaderProps { 12 | bookInfoList: ComicBookListRes 13 | } 14 | 15 | export default function Header(props: Readonly) { 16 | const { bookInfoList = [] } = props 17 | const [, {switchTheme}] = useTheme() 18 | const [isOpaque, setIsOpaque] = useState(false) 19 | const offset = 20 20 | function onScroll() { 21 | if (!isOpaque && window.scrollY > offset) { 22 | setIsOpaque(true) 23 | } else if (isOpaque && window.scrollY <= offset) { 24 | setIsOpaque(false) 25 | } 26 | } 27 | useEventListener('scroll', onScroll, {passive: true}) 28 | 29 | return ( 30 |
    40 |
    41 |
    42 |
    43 |
    44 | 45 | logo 46 | logo 47 | 48 |
    49 | { 50 | bookInfoList?.length > 0 && 51 | 52 | } 53 |
    54 | 55 | 56 | 57 | 61 |
    62 |
    63 |
    64 |
    65 |
    66 | ) 67 | } 68 | -------------------------------------------------------------------------------- /client/src/pages/Chapter/ComicWarp/index.tsx: -------------------------------------------------------------------------------- 1 | import { useContext, useEffect, useRef, useState } from 'react' 2 | import { useDebounceFn, useEventListener, useLocalStorageState } from 'ahooks' 3 | import { LOCAL_STORAGE_HISTORY } from '@/constant' 4 | import type { ILocalHistoryItem } from '@/constant' 5 | import { ChapterInfoContext } from '@/pages/Chapter/Provider' 6 | import ChapterFooter from '@/pages/Chapter/ChapterFooter' 7 | import ChapterHeader from '@/pages/Chapter/ChapterHeader' 8 | import BackTop from '@/components/BackTop' 9 | 10 | interface ComicWarpProps { 11 | children: React.ReactNode, 12 | chapterName: string, 13 | bookName: string 14 | } 15 | 16 | export default function ComicWarp({ children, chapterName, bookName }: Readonly) { 17 | const [showMenu, setShowMenu] = useState(true) 18 | const initRef = useRef(true) 19 | const [localHistory, setLocalHistory] = useLocalStorageState(LOCAL_STORAGE_HISTORY, { 20 | defaultValue: [] 21 | }) 22 | const tempScrollTop = useRef(0) 23 | const chapterInfo = useContext(ChapterInfoContext) 24 | 25 | const onScroll = () => { 26 | const scrollTop = document.body.scrollTop || document.documentElement.scrollTop 27 | // 滚到底部 快40像素时显示窗口 28 | const isScrollEnd = window.scrollY + window.innerHeight + 40 >= document.documentElement.scrollHeight 29 | // 向上滚显示菜单 向下滚隐藏菜单 30 | setShowMenu(scrollTop <= tempScrollTop.current || isScrollEnd) 31 | tempScrollTop.current = scrollTop 32 | } 33 | const {run} = useDebounceFn(onScroll,{wait: 100}) 34 | useEventListener('scroll', run, {passive: true}) 35 | 36 | useEffect(() => { 37 | if (!chapterInfo.rawName 38 | && chapterInfo.imageListPath.length === 0){ 39 | return 40 | } 41 | const newHistoryItem = { 42 | bookName, 43 | chapterName, 44 | rawChapterName: chapterInfo?.rawName || '' 45 | } 46 | if (!initRef.current) return 47 | initRef.current = false 48 | if (!localHistory) { 49 | setLocalHistory([newHistoryItem]) 50 | } else { 51 | const index = localHistory?.findIndex(item => item.bookName === bookName) ?? -1 52 | if (index >= 0) { 53 | localHistory.splice(index, 1) 54 | } 55 | setLocalHistory([...localHistory, newHistoryItem]) 56 | } 57 | }, [bookName, chapterName, localHistory, setLocalHistory, chapterInfo]) 58 | 59 | return ( 60 | <> 61 | 62 |
    setShowMenu(!showMenu)}> 63 |
    64 | {children} 65 |
    66 |
    67 | 68 | 69 | 70 | ) 71 | } -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "comic-book-browser", 3 | "version": "1.0.16", 4 | "description": "Comic Book Browser ", 5 | "bin": { 6 | "comic-book-browser": "bin/index.js" 7 | }, 8 | "main": "index.js", 9 | "keywords": [ 10 | "manga", 11 | "comic", 12 | "nodejs", 13 | "download", 14 | "comic-browser", 15 | "comic-book-browser", 16 | "cli" 17 | ], 18 | "author": "gxr404", 19 | "license": "ISC", 20 | "type": "module", 21 | "repository": { 22 | "type": "git", 23 | "url": "git+https://github.com/gxr404/comic-book-browser.git" 24 | }, 25 | "scripts": { 26 | "dev:client": "vite client", 27 | "dev:server": "tsc -p server/tsconfig.json && (concurrently \"tsc -p server/tsconfig.json -w\" \"tsc-alias -p server/tsconfig.json -w\")", 28 | "preview": "vite preview --outDir client-dist", 29 | "build": "run-s build:*", 30 | "build:client": "tsc -p ./client/tsconfig.json && vite build client", 31 | "build:server": "tsc -p server/tsconfig.json && tsc-alias -p server/tsconfig.json", 32 | "lint": "eslint . --ext ts,tsx --report-unused-disable-directives --max-warnings 0", 33 | "eslintLog": "eslint . > eslint.log", 34 | "clean": "rimraf client-dist server-dist", 35 | "np": "np --no-tests", 36 | "release": "run-s clean build np" 37 | }, 38 | "dependencies": { 39 | "@koa/router": "^12.0.1", 40 | "cac": "^6.7.14", 41 | "koa": "^2.15.0", 42 | "koa-mount": "^4.0.0", 43 | "koa-static": "^5.0.0", 44 | "log4js": "^6.9.1", 45 | "p-limit": "^5.0.0", 46 | "qrcode-terminal": "^0.12.0" 47 | }, 48 | "devDependencies": { 49 | "@types/koa": "^2.13.12", 50 | "@types/koa__router": "^12.0.4", 51 | "@types/koa-mount": "^4.0.5", 52 | "@types/koa-static": "^4.0.4", 53 | "@types/qrcode-terminal": "^0.12.2", 54 | "@types/react": "^18.2.43", 55 | "@types/react-dom": "^18.2.17", 56 | "@typescript-eslint/eslint-plugin": "^6.14.0", 57 | "@typescript-eslint/parser": "^6.14.0", 58 | "@vitejs/plugin-react-swc": "^3.5.0", 59 | "ahooks": "^3.7.8", 60 | "antd": "^5.12.7", 61 | "autoprefixer": "^10.4.16", 62 | "concurrently": "^8.2.2", 63 | "eslint": "^8.55.0", 64 | "eslint-plugin-react-hooks": "^4.6.0", 65 | "eslint-plugin-react-refresh": "^0.4.5", 66 | "np": "^9.2.0", 67 | "npm-run-all": "^4.1.5", 68 | "postcss": "^8.4.33", 69 | "react": "^18.2.0", 70 | "react-dom": "^18.2.0", 71 | "react-router-dom": "^6.21.1", 72 | "react-virtuoso": "^4.6.2", 73 | "rimraf": "^5.0.5", 74 | "tailwindcss": "^3.4.0", 75 | "tsc-alias": "^1.8.8", 76 | "typescript": "^5.2.2", 77 | "vconsole": "^3.15.1", 78 | "vite": "^5.0.8", 79 | "vite-plugin-vconsole": "^2.0.1" 80 | }, 81 | "engines": { 82 | "node": ">=16.14.0" 83 | }, 84 | "np": { 85 | "tests": false, 86 | "2fa": false 87 | } 88 | } 89 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Comic Book Browser 2 | 3 | ![logo](https://socialify.git.ci/gxr404/comic-book-browser/image?font=Source%20Code%20Pro&logo=https%3A%2F%2Fgithub.com%2Fgxr404%2Fcomic-book-browser%2Fraw%2Fmain%2Fdocs%2Flogo.png&name=1&pattern=Circuit%20Board&theme=Dark) 4 | 5 | 6 | 7 |

    8 | 一款漫画浏览器(搭配comic-book-dl使用)
    9 | 开源 | 高效 | 易用

    10 | npm 11 | Static Badge 12 | GitHub License 13 |
    14 |

    15 | 16 | ## 动机 17 | 18 | 平常喜欢看漫画的人肯定有体验过在网页看漫画,看着看着就突然弹出各种跳花里胡哨的小广告, 不小心点到还跳转到广告网站,体验非常差。 19 | 20 | 因此我就想开发一套离线本地存储的漫画书架,可以轻松管理平时关注的漫画,且无广告界面简洁,一些经典完结的漫画也可以当收藏存到自己的硬盘里,由此诞生了该项目🤔。 21 | 22 | ## 安装 23 | 24 | ```bash 25 | npm i -g comic-book-browser 26 | ``` 27 | 28 | ## 用法 29 | 30 | ```bash 31 | $ comic-book-browser --help 32 | 33 | Usage: 34 | $ comic-book-browser [options] 35 | 36 | Options: 37 | -d, --bookPath 漫画目录(comic-book所在的目录) eg: -d . (default: .) 38 | -p, --port 服务启动的端口号 eg: -p 3000 (default: 3000) 39 | -h, --help Display this message 40 | -v, --version Display version number 41 | ``` 42 | 43 | ## Start 44 | 45 | 使用 [comic-book-dl](https://github.com/gxr404/comic-book-dl) 下载完漫画后在当前含有`comic-book`目录 46 | 执行: 47 | 48 | ```bash 49 | # 当前目录需含有 comic-book文件夹 50 | $ comic-book-browser 51 | 52 | > comic-book-browser [INFO]: \(^o^)/ 服务已启动 请用浏览器打开 http://127.0.0.1:3000 53 | ``` 54 | 55 | > PS: 当然也可以不使用`comic-book-dl` 只要当前目录符合结构即可正常启动,注意的是 `bookInfo.json`里的字段得有且符合对应结构 56 | 57 | ```bash 58 | . 59 | └── comic-book 60 | ├── <漫画名> 61 | │   ├── bookInfo.json 62 | │   ├── cover.jpg 63 | │   └── chapters 64 | │   ├── 第01话 65 | │ │   └── xxx.jpg 66 | │ .... 67 | ``` 68 | 69 | ## 常见问题 70 | 71 | - 新增漫画时如果刷新没显示新漫画? 72 | - 可点击右下角清理缓存,或者重新启动`comic-book-browser`服务即可 73 | 74 | ## 界面 75 | 76 | `comic-book-browser`提供了两套主题、适配移动端、界面简洁 77 | 78 | view-1
    79 | view-2
    80 | view-3
    81 | view-4
    82 | view-5 83 | 84 | ## 功能与建议 85 | 86 | 目前项目处于开发初期, 如果你对该项目有任何功能与建议,欢迎在 Issues 中提出 87 | -------------------------------------------------------------------------------- /client/src/pages/Detail/index.tsx: -------------------------------------------------------------------------------- 1 | import { useEffect, useState } from 'react' 2 | import { Link, useParams } from 'react-router-dom' 3 | import { useRequest, useTitle } from 'ahooks' 4 | import * as api from '@/api' 5 | import { CACHE_OPTIONS } from '@/constant' 6 | import type {BookInfo, ComicBookRes} from '@/api' 7 | import ChapterList from '@/pages/Detail/ChapterList' 8 | import Header from '@/components/Header' 9 | import Loading from '@/components/Loading' 10 | 11 | export default function Detail() { 12 | const { bookName = '' } = useParams() 13 | useTitle(`${bookName} - Comic Browser`) 14 | const [bookInfoList, setBookInfoList] = useState([]) 15 | const [bookInfo, setBookInfo] = useState() 16 | const [loading, setLoading] = useState(false) 17 | 18 | const { runAsync: runComicBook } = useRequest(api.comicBook, CACHE_OPTIONS.comicBook(bookName)) 19 | const { runAsync: runComicBookList } = useRequest(api.comicBookList, CACHE_OPTIONS.comicBookList()) 20 | 21 | async function init() { 22 | setLoading(true) 23 | const newBookInfoList = await runComicBookList() 24 | setBookInfoList(newBookInfoList) 25 | 26 | const newBookInfo = await runComicBook(bookName) 27 | setBookInfo(newBookInfo) 28 | setLoading(false) 29 | } 30 | 31 | useEffect(() => { 32 | init() 33 | }, [bookName]) 34 | 35 | return loading ? 36 | : 37 | <> 38 |
    39 |
    40 | { 41 | bookInfo ? 42 | <> 43 |
    44 |
    49 | {bookInfo.pathName} 50 |
    51 |
    52 |

    {bookName}

    53 |

    {bookInfo.author}

    54 |

    {bookInfo.desc}

    55 |

    56 | 57 | 来源 58 | 59 |

    60 |
    61 |
    62 | 63 | : 64 |
    65 | Not Found 66 |
    67 | } 68 |
    69 | 70 | } -------------------------------------------------------------------------------- /server/src/routes/api/core.ts: -------------------------------------------------------------------------------- 1 | import {readdir, stat, readFile} from 'node:fs/promises' 2 | import { join } from 'node:path' 3 | import pLimit from 'p-limit' 4 | import { notEmpty } from '@/utils/index' 5 | import { mementoFn } from '@/utils/cache' 6 | 7 | export interface RawChaptersItem { 8 | /** 章节名(ps: 处理过的:index_原始章节名) */ 9 | name: string, 10 | /** 原始章节名 */ 11 | rawName: string, 12 | /** 排序索引 */ 13 | index: number 14 | /** 章节url */ 15 | href: string, 16 | /** 图片url列表 */ 17 | imageList: string[], 18 | /** 图片path列表 */ 19 | imageListPath: string[], 20 | /** 上一话内容 */ 21 | preChapter?: { 22 | name: string, 23 | href: string, 24 | rawName: string 25 | }, 26 | /** 下一话内容 */ 27 | nextChapter?: { 28 | name: string, 29 | href: string, 30 | rawName: string 31 | }, 32 | } 33 | 34 | export interface RawBookInfo { 35 | /** 原始漫画名 */ 36 | name: string, 37 | /** 漫画名(ps: 处理过 不符合path的特殊字符使用"_"替换) */ 38 | pathName: string, 39 | /** 作者名 */ 40 | author: string, 41 | /** 漫画描述 */ 42 | desc: string, 43 | /** 封面url */ 44 | coverUrl: string, 45 | /** 封面path */ 46 | coverPath: string, 47 | /** 章节列表 */ 48 | chapters: RawChaptersItem[], 49 | /** 漫画的url(ps: 处理过 如果www重定向改为cn/tw) */ 50 | url: string, 51 | /** 漫画的原始url */ 52 | rawUrl: string, 53 | /** 语言(简/繁) */ 54 | language: string, 55 | } 56 | 57 | /** 58 | * 扫描某本漫画目录,获取bookInfo.json内容 59 | * @param bookPath 漫画目录路径 60 | * @param bookName 漫画名 61 | * @returns 特定某本漫画的bookInfo.json 62 | */ 63 | async function scanBookFolder(bookPath: string, bookName: string) { 64 | const curBookPath = join(bookPath, bookName) 65 | let bookInfo: RawBookInfo|null = null 66 | try { 67 | const bookInfoStr = await readFile(`${curBookPath}/bookInfo.json`, {encoding: 'utf-8'}) 68 | bookInfo = JSON.parse(bookInfoStr) 69 | if (bookInfo) { 70 | bookInfo.coverPath = join('/public/comic-book/', bookName, bookInfo.coverPath) 71 | bookInfo.chapters.forEach(item => { 72 | item.imageListPath = item.imageListPath.map((imgPath) => { 73 | return join('/public/comic-book/', bookName, imgPath) 74 | }) 75 | }) 76 | } 77 | } catch (e) { 78 | return null 79 | } 80 | return bookInfo 81 | } 82 | 83 | const cachesScanBookFolder = mementoFn(scanBookFolder) 84 | 85 | /** 86 | * 扫描整个漫画目录所有漫画 87 | * @param bookPath 漫画目录路径 88 | * @returns 返回整个漫画目录所有漫画bookInfo.json 89 | */ 90 | async function scanFolder(bookPath: string): Promise { 91 | const dirContentList = await readdir(bookPath) 92 | const limit = pLimit(10) 93 | const promiseList = dirContentList.map((item) => { 94 | // return limit() 95 | return limit(async () => { 96 | const curBookPath = join(bookPath, item) 97 | const itemStat = await stat(curBookPath) 98 | if (!itemStat.isDirectory()) return null 99 | return await cachesScanBookFolder(bookPath, item) 100 | }) 101 | }) 102 | const tempBookInfoList = await Promise.all(promiseList) 103 | const bookInfoList = tempBookInfoList.filter(notEmpty) 104 | return bookInfoList 105 | } 106 | 107 | const cachesSanFolder = mementoFn(scanFolder) 108 | 109 | export { 110 | cachesSanFolder as scanFolder, 111 | cachesScanBookFolder as scanBookFolder 112 | } 113 | -------------------------------------------------------------------------------- /client/src/components/Search/index.tsx: -------------------------------------------------------------------------------- 1 | import { lazy, useState } from 'react' 2 | import { useNavigate } from 'react-router-dom' 3 | import type { ComicBookListRes, BookInfo } from '@/api' 4 | 5 | const AutoComplete = lazy(() => import('antd/lib/auto-complete')) 6 | 7 | interface SearchProps { 8 | bookInfoList?: ComicBookListRes 9 | } 10 | interface OptionsItem { 11 | label: JSX.Element, 12 | value: string 13 | } 14 | export default function Search(props: Readonly) { 15 | const { bookInfoList = [] } = props 16 | const [options, setOptions] = useState([]) 17 | const [searchText, setSearchText] = useState('') 18 | const navigate = useNavigate() 19 | function onSearch(text: string) { 20 | setSearchText(text) 21 | if (!text.trim()) { 22 | setOptions([]) 23 | return 24 | } 25 | const textReg = new RegExp(`${text}`, 'g') 26 | const findList = bookInfoList.filter(bookInfo => textReg.test(bookInfo.name)) 27 | const newOptions: OptionsItem[] = [] 28 | findList.forEach(bookInfo => { 29 | newOptions.push({ 30 | label: renderItem(bookInfo, text), 31 | value: bookInfo.pathName 32 | }) 33 | }) 34 | setOptions(newOptions) 35 | } 36 | 37 | function onSelect(data: any) { 38 | window.scrollTo({ top: 0 }) 39 | navigate(`/detail/${data}`) 40 | } 41 | 42 | return ( 43 |
    44 | ——— Not Found ———
    }> 51 |
    52 | 53 | 63 |
    64 | 65 | 66 | ) 67 | } 68 | 69 | function renderItem(bookInfo: BookInfo, text: string) { 70 | text = text.replace(/[.*+?^${}()|[\]\\]/g, '\\$&') 71 | const textReg = new RegExp(`${text}`, 'g') 72 | const showNameEl = bookInfo.name.replace(textReg, `${text}` ) 73 | const lastChapter = bookInfo.lastChapter 74 | return ( 75 |
    76 |
    77 | {bookInfo.name} 80 |
    81 |
    82 |

    84 |

    85 |

    最新: {lastChapter?.rawName}

    86 |
    87 |
    88 | ) 89 | } -------------------------------------------------------------------------------- /client/src/api/index.ts: -------------------------------------------------------------------------------- 1 | const API = { 2 | comicBookList: '/api/comicBookList', 3 | comicBook: '/api/comicBook', 4 | comicChapter: '/api/comicChapter', 5 | cleanCache: '/api/cleanCache' 6 | } 7 | 8 | interface CommonResponse { 9 | code: number, 10 | data: T 11 | } 12 | 13 | interface RawChaptersItem { 14 | /** 章节名(ps: 处理过的:index_原始章节名) */ 15 | name: string, 16 | /** 原始章节名 */ 17 | rawName: string, 18 | /** 排序索引 */ 19 | index: number 20 | /** 章节url */ 21 | href: string, 22 | /** 图片url列表 */ 23 | imageList: string[], 24 | /** 图片path列表 */ 25 | imageListPath: string[], 26 | /** 上一话内容 */ 27 | preChapter?: { 28 | name: string, 29 | href: string, 30 | rawName: string 31 | }, 32 | /** 下一话内容 */ 33 | nextChapter?: { 34 | name: string, 35 | href: string, 36 | rawName: string 37 | }, 38 | } 39 | 40 | interface RawBookInfo { 41 | /** 原始漫画名 */ 42 | name: string, 43 | /** 漫画名(ps: 处理过 不符合path的特殊字符使用"_"替换) */ 44 | pathName: string, 45 | /** 作者名 */ 46 | author: string, 47 | /** 漫画描述 */ 48 | desc: string, 49 | /** 封面url */ 50 | coverUrl: string, 51 | /** 封面path */ 52 | coverPath: string, 53 | /** 章节列表 */ 54 | chapters: RawChaptersItem[], 55 | /** 漫画的url(ps: 处理过 如果www重定向改为cn/tw) */ 56 | url: string, 57 | /** 漫画的原始url */ 58 | rawUrl: string, 59 | /** 语言(简/繁) */ 60 | language: string, 61 | } 62 | 63 | export interface BookInfo extends Omit { 64 | lastChapter: { 65 | rawName: string | undefined 66 | } 67 | } 68 | export type ComicBookListRes = BookInfo[] 69 | export function comicBookList() { 70 | return fetch(API.comicBookList) 71 | .then(response => { 72 | return response.json() as Promise> 73 | }).then(res => { 74 | if (res.code !== 0) { 75 | return [] as BookInfo[] 76 | } 77 | return res.data 78 | }).catch(e => { 79 | console.error('comicBookList - fetch: ', e) 80 | return [] as BookInfo[] 81 | }) 82 | } 83 | 84 | export type ChapterItem = Omit 85 | export interface ComicBookRes extends Omit { 86 | chapters: ChapterItem[] 87 | } 88 | export function comicBook(bookName: string) { 89 | if (!bookName) return Promise.resolve(null) 90 | const params = new URLSearchParams() 91 | params.append('name', bookName) 92 | return fetch(`${API.comicBook}?${params.toString()}`) 93 | .then(response => { 94 | return response.json() as Promise> 95 | }).then(res => { 96 | if (res.code !== 0) { 97 | return null 98 | } 99 | return res.data 100 | }).catch(e => { 101 | console.error('comicBook - fetch: ', e) 102 | return null 103 | }) 104 | } 105 | 106 | 107 | export type ComicChapterRes = Omit 108 | export function comicChapter(bookName: string, chapterName: string) { 109 | if (!bookName || !chapterName) return Promise.resolve(null) 110 | const params = new URLSearchParams() 111 | params.append('name', bookName) 112 | params.append('chapter', chapterName) 113 | return fetch(`${API.comicChapter}?${params.toString()}`) 114 | .then(response => { 115 | return response.json() as Promise> 116 | }).then(res => { 117 | if (res.code !== 0) { 118 | return null 119 | } 120 | return res.data 121 | }).catch(e => { 122 | console.error('comicChapter - fetch: ', e) 123 | return null 124 | }) 125 | } 126 | 127 | 128 | export function cleanCache() { 129 | return fetch(API.cleanCache) 130 | .then(response => { 131 | return response.json() as Promise 132 | }) 133 | .then(res => { 134 | return res.code !== 0 135 | }) 136 | } -------------------------------------------------------------------------------- /client/src/pages/Detail/ChapterList/index.tsx: -------------------------------------------------------------------------------- 1 | import { useEffect, useMemo, useState } from 'react' 2 | import { Link } from 'react-router-dom' 3 | import { useLocalStorageState } from 'ahooks' 4 | import BackTop from '@/components/BackTop' 5 | import { toReversed } from '@/utils' 6 | import { LOCAL_STORAGE_HISTORY } from '@/constant' 7 | import type { ILocalHistoryItem } from '@/constant' 8 | import type { ChapterItem, ComicBookRes } from '@/api' 9 | 10 | interface FCProps { 11 | bookName: string, 12 | bookInfo: ComicBookRes 13 | } 14 | 15 | const ChaptersList: React.FC = ({ bookName, bookInfo }) => { 16 | const [reverse, setReverse] = useState(true) 17 | const [historyChapterItem, setHistoryChapterItem] = useState() 18 | let chapters = useMemo(()=> bookInfo?.chapters ?? [], [bookInfo]) 19 | const lastChapters = chapters.at(-1) 20 | if (reverse) { 21 | chapters = toReversed(chapters) 22 | } 23 | const [localHistory] = useLocalStorageState(LOCAL_STORAGE_HISTORY, { 24 | defaultValue: [] 25 | }) 26 | 27 | useEffect(() => { 28 | const localItem = localHistory?.find((item) => item.bookName === bookName) 29 | if (localItem) { 30 | const chapterItem = chapters.find((item) => { 31 | return localItem?.chapterName === item.name 32 | }) 33 | chapterItem && setHistoryChapterItem(chapterItem) 34 | } 35 | }, [localHistory, bookName, chapters]) 36 | 37 | 38 | return ( 39 | <> 40 | { historyChapterItem && 41 | <> 42 |

    上次阅读

    43 |

    44 | {/* 继续阅读:   */} 45 | 46 | 53 | {historyChapterItem.rawName} 54 | 55 | 56 |

    57 | 58 | } 59 |

    章节列表

    60 |
    61 |
    62 |

    63 | 最新:   64 | 67 | {lastChapters?.rawName} 68 | 69 |

    70 |
    71 | 75 |
    76 |
      77 | { 78 | chapters.map((chapter) => { 79 | return ( 80 |
    • 81 | 88 | {chapter.rawName} 89 | 90 |
    • 91 | ) 92 | }) 93 | } 94 |
    95 | 96 | 97 | ) 98 | } 99 | 100 | export default ChaptersList -------------------------------------------------------------------------------- /client/src/pages/Home/BookList/index.tsx: -------------------------------------------------------------------------------- 1 | import { useEffect, useState } from 'react' 2 | import { Link, useNavigate } from 'react-router-dom' 3 | import { message } from 'antd' 4 | import { clearCache, useLocalStorageState } from 'ahooks' 5 | import * as api from '@/api/index' 6 | import type { BookInfo } from '@/api/index' 7 | import { LOCAL_STORAGE_HISTORY, CACHE_KEY } from '@/constant' 8 | import type { ILocalHistoryItem } from '@/constant' 9 | 10 | interface BookListProps { 11 | bookInfoList: BookInfo[] 12 | } 13 | interface HistoryItemProps { 14 | bookInfoName: string, 15 | localHistory: ILocalHistoryItem[] | undefined 16 | } 17 | function HistoryItem(props: Readonly) { 18 | const {bookInfoName, localHistory = []} = props 19 | const exist = localHistory.find(item => item.bookName === bookInfoName) 20 | const [isClient, setIsClient] = useState(false) 21 | 22 | useEffect(() => { 23 | setIsClient(true) 24 | }, []) 25 | 26 | return ( 27 | isClient && exist ? ( 28 |

    29 | 30 |   31 | {exist.rawChapterName} 32 |

    33 | ) : <> 34 | ) 35 | } 36 | 37 | export default function BookList({bookInfoList}: Readonly) { 38 | const [localHistory] = useLocalStorageState(LOCAL_STORAGE_HISTORY, { 39 | defaultValue: [] 40 | }) 41 | const navigate = useNavigate() 42 | const [messageApi, contextHolder] = message.useMessage() 43 | let msgExist = false 44 | async function fetchCleanCache(){ 45 | if (msgExist) return 46 | await api.cleanCache() 47 | clearCache(CACHE_KEY.comicBookList()) 48 | messageLog('已清理缓存') 49 | navigate(0) 50 | } 51 | 52 | function messageLog(msg: string) { 53 | if (msgExist) return 54 | msgExist = true 55 | messageApi.open({ 56 | content: msg, 57 | className: 'mt-[30vh] text-white', 58 | onClose:() => { 59 | msgExist = false 60 | } 61 | }) 62 | } 63 | 64 | return ( 65 | <> 66 | {contextHolder} 67 | { 68 | bookInfoList.map((bookInfo) => { 69 | return ( 70 |
    71 | {/* className="block hover:bg-p-4/20 dark:hover:text-p-3" */} 72 | 73 |
    74 |
    78 | {bookInfo.name} 81 |

    82 | {bookInfo.lastChapter.rawName} 83 |

    84 |
    85 |
    86 |
    87 |

    88 | {bookInfo.name} 89 |

    90 |

    {bookInfo.author}

    91 |

    {bookInfo.desc}

    92 |
    93 | 96 |
    97 |
    98 | 99 |
    100 | ) 101 | }) 102 | } 103 | 110 | 111 | ) 112 | } -------------------------------------------------------------------------------- /client/src/pages/Chapter/ChapterFooter/index.tsx: -------------------------------------------------------------------------------- 1 | import { lazy, useCallback, useContext, useState } from 'react' 2 | import { Link, useNavigate, useParams } from 'react-router-dom' 3 | import { message } from 'antd' 4 | import { Virtuoso } from 'react-virtuoso' 5 | import { BookInfoContext, ChapterInfoContext } from '@/pages/Chapter/Provider' 6 | import useScrollToTop from '@/hooks/useScrollToTop' 7 | 8 | interface Props { 9 | show: boolean, 10 | chapterName: string 11 | } 12 | 13 | const Drawer = lazy(() => import('antd/lib/drawer')) 14 | 15 | export default function ChapterFooter(props: Readonly) { 16 | const {show} = props 17 | const bookInfo = useContext(BookInfoContext) 18 | const chapterInfo = useContext(ChapterInfoContext) 19 | const { nextChapter, preChapter } = chapterInfo ?? {} 20 | const { chapterName = '' } = useParams() 21 | const navigate = useNavigate() 22 | const [messageApi, contextHolder] = message.useMessage() 23 | 24 | const [showCatalog, setShowCatalog] = useState(false) 25 | const openCatalog = () => setShowCatalog(true) 26 | const closeCatalog = () => setShowCatalog(false) 27 | 28 | let msgExist = false 29 | function messageLog(msg: string) { 30 | if (!msgExist) { 31 | msgExist = true 32 | messageApi.open({ 33 | content: msg, 34 | className: 'mt-[30vh] text-white', 35 | onClose:() => { 36 | msgExist = false 37 | } 38 | }) 39 | } 40 | } 41 | 42 | useScrollToTop(useCallback(() => { 43 | closeCatalog() 44 | }, [])) 45 | 46 | 47 | const goHome = () => { 48 | navigate('/') 49 | } 50 | 51 | const onPreChapter = () => { 52 | if (preChapter) { 53 | navigate(`/detail/${bookInfo.pathName}/${preChapter.name}`) 54 | return 55 | } 56 | messageLog('没有上一话了 (╥﹏╥)') 57 | } 58 | const onNextChapter = () => { 59 | if (nextChapter) { 60 | navigate(`/detail/${bookInfo.pathName}/${nextChapter.name}`) 61 | return 62 | } 63 | messageLog('已是最新一话了 (╥﹏╥)') 64 | } 65 | 66 | return ( 67 | <> 68 | {contextHolder} 69 |
    75 |
    76 | 80 | 84 | 88 | 92 |
    93 | 目录

    } 95 | placement="right" 96 | onClose={closeCatalog} 97 | open={showCatalog} 98 | closeIcon={} 99 | classNames={{ 100 | header: 'border-b border-slate-900/10 dark:border-slate-300/10', 101 | body: 'p-0', 102 | content: 'backdrop-blur supports-backdrop-blur:bg-white/80 bg-p-1/95 bg-white dark:bg-p-1/80 dark:text-white', 103 | }} 104 | width={ typeof window !== 'undefined' && document.body.clientWidth < 768 ? '70vw': '30vw'}> 105 | ( 109 | 116 | {item.rawName} 117 | 118 | )}/> 119 |
    120 |
    121 | 122 | ) 123 | } -------------------------------------------------------------------------------- /client/tsconfig.node.tsbuildinfo: -------------------------------------------------------------------------------- 1 | {"program":{"fileNames":["../../../../../../../usr/local/lib/node_modules/typescript/lib/lib.d.ts","../../../../../../../usr/local/lib/node_modules/typescript/lib/lib.es5.d.ts","../../../../../../../usr/local/lib/node_modules/typescript/lib/lib.dom.d.ts","../../../../../../../usr/local/lib/node_modules/typescript/lib/lib.webworker.importscripts.d.ts","../../../../../../../usr/local/lib/node_modules/typescript/lib/lib.scripthost.d.ts","./vite.config.ts","../node_modules/@types/json-schema/index.d.ts","../node_modules/@types/prop-types/index.d.ts","../node_modules/@types/react/ts5.0/global.d.ts","../node_modules/@types/scheduler/tracing.d.ts","../node_modules/@types/react/ts5.0/index.d.ts","../node_modules/@types/react-dom/index.d.ts","../node_modules/@types/scheduler/index.d.ts","../node_modules/@types/semver/classes/semver.d.ts","../node_modules/@types/semver/functions/parse.d.ts","../node_modules/@types/semver/functions/valid.d.ts","../node_modules/@types/semver/functions/clean.d.ts","../node_modules/@types/semver/functions/inc.d.ts","../node_modules/@types/semver/functions/diff.d.ts","../node_modules/@types/semver/functions/major.d.ts","../node_modules/@types/semver/functions/minor.d.ts","../node_modules/@types/semver/functions/patch.d.ts","../node_modules/@types/semver/functions/prerelease.d.ts","../node_modules/@types/semver/functions/compare.d.ts","../node_modules/@types/semver/functions/rcompare.d.ts","../node_modules/@types/semver/functions/compare-loose.d.ts","../node_modules/@types/semver/functions/compare-build.d.ts","../node_modules/@types/semver/functions/sort.d.ts","../node_modules/@types/semver/functions/rsort.d.ts","../node_modules/@types/semver/functions/gt.d.ts","../node_modules/@types/semver/functions/lt.d.ts","../node_modules/@types/semver/functions/eq.d.ts","../node_modules/@types/semver/functions/neq.d.ts","../node_modules/@types/semver/functions/gte.d.ts","../node_modules/@types/semver/functions/lte.d.ts","../node_modules/@types/semver/functions/cmp.d.ts","../node_modules/@types/semver/functions/coerce.d.ts","../node_modules/@types/semver/classes/comparator.d.ts","../node_modules/@types/semver/classes/range.d.ts","../node_modules/@types/semver/functions/satisfies.d.ts","../node_modules/@types/semver/ranges/max-satisfying.d.ts","../node_modules/@types/semver/ranges/min-satisfying.d.ts","../node_modules/@types/semver/ranges/to-comparators.d.ts","../node_modules/@types/semver/ranges/min-version.d.ts","../node_modules/@types/semver/ranges/valid.d.ts","../node_modules/@types/semver/ranges/outside.d.ts","../node_modules/@types/semver/ranges/gtr.d.ts","../node_modules/@types/semver/ranges/ltr.d.ts","../node_modules/@types/semver/ranges/intersects.d.ts","../node_modules/@types/semver/ranges/simplify.d.ts","../node_modules/@types/semver/ranges/subset.d.ts","../node_modules/@types/semver/internals/identifiers.d.ts","../node_modules/@types/semver/index.d.ts"],"fileInfos":["2dc8c927c9c162a773c6bb3cdc4f3286c23f10eedc67414028f9cb5951610f60",{"version":"f5c28122bee592cfaf5c72ed7bcc47f453b79778ffa6e301f45d21a0970719d4","affectsGlobalScope":true},{"version":"3f149f903dd20dfeb7c80e228b659f0e436532de772469980dbd00702cc05cc1","affectsGlobalScope":true},{"version":"7fac8cb5fc820bc2a59ae11ef1c5b38d3832c6d0dfaec5acdb5569137d09a481","affectsGlobalScope":true},{"version":"097a57355ded99c68e6df1b738990448e0bf170e606707df5a7c0481ff2427cd","affectsGlobalScope":true},{"version":"7a82de43ce44daf753154d196e7e27db10999867a5e8b00b607589896d76b5b0","signature":"46a0b34e1264c4d25ca6646ff0e6cfaa7275ea1ae5a6bc23d4dfd84edf2f2b2e"},"f3d8c757e148ad968f0d98697987db363070abada5f503da3c06aefd9d4248c1","9ed09d4538e25fc79cefc5e7b5bfbae0464f06d2984f19da009f85d13656c211",{"version":"0bd5e7096c7bc02bf70b2cc017fc45ef489cb19bd2f32a71af39ff5787f1b56a","affectsGlobalScope":true},"b1bf87add0ccfb88472cd4c6013853d823a7efb791c10bb7a11679526be91eda",{"version":"895ec7d6d6b37faaf5adb055d92dd7e533e329d358ebbcd6db0f81fc8c8c2db9","affectsGlobalScope":true},"7ac7ef12f7ece6464d83d2d56fea727260fb954fdd51a967e94f97b8595b714b","4ef960df4f672e93b479f88211ed8b5cfa8a598b97aafa3396cacdc3341e3504","5b5337f28573ffdbc95c3653c4a7961d0f02fdf4788888253bf74a3b5a05443e","9871b7ee672bc16c78833bdab3052615834b08375cb144e4d2cba74473f4a589","c863198dae89420f3c552b5a03da6ed6d0acfa3807a64772b895db624b0de707","8b03a5e327d7db67112ebbc93b4f744133eda2c1743dbb0a990c61a8007823ef","86c73f2ee1752bac8eeeece234fd05dfcf0637a4fbd8032e4f5f43102faa8eec","42fad1f540271e35ca37cecda12c4ce2eef27f0f5cf0f8dd761d723c744d3159","ff3743a5de32bee10906aff63d1de726f6a7fd6ee2da4b8229054dfa69de2c34","83acd370f7f84f203e71ebba33ba61b7f1291ca027d7f9a662c6307d74e4ac22","1445cec898f90bdd18b2949b9590b3c012f5b7e1804e6e329fb0fe053946d5ec","0e5318ec2275d8da858b541920d9306650ae6ac8012f0e872fe66eb50321a669","cf530297c3fb3a92ec9591dd4fa229d58b5981e45fe6702a0bd2bea53a5e59be","c1f6f7d08d42148ddfe164d36d7aba91f467dbcb3caa715966ff95f55048b3a4","f4e9bf9103191ef3b3612d3ec0044ca4044ca5be27711fe648ada06fad4bcc85","0c1ee27b8f6a00097c2d6d91a21ee4d096ab52c1e28350f6362542b55380059a","7677d5b0db9e020d3017720f853ba18f415219fb3a9597343b1b1012cfd699f7","bc1c6bc119c1784b1a2be6d9c47addec0d83ef0d52c8fbe1f14a51b4dfffc675","52cf2ce99c2a23de70225e252e9822a22b4e0adb82643ab0b710858810e00bf1","770625067bb27a20b9826255a8d47b6b5b0a2d3dfcbd21f89904c731f671ba77","d1ed6765f4d7906a05968fb5cd6d1db8afa14dbe512a4884e8ea5c0f5e142c80","799c0f1b07c092626cf1efd71d459997635911bb5f7fc1196efe449bba87e965","2a184e4462b9914a30b1b5c41cf80c6d3428f17b20d3afb711fff3f0644001fd","9eabde32a3aa5d80de34af2c2206cdc3ee094c6504a8d0c2d6d20c7c179503cc","397c8051b6cfcb48aa22656f0faca2553c5f56187262135162ee79d2b2f6c966","a8ead142e0c87dcd5dc130eba1f8eeed506b08952d905c47621dc2f583b1bff9","a02f10ea5f73130efca046429254a4e3c06b5475baecc8f7b99a0014731be8b3","c2576a4083232b0e2d9bd06875dd43d371dee2e090325a9eac0133fd5650c1cb","4c9a0564bb317349de6a24eb4efea8bb79898fa72ad63a1809165f5bd42970dd","f40ac11d8859092d20f953aae14ba967282c3bb056431a37fced1866ec7a2681","cc11e9e79d4746cc59e0e17473a59d6f104692fd0eeea1bdb2e206eabed83b03","b444a410d34fb5e98aa5ee2b381362044f4884652e8bc8a11c8fe14bbd85518e","c35808c1f5e16d2c571aa65067e3cb95afeff843b259ecfa2fc107a9519b5392","14d5dc055143e941c8743c6a21fa459f961cbc3deedf1bfe47b11587ca4b3ef5","a3ad4e1fc542751005267d50a6298e6765928c0c3a8dce1572f2ba6ca518661c","f237e7c97a3a89f4591afd49ecb3bd8d14f51a1c4adc8fcae3430febedff5eb6","3ffdfbec93b7aed71082af62b8c3e0cc71261cc68d796665faa1e91604fbae8f","662201f943ed45b1ad600d03a90dffe20841e725203ced8b708c91fcd7f9379a","c9ef74c64ed051ea5b958621e7fb853fe3b56e8787c1587aefc6ea988b3c7e79","2462ccfac5f3375794b861abaa81da380f1bbd9401de59ffa43119a0b644253d","34baf65cfee92f110d6653322e2120c2d368ee64b3c7981dff08ed105c4f19b0","85f8ebd7f245e8bf29da270e8b53dcdd17528826ffd27176c5fc7e426213ef5a"],"options":{"allowSyntheticDefaultImports":true,"composite":true,"module":99,"skipLibCheck":true},"fileIdsList":[[11],[8,9,10],[14,53],[14,38,53],[53],[14],[14,39,53],[14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52],[39,53]],"referencedMap":[[12,1],[11,2],[38,3],[39,4],[14,5],[17,5],[36,3],[37,3],[27,3],[26,6],[24,3],[19,3],[32,3],[30,3],[34,3],[18,3],[31,3],[35,3],[20,3],[21,3],[33,3],[15,3],[22,3],[23,3],[25,3],[29,3],[40,7],[28,3],[16,3],[53,8],[47,7],[49,9],[48,7],[41,7],[42,7],[44,7],[46,7],[50,9],[51,9],[43,9],[45,9]],"exportedModulesMap":[[12,1],[11,2],[38,3],[39,4],[14,5],[17,5],[36,3],[37,3],[27,3],[26,6],[24,3],[19,3],[32,3],[30,3],[34,3],[18,3],[31,3],[35,3],[20,3],[21,3],[33,3],[15,3],[22,3],[23,3],[25,3],[29,3],[40,7],[28,3],[16,3],[53,8],[47,7],[49,9],[48,7],[41,7],[42,7],[44,7],[46,7],[50,9],[51,9],[43,9],[45,9]],"semanticDiagnosticsPerFile":[[6,[{"file":"./vite.config.ts","start":29,"length":6,"messageText":"Cannot find module 'vite'. Did you mean to set the 'moduleResolution' option to 'node', or to add aliases to the 'paths' option?","category":1,"code":2792},{"file":"./vite.config.ts","start":54,"length":26,"messageText":"Cannot find module '@vitejs/plugin-react-swc'. Did you mean to set the 'moduleResolution' option to 'node', or to add aliases to the 'paths' option?","category":1,"code":2792}]],7,8,12,9,11,13,10,38,39,14,17,36,37,27,26,24,19,32,30,34,18,31,35,20,21,33,15,22,23,25,29,40,28,16,53,52,47,49,48,41,42,44,46,50,51,43,45,1,3,2,5,4]},"version":"4.7.4"} -------------------------------------------------------------------------------- /LICENSE.txt: -------------------------------------------------------------------------------- 1 | GNU AFFERO GENERAL PUBLIC LICENSE 2 | Version 3, 19 November 2007 3 | 4 | Copyright (C) 2007 Free Software Foundation, Inc. 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | Preamble 9 | 10 | The GNU Affero General Public License is a free, copyleft license for 11 | software and other kinds of works, specifically designed to ensure 12 | cooperation with the community in the case of network server software. 13 | 14 | The licenses for most software and other practical works are designed 15 | to take away your freedom to share and change the works. By contrast, 16 | our General Public Licenses are intended to guarantee your freedom to 17 | share and change all versions of a program--to make sure it remains free 18 | software for all its users. 19 | 20 | When we speak of free software, we are referring to freedom, not 21 | price. Our General Public Licenses are designed to make sure that you 22 | have the freedom to distribute copies of free software (and charge for 23 | them if you wish), that you receive source code or can get it if you 24 | want it, that you can change the software or use pieces of it in new 25 | free programs, and that you know you can do these things. 26 | 27 | Developers that use our General Public Licenses protect your rights 28 | with two steps: (1) assert copyright on the software, and (2) offer 29 | you this License which gives you legal permission to copy, distribute 30 | and/or modify the software. 31 | 32 | A secondary benefit of defending all users' freedom is that 33 | improvements made in alternate versions of the program, if they 34 | receive widespread use, become available for other developers to 35 | incorporate. Many developers of free software are heartened and 36 | encouraged by the resulting cooperation. However, in the case of 37 | software used on network servers, this result may fail to come about. 38 | The GNU General Public License permits making a modified version and 39 | letting the public access it on a server without ever releasing its 40 | source code to the public. 41 | 42 | The GNU Affero General Public License is designed specifically to 43 | ensure that, in such cases, the modified source code becomes available 44 | to the community. It requires the operator of a network server to 45 | provide the source code of the modified version running there to the 46 | users of that server. Therefore, public use of a modified version, on 47 | a publicly accessible server, gives the public access to the source 48 | code of the modified version. 49 | 50 | An older license, called the Affero General Public License and 51 | published by Affero, was designed to accomplish similar goals. This is 52 | a different license, not a version of the Affero GPL, but Affero has 53 | released a new version of the Affero GPL which permits relicensing under 54 | this license. 55 | 56 | The precise terms and conditions for copying, distribution and 57 | modification follow. 58 | 59 | TERMS AND CONDITIONS 60 | 61 | 0. Definitions. 62 | 63 | "This License" refers to version 3 of the GNU Affero General Public License. 64 | 65 | "Copyright" also means copyright-like laws that apply to other kinds of 66 | works, such as semiconductor masks. 67 | 68 | "The Program" refers to any copyrightable work licensed under this 69 | License. Each licensee is addressed as "you". "Licensees" and 70 | "recipients" may be individuals or organizations. 71 | 72 | To "modify" a work means to copy from or adapt all or part of the work 73 | in a fashion requiring copyright permission, other than the making of an 74 | exact copy. The resulting work is called a "modified version" of the 75 | earlier work or a work "based on" the earlier work. 76 | 77 | A "covered work" means either the unmodified Program or a work based 78 | on the Program. 79 | 80 | To "propagate" a work means to do anything with it that, without 81 | permission, would make you directly or secondarily liable for 82 | infringement under applicable copyright law, except executing it on a 83 | computer or modifying a private copy. Propagation includes copying, 84 | distribution (with or without modification), making available to the 85 | public, and in some countries other activities as well. 86 | 87 | To "convey" a work means any kind of propagation that enables other 88 | parties to make or receive copies. Mere interaction with a user through 89 | a computer network, with no transfer of a copy, is not conveying. 90 | 91 | An interactive user interface displays "Appropriate Legal Notices" 92 | to the extent that it includes a convenient and prominently visible 93 | feature that (1) displays an appropriate copyright notice, and (2) 94 | tells the user that there is no warranty for the work (except to the 95 | extent that warranties are provided), that licensees may convey the 96 | work under this License, and how to view a copy of this License. If 97 | the interface presents a list of user commands or options, such as a 98 | menu, a prominent item in the list meets this criterion. 99 | 100 | 1. Source Code. 101 | 102 | The "source code" for a work means the preferred form of the work 103 | for making modifications to it. "Object code" means any non-source 104 | form of a work. 105 | 106 | A "Standard Interface" means an interface that either is an official 107 | standard defined by a recognized standards body, or, in the case of 108 | interfaces specified for a particular programming language, one that 109 | is widely used among developers working in that language. 110 | 111 | The "System Libraries" of an executable work include anything, other 112 | than the work as a whole, that (a) is included in the normal form of 113 | packaging a Major Component, but which is not part of that Major 114 | Component, and (b) serves only to enable use of the work with that 115 | Major Component, or to implement a Standard Interface for which an 116 | implementation is available to the public in source code form. A 117 | "Major Component", in this context, means a major essential component 118 | (kernel, window system, and so on) of the specific operating system 119 | (if any) on which the executable work runs, or a compiler used to 120 | produce the work, or an object code interpreter used to run it. 121 | 122 | The "Corresponding Source" for a work in object code form means all 123 | the source code needed to generate, install, and (for an executable 124 | work) run the object code and to modify the work, including scripts to 125 | control those activities. However, it does not include the work's 126 | System Libraries, or general-purpose tools or generally available free 127 | programs which are used unmodified in performing those activities but 128 | which are not part of the work. For example, Corresponding Source 129 | includes interface definition files associated with source files for 130 | the work, and the source code for shared libraries and dynamically 131 | linked subprograms that the work is specifically designed to require, 132 | such as by intimate data communication or control flow between those 133 | subprograms and other parts of the work. 134 | 135 | The Corresponding Source need not include anything that users 136 | can regenerate automatically from other parts of the Corresponding 137 | Source. 138 | 139 | The Corresponding Source for a work in source code form is that 140 | same work. 141 | 142 | 2. Basic Permissions. 143 | 144 | All rights granted under this License are granted for the term of 145 | copyright on the Program, and are irrevocable provided the stated 146 | conditions are met. This License explicitly affirms your unlimited 147 | permission to run the unmodified Program. The output from running a 148 | covered work is covered by this License only if the output, given its 149 | content, constitutes a covered work. This License acknowledges your 150 | rights of fair use or other equivalent, as provided by copyright law. 151 | 152 | You may make, run and propagate covered works that you do not 153 | convey, without conditions so long as your license otherwise remains 154 | in force. You may convey covered works to others for the sole purpose 155 | of having them make modifications exclusively for you, or provide you 156 | with facilities for running those works, provided that you comply with 157 | the terms of this License in conveying all material for which you do 158 | not control copyright. Those thus making or running the covered works 159 | for you must do so exclusively on your behalf, under your direction 160 | and control, on terms that prohibit them from making any copies of 161 | your copyrighted material outside their relationship with you. 162 | 163 | Conveying under any other circumstances is permitted solely under 164 | the conditions stated below. Sublicensing is not allowed; section 10 165 | makes it unnecessary. 166 | 167 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 168 | 169 | No covered work shall be deemed part of an effective technological 170 | measure under any applicable law fulfilling obligations under article 171 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or 172 | similar laws prohibiting or restricting circumvention of such 173 | measures. 174 | 175 | When you convey a covered work, you waive any legal power to forbid 176 | circumvention of technological measures to the extent such circumvention 177 | is effected by exercising rights under this License with respect to 178 | the covered work, and you disclaim any intention to limit operation or 179 | modification of the work as a means of enforcing, against the work's 180 | users, your or third parties' legal rights to forbid circumvention of 181 | technological measures. 182 | 183 | 4. Conveying Verbatim Copies. 184 | 185 | You may convey verbatim copies of the Program's source code as you 186 | receive it, in any medium, provided that you conspicuously and 187 | appropriately publish on each copy an appropriate copyright notice; 188 | keep intact all notices stating that this License and any 189 | non-permissive terms added in accord with section 7 apply to the code; 190 | keep intact all notices of the absence of any warranty; and give all 191 | recipients a copy of this License along with the Program. 192 | 193 | You may charge any price or no price for each copy that you convey, 194 | and you may offer support or warranty protection for a fee. 195 | 196 | 5. Conveying Modified Source Versions. 197 | 198 | You may convey a work based on the Program, or the modifications to 199 | produce it from the Program, in the form of source code under the 200 | terms of section 4, provided that you also meet all of these conditions: 201 | 202 | a) The work must carry prominent notices stating that you modified 203 | it, and giving a relevant date. 204 | 205 | b) The work must carry prominent notices stating that it is 206 | released under this License and any conditions added under section 207 | 7. This requirement modifies the requirement in section 4 to 208 | "keep intact all notices". 209 | 210 | c) You must license the entire work, as a whole, under this 211 | License to anyone who comes into possession of a copy. This 212 | License will therefore apply, along with any applicable section 7 213 | additional terms, to the whole of the work, and all its parts, 214 | regardless of how they are packaged. This License gives no 215 | permission to license the work in any other way, but it does not 216 | invalidate such permission if you have separately received it. 217 | 218 | d) If the work has interactive user interfaces, each must display 219 | Appropriate Legal Notices; however, if the Program has interactive 220 | interfaces that do not display Appropriate Legal Notices, your 221 | work need not make them do so. 222 | 223 | A compilation of a covered work with other separate and independent 224 | works, which are not by their nature extensions of the covered work, 225 | and which are not combined with it such as to form a larger program, 226 | in or on a volume of a storage or distribution medium, is called an 227 | "aggregate" if the compilation and its resulting copyright are not 228 | used to limit the access or legal rights of the compilation's users 229 | beyond what the individual works permit. Inclusion of a covered work 230 | in an aggregate does not cause this License to apply to the other 231 | parts of the aggregate. 232 | 233 | 6. Conveying Non-Source Forms. 234 | 235 | You may convey a covered work in object code form under the terms 236 | of sections 4 and 5, provided that you also convey the 237 | machine-readable Corresponding Source under the terms of this License, 238 | in one of these ways: 239 | 240 | a) Convey the object code in, or embodied in, a physical product 241 | (including a physical distribution medium), accompanied by the 242 | Corresponding Source fixed on a durable physical medium 243 | customarily used for software interchange. 244 | 245 | b) Convey the object code in, or embodied in, a physical product 246 | (including a physical distribution medium), accompanied by a 247 | written offer, valid for at least three years and valid for as 248 | long as you offer spare parts or customer support for that product 249 | model, to give anyone who possesses the object code either (1) a 250 | copy of the Corresponding Source for all the software in the 251 | product that is covered by this License, on a durable physical 252 | medium customarily used for software interchange, for a price no 253 | more than your reasonable cost of physically performing this 254 | conveying of source, or (2) access to copy the 255 | Corresponding Source from a network server at no charge. 256 | 257 | c) Convey individual copies of the object code with a copy of the 258 | written offer to provide the Corresponding Source. This 259 | alternative is allowed only occasionally and noncommercially, and 260 | only if you received the object code with such an offer, in accord 261 | with subsection 6b. 262 | 263 | d) Convey the object code by offering access from a designated 264 | place (gratis or for a charge), and offer equivalent access to the 265 | Corresponding Source in the same way through the same place at no 266 | further charge. You need not require recipients to copy the 267 | Corresponding Source along with the object code. If the place to 268 | copy the object code is a network server, the Corresponding Source 269 | may be on a different server (operated by you or a third party) 270 | that supports equivalent copying facilities, provided you maintain 271 | clear directions next to the object code saying where to find the 272 | Corresponding Source. Regardless of what server hosts the 273 | Corresponding Source, you remain obligated to ensure that it is 274 | available for as long as needed to satisfy these requirements. 275 | 276 | e) Convey the object code using peer-to-peer transmission, provided 277 | you inform other peers where the object code and Corresponding 278 | Source of the work are being offered to the general public at no 279 | charge under subsection 6d. 280 | 281 | A separable portion of the object code, whose source code is excluded 282 | from the Corresponding Source as a System Library, need not be 283 | included in conveying the object code work. 284 | 285 | A "User Product" is either (1) a "consumer product", which means any 286 | tangible personal property which is normally used for personal, family, 287 | or household purposes, or (2) anything designed or sold for incorporation 288 | into a dwelling. In determining whether a product is a consumer product, 289 | doubtful cases shall be resolved in favor of coverage. For a particular 290 | product received by a particular user, "normally used" refers to a 291 | typical or common use of that class of product, regardless of the status 292 | of the particular user or of the way in which the particular user 293 | actually uses, or expects or is expected to use, the product. A product 294 | is a consumer product regardless of whether the product has substantial 295 | commercial, industrial or non-consumer uses, unless such uses represent 296 | the only significant mode of use of the product. 297 | 298 | "Installation Information" for a User Product means any methods, 299 | procedures, authorization keys, or other information required to install 300 | and execute modified versions of a covered work in that User Product from 301 | a modified version of its Corresponding Source. The information must 302 | suffice to ensure that the continued functioning of the modified object 303 | code is in no case prevented or interfered with solely because 304 | modification has been made. 305 | 306 | If you convey an object code work under this section in, or with, or 307 | specifically for use in, a User Product, and the conveying occurs as 308 | part of a transaction in which the right of possession and use of the 309 | User Product is transferred to the recipient in perpetuity or for a 310 | fixed term (regardless of how the transaction is characterized), the 311 | Corresponding Source conveyed under this section must be accompanied 312 | by the Installation Information. But this requirement does not apply 313 | if neither you nor any third party retains the ability to install 314 | modified object code on the User Product (for example, the work has 315 | been installed in ROM). 316 | 317 | The requirement to provide Installation Information does not include a 318 | requirement to continue to provide support service, warranty, or updates 319 | for a work that has been modified or installed by the recipient, or for 320 | the User Product in which it has been modified or installed. Access to a 321 | network may be denied when the modification itself materially and 322 | adversely affects the operation of the network or violates the rules and 323 | protocols for communication across the network. 324 | 325 | Corresponding Source conveyed, and Installation Information provided, 326 | in accord with this section must be in a format that is publicly 327 | documented (and with an implementation available to the public in 328 | source code form), and must require no special password or key for 329 | unpacking, reading or copying. 330 | 331 | 7. Additional Terms. 332 | 333 | "Additional permissions" are terms that supplement the terms of this 334 | License by making exceptions from one or more of its conditions. 335 | Additional permissions that are applicable to the entire Program shall 336 | be treated as though they were included in this License, to the extent 337 | that they are valid under applicable law. If additional permissions 338 | apply only to part of the Program, that part may be used separately 339 | under those permissions, but the entire Program remains governed by 340 | this License without regard to the additional permissions. 341 | 342 | When you convey a copy of a covered work, you may at your option 343 | remove any additional permissions from that copy, or from any part of 344 | it. (Additional permissions may be written to require their own 345 | removal in certain cases when you modify the work.) You may place 346 | additional permissions on material, added by you to a covered work, 347 | for which you have or can give appropriate copyright permission. 348 | 349 | Notwithstanding any other provision of this License, for material you 350 | add to a covered work, you may (if authorized by the copyright holders of 351 | that material) supplement the terms of this License with terms: 352 | 353 | a) Disclaiming warranty or limiting liability differently from the 354 | terms of sections 15 and 16 of this License; or 355 | 356 | b) Requiring preservation of specified reasonable legal notices or 357 | author attributions in that material or in the Appropriate Legal 358 | Notices displayed by works containing it; or 359 | 360 | c) Prohibiting misrepresentation of the origin of that material, or 361 | requiring that modified versions of such material be marked in 362 | reasonable ways as different from the original version; or 363 | 364 | d) Limiting the use for publicity purposes of names of licensors or 365 | authors of the material; or 366 | 367 | e) Declining to grant rights under trademark law for use of some 368 | trade names, trademarks, or service marks; or 369 | 370 | f) Requiring indemnification of licensors and authors of that 371 | material by anyone who conveys the material (or modified versions of 372 | it) with contractual assumptions of liability to the recipient, for 373 | any liability that these contractual assumptions directly impose on 374 | those licensors and authors. 375 | 376 | All other non-permissive additional terms are considered "further 377 | restrictions" within the meaning of section 10. If the Program as you 378 | received it, or any part of it, contains a notice stating that it is 379 | governed by this License along with a term that is a further 380 | restriction, you may remove that term. If a license document contains 381 | a further restriction but permits relicensing or conveying under this 382 | License, you may add to a covered work material governed by the terms 383 | of that license document, provided that the further restriction does 384 | not survive such relicensing or conveying. 385 | 386 | If you add terms to a covered work in accord with this section, you 387 | must place, in the relevant source files, a statement of the 388 | additional terms that apply to those files, or a notice indicating 389 | where to find the applicable terms. 390 | 391 | Additional terms, permissive or non-permissive, may be stated in the 392 | form of a separately written license, or stated as exceptions; 393 | the above requirements apply either way. 394 | 395 | 8. Termination. 396 | 397 | You may not propagate or modify a covered work except as expressly 398 | provided under this License. Any attempt otherwise to propagate or 399 | modify it is void, and will automatically terminate your rights under 400 | this License (including any patent licenses granted under the third 401 | paragraph of section 11). 402 | 403 | However, if you cease all violation of this License, then your 404 | license from a particular copyright holder is reinstated (a) 405 | provisionally, unless and until the copyright holder explicitly and 406 | finally terminates your license, and (b) permanently, if the copyright 407 | holder fails to notify you of the violation by some reasonable means 408 | prior to 60 days after the cessation. 409 | 410 | Moreover, your license from a particular copyright holder is 411 | reinstated permanently if the copyright holder notifies you of the 412 | violation by some reasonable means, this is the first time you have 413 | received notice of violation of this License (for any work) from that 414 | copyright holder, and you cure the violation prior to 30 days after 415 | your receipt of the notice. 416 | 417 | Termination of your rights under this section does not terminate the 418 | licenses of parties who have received copies or rights from you under 419 | this License. If your rights have been terminated and not permanently 420 | reinstated, you do not qualify to receive new licenses for the same 421 | material under section 10. 422 | 423 | 9. Acceptance Not Required for Having Copies. 424 | 425 | You are not required to accept this License in order to receive or 426 | run a copy of the Program. Ancillary propagation of a covered work 427 | occurring solely as a consequence of using peer-to-peer transmission 428 | to receive a copy likewise does not require acceptance. However, 429 | nothing other than this License grants you permission to propagate or 430 | modify any covered work. These actions infringe copyright if you do 431 | not accept this License. Therefore, by modifying or propagating a 432 | covered work, you indicate your acceptance of this License to do so. 433 | 434 | 10. Automatic Licensing of Downstream Recipients. 435 | 436 | Each time you convey a covered work, the recipient automatically 437 | receives a license from the original licensors, to run, modify and 438 | propagate that work, subject to this License. You are not responsible 439 | for enforcing compliance by third parties with this License. 440 | 441 | An "entity transaction" is a transaction transferring control of an 442 | organization, or substantially all assets of one, or subdividing an 443 | organization, or merging organizations. If propagation of a covered 444 | work results from an entity transaction, each party to that 445 | transaction who receives a copy of the work also receives whatever 446 | licenses to the work the party's predecessor in interest had or could 447 | give under the previous paragraph, plus a right to possession of the 448 | Corresponding Source of the work from the predecessor in interest, if 449 | the predecessor has it or can get it with reasonable efforts. 450 | 451 | You may not impose any further restrictions on the exercise of the 452 | rights granted or affirmed under this License. For example, you may 453 | not impose a license fee, royalty, or other charge for exercise of 454 | rights granted under this License, and you may not initiate litigation 455 | (including a cross-claim or counterclaim in a lawsuit) alleging that 456 | any patent claim is infringed by making, using, selling, offering for 457 | sale, or importing the Program or any portion of it. 458 | 459 | 11. Patents. 460 | 461 | A "contributor" is a copyright holder who authorizes use under this 462 | License of the Program or a work on which the Program is based. The 463 | work thus licensed is called the contributor's "contributor version". 464 | 465 | A contributor's "essential patent claims" are all patent claims 466 | owned or controlled by the contributor, whether already acquired or 467 | hereafter acquired, that would be infringed by some manner, permitted 468 | by this License, of making, using, or selling its contributor version, 469 | but do not include claims that would be infringed only as a 470 | consequence of further modification of the contributor version. For 471 | purposes of this definition, "control" includes the right to grant 472 | patent sublicenses in a manner consistent with the requirements of 473 | this License. 474 | 475 | Each contributor grants you a non-exclusive, worldwide, royalty-free 476 | patent license under the contributor's essential patent claims, to 477 | make, use, sell, offer for sale, import and otherwise run, modify and 478 | propagate the contents of its contributor version. 479 | 480 | In the following three paragraphs, a "patent license" is any express 481 | agreement or commitment, however denominated, not to enforce a patent 482 | (such as an express permission to practice a patent or covenant not to 483 | sue for patent infringement). To "grant" such a patent license to a 484 | party means to make such an agreement or commitment not to enforce a 485 | patent against the party. 486 | 487 | If you convey a covered work, knowingly relying on a patent license, 488 | and the Corresponding Source of the work is not available for anyone 489 | to copy, free of charge and under the terms of this License, through a 490 | publicly available network server or other readily accessible means, 491 | then you must either (1) cause the Corresponding Source to be so 492 | available, or (2) arrange to deprive yourself of the benefit of the 493 | patent license for this particular work, or (3) arrange, in a manner 494 | consistent with the requirements of this License, to extend the patent 495 | license to downstream recipients. "Knowingly relying" means you have 496 | actual knowledge that, but for the patent license, your conveying the 497 | covered work in a country, or your recipient's use of the covered work 498 | in a country, would infringe one or more identifiable patents in that 499 | country that you have reason to believe are valid. 500 | 501 | If, pursuant to or in connection with a single transaction or 502 | arrangement, you convey, or propagate by procuring conveyance of, a 503 | covered work, and grant a patent license to some of the parties 504 | receiving the covered work authorizing them to use, propagate, modify 505 | or convey a specific copy of the covered work, then the patent license 506 | you grant is automatically extended to all recipients of the covered 507 | work and works based on it. 508 | 509 | A patent license is "discriminatory" if it does not include within 510 | the scope of its coverage, prohibits the exercise of, or is 511 | conditioned on the non-exercise of one or more of the rights that are 512 | specifically granted under this License. You may not convey a covered 513 | work if you are a party to an arrangement with a third party that is 514 | in the business of distributing software, under which you make payment 515 | to the third party based on the extent of your activity of conveying 516 | the work, and under which the third party grants, to any of the 517 | parties who would receive the covered work from you, a discriminatory 518 | patent license (a) in connection with copies of the covered work 519 | conveyed by you (or copies made from those copies), or (b) primarily 520 | for and in connection with specific products or compilations that 521 | contain the covered work, unless you entered into that arrangement, 522 | or that patent license was granted, prior to 28 March 2007. 523 | 524 | Nothing in this License shall be construed as excluding or limiting 525 | any implied license or other defenses to infringement that may 526 | otherwise be available to you under applicable patent law. 527 | 528 | 12. No Surrender of Others' Freedom. 529 | 530 | If conditions are imposed on you (whether by court order, agreement or 531 | otherwise) that contradict the conditions of this License, they do not 532 | excuse you from the conditions of this License. If you cannot convey a 533 | covered work so as to satisfy simultaneously your obligations under this 534 | License and any other pertinent obligations, then as a consequence you may 535 | not convey it at all. For example, if you agree to terms that obligate you 536 | to collect a royalty for further conveying from those to whom you convey 537 | the Program, the only way you could satisfy both those terms and this 538 | License would be to refrain entirely from conveying the Program. 539 | 540 | 13. Remote Network Interaction; Use with the GNU General Public License. 541 | 542 | Notwithstanding any other provision of this License, if you modify the 543 | Program, your modified version must prominently offer all users 544 | interacting with it remotely through a computer network (if your version 545 | supports such interaction) an opportunity to receive the Corresponding 546 | Source of your version by providing access to the Corresponding Source 547 | from a network server at no charge, through some standard or customary 548 | means of facilitating copying of software. This Corresponding Source 549 | shall include the Corresponding Source for any work covered by version 3 550 | of the GNU General Public License that is incorporated pursuant to the 551 | following paragraph. 552 | 553 | Notwithstanding any other provision of this License, you have 554 | permission to link or combine any covered work with a work licensed 555 | under version 3 of the GNU General Public License into a single 556 | combined work, and to convey the resulting work. The terms of this 557 | License will continue to apply to the part which is the covered work, 558 | but the work with which it is combined will remain governed by version 559 | 3 of the GNU General Public License. 560 | 561 | 14. Revised Versions of this License. 562 | 563 | The Free Software Foundation may publish revised and/or new versions of 564 | the GNU Affero General Public License from time to time. Such new versions 565 | will be similar in spirit to the present version, but may differ in detail to 566 | address new problems or concerns. 567 | 568 | Each version is given a distinguishing version number. If the 569 | Program specifies that a certain numbered version of the GNU Affero General 570 | Public License "or any later version" applies to it, you have the 571 | option of following the terms and conditions either of that numbered 572 | version or of any later version published by the Free Software 573 | Foundation. If the Program does not specify a version number of the 574 | GNU Affero General Public License, you may choose any version ever published 575 | by the Free Software Foundation. 576 | 577 | If the Program specifies that a proxy can decide which future 578 | versions of the GNU Affero General Public License can be used, that proxy's 579 | public statement of acceptance of a version permanently authorizes you 580 | to choose that version for the Program. 581 | 582 | Later license versions may give you additional or different 583 | permissions. However, no additional obligations are imposed on any 584 | author or copyright holder as a result of your choosing to follow a 585 | later version. 586 | 587 | 15. Disclaimer of Warranty. 588 | 589 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY 590 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT 591 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY 592 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, 593 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 594 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM 595 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF 596 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 597 | 598 | 16. Limitation of Liability. 599 | 600 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 601 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 602 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY 603 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE 604 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF 605 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD 606 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), 607 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF 608 | SUCH DAMAGES. 609 | 610 | 17. Interpretation of Sections 15 and 16. 611 | 612 | If the disclaimer of warranty and limitation of liability provided 613 | above cannot be given local legal effect according to their terms, 614 | reviewing courts shall apply local law that most closely approximates 615 | an absolute waiver of all civil liability in connection with the 616 | Program, unless a warranty or assumption of liability accompanies a 617 | copy of the Program in return for a fee. 618 | 619 | END OF TERMS AND CONDITIONS 620 | 621 | How to Apply These Terms to Your New Programs 622 | 623 | If you develop a new program, and you want it to be of the greatest 624 | possible use to the public, the best way to achieve this is to make it 625 | free software which everyone can redistribute and change under these terms. 626 | 627 | To do so, attach the following notices to the program. It is safest 628 | to attach them to the start of each source file to most effectively 629 | state the exclusion of warranty; and each file should have at least 630 | the "copyright" line and a pointer to where the full notice is found. 631 | 632 | 633 | Copyright (C) 634 | 635 | This program is free software: you can redistribute it and/or modify 636 | it under the terms of the GNU Affero General Public License as published 637 | by the Free Software Foundation, either version 3 of the License, or 638 | (at your option) any later version. 639 | 640 | This program is distributed in the hope that it will be useful, 641 | but WITHOUT ANY WARRANTY; without even the implied warranty of 642 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 643 | GNU Affero General Public License for more details. 644 | 645 | You should have received a copy of the GNU Affero General Public License 646 | along with this program. If not, see . 647 | 648 | Also add information on how to contact you by electronic and paper mail. 649 | 650 | If your software can interact with users remotely through a computer 651 | network, you should also make sure that it provides a way for users to 652 | get its source. For example, if your program is a web application, its 653 | interface could display a "Source" link that leads users to an archive 654 | of the code. There are many ways you could offer source, and different 655 | solutions will be better for different programs; see section 13 for the 656 | specific requirements. 657 | 658 | You should also get your employer (if you work as a programmer) or school, 659 | if any, to sign a "copyright disclaimer" for the program, if necessary. 660 | For more information on this, and how to apply and follow the GNU AGPL, see 661 | . 662 | --------------------------------------------------------------------------------