Merge pull request #86 from Tlntin/master

This commit is contained in:
Tw93
2022-11-19 23:02:29 +08:00
committed by GitHub
81 changed files with 875 additions and 60 deletions

2
.gitignore vendored
View File

@@ -21,6 +21,8 @@ dist-ssr
*.njsproj
*.sln
*.sw?
.npmrc
output
package-lock.json
yarn.lock

View File

@@ -63,8 +63,19 @@
更多常用 App 下载可以去 [Releases](https://github.com/tw93/Pake/releases) 中看看。
## 快捷键
## 快捷键(Windows/Linux)
1. <kbd>Ctrl</kbd> + <kbd>⬅</kbd>:返回上一个页面
2. <kbd>Ctrl</kbd> + <kbd>➡</kbd>:去下一个页面
3. <kbd>Ctrl</kbd> + <kbd>⬆</kbd>:自动滚动到页面顶部
4. <kbd>Ctrl</kbd> + <kbd>⬇</kbd>:自动滚动到页面底部
5. <kbd>Ctrl</kbd> + <kbd>r</kbd>:刷新页面
6. <kbd>Ctrl</kbd> + <kbd>-</kbd>:缩小页面
7. <kbd>Ctrl</kbd> + <kbd>+</kbd>:放大页面
8. <kbd>Ctrl</kbd> + <kbd>=</kbd>:放大页面
9. <kbd>Ctrl</kbd> + <kbd>0</kbd>:重置页面缩放
## 快捷键(Mac)
1. <kbd>⌘</kbd> + <kbd>[</kbd>:返回上一个页面
2. <kbd>⌘</kbd> + <kbd>]</kbd>:去下一个页面
3. <kbd>⌘</kbd> + <kbd>↑</kbd>:自动滚动到页面顶部
@@ -77,6 +88,10 @@
此外还支持双击头部进行全屏切换,拖拽头部进行移动窗口,还有其他需求,欢迎提过来。
## 已知Bug
- Windows下不能安装到C:\Program File会直接闪退。建议安装到其他目录比如D:\Program Files。
- Linux下暂时不能存cookie即应用关闭后数据清空账号自动推出。
## 开发
开始前参考 [Tauri](https://tauri.app/v1/guides/getting-started/prerequisites#setting-up-macos) 快速配置好环境,如果你想打包 Windows、Linux 系统的包,可以参考 [Building](https://tauri.app/v1/guides/building/) 文档
@@ -88,8 +103,20 @@ npm i
// 调试
npm run dev
// 打包
// 打包(Mac)
npm run build
// 打包Windows
npm run build:windows
// 打包Linux
npm run build:linux
// 一键打包所有项目Linux/Mac
chmod +x build.sh && ./build.sh
// 一键打包所有项目Windows)
.\build.bat
```
## 打新包

View File

@@ -63,7 +63,20 @@
More common apps can be downloaded from [Releases](https://github.com/tw93/Pake/releases).
## Shortcuts
## Shortcuts(Windows/Linux)
1. <kbd>Ctrl</kbd> + <kbd>⬅</kbd>Return to the previous page
2. <kbd>Ctrl</kbd> + <kbd>➡</kbd>Go to the next page
3. <kbd>Ctrl</kbd> + <kbd>⬆</kbd>Auto scroll to top of page
4. <kbd>Ctrl</kbd> + <kbd>⬇</kbd>Auto scroll to bottom of page
5. <kbd>Ctrl</kbd> + <kbd>r</kbd>Refresh Page
6. <kbd>Ctrl</kbd> + <kbd>-</kbd>Zoom out the page
7. <kbd>Ctrl</kbd> + <kbd>+</kbd>Zoom in the Page
8. <kbd>Ctrl</kbd> + <kbd>=</kbd>Zoom in the Page
9. <kbd>Ctrl</kbd> + <kbd>0</kbd>Reset the page zoom
## Shortcuts(Mac)
1. <kbd>⌘</kbd> + <kbd>[</kbd>Return to the previous page
2. <kbd>⌘</kbd> + <kbd>]</kbd>Go to the next page
@@ -77,6 +90,10 @@ More common apps can be downloaded from [Releases](https://github.com/tw93/Pake/
In addition, it supports double clicking the head to switch to full screen, and dragging the head to move the window
## Bugs
- It cannot be installed to C:\Program File under Windows, and it will crash directly. It is recommended to install to another directory, such as D:\Program Files.
- Under Linux, cookies cannot be stored temporarily, that is, the data will be cleared after the application is closed, and the account will be automatically released.
## Development
Refer to the [Tauri documentation](https://tauri.app/v1/guides/getting-started/prerequisites#setting-up-macos) to quickly configure your environment before you start, if you want to package Windows or Linux systems, you can refer to [Building](https://tauri.app/v1/guides/building/) Documentation.
@@ -88,10 +105,25 @@ npm i
// Local development
npm run dev
// Pack
// Pack (Mac)
npm run build
// Pack (Windows)
npm run build:windows
// Pack(Linux)
npm run build:linux
// One-click packaging of all projects (Linux/Mac)
chmod +x build.sh && ./build.sh
// One-click packaging of all projects (Windows)
.\build.bat
```
// Package all your projects in one click
chmod +x build.sh && ./build.sh
## New pack
1. Modify the `tauri.conf.json` in the `src-tauri` directory to include 4 fields `url, productName, icon, identifier`, icon can be selected from the `icons` directory or downloaded from [macOSicons](https://macosicons.com/#/) to match the product.

4
app.csv Normal file
View File

@@ -0,0 +1,4 @@
weread,微信阅读,weread.qq.com
aliyuque,语雀,www.yuque.com
flomo,浮墨,flomoapp.com
weread,微信阅读,weread.qq.com
1 weread 微信阅读 weread.qq.com
2 aliyuque 语雀 www.yuque.com
3 flomo 浮墨 flomoapp.com
4 weread 微信阅读 weread.qq.com

69
build.bat Normal file
View File

@@ -0,0 +1,69 @@
@echo off
chcp 65001
if not exist node_modules (
call npm i
)
if not exist output (
mkdir output
)
if not exist output\windows (
mkdir output\windows
)
echo.
echo =======================
echo "build for windows"
echo =======================
echo.
:: total package number
set /A index=1
for /f %%a in (' find /c /v "" ^<"app.csv" ') do set /A total=%%a
set old_name=weread
set old_zh_name=微信阅读
set old_url=weread.qq.com
for /f "tokens=1-3 delims=," %%i in (app.csv) do (
setlocal enabledelayedexpansion
set name=%%i
set name_zh=%%j
set url=%%k
@echo on
::echo name is !name! !name_zh! !url!
:: replace url
.\sd.exe !old_url! !url! src-tauri\tauri.conf.json
::replace pacakge name
.\sd.exe !old_name! !name! src-tauri\tauri.conf.json
echo update ico with 32x32 pictue
echo .\sd.exe !old_name! !name! src-tauri\src\main.rs
.\sd.exe !old_name! !name! src-tauri\src\main.rs
::copy src-tauri\png\!name!_32.ico src-tauri\icons\icon.ico
echo.
::update package info
set old_zh_name=!name_zh!
set old_name=!name!
set old_url=!url!
::build package
echo building package !index!/!total!
echo package name is !name! !name_zh!
echo npm run build:windows
@echo off
call npm run tauri build -- --target x86_64-pc-windows-msvc
move src-tauri\target\x86_64-pc-windows-msvc\release\bundle\msi\*.msi output\windows
@echo on
echo package build success!
echo.
echo.
set /A index=index+1
@echo off
)
echo "output dir is output\windows"

116
build.sh Executable file
View File

@@ -0,0 +1,116 @@
#!/bin/bash
if [ ! -d "node_modules" ]; then
npm i
fi
if [ ! -d "output" ]; then
mkdir output
fi
if [[ "$OSTYPE" =~ ^linux ]]; then
if [ ! -d "output/linux" ]; then
mkdir output/linux
fi
fi
if [[ "$OSTYPE" =~ ^darwin ]]; then
if [ ! -d "output/macos" ]; then
mkdir output/macos
fi
fi
# total package number
export total=`sed -n '$=' app.csv`
export index=1
old_name="weread"
old_zh_name="微信阅读"
old_url="weread.qq.com"
package_prefix="com-tw93"
if [[ "$OSTYPE" =~ ^linux ]]; then
echo "==============="
echo "Build for Linux"
echo "==============="
# for linux, package name may be com.xxx.xxx
echo "rename package name"
export desktop_file="src-tauri/assets/${package_prefix}.weread.desktop"
sed -i "s/\"productName\": \"weread\"/\"productName\": \"${package_prefix}-weread\"/g" src-tauri/tauri.conf.json
fi
if [[ "$OSTYPE" =~ ^darwin ]]; then
echo "==============="
echo "Build for MacOS"
echo "==============="
fi
while read line
do
package_name=$(echo ${line} | cut -d , -f 1)
package_zh_name=$(echo ${line} | cut -d , -f 2)
url=$(echo ${line} | cut -d , -f 3)
echo "update package name and url"
# replace package info
if [[ "$OSTYPE" =~ ^linux ]]; then
sed -i "s/${old_url}/${url}/g" src-tauri/tauri.conf.json
sed -i "s/${old_name}/${package_name}/g" src-tauri/tauri.conf.json
echo "update ico with 32x32 pictue"
sed -i "s/${old_name}/${package_name}/g" src-tauri/src/main.rs
fi
if [[ "$OSTYPE" =~ ^darwin ]]; then
sed -i '' "s|${old_url}|${url}|g" src-tauri/tauri.conf.json
sed -i '' "s|${old_name}|${package_name}|g" src-tauri/tauri.conf.json
echo "update ico with 32x32 pictue"
sed -i '' "s|${old_name}|${package_name}|g" src-tauri/src/main.rs
fi
# echo "update ico with 32x32 pictue"
# cp "src-tauri/png/${package_name}_32.ico" "src-tauri/icons/icon.ico"
if [[ "$OSTYPE" =~ ^linux ]]; then
echo "update desktop"
old_desktop="src-tauri/assets/${package_prefix}-${old_name}.desktop"
new_desktop="src-tauri/assets/${package_prefix}-${package_name}.desktop"
mv ${old_desktop} ${new_desktop}
sed -i "s/${old_zh_name}/${package_zh_name}/g" ${new_desktop}
sed -i "s/${old_name}/${package_name}/g" ${new_desktop}
fi
# update package info
old_zh_name=${package_zh_name}
old_name=${package_name}
old_url=${url}
echo "building package ${index}/${total}"
echo "package name is ${package_name} (${package_zh_name})"
npm run tauri build
echo "package build success!"
index=$(($index+1))
if [[ "$OSTYPE" =~ ^linux ]]; then
mv src-tauri/target/release/bundle/deb/*.deb output/linux
fi
if [[ "$OSTYPE" =~ ^darwin ]]; then
mv src-tauri/target/release/bundle/dmg/*.dmg output/macos
echo ""
fi
done < app.csv
echo "build all package success!"
if [[ "$OSTYPE" =~ ^linux ]]; then
echo "result file in output/linux"
fi
if [[ "$OSTYPE" =~ ^darwin ]]; then
echo "result file in output/macos"
fi

38
icns2png.py Normal file
View File

@@ -0,0 +1,38 @@
"""
批量将icns文件转成png文件
Batch convert ICNS files to PNG files
"""
import os
try:
from PIL import Image
except ImportError:
os.system("pip install Pillow")
from PIL import Image
if __name__ == "__main__":
now_dir = os.path.dirname(os.path.abspath(__file__))
icons_dir = os.path.join(now_dir, "src-tauri", "icons")
png_dir = os.path.join(now_dir, "src-tauri", "png")
if not os.path.exists(png_dir):
os.mkdir(png_dir)
file_list = os.listdir(icons_dir)
file_list = [file for file in file_list if file.endswith(".icns")]
for file in file_list:
icns_path = os.path.join(icons_dir, file)
image = Image.open(icns_path)
image_512 = image.copy().resize((512, 512))
image_256 = image.copy().resize((256, 256))
image_32 = image.copy().resize((32, 32))
image_name = os.path.splitext(file)[0]
image_512_path = os.path.join(png_dir, image_name + "_512.png")
image_256_path = os.path.join(png_dir, image_name + "_256.ico")
image_32_path = os.path.join(png_dir, image_name + "_32.ico")
image_512.save(image_512_path, "PNG")
image_256.save(image_256_path, "ICO")
image_32.save(image_32_path, "ICO")
print("png file write success.")
print(f"There are {len(os.listdir(png_dir))} png picture in ", png_dir)

View File

@@ -15,6 +15,7 @@
"dev:debug": "npm run tauri dev -- --features devtools",
"build": "npm run tauri build -- --target universal-apple-darwin",
"build:windows": "npm run tauri build -- --target x86_64-pc-windows-msvc",
"build:linux": "npm run tauri build --release",
"tauri": "tauri"
},
"license": "MIT",

BIN
sd.exe Normal file

Binary file not shown.

254
src-tauri/Cargo.lock generated
View File

@@ -57,6 +57,7 @@ checksum = "bb07d2053ccdbe10e2af2995a2f116c1330396493dc1269f6a91d0ae82e19704"
name = "app"
version = "0.1.0"
dependencies = [
"image",
"serde",
"serde_json",
"tauri",
@@ -118,6 +119,12 @@ version = "0.13.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "904dfeac50f3cdaba28fc6f57fdcddb75f49ed61346676a78c4ffe55877802fd"
[[package]]
name = "bit_field"
version = "0.10.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "dcb6dd1c2376d2e096796e234a70e17e94cc2d5d54ff8ce42b28cef1d0d359a4"
[[package]]
name = "bitflags"
version = "1.3.2"
@@ -395,6 +402,30 @@ dependencies = [
"crossbeam-utils",
]
[[package]]
name = "crossbeam-deque"
version = "0.8.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "715e8152b692bba2d374b53d4875445368fdf21a94751410af607a5ac677d1fc"
dependencies = [
"cfg-if",
"crossbeam-epoch",
"crossbeam-utils",
]
[[package]]
name = "crossbeam-epoch"
version = "0.9.11"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f916dfc5d356b0ed9dae65f1db9fc9770aa2851d2662b988ccf4fe3516e86348"
dependencies = [
"autocfg",
"cfg-if",
"crossbeam-utils",
"memoffset",
"scopeguard",
]
[[package]]
name = "crossbeam-utils"
version = "0.8.10"
@@ -405,6 +436,12 @@ dependencies = [
"once_cell",
]
[[package]]
name = "crunchy"
version = "0.2.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7a81dae078cea95a014a339291cec439d2f232ebe854a9d672b796c6afafa9b7"
[[package]]
name = "crypto-common"
version = "0.1.3"
@@ -514,15 +551,6 @@ dependencies = [
"byteorder",
]
[[package]]
name = "deflate"
version = "1.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c86f7e25f518f4b81808a2cf1c50996a61f5c2eb394b2393bd87f2a4780a432f"
dependencies = [
"adler32",
]
[[package]]
name = "derive_more"
version = "0.99.17"
@@ -594,6 +622,12 @@ version = "1.0.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0bd4b30a6560bbd9b4620f4de34c3f14f60848e58a9b7216801afcb4c7b31c3c"
[[package]]
name = "either"
version = "1.8.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "90e5c1c8368803113bf0c9584fc495a58b86dc8a29edbf8fe877d21d9507e797"
[[package]]
name = "embed_plist"
version = "1.2.2"
@@ -609,6 +643,21 @@ dependencies = [
"cfg-if",
]
[[package]]
name = "exr"
version = "1.5.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8eb5f255b5980bb0c8cf676b675d1a99be40f316881444f44e0462eaf5df5ded"
dependencies = [
"bit_field",
"flume",
"half",
"lebe",
"miniz_oxide 0.6.2",
"smallvec",
"threadpool",
]
[[package]]
name = "fastrand"
version = "1.7.0"
@@ -647,7 +696,20 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f82b0f4c27ad9f8bfd1f3208d882da2b09c301bc1c828fd3a00d0216d2fbbff6"
dependencies = [
"crc32fast",
"miniz_oxide",
"miniz_oxide 0.5.3",
]
[[package]]
name = "flume"
version = "0.10.14"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1657b4441c3403d9f7b3409e47575237dac27b1b5726df654a6ecbf92f0f7577"
dependencies = [
"futures-core",
"futures-sink",
"nanorand",
"pin-project",
"spin",
]
[[package]]
@@ -734,6 +796,12 @@ dependencies = [
"syn",
]
[[package]]
name = "futures-sink"
version = "0.3.25"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "39c15cf1a4aa79df40f1bb462fb39676d0ad9e366c2a33b590d7c66f4f81fcf9"
[[package]]
name = "futures-task"
version = "0.3.21"
@@ -876,8 +944,20 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4eb1a864a501629691edf6c15a593b7a51eebaa1e8468e9ddc623de7c9b58ec6"
dependencies = [
"cfg-if",
"js-sys",
"libc",
"wasi 0.11.0+wasi-snapshot-preview1",
"wasm-bindgen",
]
[[package]]
name = "gif"
version = "0.11.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3edd93c6756b4dfaf2709eafcc345ba2636565295c198a9cfbf75fa5e3e00b06"
dependencies = [
"color_quant",
"weezl",
]
[[package]]
@@ -1040,6 +1120,15 @@ dependencies = [
"syn",
]
[[package]]
name = "half"
version = "2.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ad6a9459c9c30b177b925162351f97e7d967c7ea8bab3b8352805327daf45554"
dependencies = [
"crunchy",
]
[[package]]
name = "hashbrown"
version = "0.12.1"
@@ -1148,16 +1237,21 @@ dependencies = [
[[package]]
name = "image"
version = "0.24.2"
version = "0.24.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "28edd9d7bc256be2502e325ac0628bde30b7001b9b52e0abe31a1a9dc2701212"
checksum = "69b7ea949b537b0fd0af141fff8c77690f2ce96f4f41f042ccb6c69c6c965945"
dependencies = [
"bytemuck",
"byteorder",
"color_quant",
"num-iter",
"exr",
"gif",
"jpeg-decoder",
"num-rational",
"num-traits",
"png 0.17.7",
"scoped_threadpool",
"tiff",
]
[[package]]
@@ -1266,6 +1360,15 @@ version = "0.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8eaf4bc02d17cbdd7ff4c7438cafcdf7fb9a4613313ad11b4f8fefe7d3fa0130"
[[package]]
name = "jpeg-decoder"
version = "0.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bc0000e42512c92e31c2252315bda326620a4e034105e900c98ec492fa077b3e"
dependencies = [
"rayon",
]
[[package]]
name = "js-sys"
version = "0.3.58"
@@ -1304,6 +1407,12 @@ version = "1.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646"
[[package]]
name = "lebe"
version = "0.5.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "03087c2bad5e1034e8cace5926dec053fb3790248370865f5117a7d0213354c8"
[[package]]
name = "libc"
version = "0.2.126"
@@ -1443,6 +1552,24 @@ dependencies = [
"adler",
]
[[package]]
name = "miniz_oxide"
version = "0.6.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b275950c28b37e794e8c55d88aeb5e139d0ce23fdbbeda68f8d7174abdf9e8fa"
dependencies = [
"adler",
]
[[package]]
name = "nanorand"
version = "0.7.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6a51313c5820b0b02bd422f4b44776fbf47961755c74ce64afc73bfad10226c3"
dependencies = [
"getrandom 0.2.7",
]
[[package]]
name = "native-tls"
version = "0.2.10"
@@ -1887,6 +2014,26 @@ dependencies = [
"siphasher",
]
[[package]]
name = "pin-project"
version = "1.0.12"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ad29a609b6bcd67fee905812e544992d216af9d755757c05ed2d0e15a74c6ecc"
dependencies = [
"pin-project-internal",
]
[[package]]
name = "pin-project-internal"
version = "1.0.12"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "069bdb1e05adc7a8990dce9cc75370895fbe4e3d58b9b73bf1aee56359344a55"
dependencies = [
"proc-macro2",
"quote",
"syn",
]
[[package]]
name = "pin-project-lite"
version = "0.2.9"
@@ -1926,21 +2073,21 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f0b0cabbbd20c2d7f06dbf015e06aad59b6ca3d9ed14848783e98af9aaf19925"
dependencies = [
"bitflags",
"deflate 0.7.20",
"deflate",
"inflate",
"num-iter",
]
[[package]]
name = "png"
version = "0.17.5"
version = "0.17.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "dc38c0ad57efb786dd57b9864e5b18bae478c00c824dc55a38bbc9da95dde3ba"
checksum = "5d708eaf860a19b19ce538740d2b4bdeeb8337fa53f7738455e706623ad5c638"
dependencies = [
"bitflags",
"crc32fast",
"deflate 1.0.0",
"miniz_oxide",
"flate2",
"miniz_oxide 0.6.2",
]
[[package]]
@@ -2103,6 +2250,30 @@ dependencies = [
"cty",
]
[[package]]
name = "rayon"
version = "1.5.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bd99e5772ead8baa5215278c9b15bf92087709e9c1b2d1f97cdb5a183c933a7d"
dependencies = [
"autocfg",
"crossbeam-deque",
"either",
"rayon-core",
]
[[package]]
name = "rayon-core"
version = "1.9.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "258bcdb5ac6dad48491bb2992db6b7cf74878b0384908af124823d118c99683f"
dependencies = [
"crossbeam-channel",
"crossbeam-deque",
"crossbeam-utils",
"num_cpus",
]
[[package]]
name = "redox_syscall"
version = "0.2.13"
@@ -2243,6 +2414,12 @@ version = "1.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ea6a9290e3c9cf0f18145ef7ffa62d68ee0bf5fcd651017e586dc7fd5da448c2"
[[package]]
name = "scoped_threadpool"
version = "0.1.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1d51f5df5af43ab3f1360b429fa5e0152ac5ce8c0bd6485cae490332e96846a8"
[[package]]
name = "scopeguard"
version = "1.1.0"
@@ -2503,6 +2680,15 @@ dependencies = [
"system-deps 5.0.0",
]
[[package]]
name = "spin"
version = "0.9.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7f6002a767bff9e83f8eeecf883ecb8011875a21ae8da43bffb817a57e78cc09"
dependencies = [
"lock_api",
]
[[package]]
name = "stable_deref_trait"
version = "1.2.0"
@@ -2643,7 +2829,7 @@ dependencies = [
"once_cell",
"parking_lot",
"paste",
"png 0.17.5",
"png 0.17.7",
"raw-window-handle",
"scopeguard",
"serde",
@@ -2689,7 +2875,7 @@ dependencies = [
"once_cell",
"parking_lot",
"paste",
"png 0.17.5",
"png 0.17.7",
"raw-window-handle",
"scopeguard",
"serde",
@@ -2791,7 +2977,7 @@ dependencies = [
"ico",
"json-patch",
"plist",
"png 0.17.5",
"png 0.17.7",
"proc-macro2",
"quote",
"regex",
@@ -2948,6 +3134,26 @@ dependencies = [
"once_cell",
]
[[package]]
name = "threadpool"
version = "1.8.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d050e60b33d41c19108b32cea32164033a9013fe3b46cbd4457559bfbf77afaa"
dependencies = [
"num_cpus",
]
[[package]]
name = "tiff"
version = "0.8.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f17def29300a156c19ae30814710d9c63cd50288a49c6fd3a10ccfbe4cf886fd"
dependencies = [
"flate2",
"jpeg-decoder",
"weezl",
]
[[package]]
name = "time"
version = "0.3.11"
@@ -3369,6 +3575,12 @@ dependencies = [
"windows-metadata",
]
[[package]]
name = "weezl"
version = "0.1.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9193164d4de03a926d909d3bc7c30543cecb35400c02114792c2cae20d5e2dbb"
[[package]]
name = "widestring"
version = "1.0.2"

View File

@@ -12,14 +12,16 @@ rust-version = "1.61.0"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[build-dependencies]
tauri-build = { version = "1.1.1", features = [] }
tauri-build = { version = "1.2.0", features = [] }
[dependencies]
serde_json = "1.0.86"
serde = { version = "1.0.145", features = ["derive"] }
tauri = { version = "1.1.1", features = ["api-all"] }
tauri = { version = "1.2.0", features = ["api-all"] }
image = "0.24.5"
wry = "0.21.1"
tauri-utils = "1.1.1"
tauri-utils = "1.2.0"
webbrowser = "0.8.2"
[features]

View File

@@ -0,0 +1,10 @@
[Desktop Entry]
Encoding=UTF-8
Categories=Office
Exec=com-tw93-weread
Icon=com-tw93-weread
Name=com-tw93-weread
Name[zh_CN]=微信阅读
StartupNotify=true
Terminal=false
Type=Application

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.2 KiB

After

Width:  |  Height:  |  Size: 2.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 47 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 75 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 33 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 37 KiB

BIN
src-tauri/png/code_256.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 65 KiB

BIN
src-tauri/png/code_32.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.7 KiB

BIN
src-tauri/png/code_512.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 124 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 28 KiB

BIN
src-tauri/png/fanfou_32.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 35 KiB

BIN
src-tauri/png/flomo_256.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 47 KiB

BIN
src-tauri/png/flomo_32.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.1 KiB

BIN
src-tauri/png/flomo_512.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 80 KiB

BIN
src-tauri/png/fone_256.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 28 KiB

BIN
src-tauri/png/fone_32.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.9 KiB

BIN
src-tauri/png/fone_512.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 33 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 23 KiB

BIN
src-tauri/png/jdread_32.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 26 KiB

BIN
src-tauri/png/jike_256.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 21 KiB

BIN
src-tauri/png/jike_32.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 KiB

BIN
src-tauri/png/jike_512.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 26 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

BIN
src-tauri/png/notion_32.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 374 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 874 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 39 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 55 KiB

BIN
src-tauri/png/roam_256.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 50 KiB

BIN
src-tauri/png/roam_32.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.3 KiB

BIN
src-tauri/png/roam_512.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 75 KiB

BIN
src-tauri/png/tool_256.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 49 KiB

BIN
src-tauri/png/tool_32.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.1 KiB

BIN
src-tauri/png/tool_512.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 75 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 48 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 91 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 38 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 54 KiB

BIN
src-tauri/png/v2ex_256.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 40 KiB

BIN
src-tauri/png/v2ex_32.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.6 KiB

BIN
src-tauri/png/v2ex_512.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 51 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 42 KiB

BIN
src-tauri/png/vercel_32.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 66 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 24 KiB

BIN
src-tauri/png/weread_32.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 27 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 48 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 72 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 29 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 44 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 35 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 60 KiB

BIN
src-tauri/png/yuque_256.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 52 KiB

BIN
src-tauri/png/yuque_32.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.5 KiB

BIN
src-tauri/png/yuque_512.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 102 KiB

View File

@@ -1,44 +1,107 @@
// at the top of main.rs - that will prevent the console from showing
#![windows_subsystem = "windows"]
extern crate image;
use tauri_utils::config::{Config, WindowConfig};
#[cfg(target_os = "macos")]
use wry::application::platform::macos::WindowBuilderExtMacOS;
#[cfg(target_os = "windows")]
use wry::application::platform::windows::WindowBuilderExtWindows;
#[cfg(target_os="macos")]
use wry::{
application::{
accelerator::{Accelerator, SysMods},
event::{Event, StartCause, WindowEvent},
event_loop::{ControlFlow, EventLoop},
keyboard::KeyCode,
menu::{MenuBar as Menu, MenuItem, MenuItemAttributes, MenuType},
window::{Fullscreen, Window, WindowBuilder},
},
webview::WebViewBuilder,
};
#[cfg(target_os="windows")]
use wry::{
application::{
event::{Event, StartCause, WindowEvent},
event_loop::{ControlFlow, EventLoop},
menu::{MenuType},
window::{Fullscreen, Window, WindowBuilder, Icon},
},
webview::WebViewBuilder,
};
#[cfg(target_os="linux")]
use wry::{
application::{
event::{Event, StartCause, WindowEvent},
event_loop::{ControlFlow, EventLoop},
menu::{MenuType},
window::{Fullscreen, Window, WindowBuilder},
},
webview::WebViewBuilder,
};
fn main() -> wry::Result<()> {
use wry::{
application::{
accelerator::{Accelerator, SysMods},
event::{Event, StartCause, WindowEvent},
event_loop::{ControlFlow, EventLoop},
keyboard::KeyCode,
menu::{MenuBar as Menu, MenuItem, MenuItemAttributes, MenuType},
window::{Fullscreen, Window, WindowBuilder},
},
webview::WebViewBuilder,
};
#[cfg(target_os = "macos")]
let mut menu_bar_menu = Menu::new();
#[cfg(target_os = "macos")]
let mut first_menu = Menu::new();
#[cfg(target_os = "macos")]
first_menu.add_native_item(MenuItem::Hide);
#[cfg(target_os = "macos")]
first_menu.add_native_item(MenuItem::EnterFullScreen);
#[cfg(target_os = "macos")]
first_menu.add_native_item(MenuItem::Minimize);
#[cfg(target_os = "macos")]
first_menu.add_native_item(MenuItem::Separator);
#[cfg(target_os = "macos")]
first_menu.add_native_item(MenuItem::Copy);
#[cfg(target_os = "macos")]
first_menu.add_native_item(MenuItem::Cut);
#[cfg(target_os = "macos")]
first_menu.add_native_item(MenuItem::Paste);
#[cfg(target_os = "macos")]
first_menu.add_native_item(MenuItem::Undo);
#[cfg(target_os = "macos")]
first_menu.add_native_item(MenuItem::Redo);
#[cfg(target_os = "macos")]
first_menu.add_native_item(MenuItem::SelectAll);
#[cfg(target_os = "macos")]
first_menu.add_native_item(MenuItem::Separator);
#[cfg(target_os = "macos")]
let close_item = first_menu.add_item(
MenuItemAttributes::new("CloseWindow")
.with_accelerators(&Accelerator::new(SysMods::Cmd, KeyCode::KeyW)),
);
#[cfg(target_os = "macos")]
first_menu.add_native_item(MenuItem::Quit);
#[cfg(target_os = "macos")]
menu_bar_menu.add_submenu("App", true, first_menu);
#[cfg(target_os = "linux")]
let WindowConfig {
url,
width,
height,
resizable,
fullscreen,
..
} = get_windows_config().unwrap_or(WindowConfig::default());
#[cfg(target_os = "windows")]
let WindowConfig {
url,
width,
height,
resizable,
fullscreen,
..
} = get_windows_config().unwrap_or(WindowConfig::default());
#[cfg(target_os = "macos")]
let WindowConfig {
url,
width,
@@ -58,13 +121,26 @@ fn main() -> wry::Result<()> {
None
})
.with_inner_size(wry::application::dpi::LogicalSize::new(width, height));
#[cfg(target_os = "windows")]
let icon_path = concat!(env!("CARGO_MANIFEST_DIR"), "/png/weread_32.ico");
#[cfg(target_os = "windows")]
let icon = load_icon(std::path::Path::new(icon_path));
#[cfg(target_os = "windows")]
let window = common_window
.with_decorations(false)
.with_decorations(true)
.with_title("")
.with_window_icon(Some(icon))
.build(&event_loop)
.unwrap();
#[cfg(target_os = "linux")]
let window = common_window
.with_title("")
.build(&event_loop)
.unwrap();
#[cfg(target_os = "macos")]
let window = common_window
.with_fullsize_content_view(true)
@@ -89,7 +165,16 @@ fn main() -> wry::Result<()> {
webbrowser::open(&href).expect("no browser");
}
};
#[cfg(target_os = "windows")]
let webview = WebViewBuilder::new(window)?
.with_url(&url.to_string())?
.with_devtools(cfg!(feature = "devtools"))
.with_initialization_script(include_str!("pake.js"))
.with_ipc_handler(handler)
.build()?;
#[cfg(target_os = "linux")]
let webview = WebViewBuilder::new(window)?
.with_url(&url.to_string())?
.with_devtools(cfg!(feature = "devtools"))
@@ -97,6 +182,14 @@ fn main() -> wry::Result<()> {
.with_ipc_handler(handler)
.build()?;
#[cfg(target_os = "macos")]
let webview = WebViewBuilder::new(window)?
.with_url(&url.to_string())?
.with_devtools(cfg!(feature = "devtools"))
.with_initialization_script(include_str!("pake-mac.js"))
.with_ipc_handler(handler)
.build()?;
#[cfg(feature = "devtools")] {
webview.open_devtools();
}
@@ -115,10 +208,12 @@ fn main() -> wry::Result<()> {
origin: MenuType::MenuBar,
..
} => {
#[cfg(target_os = "macos")]
if menu_id == close_item.clone().id() {
webview.window().set_minimized(true);
}
println!("Clicked on {:?}", menu_id);
println!("Clicked on {:?}", webview.window().is_visible());
}
_ => (),
}
@@ -131,3 +226,17 @@ fn get_windows_config() -> Option<WindowConfig> {
config.tauri.windows.iter().next().cloned()
}
#[cfg(target_os = "windows")]
fn load_icon(path: &std::path::Path) -> Icon {
let (icon_rgba, icon_width, icon_height) = {
// alternatively, you can embed the icon in the binary through `include_bytes!` macro and use `image::load_from_memory`
let image = image::open(path)
.expect("Failed to open icon path")
.into_rgba8();
let (width, height) = image.dimensions();
let rgba = image.into_raw();
(rgba, width, height)
};
Icon::from_rgba(icon_rgba, icon_width, icon_height).expect("Failed to open icon")
}

175
src-tauri/src/pake-mac.js Normal file
View File

@@ -0,0 +1,175 @@
/**
* @typedef {string} KeyboardKey `event.key` 的代号,
* 见 <https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/key/Key_Values>
* @typedef {() => void} OnKeyDown 使用者按下 ⌘ [KeyboardKey] 时应该执行的行为
* 以 Meta 键 (⌘) 为首的快捷键清单。
* 每个写在这里的 shortcuts 都会运行 {@link Event.preventDefault}.
* @type {Record<KeyboardKey, OnKeyDown>}
*/
const metaKeyShortcuts = {
'ArrowUp': () => scrollTo(0, 0),
'ArrowDown': () => scrollTo(0, document.body.scrollHeight),
'[': () => window.history.back(),
']': () => window.history.forward(),
'r': () => window.location.reload(),
'-': () => zoomOut(),
'=': () => zoomIn(),
'0': () => zoomCommon(() => '100%'),
}
window.addEventListener('DOMContentLoaded', (_event) => {
const style = document.createElement('style');
style.innerHTML = `
#page #footer-wrapper,
.drawing-board .toolbar .toolbar-action,
.c-swiper-container,
.download_entry,
.lang, .copyright,
.wwads-cn, .adsbygoogle,
#Bottom > div.content > div.inner,
#Rightbar .sep20:nth-of-type(5),
#Rightbar > div.box:nth-child(4),
#Main > div.box:nth-child(8) > div
#Wrapper > div.sep20,
#Main > div.box:nth-child(8),
#masthead-ad,
#Rightbar > div:nth-child(6) > div.sidebar_compliance {
display: none !important;
}
#page .main_header {
padding-top: 20px;
}
.panel.give_me .nav_view {
top: 154px !important;
}
.columns .column #header{
padding-top: 30px;
}
ytd-masthead>#container.style-scope.ytd-masthead {
padding-top: 12px !important;
}
.wrap.h1body-exist.max-container > div.menu-tocs > div.menu-btn{
top: 28px;
}
#Wrapper{
background-color: #F8F8F8 !important;
background-image:none !important;
}
#Top {
border-bottom: none;
}
.container-with-note #home, .container-with-note #switcher{
top: 30px;
}
.geist-page nav.dashboard_nav__PRmJv {
padding-top:10px;
}
.geist-page .submenu button{
margin-top:24px;
}
#pack-top-dom:active {
cursor: grabbing;
cursor: -webkit-grabbing;
}
#pack-top-dom{
position:fixed;
background:transparent;
top:0;
width: 100%;
height: 20px;
cursor: grab;
cursor: -webkit-grab;
z-index: 90000;
}
`;
document.head.append(style);
const topDom = document.createElement('div');
topDom.id = 'pack-top-dom';
document.body.appendChild(topDom);
const domEl = document.getElementById('pack-top-dom');
domEl.addEventListener('mousedown', (e) => {
if (e.buttons === 1 && e.detail !== 2) {
window.ipc.postMessage('drag_window');
}
});
domEl.addEventListener('touchstart', () => {
window.ipc.postMessage('drag_window');
});
domEl.addEventListener('dblclick', () => {
window.ipc.postMessage('fullscreen');
});
document.addEventListener('keyup', function (event) {
const preventDefault = (f) => {
event.preventDefault();
f();
};
if (event.metaKey && event.key in metaKeyShortcuts) {
preventDefault(metaKeyShortcuts[event.key]);
}
});
document.addEventListener('click', (e) => {
const origin = e.target.closest('a');
if (origin && origin.href) {
origin.target = '_self';
//额外处理下 twitter 的外跳,对于其他需要外跳的可以改这里成对应域名
const href = origin.href;
if(location.host === "twitter.com" && href.indexOf("twitter.com")===-1){
e.preventDefault();
window.ipc.postMessage(`open_browser:${href}`);
}
}
});
});
setDefaultZoom();
function setDefaultZoom() {
const htmlZoom = window.localStorage.getItem('htmlZoom');
if (htmlZoom) {
document.getElementsByTagName('html')[0].style.zoom = htmlZoom;
}
}
/**
* @param {(htmlZoom: string) => string} [zoomRule]
*/
function zoomCommon(zoomRule) {
const htmlZoom = window.localStorage.getItem('htmlZoom') || '100%';
const html = document.getElementsByTagName('html')[0];
const zoom = zoomRule(htmlZoom);
html.style.zoom = zoom;
window.localStorage.setItem('htmlZoom', zoom);
}
function zoomIn() {
zoomCommon((htmlZoom) =>
`${Math.min(parseInt(htmlZoom) + 10, 200)}%`
);
}
function zoomOut() {
zoomCommon((htmlZoom) =>
`${Math.max(parseInt(htmlZoom) - 10, 30)}%`
);
}

View File

@@ -1,19 +1,20 @@
/**
* @typedef {string} KeyboardKey `event.key` 的代号,
* 见 <https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/key/Key_Values>
* @typedef {() => void} OnKeyDown 使用者按下 ⌘ [KeyboardKey] 时应该执行的行为
* 以 Meta 键 (⌘) 为首的快捷键清单。
* @typedef {() => void} OnKeyDown 使用者按下 [CtrlKey] 时应该执行的行为
* 以 Ctrl 键 为首的快捷键清单。
* 每个写在这里的 shortcuts 都会运行 {@link Event.preventDefault}.
* @type {Record<KeyboardKey, OnKeyDown>}
*/
const metaKeyShortcuts = {
const ctrlKeyShortcuts = {
'ArrowUp': () => scrollTo(0, 0),
'ArrowDown': () => scrollTo(0, document.body.scrollHeight),
'[': () => window.history.back(),
']': () => window.history.forward(),
'ArrowLeft': () => window.history.back(),
'ArrowRight': () => window.history.forward(),
'r': () => window.location.reload(),
'-': () => zoomOut(),
'=': () => zoomIn(),
'+': () => zoomIn(),
'0': () => zoomCommon(() => '100%'),
}
@@ -121,8 +122,8 @@ window.addEventListener('DOMContentLoaded', (_event) => {
f();
};
if (event.metaKey && event.key in metaKeyShortcuts) {
preventDefault(metaKeyShortcuts[event.key]);
if (event.ctrlKey && event.key in ctrlKeyShortcuts) {
preventDefault(ctrlKeyShortcuts[event.key]);
}
});

View File

@@ -1,6 +1,6 @@
{
"package": {
"productName": "WeRead",
"productName": "weread",
"version": "0.2.0"
},
"tauri": {
@@ -19,15 +19,29 @@
},
"bundle": {
"icon": [
"icons/weRead.icns",
"icons/icon.ico"
"icons/weread.icns",
"png/weread_256.ico",
"png/weread_32.ico",
"png/weread_512.png"
],
"identifier": "com.tw93.weRead",
"identifier": "com.tw93.weread",
"active": true,
"category": "DeveloperTool",
"copyright": "",
"deb": {
"depends": []
"depends": [
"libwebkit2gtk-4.0-dev",
"build-essential",
"curl",
"wget",
"libssl-dev",
"libgtk-3-dev",
"libayatana-appindicator3-dev",
"librsvg2-dev"
],
"files": {
"/usr/share/applications/com-tw93-weread.desktop": "assets/com-tw93-weread.desktop"
}
},
"externalBin": [],
"longDescription": "",
@@ -40,11 +54,14 @@
},
"resources": [],
"shortDescription": "",
"targets": "all",
"targets": ["deb", "msi", "dmg"],
"windows": {
"certificateThumbprint": null,
"digestAlgorithm": "sha256",
"timestampUrl": ""
"timestampUrl": "",
"wix": {
"language": ["en-US", "zh-CN"]
}
}
},
"security": {