pake-cli 0.0.1-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +110 -0
- package/README_EN.md +110 -0
- package/dist/.gitkeep +0 -0
- package/dist/builders/BuilderFactory.js +11 -0
- package/dist/builders/BuilderFactory.js.map +1 -0
- package/dist/builders/LinuxBuilder.js +2 -0
- package/dist/builders/LinuxBuilder.js.map +1 -0
- package/dist/builders/MacBuilder.js +74 -0
- package/dist/builders/MacBuilder.js.map +1 -0
- package/dist/builders/WinBulider.js +2 -0
- package/dist/builders/WinBulider.js.map +1 -0
- package/dist/builders/base.js +2 -0
- package/dist/builders/base.js.map +1 -0
- package/dist/builders/common.js +38 -0
- package/dist/builders/common.js.map +1 -0
- package/dist/cli.js +34 -0
- package/dist/cli.js.map +1 -0
- package/dist/defaults.js +10 -0
- package/dist/defaults.js.map +1 -0
- package/dist/helpers/dir.js +9 -0
- package/dist/helpers/dir.js.map +1 -0
- package/dist/helpers/path.js +2 -0
- package/dist/helpers/path.js.map +1 -0
- package/dist/helpers/prepareCheck.js +53 -0
- package/dist/helpers/prepareCheck.js.map +1 -0
- package/dist/helpers/rust.js +31 -0
- package/dist/helpers/rust.js.map +1 -0
- package/dist/helpers/tauriConfig.js +8 -0
- package/dist/helpers/tauriConfig.js.map +1 -0
- package/dist/options/icon.js +111 -0
- package/dist/options/icon.js.map +1 -0
- package/dist/options/index.js +27 -0
- package/dist/options/index.js.map +1 -0
- package/dist/options/title.js +25 -0
- package/dist/options/title.js.map +1 -0
- package/dist/pake.js +43 -0
- package/dist/pake.js.map +1 -0
- package/dist/types.js +2 -0
- package/dist/types.js.map +1 -0
- package/dist/utils/platform.js +4 -0
- package/dist/utils/platform.js.map +1 -0
- package/dist/utils/shell.js +14 -0
- package/dist/utils/shell.js.map +1 -0
- package/dist/utils/url.js +20 -0
- package/dist/utils/url.js.map +1 -0
- package/dist/utils/validate.js +18 -0
- package/dist/utils/validate.js.map +1 -0
- package/package.json +60 -0
- package/src-tauri/Cargo.lock +3609 -0
- package/src-tauri/Cargo.toml +30 -0
- package/src-tauri/build.rs +3 -0
- package/src-tauri/icons/anymind.icns +0 -0
- package/src-tauri/icons/code.icns +0 -0
- package/src-tauri/icons/fanfou.icns +0 -0
- package/src-tauri/icons/flomo.icns +0 -0
- package/src-tauri/icons/fone.icns +0 -0
- package/src-tauri/icons/jdread.icns +0 -0
- package/src-tauri/icons/jike.icns +0 -0
- package/src-tauri/icons/roam.icns +0 -0
- package/src-tauri/icons/tool.icns +0 -0
- package/src-tauri/icons/twitter.icns +0 -0
- package/src-tauri/icons/vercel.icns +0 -0
- package/src-tauri/icons/weRead.icns +0 -0
- package/src-tauri/icons/whatsapp.icns +0 -0
- package/src-tauri/icons/witeboard.icns +0 -0
- package/src-tauri/icons/yuque.icns +0 -0
- package/src-tauri/src/main.rs +114 -0
- package/src-tauri/src/pake.js +130 -0
- package/src-tauri/tauri.conf.json +63 -0
- package/tsconfig.json +17 -0
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
[package]
|
|
2
|
+
name = "app"
|
|
3
|
+
version = "0.1.0"
|
|
4
|
+
description = "Pake 打包工具"
|
|
5
|
+
authors = ["Tw93"]
|
|
6
|
+
license = ""
|
|
7
|
+
repository = ""
|
|
8
|
+
default-run = "app"
|
|
9
|
+
edition = "2021"
|
|
10
|
+
rust-version = "1.61.0"
|
|
11
|
+
|
|
12
|
+
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
|
13
|
+
|
|
14
|
+
[build-dependencies]
|
|
15
|
+
tauri-build = { version = "1.1.1", features = [] }
|
|
16
|
+
|
|
17
|
+
[dependencies]
|
|
18
|
+
serde_json = "1.0.86"
|
|
19
|
+
serde = { version = "1.0.145", features = ["derive"] }
|
|
20
|
+
tauri = { version = "1.1.1", features = ["api-all"] }
|
|
21
|
+
wry = "0.21.1"
|
|
22
|
+
tauri-utils = "1.1.1"
|
|
23
|
+
|
|
24
|
+
[features]
|
|
25
|
+
# by default Tauri runs in production mode
|
|
26
|
+
# when `tauri dev` runs it is executed with `cargo run --no-default-features` if `devPath` is an URL
|
|
27
|
+
default = [ "custom-protocol" ]
|
|
28
|
+
# this feature is used used for production builds where `devPath` points to the filesystem
|
|
29
|
+
# DO NOT remove this
|
|
30
|
+
custom-protocol = [ "tauri/custom-protocol" ]
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
use tauri_utils::config::{Config, WindowConfig};
|
|
2
|
+
|
|
3
|
+
fn main() -> wry::Result<()> {
|
|
4
|
+
use wry::{
|
|
5
|
+
application::{
|
|
6
|
+
accelerator::{Accelerator, SysMods},
|
|
7
|
+
event::{Event, StartCause, WindowEvent},
|
|
8
|
+
event_loop::{ControlFlow, EventLoop},
|
|
9
|
+
keyboard::KeyCode,
|
|
10
|
+
menu::{MenuBar as Menu, MenuItem, MenuItemAttributes, MenuType},
|
|
11
|
+
platform::macos::WindowBuilderExtMacOS,
|
|
12
|
+
window::{Fullscreen, Window, WindowBuilder},
|
|
13
|
+
},
|
|
14
|
+
webview::WebViewBuilder,
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
let mut menu_bar_menu = Menu::new();
|
|
18
|
+
let mut first_menu = Menu::new();
|
|
19
|
+
|
|
20
|
+
first_menu.add_native_item(MenuItem::Hide);
|
|
21
|
+
first_menu.add_native_item(MenuItem::EnterFullScreen);
|
|
22
|
+
first_menu.add_native_item(MenuItem::Minimize);
|
|
23
|
+
first_menu.add_native_item(MenuItem::Separator);
|
|
24
|
+
first_menu.add_native_item(MenuItem::Copy);
|
|
25
|
+
first_menu.add_native_item(MenuItem::Cut);
|
|
26
|
+
first_menu.add_native_item(MenuItem::Paste);
|
|
27
|
+
first_menu.add_native_item(MenuItem::Undo);
|
|
28
|
+
first_menu.add_native_item(MenuItem::Redo);
|
|
29
|
+
first_menu.add_native_item(MenuItem::SelectAll);
|
|
30
|
+
first_menu.add_native_item(MenuItem::Separator);
|
|
31
|
+
let close_item = first_menu.add_item(
|
|
32
|
+
MenuItemAttributes::new("CloseWindow")
|
|
33
|
+
.with_accelerators(&Accelerator::new(SysMods::Cmd, KeyCode::KeyW)),
|
|
34
|
+
);
|
|
35
|
+
first_menu.add_native_item(MenuItem::Quit);
|
|
36
|
+
|
|
37
|
+
menu_bar_menu.add_submenu("App", true, first_menu);
|
|
38
|
+
|
|
39
|
+
let WindowConfig {
|
|
40
|
+
url,
|
|
41
|
+
width,
|
|
42
|
+
height,
|
|
43
|
+
resizable,
|
|
44
|
+
transparent,
|
|
45
|
+
fullscreen,
|
|
46
|
+
..
|
|
47
|
+
} = get_windows_config();
|
|
48
|
+
let event_loop = EventLoop::new();
|
|
49
|
+
let window = WindowBuilder::new()
|
|
50
|
+
.with_resizable(resizable)
|
|
51
|
+
.with_titlebar_transparent(transparent)
|
|
52
|
+
.with_fullscreen(if fullscreen {
|
|
53
|
+
Some(Fullscreen::Borderless(None))
|
|
54
|
+
} else {
|
|
55
|
+
None
|
|
56
|
+
})
|
|
57
|
+
.with_fullsize_content_view(true)
|
|
58
|
+
.with_titlebar_buttons_hidden(false)
|
|
59
|
+
.with_title_hidden(true)
|
|
60
|
+
.with_menu(menu_bar_menu)
|
|
61
|
+
.with_inner_size(wry::application::dpi::LogicalSize::new(width, height))
|
|
62
|
+
.build(&event_loop)
|
|
63
|
+
.unwrap();
|
|
64
|
+
|
|
65
|
+
let handler = move |window: &Window, req: String| {
|
|
66
|
+
if req == "drag_window" {
|
|
67
|
+
let _ = window.drag_window();
|
|
68
|
+
} else if req == "fullscreen" {
|
|
69
|
+
if window.fullscreen().is_some() {
|
|
70
|
+
window.set_fullscreen(None);
|
|
71
|
+
} else {
|
|
72
|
+
window.set_fullscreen(Some(Fullscreen::Borderless(None)));
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
let _webview = WebViewBuilder::new(window)?
|
|
78
|
+
.with_url(&url.to_string())?
|
|
79
|
+
// .with_devtools(true)
|
|
80
|
+
.with_initialization_script(include_str!("pake.js"))
|
|
81
|
+
.with_ipc_handler(handler)
|
|
82
|
+
.build()?;
|
|
83
|
+
|
|
84
|
+
// _webview.open_devtools();
|
|
85
|
+
event_loop.run(move |event, _, control_flow| {
|
|
86
|
+
*control_flow = ControlFlow::Wait;
|
|
87
|
+
|
|
88
|
+
match event {
|
|
89
|
+
Event::NewEvents(StartCause::Init) => println!("Wry has started!"),
|
|
90
|
+
Event::WindowEvent {
|
|
91
|
+
event: WindowEvent::CloseRequested,
|
|
92
|
+
..
|
|
93
|
+
} => *control_flow = ControlFlow::Exit,
|
|
94
|
+
Event::MenuEvent {
|
|
95
|
+
menu_id,
|
|
96
|
+
origin: MenuType::MenuBar,
|
|
97
|
+
..
|
|
98
|
+
} => {
|
|
99
|
+
if menu_id == close_item.clone().id() {
|
|
100
|
+
_webview.window().set_minimized(true);
|
|
101
|
+
}
|
|
102
|
+
println!("Clicked on {:?}", menu_id);
|
|
103
|
+
}
|
|
104
|
+
_ => (),
|
|
105
|
+
}
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
fn get_windows_config() -> WindowConfig {
|
|
110
|
+
let config_file = include_str!("../tauri.conf.json");
|
|
111
|
+
let config: Config = serde_json::from_str(config_file).expect("failed to parse windows config");
|
|
112
|
+
|
|
113
|
+
config.tauri.windows[0].clone()
|
|
114
|
+
}
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
window.addEventListener('DOMContentLoaded', (_event) => {
|
|
2
|
+
const style = document.createElement('style');
|
|
3
|
+
style.innerHTML = `
|
|
4
|
+
.panel.give_me .nav_view {
|
|
5
|
+
top: 154px !important;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
.columns .column #header{
|
|
9
|
+
padding-top: 30px;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
#page .main_header {
|
|
13
|
+
padding-top: 20px;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
#page #footer-wrapper,
|
|
17
|
+
.drawing-board .toolbar .toolbar-action,
|
|
18
|
+
.c-swiper-container,
|
|
19
|
+
.download_entry,
|
|
20
|
+
.lang, .copyright {
|
|
21
|
+
display: none !important;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
.container-with-note #home, .container-with-note #switcher{
|
|
25
|
+
top: 30px;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
.geist-page nav.dashboard_nav__PRmJv {
|
|
29
|
+
padding-top:10px;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
.geist-page .submenu button{
|
|
33
|
+
margin-top:24px;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
#pack-top-dom:active {
|
|
37
|
+
cursor: grabbing;
|
|
38
|
+
cursor: -webkit-grabbing;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
#pack-top-dom{
|
|
42
|
+
position:fixed;
|
|
43
|
+
background:transparent;
|
|
44
|
+
top:0;
|
|
45
|
+
width: 100%;
|
|
46
|
+
height: 20px;
|
|
47
|
+
cursor: grab;
|
|
48
|
+
cursor: -webkit-grab;
|
|
49
|
+
}
|
|
50
|
+
`;
|
|
51
|
+
document.head.append(style);
|
|
52
|
+
const topDom = document.createElement("div");
|
|
53
|
+
topDom.id = "pack-top-dom"
|
|
54
|
+
document.body.appendChild(topDom);
|
|
55
|
+
|
|
56
|
+
const domEl = document.getElementById('pack-top-dom');
|
|
57
|
+
|
|
58
|
+
domEl.addEventListener('mousedown', (e) => {
|
|
59
|
+
if (e.buttons === 1 && e.detail !== 2) {
|
|
60
|
+
window.ipc.postMessage('drag_window');
|
|
61
|
+
}
|
|
62
|
+
})
|
|
63
|
+
|
|
64
|
+
domEl.addEventListener('touchstart', (e) => {
|
|
65
|
+
window.ipc.postMessage('drag_window');
|
|
66
|
+
})
|
|
67
|
+
|
|
68
|
+
domEl.addEventListener('dblclick', (e) => {
|
|
69
|
+
window.ipc.postMessage('fullscreen');
|
|
70
|
+
})
|
|
71
|
+
|
|
72
|
+
document.addEventListener('keyup', function (event) {
|
|
73
|
+
if (event.key === "ArrowUp" && event.metaKey){
|
|
74
|
+
scrollTo(0,0);
|
|
75
|
+
}
|
|
76
|
+
if (event.key === "ArrowDown" && event.metaKey){
|
|
77
|
+
window.scrollTo(0, document.body.scrollHeight);
|
|
78
|
+
}
|
|
79
|
+
if (event.key === "[" && event.metaKey){
|
|
80
|
+
window.history.go(-1);
|
|
81
|
+
}
|
|
82
|
+
if (event.key === "]" && event.metaKey){
|
|
83
|
+
window.history.go(1);
|
|
84
|
+
}
|
|
85
|
+
if (event.key === "r" && event.metaKey){
|
|
86
|
+
window.location.reload();
|
|
87
|
+
}
|
|
88
|
+
if (event.key === "-" && event.metaKey){
|
|
89
|
+
zoomOut();
|
|
90
|
+
}
|
|
91
|
+
if (event.key === "=" && event.metaKey){
|
|
92
|
+
zoomIn();
|
|
93
|
+
}
|
|
94
|
+
if (event.key === "0" && event.metaKey){
|
|
95
|
+
document.getElementsByTagName('html')[0].style.zoom = '100%';
|
|
96
|
+
window.localStorage.setItem('htmlZoom', '100%');
|
|
97
|
+
}
|
|
98
|
+
})
|
|
99
|
+
|
|
100
|
+
const pakeLinks = document.links;
|
|
101
|
+
for (let linkIndex = 0; linkIndex < pakeLinks.length; linkIndex++) {
|
|
102
|
+
pakeLinks[linkIndex].target = '_self';
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
});
|
|
106
|
+
|
|
107
|
+
setDefaultZoom();
|
|
108
|
+
|
|
109
|
+
function setDefaultZoom() {
|
|
110
|
+
const htmlZoom = window.localStorage.getItem('htmlZoom');
|
|
111
|
+
if (htmlZoom) {
|
|
112
|
+
document.getElementsByTagName('html')[0].style.zoom = htmlZoom;
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
function zoomIn() {
|
|
117
|
+
const htmlZoom = window.localStorage.getItem('htmlZoom') || '100%';
|
|
118
|
+
const html = document.getElementsByTagName('html')[0];
|
|
119
|
+
const zoom = parseInt(htmlZoom) < 200 ? (parseInt(htmlZoom) + 10 +'%') : '200%';
|
|
120
|
+
html.style.zoom = zoom;
|
|
121
|
+
window.localStorage.setItem('htmlZoom', zoom);
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
function zoomOut() {
|
|
125
|
+
const htmlZoom = window.localStorage.getItem('htmlZoom') || '100%';
|
|
126
|
+
const html = document.getElementsByTagName('html')[0];
|
|
127
|
+
const zoom = parseInt(htmlZoom) > 30 ? (parseInt(htmlZoom) - 10 +'%') : '30%';
|
|
128
|
+
html.style.zoom = zoom;
|
|
129
|
+
window.localStorage.setItem('htmlZoom', zoom);
|
|
130
|
+
}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
{
|
|
2
|
+
"package": {
|
|
3
|
+
"productName": "baidu",
|
|
4
|
+
"version": "0.2.0"
|
|
5
|
+
},
|
|
6
|
+
"tauri": {
|
|
7
|
+
"windows": [
|
|
8
|
+
{
|
|
9
|
+
"url": "https://baidu.com",
|
|
10
|
+
"transparent": false,
|
|
11
|
+
"fullscreen": false,
|
|
12
|
+
"width": 1280,
|
|
13
|
+
"height": 800,
|
|
14
|
+
"resizable": true,
|
|
15
|
+
"title": "百度一下,你就知道"
|
|
16
|
+
}
|
|
17
|
+
],
|
|
18
|
+
"allowlist": {
|
|
19
|
+
"all": true
|
|
20
|
+
},
|
|
21
|
+
"bundle": {
|
|
22
|
+
"icon": [
|
|
23
|
+
"/var/folders/vd/8qqrr2yd6gbf23bgx5vhdzrm0000gn/T/tmp-91408-NUAYXSkVg43n/icon.icns"
|
|
24
|
+
],
|
|
25
|
+
"active": true,
|
|
26
|
+
"category": "DeveloperTool",
|
|
27
|
+
"copyright": "",
|
|
28
|
+
"deb": {
|
|
29
|
+
"depends": []
|
|
30
|
+
},
|
|
31
|
+
"externalBin": [],
|
|
32
|
+
"identifier": "pake-bb6e08",
|
|
33
|
+
"longDescription": "",
|
|
34
|
+
"macOS": {
|
|
35
|
+
"entitlements": null,
|
|
36
|
+
"exceptionDomain": "",
|
|
37
|
+
"frameworks": [],
|
|
38
|
+
"providerShortName": null,
|
|
39
|
+
"signingIdentity": null
|
|
40
|
+
},
|
|
41
|
+
"resources": [],
|
|
42
|
+
"shortDescription": "",
|
|
43
|
+
"targets": "all",
|
|
44
|
+
"windows": {
|
|
45
|
+
"certificateThumbprint": null,
|
|
46
|
+
"digestAlgorithm": "sha256",
|
|
47
|
+
"timestampUrl": ""
|
|
48
|
+
}
|
|
49
|
+
},
|
|
50
|
+
"security": {
|
|
51
|
+
"csp": null
|
|
52
|
+
},
|
|
53
|
+
"updater": {
|
|
54
|
+
"active": false
|
|
55
|
+
}
|
|
56
|
+
},
|
|
57
|
+
"build": {
|
|
58
|
+
"devPath": "../dist",
|
|
59
|
+
"distDir": "../dist",
|
|
60
|
+
"beforeBuildCommand": "",
|
|
61
|
+
"beforeDevCommand": ""
|
|
62
|
+
}
|
|
63
|
+
}
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"module": "Node16",
|
|
4
|
+
"esModuleInterop": true,
|
|
5
|
+
"allowSyntheticDefaultImports": true,
|
|
6
|
+
"target": "es6",
|
|
7
|
+
"noImplicitAny": true,
|
|
8
|
+
"moduleResolution": "Node16",
|
|
9
|
+
"sourceMap": true,
|
|
10
|
+
"outDir": "dist",
|
|
11
|
+
"baseUrl": ".",
|
|
12
|
+
"paths": {
|
|
13
|
+
"@/*": ["bin/*"]
|
|
14
|
+
}
|
|
15
|
+
},
|
|
16
|
+
"include": ["bin/**/*"]
|
|
17
|
+
}
|