前端分流页功能
This commit is contained in:
@@ -0,0 +1,12 @@
|
||||
-- 分流链接:像素配置 JSON 字段 + 权限节点
|
||||
SET NAMES utf8mb4;
|
||||
|
||||
ALTER TABLE `fa_split_link`
|
||||
ADD COLUMN `pixel_config` mediumtext COMMENT '像素配置JSON' AFTER `auto_reply`;
|
||||
|
||||
INSERT INTO `fa_auth_rule` (`type`, `pid`, `name`, `title`, `icon`, `condition`, `remark`, `ismenu`, `createtime`, `updatetime`, `weigh`, `status`)
|
||||
SELECT 'file', m.id, 'split.link/pixel', '像素配置', 'fa fa-circle-o', '', '', 0, UNIX_TIMESTAMP(), UNIX_TIMESTAMP(), 0, 'normal'
|
||||
FROM `fa_auth_rule` m
|
||||
WHERE m.name = 'split.link' AND m.ismenu = 1
|
||||
AND NOT EXISTS (SELECT 1 FROM `fa_auth_rule` WHERE `name` = 'split.link/pixel' LIMIT 1)
|
||||
LIMIT 1;
|
||||
@@ -9,6 +9,7 @@ use app\common\controller\Backend;
|
||||
use app\common\library\CountryIso;
|
||||
use app\common\service\SplitAutoReplyService;
|
||||
use app\common\service\SplitLinkCodeService;
|
||||
use app\common\service\SplitPixelConfigService;
|
||||
use app\common\service\SplitPlatformDomainService;
|
||||
use think\Db;
|
||||
use think\Exception;
|
||||
@@ -224,8 +225,8 @@ class Link extends Backend
|
||||
$this->success('', null, [
|
||||
'platform_domains' => $platformDomains,
|
||||
'my_domains' => $myDomains,
|
||||
'domain_index_url' => (string) url('domain/index'),
|
||||
'domain_add_url' => (string) url('domain/add'),
|
||||
'domain_index_url' => (string) url('domain', '', false, false),
|
||||
'domain_add_url' => (string) url('domain/add', '', false, false),
|
||||
'config_index_url' => (string) url('general/config/index'),
|
||||
]);
|
||||
}
|
||||
@@ -284,6 +285,58 @@ class Link extends Backend
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 像素配置:读取 / 保存
|
||||
*
|
||||
* @param string|null $ids 链接 ID
|
||||
* @return Json
|
||||
* @throws DbException
|
||||
*/
|
||||
public function pixel($ids = null): Json
|
||||
{
|
||||
$row = $this->model->get($ids);
|
||||
if (!$row) {
|
||||
$this->error(__('No Results were found'));
|
||||
}
|
||||
|
||||
$adminIds = $this->getDataLimitAdminIds();
|
||||
if (is_array($adminIds) && !in_array((int) $row[$this->dataLimitField], $adminIds, true)) {
|
||||
$this->error(__('You have no permission'));
|
||||
}
|
||||
|
||||
if ($this->request->isPost()) {
|
||||
$payload = $this->request->post('pixel_config/a', []);
|
||||
if ($payload === []) {
|
||||
$raw = (string) $this->request->post('pixel_config', '');
|
||||
$decoded = json_decode($raw, true);
|
||||
$payload = is_array($decoded) ? $decoded : [];
|
||||
}
|
||||
$existing = SplitPixelConfigService::parseStorage((string) $row->getAttr('pixel_config'));
|
||||
try {
|
||||
$merged = SplitPixelConfigService::mergeForSave($payload, $existing);
|
||||
$row->save([
|
||||
'pixel_config' => SplitPixelConfigService::encodeStorage($merged),
|
||||
]);
|
||||
} catch (\InvalidArgumentException $e) {
|
||||
$this->error($e->getMessage());
|
||||
} catch (PDOException|Exception $e) {
|
||||
$this->error($e->getMessage());
|
||||
}
|
||||
$this->success(__('Pixel config saved'));
|
||||
}
|
||||
|
||||
$config = SplitPixelConfigService::parseStorage((string) $row->getAttr('pixel_config'));
|
||||
$masked = SplitPixelConfigService::maskForAdmin($config);
|
||||
|
||||
$this->success('', null, [
|
||||
'id' => (int) $row['id'],
|
||||
'link_code' => (string) $row['link_code'],
|
||||
'facebook' => $masked[SplitPixelConfigService::PLATFORM_FACEBOOK],
|
||||
'tiktok' => $masked[SplitPixelConfigService::PLATFORM_TIKTOK],
|
||||
'event_options' => SplitPixelConfigService::EVENT_OPTIONS,
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 编辑(分流链接码不可修改)
|
||||
*
|
||||
|
||||
@@ -18,6 +18,7 @@ return [
|
||||
'Status hidden' => '停用',
|
||||
'Copy split link' => '复制分流链接',
|
||||
'Manage my domains' => '管理我的域名',
|
||||
'Domain management' => '域名管理',
|
||||
'Select main domain' => '选择主域名',
|
||||
'Platform assigned domain' => '平台分配域名',
|
||||
'My domains' => '我的域名',
|
||||
@@ -39,4 +40,26 @@ return [
|
||||
'Reply statements tip'=> '一行填写一条回复语句,保存后与当前分流链接关联',
|
||||
'Auto reply saved' => '自动回复已保存',
|
||||
'Reply statements column' => '回复语',
|
||||
'NS' => 'NS',
|
||||
'DNS' => 'DNS',
|
||||
'Pixel config' => '像素配置',
|
||||
'Pixel config tip' => '浏览器 Pixel 会在分流中转页触发;服务端回传需要填写对应平台 Access Token,Token 留空会保留原配置。',
|
||||
'Facebook Pixel' => 'Facebook Pixel',
|
||||
'TikTok Pixel' => 'TikTok Pixel',
|
||||
'Add FB Pixel' => '+ 添加FB Pixel',
|
||||
'Add TK Pixel' => '+ 添加TK Pixel',
|
||||
'Pixel enabled' => '启用',
|
||||
'Server postback' => '服务端回传',
|
||||
'Pixel ID' => 'Pixel ID',
|
||||
'Access Token' => 'Access Token',
|
||||
'Test code' => '测试码',
|
||||
'Pixel event' => '事件',
|
||||
'Pixel sort' => '排序',
|
||||
'Pixel config saved' => '像素配置已保存',
|
||||
'Pixel ID required' => '请填写 Pixel ID',
|
||||
'Remove row' => '删除',
|
||||
'Optional' => '选填',
|
||||
'Pixel list empty' => '暂无配置,请点击上方按钮添加',
|
||||
'Pixel row index' => '序号',
|
||||
'Operate' => '操作',
|
||||
];
|
||||
|
||||
@@ -94,15 +94,11 @@ class Link extends Model
|
||||
}
|
||||
|
||||
/**
|
||||
* 列表「回复语」列展示(多行合并为单行,供省略号截断)
|
||||
* 列表「回复语」列预览(最多 50 字 + ...,悬停用原始 auto_reply 换行展示)
|
||||
*/
|
||||
public function getAutoReplyTextAttr($value, $data): string
|
||||
{
|
||||
$lines = \app\common\service\SplitAutoReplyService::parseLines((string)($data['auto_reply'] ?? ''));
|
||||
if ($lines === []) {
|
||||
return '';
|
||||
}
|
||||
return implode(';', $lines);
|
||||
return \app\common\service\SplitAutoReplyService::previewForList((string) ($data['auto_reply'] ?? ''));
|
||||
}
|
||||
|
||||
public function getIpProtectTextAttr($value, $data): string
|
||||
|
||||
Reference in New Issue
Block a user