Skip to content

Commit

Permalink
🚀 publish
Browse files Browse the repository at this point in the history
  • Loading branch information
niuhuan committed Jan 9, 2024
1 parent cf8dcdd commit 05b2a7e
Show file tree
Hide file tree
Showing 46 changed files with 5,852 additions and 35 deletions.
7 changes: 0 additions & 7 deletions .github/workflows/Release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -131,13 +131,6 @@ jobs:
cd ci
cargo run --bin check-asset
- name: Check core
uses: actions/checkout@v3
with:
repository: 'niuhuan/jasmine-rs-core'
token: ${{ secrets.GH_TOKEN }}
path: 'native'

- name: Cache Flutter dependencies (Linux/Android)
if: steps.check_asset.outputs.skip_build != 'true' && matrix.config.host == 'ubuntu-latest'
uses: actions/cache@v3
Expand Down
36 changes: 8 additions & 28 deletions lib/screens/init_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -62,34 +62,14 @@ class _InitScreenState extends State<InitScreen> {
await methods.init();
await initConfigs();
print("STATE : ${loginStatus}");
if (!currentPassed()) {
Future.delayed(Duration.zero, () async {
await webDavSyncAuto(context);
Navigator.of(context).pushReplacement(
MaterialPageRoute(builder: (BuildContext context) {
return const CalculatorScreen();
}),
);
});
} else if (loginStatus == LoginStatus.notSet) {
Future.delayed(Duration.zero, () async {
await webDavSyncAuto(context);
Navigator.of(context).pushReplacement(
MaterialPageRoute(builder: (BuildContext context) {
return firstLoginScreen;
}),
);
});
} else {
Future.delayed(Duration.zero, () async {
await webDavSyncAuto(context);
Navigator.of(context).pushReplacement(
MaterialPageRoute(builder: (BuildContext context) {
return const AppScreen();
}),
);
});
}
Future.delayed(Duration.zero, () async {
await webDavSyncAuto(context);
Navigator.of(context).pushReplacement(
MaterialPageRoute(builder: (BuildContext context) {
return const AppScreen();
}),
);
});
} catch (e, st) {
print("$e\n$st");
defaultToast(context, "初始化失败, 请设置网络");
Expand Down
9 changes: 9 additions & 0 deletions native/jmbackend/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
target/
Cargo.lock

platforms/android/jmbackend
platforms/android/jmcomic-rs
platforms/test/

/.idea/
*.iml
38 changes: 38 additions & 0 deletions native/jmbackend/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
[package]
name = "jmbackend"
version = "0.1.0"
edition = "2021"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
jmcomic = { path = "../jmcomic-rs" }
lazy_static = "1.4.0"
sea-orm = { version = "0.12.4", features = ["sqlx-sqlite", "runtime-tokio-rustls", "macros"], default-features = false }
sea-orm-migration = { version = "0.12.4", features = ["sqlx-sqlite", "runtime-tokio-rustls"], default-features = false }
chrono = "0.4.31"
libc = "0.2.149"
bytes = "1.5.0"
tokio = { version = "1.33.0", features = ["full"] }
reqwest = { version = "0.11.22", features = ["socks", "stream", "rustls", "tokio-rustls", "rustls-tls"], default-features = false }
hex = "0.4.3"
md5 = "0.7.0"
image = { version = "0.24.7", features = ["png", "jpeg", "bmp", "gif", "webp"] }
rand = "0.8.5"
itertools = "0.11.0"
async-trait = "0.1.74"
anyhow = "1.0.75"
rsa = "0.6.1"
base64 = "0.13.0"
once_cell = "1.18.0"
regex = "1.10.2"
num-iter = "0.1.43"
futures-util = "0.3.29"
grouping_by = "0.2.2"
tokio-util = { version = "0.7.10", features = ["full"] }
async_zip = { version = "0.0.9", features = ["deflate"], default-features = false }
serde = { version = "1.0.190", features = ["derive"] }
serde_derive = "1.0.190"
serde_json = "1.0.108"

[features]
11 changes: 11 additions & 0 deletions native/jmbackend/platforms/android/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
[package]
name = "rust"
version = "0.1.0"
edition = "2021"

[dependencies]
jmbackend = { path = "../../" }
jni = "0.21.0"

[lib]
crate-type = ["cdylib"]
24 changes: 24 additions & 0 deletions native/jmbackend/platforms/android/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
pub use jmbackend::*;
use jni::objects::JClass;
use jni::objects::JString;
use jni::JNIEnv;

#[no_mangle]
pub unsafe extern "system" fn Java_opensource_jenny_Jni_init<'local>(
mut env: JNIEnv<'local>,
_class: JClass<'local>,
params: JString<'local>,
) {
let params: String = env.get_string(&params).unwrap().into();
init_sync(params.as_str());
}

#[no_mangle]
pub unsafe extern "C" fn Java_opensource_jenny_Jni_invoke<'local>(
mut env: JNIEnv<'local>,
_: JClass<'local>,
params: JString<'local>,
) -> JString<'local> {
let params: String = env.get_string(&params).unwrap().into();
env.new_string(invoke(params.as_str())).unwrap()
}
10 changes: 10 additions & 0 deletions native/jmbackend/platforms/ios-sim/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
[package]
name = "rust"
version = "0.1.0"
edition = "2021"

[dependencies]
jmbackend = { path = "../../" }

[lib]
crate-type = ["staticlib"]
1 change: 1 addition & 0 deletions native/jmbackend/platforms/ios-sim/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
pub use jmbackend::*;
10 changes: 10 additions & 0 deletions native/jmbackend/platforms/ios/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
[package]
name = "rust"
version = "0.1.0"
edition = "2021"

[dependencies]
jmbackend = { path = "../../" }

[lib]
crate-type = ["staticlib"]
1 change: 1 addition & 0 deletions native/jmbackend/platforms/ios/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
pub use jmbackend::*;
17 changes: 17 additions & 0 deletions native/jmbackend/platforms/linux/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
[package]
name = "rust"
version = "0.1.0"
edition = "2021"

[dependencies]
jmbackend = { path = "../../" }
lazy_static = "1.4.0"
reqwest = { version = "0.11.9", features = ["rustls", "tokio-rustls", "rustls-tls"], default-features = false }
serde = { version = "1.0.152", features = ["derive"] }
serde_derive = "1.0.152"
serde_json = "1.0.93"
warp = "0.3.2"
tokio = { version = "1.26.0", features = ["full"] }

[lib]
crate-type = ["staticlib"]
53 changes: 53 additions & 0 deletions native/jmbackend/platforms/linux/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
use std::process::exit;
use std::time::Duration;

use serde_json::to_string;
use warp::Filter;

pub use jmbackend::*;

#[derive(Debug, serde::Deserialize, serde::Serialize)]
pub struct DartQuery {
pub method: String,
pub params: String,
}

#[no_mangle]
pub unsafe extern "C" fn init_http_server() {
let ping = warp::get()
.and(warp::path("ping"))
.map(|| "pong".to_owned());
let invoke = warp::post()
.and(warp::path("invoke"))
.and(warp::body::json())
.map(invoke);
std::thread::spawn(move || {
jmbackend::RUNTIME.block_on(warp::serve(ping.or(invoke)).run(([127, 0, 0, 1], 52764)))
});
jmbackend::RUNTIME.block_on(test_startup());
}

fn invoke(dq: DartQuery) -> String {
jmbackend::RUNTIME.block_on(jmbackend::invoke_async(to_string(&dq).unwrap().as_str()))
}

async fn test_startup() {
for i in 0..6 {
if i == 5 {
exit(2);
}
std::thread::sleep(Duration::new(1, 0));
match reqwest::get("http://127.0.0.1:52764/ping").await {
Ok(req) => match req.text().await {
Ok(txt) => {
println!("OK : {}", txt);
break;
}
Err(err) => println!("ERR : {}", err),
},
Err(err) => {
println!("ERR : {}", err)
}
}
}
}
10 changes: 10 additions & 0 deletions native/jmbackend/platforms/macos/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
[package]
name = "rust"
version = "0.1.0"
edition = "2021"

[dependencies]
jmbackend = { path = "../../" }

[lib]
crate-type = ["staticlib"]
1 change: 1 addition & 0 deletions native/jmbackend/platforms/macos/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
pub use jmbackend::*;
10 changes: 10 additions & 0 deletions native/jmbackend/platforms/windows/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
[package]
name = "rust"
version = "0.1.0"
edition = "2021"

[dependencies]
jmbackend = { path = "../../" }

[lib]
crate-type = ["staticlib"]
1 change: 1 addition & 0 deletions native/jmbackend/platforms/windows/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
pub use jmbackend::*;
Loading

0 comments on commit 05b2a7e

Please sign in to comment.