diff options
author | kaiwu <kaiwu2004@gmail.com> | 2024-07-18 23:28:54 +0800 |
---|---|---|
committer | kaiwu <kaiwu2004@gmail.com> | 2024-07-18 23:28:54 +0800 |
commit | e3460d0094fda7dcab97d832c244d98fcf38b970 (patch) | |
tree | 9e95c2193d9c0eb665ac5ca3c7ad1abc2c1835ca | |
parent | c435113adf8af40a48780a5d07abd9e105bdbb7e (diff) | |
download | wechat_dev_tools-e3460d0094fda7dcab97d832c244d98fcf38b970.tar.gz wechat_dev_tools-e3460d0094fda7dcab97d832c244d98fcf38b970.zip |
run app/page
-rw-r--r-- | src/bundle.gleam | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/src/bundle.gleam b/src/bundle.gleam index 27cf34d..8781096 100644 --- a/src/bundle.gleam +++ b/src/bundle.gleam @@ -1,4 +1,8 @@ +import gleam/list +import gleam/result import wechat/object.{type JsObject} +import wechat/page.{run_page} +import wechat/app as weapp import app/app import app/pages/index/index @@ -6,8 +10,8 @@ import app/components/basic/basic pub type Constructor = fn() -> JsObject -pub fn app() -> Constructor { - app.app +pub fn app() -> Result(Nil, Nil) { + app.app() |> weapp.run_app |> Ok } pub fn pages() -> List(#(String, Constructor)) { @@ -17,3 +21,9 @@ pub fn pages() -> List(#(String, Constructor)) { pub fn components() -> List(#(String, Constructor)) { [#("basic", basic.component)] } + +pub fn page(ps: List(#(String, Constructor)), p: String) -> Result(Nil, Nil) { + ps + |> list.find(fn(px) { px.0 == p }) + |> result.try(fn(px) { px.1() |> run_page |> Ok}) +} |