diff --git a/application/admin/command/Install/fastadmin.sql b/application/admin/command/Install/fastadmin.sql index 4ebc431d..2a5a8c9c 100755 --- a/application/admin/command/Install/fastadmin.sql +++ b/application/admin/command/Install/fastadmin.sql @@ -321,6 +321,7 @@ CREATE TABLE `fa_config` ( `content` text NOT NULL COMMENT '变量字典数据', `rule` varchar(100) NOT NULL DEFAULT '' COMMENT '验证规则', `extend` varchar(255) NOT NULL DEFAULT '' COMMENT '扩展属性', + `setting` varchar(255) NOT NULL DEFAULT '' COMMENT '配置', PRIMARY KEY (`id`), UNIQUE KEY `name` (`name`) ) ENGINE=InnoDB AUTO_INCREMENT=18 DEFAULT CHARSET=utf8mb4 COLLATE utf8mb4_unicode_ci COMMENT='系统配置'; @@ -329,23 +330,23 @@ CREATE TABLE `fa_config` ( -- Records of fa_config -- ---------------------------- BEGIN; -INSERT INTO `fa_config` VALUES (1, 'name', 'basic', 'Site name', '请填写站点名称', 'string', '我的网站', '', 'required', ''); -INSERT INTO `fa_config` VALUES (2, 'beian', 'basic', 'Beian', '粤ICP备15000000号-1', 'string', '', '', '', ''); -INSERT INTO `fa_config` VALUES (3, 'cdnurl', 'basic', 'Cdn url', '如果静态资源使用第三方云储存请配置该值', 'string', '', '', '', ''); -INSERT INTO `fa_config` VALUES (4, 'version', 'basic', 'Version', '如果静态资源有变动请重新配置该值', 'string', '1.0.1', '', 'required', ''); -INSERT INTO `fa_config` VALUES (5, 'timezone', 'basic', 'Timezone', '', 'string', 'Asia/Shanghai', '', 'required', ''); -INSERT INTO `fa_config` VALUES (6, 'forbiddenip', 'basic', 'Forbidden ip', '一行一条记录', 'text', '', '', '', ''); -INSERT INTO `fa_config` VALUES (7, 'languages', 'basic', 'Languages', '', 'array', '{\"backend\":\"zh-cn\",\"frontend\":\"zh-cn\"}', '', 'required', ''); -INSERT INTO `fa_config` VALUES (8, 'fixedpage', 'basic', 'Fixed page', '请尽量输入左侧菜单栏存在的链接', 'string', 'dashboard', '', 'required', ''); -INSERT INTO `fa_config` VALUES (9, 'categorytype', 'dictionary', 'Category type', '', 'array', '{\"default\":\"Default\",\"page\":\"Page\",\"article\":\"Article\",\"test\":\"Test\"}', '', '', ''); -INSERT INTO `fa_config` VALUES (10, 'configgroup', 'dictionary', 'Config group', '', 'array', '{\"basic\":\"Basic\",\"email\":\"Email\",\"dictionary\":\"Dictionary\",\"user\":\"User\",\"example\":\"Example\"}', '', '', ''); -INSERT INTO `fa_config` VALUES (11, 'mail_type', 'email', 'Mail type', '选择邮件发送方式', 'select', '1', '[\"Please select\",\"SMTP\",\"Mail\"]', '', ''); -INSERT INTO `fa_config` VALUES (12, 'mail_smtp_host', 'email', 'Mail smtp host', '错误的配置发送邮件会导致服务器超时', 'string', 'smtp.qq.com', '', '', ''); -INSERT INTO `fa_config` VALUES (13, 'mail_smtp_port', 'email', 'Mail smtp port', '(不加密默认25,SSL默认465,TLS默认587)', 'string', '465', '', '', ''); -INSERT INTO `fa_config` VALUES (14, 'mail_smtp_user', 'email', 'Mail smtp user', '(填写完整用户名)', 'string', '10000', '', '', ''); -INSERT INTO `fa_config` VALUES (15, 'mail_smtp_pass', 'email', 'Mail smtp password', '(填写您的密码)', 'string', 'password', '', '', ''); -INSERT INTO `fa_config` VALUES (16, 'mail_verify_type', 'email', 'Mail vertify type', '(SMTP验证方式[推荐SSL])', 'select', '2', '[\"None\",\"TLS\",\"SSL\"]', '', ''); -INSERT INTO `fa_config` VALUES (17, 'mail_from', 'email', 'Mail from', '', 'string', '10000@qq.com', '', '', ''); +INSERT INTO `fa_config` VALUES (1, 'name', 'basic', 'Site name', '请填写站点名称', 'string', '我的网站', '', 'required', '', ''); +INSERT INTO `fa_config` VALUES (2, 'beian', 'basic', 'Beian', '粤ICP备15000000号-1', 'string', '', '', '', '', ''); +INSERT INTO `fa_config` VALUES (3, 'cdnurl', 'basic', 'Cdn url', '如果全站静态资源使用第三方云储存请配置该值', 'string', '', '', '', '', ''); +INSERT INTO `fa_config` VALUES (4, 'version', 'basic', 'Version', '如果静态资源有变动请重新配置该值', 'string', '1.0.1', '', 'required', '', ''); +INSERT INTO `fa_config` VALUES (5, 'timezone', 'basic', 'Timezone', '', 'string', 'Asia/Shanghai', '', 'required', '', ''); +INSERT INTO `fa_config` VALUES (6, 'forbiddenip', 'basic', 'Forbidden ip', '一行一条记录', 'text', '', '', '', '', ''); +INSERT INTO `fa_config` VALUES (7, 'languages', 'basic', 'Languages', '', 'array', '{\"backend\":\"zh-cn\",\"frontend\":\"zh-cn\"}', '', 'required', '', ''); +INSERT INTO `fa_config` VALUES (8, 'fixedpage', 'basic', 'Fixed page', '请尽量输入左侧菜单栏存在的链接', 'string', 'dashboard', '', 'required', '', ''); +INSERT INTO `fa_config` VALUES (9, 'categorytype', 'dictionary', 'Category type', '', 'array', '{\"default\":\"Default\",\"page\":\"Page\",\"article\":\"Article\",\"test\":\"Test\"}', '', '', '', ''); +INSERT INTO `fa_config` VALUES (10, 'configgroup', 'dictionary', 'Config group', '', 'array', '{\"basic\":\"Basic\",\"email\":\"Email\",\"dictionary\":\"Dictionary\",\"user\":\"User\",\"example\":\"Example\"}', '', '', '', ''); +INSERT INTO `fa_config` VALUES (11, 'mail_type', 'email', 'Mail type', '选择邮件发送方式', 'select', '1', '[\"Please select\",\"SMTP\",\"Mail\"]', '', '', ''); +INSERT INTO `fa_config` VALUES (12, 'mail_smtp_host', 'email', 'Mail smtp host', '错误的配置发送邮件会导致服务器超时', 'string', 'smtp.qq.com', '', '', '', ''); +INSERT INTO `fa_config` VALUES (13, 'mail_smtp_port', 'email', 'Mail smtp port', '(不加密默认25,SSL默认465,TLS默认587)', 'string', '465', '', '', '', ''); +INSERT INTO `fa_config` VALUES (14, 'mail_smtp_user', 'email', 'Mail smtp user', '(填写完整用户名)', 'string', '10000', '', '', '', ''); +INSERT INTO `fa_config` VALUES (15, 'mail_smtp_pass', 'email', 'Mail smtp password', '(填写您的密码)', 'string', 'password', '', '', '', ''); +INSERT INTO `fa_config` VALUES (16, 'mail_verify_type', 'email', 'Mail vertify type', '(SMTP验证方式[推荐SSL])', 'select', '2', '[\"None\",\"TLS\",\"SSL\"]', '', '', ''); +INSERT INTO `fa_config` VALUES (17, 'mail_from', 'email', 'Mail from', '', 'string', '10000@qq.com', '', '', '', ''); COMMIT; -- ---------------------------- diff --git a/application/admin/controller/general/Config.php b/application/admin/controller/general/Config.php index 24b405a4..eb1739d8 100644 --- a/application/admin/controller/general/Config.php +++ b/application/admin/controller/general/Config.php @@ -5,6 +5,8 @@ namespace app\admin\controller\general; use app\common\controller\Backend; use app\common\library\Email; use app\common\model\Config as ConfigModel; +use think\Cache; +use think\Db; use think\Exception; use think\Validate; @@ -21,7 +23,7 @@ class Config extends Backend * @var \app\common\model\Config */ protected $model = null; - protected $noNeedRight = ['check', 'rulelist']; + protected $noNeedRight = ['check', 'rulelist', 'selectpage', 'get_fields_list']; public function _initialize() { @@ -82,7 +84,7 @@ class Config extends Backend $params = $this->request->post("row/a", [], 'trim'); if ($params) { foreach ($params as $k => &$v) { - $v = is_array($v) ? implode(',', $v) : $v; + $v = is_array($v) && $k !== 'setting' ? implode(',', $v) : $v; } if (in_array($params['type'], ['select', 'selects', 'checkbox', 'radio', 'array'])) { $params['content'] = json_encode(ConfigModel::decode($params['content']), JSON_UNESCAPED_UNICODE); @@ -202,12 +204,12 @@ class Config extends Backend if ($params) { $config = $this->model->get($params); if (!$config) { - return $this->success(); + $this->success(); } else { - return $this->error(__('Name already exist')); + $this->error(__('Name already exist')); } } else { - return $this->error(__('Invalid parameters')); + $this->error(__('Invalid parameters')); } } @@ -262,7 +264,51 @@ class Config extends Backend $this->error($email->getError()); } } else { - return $this->error(__('Invalid parameters')); + $this->error(__('Invalid parameters')); } } + + public function selectpage() + { + $id = $this->request->get("id/d"); + $config = \app\common\model\Config::get($id); + if (!$config) { + $this->error(__('Invalid parameters')); + } + $setting = $config['setting']; + //自定义条件 + $custom = isset($setting['conditions']) ? (array)json_decode($setting['conditions'], true) : []; + $custom = array_filter($custom); + + $this->request->request(['showField' => $setting['field'], 'keyField' => $setting['primarykey'], 'custom' => $custom, 'searchField' => [$setting['field'], $setting['primarykey']]]); + $this->model = \think\Db::connect()->setTable($setting['table']); + return parent::selectpage(); + } + + /** + * 获取表列表 + * @internal + */ + public function get_table_list() + { + $tableList = []; + $dbname = \think\Config::get('database.database'); + $tableList = \think\Db::query("SELECT `TABLE_NAME` AS `name`,`TABLE_COMMENT` AS `title` FROM `information_schema`.`TABLES` where `TABLE_SCHEMA` = '{$dbname}';"); + $this->success('', null, ['tableList' => $tableList]); + } + + /** + * 获取表字段列表 + * @internal + */ + public function get_fields_list() + { + $table = $this->request->request('table'); + $dbname = \think\Config::get('database.database'); + //从数据库中获取表字段信息 + $sql = "SELECT `COLUMN_NAME` AS `name`,`COLUMN_COMMENT` AS `title`,`DATA_TYPE` AS `type` FROM `information_schema`.`columns` WHERE TABLE_SCHEMA = ? AND TABLE_NAME = ? ORDER BY ORDINAL_POSITION"; + //加载主表的列 + $fieldList = Db::query($sql, [$dbname, $table]); + $this->success("", null, ['fieldList' => $fieldList]); + } } diff --git a/application/admin/lang/zh-cn/general/config.php b/application/admin/lang/zh-cn/general/config.php index 3904648e..242f77a6 100644 --- a/application/admin/lang/zh-cn/general/config.php +++ b/application/admin/lang/zh-cn/general/config.php @@ -33,7 +33,17 @@ return [ 'Array' => '数组', 'Array key' => '键名', 'Array value' => '键值', + 'City' => '城市地区', + 'Selectpage' => '关联表', + 'Selectpages' => '关联表(多选)', 'Custom' => '自定义', + 'Please select table' => '关联表', + 'Selectpage table' => '关联表', + 'Selectpage primarykey' => '存储字段', + 'Selectpage field' => '显示字段', + 'Selectpage conditions' => '筛选条件', + 'Field title' => '字段名', + 'Field value' => '字段值', 'Content' => '数据列表', 'Rule' => '校验规则', 'Site name' => '站点名称', diff --git a/application/admin/view/common/meta.html b/application/admin/view/common/meta.html index 1d7960a5..fe4ed3c3 100644 --- a/application/admin/view/common/meta.html +++ b/application/admin/view/common/meta.html @@ -8,6 +8,10 @@ +{if $Think.config.fastadmin.adminskin} + +{/if} + {include file="common/meta" /} - +
diff --git a/application/admin/view/index/login.html b/application/admin/view/index/login.html index e78450c6..32f47119 100644 --- a/application/admin/view/index/login.html +++ b/application/admin/view/index/login.html @@ -1,105 +1,121 @@ - - {include file="common/meta" /} + + {include file="common/meta" /} - - - -
-