操作记录

This commit is contained in:
2025-08-14 11:23:44 +08:00
parent 01c73efb1e
commit fe378eccd5
2 changed files with 33 additions and 1 deletions

View File

@@ -461,6 +461,15 @@ class ViewHelper
try {
// 尝试使用ThinkPHP的视图渲染
if (class_exists('\\think\\facade\\View')) {
// 构建插件模板的完整路径
$pluginViewPath = static::getPluginViewPath($template);
// 如果插件模板文件存在,使用完整路径加载
if (file_exists($pluginViewPath)) {
return View::fetch($pluginViewPath, $vars);
}
// 否则尝试使用原始模板路径(用于自定义模板)
return View::fetch($template, $vars);
}
} catch (\Exception $e) {
@@ -472,6 +481,29 @@ class ViewHelper
return static::renderBuiltinHtml($template, $vars);
}
/**
* 获取插件视图文件的完整路径
* @param string $template 模板路径
* @return string
*/
protected static function getPluginViewPath(string $template): string
{
// 获取当前文件的目录 (/path/to/plugs/think-plugs-recorder/src/helper)
$currentDir = __DIR__;
// 向上两级回到插件根目录 (/path/to/plugs/think-plugs-recorder)
$pluginDir = dirname(dirname($currentDir));
// 标准化模板路径中的分隔符
$template = str_replace(['/', '\\'], DIRECTORY_SEPARATOR, $template);
// 构建视图文件路径
$viewPath = $pluginDir . DIRECTORY_SEPARATOR . 'view' . DIRECTORY_SEPARATOR . $template . '.html';
// 返回标准化的绝对路径
return realpath($viewPath) ?: $viewPath;
}
/**
* 内置HTML渲染
* @param string $template

View File

@@ -478,7 +478,7 @@ class RecorderService extends Service
// 基础查询条件
$query->where('data_type', $dataType)
->where('data_id', $dataId)
->where('operation_type', '<>', '读取'); // 排除读取操作
->whereNotIn('operation_type', ['读取', '查看']); // 排除读取操作
// 额外条件
if (!empty($conditions['start_time'])) {