From 34520f36fd7383d65564943a9bcbd36b4cc47542 Mon Sep 17 00:00:00 2001 From: veypi Date: Tue, 20 Dec 2022 01:25:32 +0800 Subject: [PATCH] save --- oab/Cargo.lock | 12 ++ oab/Cargo.toml | 1 + oab/src/api/app.rs | 35 ++++ oab/src/api/mod.rs | 4 + oab/src/api/user.rs | 3 +- oab/src/models/app.rs | 5 +- oab/src/models/role.rs | 3 +- oaf/package.json | 14 +- oaf/src/App.vue | 6 +- oaf/src/components/app.vue | 106 ++++++------ oaf/src/components/frame.vue | 116 +++++++++----- oaf/src/models/index.ts | 59 ++++--- oaf/src/oaer/src/models/index.ts | 35 ++-- oaf/src/store/index.ts | 18 +-- oaf/src/views/app/users.vue | 266 +++++++++++++++---------------- oaf/src/views/home.vue | 193 +++++++++++++--------- oaf/src/views/login.vue | 3 +- oaf/src/views/user_setting.vue | 176 ++++++++++---------- oaf/yarn.lock | 6 +- 19 files changed, 616 insertions(+), 445 deletions(-) diff --git a/oab/Cargo.lock b/oab/Cargo.lock index 380c04f..b770ff0 100644 --- a/oab/Cargo.lock +++ b/oab/Cargo.lock @@ -1169,6 +1169,7 @@ dependencies = [ "serde", "serde-big-array", "serde_json", + "serde_repr", "serde_yaml", "sqlx", "thiserror", @@ -1549,6 +1550,17 @@ dependencies = [ "serde", ] +[[package]] +name = "serde_repr" +version = "0.1.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a2ad84e47328a31223de7fed7a4f5087f2d6ddfe586cf3ca25b7a165bc0a5aed" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + [[package]] name = "serde_urlencoded" version = "0.7.1" diff --git a/oab/Cargo.toml b/oab/Cargo.toml index 9de86e5..5443a3a 100644 --- a/oab/Cargo.toml +++ b/oab/Cargo.toml @@ -32,3 +32,4 @@ serde-big-array = "0.4.1" base64 = "0.13.0" uuid = { version = "1.1", features = ["v3","v4", "fast-rng", "macro-diagnostics"]} +serde_repr = "0.1.8" diff --git a/oab/src/api/app.rs b/oab/src/api/app.rs index 565e598..35b13e2 100644 --- a/oab/src/api/app.rs +++ b/oab/src/api/app.rs @@ -4,3 +4,38 @@ // 2022-07-09 03:10 // Distributed under terms of the Apache license. // +// +use actix_web::{delete, get, post, web, Responder}; + +use crate::{models, Error, Result, CONFIG}; + +#[get("/app/{id}")] +pub async fn get(id: web::Path) -> Result { + let n = id.into_inner(); + if !n.is_empty() { + let s = sqlx::query_as::<_, models::App>("select * from app where id = ?") + .bind(n) + .fetch_one(CONFIG.db()) + .await?; + Ok(web::Json(s)) + } else { + Err(Error::Missing("id".to_string())) + } +} + +#[get("/app/")] +pub async fn list() -> Result { + let result = sqlx::query_as::<_, models::App>("select * from app") + .fetch_all(CONFIG.db()) + .await?; + Ok(web::Json(result)) +} + +#[post("/app/")] +pub async fn create() -> Result { + Ok("") +} +#[delete("/app/{id}")] +pub async fn del(id: web::Path) -> Result { + Ok("") +} diff --git a/oab/src/api/mod.rs b/oab/src/api/mod.rs index 99d0310..7c3b0d9 100644 --- a/oab/src/api/mod.rs +++ b/oab/src/api/mod.rs @@ -30,5 +30,9 @@ pub fn routes(cfg: &mut web::ServiceConfig) { .service(user::register) .service(user::login) .service(user::delete); + cfg.service(app::get) + .service(app::list) + .service(app::create) + .service(app::del); cfg.service(greet); } diff --git a/oab/src/api/user.rs b/oab/src/api/user.rs index e0c092a..38a42d8 100644 --- a/oab/src/api/user.rs +++ b/oab/src/api/user.rs @@ -5,14 +5,13 @@ // Distributed under terms of the Apache license. // -use std::fmt::{format, Debug}; +use std::fmt::Debug; use crate::{models, Error, Result, CONFIG}; use actix_web::{delete, get, head, http, post, web, HttpResponse, Responder}; use base64; use serde::{Deserialize, Serialize}; use tracing::info; -use uuid::uuid; #[get("/user/{id}")] pub async fn get(id: web::Path) -> Result { diff --git a/oab/src/models/app.rs b/oab/src/models/app.rs index 0a5503e..145bba8 100644 --- a/oab/src/models/app.rs +++ b/oab/src/models/app.rs @@ -7,8 +7,9 @@ use chrono::NaiveDateTime; use serde::{Deserialize, Serialize}; +use serde_repr::*; -#[derive(Debug, Serialize, Deserialize, Clone, sqlx::Type)] +#[derive(Debug, Serialize_repr, Deserialize_repr, Clone, sqlx::Type)] #[repr(i64)] pub enum AppJoin { Auto = 0, @@ -57,7 +58,7 @@ impl App { } } -#[derive(Debug, Deserialize, Serialize, Clone, sqlx::Type)] +#[derive(Debug, Deserialize_repr, Serialize_repr, Clone, sqlx::Type)] #[repr(i64)] pub enum AUStatus { OK = 0, diff --git a/oab/src/models/role.rs b/oab/src/models/role.rs index c0fe374..7c900f2 100644 --- a/oab/src/models/role.rs +++ b/oab/src/models/role.rs @@ -8,7 +8,8 @@ use chrono::NaiveDateTime; use serde::{Deserialize, Serialize}; -#[derive(Debug, Default, Serialize, Deserialize)] +#[derive(Debug, Default, Serialize, Deserialize, sqlx::Type, sqlx::FromRow)] +#[sqlx(type_name = "role")] pub struct Role { pub id: String, pub created: Option, diff --git a/oaf/package.json b/oaf/package.json index 8ddf0b5..360aa46 100644 --- a/oaf/package.json +++ b/oaf/package.json @@ -16,14 +16,16 @@ "@veypi/msg": "^0.1.0", "animate.css": "^4.1.1", "axios": "^0.24.0", - "fast-xml-parser": "^3.19.0", - "hot-patcher": "^0.5.0", "js-base64": "^3.7.2", - "layerr": "^0.1.2", "mitt": "^3.0.0", - "nested-property": "^4.0.0", - "path-posix": "^1.0.0", "seamless-scroll-polyfill": "^2.1.5", + "hot-patcher": "^0.5.0", + "path-posix": "^1.0.0", + "fast-xml-parser": "^3.19.0", + "nested-property": "^4.0.0", + "layerr": "^0.1.2", + "base-64": "^1.0.0", + "md5": "^2.3.0", "url-join": "^4.0.1", "url-parse": "^1.5.3", "vue": "^3.2.16", @@ -35,9 +37,7 @@ "@veypi/one-icon": "2.0.6", "@vitejs/plugin-vue": "^1.9.3", "autoprefixer": "^9.8.8", - "base-64": "^1.0.0", "less": "^4.1.2", - "md5": "^2.3.0", "naive-ui": "^2.19.11", "postcss": "^7.0.39", "tailwindcss": "npm:@tailwindcss/postcss7-compat@2.1.0", diff --git a/oaf/src/App.vue b/oaf/src/App.vue index 095b149..8e3b145 100644 --- a/oaf/src/App.vue +++ b/oaf/src/App.vue @@ -12,9 +12,8 @@ diff --git a/oaf/src/components/app.vue b/oaf/src/components/app.vue index b0bde0c..9d00912 100644 --- a/oaf/src/components/app.vue +++ b/oaf/src/components/app.vue @@ -2,66 +2,80 @@
- +
-
{{ core.Name }}
+
+ {{ core.Name }} +
{{ core.Des }}
- diff --git a/oaf/src/views/home.vue b/oaf/src/views/home.vue index e581dc0..0cbd8d3 100644 --- a/oaf/src/views/home.vue +++ b/oaf/src/views/home.vue @@ -4,46 +4,75 @@

我的应用

- 创建应用 + 创建应用 +
-
-
+
+

应用中心

-
-
+
+
- - + + - - + @@ -51,83 +80,95 @@ - + diff --git a/oaf/src/views/login.vue b/oaf/src/views/login.vue index 11bc230..d805954 100644 --- a/oaf/src/views/login.vue +++ b/oaf/src/views/login.vue @@ -74,7 +74,8 @@ function login() { store.commit('user/refreshToken', localStorage.auth_token) msg.Info('登录成功') store.dispatch('user/fetchUserData') - redirect(route.query.redirect as string) + let url = route.query.redirect || headers.redirect || '/' + redirect(url) } else { msg.Info('正在申请加入,请等待管理员审批') } diff --git a/oaf/src/views/user_setting.vue b/oaf/src/views/user_setting.vue index 44cb3bc..bcb488f 100644 --- a/oaf/src/views/user_setting.vue +++ b/oaf/src/views/user_setting.vue @@ -1,72 +1,72 @@ diff --git a/oaf/yarn.lock b/oaf/yarn.lock index cffc6ec..98cc0e2 100644 --- a/oaf/yarn.lock +++ b/oaf/yarn.lock @@ -495,9 +495,9 @@ camelcase-css@^2.0.1: integrity sha512-QOSvevhslijgYwRx6Rv7zKdMF8lbRmx+uQGx2+vDc+KI/eBnsy9kit5aj23AgGu3pa4t9AgwbnXWqS+iOY+2aA== caniuse-lite@^1.0.30001109, caniuse-lite@^1.0.30001286: - version "1.0.30001292" - resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30001292.tgz#4a55f61c06abc9595965cfd77897dc7bc1cdc456" - integrity sha512-jnT4Tq0Q4ma+6nncYQVe7d73kmDmE9C3OGTx3MvW7lBM/eY1S1DZTMBON7dqV481RhNiS5OxD7k9JQvmDOTirw== + version "1.0.30001373" + resolved "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001373.tgz" + integrity sha512-pJYArGHrPp3TUqQzFYRmP/lwJlj8RCbVe3Gd3eJQkAV8SAC6b19XS9BjMvRdvaS8RMkaTN8ZhoHP6S1y8zzwEQ== chalk@^2.4.1: version "2.4.2"