安装 composer
https://pkg.phpcomposer.com/#how-to-install-composer/
安装 git
安装 [webman]v2 和 [tpextmyadmin] https://github.com/hi-tpext/tpextmyadmin/tree/4.5
composer create-project workerman/webman:~2.0 mywebman
cd mywebman
```bash
# 版本webman 2.0以上使用[tpext-myadmin] 4.5分支
composer require ichynul/tpextmyadmin:~4.5
#4.5分支版本不带 UI依赖 tpextbuilder
#需要选择安装一个:
composer require ichynul/tpextbuilder:~3.9
或
composer require ichynul/tpext-vexipui
或
composer require ichynul/tpext-tinyvue
#更多说明 见 https://github.com/hi-tpext/tpext-myadmin/tree/4.5安装完毕,此安装版是最小模式,只包含基本的后台功能,建议开发新项目时使用此方式。
git拉取,依次执行以下命令,
mywebman为新项目目录,可自行调整
git clone https://github.com/hi-tpext/mywebman.git mywebman
cd mywebman
composer update双击 windows.bat 或者运行 php windows.php 启动
调试方式运行(用于开发调试,打印数据会显示在终端,终端关闭后webman服务也随之关闭)
php start.php start守护进程方式运行(用于正式环境,打印数据不会显示在终端,终端关闭后webman服务会持续运行)
php start.php start -d如果有报错,很可能是有函数被禁用,参考函数禁用检查解除禁用
相关演示代码在https://github.com/hi-tpext/mywebman
app/admin/中,数据库脚本由[myadmindata]扩展提供,请下载安装。
安装完毕,此安装版是最和演示站同步的,如果你想自己搭建演示站可用此方式。
注意:此方式的仓库是不带
composer依赖vendor目录的,请务必运行composer update安装所有依赖后再访问网站。
默认开启控制器后缀:'controller_suffix' => 'Controller',
请关闭它,在config/app.php中修改为:
'controller_suffix' => '',
- 在
/config/think-orm.php中配置数据库,或在网页中配置[见下一步]
-
浏览器输入 [
http://localhost:8787/admin] 打开,如果没有事先配置数据库,将会跳转到配置数据库的页面(若不能正常跳,配置数据库后再试)。 -
自动安装基础扩展
-
手动安装 [
tpext.myadmin],确保此扩展优先,以支持其他扩展的后台菜单创建默认账号: 账号:
admin密码:tpextadmin
安装成功后自动创建id为1的超级管理员,并处于登录状态。
- 手动安装其余装扩展
- 浏览器再次输入[
http://localhost:8787/admin]打开,进入后台主页。
extend扩展基于composer.josn配置
初次安装会自动修改composer.json(命令行会提示:注册扩展目录:extend/成功,composer.json文件已修改),但修改后仍然需要下次运行composer相关命名才生效。
如果下载extend插件不能识别,提示:
执行出错:
未匹配到扩展
https://gxzrnxb27j.k.topthink.com/@tpext-docs/about.html
https://yes.shenzhuo.vip/admin
admin:tpextadmin
- 请不要乱修改数据
- 请不要上传非法内容或图片
- 请不要上传您的重要数据到上面以防泄漏
- 有问题请联系:ichynul#163.com (#换@),或通过群联系。
- 演示网站偶尔不稳定,会定期重启
1.模块化开发,核心功能都是通过 composer 安装的
- [tpext] https://www.gitlink.org.cn/hi-tpext/tpext 扩展核心
- [tpextbuilder] https://www.gitlink.org.cn/hi-tpext/tpextb-uilder UI 生成器
- [tpextmanager] https://www.gitlink.org.cn/hi-tpext/tpext-manager 管理工具
- [lightyearadmin]https://www.gitlink.org.cn/hi-tpext/lightyear-admin 基础样式库
- [tpextmyadmin] https://www.gitlink.org.cn/hi-tpext/tpext-myadmin 集成后台基础功能:权限、设置等
- [更多] https://www.gitlink.org.cn/hi-tpext/extensions/tree/main/extensions.json 查看全部扩展介绍
2.tpextbuilderUI模块基于bootstrap和Light-Year-Admin-Template的后台模板, 封装了大部分常用组件 :
Column、Row、Tab、Table、Form、Toolbar、Layer、Content
3.HasBuilder 封装了常用操作,可供控制器引入使用
Thinkphp版:https://github.com/hi-tpext/myadmin
webman插件主页:https://www.workerman.net/plugin/70
<?php
namespace app\admin\controller;
use app\common\logic\MemberLogic;
use app\common\model;
use think\Controller;
use tpext\builder\traits\HasBuilder;
/**
* Undocumented class
* @title 会员管理
*/
class Member extends Controller
{
use HasBuilder;
/**
* Undocumented variable
*
* @var model\Member
*/
protected $dataModel;
protected function initialize()
{
$this->dataModel = new model\Member;
$this->pageTitle = '会员管理';
$this->enableField = 'status';
$this->pagesize = 8;
/* 作为下拉选择数据源 相关设置 */
//显示
$this->selectTextField = '{id}#{nickname}({mobile})';
//like查询字段,$this->dataModel->where('username|nickname|mobile', 'like', $kwd);
$this->selectSearch = 'username|nickname|mobile';
}
protected function filterWhere()
{
$searchData = request()->get();
$where = [];
if (!empty($searchData['id'])) {
$where[] = ['id', 'eq', $searchData['id']];
}
if (!empty($searchData['username'])) {
$where[] = ['username', 'like', '%' . $searchData['username'] . '%'];
}
if (!empty($searchData['nickname'])) {
$where[] = ['nickname', 'like', '%' . $searchData['nickname'] . '%'];
}
if (!empty($searchData['mobile'])) {
$where[] = ['mobile', 'like', '%' . $searchData['mobile'] . '%'];
}
if (isset($searchData['status']) && $searchData['status'] != '') {
$where[] = ['status', 'eq', $searchData['status']];
}
if (isset($searchData['level']) && $searchData['level'] != '') {
$where[] = ['level', 'eq', $searchData['level']];
}
if (!empty($searchData['province'])) {
$where[] = ['province', 'eq', $searchData['province']];
if (!empty($searchData['city'])) {
$where[] = ['city', 'eq', $searchData['city']];
if (!empty($searchData['area'])) {
$where[] = ['area', 'eq', $searchData['area']];
}
}
}
return $where;
}
/**
* 构建搜索
*
* @return void
*/
protected function builSearch()
{
$search = $this->search;
$search->text('id', '会员id')->maxlength(20);
$search->text('username', '账号')->maxlength(20);
$search->text('nickname', '昵称')->maxlength(20);
$search->text('mobile', '手机号')->maxlength(20);
$search->select('level', '等级')->optionsData(model\MemberLevel::order('level')->select(), 'name', 'level')->afterOptions([0 => '普通会员']);
$search->select('status', '状态')->options([0 => '禁用', 1 => '正常']);
$search->select('province', '省份')->dataUrl(url('api/areacity/province'), 'ext_name')->withNext(
$search->select('city', '城市')->dataUrl(url('api/areacity/city'), 'ext_name')->withNext(
$search->select('area', '地区')->dataUrl(url('api/areacity/area'), 'ext_name')
)
);
}
/**
* 构建表格
*
* @return void
*/
protected function buildTable(&$data = [])
{
$table = $this->table;
$table->show('id', 'ID');
$table->image('avatar', '头像')->thumbSize(50, 50)->default('/static/images/touxiang.png');
$table->show('username', '账号');
$table->text('nickname', '昵称')->autoPost()->getWrapper()->addStyle('width:130px');
$table->show('mobile', '手机号')->getWrapper()->addStyle('width:100px');
$table->match('gender', '性别')->options([1 => '男', 2 => '女', 0 => '未知'])->getWrapper()->addStyle('width:50px');
$table->show('age', '性别');
$table->show('level_name', '等级');
$table->show('money', model\MemberAccount::$types['money']);
$table->show('points', model\MemberAccount::$types['points']);
$table->show('pca', '省市区');
$table->switchBtn('status', '状态')->default(1)->autoPost()->getWrapper()->addStyle('width:60px');
$table->show('last_login_time', '最近登录')->getWrapper()->addStyle('width:150px');
$table->show('create_time', '注册时间')->getWrapper()->addStyle('width:150px');
$table->sortable('id,sort,money,points,commission,re_comm,shares,last_login_time');
$table->getToolbar()
->btnAdd()
->btnEnableAndDisable('启用', '禁用')
->btnRefresh();
$table->getActionbar()
->btnEdit()
->btnView()
->btnLink('account', url('/admin/memberaccount/add', ['member_id' => '__data.pk__']), '', 'btn-success', 'mdi-square-inc-cash');
}
/**
* 构建表单
*
* @param boolean $isEdit
* @param array $data
*/
protected function builForm($isEdit, &$data = [])
{
$form = $this->form;
$form->tab('基本信息');
$form->image('avatar', '头像')->thumbSize(50, 50);
$form->text('username', '账号')->required()->maxlength(20);
$form->text('nickname', '昵称')->required()->maxlength(20);
$form->text('mobile', '手机号')->maxlength(11);
$form->text('email', '邮件')->maxlength(60);
$form->number('age', '年龄')->max(100)->min(1)->default(18);
$form->radio('gender', '性别')->options([0 => '未知', 1 => '男', 2 => '女'])->default(0);
$form->tab('其他信息');
$form->textarea('remark', '备注')->maxlength(255);
$form->switchBtn('status', '状态')->default(1);
if ($isEdit) {
$form->show('last_login_time', '最近登录时间');
$form->show('create_time', '注册时间');
$form->show('update_time', '修改时间');
}
}
/**
* 保存数据
*
* @param integer $id
* @return void
*/
private function save($id = 0)
{
$data = request()->only([
'avatar',
'username',
'nickname',
'mobile',
'email',
'gender',
'age',
'status',
'remark',
], 'post');
$result = $this->validate($data, [
'username|账号' => 'require',
'nickname|昵称' => 'require',
'mobile|手机号' => 'mobile',
'age|年龄' => 'number',
]);
if (true !== $result) {
$this->error($result);
}
return $this->doSave($data, $id);
}
}Tpext 系列扩展和使用了以下框架技术或受到其启发:
- webman
- Thinkphp
- Botstrap
- Lightyear-admin
- Laravel-admin
- Jquery
- Layer
- Bootstrap-number-input
- Bootstrap-duallistbox
- Bootstrap-datepicker
- Bootstrap-daterangepicker
- Bootstrap-colorpicker
- Bootstrap-maxlength
- Bootstrap-touchspin
- Webuploader
- FontIconPicker
- Select2
- Dropzone
- ZTree
- Jstree
- CKEditor
- Editormd
- Tinymce
- UEditor
- WangEditor
- AreaCity-JsSpider-StatsGov
- 等
Apache2








