Risuai 0.6.3 first commit
4
src-tauri/.cargo/config.toml
Normal file
@@ -0,0 +1,4 @@
|
||||
[build]
|
||||
target = 'x86_64-pc-windows-msvc'
|
||||
|
||||
[target]
|
||||
3
src-tauri/.gitignore
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
# Generated by Cargo
|
||||
# will have compiled files and executables
|
||||
/target/
|
||||
3889
src-tauri/Cargo.lock
generated
Normal file
28
src-tauri/Cargo.toml
Normal file
@@ -0,0 +1,28 @@
|
||||
[package]
|
||||
name = "risuai"
|
||||
version = "0.0.0"
|
||||
description = "A Tauri App"
|
||||
authors = ["you"]
|
||||
license = ""
|
||||
repository = ""
|
||||
edition = "2021"
|
||||
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[build-dependencies]
|
||||
tauri-build = { version = "1.2.1", features = [] }
|
||||
|
||||
[dependencies]
|
||||
tauri = { version = "1.2.4", features = ["app-all", "dialog-all", "fs-all", "http-all", "os-all", "path-all", "process-relaunch", "protocol-all", "shell-open", "window-maximize", "window-set-fullscreen"] }
|
||||
serde_json = "1.0"
|
||||
tiktoken-rs = "0.4.0"
|
||||
base64 = "0.21.0"
|
||||
reqwest = { version = "0.11.16", features = ["json"] }
|
||||
|
||||
[features]
|
||||
# this feature is used for production builds or when `devPath` points to the filesystem
|
||||
# DO NOT REMOVE!!
|
||||
custom-protocol = ["tauri/custom-protocol"]
|
||||
|
||||
# [lib]
|
||||
# crate-type = ["staticlib", "cdylib", "rlib"]
|
||||
3
src-tauri/build.rs
Normal file
@@ -0,0 +1,3 @@
|
||||
fn main() {
|
||||
tauri_build::build()
|
||||
}
|
||||
BIN
src-tauri/icons/128x128.png
Normal file
|
After Width: | Height: | Size: 17 KiB |
BIN
src-tauri/icons/128x128@2x.png
Normal file
|
After Width: | Height: | Size: 69 KiB |
BIN
src-tauri/icons/32x32.png
Normal file
|
After Width: | Height: | Size: 1.7 KiB |
BIN
src-tauri/icons/Square107x107Logo.png
Normal file
|
After Width: | Height: | Size: 12 KiB |
0
src-tauri/icons/Square142x142Logo.png
Normal file
BIN
src-tauri/icons/Square150x150Logo.png
Normal file
|
After Width: | Height: | Size: 24 KiB |
BIN
src-tauri/icons/Square284x284Logo.png
Normal file
|
After Width: | Height: | Size: 86 KiB |
BIN
src-tauri/icons/Square30x30Logo.png
Normal file
|
After Width: | Height: | Size: 1.5 KiB |
BIN
src-tauri/icons/Square310x310Logo.png
Normal file
|
After Width: | Height: | Size: 104 KiB |
BIN
src-tauri/icons/Square44x44Logo.png
Normal file
|
After Width: | Height: | Size: 2.7 KiB |
BIN
src-tauri/icons/Square71x71Logo.png
Normal file
|
After Width: | Height: | Size: 5.9 KiB |
BIN
src-tauri/icons/Square89x89Logo.png
Normal file
|
After Width: | Height: | Size: 8.8 KiB |
BIN
src-tauri/icons/StoreLogo.png
Normal file
|
After Width: | Height: | Size: 3.3 KiB |
BIN
src-tauri/icons/icon.icns
Normal file
BIN
src-tauri/icons/icon.ico
Normal file
|
After Width: | Height: | Size: 84 KiB |
BIN
src-tauri/icons/icon.png
Normal file
|
After Width: | Height: | Size: 316 KiB |
81
src-tauri/src/main.rs
Normal file
@@ -0,0 +1,81 @@
|
||||
// Prevents additional console window on Windows in release, DO NOT REMOVE!!
|
||||
#![cfg_attr(not(debug_assertions), windows_subsystem = "windows")]
|
||||
|
||||
|
||||
#[tauri::command]
|
||||
fn greet(name: &str) -> String {
|
||||
format!("Hello, {}! You've been greeted from Rust!", name)
|
||||
}
|
||||
|
||||
use serde_json::Value;
|
||||
use reqwest::header::{HeaderMap, HeaderName, HeaderValue};
|
||||
use base64::{engine::general_purpose, Engine as _};
|
||||
use std::time::Duration;
|
||||
|
||||
|
||||
#[tauri::command]
|
||||
async fn native_request(url: String, body: String, header: String, method:String) -> String {
|
||||
let headers_json: Value = match serde_json::from_str(&header) {
|
||||
Ok(h) => h,
|
||||
Err(e) => return format!(r#"{{"success":false,"body":"{}"}}"#, e.to_string()),
|
||||
};
|
||||
|
||||
let mut headers = HeaderMap::new();
|
||||
let method = method.to_string();
|
||||
if let Some(obj) = headers_json.as_object() {
|
||||
for (key, value) in obj {
|
||||
let header_name = match HeaderName::from_bytes(key.as_bytes()) {
|
||||
Ok(name) => name,
|
||||
Err(e) => return format!(r#"{{"success":false,"body":"{}"}}"#, e.to_string()),
|
||||
};
|
||||
let header_value = match HeaderValue::from_str(value.as_str().unwrap_or("")) {
|
||||
Ok(value) => value,
|
||||
Err(e) => return format!(r#"{{"success":false,"body":"{}"}}"#, e.to_string()),
|
||||
};
|
||||
headers.insert(header_name, header_value);
|
||||
}
|
||||
} else {
|
||||
return format!(r#"{{"success":false,"body":"Invalid header JSON"}}"#);
|
||||
}
|
||||
|
||||
let client = reqwest::Client::new();
|
||||
let response:Result<reqwest::Response, reqwest::Error>;
|
||||
|
||||
if method == "POST" {
|
||||
response = client
|
||||
.post(&url)
|
||||
.headers(headers)
|
||||
.timeout(Duration::from_secs(120))
|
||||
.body(body)
|
||||
.send()
|
||||
.await;
|
||||
}
|
||||
else{
|
||||
response = client
|
||||
.get(&url)
|
||||
.headers(headers)
|
||||
.timeout(Duration::from_secs(120))
|
||||
.send()
|
||||
.await;
|
||||
}
|
||||
|
||||
match response {
|
||||
Ok(resp) => {
|
||||
let bytes = match resp.bytes().await {
|
||||
Ok(b) => b,
|
||||
Err(e) => return format!(r#"{{"success":false,"body":"{}"}}"#, e.to_string()),
|
||||
};
|
||||
let encoded = general_purpose::STANDARD.encode(&bytes);
|
||||
|
||||
format!(r#"{{"success":true,"body":"{}"}}"#, encoded)
|
||||
}
|
||||
Err(e) => format!(r#"{{"success":false,"body":"{}"}}"#, e.to_string()),
|
||||
}
|
||||
}
|
||||
|
||||
fn main() {
|
||||
tauri::Builder::default()
|
||||
.invoke_handler(tauri::generate_handler![greet, native_request])
|
||||
.run(tauri::generate_context!())
|
||||
.expect("error while running tauri application");
|
||||
}
|
||||
110
src-tauri/tauri.conf.json
Normal file
@@ -0,0 +1,110 @@
|
||||
{
|
||||
"build": {
|
||||
"beforeDevCommand": "pnpm dev",
|
||||
"beforeBuildCommand": "pnpm build",
|
||||
"devPath": "http://localhost:5174",
|
||||
"distDir": "../dist",
|
||||
"withGlobalTauri": false
|
||||
},
|
||||
"package": {
|
||||
"productName": "RisuAI",
|
||||
"version": "0.6.2"
|
||||
},
|
||||
"tauri": {
|
||||
"allowlist": {
|
||||
"app": {
|
||||
"all": true
|
||||
},
|
||||
"process": {
|
||||
"relaunch": true
|
||||
},
|
||||
"protocol": {
|
||||
"all": true,
|
||||
"assetScope": ["asset","$APPDATA","$APPDATA/*","$APPDATA/**/*", "/data/**/*"]
|
||||
},
|
||||
"all": false,
|
||||
"shell": {
|
||||
"all": false,
|
||||
"open": true
|
||||
},
|
||||
"fs":{
|
||||
"all": true,
|
||||
"scope": ["$APPDATA","$APPDATA/*","$APPDATA/**/*", "$DOWNLOAD/*", "/data/**/*"]
|
||||
},
|
||||
"path":{
|
||||
"all": true
|
||||
},
|
||||
"http": {
|
||||
"all": true,
|
||||
"request": true,
|
||||
"scope": ["https://*/*", "https://*/**/*","http://*/*", "http://*/**/*"]
|
||||
},
|
||||
"window": {
|
||||
"center": false,
|
||||
"close": false,
|
||||
"create": false,
|
||||
"hide": false,
|
||||
"maximize": true,
|
||||
"minimize": false,
|
||||
"print": false,
|
||||
"requestUserAttention": false,
|
||||
"setAlwaysOnTop": false,
|
||||
"setCursorGrab": false,
|
||||
"setCursorIcon": false,
|
||||
"setCursorPosition": false,
|
||||
"setCursorVisible": false,
|
||||
"setDecorations": false,
|
||||
"setFocus": false,
|
||||
"setFullscreen": true,
|
||||
"setIcon": false,
|
||||
"setIgnoreCursorEvents": false,
|
||||
"setMaxSize": false,
|
||||
"setMinSize": false,
|
||||
"setPosition": false,
|
||||
"setResizable": false,
|
||||
"setSize": false,
|
||||
"setSkipTaskbar": false,
|
||||
"setTitle": false,
|
||||
"show": false,
|
||||
"startDragging": false,
|
||||
"unmaximize": false,
|
||||
"unminimize": false
|
||||
},
|
||||
"dialog": {
|
||||
"all": true
|
||||
},
|
||||
"os": {
|
||||
"all": true
|
||||
}
|
||||
},
|
||||
"bundle": {
|
||||
"active": true,
|
||||
"icon": [
|
||||
"icons/32x32.png",
|
||||
"icons/128x128.png",
|
||||
"icons/128x128@2x.png",
|
||||
"icons/icon.icns",
|
||||
"icons/icon.ico"
|
||||
],
|
||||
"identifier": "co.aiclient.risu",
|
||||
"targets": "all"
|
||||
},
|
||||
"security": {
|
||||
"csp": null
|
||||
},
|
||||
"updater": {
|
||||
"active": false
|
||||
},
|
||||
"windows": [
|
||||
{
|
||||
"fullscreen": false,
|
||||
"resizable": true,
|
||||
"title": "RisuAI",
|
||||
"width": 1024,
|
||||
"height": 768,
|
||||
"minWidth": 300,
|
||||
"minHeight": 500
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||