diff --git a/bin/README.md b/bin/README.md index f97b018..1da7520 100644 --- a/bin/README.md +++ b/bin/README.md @@ -245,8 +245,17 @@ Enable recursive copying. When the URL is a local file path, enabling this optio Using `inject`, you can inject local absolute and relative path `css` and `js` files into the page you specify the `url` to customize it. For example, an adblock script that can be applied to any web page, or a `css` that optimizes the `UI` of a page, you can write it once to customize it. would only need to write the `app` once to generalize it to any other page. +Supports both comma-separated and multiple option formats: + ```shell +# Comma-separated (recommended) --inject ./tools/style.css,./tools/hotkey.js + +# Multiple options +--inject ./tools/style.css --inject ./tools/hotkey.js + +# Single file +--inject ./tools/style.css ``` #### [proxy-url] diff --git a/bin/README_CN.md b/bin/README_CN.md index 517e87a..a8b9ed2 100644 --- a/bin/README_CN.md +++ b/bin/README_CN.md @@ -245,14 +245,19 @@ pake [url] [options] #### [inject] -使用 `inject` 可以通过本地的绝对、相对路径的 `css` `js` 文件注入到你所指定 `url` 的页面中,从而为 +使用 `inject` 可以通过本地的绝对、相对路径的 `css` `js` 文件注入到你所指定 `url` 的页面中,从而为其做定制化改造。举个例子:一段可以通用到任何网页的广告屏蔽脚本,或者是优化页面 `UI` 展示的 `css`,你只需要书写一次可以将其通用到任何其他网页打包的 `app`。 -其做定制化改造。举个例子:一段可以通用到任何网页的广告屏蔽脚本,或者是优化页面 `UI` 展的 `css`,你 - -只需要书写一次可以将其通用到任何其他网页打包的 `app`。 +支持逗号分隔和多个选项两种格式: ```shell +# 逗号分隔(推荐) +--inject ./tools/style.css,./tools/hotkey.js + +# 多个选项 --inject ./tools/style.css --inject ./tools/hotkey.js + +# 单个文件 +--inject ./tools/style.css ``` #### [proxy-url] diff --git a/bin/cli.ts b/bin/cli.ts index cc42da2..07b1421 100644 --- a/bin/cli.ts +++ b/bin/cli.ts @@ -42,7 +42,17 @@ program .option( '--inject <./style.css,./script.js,...>', 'Injection of .js or .css files', - (val, previous) => (val ? val.split(',').map(item => item.trim()) : DEFAULT.inject), + (val, previous) => { + if (!val) return DEFAULT.inject; + + // Split by comma and trim whitespace, filter out empty strings + const files = val.split(',') + .map(item => item.trim()) + .filter(item => item.length > 0); + + // If previous values exist (from multiple --inject options), merge them + return previous ? [...previous, ...files] : files; + }, DEFAULT.inject, ) .option('--debug', 'Debug build and more output', DEFAULT.debug) diff --git a/dist/cli.js b/dist/cli.js index 22d8487..29bd246 100644 --- a/dist/cli.js +++ b/dist/cli.js @@ -135,7 +135,7 @@ var windows = [ dark_mode: false, activation_shortcut: "", disabled_web_shortcuts: false, - hide_on_close: false + hide_on_close: true } ]; var user_agent = { @@ -785,6 +785,7 @@ const DEFAULT_PAKE_OPTIONS = { height: 780, width: 1200, fullscreen: false, + resizable: true, hideTitleBar: false, alwaysOnTop: false, appVersion: '1.0.0', @@ -992,7 +993,16 @@ program .option('--fullscreen', 'Start in full screen', DEFAULT_PAKE_OPTIONS.fullscreen) .option('--hide-title-bar', 'For Mac, hide title bar', DEFAULT_PAKE_OPTIONS.hideTitleBar) .option('--multi-arch', 'For Mac, both Intel and M1', DEFAULT_PAKE_OPTIONS.multiArch) - .option('--inject ', 'Injection of .js or .css files', DEFAULT_PAKE_OPTIONS.inject) + .option('--inject <./style.css,./script.js,...>', 'Injection of .js or .css files', (val, previous) => { + if (!val) + return DEFAULT_PAKE_OPTIONS.inject; + // Split by comma and trim whitespace, filter out empty strings + const files = val.split(',') + .map(item => item.trim()) + .filter(item => item.length > 0); + // If previous values exist (from multiple --inject options), merge them + return previous ? [...previous, ...files] : files; +}, DEFAULT_PAKE_OPTIONS.inject) .option('--debug', 'Debug build and more output', DEFAULT_PAKE_OPTIONS.debug) .addOption(new Option('--proxy-url ', 'Proxy URL for all network requests').default(DEFAULT_PAKE_OPTIONS.proxyUrl).hideHelp()) .addOption(new Option('--user-agent ', 'Custom user agent').default(DEFAULT_PAKE_OPTIONS.userAgent).hideHelp())