Files
YwxAppThink/app/frontend/controller/Feature.php
T

107 lines
3.7 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<?php
declare(strict_types=1);
namespace app\frontend\controller;
use ywxapp\controller\FrontendBase;
/**
* 特性详情(由 app/wxapp 合并至 app/frontend
*/
class Feature extends FrontendBase
{
protected $noNeedLogin = ['index', 'detail'];
protected $noNeedVerify = ['*'];
// 四大特性元数据
private $items = [
'plugin' => [
'title' => '插件机制',
'summary' => '基于 ThinkPHP 事件系统 + 订阅器的热插拔插件架构。',
'points' => [
'插件在 info.php 的 events.subscribe 声明订阅器类',
'AppService 启动时自动 loadEvent 注册,无需手动绑定',
'订阅方法 onXxx 自动监听对应事件,与业务完全解耦',
'后台可在线安装 / 启用 / 禁用 / 卸载',
],
'code' => "## 插件订阅器示例(mqpay
class Payment extends \\ywxapp\\addon {
// 监听支付方式列表事件
public function onPaymentMethods(\$event) {
return ['personal' => ['name'=>'免签支付','sort'=>10]];
}
// 监听支付创建事件,生成收款码
public function onPaymentCreate(\$event) { /* ... */ }
}",
],
'multi-app' => [
'title' => '多应用架构',
'summary' => 'app 目录下按业务域拆分多个独立应用,互不干扰。',
'points' => [
'api → 对外 JSON 接口(移动端 / 第三方)',
'backend → 管理后台(RBAC 权限)',
'member → 会员中心(支付 / 订单 / 会员)',
'frontend → 标准 Web 前端',
'site → 本展示官网',
],
'code' => "# route/app.php 按应用分组
Route::group('api', function () {
Route::get('user/info', 'api/v1.user/info');
});",
],
'member-pay' => [
'title' => '会员 / 支付',
'summary' => 'mqpay 免签支付 + 会员开通事件链,扫码到账自动开通。',
'points' => [
'免签支付:监听系统通知栏,到账自动确认',
'安卓调用 POST /mqpay/pay/notify-app 验签确认',
'confirmOrder() 触发 UserMemberActivate 事件',
'会员监听器顺延会员期限并写入权益',
],
'code' => "// confirmOrder 内触发会员开通
Event::trigger('UserMemberActivate', [
'uid' => \$order['uid'],
'plan_id' => \$order['plan_id'],
'order' => \$order,
'method' => 'personal',
]);",
],
'doc' => [
'title' => '文档 / 示例',
'summary' => '完善的开发文档、API 示例与快速开始指南。',
'points' => [
'插件 README + docs 文档体系',
'API 示例与请求 / 响应契约',
'快速开始指南降低上手成本',
'钩子 / 事件速查表一键索引',
],
'code' => "# 查看支付钩子文档
addon/mqpay/docs/payment_hooks.md
addon/mqpay/docs/listen_app_guide.md",
],
];
public function index()
{
return view('feature/index', [
'controller' => $this->request->controller(),
'items' => $this->items,
]);
}
public function detail($name = 'plugin')
{
if (!isset($this->items[$name])) {
$name = 'plugin';
}
$item = $this->items[$name];
return view('feature/detail', [
'controller' => $this->request->controller(),
'name' => $name,
'item' => $item,
'items' => $this->items,
]);
}
}