From 50a678714e1e75541a8d696ca105af961d962748 Mon Sep 17 00:00:00 2001 From: wh <382379437@qq.com> Date: Thu, 8 Aug 2024 01:46:39 +0800 Subject: [PATCH] fixed --- .../application/index/controller/Test.php | 86 +++++++++++++- digital_doctor/public/api_docs/api_list.html | 112 +++++++++++------- digital_doctor/public/api_docs/api_list.md | 15 ++- .../src/api/ApiDocument.php | 34 ++++-- 4 files changed, 190 insertions(+), 57 deletions(-) diff --git a/digital_doctor/application/index/controller/Test.php b/digital_doctor/application/index/controller/Test.php index d54483a..e69bf2a 100644 --- a/digital_doctor/application/index/controller/Test.php +++ b/digital_doctor/application/index/controller/Test.php @@ -88,6 +88,16 @@ dump($requestUrl); // 运行事件循环 $loop->run(); } + //function stringToColor($string) { + // // 使用crc32函数计算字符串的哈希值 + // $hash = crc32($string); + // + // // 将整数哈希值转换为16进制,并填充0以确保6位长度 + // $color = sprintf("%06X", $hash & 0xFFFFFF); + // + // // 返回颜色码 + // return '#' . $color; + //} function stringToColor($string) { // 使用crc32函数计算字符串的哈希值 $hash = crc32($string); @@ -95,12 +105,86 @@ dump($requestUrl); // 将整数哈希值转换为16进制,并填充0以确保6位长度 $color = sprintf("%06X", $hash & 0xFFFFFF); + // 分解颜色码为RGB三个部分 + $r = hexdec(substr($color, 0, 2)); + $g = hexdec(substr($color, 2, 2)); + $b = hexdec(substr($color, 4, 2)); + + // 计算亮度调整 + $brightnessFactor = 30; // 减少亮度因子以使颜色更浅 + $contrastThreshold = 80; // 进一步降低对比度阈值以允许更浅的颜色 + $maxBrightness = 100; // 降低最大亮度限制,防止生成过于接近白色的颜色 + + // 调整RGB值以确保颜色足够亮且与黑色有足够的对比度 + $r = min($maxBrightness, max($r + $brightnessFactor, $contrastThreshold)); + $g = min($maxBrightness, max($g + $brightnessFactor, $contrastThreshold)); + $b = min($maxBrightness, max($b + $brightnessFactor, $contrastThreshold)); + + // 将调整后的RGB值转换回16进制颜色码 + $adjustedColor = sprintf("#%02X%02X%02X", $r, $g, $b); + // 返回颜色码 - return '#' . $color; + return $adjustedColor; } + + + function test() { + $api_cache_arr['aaa'][] = ['api_name'=>111,'doc_txt'=>222]; + $api_cache_arr['bb'][] = ['api_name'=>777,'doc_txt'=>777]; + $api_cache_arr['aaa'][] = ['api_name'=>666,'doc_txt'=>666]; + $api_cache_arr['ccc'][] = ['api_name'=>111,'doc_txt'=>222]; + $api_cache_arr['aaa'][] = ['api_name'=>555,'doc_txt'=>555]; + $api_cache_arr['ccc'][] = ['api_name'=>333,'doc_txt'=>333]; + dump($api_cache_arr);die; + // 使用示例 + $color = $this->stringToColor("example string"); + //echo $color; // 输出颜色码 + echo '
test
'; + echo '
test
'; + echo '
test
'; + echo '
test
'; + echo '
test
'; + echo '
test
'; + echo '
test
'; + echo '
test
'; + echo '
test
'; + echo '
test
'; + echo '
test
'; + echo '
test
'; + echo '
test
'; + echo '
test
'; + echo '
test
'; + echo '
test
'; + echo '
test
'; + echo '
test
'; + echo '
test
'; + echo '
test
'; + echo '
test
'; + echo '
test
'; + echo '
test
'; + echo '
test
'; + echo '
test
'; + echo '
test
'; + echo '
test
'; + echo '
test
'; + echo '
test
'; + echo '
test
'; + echo '
test
'; + echo '
test
'; + echo '
test
'; + echo '
test
'; + echo '
test
'; + echo '
test
'; + echo '
test
'; + echo '
test
'; + die; + + die; + $color_code = substr(md5('asdfasdf'),0,6); + echo '
test
';die; // 使用示例 $color = $this->stringToColor("example string"); diff --git a/digital_doctor/public/api_docs/api_list.html b/digital_doctor/public/api_docs/api_list.html index 61463f6..4ac7a2e 100644 --- a/digital_doctor/public/api_docs/api_list.html +++ b/digital_doctor/public/api_docs/api_list.html @@ -6,7 +6,7 @@
-
+
*** ``` @@ -25,7 +25,7 @@
-
+
*** ``` @@ -53,7 +53,7 @@
-
+
*** ``` @@ -78,7 +78,7 @@
-
+
*** ``` @@ -106,7 +106,7 @@
-
+
*** ``` @@ -154,7 +154,7 @@
-
+
*** ``` @@ -180,7 +180,7 @@
-
+
*** ``` @@ -220,7 +220,7 @@
-
+
*** ``` @@ -244,7 +244,27 @@
-
+
+
+*** +``` + /** + * 删除随访 + * 参数: + * id ID + * api/Hdrfollowup/del + * api/hdrfollowup/del + */ +``` +
+
+ 按需填写其它接口参数: + + 测试 +
+
+ +
*** ``` @@ -280,7 +300,7 @@
-
+
*** ``` @@ -302,7 +322,7 @@
-
+
*** ``` @@ -324,7 +344,7 @@
-
+
*** ``` @@ -346,7 +366,7 @@
-
+
*** ``` @@ -372,7 +392,7 @@
-
+
*** ``` @@ -398,7 +418,7 @@
-
+
*** ``` @@ -421,7 +441,7 @@
-
+
*** ``` @@ -434,9 +454,7 @@ * 带分页 * current_page 当前页码 * list_rows 每页显示条数 默认15 - * id ID - * hdrdepartment_id 所属科室 - * question 问卷问题 + * * 所有字段说明(可能有部分额外字段未在此体现): * id ID @@ -461,7 +479,7 @@
-
+
*** ``` @@ -489,7 +507,7 @@
-
+
*** ``` @@ -534,7 +552,7 @@
-
+
*** ``` @@ -593,7 +611,7 @@
-
+
*** ``` @@ -643,7 +661,7 @@
-
+
*** ``` @@ -689,7 +707,7 @@
-
+
*** ``` @@ -711,7 +729,7 @@
-
+
*** ``` @@ -734,7 +752,7 @@
-
+
*** ``` @@ -765,7 +783,7 @@
-
+
*** ``` @@ -789,7 +807,7 @@
-
+
*** ``` @@ -811,7 +829,7 @@
-
+
*** ``` @@ -834,7 +852,7 @@
-
+
*** ``` @@ -867,7 +885,7 @@
-
+
*** ``` @@ -904,7 +922,7 @@
-
+
*** ``` @@ -941,7 +959,7 @@
-
+
*** ``` @@ -991,7 +1009,7 @@
-
+
*** ``` @@ -1027,7 +1045,7 @@
-
+
*** ``` @@ -1059,7 +1077,7 @@
-
+
*** ``` @@ -1097,7 +1115,7 @@
-
+
*** ``` @@ -1120,7 +1138,7 @@
-
+
*** ``` @@ -1141,7 +1159,7 @@
-
+
*** ``` @@ -1166,7 +1184,7 @@
-
+
*** ``` @@ -1187,7 +1205,7 @@
-
+
*** ``` @@ -1222,7 +1240,7 @@
-
+
*** ``` @@ -1253,7 +1271,7 @@
-
+
*** ``` @@ -1344,6 +1362,12 @@ $('.api_hdrfollowup_updateHdrfollowup_response_result').html(JSON.stringify(res, null, "\t")); $('.api_hdrfollowup_updateHdrfollowup_response_result').attr('style','color:green'); },'json'); + }, api_hdrfollowup_del(){ + let url = $('#api_hdrfollowup_del_textarea').val(); + $.post(url,{},function(res) { + $('.api_hdrfollowup_del_response_result').html(JSON.stringify(res, null, "\t")); + $('.api_hdrfollowup_del_response_result').attr('style','color:green'); + },'json'); }, api_hdrquestionnaireanswer_getHdrquestionnaireanswerList(){ let url = $('#api_hdrquestionnaireanswer_getHdrquestionnaireanswerList_textarea').val(); $.post(url,{},function(res) { diff --git a/digital_doctor/public/api_docs/api_list.md b/digital_doctor/public/api_docs/api_list.md index b8c4f69..148fb42 100644 --- a/digital_doctor/public/api_docs/api_list.md +++ b/digital_doctor/public/api_docs/api_list.md @@ -170,6 +170,17 @@ */ ``` +*** +``` + /** + * 删除随访 + * 参数: + * id ID + * api/Hdrfollowup/del + * api/hdrfollowup/del + */ +``` + *** ``` /** @@ -295,9 +306,7 @@ * 带分页 * current_page 当前页码 * list_rows 每页显示条数 默认15 - * id ID - * hdrdepartment_id 所属科室 - * question 问卷问题 + * * 所有字段说明(可能有部分额外字段未在此体现): * id ID diff --git a/digital_doctor/vendor/wanghua/general-utility-tools-php/src/api/ApiDocument.php b/digital_doctor/vendor/wanghua/general-utility-tools-php/src/api/ApiDocument.php index a806b82..6ce079e 100644 --- a/digital_doctor/vendor/wanghua/general-utility-tools-php/src/api/ApiDocument.php +++ b/digital_doctor/vendor/wanghua/general-utility-tools-php/src/api/ApiDocument.php @@ -178,7 +178,7 @@ EOF; ``` EOF; $doc_txt= $str.$comments_str.$doc_txt." \r\n"; - $this->api_cache_arr[] = ['api_name'=>$api_name,'doc_txt'=>$doc_txt]; + $this->api_cache_arr[$className][] = ['api_name'=>$api_name,'doc_txt'=>$doc_txt,'class_name'=>$className]; file_put_contents($savepath,$doc_txt, FILE_APPEND); } @@ -194,16 +194,32 @@ EOF; } function buildApiDocHtml(){ + //给定一组浅色背景色码 + $color_code_arr = [ + '#f0f8ff', '#f0ffff', '#f5f5dc', '#ffe4c4', '#f5f5f5', '#f5fffa', '#fff5ee', '#f8f8ff', '#fffaf0', '#fffff0', '#fafad2', '#f0fff0', '#fff0f5', '#ffe4e1', '#f0ffff', '#f0f8ff', '#f8f8ff', '#faebd7', '#fff0f5', '#ffe4e1', '#ffe4b5', '#ffdead', '#dcdcdc', '#dda0dd', '#fffaf0', '#eee8aa', '#fffafa', '#f0fff0', '#f0fff0', '#f0f8ff', '#f0ffff', '#f5f5dc', '#ffe4c4', '#f5f5f5', '#f5fffa', '#fff5ee', '#f8f8ff', '#fffaf0', '#f0fff0', '#fff0f5', '#ffe4e1', '#f0ffff', '#f0f8ff', '#f8f8ff', '#faebd7', '#fff0f5', '#ffe4e1', '#ffe4b5', '#ffdead', '#dcdcdc', '#dda0dd', '#fffaf0', '#eee8aa', '#fffafa', '#f0fff0', '#f0fff0', '#f0f8ff', '#f0ffff', '#f5f5dc', '#ffe4c4', '#f5f5f5', '#f5fffa', '#fff5ee', '#f8f8ff', '#fffaf0', + ]; + $api_doc_cache_arr = cache('api_doc_cache_arr'); + $htm_str = ""; $script_str = ""; - foreach ($api_doc_cache_arr as $item){ - $api_name = $item['api_name']; - $doc_txt = $item['doc_txt']; + foreach ($api_doc_cache_arr as $class_name_key=>$func_arr){ + $color_code = $color_code_arr[strlen($class_name_key)-1]; + //是否显示上边距 + $is_show_margin_top = 'margin-top: 50px;'; + foreach ($func_arr as $k => $item){ + $api_name = $item['api_name']; + $doc_txt = $item['doc_txt']; - $function_name = str_replace('/','_',$api_name); - $htm_str .= << + if($k > 0){ + + $is_show_margin_top = ''; + } + + + $function_name = str_replace('/','_',$api_name); + $htm_str .= <<
{$doc_txt}
按需填写其它接口参数: @@ -214,7 +230,7 @@ EOF;
EOF; - $script_str.=<<