Merge remote-tracking branch 'origin/master' into dev

This commit is contained in:
jeasonnow
2023-07-27 09:43:53 +08:00
15 changed files with 285 additions and 203 deletions

View File

@@ -8,9 +8,9 @@ on:
default: "macos-latest" default: "macos-latest"
type: choice type: choice
options: options:
- "windows-latest" - "windows-latest"
- "macos-latest" - "macos-latest"
- "ubuntu-20.04" - "ubuntu-20.04"
url: url:
description: "[URL]" description: "[URL]"
required: true required: true
@@ -44,9 +44,9 @@ on:
default: "deb" default: "deb"
type: choice type: choice
options: options:
- "deb" - "deb"
- "appimage" - "appimage"
- "all" - "all"
jobs: jobs:
@@ -57,71 +57,91 @@ jobs:
fail-fast: false fail-fast: false
steps: steps:
- name: Checkout repository - name: Checkout repository
uses: actions/checkout@v3 uses: actions/checkout@v3
- name: install node - name: install node
uses: actions/setup-node@v3 uses: actions/setup-node@v3
with: with:
node-version: 18 node-version: 18
- name: Install Rust for ubuntu-20.04 - name: Install Rust for ubuntu-20.04
if: inputs.platform == 'ubuntu-20.04' if: inputs.platform == 'ubuntu-20.04'
uses: dtolnay/rust-toolchain@stable uses: dtolnay/rust-toolchain@stable
with: with:
toolchain: stable toolchain: stable
target: x86_64-unknown-linux-musl target: x86_64-unknown-linux-musl
- name: Install Rust for windows-latest - name: Install Rust for windows-latest
if: inputs.platform == 'windows-latest' if: inputs.platform == 'windows-latest'
uses: dtolnay/rust-toolchain@stable uses: dtolnay/rust-toolchain@stable
with: with:
toolchain: stable-x86_64-msvc toolchain: stable-x86_64-msvc
target: x86_64-pc-windows-msvc target: x86_64-pc-windows-msvc
- name: Install Rust for macos-latest - name: Install Rust for macos-latest
if: inputs.platform == 'macos-latest' if: inputs.platform == 'macos-latest'
uses: dtolnay/rust-toolchain@stable uses: dtolnay/rust-toolchain@stable
with: with:
toolchain: stable toolchain: stable
target: x86_64-apple-darwin target: x86_64-apple-darwin
- name: install dependencies (ubuntu only) - name: install dependencies (ubuntu only)
if: inputs.platform == 'ubuntu-20.04' if: inputs.platform == 'ubuntu-20.04'
uses: awalsh128/cache-apt-pkgs-action@latest uses: awalsh128/cache-apt-pkgs-action@latest
with: with:
packages: libwebkit2gtk-4.0-dev build-essential curl wget libssl-dev libgtk-3-dev libayatana-appindicator3-dev librsvg2-dev gnome-video-effects gnome-video-effects-extra packages: libwebkit2gtk-4.0-dev build-essential curl wget libssl-dev libgtk-3-dev libayatana-appindicator3-dev librsvg2-dev gnome-video-effects gnome-video-effects-extra
version: 1.1 version: 1.1
- name: install pake-cli local - name: install pake-cli local
shell: bash shell: bash
run: | run: |
echo "install pake on local" echo "install pake on local"
npm install pake-cli npm install pake-cli
- name: rust cache - name: rust cache restore
uses: Swatinem/rust-cache@v2 uses: actions/cache/restore@v3
id: cache_store
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
node_modules/pake-cli/src-tauri/target/
key: ${{ inputs.platform }}-cargo-${{ hashFiles('node_modules/pake-cli/src-tauri/Cargo.lock') }}
- name: build with pake-cli - name: build with pake-cli
shell: pwsh shell: pwsh
run: | run: |
pwsh ./script/build_with_pake_cli.ps1 pwsh ./script/build_with_pake_cli.ps1
env: env:
URL: ${{ inputs.url }} URL: ${{ inputs.url }}
NAME: ${{ inputs.name }} NAME: ${{ inputs.name }}
ICON: ${{ inputs.icon }} ICON: ${{ inputs.icon }}
HEIGHT: ${{ inputs.height }} HEIGHT: ${{ inputs.height }}
WIDTH: ${{ inputs.width }} WIDTH: ${{ inputs.width }}
TRANSPARENT: ${{ inputs.transparent }} TRANSPARENT: ${{ inputs.transparent }}
FULLSCREEN: ${{ inputs.fullscreen }} FULLSCREEN: ${{ inputs.fullscreen }}
RESIZE: ${{ inputs.resize }} RESIZE: ${{ inputs.resize }}
MULTI_ARCH: ${{ inputs.multi_arch }} MULTI_ARCH: ${{ inputs.multi_arch }}
TARGETS: ${{ inputs.targets }} TARGETS: ${{ inputs.targets }}
- name: Upload archive - name: Upload archive
uses: actions/upload-artifact@v3 uses: actions/upload-artifact@v3
with: with:
name: output-${{ inputs.platform }}.zip name: output-${{ inputs.platform }}.zip
path: node_modules/pake-cli/output/* path: node_modules/pake-cli/output/*
retention-days: 3 retention-days: 3
- name: rust cache store
uses: actions/cache/save@v3
if: steps.cache_store.outputs.cache-hit != 'true'
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
node_modules/pake-cli/src-tauri/target/
key: ${{ inputs.platform }}-cargo-${{ hashFiles('node_modules/pake-cli/src-tauri/Cargo.lock') }}

View File

@@ -13,57 +13,73 @@ jobs:
matrix: matrix:
build: [linux, windows, macos] build: [linux, windows, macos]
include: include:
- build: linux - build: linux
os: ubuntu-20.04 os: ubuntu-20.04
rust: stable rust: stable
target: x86_64-unknown-linux-musl target: x86_64-unknown-linux-musl
- build: windows - build: windows
os: windows-latest os: windows-latest
rust: stable-x86_64-msvc rust: stable-x86_64-msvc
target: x86_64-pc-windows-msvc target: x86_64-pc-windows-msvc
- build: macos - build: macos
os: macos-latest os: macos-latest
rust: stable rust: stable
target: x86_64-apple-darwin target: x86_64-apple-darwin
fail-fast: false fail-fast: false
steps: steps:
- name: Checkout repository - name: Checkout repository
uses: actions/checkout@v3 uses: actions/checkout@v3
- name: install node - name: install node
uses: actions/setup-node@v3 uses: actions/setup-node@v3
with: with:
node-version: 18 node-version: 18
- name: Install Rust - name: Install Rust
uses: dtolnay/rust-toolchain@stable uses: dtolnay/rust-toolchain@stable
with: with:
toolchain: ${{ matrix.rust }} toolchain: ${{ matrix.rust }}
target: ${{ matrix.target }} target: ${{ matrix.target }}
- name: install dependencies (ubuntu only) - name: install dependencies (ubuntu only)
if: matrix.os == 'ubuntu-20.04' if: matrix.os == 'ubuntu-20.04'
uses: awalsh128/cache-apt-pkgs-action@latest uses: awalsh128/cache-apt-pkgs-action@latest
with: with:
packages: libwebkit2gtk-4.0-dev build-essential curl wget libssl-dev libgtk-3-dev libayatana-appindicator3-dev librsvg2-dev gnome-video-effects gnome-video-effects-extra packages: libwebkit2gtk-4.0-dev build-essential curl wget libssl-dev libgtk-3-dev libayatana-appindicator3-dev librsvg2-dev gnome-video-effects gnome-video-effects-extra
version: 1.1 version: 1.1
- name: rust cache - name: rust cache restore
uses: Swatinem/rust-cache@v2 uses: actions/cache/restore@v3
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
src-tauri/target/
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
- name: build for Ubuntu - name: build for Ubuntu
if: matrix.os == 'ubuntu-20.04' if: matrix.os == 'ubuntu-20.04'
run: npm run build:all-unix run: npm run build:all-unix
- name: build for MacOS - name: build for MacOS
if: matrix.os == 'macos-latest' if: matrix.os == 'macos-latest'
run: | run: |
rustup target add aarch64-apple-darwin rustup target add aarch64-apple-darwin
npm run build:all-unix npm run build:all-unix
- name: build for windows - name: build for windows
if: matrix.os == 'windows-latest' if: matrix.os == 'windows-latest'
shell: pwsh shell: pwsh
run: | run: |
npm run build:all-windows npm run build:all-windows
- name: Upload files
# arg info: https://github.com/ncipollo/release-action#release-action
uses: ncipollo/release-action@v1
with:
allowUpdates: true
artifacts: "output/*/*.*"
token: ${{ secrets.GITHUB_TOKEN }}

View File

@@ -21,70 +21,91 @@ jobs:
matrix: matrix:
build: [linux, windows, macos] build: [linux, windows, macos]
include: include:
- build: linux - build: linux
os: ubuntu-20.04 os: ubuntu-20.04
rust: stable rust: stable
target: x86_64-unknown-linux-musl target: x86_64-unknown-linux-musl
# archive-name: target-linux.tar.gz # archive-name: target-linux.tar.gz
- build: windows - build: windows
os: windows-latest os: windows-latest
rust: stable-x86_64-msvc rust: stable-x86_64-msvc
target: x86_64-pc-windows-msvc target: x86_64-pc-windows-msvc
# archive-name: target-windows.tar.gz # archive-name: target-windows.tar.gz
- build: macos - build: macos
os: macos-latest os: macos-latest
rust: stable rust: stable
target: x86_64-apple-darwin target: x86_64-apple-darwin
# archive-name: target-macos.tar.gz # archive-name: target-macos.tar.gz
fail-fast: false fail-fast: false
steps: steps:
- name: Checkout repository - name: Checkout repository
uses: actions/checkout@v3 uses: actions/checkout@v3
- name: install node - name: install node
uses: actions/setup-node@v3 uses: actions/setup-node@v3
with: with:
node-version: 18 node-version: 18
- name: Install Rust - name: Install Rust
uses: dtolnay/rust-toolchain@stable uses: dtolnay/rust-toolchain@stable
with: with:
toolchain: ${{ matrix.rust }} toolchain: ${{ matrix.rust }}
target: ${{ matrix.target }} target: ${{ matrix.target }}
- name: install dependencies (ubuntu only) - name: install dependencies (ubuntu only)
if: matrix.os == 'ubuntu-20.04' if: matrix.os == 'ubuntu-20.04'
uses: awalsh128/cache-apt-pkgs-action@latest uses: awalsh128/cache-apt-pkgs-action@latest
with: with:
packages: libwebkit2gtk-4.0-dev build-essential curl wget libssl-dev libgtk-3-dev libayatana-appindicator3-dev librsvg2-dev gnome-video-effects gnome-video-effects-extra packages: libwebkit2gtk-4.0-dev build-essential curl wget libssl-dev libgtk-3-dev libayatana-appindicator3-dev librsvg2-dev gnome-video-effects gnome-video-effects-extra
version: 1.1 version: 1.1
- name: rust cache - name: rust cache restore
uses: Swatinem/rust-cache@v2 uses: actions/cache/restore@v3
id: cache_store
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
src-tauri/target/
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
- name: build for Ubuntu - name: build for Ubuntu
if: matrix.os == 'ubuntu-20.04' if: matrix.os == 'ubuntu-20.04'
run: npm run build:all-unix run: npm run build:all-unix
- name: build for MacOS - name: build for MacOS
if: matrix.os == 'macos-latest' if: matrix.os == 'macos-latest'
run: | run: |
rustup target add aarch64-apple-darwin rustup target add aarch64-apple-darwin
npm run build:all-unix npm run build:all-unix
- name: build for windows - name: build for windows
if: matrix.os == 'windows-latest' if: matrix.os == 'windows-latest'
shell: pwsh shell: pwsh
run: | run: |
npm run build:all-windows npm run build:all-windows
- name: Upload files - name: Upload files
# arg info: https://github.com/ncipollo/release-action#release-action # arg info: https://github.com/ncipollo/release-action#release-action
uses: ncipollo/release-action@v1 uses: ncipollo/release-action@v1
with: with:
allowUpdates: true allowUpdates: true
prerelease: ${{ inputs.is_pre_release }} prerelease: ${{ inputs.is_pre_release }}
artifacts: "output/*/*.*" artifacts: "output/*/*.*"
tag: ${{ inputs.version }} tag: ${{ inputs.version }}
token: ${{ secrets.GITHUB_TOKEN }} token: ${{ secrets.GITHUB_TOKEN }}
- name: rust cache store
uses: actions/cache/save@v3
if: steps.cache_store.outputs.cache-hit != 'true'
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
src-tauri/target/
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}

View File

@@ -107,7 +107,7 @@
</tr> </tr>
<tr> <tr>
<td><img src=https://cdn.fliggy.com/upic/i2eg6G.png width=600/></td> <td><img src=https://cdn.fliggy.com/upic/i2eg6G.png width=600/></td>
<td><img src=https://cdn.fliggy.com/upic/fS1lVi.jpg width=600/></td> <td><img src=https://cdn.fliggy.com/upic/mUzOek.jpg width=600/></td>
</tr> </tr>
<tr> <tr>
<td>Flomo <td>Flomo

View File

@@ -3,7 +3,7 @@
<img src=https://gw.alipayobjects.com/zos/k/fa/logo-modified.png width=138/> <img src=https://gw.alipayobjects.com/zos/k/fa/logo-modified.png width=138/>
</p> </p>
<h1 align="center">Pake</h1> <h1 align="center">Pake</h1>
<p align="center"><strong>很简单的用 Rust 打包网页生成很小的桌面App</strong></p> <p align="center"><strong>用 Rust 轻松构建轻量级多端桌面应用</strong></p>
<div align="center"> <div align="center">
<a href="https://twitter.com/HiTw93" target="_blank"> <a href="https://twitter.com/HiTw93" target="_blank">
<img alt="twitter" src="https://img.shields.io/badge/follow-Tw93-red?style=flat-square&logo=Twitter"></a> <img alt="twitter" src="https://img.shields.io/badge/follow-Tw93-red?style=flat-square&logo=Twitter"></a>
@@ -106,7 +106,7 @@
</tr> </tr>
<tr> <tr>
<td><img src=https://cdn.fliggy.com/upic/i2eg6G.png width=600/></td> <td><img src=https://cdn.fliggy.com/upic/i2eg6G.png width=600/></td>
<td><img src=https://cdn.fliggy.com/upic/fS1lVi.jpg width=600/></td> <td><img src=https://cdn.fliggy.com/upic/mUzOek.jpg width=600/></td>
</tr> </tr>
<tr> <tr>
<td>Flomo <td>Flomo

View File

@@ -1,7 +1,7 @@
name(Linux),name(Mac/Windows),name_zh,url name(Linux),name(Mac/Windows),name_zh,url
programmusic,ProgramMusic,ProgramMusic,https://musicforprogramming.net/ programmusic,ProgramMusic,ProgramMusic,https://musicforprogramming.net/
twitter,Twitter,推特,https://twitter.com/ twitter,Twitter,推特,https://twitter.com/
youtube,YouTube,YouTube,https://youtube.com youtube,YouTube,YouTube,https://www.youtube.com
reference,Reference,Reference,https://quickref.me/zh-CN/ reference,Reference,Reference,https://quickref.me/zh-CN/
coderunner,CodeRunner,CodeRunner,https://riju.codes/ coderunner,CodeRunner,CodeRunner,https://riju.codes/
chatgpt,ChatGPT,ChatGPT,https://chat.openai.com/chat chatgpt,ChatGPT,ChatGPT,https://chat.openai.com/chat
1 name(Linux) name(Mac/Windows) name_zh url
2 programmusic ProgramMusic ProgramMusic https://musicforprogramming.net/
3 twitter Twitter 推特 https://twitter.com/
4 youtube YouTube YouTube https://youtube.com https://www.youtube.com
5 reference Reference Reference https://quickref.me/zh-CN/
6 coderunner CodeRunner CodeRunner https://riju.codes/
7 chatgpt ChatGPT ChatGPT https://chat.openai.com/chat

3
bin/helpers/rust.ts vendored
View File

@@ -7,8 +7,9 @@ import { shellExec } from '@/utils/shell';
import { isChinaDomain } from '@/utils/ip'; import { isChinaDomain } from '@/utils/ip';
export async function installRust() { export async function installRust() {
const isActions = process.env.GITHUB_ACTIONS;
const isInChina = await isChinaDomain('sh.rustup.rs'); const isInChina = await isChinaDomain('sh.rustup.rs');
const rustInstallScriptForMac = isInChina const rustInstallScriptForMac = isInChina && !isActions
? 'export RUSTUP_DIST_SERVER="https://rsproxy.cn" && export RUSTUP_UPDATE_ROOT="https://rsproxy.cn/rustup" && curl --proto "=https" --tlsv1.2 -sSf https://rsproxy.cn/rustup-init.sh | sh' ? 'export RUSTUP_DIST_SERVER="https://rsproxy.cn" && export RUSTUP_UPDATE_ROOT="https://rsproxy.cn/rustup" && curl --proto "=https" --tlsv1.2 -sSf https://rsproxy.cn/rustup-init.sh | sh'
: "curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y"; : "curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y";
const rustInstallScriptForWindows = 'winget install --id Rustlang.Rustup'; const rustInstallScriptForWindows = 'winget install --id Rustlang.Rustup';

9
bin/options/icon.ts vendored
View File

@@ -45,7 +45,14 @@ export async function downloadIcon(iconUrl: string) {
} }
const { path: tempPath } = await dir(); const { path: tempPath } = await dir();
const iconPath = `${tempPath}/icon.${fileDetails.ext}`; let iconPath = `${tempPath}/icon.${fileDetails.ext}`;
// Fix this for linux
if (IS_LINUX) {
iconPath = 'png/linux_temp.png';
await fsExtra.outputFile(`${npmDirectory}/src-tauri/${iconPath}`, iconData);
} else {
await fsExtra.outputFile(iconPath, iconData);
}
await fsExtra.outputFile(iconPath, iconData); await fsExtra.outputFile(iconPath, iconData);
spinner.succeed(chalk.green('Icon downloaded successfully!')); spinner.succeed(chalk.green('Icon downloaded successfully!'));
return iconPath; return iconPath;

37
dist/cli.js vendored
View File

@@ -11,16 +11,16 @@ import { fileURLToPath } from 'url';
import dns from 'dns'; import dns from 'dns';
import http from 'http'; import http from 'http';
import { promisify } from 'util'; import { promisify } from 'util';
import fs from 'fs';
import updateNotifier from 'update-notifier'; import updateNotifier from 'update-notifier';
import axios from 'axios'; import axios from 'axios';
import { dir } from 'tmp-promise'; import { dir } from 'tmp-promise';
import { fileTypeFromBuffer } from 'file-type'; import { fileTypeFromBuffer } from 'file-type';
import psl from 'psl'; import psl from 'psl';
import isUrl from 'is-url'; import isUrl from 'is-url';
import fs from 'fs';
var name = "pake-cli"; var name = "pake-cli";
var version = "2.2.0"; var version = "2.2.5";
var description = "🤱🏻 Turn any webpage into a desktop app with Rust. 🤱🏻 很简单的用 Rust 打包网页生成很小的桌面 App。"; var description = "🤱🏻 Turn any webpage into a desktop app with Rust. 🤱🏻 很简单的用 Rust 打包网页生成很小的桌面 App。";
var engines = { var engines = {
node: ">=16.0.0" node: ">=16.0.0"
@@ -53,14 +53,12 @@ var scripts = {
start: "npm run dev", start: "npm run dev",
dev: "npm run tauri dev", dev: "npm run tauri dev",
build: "npm run tauri build --release", build: "npm run tauri build --release",
"build:debug": "npm run tauri build -- --debug",
"build:mac": "npm run tauri build -- --target universal-apple-darwin", "build:mac": "npm run tauri build -- --target universal-apple-darwin",
"build:all-unix": "chmod +x ./script/build.sh && ./script/build.sh", "build:all-unix": "chmod +x ./script/build.sh && ./script/build.sh",
"build:all-windows": "pwsh ./script/build.ps1", "build:all-windows": "pwsh ./script/build.ps1",
analyze: "cd src-tauri && cargo bloat --release --crates", analyze: "cd src-tauri && cargo bloat --release --crates",
tauri: "tauri", tauri: "tauri",
cli: "rollup -c rollup.config.js --watch", cli: "rollup -c rollup.config.js --watch",
"cli:dev": "cross-env NODE_ENV=development rollup -c rollup.config.js -w",
"cli:build": "cross-env NODE_ENV=production rollup -c rollup.config.js", "cli:build": "cross-env NODE_ENV=production rollup -c rollup.config.js",
prepublishOnly: "npm run cli:build" prepublishOnly: "npm run cli:build"
}; };
@@ -88,7 +86,6 @@ var devDependencies = {
"@rollup/plugin-alias": "^4.0.2", "@rollup/plugin-alias": "^4.0.2",
"@rollup/plugin-commonjs": "^23.0.2", "@rollup/plugin-commonjs": "^23.0.2",
"@rollup/plugin-json": "^5.0.2", "@rollup/plugin-json": "^5.0.2",
"@rollup/plugin-replace": "^5.0.2",
"@rollup/plugin-terser": "^0.1.0", "@rollup/plugin-terser": "^0.1.0",
"@types/fs-extra": "^9.0.13", "@types/fs-extra": "^9.0.13",
"@types/is-url": "^1.2.30", "@types/is-url": "^1.2.30",
@@ -126,7 +123,7 @@ var packageJson = {
var windows = [ var windows = [
{ {
url: "https://weread.qq.com/", url: "https://weread.qq.com/",
transparent: false, transparent: true,
fullscreen: false, fullscreen: false,
width: 1200, width: 1200,
height: 780, height: 780,
@@ -140,7 +137,7 @@ var user_agent = {
windows: "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/108.0.0.0 Safari/537.36" windows: "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/108.0.0.0 Safari/537.36"
}; };
var menu = { var menu = {
macos: false, macos: true,
linux: false, linux: false,
windows: false windows: false
}; };
@@ -149,14 +146,11 @@ var system_tray = {
linux: true, linux: true,
windows: true windows: true
}; };
var inject = [
];
var pakeConf = { var pakeConf = {
windows: windows, windows: windows,
user_agent: user_agent, user_agent: user_agent,
menu: menu, menu: menu,
system_tray: system_tray, system_tray: system_tray
inject: inject
}; };
var tauri$3 = { var tauri$3 = {
@@ -176,7 +170,7 @@ var tauri$3 = {
active: false active: false
}, },
systemTray: { systemTray: {
iconPath: "png/icon_512.png", iconPath: "png/weread_512.png",
iconAsTemplate: true iconAsTemplate: true
}, },
allowlist: { allowlist: {
@@ -197,11 +191,11 @@ var build = {
beforeDevCommand: "" beforeDevCommand: ""
}; };
var CommonConf = { var CommonConf = {
tauri: tauri$3,
"package": { "package": {
productName: "WeRead", productName: "WeRead",
version: "1.0.0" version: "1.0.0"
}, },
tauri: tauri$3,
build: build build: build
}; };
@@ -245,9 +239,9 @@ var WinConf = {
var tauri$1 = { var tauri$1 = {
bundle: { bundle: {
icon: [ icon: [
"icons/icon.icns" "icons/weread.icns"
], ],
identifier: "com.pake.5b8ae9", identifier: "com.pake.weread",
active: true, active: true,
category: "DeveloperTool", category: "DeveloperTool",
copyright: "", copyright: "",
@@ -443,8 +437,9 @@ async function isChinaIP(ip, domain) {
} }
async function installRust() { async function installRust() {
const isActions = process.env.GITHUB_ACTIONS;
const isInChina = await isChinaDomain('sh.rustup.rs'); const isInChina = await isChinaDomain('sh.rustup.rs');
const rustInstallScriptForMac = isInChina const rustInstallScriptForMac = isInChina && !isActions
? 'export RUSTUP_DIST_SERVER="https://rsproxy.cn" && export RUSTUP_UPDATE_ROOT="https://rsproxy.cn/rustup" && curl --proto "=https" --tlsv1.2 -sSf https://rsproxy.cn/rustup-init.sh | sh' ? 'export RUSTUP_DIST_SERVER="https://rsproxy.cn" && export RUSTUP_UPDATE_ROOT="https://rsproxy.cn/rustup" && curl --proto "=https" --tlsv1.2 -sSf https://rsproxy.cn/rustup-init.sh | sh'
: "curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y"; : "curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y";
const rustInstallScriptForWindows = 'winget install --id Rustlang.Rustup'; const rustInstallScriptForWindows = 'winget install --id Rustlang.Rustup';
@@ -876,7 +871,15 @@ async function downloadIcon(iconUrl) {
return null; return null;
} }
const { path: tempPath } = await dir(); const { path: tempPath } = await dir();
const iconPath = `${tempPath}/icon.${fileDetails.ext}`; let iconPath = `${tempPath}/icon.${fileDetails.ext}`;
// Fix this for linux
if (IS_LINUX) {
iconPath = 'png/linux_temp.png';
await fsExtra.outputFile(`${npmDirectory}/src-tauri/${iconPath}`, iconData);
}
else {
await fsExtra.outputFile(iconPath, iconData);
}
await fsExtra.outputFile(iconPath, iconData); await fsExtra.outputFile(iconPath, iconData);
spinner.succeed(chalk.green('Icon downloaded successfully!')); spinner.succeed(chalk.green('Icon downloaded successfully!'));
return iconPath; return iconPath;

View File

@@ -1,7 +1,7 @@
{ {
"name": "pake-cli", "name": "pake-cli",
"version": "2.2.0", "version": "2.2.5",
"description": "🤱🏻 Turn any webpage into a desktop app with Rust. 🤱🏻 很简单的用 Rust 打包网页生成很小的桌面 App。", "description": "🤱🏻 Turn any webpage into a desktop app with Rust. 🤱🏻 用 Rust 轻松构建轻量级多端桌面应用。",
"engines": { "engines": {
"node": ">=16.0.0" "node": ">=16.0.0"
}, },

4
script/build.ps1 vendored
View File

@@ -39,6 +39,7 @@ $total = $total - 1
# for windows, we need replace package name to title # for windows, we need replace package name to title
ForEach ($line in (Get-Content -Path .\app.csv | Select-Object -Skip 1)) { ForEach ($line in (Get-Content -Path .\app.csv | Select-Object -Skip 1)) {
$name, $title, $name_zh, $url = $line.Split(",") $name, $title, $name_zh, $url = $line.Split(",")
$domain = ([Uri]$url).Host
Write-Host "building package ${index}/${total}" Write-Host "building package ${index}/${total}"
Write-Host "package name is ${name} ${name_zh}" Write-Host "package name is ${name} ${name_zh}"
Write-Host "==========================" Write-Host "=========================="
@@ -54,6 +55,9 @@ ForEach ($line in (Get-Content -Path .\app.csv | Select-Object -Skip 1)) {
# replace url with no regex # replace url with no regex
(Get-Content -Path $pake_conf_path -Raw) | ForEach-Object { $_.Replace('"url": ""', "`"url`": `"${url}`"") } | Set-Content $pake_conf_path (Get-Content -Path $pake_conf_path -Raw) | ForEach-Object { $_.Replace('"url": ""', "`"url`": `"${url}`"") } | Set-Content $pake_conf_path
# -- replace domain -- #
(Get-Content -Path $common_conf_path -Raw) -replace '"domain":\s*"[^"]*"', '"domain": ""' | Set-Content -Path $common_conf_path
(Get-Content -Path $common_conf_path -Raw) | ForEach-Object { $_.Replace('"domain": ""', "`"domain`": `"${domain}`"") } | Set-Content $common_conf_path
# -- replace package name -- # # -- replace package name -- #
# clear package_name with regex # clear package_name with regex

8
script/build.sh vendored
View File

@@ -59,6 +59,8 @@ do
package_title=${arr[1]} package_title=${arr[1]}
package_zh_name=${arr[2]} package_zh_name=${arr[2]}
url=${arr[3]} url=${arr[3]}
domain=${url//http*:\/\//}
domain=${domain%%/*}
# replace package info # replace package info
# clear url with regex # clear url with regex
@@ -66,6 +68,10 @@ do
# replace url with no regex # replace url with no regex
$sd -s "\"url\": \"\"," "\"url\": \"${url}\"," src-tauri/pake.json $sd -s "\"url\": \"\"," "\"url\": \"${url}\"," src-tauri/pake.json
# replace dangerousRemoteDomainIpcAccess domain
$sd "\"domain\": \"(.*?)\"," "\"domain\": \"\"," src-tauri/tauri.conf.json
$sd -s "\"domain\": \"\"," "\"domain\": \"${domain}\"," src-tauri/tauri.conf.json
# for apple, need replace title # for apple, need replace title
if [[ "$OSTYPE" =~ ^darwin ]]; then if [[ "$OSTYPE" =~ ^darwin ]]; then
# update icon # update icon
@@ -145,7 +151,7 @@ do
$sd "Icon=.*" "Icon=" "${new_desktop}" $sd "Icon=.*" "Icon=" "${new_desktop}"
$sd "Name=.*" "Name=" "${new_desktop}" $sd "Name=.*" "Name=" "${new_desktop}"
$sd "Name\[zh_CN\]=.*" "Name[zh_CN]=" "${new_desktop}" $sd "Name\[zh_CN\]=.*" "Name[zh_CN]=" "${new_desktop}"
# repleace dekstop content with no reg # replace desktop content with no reg
$sd -s "Exec=" "Exec=${package_prefix}-${package_name}" "${new_desktop}" $sd -s "Exec=" "Exec=${package_prefix}-${package_name}" "${new_desktop}"
$sd -s "Icon=" "Icon=${package_prefix}-${package_name}" "${new_desktop}" $sd -s "Icon=" "Icon=${package_prefix}-${package_name}" "${new_desktop}"
$sd -s "Name=" "Name=${package_title}" "${new_desktop}" $sd -s "Name=" "Name=${package_title}" "${new_desktop}"

View File

@@ -1,9 +1,8 @@
use std::fs; use crate::util::{check_file_or_append, get_download_message, show_toast, MessageType};
use crate::util::{check_file_or_append, get_download_message, MessageType, show_toast};
use tauri::{api, command, AppHandle, Manager, Window};
use tauri::api::http::{ClientBuilder, HttpRequestBuilder, ResponseType};
use std::fs::File; use std::fs::File;
use std::io::Write; use std::io::Write;
use tauri::api::http::{ClientBuilder, HttpRequestBuilder, ResponseType};
use tauri::{api, command, AppHandle, Manager, Window};
#[derive(serde::Deserialize)] #[derive(serde::Deserialize)]
pub struct DownloadFileParams { pub struct DownloadFileParams {
@@ -26,11 +25,13 @@ pub async fn download_file(app: AppHandle, params: DownloadFileParams) -> Result
let file_path = check_file_or_append(output_path.to_str().unwrap()); let file_path = check_file_or_append(output_path.to_str().unwrap());
let client = ClientBuilder::new().build().unwrap(); let client = ClientBuilder::new().build().unwrap();
let response = client.send( let response = client
HttpRequestBuilder::new("GET", &params.url) .send(
.unwrap() HttpRequestBuilder::new("GET", &params.url)
.response_type(ResponseType::Binary) .unwrap()
).await; .response_type(ResponseType::Binary),
)
.await;
match response { match response {
Ok(res) => { Ok(res) => {

View File

@@ -180,6 +180,11 @@ window.addEventListener('DOMContentLoaded', _event => {
visibility: hidden !important; visibility: hidden !important;
} }
#__next > div.overflow-hidden.w-full.h-full .absolute.bottom-0.left-0.w-full > div.text-center.text-xs {
visibility: hidden !important;
height: 0px !important;
}
#react-root [data-testid="primaryColumn"] > div > div { #react-root [data-testid="primaryColumn"] > div > div {
position: relative !important; position: relative !important;
} }

View File

@@ -8,9 +8,7 @@
"copyright": "", "copyright": "",
"deb": { "deb": {
"depends": ["curl", "wget"], "depends": ["curl", "wget"],
"files": { "files": {"/usr/share/applications/com-pake-weread.desktop": "assets/com-pake-weread.desktop"}
"/usr/share/applications/com-pake-weread.desktop": "assets/com-pake-weread.desktop"
}
}, },
"externalBin": [], "externalBin": [],
"longDescription": "", "longDescription": "",