diff --git a/oab/dist/index.html b/oab/dist/index.html
index 81a771a..2af09e8 100644
--- a/oab/dist/index.html
+++ b/oab/dist/index.html
@@ -1,3 +1,3 @@
-
OA
-
+OA
+
\ No newline at end of file
diff --git a/oab/src/api/mod.rs b/oab/src/api/mod.rs
index 5ea234b..0c2d8b0 100644
--- a/oab/src/api/mod.rs
+++ b/oab/src/api/mod.rs
@@ -68,10 +68,11 @@ pub async fn info(stat: web::Data) -> Result,
+ stat: web::Data,
) -> Result {
let data = req.uri().query();
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() {
url = format!("{url}/{p}")
}
@@ -87,10 +88,11 @@ pub async fn proxynats(
pub async fn tsdb(
req: actix_web::HttpRequest,
p: web::Path,
+ stat: web::Data,
) -> Result {
let data = req.uri().query();
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() {
url = format!("{url}/{p}")
}
diff --git a/oab/src/cfg.rs b/oab/src/cfg.rs
index 89b8cc7..e8fa1fe 100644
--- a/oab/src/cfg.rs
+++ b/oab/src/cfg.rs
@@ -35,7 +35,7 @@ use crate::Result;
#[clap(name = "oab")]
#[clap(about = "oab", long_about = None)]
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,
#[clap(subcommand)]
pub command: Option,
@@ -131,6 +131,8 @@ pub struct AppState {
pub db_name: String,
pub log_dir: Option,
pub fs_root: String,
+ pub ts_url: String,
+ pub nats_url: String,
pub nats_usr: [String; 2],
pub nats_node: [String; 2],
pub nats_sys: [String; 2],
@@ -180,6 +182,8 @@ impl AppState {
log_level: None,
_sqlx: None,
_db: None,
+ ts_url: "127.0.0.1:8428".to_string(),
+ nats_url: "127.0.0.1:4222".to_string(),
nats_usr: [
String::from("UCXFAAVMCPTATZUZX6H24YF6FI3NKPQBPLM6BNN2EDFPNSUUEZPNFKEL"),
String::from("SUACQNAAFKDKRBXS62J4JYZ7DWZS7UNUQI52BOFGGBUACHTDHRQP7I66GI"),
diff --git a/oab/src/libs/fs.rs b/oab/src/libs/fs.rs
index b1cb410..186e5c2 100644
--- a/oab/src/libs/fs.rs
+++ b/oab/src/libs/fs.rs
@@ -89,16 +89,23 @@ pub async fn dav_handler(
Some(o) => o.to_str().unwrap(),
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()
.status(200)
.header("WWW-Authenticate", "Basic realm=\"file\"")
.header("Access-Control-Allow-Origin", origin)
.header("Access-Control-Allow-Credentials", "true")
- .header("Access-Control-Allow-Headers", "auth_token, depth")
- .header(
- "Access-Control-Allow-Methods",
- "OPTIONS, DELETE, GET, POST, PUT, HEAD, TRACE, PATCH, CONNECT, PROPFIND",
- )
+ .header("Access-Control-Allow-Headers", allowed_headers)
+ .header("Access-Control-Allow-Methods", allowed_method)
.header(
"Access-Control-Expose-Headers",
"access-control-allow-origin, content-type",
diff --git a/oab/src/libs/task.rs b/oab/src/libs/task.rs
index 2c1b405..f15cbaf 100644
--- a/oab/src/libs/task.rs
+++ b/oab/src/libs/task.rs
@@ -35,7 +35,7 @@ pub fn start_stats_info(url: String) {
let mut s = System::new_all();
let pid = Pid::from(pid as usize);
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 start = Instant::now();
loop {
diff --git a/oab/src/main.rs b/oab/src/main.rs
index abc0c7d..8cdb5f0 100644
--- a/oab/src/main.rs
+++ b/oab/src/main.rs
@@ -52,7 +52,7 @@ async fn main() -> Result<()> {
async fn web(data: AppState) -> Result<()> {
// 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 dav = libs::fs::core();
let serv = HttpServer::new(move || {
diff --git a/oab/src/models/mod.rs b/oab/src/models/mod.rs
index bb4b386..c6df8d7 100644
--- a/oab/src/models/mod.rs
+++ b/oab/src/models/mod.rs
@@ -9,8 +9,6 @@ mod app_plugin;
pub mod entity;
mod user_plugin;
-
-
use serde::{Deserialize, Serialize};
use tracing::info;
diff --git a/oaweb/src/pages/login.vue b/oaweb/src/pages/login.vue
index 2352a54..9959094 100644
--- a/oaweb/src/pages/login.vue
+++ b/oaweb/src/pages/login.vue
@@ -58,7 +58,7 @@ const onSubmit = () => {
util.setToken(data.auth_token)
msg.Info('登录成功')
user.fetchUserData()
- let url = route.query.redirect || data.redirect || '/'
+ let url = route.query.redirect || data.redirect || ''
redirect(url)
}).catch(e => {
let m = e === '1' ? '被禁止登录' : e === '2' ? '正在申请中' : e
@@ -81,8 +81,10 @@ let ifLogOut = computed(() => {
function redirect(url: string) {
+ if (url === 'undefined') {
+ url = ''
+ }
if (uuid.value && uuid.value !== app.id) {
-
api.app.get(uuid.value as string).then((app: modelsApp) => {
api.token(uuid.value as string).get({
token: