diff --git a/README.md b/README.md index d5a3563..3eef09a 100644 --- a/README.md +++ b/README.md @@ -171,9 +171,6 @@ npm i # Local development npm run dev -# Local debug -npm run dev:debug - # Pack application npm run build ``` @@ -183,7 +180,7 @@ npm run build 1. You can refer to the [codebase structure](https://github.com/tw93/Pake/wiki/Description-of-Pake's-code-structure) before working on Pake, which will help you much in development. 2. Modify the `url` and `productName` fields in the `tauri.conf.json` file under the src-tauri directory, as well as the `icon` and `identifier` fields in the `tauri.xxx.conf.json` file. You can select a `icon` from the `icons` directory or download one from [macOSicons](https://macosicons.com/#/) to match your product needs. 3. For configurations on window properties, you can modify the `tauri.conf.json` file to change the value of `width`, `height`, `fullscreen` (or not), `resizable` (or not) of the `windows` property. To adapt to the immersive header on Mac, change `transparent` to `true`, look for the `Header` element, and add the `padding-top` property. -4. For advanced usages such as style rewriting, advertisement removal, JS injection, container message communication, and user-defined shortcut keys, see [Advanced Usage of Make](https://github.com/tw93/Pake/wiki/Advanced-Usage-of-Make). +4. For advanced usages such as style rewriting, advertisement removal, JS injection, container message communication, and user-defined shortcut keys, see [Advanced Usage of Make](https://github.com/tw93/Pake/wiki/Advanced-Usage-of-Pake). ## Developer diff --git a/README_CN.md b/README_CN.md index 39e5b64..cb78582 100644 --- a/README_CN.md +++ b/README_CN.md @@ -172,9 +172,6 @@ npm i # 本地开发 npm run dev -# 本地调试 -npm run dev:debug - # 打包应用 npm run build diff --git a/package.json b/package.json index 2c5e7c7..f8cce53 100644 --- a/package.json +++ b/package.json @@ -32,7 +32,6 @@ "scripts": { "start": "npm run dev", "dev": "npm run tauri dev", - "dev:debug": "npm run tauri dev -- --features devtools", "build": "npm run tauri build --release", "build:mac": "npm run tauri build -- --target universal-apple-darwin", "build:all-unix": "chmod +x ./script/build.sh && ./script/build.sh", diff --git a/src-tauri/Cargo.toml b/src-tauri/Cargo.toml index b40edcc..cfc3c7b 100644 --- a/src-tauri/Cargo.toml +++ b/src-tauri/Cargo.toml @@ -17,7 +17,7 @@ tauri-build = { version = "1.2.1", features = [] } [dependencies] serde_json = "1.0.89" serde = { version = "1.0.150", features = ["derive"] } -tauri = { version = "1.2.1", features = ["api-all", "devtools", "system-tray"] } +tauri = { version = "1.2.4", features = ["api-all", "system-tray"] } image = "0.24.5" home = "0.5" dirs = "5.0" diff --git a/src-tauri/src/inject/style.js b/src-tauri/src/inject/style.js index 25470b7..48826eb 100644 --- a/src-tauri/src/inject/style.js +++ b/src-tauri/src/inject/style.js @@ -36,7 +36,7 @@ window.addEventListener('DOMContentLoaded', (_event) => { } .fui-FluentProvider .fui-Button[data-testid="HomeButton"]{ - padding-top: 20px; + padding-top: 20px; } .chakra-ui-light #app .chakra-heading, @@ -45,7 +45,7 @@ window.addEventListener('DOMContentLoaded', (_event) => { .chakra-ui-dark #app .chakra-stack, .app-main .sidebar-mouse-in-out, .chakra-modal__content-container .chakra-modal__header > div > div { - padding-top: 10px; + padding-top: 10px; } #__next .overflow-hidden>.hidden.bg-gray-900 span.rounded-md.bg-yellow-200 { @@ -57,7 +57,7 @@ window.addEventListener('DOMContentLoaded', (_event) => { } #__next .absolute .px-3.pt-2.pb-3.text-center { - visibility: hidden; + visibility: hidden; } .lark > .dashboard-sidebar, .lark > .dashboard-sidebar > .sidebar-user-info , .lark > .dashboard-sidebar .index-module_wrapper_F-Wbq{ @@ -266,109 +266,13 @@ window.addEventListener('DOMContentLoaded', (_event) => { width: 100%; height: 20px; cursor: grab; - cursor: -webkit-grab; + -webkit-app-region: drag; user-select: none; + -webkit-user-select: none; 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) => { - e && e.preventDefault(); - 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 (/windows|linux/i.test(navigator.userAgent)) { - if (event.ctrlKey && event.key in ctrlKeyShortcuts) { - preventDefault(ctrlKeyShortcuts[event.key]); - } - } - if (/macintosh|mac os x/i.test(navigator.userAgent)) { - 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) { - const target = origin.target - origin.target = "_self"; - const hrefUrl = new URL(origin.href) - - if ( - window.location.host !== hrefUrl.host && // 如果 a 标签内链接的域名和当前页面的域名不一致 且 - target === '_blank' // a 标签内链接的 target 属性为 _blank 时 - ) { - e.preventDefault(); - window.ipc.postMessage(`open_browser:${origin.href}`); - } - } - }); + const styleElement = document.createElement('style'); + styleElement.innerHTML = css; + document.head.appendChild(styleElement); }); - -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)}%`); -} - - -function pakeToast(msg) { - const m = document.createElement('div'); - m.innerHTML = msg; - m.style.cssText = "max-width:60%;min-width: 180px;padding:0 8px;height: 36px;color: rgb(255, 255, 255);line-height: 36px;text-align: center;border-radius: 4px;position: fixed;bottom:16px;right: 16px;transform: translate(-50%, -50%);z-index: 999999;background: rgba(0, 0, 0,.9);font-size: 14px;"; - document.body.appendChild(m); - setTimeout(function() { - const d = 0.5; - m.style.transition = 'transform ' + d + 's ease-in, opacity ' + d + 's ease-in'; - m.style.opacity = '0'; - setTimeout(function() { - document.body.removeChild(m) - }, d * 1000); - }, 2500); -} - diff --git a/src-tauri/src/main.rs b/src-tauri/src/main.rs index 66a5e33..e88c395 100644 --- a/src-tauri/src/main.rs +++ b/src-tauri/src/main.rs @@ -52,10 +52,6 @@ pub fn run_app() { // Prevent initial shaking _window.restore_state(StateFlags::all()).unwrap(); _window.show().unwrap(); - #[cfg(feature = "devtools")] - { - _window.open_devtools(); - } Ok(()) }) .on_window_event(|event| { diff --git a/src-tauri/tauri.linux.conf.json b/src-tauri/tauri.linux.conf.json index 72b95b6..7ab88e0 100644 --- a/src-tauri/tauri.linux.conf.json +++ b/src-tauri/tauri.linux.conf.json @@ -8,16 +8,8 @@ "copyright": "", "deb": { "depends": [ - "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" + "wget" ], "files": { "/usr/share/applications/com-tw93-weread.desktop": "assets/com-tw93-weread.desktop"