From d3aceabe0d04935cd1133eb1d1d42a29dc173eda Mon Sep 17 00:00:00 2001 From: wangzemei Date: Thu, 20 Nov 2025 14:02:07 +0800 Subject: [PATCH] * [task#152541] remove the useless code of ai. --- module/ai/js/chat.js | 118 -------------------------------- module/ai/view/chat.html.php | 43 ------------ module/group/packagemanager.php | 7 -- module/index/config.php | 1 - 4 files changed, 169 deletions(-) delete mode 100644 module/ai/js/chat.js delete mode 100644 module/ai/view/chat.html.php diff --git a/module/ai/js/chat.js b/module/ai/js/chat.js deleted file mode 100644 index 5c69a05abb..0000000000 --- a/module/ai/js/chat.js +++ /dev/null @@ -1,118 +0,0 @@ -$(function() -{ - function markBusy() - { - $('input[type=submit]').attr('readonly', true).addClass('busy'); - $('textarea[name=message]').attr('readonly', true).addClass('busy'); - $('#retry').addClass('busy'); - $('#reset').addClass('busy'); - $('form').addClass('busy'); - } - - function reset(e) - { - if($(e.target).hasClass('busy') || $(e.target).hasClass('disabled')) return; - markBusy(); - $.ajax({ - url: createLink('ai', 'chat'), - dataType: 'html', - success: function(response) - { - $('.chat').html($($.parseHTML(response)).filter('.chat').html()); - init(); - } - }); - } - - function retry(e) - { - if($(e.target).hasClass('busy')) return; - markBusy(); - $.ajax({ - url: createLink('ai', 'chat'), - type: 'POST', - dataType: 'html', - data: {retry: 'true', history: $('input[name=history]').val()}, - success: function(response) - { - $('.chat').html($($.parseHTML(response)).filter('.chat').html()); - init(); - } - }); - } - - function init() - { - $('textarea[name=message]').keydown(function(e) - { - /* Send message on enter, allowing linebreak inputs. */ - if((e.keyCode == 13 || e.keyCode == 10)) - { - if($(this).hasClass('busy')) return; - - if(e.ctrlKey || e.metaKey) - { - $('textarea[name=message]').val($('textarea[name=message]').val() + '\n'); - $('textarea[name=message]').trigger('input'); - } - else - { - if($('textarea[name=message]').val().trim().length == 0) - { - e.preventDefault(); - return; - } - $('form').submit(); - } - } - }); - $('form').on('submit', function(e) - { - if($(this).hasClass('busy')) return false; - - /* Disable form and add message. */ - markBusy(); - const message = $('textarea[name=message]').val().trim(); - $('.messages').prepend("
" + message + '
'); - - /* Send message to server and re-render the chat. */ - e.preventDefault(); - $.ajax({ - url: createLink('ai', 'chat'), - type: 'POST', - data: {message, history: $('input[name=history]').val()}, - dataType: 'html', - success: function(response) - { - $('.chat').html($($.parseHTML(response)).filter('.chat').html()); - init(); - } - }); - }); - $('#reset').click(reset); - $('#retry').click(retry); - $('textarea[name=message]').focus(); - $('textarea[name=message]').on('input', function() - { - /* Toggle send button. */ - const hasMessage = $(this).val().trim().length > 0; - $('input[type=submit]').attr('disabled', !hasMessage).toggleClass('disabled', !hasMessage); - - /* Resize textarea to fit content. */ - const clientHeight = +$(this).prop('clientHeight'); - const scrollHeight = +$(this).prop('scrollHeight'); - if(clientHeight < scrollHeight) - { - if(clientHeight < 150) - { - $(this).css('height', (scrollHeight + 2) + 'px'); - } - else - { - $(this).addClass('has-scrollbar'); - } - } - }); - } - init(); -}); diff --git a/module/ai/view/chat.html.php b/module/ai/view/chat.html.php deleted file mode 100644 index 96ae45d64a..0000000000 --- a/module/ai/view/chat.html.php +++ /dev/null @@ -1,43 +0,0 @@ - - * @package ai - * @link https://www.zentao.net - */ -?> - -
-
-
$error
"; - } - $shownMessages = array_reverse(array_filter($messages, function($message) { return $message->role != 'system'; })); - if(!empty($shownMessages)) - { - foreach($shownMessages as $message) - { - if($message->role != 'system') echo "
" . htmlspecialchars($message->content) . '
'; - } - } - else - { - echo "
{$lang->ai->chatPlaceholderMessage}
"; - } - ?> -
-
-
- - - value="ai->chatReset; ?>" /> -
- -
- - diff --git a/module/group/packagemanager.php b/module/group/packagemanager.php index 1f4c0c42b9..fecc5aa209 100644 --- a/module/group/packagemanager.php +++ b/module/group/packagemanager.php @@ -3948,13 +3948,6 @@ $config->group->package->exportDatatable->subset = 'dataview'; $config->group->package->exportDatatable->privs = array(); $config->group->package->exportDatatable->privs['dataview-export'] = array('edition' => 'biz,max,ipd', 'vision' => 'rnd', 'order' => 30, 'depend' => array('dataview-browse', 'dataview-query'), 'recommend' => array()); -/* Temporarily hide */ -// $config->group->package->aiChatting = new stdclass(); -// $config->group->package->aiChatting->order = 2020; -// $config->group->package->aiChatting->subset = 'aiapp'; -// $config->group->package->aiChatting->privs = array(); -// $config->group->package->aiChatting->privs['ai-chat'] = array('edition' => 'open,biz,max,ipd', 'vision' => 'rnd,lite,or', 'order' => 10, 'depend' => array(), 'recommend' => array()); - $config->group->package->aiConversation = new stdclass(); $config->group->package->aiConversation->order = 2030; $config->group->package->aiConversation->subset = 'aiapp'; diff --git a/module/index/config.php b/module/index/config.php index 29735ce945..bc937b2b23 100644 --- a/module/index/config.php +++ b/module/index/config.php @@ -27,7 +27,6 @@ $config->index->oldPages[] = 'screen-burn'; $config->index->oldPages[] = 'screen-viewold'; $config->index->oldPages[] = 'screen-staticdataold'; $config->index->oldPages[] = 'report-annualdata'; -$config->index->oldPages[] = 'ai-chat'; $config->index->oldPages[] = 'api-debug'; $config->index->oldPages[] = 'datatable-ajaxoldcustom'; $config->index->oldPages[] = 'kanban-importticket';