前端 按钮钩子不显示 有没有哪位大神帮我看看原因?
插件功能上开发没有遇到挑战,反而在按钮 钩子上卡的死死的。
都已经放弃了好几个不同的版本了。
xml
class.php代码
post.htm
botton.htm
都已经放弃了好几个不同的版本了。
xml
- <?xml version="1.0" encoding="ISO-8859-1"?><root> <item id="Title"><![CDATA[Discuz! Plugin]]></item> <item id="Version"><![CDATA[X3.5]]></item> <item id="Time"><![CDATA[2024-09-07 17:56]]></item> <item id="From"><![CDATA[起尔网 (https://www.72jz.com/)]]></item> <item id="Data"> <item id="plugin"> <item id="available"><![CDATA[1]]></item> <item id="adminid"><![CDATA[1]]></item> <item id="name"><![CDATA[帖子内容生成]]></item> <item id="identifier"><![CDATA[qier_thread]]></item> <item id="description"><![CDATA[帖子内容一键生成]]></item> <item id="datatables"><![CDATA[]]></item> <item id="directory"><![CDATA[qier_thread/]]></item> <item id="copyright"><![CDATA[起尔网]]></item> <item id="version"><![CDATA[1.0]]></item> <item id="__modules"> <item id="0"> <item id="name"><![CDATA[qier_thread]]></item> <item id="param"><![CDATA[]]></item> <item id="menu"><![CDATA[]]></item> <item id="url"><![CDATA[]]></item> <item id="type"><![CDATA[11]]></item> <item id="adminid"><![CDATA[0]]></item> <item id="displayorder"><![CDATA[0]]></item> <item id="navtitle"><![CDATA[]]></item> <item id="navicon"><![CDATA[]]></item> <item id="navsubname"><![CDATA[]]></item> <item id="navsuburl"><![CDATA[]]></item> </item> <item id="1"> <item id="name"><![CDATA[qier_thread]]></item> <item id="param"><![CDATA[]]></item> <item id="menu"><![CDATA[测试]]></item> <item id="url"><![CDATA[]]></item> <item id="type"><![CDATA[3]]></item> <item id="adminid"><![CDATA[0]]></item> <item id="displayorder"><![CDATA[0]]></item> <item id="navtitle"><![CDATA[]]></item> <item id="navicon"><![CDATA[]]></item> <item id="navsubname"><![CDATA[]]></item> <item id="navsuburl"><![CDATA[]]></item> </item> </item> </item><item id="hooks"> <item id="post_top"><![CDATA[post_top]]></item> <item id="post_middle"><![CDATA[post_middle]]></item> <item id="post_bottom"><![CDATA[post_bottom]]></item> <item id="viewthread_fastpost_content"><![CDATA[viewthread_fastpost_content]]></item> <item id="forumdisplay_postbutton_bottom"><![CDATA[forumdisplay_postbutton_bottom]]></item></item> <item id="version"><![CDATA[X3.5]]></item> <item id="var"> <item id="0"> <item id="displayorder"><![CDATA[0]]></item> <item id="title"><![CDATA[是否启用生成功能 ...]]></item> <item id="description"><![CDATA[启用后,生成按钮将显示在发帖页面]]></item> <item id="variable"><![CDATA[enable]]></item> <item id="type"><![CDATA[radio]]></item> <item id="value"><![CDATA[1]]></item> <item id="extra"><![CDATA[]]></item> </item> <item id="1"> <item id="displayorder"><![CDATA[1]]></item> <item id="title"><![CDATA[按钮显示位置]]></item> <item id="description"><![CDATA[选择生成按钮的显示位置]]></item> <item id="variable"><![CDATA[button_position]]></item> <item id="type"><![CDATA[select]]></item> <item id="value"><![CDATA[1]]></item> <item id="extra"><![CDATA[1=发帖框顶部2=发帖框中部3=发帖框底部]]></item> </item> <item id="2"> <item id="displayorder"><![CDATA[2]]></item> <item id="title"><![CDATA[是否在快速回复区域显示]]></item> <item id="description"><![CDATA[选择是否在快速回复区域显示生成按钮]]></item> <item id="variable"><![CDATA[show_in_fastpost]]></item> <item id="type"><![CDATA[radio]]></item> <item id="value"><![CDATA[1]]></item> <item id="extra"><![CDATA[]]></item> </item> <item id="3"> <item id="displayorder"><![CDATA[3]]></item> <item id="title"><![CDATA[API Key]]></item> <item id="description"><![CDATA[]]></item> <item id="variable"><![CDATA[api_key]]></item> <item id="type"><![CDATA[text]]></item> <item id="value"><![CDATA[1]]></item> <item id="extra"><![CDATA[]]></item> </item> <item id="4"> <item id="displayorder"><![CDATA[4]]></item> <item id="title"><![CDATA[Secret Key]]></item> <item id="description"><![CDATA[]]></item> <item id="variable"><![CDATA[secret_key]]></item> <item id="type"><![CDATA[text]]></item> <item id="value"><![CDATA[1]]></item> <item id="extra"><![CDATA[]]></item> </item> <item id="5"> <item id="displayorder"><![CDATA[5]]></item> <item id="title"><![CDATA[每日免费使用次数]]></item> <item id="description"><![CDATA[]]></item> <item id="variable"><![CDATA[daily_free_count]]></item> <item id="type"><![CDATA[number]]></item> <item id="value"><![CDATA[1]]></item> <item id="extra"><![CDATA[]]></item> </item> <item id="6"> <item id="displayorder"><![CDATA[6]]></item> <item id="title"><![CDATA[总共免费使用次数]]></item> <item id="description"><![CDATA[]]></item> <item id="variable"><![CDATA[total_free_count]]></item> <item id="type"><![CDATA[number]]></item> <item id="value"><![CDATA[1]]></item> <item id="extra"><![CDATA[]]></item> </item> <item id="7"> <item id="displayorder"><![CDATA[7]]></item> <item id="title"><![CDATA[生成文章积分类型]]></item> <item id="description"><![CDATA[属于论坛的一种虚拟币 在全局-积分设置里面的类型]]></item> <item id="variable"><![CDATA[credit_type]]></item> <item id="type"><![CDATA[extcredit]]></item> <item id="value"><![CDATA[1]]></item> <item id="extra"><![CDATA[]]></item> </item> <item id="8"> <item id="displayorder"><![CDATA[8]]></item> <item id="title"><![CDATA[生成需扣除的积分]]></item> <item id="description"><![CDATA[生成文章需使用的积分 比如:1]]></item> <item id="variable"><![CDATA[credit_cost]]></item> <item id="type"><![CDATA[number]]></item> <item id="value"><![CDATA[0]]></item> <item id="extra"><![CDATA[]]></item> </item> <item id="9"> <item id="displayorder"><![CDATA[9]]></item> <item id="title"><![CDATA[固定词]]></item> <item id="description"><![CDATA[这里是用户提交后额外给出的文章要求。没有请留空]]></item> <item id="variable"><![CDATA[fixed_words]]></item> <item id="type"><![CDATA[textarea]]></item> <item id="value"><![CDATA[]]></item> <item id="extra"><![CDATA[]]></item> </item> <item id="10"> <item id="displayorder"><![CDATA[10]]></item> <item id="title"><![CDATA[快捷词]]></item> <item id="description"><![CDATA[设置快捷词,每个词用逗号分隔]]></item> <item id="variable"><![CDATA[quick_words]]></item> <item id="type"><![CDATA[textarea]]></item> <item id="value"><![CDATA[]]></item> <item id="extra"><![CDATA[]]></item> </item> <item id="11"> <item id="displayorder"><![CDATA[11]]></item> <item id="title"><![CDATA[自定义按钮文字]]></item> <item id="description"><![CDATA[设置AI文章生成按钮的显示文字]]></item> <item id="variable"><![CDATA[custom_button_text]]></item> <item id="type"><![CDATA[text]]></item> <item id="value"><![CDATA[按钮]]></item> <item id="extra"><![CDATA[]]></item> </item> <item id="12"> <item id="displayorder"><![CDATA[12]]></item> <item id="title"><![CDATA[敏感词]]></item> <item id="description"><![CDATA[禁止生成的敏感词过滤,用逗号分隔多个敏感词]]></item> <item id="variable"><![CDATA[sensitive_words]]></item> <item id="type"><![CDATA[textarea]]></item> <item id="value"><![CDATA[]]></item> <item id="extra"><![CDATA[]]></item> </item> <item id="13"> <item id="displayorder"><![CDATA[13]]></item> <item id="title"><![CDATA[是否在论坛列表页显示]]></item> <item id="description"><![CDATA[选择是否在论坛列表页底部显示生成按钮]]></item> <item id="variable"><![CDATA[show_in_forumdisplay]]></item> <item id="type"><![CDATA[radio]]></item> <item id="value"><![CDATA[1]]></item> <item id="extra"><![CDATA[]]></item> </item></item><item id="language"> <item id="scriptlang"> <item id="setting_tips"><![CDATA[<li>如果需要使用文章生成功能,请在下方设置中启用相应配置</li>]]></item> <item id="succeed"><![CDATA[操作成功]]></item> <item id="failed"><![CDATA[操作失败]]></item> </item></item><item id="installfile"><![CDATA[install.php]]></item><item id="uninstallfile"><![CDATA[uninstall.php]]></item> <item id="extra"> <item id="css"><![CDATA[static/css/style.css]]></item> <item id="script"><![CDATA[static/js/qier_thread.js]]></item> </item> </item></root>
class.php代码
- <?phpif(!defined('IN_DISCUZ')) { exit('Access Denied');}class plugin_qier_thread { public function post_top() { return $this->qier_thread_button('post_top'); } public function post_middle() { return $this->qier_thread_button('post_middle'); } public function post_bottom() { return $this->qier_thread_button('post_bottom'); } public function viewthread_fastpost_content() { if (!$this->can_use_plugin()) return ''; global $_G; if($_G['cache']['plugin']['qier_thread']['show_in_fastpost']) { return $this->get_button_html(); } return ''; } public function forumdisplay_postbutton_bottom() { if (!$this->can_use_plugin()) return ''; global $_G; if($_G['cache']['plugin']['qier_thread']['show_in_forumdisplay']) { return $this->get_button_html(); } return ''; } private function qier_thread_button($position) { if (!$this->can_use_plugin()) { return ''; } global $_G; $button_position = $_G['cache']['plugin']['qier_thread']['button_position']; $position_map = [ 'post_top' => '1', 'post_middle' => '2', 'post_bottom' => '3' ]; if ($button_position !== $position_map[$position]) { return ''; } return $this->get_button_html(); } private function get_button_html() { global $_G; $css_url = 'source/plugin/qier_thread/static/css/style.css'; $js_url = 'source/plugin/qier_thread/static/js/qier_thread.js'; $output = '<link rel="stylesheet" type="text/css" href="' . $css_url . '" />'; $output .= '<script type="text/javascript" src="' . $js_url . '"></script>'; $button_text = $_G['cache']['plugin']['qier_thread']['custom_button_text'] ?: '这里是个按钮'; $button = '<button type="button" id="qier_thread_button" class="qier-thread-button">'; $button .= '<span class="qier-thread-icon"></span>'; $button .= '<span class="qier-thread-text">' . $button_text . '</span>'; $button .= '</button>'; return $output . $button; }
- //开启日志
post.htm
- <div class="qier_thread_container"> <!--{if $button_position == 1}--> {template qier_thread:button} <!--{/if}--> <!-- 其他发帖表单元素 --> <!--{if $button_position == 2}--> {template qier_thread:button} <!--{/if}--> <!-- 更多发帖表单元素 --> <!--{if $button_position == 3}--> {template qier_thread:button} <!--{/if}--></div>
botton.htm
- <button type="button" id="qier_thread_button" class="qier-thread-button"> <span class="qier-thread-icon"></span> <span class="qier-thread-text">{$button_text}</span></button>