File: /www/wwwroot/www.sceybwg.com/wp-content/themes/Modular/extends/wpjam-module/public/module-page.php
<?php
class WPJAM_Module_Platform{
public static function __callStatic($method, $args){
$platforms = self::get_all();
if($platforms){
$object = WPJAM_Platforms::get_instance($platforms);
return call_user_func_array([$object, $method], $args);
}
}
public static function get_all($output='names'){
return WPJAM_Platform::get_registereds(['module_page'=>true], $output);
}
public static function get($name){
$object = WPJAM_Platform::get($name);
return ($object && $object->module_page) ? $object : null;
}
public static function register($name, $args){
$object = WPJAM_Platform::get($name);
if($object){
wpjam_register_path('module_page', $name, [
'title' => '模块页面',
'page_type' => 'taxonomy',
'group' => 'tabbar',
'path' => $args['path'] ?? '',
'fields' => ['module_page_id'=>WPJAM_Module_Page::get_field()],
'callback' => [self::class, 'path_callback']
]);
if(empty($args['unit'])){
$args['unit'] = array_get($args, 'rpx') ? 'rpx' : 'px';
}
if($name == 'weapp'){
$args['qrcode'] = true;
}
return $object->update_arg('module_page', array_merge($args, ['platform'=>$name]));
}
}
public static function path_callback(...$args){
if(is_array($args[0])){
$args = $args[0];
$id = (int)wpjam_pull($args, 'module_page_id');
}else{
[$id, $args] = $args;
}
if(!$id){
return new WP_Error('empty_module_page_id', '页面ID不能为空。');
}
if(is_admin()){
$platform = self::get($args['platform']);
$tabbar = $platform->get_arg('module_page.tabbar') ?: [];
foreach($tabbar as $key => $text){
if(wpjam_get_module_default_page($args['platform'], $key) == $id){
$path = wpjam_get_path($args['platform'], $key);
if($path && !is_wp_error($path)){
return $path;
}
}
}
}
return empty($args['path']) ? get_term_link($id) : str_replace('%page_id%', $id, $args['path']);
}
}
/**
* @taxonomy module_page
**/
#[taxonomy('module_page')]
class WPJAM_Module_Page extends WPJAM_Term{
private $_modules;
public function __get($key){
if($key == 'page_id'){
return $this->id;
}elseif(in_array($key, ['data', 'module_page'])){
return self::get($this->id);
}elseif($key == 'page_width'){
return 750-2*$this->padding;
}
return parent::__get($key);
}
public function __call($method, $args){
if(str_contains($method, '_module')){
$this->_modules ??= new WPJAM_Modules($this->id);
$method = str_replace(str_contains($method, '_modules') ? '_modules' : '_module', '', $method);
return [$this->_modules, $method](...$args);
}
return method_exists(parent::class, '__call') ? parent::__call($method, $args) : new WP_Error('undefined_method', [$method]);
}
public function is_shared(){
return $this->id == self::get_shared();
}
public function is_deletable(){
$platform = array_find(self::get_platforms(), fn($platform, $pf)=> self::get_by_tabbar($pf) == $this->id);
if($platform){
return new WP_Error('home_page_indelible', '该页为'.$platform->title.'首页不可删除,请先设置其他页面为首页之后再试!');
}
if($this->get_module_ids()){
return new WP_Error('modules_exist', '请清空页面中所有模块,再删除页面!');
}
return true;
}
public function export(){
$modules = $this->parse_modules(false);
if(!$modules){
return new WP_Error('empty_modules', '未设置模块,不能导出');
}
$keys = array_reduce(wpjam_get_term_options('module_page'), fn($keys, $option)=> array_merge($keys, array_keys($option->get_fields($this->id, ''))), ['thumbnail', 'share_title']);
$meta = wpjam_fill($keys, fn($key)=> $this->meta_get($key));
wpjam_export('module_page_'.$this->id.'.txt', ['module_page'=>array_merge($this->data, ['meta_input'=>$meta]), 'modules'=>$modules]);
}
public function set_as_tabbar(...$args){
if(is_array($args[0])){
$pf = $args[0]['platform'];
$key = $args[0]['tabbar_name'];
}else{
$pf = $args[0];
$key = $args[1];
}
$result = self::update_setting(self::parse_tabbar_name($pf, $key), $this->id);
return $result ? ['bulk'=>true, 'ids'=>[$this->id, self::get_by_tabbar($pf, $key)]] : $result;
}
public function generate_path($data){
$data = array_merge($data, ['page_key'=>'module_page', 'module_page_id'=>$this->id]);
return weapp_generate_qrcode_html(array_merge($data, ['path'=>weapp_get_path('module_page', $data)]));
}
public function parse_icons(){
return WPJAM_Module_Page_Icon::parse($this->id);
}
public function parse_style($args){
if($this->padding){
$style[] = 'padding:0 '.$this->padding.$args['unit'];
}
if($this->bg_img){
$style[] = 'background:url('.wpjam_get_thumbnail($this->bg_img, [1200]).') no-repeat';
$style[] = 'background-size: 100% auto';
}
if($this->bg_color){
$style[] = 'background-color:'.$this->bg_color.'';
}
return isset($style) ? implode('; ', $style).';' : '';
}
public static function insert($data){
$result = self::is_over();
$id = is_wp_error($result) ? $result : parent::insert($data);
if(!is_wp_error($id) && wp_count_terms('module_page') <= 2){
$object = self::get_instance($id);
$result = wpjam_map(array_keys(WPJAM_Platform::get_active('module_page.tabbar.home')), fn($pf)=> $object->set_as_tabbar($pf, 'home'));
}
return $id;
}
public static function is_over(){
$max = wpjam_get_taxonomy_setting('module_page', 'max_pages');
if($max && (wp_count_terms('module_page')-1 >= $max)){
return new WP_Error('quota_exceeded', '页面最多'.$max.'个');
}
return false;
}
public static function import($data){
if(!current_user_can('manage_options')){
return new WP_Error('access_denied');
}
if(is_array($data) && isset($data['file'])){
$page = wp_array_slice_assoc($data, ['name', 'slug']);
$data = wpjam_import($data['file']);
if(is_wp_error($data)){
return $data;
}
}else{
$page = [];
}
$data = wpjam_except($data, 'slug');
if(empty($data['module_page']) || empty($data['modules'])){
return new WP_Error('invalid_module_page_data', '文件中的数据无效');
}
$page = array_merge($data['module_page'], array_filter($page));
$id = self::insert($page);
if(!is_wp_error($id)){
$object = self::get_instance($id);
$result = $object->import_modules($data['modules']);
if(is_wp_error($result)){
return $result;
}
}
return $id;
}
public static function parse($value, $type='id'){
if(is_array($value)){
$data = $value;
$value = $data['id'] ?: $data['key'];
$type = $data['id'] ? 'id' : 'key';
}
$platforms = wpjam_get_module_platforms('objects');
$platform = array_find($platforms, fn($v)=> $v && $v->get_arg('module_page') && $v->verify());
if(!$platform){
return new WP_Error('module_page_uninit', '页面模块未初始化');
}
if($type == 'id'){
$id = $value;
}else{
$pf = array_find($platforms, fn($v)=> $v && $v->get_arg('module_page.tabbar') && $v->verify());
$id = $pf ? self::get_by_tabbar($pf->name, $value) : 0;
}
$object = $id ? self::get_instance($id) : null;
if(!$object){
return new WP_Error('invalid_page_id', '无效的页面');
}
$args = $platform->get_arg('module_page');
$page = $object->parse_for_json();
$icons = $object->parse_icons();
$style = $object->parse_style($args);
return [
'page_title' => $object->name,
'share_title' => $object->share_title ?: $object->name,
'share_image' => $object->thumbnail,
'module_page' => array_merge($page, ['style'=>$style, 'icons'=>$icons]),
'icons' => $icons,
'modules' => $object->parse_modules(wp_parse_args($args, ['module_page'=>$object])),
];
}
public static function register_json($json){
if($json == 'post.list'){
add_filter('wpjam_json_args', ['WPJAM_Post_Module', 'filter_json_args'], 10, 2);
}elseif($json == 'module.page'){
wpjam_register_json($json, [
'title' => '模块页面',
'fields' => ['id'=>['type'=>'number'], 'key'=>['default'=>'']],
'callback' => [self::class, 'parse']
]);
}
}
public static function query_items($args){
$sticky = array_reduce(self::get_platforms(), fn($sticky, $platform)=> array_merge($sticky, wpjam_map(($platform->get_arg('module_page.tabbar') ?: []), fn($v, $k)=> self::get_by_tabbar($platform->name, $k))), []);
$sticky = array_unique(array_filter($sticky));
$items = get_terms(['taxonomy'=>'module_page', 'hide_empty'=>false, 'orderby'=>'term_id', 'order'=>'DESC']);
$items = wpjam_except(array_combine(wp_list_pluck($items, 'term_id'), $items), self::get_shared());
return $sticky ? wpjam_pull($items, $sticky)+$items : $items;
}
public static function render_item($item){
$thumbnail = get_term_meta($item['id'], 'thumbnail', true);
$thumbnail = $thumbnail ? wpjam_tag('img', ['src'=>wpjam_get_thumbnail($thumbnail, [120])]) : '';
$item['name'] = wpjam_tag('a', ['class'=>'wpjam-thumbnail-wrap', 'href'=>admin_url('page=wpjam-modules&page_id='.$item['id'])], $thumbnail.$item['name'])->wrap('strong').($item['description'] ? wpautop($item['description']) : '');
foreach(['modules'=>'模块', 'page-icons'=>'图标'] as $key => $text){
$item[$key] = wpjam_tag('a', ['class'=>'button', 'href'=>admin_url('page=wpjam-'.$key.'&page_id='.$item['id'])], '设置'.$text)->wrap('p');
}
$item['tabbar'] = '';
foreach(self::get_platforms() as $pf => $platform){
if($tabbar = $platform->get_arg('module_page.tabbar')){
$buttons = wpjam_map($tabbar, fn($v, $k)=> $item['id'] == self::get_by_tabbar($platform->name, $k) ? wpjam_tag('span', ['button', 'button-small', 'disabled'], $v) : '[row_action name="set_as_tabbar" id="'.$item['id'].'" data="tabbar_name='.$k.'&platform='.$pf.'" title="'.$v.'" class="button button-small"]');
$item['tabbar'] .= wpjam_wrap($platform->title, 'span', ['platform'])->after(implode(' ', $buttons))->wrap('p');
}
}
return $item;
}
public static function get_actions(){
$actions = [
'add' =>['title'=>'新建', 'dismiss'=>true],
'edit' =>['title'=>'编辑', 'order'=>20],
'export' =>['title'=>'导出', 'direct'=>true, 'export'=>true],
'import' =>['title'=>'导入', 'overall'=>true],
'delete' =>['title'=>'删除', 'direct'=>true, 'confirm'=>true, 'bulk'=>'true', 'order'=>9],
'generate_path' =>['title'=>'生成路径', 'page_title'=>'生成路径', 'response'=>'append', 'submit_text'=>''],
'set_as_tabbar' =>['title'=>'设置页面', 'direct'=>true, 'confirm'=>true, 'row_action'=>false],
];
if(WPJAM_Platform::get_active('module_page.qrcode')){
$actions['generate_path'] = ['submit_text'=>'生成二维码', 'page_title'=>'路径和二维码', 'title'=>'路径和二维码']+$actions['generate_path'];
}
return array_reduce(self::get_platforms(), fn($actions, $platform)=> $actions+($platform->get_arg('module_page.actions') ?: []), $actions);
}
public static function get_fields($action_key='', $id=0){
$platforms = self::get_platforms();
if($action_key == 'update_setting'){
$fields = $tabbar_fields = [];
foreach($platforms as $pf => $platform){
$fields = array_merge($fields, ($platform->get_arg('module_page.fields') ?: []));
$tabbar = $platform->get_arg('module_page.tabbar');
if($tabbar && $pf != 'template'){
$sub_fields = wpjam_array($tabbar, fn($k, $v)=> [self::parse_tabbar_name($pf, $k), self::get_field(['title'=>$v])]);
$tabbar_fields[$pf.'_tabbar'] = ['title'=>$platform->title, 'type'=>'fieldset', 'fields'=>$sub_fields];
}
}
return $fields+$tabbar_fields;
}elseif($action_key == 'generate_path'){
$fields = wpjam_map($platforms, fn($platform, $pf)=> ['type'=>'view', 'title'=>$platform->title.'路径', 'value'=>wpjam_get_path($pf, 'module_page', ['module_page_id'=>$id])]);
if(WPJAM_Platform::get_active('module_page.qrcode')){
$fields['width'] = ['title'=>'二维码宽度', 'type'=>'number', 'after'=>'px', 'value'=>430, 'min'=>430, 'max'=>2000, 'step'=>10];
}
}elseif($action_key == 'import'){
$fields = [
'file' => ['title'=>'页面文件', 'type'=>'uploader', 'required', 'accept'=>'.txt'],
'name' => ['title'=>'页面标题', 'type'=>'text'],
'slug' => ['title'=>'页面别名', 'type'=>'text', 'placeholder'=>'请输入英文数字-_'],
];
}else{
if($action_key == 'add'){
$result = self::is_over();
if(is_wp_error($result)){
return $result;
}
}
$fields = [
'name' => ['title'=>'页面标题', 'type'=>'text', 'show_admin_column'=>true],
'slug' => ['title'=>'页面别名', 'type'=>'text', 'placeholder'=>'请输入英文数字-_'],
'share_title' => ['title'=>'分享标题', 'type'=>'text', 'name'=>'meta_input[share_title]'],
'description' => ['title'=>'页面简介', 'type'=>'textarea', 'rows'=>3],
'thumbnail' => ['title'=>'分享图', 'type'=>'img', 'item_type'=>'url', 'name'=>'meta_input[thumbnail]'],
'modules' => ['title'=>'页面模块', 'show_admin_column'=>'only'],
'page-icons' => ['title'=>'页面图标', 'show_admin_column'=>'only'],
'tabbar' => ['title'=>'应用于', 'show_admin_column'=>'only'],
];
}
return (empty($platforms['template']) || !taxonomy_supports('module_page', 'slug')) ? wpjam_except($fields, 'slug') : $fields;
}
public static function get_field($args=[]){
return ['options'=>[self::class, 'get_options']]+wpjam_get_term_id_field('module_page', $args+['type'=>'select', 'option_all'=>false]);
}
public static function get_options(){
return wpjam_get_taxonomy_object('module_page')->get_options(['exclude'=>self::get_shared()]);
}
public static function get_by_tabbar($platform, $key=''){
$value = self::get_setting(self::parse_tabbar_name($platform, $key));
return ($value && is_array($value)) ? ($value['term_id'] ?? 0) : $value;
}
public static function parse_tabbar_name($platform, $key=''){
return wpjam_join('-', [$platform, ($key == 'home' ? '' : $key)]);
}
public static function get_setting($name='', ...$args){
return wpjam_get_setting('wpjam-module', $name) ?? array_shift($args);
}
public static function update_setting(...$args){
if(is_array($args[0]) && isset($args[0]['permastruct'])){
flush_rewrite_rules();
}
return wpjam_update_setting('wpjam-module', ...$args);
}
public static function get_shared(){
$shared = self::get_setting('shared_page');
$page = $shared ? get_term($shared, 'module_page') : null;
if(!$page || is_wp_error($page)){
$result = wp_insert_term('共用模块', 'module_page');
if(is_wp_error($result)){
if($result->get_error_code() != 'term_exists'){
return false;
}
$shared = $result->get_error_data();
}else{
$shared = $result['term_id'];
}
self::update_setting('shared_page', $shared);
}
return $shared;
}
public static function get_platforms(){
return wpjam_get_module_platforms('objects');
}
public static function get_list_table(){
wpjam_admin('style', [
'td.column-name img{object-fit:cover; width:60px; max-height:60px;}',
'td.column-name strong{font-size: larger; line-height: 1.5;}',
'td.column-tabbar p:only-child span.platform{display:none;}',
'td.column-tabbar span.platform{width:60px; display: inline-block;}'
]);
return [
'title' => '页面',
'plural' => 'module-pages',
'singular' => 'module-page',
'data_type' => 'taxonomy',
'taxonomy' => 'module_page',
'model' => self::class,
'update_setting' =>['page_title'=>'页面设置'],
];
}
public static function get_menu_page(){
if(!self::get_platforms()){
return [];
}
if(in_array($GLOBALS['plugin_page'], ['wpjam-modules', 'wpjam-page-icons'])){
$page_id = (int)wpjam_get_data_parameter('page_id');
if(!$page_id || !self::get_instance($page_id)){
wp_die('无效的页面');
}
$subs['wpjam-modules'] = [
'menu_title' => '└ 模块设置',
'page_title' => '模块设置',
'query_args' => ['page_id'],
'editor' => true,
'order' => 20,
'function' => 'list',
'list_table' => 'WPJAM_Module',
];
$subs['wpjam-page-icons'] = [
'menu_title' => '└ 图标设置',
'page_title' => '图标设置',
'query_args' => ['page_id'],
'order' => 19,
'function' => 'list',
'list_table' => [
'title' => '「'.get_term_field('name', $page_id).'」页面图标',
'plural' => 'icons',
'singular' => 'icon',
'model' => 'WPJAM_Module_Page_Icon',
'sortable' => true,
]
];
}
$subs['wpjam-shared-modules'] = [
'menu_title' => '共用模块',
'function' => 'list',
'defaults' => ['page_id'=>self::get_shared()],
'list_table' => 'WPJAM_Module',
];
if(WPJAM_Module_Page_Template::get_dir()){
$subs['wpjam-page-templates'] = [
'menu_title' => '公共模板',
'function' => 'list',
'list_table' => [
'plural' => 'templates',
'singular' => 'template',
'primary_key' => 'template',
'primary_column' => 'name',
'model' => 'WPJAM_Module_Page_Template',
],
];
}
return [
'menu_slug' => 'wpjam-pages',
'menu_title' => '页面管理',
'icon' => 'ri-pages-fill',
'position' => '3.111',
'function' => 'list',
'editor' => true,
'list_table' => 'WPJAM_Module_Page',
'subs' => $subs
];
}
public static function on_after_setup_theme(){
if(locate_template('taxonomy-module_page.php')){
$options = [
'%module_page%' => home_url('别名'),
'module/page/%module_page%' => home_url('module/page/别名'),
'module/page/%module_page_id%' => home_url('module/page/ID')
];
wpjam_register_module_platform('template', [
'title' => '网页',
'path' => '',
'tabbar' => self::get_setting('home_page', true) ? ['home'=>'首页'] : [],
'actions' => ['view' =>['title'=>'查看', 'redirect'=>fn($id)=>get_term_link($id)]],
'fields' => [
'permastruct' => ['title'=>'固定链接', 'type'=>'select', 'options'=>$options],
'home_set' => ['title'=>'网站首页', 'type'=>'fields', 'sep'=>' ', 'fields'=>[
'home_page' => ['type'=>'checkbox', 'label'=>'网站首页也使用模块页面', 'value'=>1, 'fields'=>['template'=>self::get_field(['title'=>''])]],
]],
]
]);
wpjam_register_module_platform('mobile', ['title'=>'移动网页', 'path'=>'']);
wpjam_update_taxonomy_setting('module_page', 'show_in_nav_menus', true);
wpjam_update_taxonomy_setting('module_page', 'permastruct', self::get_setting('permastruct', 'module/page/%module_page_id%'));
add_action('pre_get_posts', [self::class, 'on_pre_get_posts']);
}
}
public static function on_pre_get_posts($wp_query){
if($wp_query->is_main_query()){
if($wp_query->is_tax('module_page')){
$wp_query->set('post_type', 'module');
$is_module_page = true;
}elseif($wp_query->is_home() && !wpjam_get_query_var('module') && self::get_setting('home_page', true)){
$id = self::get_by_tabbar('template');
if($id){
$wp_query->set('post_type', 'module');
$wp_query->set('tax_query', [[
'taxonomy' => 'module_page',
'terms' => [$id],
'field' => 'term_id',
]]);
$is_module_page = true;
}
}
if(!empty($is_module_page)){
add_filter('template_include', fn()=> locate_template('taxonomy-module_page.php'));
}
}
}
public static function add_hooks(){
add_action('after_setup_theme', [self::class, 'on_after_setup_theme']);
add_action('wp_loaded', fn() => do_action('wpjam_module_loaded'));
}
}
class WPJAM_Module_Page_Icon{
public static function __callStatic($method, $args){
return wpjam_call_handler(self::get_handler(), $method, ...$args);
}
public static function get_handler($id=null){
$id ??= (int)wpjam_get_data_parameter('page_id');
return wpjam_get_handler('wpjam_module_page_icon:'.$id, function($name){
wpjam_register_path('top', [
'title' => '回到顶部',
'path' => false,
'platform' => wpjam_get_current_platforms(),
'callback' => fn()=> ['type'=>'top']
]);
return [
'items_type' => 'meta',
'meta_type' => 'term',
'object_id' => explode(':', $name)[1],
'meta_key' => 'icons',
'primary_title' => '图标',
'max_items' => 4
];
}, $id);
}
public static function parse($id){
$handler = static::get_handler($id);
$items = $handler->get_items();
foreach($items as &$item){
$name = $item['name'] ?? '';
$icon = $item['icon'] ? wpjam_get_thumbnail($item['icon'], '120x120') : '';
$item = WPJAM_Module_Platform::parse_item($item)+['name'=>$name, 'icon'=>$icon];
}
return array_values($items);
}
public static function get_actions(){
return [
'add' => ['title'=>'新建', 'dismiss'=>true],
'edit' => ['title'=>'编辑'],
'delete' => ['title'=>'删除', 'direct'=>true, 'confirm'=>true, 'bulk'=>true],
'reset' => ['title'=>'重置', 'direct'=>true, 'confirm'=>true, 'overall'=>true],
];
}
public static function get_fields($action_key='', $id=0){
$fields = wpjam_get_module_path_fields();
$fields['page_key_set']['fields']['page_key'] += ['show_admin_column'=>true, 'column_title'=>'页面'];
return [
'name' => ['title'=>'名称', 'type'=>'text', 'show_admin_column'=>true, 'required'],
'icon' => ['title'=>'图标', 'type'=>'img', 'column'=>['render'=>true], 'item_type'=>'url', 'required', 'size'=>'120x0'],
]+$fields;
}
}
class WPJAM_Module_Page_Template{
public static function get_dir(){
$dir = wpjam_get_taxonomy_setting('module_page', 'template_dir');
return ($dir && is_dir($dir)) ? $dir : false;
}
public static function set_dir($dir=''){
wpjam_update_taxonomy_setting('module_page', 'template_dir', $dir);
}
public static function apply($template){
$file = self::get_dir().$template;
return is_file($file) ? WPJAM_Module_Page::import(maybe_unserialize(file_get_contents($file))) : wp_die('无效的公共模板');
}
public static function query_items($args){
$dir = self::get_dir();
$items = [];
if($handle = opendir($dir)){
while(($template = readdir($handle)) !== false){
if($template == '.' || $template == '..' || is_dir($dir.$template)){
continue;
}
$data = maybe_unserialize(file_get_contents($dir.$template));
if(empty($data) || empty($data['module_page']) || empty($data['modules'])){
continue;
}
$items[] = array_merge($data['module_page'], ['template'=>$template]);
}
closedir($handle);
}
return $items;
}
public static function get_actions(){
return ['apply' =>['title'=>'复制到我的页面', 'direct'=>true, 'confirm'=>true, 'response'=>'list']];
}
public static function get_fields($action_key='', $id=0){
return [
'thumbnail' => ['title'=>'分享图', 'type'=>'img', 'column'=>['render'=>true], 'size'=>'120x0'],
'name' => ['title'=>'标题', 'type'=>'text', 'show_admin_column'=>true],
'description' => ['title'=>'简介', 'type'=>'textarea', 'column'=>['render'=>'wpautop']],
];
}
}
function wpjam_register_module_platform($name, $args){
return WPJAM_Module_Platform::register($name, $args);
}
function wpjam_get_module_platforms($output='names'){
return WPJAM_Module_Platform::get_all($output);
}
function wpjam_get_module_path_fields($prepend_name=''){
return WPJAM_Module_Platform::get_fields(compact('prepend_name'));
}
function wpjam_set_max_module_pages($value){
wpjam_update_taxonomy_setting('module_page', 'max_pages', $value);
}
function wpjam_set_module_page_template_dir($dir=''){
WPJAM_Module_Page_Template::set_dir($dir);
}
function wpjam_get_module_default_page($platform, $key=''){
return WPJAM_Module_Page::get_by_tabbar($platform, $key);
}
wpjam_register_taxonomy('module_page', [
'label' => '模块页面',
'object_type' => ['module'],
'model' => 'WPJAM_Module_Page',
'max_pages' => 10,
'public' => true,
'show_ui' => false,
'rewrite' => false,
'query_var' => false,
'hierarchical' => false,
'options' => ['style' => [
'title' => '页面样式',
'page_title' => '设置页面样式',
'submit_text' => '设置',
'order' => 19,
'fields' => [
'bg_color' => ['title'=>'背景色', 'type'=>'color', 'value'=>''],
'bg_img' => ['title'=>'背景图', 'type'=>'img', 'value'=>'', 'item_type'=>'url', 'size'=>'1200x'],
'padding' => ['title'=>'左右边距', 'type'=>'number', 'max'=>20],
'border_radius' => ['title'=>'模块圆角', 'type'=>'select', 'show_in_rest'=>['type'=>'integer'], 'options'=>[0=>'关闭', 10=>'开启']]
]
]]
]);