安装插件后的基础文件

This commit is contained in:
panx
2024-07-13 12:53:20 +08:00
parent db41c93a84
commit 7f33ce4bf6
318 changed files with 31711 additions and 0 deletions

58
plugin/demo/Demo.php Normal file
View File

@@ -0,0 +1,58 @@
<?php
namespace plugin\demo;
use app\PluginController;
/**
* 演示插件
*/
class Demo extends PluginController
{
/**
* 插件安装方法
* @return bool
*/
public function install()
{
return true;
}
/**
* 插件卸载方法
* @return bool
*/
public function uninstall()
{
return true;
}
/**
* 插件启用方法
* @return bool
*/
public function enabled()
{
return true;
}
/**
* 插件禁用方法
* @return bool
*/
public function disabled()
{
return true;
}
/**
* 测试HOOK API
* 自定义钩子
* @return bool
*/
public function testhook($params)
{
var_dump('testhook');
}
}

32
plugin/demo/README.md Normal file
View File

@@ -0,0 +1,32 @@
// +----------------------------------------------------------------------
// | swiftAdmin 极速开发框架 [基于 WebMan 开发]
// +----------------------------------------------------------------------
// | Copyright (c) 2020-2099 http://www.swiftadmin.net
// +----------------------------------------------------------------------
// | swiftAdmin.net High Speed Development Framework
// +----------------------------------------------------------------------
// | Author: meystack <coolsec@foxmail.com> Apache2
// +----------------------------------------------------------------------
* app 文件夹下所有文件将复制到根目录
* public 文件夹下所有文件将复制到根目录
* data 附加文件menu.php文件插件后台菜单menu.html为插件前台菜单
* Demo.php 为插件的核心安装文件,请务必按要求书写代码
请注意钩子函数为public类型如需非钩子函数可使用protected类型
* function.php 为当前插件的函数库文件
* config.json 为当前插件的配置信息文件
* config.html 为当前配置模板,存在才会出现配置按钮
* install.sql 插件的数据库安装文件,不需要可删除!!
* uninstall.sql 插件的数据库卸载文件,不需要可删除!!
* library 该目录下为第三方类库文件,如果你的类库文件存在命名空间问题,
可手动修改或自行实现install方法将第三方类库复制到extend文件夹下

21
plugin/demo/Upgrade.php Normal file
View File

@@ -0,0 +1,21 @@
<?php
namespace plugin\demo;
/**
* 演示插件
* 升级脚本
*/
class Upgrade
{
/**
* 插件升级方法
* @access public
* @return bool
*/
public function execute()
{
var_dump('Upgrade');
return true;
}
}

View File

@@ -0,0 +1,16 @@
<?php
declare(strict_types = 1);
namespace app\admin\controller\demo;
use app\AdminController;
class Index extends AdminController{
public function index() {
echo '后台首页控制器<br/>';
return view('/demo/index/index');
}
}

View File

@@ -0,0 +1,29 @@
<?php
declare (strict_types = 1);
namespace app\admin\model;
use think\Model;
/**
* @mixin \think\Model
*/
class Demo extends Model
{
// 自动写入时间戳字段
protected $autoWriteTimestamp = 'int';
// 定义时间戳字段名
protected $createTime = 'create_time';
protected $updatetime = 'update_time';
// 字段修改器
public function setSortAttr($value)
{
if (is_empty($value)) {
return self::max('id') + 1;
}
return $value;
}
}

View File

@@ -0,0 +1,31 @@
<?php
namespace app\admin\validate;
use think\Validate;
class Demo extends Validate
{
/**
* 验证规则
*/
protected $rule = [
];
/**
* 提示消息
*/
protected $message = [
];
/**
* 验证场景
*/
protected $scene = [
'add' => [],
'edit' => [],
];
}

View File

@@ -0,0 +1,12 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>我是后台首页控制器模板</title>
</head>
<body>
我是后台首页控制器模板
</body>
</html>

View File

@@ -0,0 +1,37 @@
<?php
declare (strict_types = 1);
// +----------------------------------------------------------------------
// | swiftAdmin 极速开发框架 [基于 WebMan 开发]
// +----------------------------------------------------------------------
// | Copyright (c) 2020-2030 http://www.swiftadmin.net
// +----------------------------------------------------------------------
// | swiftAdmin.net High Speed Development Framework
// +----------------------------------------------------------------------
// | Author: meystack <coolsec@foxmail.com> Apache2 License
// +----------------------------------------------------------------------
namespace app\index\controller;
use app\HomeController;
/**
* 插件示例
*/
class Demo extends HomeController
{
/**
* 会员中心首页模板
* @return \support\Response
* @throws \Psr\SimpleCache\InvalidArgumentException
*/
public function index(): \support\Response
{
return view('/demo/index');
}
public function demo()
{
return response('demo');
}
}

View File

@@ -0,0 +1,21 @@
<layout name="layout:layout"/>
<!-- 内容主体区域 -->
<div id="content">
<div class="layui-card">
<div class="layui-card-body"> 示例页面 TODO...</div>
<!-- // 创建数据实例 -->
<table id="lay-tableList" lay-filter="lay-tableList"></table>
</div>
</div>
<!-- // 列表工具栏 -->
<script type="text/html" id="tableBar">
<!-- // TODO-->
</script>
<script>
layui.use(['table','jquery'], function () {
let $ = layui.jquery;
let table = layui.table;
})
</script>

88
plugin/demo/config.html Normal file
View File

@@ -0,0 +1,88 @@
<include file="/public/header" />
<link rel="stylesheet" type="text/css" href="__STATICADMIN__css/plugin.css?v={:release()}">
<!-- // 重定位style -->
<style>
body {
background: #fff;
}
</style>
<div class="layui-fluid">
<form action="{:url('/system/Plugin/config')}" class="layui-form layui-form-fixed" >
<input type="text" name="name" value="demo" hidden="">
<blockquote class="layui-elem-quote">配置项提示信息 TODO...</blockquote>
<div class="layui-form-item">
<label class="layui-form-label">{:__('配置项')}</label>
<div class="layui-input-block">
<input name="extends[title]"
type="text" class="layui-input"
value="{$config.extends.title}"
lay-verType="tips" lay-verify="required"
placeholder="{:__('请填写配置项')}"/>
</div>
</div>
<div class="layui-form-item">
<blockquote class="layui-elem-quote">{:__('伪静态规则')}</blockquote>
<div class="layui-card">
<table class="layui-table" lay-skin="nob">
<colgroup>
<col width="100">
<col width="200">
<col width="100">
</colgroup>
<thead>
<tr>
<th>变量名</th>
<th>变量值</th>
<th>操作</th>
</tr>
</thead>
<tbody id="layui-variable-content">
<volist name="$config['rewrite']" id="vo">
<tr>
<td><input type="text" value="{$key}" class="layui-input layui-variable-key" lay-verType="tips" lay-verify="required" ></td>
<td><input type="text" name="rewrite[{$key}]" value="{$vo}" class="layui-input layui-variable-value"></td>
<td><button type="button" class="layui-btn layui-btn-primary layui-btn-xs"><i class="layui-icon layui-icon-delete"></i></button></td>
</tr>
</volist>
</tbody>
</table>
</div>
<button type="button" class="layui-btn layui-btn-sm layui-variable-add" >{:__('增加变量')}</button>
</div>
<div class="layui-footer layui-form-item layui-center ">
<button class="layui-btn layui-btn-primary" type="button" sa-event="closeDialog">{:__('取消')}</button>
<button class="layui-btn" lay-filter="submitIframe" lay-submit>{:__('提交')}</button>
</div>
</form>
</div>
<include file="/public/footer" />
<script>
layui.use(['layer', 'admin'], function () {
var $ = layui.jquery;
var admin = layui.admin;
// 增加变量
$('.layui-variable-add').on('click',function(){
var html = '<tr>';
html += '<td><input type="text" class="layui-input layui-variable-key" lay-verType="tips" lay-verify="required" ><\/td>';
html += '<td><input type="text" class="layui-input layui-variable-value"><\/td>';
html += '<td><button type="button" class="layui-btn layui-btn-primary layui-btn-xs"><i class="layui-icon layui-icon-delete"><\/i><\/button><\/td>';
html += '<\/tr>';
$('#layui-variable-content').append(html);
})
// 改变表单值
$('body').on('change','.layui-variable-key',function() {
var that = $(this),
name = 'rewrite['+ that.val() +']';
$(that).parents('tr').find('.layui-variable-value').attr('name',name);
})
// 删除自定义变量
$('body').on('click','#layui-variable-content .layui-btn',function() {
$(this).parents('tr').remove();
})
});
</script>

24
plugin/demo/config.json Normal file
View File

@@ -0,0 +1,24 @@
{
"name": "demo",
"title": "测试插件",
"intro": "这是一个测试插件!",
"author": "官方",
"home": "https:\/\/www.swiftadmin.net",
"version": "1.0.1",
"status": 1,
"extends": {
"title": "这里是扩展配置信"
},
"rewrite": {
"\/demo1": "demo\/demo",
"\/demo2": "index\/list",
"\/demo3": "index\/query"
},
"area": [
"600px",
"650px"
],
"auto": true,
"config": 1,
"path": "\/home\/bt_www\/www\/wwwroot\/pdm.sa.webadmain.com\/plugin\/demo\/"
}

View File

@@ -0,0 +1,4 @@
<li class="layui-nav-item">
<a class="#" lay-href="/index/demo/index">演示插件</a>
</li>

16
plugin/demo/data/menu.php Normal file
View File

@@ -0,0 +1,16 @@
<?php
return [
[
'title' => '测试插件',
'router' => '/demo/Index/index',
'icon' => 'layui-icon-app',
'auth' => '1', // 是否鉴权
'children' => [
['router' => '/demo/Index/index', 'title' => '查看'],
['router' => '/demo/Index/add', 'title' => '添加'],
['router' => '/demo/Indexx/edit', 'title' => '编辑'],
['router' => '/demo/Index/execute', 'title' => '运行'],
['router' => '/demo/Indexx/del', 'title' => '删除']
]
],
];

10
plugin/demo/function.php Normal file
View File

@@ -0,0 +1,10 @@
<?php
/**
* DEMO插件函数库
*/
if (!function_exists('demo_test')) {
function demo_test() {javascript:;
echo 'demo_test function<br/>';
}
}

37
plugin/demo/install.sql Normal file
View File

@@ -0,0 +1,37 @@
/*
Navicat Premium Data Transfer
Source Server : localhost_3306
Source Server Type : MySQL
Source Server Version : 50726
Source Host : localhost:3306
Source Schema : swiftadmin
Target Server Type : MySQL
Target Server Version : 50726
File Encoding : 65001
Date: 23/03/2021 20:44:01
*/
SET NAMES utf8mb4;
SET FOREIGN_KEY_CHECKS = 0;
-- ----------------------------
-- Table structure for __PREFIX__demo
-- ----------------------------
DROP TABLE IF EXISTS `__PREFIX__demo`;
CREATE TABLE `__PREFIX__demo` (
`id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT COMMENT '主键',
`title` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '标题',
`update_time` int(11) NULL DEFAULT NULL COMMENT '更新时间',
`create_time` int(11) NULL DEFAULT NULL COMMENT '创建时间',
PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 2 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = 'demo插件数据表' ROW_FORMAT = Dynamic;
-- ----------------------------
-- Records of __PREFIX__demo
-- ----------------------------
INSERT INTO `__PREFIX__demo` VALUES (1, 'demo插件', 1602812266, 1602812266);
SET FOREIGN_KEY_CHECKS = 1;

1
plugin/demo/plugin.js Normal file
View File

@@ -0,0 +1 @@
console.log('Hello plugin!');

View File

@@ -0,0 +1 @@
// 后端JS文件

View File

@@ -0,0 +1 @@
// 前端JS文件

View File

@@ -0,0 +1 @@
DROP TABLE IF EXISTS `__PREFIX__demo`;