欢迎使用 DCSHOP 应用开发文档!本文档将帮助您快速了解如何为 DCSHOP 发卡系统开发插件、支付接口和模板。
DCSHOP 支持插件和多种模板应用开发:
| 类型 | 说明 | 存放目录 |
|---|---|---|
| 插件 | 功能扩展插件,如支付接口、美化效果、功能增强等 | content/plugins/插件名/ |
| 首页模板 | 前台网站模板,控制商品展示、下单页面等;应用类型使用 template |
content/templates/模板名/ |
| 用户后台模板 | 用户中心/商户后台模板 | content/user_templates/模板名/ |
| 底部导航模板 | 移动端底部导航模板 | content/bottom_nav_templates/模板名/ |
<?php
/*
Plugin Name: 我的插件
Version: 1.0.0
Plugin URL: https://your-website.com
Description: 这是一个示例插件
Author: 作者名
Author URL: https://your-website.com
Ui: Layui
*/
defined('DC_ROOT') || exit('access denied!');
Ui: Layui 声明是必须的!这样插件配置页面才会以弹窗方式打开。
// 注册钩子
addAction('钩子名称', '回调函数名');
// 示例:在后台页脚添加内容
function myPluginFooter() {
echo '<script>console.log("Hello from my plugin!");</script>';
}
addAction('adm_footer', 'myPluginFooter');
<link rel="stylesheet" href="./assets/remixicon/remixicon.css">
html[data-theme="dark"] 选择器。
使用 Storage 类存储插件配置:
// 获取存储实例
$storage = Storage::getInstance('插件名');
// 保存配置
$storage->setValue('key', 'value');
// 读取配置
$value = $storage->getValue('key');
| 函数 | 说明 |
|---|---|
addAction($hook, $func) | 注册钩子回调函数 |
doAction($hook, ...) | 触发钩子 |
Option::get($key) | 获取系统配置 |
Input::getStrVar($key) | 获取 GET 字符串参数 |
Input::postStrVar($key) | 获取 POST 字符串参数 |
Output::ok($data) | 返回成功 JSON |
Output::error($msg) | 返回错误 JSON |
isMobile() | 判断是否移动端 |
getClientIP() | 获取客户端 IP |
Database::getInstance() | 获取主程序数据库实例 |
Ret::success() / Ret::error() | 前台/用户接口常用 JSON 输出 |
PluginLicense::verify($slug) | 付费应用授权校验 |
dc_ 或 lic_,所有 SQL 均应使用 DB_PREFIX。config.php。default,不要把空模板当作关闭态。default,但允许显式 em_null_tpl 关闭。上架到应用商店并需要授权控制的插件,建议在主文件顶部加入授权校验:
defined('DC_ROOT') || exit('access denied!');
$__slug = 'my_plugin';
if (basename(__DIR__) !== $__slug) {
return; // 防止改目录名绕过授权
}
require_once DC_ROOT . '/include/lib/plugin_license.php';
if (!PluginLicense::verify($__slug)) {
return; // 未授权、过期或封禁时不加载插件逻辑
}