update
This commit is contained in:
1
addons/.gitkeep
Normal file
1
addons/.gitkeep
Normal file
@@ -0,0 +1 @@
|
||||
|
||||
1
addons/.htaccess
Normal file
1
addons/.htaccess
Normal file
@@ -0,0 +1 @@
|
||||
deny from all
|
||||
1
addons/alisms/.addonrc
Normal file
1
addons/alisms/.addonrc
Normal file
@@ -0,0 +1 @@
|
||||
{"files":[],"license":"extended","licenseto":"10836","licensekey":"jxn5E1hW0TPR2yGK fdqVjV6k9iz5iqRCHoaYCQ==","domains":["localhost"],"licensecodes":[],"validations":["757319b447175b6ca1882635b132a594"]}
|
||||
83
addons/alisms/Alisms.php
Normal file
83
addons/alisms/Alisms.php
Normal file
@@ -0,0 +1,83 @@
|
||||
<?php
|
||||
|
||||
namespace addons\alisms;
|
||||
|
||||
use think\Addons;
|
||||
|
||||
/**
|
||||
* Alisms
|
||||
*/
|
||||
class Alisms extends Addons
|
||||
{
|
||||
|
||||
/**
|
||||
* 插件安装方法
|
||||
* @return bool
|
||||
*/
|
||||
public function install()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 插件卸载方法
|
||||
* @return bool
|
||||
*/
|
||||
public function uninstall()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 短信发送行为
|
||||
* @param array $params 必须包含mobile,event,code
|
||||
* @return boolean
|
||||
*/
|
||||
public function smsSend(&$params)
|
||||
{
|
||||
$config = get_addon_config('alisms');
|
||||
$alisms = new \addons\alisms\library\Alisms();
|
||||
$result = $alisms->mobile($params['mobile'])
|
||||
->template($config['template'][$params['event']])
|
||||
->param(['code' => $params['code']])
|
||||
->send();
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 短信发送通知
|
||||
* @param array $params 必须包含 mobile,event,msg
|
||||
* @return boolean
|
||||
*/
|
||||
public function smsNotice(&$params)
|
||||
{
|
||||
$config = get_addon_config('alisms');
|
||||
$alisms = \addons\alisms\library\Alisms::instance();
|
||||
if (isset($params['msg'])) {
|
||||
if (is_array($params['msg'])) {
|
||||
$param = $params['msg'];
|
||||
} else {
|
||||
parse_str($params['msg'], $param);
|
||||
}
|
||||
} else {
|
||||
$param = [];
|
||||
}
|
||||
$param = $param ? $param : [];
|
||||
$params['template'] = isset($params['template']) ? $params['template'] : (isset($params['event']) && isset($config['template'][$params['event']]) ? $config['template'][$params['event']] : '');
|
||||
$result = $alisms->mobile($params['mobile'])
|
||||
->template($params['template'])
|
||||
->param($param)
|
||||
->send();
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 检测验证是否正确
|
||||
* @param $params
|
||||
* @return boolean
|
||||
*/
|
||||
public function smsCheck(&$params)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
66
addons/alisms/config.php
Normal file
66
addons/alisms/config.php
Normal file
@@ -0,0 +1,66 @@
|
||||
<?php
|
||||
|
||||
return [
|
||||
[
|
||||
'name' => 'key',
|
||||
'title' => '应用key',
|
||||
'type' => 'string',
|
||||
'content' => [],
|
||||
'value' => 'LTAI5t6oEsk1iPSXenJfDAxY',
|
||||
'rule' => 'required',
|
||||
'msg' => '',
|
||||
'tip' => '',
|
||||
'ok' => '',
|
||||
'extend' => '',
|
||||
],
|
||||
[
|
||||
'name' => 'secret',
|
||||
'title' => '密钥secret',
|
||||
'type' => 'string',
|
||||
'content' => [],
|
||||
'value' => 'tvbeWgGITSWFaen2OAoolITz3t6UWR',
|
||||
'rule' => 'required',
|
||||
'msg' => '',
|
||||
'tip' => '',
|
||||
'ok' => '',
|
||||
'extend' => '',
|
||||
],
|
||||
[
|
||||
'name' => 'sign',
|
||||
'title' => '签名',
|
||||
'type' => 'string',
|
||||
'content' => [],
|
||||
'value' => '域展科技',
|
||||
'rule' => 'required',
|
||||
'msg' => '',
|
||||
'tip' => '',
|
||||
'ok' => '',
|
||||
'extend' => '',
|
||||
],
|
||||
[
|
||||
'name' => 'template',
|
||||
'title' => '短信模板',
|
||||
'type' => 'array',
|
||||
'content' => [],
|
||||
'value' => [
|
||||
'adminlogin' => 'SMS_176560077',
|
||||
],
|
||||
'rule' => 'required',
|
||||
'msg' => '',
|
||||
'tip' => '',
|
||||
'ok' => '',
|
||||
'extend' => '',
|
||||
],
|
||||
[
|
||||
'name' => '__tips__',
|
||||
'title' => '温馨提示',
|
||||
'type' => 'string',
|
||||
'content' => [],
|
||||
'value' => '应用key和密钥你可以通过 https://ak-console.aliyun.com/?spm=a2c4g.11186623.2.13.fd315777PX3tjy#/accesskey 获取',
|
||||
'rule' => 'required',
|
||||
'msg' => '',
|
||||
'tip' => '',
|
||||
'ok' => '',
|
||||
'extend' => '',
|
||||
],
|
||||
];
|
||||
52
addons/alisms/controller/Index.php
Normal file
52
addons/alisms/controller/Index.php
Normal file
@@ -0,0 +1,52 @@
|
||||
<?php
|
||||
|
||||
namespace addons\alisms\controller;
|
||||
|
||||
use think\addons\Controller;
|
||||
|
||||
/**
|
||||
* 阿里短信
|
||||
*/
|
||||
class Index extends Controller
|
||||
{
|
||||
|
||||
protected $model = null;
|
||||
|
||||
public function _initialize()
|
||||
{
|
||||
if (!\app\admin\library\Auth::instance()->id) {
|
||||
$this->error('暂无权限浏览');
|
||||
}
|
||||
parent::_initialize();
|
||||
}
|
||||
|
||||
public function index()
|
||||
{
|
||||
return $this->view->fetch();
|
||||
}
|
||||
|
||||
public function send()
|
||||
{
|
||||
$config = get_addon_config('alisms');
|
||||
$mobile = $this->request->post('mobile');
|
||||
$template = $this->request->post('template');
|
||||
$sign = $this->request->post('sign');
|
||||
if (!$mobile || !$template) {
|
||||
$this->error('手机号、模板ID不能为空');
|
||||
}
|
||||
$sign = $sign ? $sign : $config['sign'];
|
||||
$param = (array)json_decode($this->request->post('param', '', 'trim'));
|
||||
$alisms = new \addons\alisms\library\Alisms();
|
||||
$ret = $alisms->mobile($mobile)
|
||||
->template($template)
|
||||
->sign($sign)
|
||||
->param($param)
|
||||
->send();
|
||||
if ($ret) {
|
||||
$this->success("发送成功");
|
||||
} else {
|
||||
$this->error("发送失败!失败原因:" . $alisms->getError());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
10
addons/alisms/info.ini
Normal file
10
addons/alisms/info.ini
Normal file
@@ -0,0 +1,10 @@
|
||||
name = alisms
|
||||
title = 阿里云短信发送
|
||||
intro = 阿里云短信发送插件
|
||||
author = FastAdmin
|
||||
website = https://www.fastadmin.net
|
||||
version = 1.0.9
|
||||
state = 1
|
||||
url = /putoufy/public/addons/alisms
|
||||
license = extended
|
||||
licenseto = 10836
|
||||
170
addons/alisms/library/Alisms.php
Normal file
170
addons/alisms/library/Alisms.php
Normal file
@@ -0,0 +1,170 @@
|
||||
<?php
|
||||
|
||||
namespace addons\alisms\library;
|
||||
|
||||
/**
|
||||
* 阿里大于SMS短信发送
|
||||
*/
|
||||
class Alisms
|
||||
{
|
||||
private $_params = [];
|
||||
public $error = '';
|
||||
protected $config = [];
|
||||
protected static $instance;
|
||||
|
||||
public function __construct($options = [])
|
||||
{
|
||||
if ($config = get_addon_config('alisms')) {
|
||||
$this->config = array_merge($this->config, $config);
|
||||
}
|
||||
$this->config = array_merge($this->config, is_array($options) ? $options : []);
|
||||
}
|
||||
|
||||
/**
|
||||
* 单例
|
||||
* @param array $options 参数
|
||||
* @return Alisms
|
||||
*/
|
||||
public static function instance($options = [])
|
||||
{
|
||||
if (is_null(self::$instance)) {
|
||||
self::$instance = new static($options);
|
||||
}
|
||||
|
||||
return self::$instance;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置签名
|
||||
* @param string $sign
|
||||
* @return Alisms
|
||||
*/
|
||||
public function sign($sign = '')
|
||||
{
|
||||
$this->_params['SignName'] = $sign;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置参数
|
||||
* @param array $param
|
||||
* @return Alisms
|
||||
*/
|
||||
public function param(array $param = [])
|
||||
{
|
||||
foreach ($param as $k => &$v) {
|
||||
$v = (string)$v;
|
||||
}
|
||||
unset($v);
|
||||
$param = array_filter($param);
|
||||
$this->_params['TemplateParam'] = $param ? json_encode($param) : '{}';
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置模板
|
||||
* @param string $code 短信模板
|
||||
* @return Alisms
|
||||
*/
|
||||
public function template($code = '')
|
||||
{
|
||||
$this->_params['TemplateCode'] = $code;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 接收手机
|
||||
* @param string $mobile 手机号码
|
||||
* @return Alisms
|
||||
*/
|
||||
public function mobile($mobile = '')
|
||||
{
|
||||
$this->_params['PhoneNumbers'] = $mobile;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 立即发送
|
||||
* @return boolean
|
||||
*/
|
||||
public function send()
|
||||
{
|
||||
$this->error = '';
|
||||
$params = $this->_params();
|
||||
$params['Signature'] = $this->_signed($params);
|
||||
$response = $this->_curl($params);
|
||||
if ($response !== false) {
|
||||
$res = (array)json_decode($response, true);
|
||||
if (isset($res['Code']) && $res['Code'] == 'OK') {
|
||||
return true;
|
||||
}
|
||||
$this->error = isset($res['Message']) ? $res['Message'] : 'InvalidResult';
|
||||
} else {
|
||||
$this->error = 'InvalidResult';
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取错误信息
|
||||
* @return string
|
||||
*/
|
||||
public function getError()
|
||||
{
|
||||
return $this->error;
|
||||
}
|
||||
|
||||
private function _params()
|
||||
{
|
||||
return array_merge([
|
||||
'AccessKeyId' => $this->config['key'],
|
||||
'SignName' => isset($this->config['sign']) ? $this->config['sign'] : '',
|
||||
'Action' => 'SendSms',
|
||||
'Format' => 'JSON',
|
||||
'Version' => '2017-05-25',
|
||||
'SignatureVersion' => '1.0',
|
||||
'SignatureMethod' => 'HMAC-SHA1',
|
||||
'SignatureNonce' => uniqid(),
|
||||
'Timestamp' => gmdate('Y-m-d\TH:i:s\Z'),
|
||||
], $this->_params);
|
||||
}
|
||||
|
||||
private function percentEncode($string)
|
||||
{
|
||||
$string = urlencode($string);
|
||||
$string = preg_replace('/\+/', '%20', $string);
|
||||
$string = preg_replace('/\*/', '%2A', $string);
|
||||
$string = preg_replace('/%7E/', '~', $string);
|
||||
return $string;
|
||||
}
|
||||
|
||||
private function _signed($params)
|
||||
{
|
||||
$sign = $this->config['secret'];
|
||||
ksort($params);
|
||||
$canonicalizedQueryString = '';
|
||||
foreach ($params as $key => $value) {
|
||||
$canonicalizedQueryString .= '&' . $this->percentEncode($key) . '=' . $this->percentEncode($value);
|
||||
}
|
||||
$stringToSign = 'GET&%2F&' . $this->percentencode(substr($canonicalizedQueryString, 1));
|
||||
$signature = base64_encode(hash_hmac('sha1', $stringToSign, $sign . '&', true));
|
||||
return $signature;
|
||||
}
|
||||
|
||||
private function _curl($params)
|
||||
{
|
||||
$uri = 'http://dysmsapi.aliyuncs.com/?' . http_build_query($params);
|
||||
$ch = curl_init();
|
||||
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
|
||||
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
|
||||
curl_setopt($ch, CURLOPT_URL, $uri);
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 5);
|
||||
curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/45.0.2454.98 Safari/537.36");
|
||||
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
|
||||
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
|
||||
$reponse = curl_exec($ch);
|
||||
curl_close($ch);
|
||||
return $reponse;
|
||||
}
|
||||
}
|
||||
75
addons/alisms/view/index/index.html
Normal file
75
addons/alisms/view/index/index.html
Normal file
@@ -0,0 +1,75 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8"/>
|
||||
<title>阿里云通信短信发送示例 - FastAdmin</title>
|
||||
|
||||
<!-- Bootstrap Core CSS -->
|
||||
<link href="https://cdn.staticfile.org/twitter-bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet">
|
||||
|
||||
<!-- Custom CSS -->
|
||||
<link href="__CDN__/assets/css/frontend.css" rel="stylesheet">
|
||||
|
||||
<!-- Plugin CSS -->
|
||||
<link href="https://cdn.staticfile.org/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet">
|
||||
<link href="https://cdn.staticfile.org/simple-line-icons/2.4.1/css/simple-line-icons.min.css" rel="stylesheet">
|
||||
|
||||
<!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
|
||||
<!--[if lt IE 9]>
|
||||
<script src="https://cdn.staticfile.org/html5shiv/3.7.3/html5shiv.min.js"></script>
|
||||
<script src="https://cdn.staticfile.org/respond.js/1.4.2/respond.min.js"></script>
|
||||
<![endif]-->
|
||||
</head>
|
||||
<body>
|
||||
<div class="container">
|
||||
<div class="well" style="margin-top:30px;">
|
||||
<form class="form-horizontal" action="{:addon_url('alisms/index/send')}" method="POST">
|
||||
<fieldset>
|
||||
<legend>阿里云通信短信发送</legend>
|
||||
<div class="form-group">
|
||||
<label class="col-lg-2 control-label">手机号</label>
|
||||
<div class="col-lg-10">
|
||||
<input type="text" class="form-control" name="mobile" placeholder="手机号">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="col-lg-2 control-label">消息模板ID</label>
|
||||
<div class="col-lg-10">
|
||||
<input type="text" class="form-control" name="template" placeholder="消息模板ID,从阿里云通信获得,通常是:SMS_114000000这种格式">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="col-lg-2 control-label">签名</label>
|
||||
<div class="col-lg-10">
|
||||
<input type="text" class="form-control" name="sign" placeholder="消息模板(可以留空,留空使用后台插件管理中的配置)">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="col-lg-2 control-label">模板变量参数</label>
|
||||
<div class="col-lg-10">
|
||||
<textarea name="param" class="form-control" cols="30" rows="10" placeholder='必须是JSON字符串,如{"name":"李明"}'></textarea>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<div class="col-lg-10 col-lg-offset-2">
|
||||
<button type="submit" class="btn btn-primary">发送</button>
|
||||
<button type="reset" class="btn btn-default">重置</button>
|
||||
</div>
|
||||
</div>
|
||||
</fieldset>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
<!-- jQuery -->
|
||||
<script src="https://cdn.staticfile.org/jquery/2.1.4/jquery.min.js"></script>
|
||||
|
||||
<!-- Bootstrap Core JavaScript -->
|
||||
<script src="https://cdn.staticfile.org/twitter-bootstrap/3.3.7/js/bootstrap.min.js"></script>
|
||||
|
||||
<script type="text/javascript">
|
||||
$(function () {
|
||||
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
1
addons/command/.addonrc
Normal file
1
addons/command/.addonrc
Normal file
@@ -0,0 +1 @@
|
||||
{"files":["application\\admin\\controller\\Command.php","application\\admin\\lang\\zh-cn\\command.php","application\\admin\\model\\Command.php","application\\admin\\validate\\Command.php","application\\admin\\view\\command\\add.html","application\\admin\\view\\command\\detail.html","application\\admin\\view\\command\\index.html","public\\assets\\js\\backend\\command.js"],"license":"regular","licenseto":"6223","licensekey":"rKTYoS1sgHL8izbp ZQeoL2x4s2yxbmzh7HAICQ==","domains":["hphb.com"],"licensecodes":[],"validations":["f8b7a3069155d30685a8a2976040a1d7"],"menus":["command","command\/index","command\/add","command\/detail","command\/execute","command\/del","command\/multi"]}
|
||||
69
addons/command/Command.php
Normal file
69
addons/command/Command.php
Normal file
@@ -0,0 +1,69 @@
|
||||
<?php
|
||||
|
||||
namespace addons\command;
|
||||
|
||||
use app\common\library\Menu;
|
||||
use think\Addons;
|
||||
|
||||
/**
|
||||
* 在线命令插件
|
||||
*/
|
||||
class Command extends Addons
|
||||
{
|
||||
|
||||
/**
|
||||
* 插件安装方法
|
||||
* @return bool
|
||||
*/
|
||||
public function install()
|
||||
{
|
||||
$menu = [
|
||||
[
|
||||
'name' => 'command',
|
||||
'title' => '在线命令管理',
|
||||
'icon' => 'fa fa-terminal',
|
||||
'sublist' => [
|
||||
['name' => 'command/index', 'title' => '查看'],
|
||||
['name' => 'command/add', 'title' => '添加'],
|
||||
['name' => 'command/detail', 'title' => '详情'],
|
||||
['name' => 'command/execute', 'title' => '运行'],
|
||||
['name' => 'command/del', 'title' => '删除'],
|
||||
['name' => 'command/multi', 'title' => '批量更新'],
|
||||
]
|
||||
]
|
||||
];
|
||||
Menu::create($menu);
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 插件卸载方法
|
||||
* @return bool
|
||||
*/
|
||||
public function uninstall()
|
||||
{
|
||||
Menu::delete('command');
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 插件启用方法
|
||||
* @return bool
|
||||
*/
|
||||
public function enable()
|
||||
{
|
||||
Menu::enable('command');
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 插件禁用方法
|
||||
* @return bool
|
||||
*/
|
||||
public function disable()
|
||||
{
|
||||
Menu::disable('command');
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
4
addons/command/config.php
Normal file
4
addons/command/config.php
Normal file
@@ -0,0 +1,4 @@
|
||||
<?php
|
||||
|
||||
return [
|
||||
];
|
||||
15
addons/command/controller/Index.php
Normal file
15
addons/command/controller/Index.php
Normal file
@@ -0,0 +1,15 @@
|
||||
<?php
|
||||
|
||||
namespace addons\command\controller;
|
||||
|
||||
use think\addons\Controller;
|
||||
|
||||
class Index extends Controller
|
||||
{
|
||||
|
||||
public function index()
|
||||
{
|
||||
$this->error("当前插件暂无前台页面");
|
||||
}
|
||||
|
||||
}
|
||||
10
addons/command/info.ini
Normal file
10
addons/command/info.ini
Normal file
@@ -0,0 +1,10 @@
|
||||
name = command
|
||||
title = 在线命令
|
||||
intro = 可在线执行一键生成CRUD、一键生成菜单等相关命令
|
||||
author = FastAdmin
|
||||
website = https://www.fastadmin.net
|
||||
version = 1.1.0
|
||||
state = 1
|
||||
url = /addons/command
|
||||
license = regular
|
||||
licenseto = 6223
|
||||
12
addons/command/install.sql
Normal file
12
addons/command/install.sql
Normal file
@@ -0,0 +1,12 @@
|
||||
CREATE TABLE IF NOT EXISTS `__PREFIX__command` (
|
||||
`id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT COMMENT 'ID',
|
||||
`type` varchar(30) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT '' COMMENT '类型',
|
||||
`params` varchar(1500) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT '' COMMENT '参数',
|
||||
`command` varchar(1500) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT '' COMMENT '命令',
|
||||
`content` text COMMENT '返回结果',
|
||||
`executetime` bigint(16) UNSIGNED DEFAULT NULL COMMENT '执行时间',
|
||||
`createtime` bigint(16) UNSIGNED DEFAULT NULL COMMENT '创建时间',
|
||||
`updatetime` bigint(16) UNSIGNED DEFAULT NULL COMMENT '更新时间',
|
||||
`status` enum('successed','failured') CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT 'failured' COMMENT '状态',
|
||||
PRIMARY KEY (`id`) USING BTREE
|
||||
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '在线命令表';
|
||||
28
addons/command/library/Output.php
Normal file
28
addons/command/library/Output.php
Normal file
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
namespace addons\command\library;
|
||||
|
||||
/**
|
||||
* Class Output
|
||||
*/
|
||||
class Output extends \think\console\Output
|
||||
{
|
||||
|
||||
protected $message = [];
|
||||
|
||||
public function __construct($driver = 'console')
|
||||
{
|
||||
parent::__construct($driver);
|
||||
}
|
||||
|
||||
protected function block($style, $message)
|
||||
{
|
||||
$this->message[] = $message;
|
||||
}
|
||||
|
||||
public function getMessage()
|
||||
{
|
||||
return $this->message;
|
||||
}
|
||||
|
||||
}
|
||||
1
addons/summernote/.addonrc
Normal file
1
addons/summernote/.addonrc
Normal file
@@ -0,0 +1 @@
|
||||
{"files":["public\/assets\/addons\/summernote\/css\/summernote.css","public\/assets\/addons\/summernote\/js\/summernote.js","public\/assets\/addons\/summernote\/js\/summernote.min.js","public\/assets\/addons\/summernote\/lang\/summernote-zh-TW.min.js","public\/assets\/addons\/summernote\/lang\/summernote-zh-TW.js","public\/assets\/addons\/summernote\/lang\/summernote-zh-CN.js","public\/assets\/addons\/summernote\/lang\/summernote-zh-CN.min.js","public\/assets\/addons\/summernote\/font\/summernote.ttf","public\/assets\/addons\/summernote\/font\/summernote.woff","public\/assets\/addons\/summernote\/font\/summernote.eot"],"license":"regular","licenseto":"21507","licensekey":"mK31hOzoPLxQ4Sv0 6wgXqM\/dVaxP5Smu6cO3DmiKYrZKyhjsQvIWgDzy6AQ=","domains":["localhost"],"licensecodes":[],"validations":["757319b447175b6ca1882635b132a594"]}
|
||||
40
addons/summernote/Summernote.php
Normal file
40
addons/summernote/Summernote.php
Normal file
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
namespace addons\summernote;
|
||||
|
||||
use think\Addons;
|
||||
|
||||
/**
|
||||
* Summernote富文本编辑器
|
||||
*/
|
||||
class Summernote extends Addons
|
||||
{
|
||||
|
||||
/**
|
||||
* 插件安装方法
|
||||
* @return bool
|
||||
*/
|
||||
public function install()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 插件卸载方法
|
||||
* @return bool
|
||||
*/
|
||||
public function uninstall()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $params
|
||||
*/
|
||||
public function configInit(&$params)
|
||||
{
|
||||
$config = $this->getConfig();
|
||||
$params['summernote'] = ['classname' => $config['classname'] ?? '.editor'];
|
||||
}
|
||||
|
||||
}
|
||||
116
addons/summernote/bootstrap.js
vendored
Normal file
116
addons/summernote/bootstrap.js
vendored
Normal file
@@ -0,0 +1,116 @@
|
||||
require.config({
|
||||
paths: {
|
||||
'summernote': '../addons/summernote/lang/summernote-zh-CN.min'
|
||||
},
|
||||
shim: {
|
||||
'summernote': ['../addons/summernote/js/summernote.min', 'css!../addons/summernote/css/summernote.css'],
|
||||
}
|
||||
});
|
||||
require(['form', 'upload'], function (Form, Upload) {
|
||||
var _bindevent = Form.events.bindevent;
|
||||
Form.events.bindevent = function (form) {
|
||||
_bindevent.apply(this, [form]);
|
||||
try {
|
||||
//绑定summernote事件
|
||||
if ($(Config.summernote.classname || '.editor', form).size() > 0) {
|
||||
var selectUrl = typeof Config !== 'undefined' && Config.modulename === 'index' ? 'user/attachment' : 'general/attachment/select';
|
||||
require(['summernote'], function () {
|
||||
var imageButton = function (context) {
|
||||
var ui = $.summernote.ui;
|
||||
var button = ui.button({
|
||||
contents: '<i class="fa fa-file-image-o"/>',
|
||||
tooltip: __('Choose'),
|
||||
click: function () {
|
||||
parent.Fast.api.open(selectUrl + "?element_id=&multiple=true&mimetype=image/", __('Choose'), {
|
||||
callback: function (data) {
|
||||
var urlArr = data.url.split(/\,/);
|
||||
$.each(urlArr, function () {
|
||||
var url = Fast.api.cdnurl(this, true);
|
||||
context.invoke('editor.insertImage', url);
|
||||
});
|
||||
}
|
||||
});
|
||||
return false;
|
||||
}
|
||||
});
|
||||
return button.render();
|
||||
};
|
||||
var attachmentButton = function (context) {
|
||||
var ui = $.summernote.ui;
|
||||
var button = ui.button({
|
||||
contents: '<i class="fa fa-file"/>',
|
||||
tooltip: __('Choose'),
|
||||
click: function () {
|
||||
parent.Fast.api.open(selectUrl + "?element_id=&multiple=true&mimetype=*", __('Choose'), {
|
||||
callback: function (data) {
|
||||
var urlArr = data.url.split(/\,/);
|
||||
$.each(urlArr, function () {
|
||||
var url = Fast.api.cdnurl(this, true);
|
||||
var node = $("<a href='" + url + "'>" + url + "</a>");
|
||||
context.invoke('insertNode', node[0]);
|
||||
});
|
||||
}
|
||||
});
|
||||
return false;
|
||||
}
|
||||
});
|
||||
return button.render();
|
||||
};
|
||||
$(Config.summernote.classname || '.editor', form).each(function () {
|
||||
$(this).summernote($.extend(true, {}, {
|
||||
height: 250,
|
||||
lang: 'zh-CN',
|
||||
fontNames: [
|
||||
'Arial', 'Arial Black', 'Serif', 'Sans', 'Courier',
|
||||
'Courier New', 'Comic Sans MS', 'Helvetica', 'Impact', 'Lucida Grande',
|
||||
"Open Sans", "Hiragino Sans GB", "Microsoft YaHei",
|
||||
'微软雅黑', '宋体', '黑体', '仿宋', '楷体', '幼圆',
|
||||
],
|
||||
fontNamesIgnoreCheck: [
|
||||
"Open Sans", "Microsoft YaHei",
|
||||
'微软雅黑', '宋体', '黑体', '仿宋', '楷体', '幼圆'
|
||||
],
|
||||
toolbar: [
|
||||
['style', ['style', 'undo', 'redo']],
|
||||
['font', ['bold', 'underline', 'strikethrough', 'clear']],
|
||||
['fontname', ['color', 'fontname', 'fontsize']],
|
||||
['para', ['ul', 'ol', 'paragraph', 'height']],
|
||||
['table', ['table', 'hr']],
|
||||
['insert', ['link', 'picture', 'video']],
|
||||
['select', ['image', 'attachment']],
|
||||
['view', ['fullscreen', 'codeview', 'help']],
|
||||
],
|
||||
buttons: {
|
||||
image: imageButton,
|
||||
attachment: attachmentButton,
|
||||
},
|
||||
dialogsInBody: true,
|
||||
followingToolbar: false,
|
||||
callbacks: {
|
||||
onChange: function (contents) {
|
||||
$(this).val(contents);
|
||||
$(this).trigger('change');
|
||||
},
|
||||
onInit: function () {
|
||||
},
|
||||
onImageUpload: function (files) {
|
||||
var that = this;
|
||||
//依次上传图片
|
||||
for (var i = 0; i < files.length; i++) {
|
||||
Upload.api.send(files[i], function (data) {
|
||||
var url = Fast.api.cdnurl(data.url, true);
|
||||
$(that).summernote("insertImage", url, 'filename');
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}, $(this).data("summernote-options") || {}));
|
||||
});
|
||||
});
|
||||
}
|
||||
} catch (e) {
|
||||
|
||||
}
|
||||
|
||||
};
|
||||
});
|
||||
16
addons/summernote/config.php
Normal file
16
addons/summernote/config.php
Normal file
@@ -0,0 +1,16 @@
|
||||
<?php
|
||||
|
||||
return [
|
||||
[
|
||||
'name' => 'classname',
|
||||
'title' => '渲染文本框元素',
|
||||
'type' => 'string',
|
||||
'content' => [],
|
||||
'value' => '.summernote,.editor',
|
||||
'rule' => 'required',
|
||||
'msg' => '',
|
||||
'tip' => '用于对指定的元素渲染,一般情况下无需修改',
|
||||
'ok' => '',
|
||||
'extend' => '',
|
||||
],
|
||||
];
|
||||
16
addons/summernote/controller/Index.php
Normal file
16
addons/summernote/controller/Index.php
Normal file
@@ -0,0 +1,16 @@
|
||||
<?php
|
||||
|
||||
namespace addons\summernote\controller;
|
||||
|
||||
use think\addons\Controller;
|
||||
|
||||
class Index extends Controller
|
||||
{
|
||||
|
||||
public function index()
|
||||
{
|
||||
$this->error("当前插件暂无前台页面");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
10
addons/summernote/info.ini
Normal file
10
addons/summernote/info.ini
Normal file
@@ -0,0 +1,10 @@
|
||||
name = summernote
|
||||
title = Summernote富文本编辑器
|
||||
intro = 一款简单的富文本编辑器
|
||||
author = FastAdmin
|
||||
website = http://www.fastadmin.net
|
||||
version = 1.0.5
|
||||
state = 1
|
||||
url = /peace-poster/public/addons/summernote
|
||||
license = regular
|
||||
licenseto = 21507
|
||||
Reference in New Issue
Block a user