欢迎使用 DCSHOP 应用开发文档!本文档将帮助您快速了解如何为 DCSHOP 发卡系统开发插件、支付接口和模板。
DCSHOP 支持三种类型的应用开发:
| 类型 | 说明 | 存放目录 |
|---|---|---|
| 插件 | 功能扩展插件,如支付接口、美化效果、功能增强等 | content/plugins/插件名/ |
| 模板 | 前台网站模板,控制商品展示、下单页面等 | content/templates/模板名/ |
| 分站模板 | 分站专用模板 | content/station_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 |