use json::{JsonValue, object}; use br_plugin::Response; use br_plugin::action::Action; use br_plugin::addon::Addon; use crate::plugin::{addon, check_auth}; use crate::plugin::{{plugin}}::{{model_a}}::{{model}}; pub struct {{action}} { pub model: {{model}}, } impl Action for {{action}} { fn author(&mut self) -> &'static str { return ""; } fn title(&mut self) -> &'static str { "{{title}}" } fn api(&mut self) -> &'static str { "{{api}}" } fn auth(&mut self) -> bool { false } fn describe(&mut self) -> &'static str { "模块菜单列表" } fn params(&mut self) -> JsonValue { let params = object! {}; return params; } fn index(&mut self, header: JsonValue, _request: JsonValue) -> Response { let mode = header["custom"]["mode"].as_str().unwrap(); let mut menu = vec![]; let addon_name = self.model.addon.name(); let list = self.model.get_menu_list(mode, addon_name,""); for item in list.members() { let res = addon(item["api"].as_str().unwrap()).menu_info(""); menu.push(res); } menu = check_auth(menu, header); return self.success(menu.into(), "ok"); } }