From a2d543f8bc5d899d78270d941e01505cebaf4102 Mon Sep 17 00:00:00 2001 From: krircc Date: Sat, 23 Jun 2018 15:54:08 +0800 Subject: [PATCH] fix index page --- layouts/index.html | 145 ++++++++++++++++++----------------- layouts/partials/footer.html | 15 +--- static/css/actix.css | 24 ++++++ static/js/actix.js | 29 +++++++ 4 files changed, 128 insertions(+), 85 deletions(-) diff --git a/layouts/index.html b/layouts/index.html index ea96734..4391657 100644 --- a/layouts/index.html +++ b/layouts/index.html @@ -195,62 +195,70 @@
{{ highlight `extern crate actix_web; - use actix_web::{http::Method, server, App, Path, Responder}; + use actix_web::{http::Method, server, App, Path, Responder}; - fn index(info: Path<(u32, String)>) -> impl Responder { - format!("Hello {}! id:{}", info.1, info.0) - } + fn index(info: Path<(u32, String)>) -> impl Responder { + format!("Hello {}! id:{}", info.1, info.0) + } - fn main() { - server::new( - || App::new() - .route("/{id}/{name}/index.html", Method::GET, index)) - .bind("127.0.0.1:8080").unwrap() - .run(); - }` "rust" "" }} + fn main() { + server::new( + || App::new() + .route("/{id}/{name}/index.html", Method::GET, index)) + .bind("127.0.0.1:8080").unwrap() + .run(); + }` "rust" "" }}
-
-
-
-

灵活的请求响应

-

- Actix中的Handler函数可以返回实现该Respondert rait的各种对象。这使得从API返回一致的响应变得轻而易举。 -

- {{ highlight `#[derive(Serialize)] - struct Measurement { - temperature: f32, - } - - fn hello_world() -> impl Responder { - "Hello World!" - } - - fn current_temperature(_req: HttpRequest) -> impl Responder { - Json(Measurement { temperature: 42.3 }) - }` "rust" "" }} -
-
-

强大的Extractors

-

- Actix提供了一个强大的提取器系统,可以从传入的HTTP请求中提取数据并将其传递给您的视图函数。这不仅可以创建方便的API, - 而且还意味着您的视图函数可以是同步代码,并且仍然可以受益于异步IO处理。 -

- {{ highlight `#[derive(Deserialize)] + + +
+
    +
  • 灵活的请求响应
  • +
  • 强大的Extractors
  • +
  • 轻松处理表单
  • +
  • 请求路由
  • +
+
+
+

灵活的请求响应

+

+ Actix中的Handler函数可以返回实现该Respondert rait的各种对象。这使得从API返回一致的响应变得轻而易举。 +

+ {{ highlight `#[derive(Serialize)] + struct Measurement { + temperature: f32, + } + + fn hello_world() -> impl Responder { + "Hello World!" + } + + fn current_temperature(_req: HttpRequest) -> impl Responder { + Json(Measurement { temperature: 42.3 }) + }` "rust" "" }} +
+ -
-

轻松处理表单

+
+ -
-

请求路由

-

- 一个actix应用程序带有一个URL路由系统,可以让你在URL上匹配并调用单个处理程序。为了获得额外的灵活性,可以使用域。 -

- {{ highlight `fn index(req: HttpRequest) -> impl Responder { - "Hello from the index page" +
+ -
- +
+
+ + +
- + {{ partial "footer" . }} diff --git a/layouts/partials/footer.html b/layouts/partials/footer.html index ff5f9c3..956482b 100644 --- a/layouts/partials/footer.html +++ b/layouts/partials/footer.html @@ -13,20 +13,7 @@ - + {{ template "_internal/google_analytics.html" . }} - - diff --git a/static/css/actix.css b/static/css/actix.css index 34db1a0..3c0537d 100644 --- a/static/css/actix.css +++ b/static/css/actix.css @@ -600,3 +600,27 @@ h5:hover a { width: 88%; } } + + +#act-cn-tabs { + padding: 2rem 1.5rem 0.5rem 2rem; + margin: 2rem auto; + background:#dceaea; +} + +.act-menu{ + width: 24%; + float: right; + border-right:#cccccc solid 1px; +} +.act-menu li{ + text-align:center; + line-height:44px; + font-size:15px; + overflow:hidden; +} +.act-menu li.off{ + background:#FFFFFF; + color:#000000; + font-weight:bold; +} \ No newline at end of file diff --git a/static/js/actix.js b/static/js/actix.js index ef2cb66..44b1c8b 100644 --- a/static/js/actix.js +++ b/static/js/actix.js @@ -1,3 +1,30 @@ +window.onload = function(){ + if (window.location.href.search("cn") != -1) { + var actix_home = document.getElementById("act-home") + actix_home.style.display = "none" + }else{ + var actix_home_cn = document.getElementById("act-home-cn") + actix_home_cn.style.display = "none" + } +} + +function setTab(name,cursel){ + let tlinks = document.getElementById("act-cn-tabs").getElementsByTagName('li') + for(var i=1; i<=tlinks.length; i++){ + var menu = document.getElementById(name+i); + var menudiv = document.getElementById("con_"+name+"_"+i); + if(i==cursel){ + menu.className="off"; + menudiv.style.display="block"; + } + else{ + menu.className=""; + menudiv.style.display="none"; + } + } +} + + (function() { function activateFeature(sel) { $('div.actix-feature').hide(); @@ -36,3 +63,5 @@ initFeatureSelector(); }); })(); + +