Skip to content

Commit

Permalink
refactor: ♻️ 调整项目结构,将所有代码放到一起
Browse files Browse the repository at this point in the history
  • Loading branch information
hymbz committed May 8, 2023
1 parent cb04ccb commit 3ef37dc
Show file tree
Hide file tree
Showing 150 changed files with 2,201 additions and 12,159 deletions.
3 changes: 1 addition & 2 deletions .eslintrc.js → .eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ const publicConfig = {
singleQuote: true,
trailingComma: 'all',
htmlWhitespaceSensitivity: 'strict',
plugins: [require('prettier-plugin-tailwindcss')],
},
],

Expand Down Expand Up @@ -83,7 +82,7 @@ module.exports = {
parser: '@typescript-eslint/parser',
parserOptions: {
tsconfigRootDir: __dirname,
project: ['./packages/*/tsconfig.json'],
project: ['./tsconfig.json'],
},
plugins: ['@typescript-eslint', 'jsdoc', 'solid'],
extends: [
Expand Down
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
dist
node_modules
packages/ui-component/tsconfig.tsbuildinfo
File renamed without changes.
2 changes: 2 additions & 0 deletions .stylelintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,7 @@ module.exports = {

// 防止使用低性能的动画和过度属性
'plugin/no-low-performance-animation-properties': true,

'import-notation': 'string',
},
};
4,853 changes: 0 additions & 4,853 deletions ComicRead.user.js

This file was deleted.

26 changes: 0 additions & 26 deletions ComicReadScript.code-workspace

This file was deleted.

18 changes: 15 additions & 3 deletions docs/Dev.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
## TODO

- 百合会更新后自动签到失效了
- 长图自动开启卷轴模式 https://bbs.yamibo.com/thread-534775-1-1.html
- 页数加一
- 测试平板上的使用
- 卷轴模式下滚动到底要能触发结束页
- 放大后侧边栏按钮悬浮背景色变为半透明会导致看不清图标
- 检查控制台警告
- 300 自动签到功能在菜单切换时没有实时刷新
- 为图片增加背景,以便用户知道当前图片正在加载
- 百合会退出时有点卡
- 填充页位置调整 https://bbs.yamibo.com/thread-535108-1-1.html

## 项目结构

Expand All @@ -20,7 +23,6 @@
## 调试

```bash
cd packages/userscript
pnpm dev
```

Expand Down Expand Up @@ -52,10 +54,20 @@ Object.fromEntries(
3. 如果有上下一话的按钮,就通过 `setManga` 修改 onNext、onPrev 两个参数。注意如果按钮存在但无法点击的话,应该传递空值或直接不传
4.`init` 函数传一个返回所有图片链接的函数

---

## 动态导入外部库

`src\helper\import.ts`
创建一个自定义的 require 函数放在脚本开头,再让 rollup 导出 cjs 模块规范的代码,就能直接在脚本里使用 cjs、umd 模块了。
不过因为有些 cjs 会使用 node 环境特有的变量、在模块里再 require() 其他模块(这种情况下也需要将其依赖模块在 @resource 中声明),所以尽量还是选择 umd 的代码。

另外为了尽量减少在无关页面浪费时间,components、helper 下的代码会被打包视为外部库 `'../helper'` 来使用,如果只需要其中一段代码则通过 `helper/XXX` 来导入即可。

## pnpm dev

这个命令总共会做三件事

1. 打包代码到 dist
2. 创建 dist 的文件服务器,用于在浏览器获取最新的脚本代码
3. 使用 vite 加载 src\components\display.tsx 以便单独测试组件
2 changes: 1 addition & 1 deletion packages/ui-component/index.html → index.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<body>
<noscript>You need to enable JavaScript to run this app.</noscript>
<div id="root"></div>
<script type="module" src="/src/display.tsx"></script>
<script type="module" src="/src/components/display.tsx"></script>
<style type="text/css">
html {
background-color: black;
Expand Down
74 changes: 54 additions & 20 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,37 +5,71 @@
"author": "hymbz",
"license": "AGPL-3.0-or-later",
"private": "true",
"workspaces": [
"packages/*"
],
"scripts": {
"release": "node scripts/release.mjs",
"dev": "rollup --config --watch --environment NODE_ENV:development --configPlugin rollup-plugin-ts",
"build": "rollup --config --configPlugin rollup-plugin-ts",
"release": "node release.mjs",
"test": "vitest"
},
"dependencies": {
"@material-design-icons/svg": "^0.14.6",
"fflate": "^0.7.4",
"panzoom": "^9.4.3",
"solid-element": "^1.7.0",
"solid-js": "^1.7.3",
"solid-toast": "^0.5.0",
"throttle-debounce": "^5.0.0"
},
"devDependencies": {
"@babel/core": "^7.21.4",
"@babel/plugin-transform-runtime": "^7.21.4",
"@babel/preset-env": "^7.21.4",
"@babel/preset-typescript": "^7.21.4",
"@babel/runtime": "^7.17.9",
"@release-it/conventional-changelog": "^5.1.1",
"@typescript-eslint/eslint-plugin": "^5.58.0",
"@typescript-eslint/parser": "^5.58.0",
"@rollup/plugin-babel": "^6.0.3",
"@rollup/plugin-commonjs": "^24.1.0",
"@rollup/plugin-node-resolve": "^15.0.2",
"@rollup/plugin-replace": "^5.0.2",
"@solidjs/router": "^0.8.2",
"@types/shelljs": "^0.8.12",
"@types/throttle-debounce": "^5.0.0",
"@typescript-eslint/eslint-plugin": "^5.59.0",
"@typescript-eslint/parser": "^5.59.0",
"autoprefixer": "^10.4.14",
"babel-preset-solid": "^1.7.3",
"cssnano": "^6.0.0",
"eslint": "^8.38.0",
"eslint-config-airbnb-base": "^15.0.0",
"eslint-config-prettier": "^8.8.0",
"eslint-plugin-import": "^2.27.5",
"eslint-plugin-jsdoc": "^41.1.1",
"eslint-plugin-jsx-a11y": "^6.7.1",
"eslint-plugin-jsdoc": "^43.0.6",
"eslint-plugin-prettier": "^4.2.1",
"eslint-plugin-solid": "^0.12.1",
"fake-indexeddb": "^4.0.1",
"jsdom": "^21.1.1",
"normalize.css": "^8.0.1",
"postcss-import": "^15.1.0",
"postcss-nesting": "^11.2.2",
"prettier": "^2.8.7",
"release-it": "^15.8.0",
"rollup-plugin-userscript-metablock": "^0.3.1",
"release-it": "^15.10.1",
"rollup": "^3.20.6",
"rollup-plugin-styles": "^4.0.0",
"rollup-plugin-ts": "^3.2.0",
"rollup-plugin-watch-external": "^1.0.2",
"shelljs": "^0.8.5",
"stylelint": "^14.11.0",
"stylelint-config-clean-order": "^0.9.0",
"stylelint-config-prettier": "^9.0.3",
"stylelint-config-recess-order": "^3.0.0",
"stylelint-config-standard": "^28.0.0",
"stylelint-high-performance-animation": "^1.6.0",
"stylelint-order": "^5.0.0",
"stylelint-prettier": "^2.0.0",
"typescript": "^5.0.4",
"vitest": "^0.28.4"
"stylelint": "^15.6.0",
"stylelint-config-clean-order": "^5.0.1",
"stylelint-config-prettier": "^9.0.5",
"stylelint-config-recess-order": "^4.0.0",
"stylelint-config-standard": "^33.0.0",
"stylelint-high-performance-animation": "^1.8.0",
"stylelint-order": "^6.0.3",
"stylelint-prettier": "^3.0.0",
"svgo": "^3.0.2",
"tslib": "^2.5.0",
"vite": "^4.2.2",
"vite-plugin-solid": "^2.7.0",
"vitest": "^0.30.1"
}
}
2 changes: 0 additions & 2 deletions packages/ui-component/.gitignore

This file was deleted.

3 changes: 0 additions & 3 deletions packages/ui-component/README.md

This file was deleted.

Loading

0 comments on commit 3ef37dc

Please sign in to comment.