master
veypi 1 year ago
parent 1560ec9ad2
commit c180cd4241

@ -1,3 +1,3 @@
<!DOCTYPE html><html><head><title>OA</title><meta charset=utf-8><meta name=description content=oneauth><meta name=format-detection content="telephone=no"><meta name=msapplication-tap-highlight content=no><meta name=viewport content="user-scalable=no,initial-scale=1,maximum-scale=1,minimum-scale=1,width=device-width"><link rel=icon type=image/ico href="/favicon.ico"> <script type="module" crossorigin src="/assets/index.43a53367.js"></script> <!DOCTYPE html><html><head><title>OA</title><meta charset=utf-8><meta name=description content=oneauth><meta name=format-detection content="telephone=no"><meta name=msapplication-tap-highlight content=no><meta name=viewport content="user-scalable=no,initial-scale=1,maximum-scale=1,minimum-scale=1,width=device-width"><link rel=icon type=image/ico href="/favicon.ico"> <script type="module" crossorigin src="/assets/index.d8d01e36.js"></script>
<link rel="stylesheet" href="/assets/index.4abc03f5.css"> <link rel="stylesheet" href="/assets/index.8c5080bc.css">
</head><body><div id=v-msg></div><div id=q-app></div></body></html> </head><body><div id=v-msg></div><div id=q-app></div></body></html>

@ -68,10 +68,11 @@ pub async fn info(stat: web::Data<AppState>) -> Result<impl actix_web::Responder
pub async fn proxynats( pub async fn proxynats(
req: actix_web::HttpRequest, req: actix_web::HttpRequest,
p: web::Path<String>, p: web::Path<String>,
stat: web::Data<AppState>,
) -> Result<impl actix_web::Responder> { ) -> Result<impl actix_web::Responder> {
let data = req.uri().query(); let data = req.uri().query();
let p = p.into_inner(); let p = p.into_inner();
let mut url = "http://127.0.0.1:8222".to_string(); let mut url = stat.nats_url.clone();
if !p.is_empty() { if !p.is_empty() {
url = format!("{url}/{p}") url = format!("{url}/{p}")
} }
@ -87,10 +88,11 @@ pub async fn proxynats(
pub async fn tsdb( pub async fn tsdb(
req: actix_web::HttpRequest, req: actix_web::HttpRequest,
p: web::Path<String>, p: web::Path<String>,
stat: web::Data<AppState>,
) -> Result<impl actix_web::Responder> { ) -> Result<impl actix_web::Responder> {
let data = req.uri().query(); let data = req.uri().query();
let p = p.into_inner(); let p = p.into_inner();
let mut url = "http://127.0.0.1:8428/api/v1".to_string(); let mut url = format!("{}/api/v1", stat.ts_url);
if !p.is_empty() { if !p.is_empty() {
url = format!("{url}/{p}") url = format!("{url}/{p}")
} }

@ -35,7 +35,7 @@ use crate::Result;
#[clap(name = "oab")] #[clap(name = "oab")]
#[clap(about = "oab", long_about = None)] #[clap(about = "oab", long_about = None)]
pub struct AppCli { pub struct AppCli {
#[clap(short = 'c', value_name = "cfg",default_value_t = String::from("~/.config/oab/oab.yml"), value_hint = clap::ValueHint::DirPath)] #[clap(short = 'c', value_name = "cfg",default_value_t = String::from("~/.config/oa/oab.yml"), value_hint = clap::ValueHint::DirPath)]
cfg: String, cfg: String,
#[clap(subcommand)] #[clap(subcommand)]
pub command: Option<Clis>, pub command: Option<Clis>,
@ -131,6 +131,8 @@ pub struct AppState {
pub db_name: String, pub db_name: String,
pub log_dir: Option<String>, pub log_dir: Option<String>,
pub fs_root: String, pub fs_root: String,
pub ts_url: String,
pub nats_url: String,
pub nats_usr: [String; 2], pub nats_usr: [String; 2],
pub nats_node: [String; 2], pub nats_node: [String; 2],
pub nats_sys: [String; 2], pub nats_sys: [String; 2],
@ -180,6 +182,8 @@ impl AppState {
log_level: None, log_level: None,
_sqlx: None, _sqlx: None,
_db: None, _db: None,
ts_url: "127.0.0.1:8428".to_string(),
nats_url: "127.0.0.1:4222".to_string(),
nats_usr: [ nats_usr: [
String::from("UCXFAAVMCPTATZUZX6H24YF6FI3NKPQBPLM6BNN2EDFPNSUUEZPNFKEL"), String::from("UCXFAAVMCPTATZUZX6H24YF6FI3NKPQBPLM6BNN2EDFPNSUUEZPNFKEL"),
String::from("SUACQNAAFKDKRBXS62J4JYZ7DWZS7UNUQI52BOFGGBUACHTDHRQP7I66GI"), String::from("SUACQNAAFKDKRBXS62J4JYZ7DWZS7UNUQI52BOFGGBUACHTDHRQP7I66GI"),

@ -89,16 +89,23 @@ pub async fn dav_handler(
Some(o) => o.to_str().unwrap(), Some(o) => o.to_str().unwrap(),
None => "", None => "",
}; };
let allowed_headers =
match req.request.headers().get("Access-Control-Request-Headers") {
Some(o) => o.to_str().unwrap(),
None => "",
};
let allowed_method =
match req.request.headers().get("Access-Control-Request-Method") {
Some(o) => o.to_str().unwrap(),
None => "",
};
Response::builder() Response::builder()
.status(200) .status(200)
.header("WWW-Authenticate", "Basic realm=\"file\"") .header("WWW-Authenticate", "Basic realm=\"file\"")
.header("Access-Control-Allow-Origin", origin) .header("Access-Control-Allow-Origin", origin)
.header("Access-Control-Allow-Credentials", "true") .header("Access-Control-Allow-Credentials", "true")
.header("Access-Control-Allow-Headers", "auth_token, depth") .header("Access-Control-Allow-Headers", allowed_headers)
.header( .header("Access-Control-Allow-Methods", allowed_method)
"Access-Control-Allow-Methods",
"OPTIONS, DELETE, GET, POST, PUT, HEAD, TRACE, PATCH, CONNECT, PROPFIND",
)
.header( .header(
"Access-Control-Expose-Headers", "Access-Control-Expose-Headers",
"access-control-allow-origin, content-type", "access-control-allow-origin, content-type",

@ -35,7 +35,7 @@ pub fn start_stats_info(url: String) {
let mut s = System::new_all(); let mut s = System::new_all();
let pid = Pid::from(pid as usize); let pid = Pid::from(pid as usize);
let props = sysinfo::ProcessRefreshKind::everything(); let props = sysinfo::ProcessRefreshKind::everything();
let url = format!("http://{}/api/v1/import/prometheus", url); let url = format!("{}/api/v1/import/prometheus", url);
let client = reqwest::Client::new(); let client = reqwest::Client::new();
let start = Instant::now(); let start = Instant::now();
loop { loop {

@ -52,7 +52,7 @@ async fn main() -> Result<()> {
async fn web(data: AppState) -> Result<()> { async fn web(data: AppState) -> Result<()> {
// libs::task::start_nats_online(client.clone()); // libs::task::start_nats_online(client.clone());
libs::task::start_stats_info(data.info.ts_url.clone()); libs::task::start_stats_info(data.ts_url.clone());
let url = data.server_url.clone(); let url = data.server_url.clone();
let dav = libs::fs::core(); let dav = libs::fs::core();
let serv = HttpServer::new(move || { let serv = HttpServer::new(move || {

@ -9,8 +9,6 @@ mod app_plugin;
pub mod entity; pub mod entity;
mod user_plugin; mod user_plugin;
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use tracing::info; use tracing::info;

@ -58,7 +58,7 @@ const onSubmit = () => {
util.setToken(data.auth_token) util.setToken(data.auth_token)
msg.Info('登录成功') msg.Info('登录成功')
user.fetchUserData() user.fetchUserData()
let url = route.query.redirect || data.redirect || '/' let url = route.query.redirect || data.redirect || ''
redirect(url) redirect(url)
}).catch(e => { }).catch(e => {
let m = e === '1' ? '被禁止登录' : e === '2' ? '正在申请中' : e let m = e === '1' ? '被禁止登录' : e === '2' ? '正在申请中' : e
@ -81,8 +81,10 @@ let ifLogOut = computed(() => {
function redirect(url: string) { function redirect(url: string) {
if (url === 'undefined') {
url = ''
}
if (uuid.value && uuid.value !== app.id) { if (uuid.value && uuid.value !== app.id) {
api.app.get(uuid.value as string).then((app: modelsApp) => { api.app.get(uuid.value as string).then((app: modelsApp) => {
api.token(uuid.value as string).get({ api.token(uuid.value as string).get({
token: token:

Loading…
Cancel
Save