{"id":6918,"date":"2025-09-28T15:03:27","date_gmt":"2025-09-28T07:03:27","guid":{"rendered":"https:\/\/support.fuxinsoft.cn\/?p=6918"},"modified":"2025-10-28T14:16:03","modified_gmt":"2025-10-28T06:16:03","slug":"%e5%a6%82%e4%bd%95%e5%9c%a8%e5%8f%b3%e4%be%a7%e4%be%a7%e8%be%b9%e6%a0%8f%e4%b8%ad%e5%a2%9e%e5%8a%a0%e4%b8%80%e4%b8%aa%e8%87%aa%e5%ae%9a%e4%b9%89%e7%9a%84tab%e6%a0%87%e7%ad%be%e9%a1%b5%ef%bc%8c","status":"publish","type":"post","link":"https:\/\/support.fuxinsoft.cn\/?p=6918","title":{"rendered":"\u81ea\u5b9a\u4e49\u53f3\u4fa7\u8fb9\u680f\u9009\u9879\u5361\uff1a\u52a8\u6001\u63a7\u5236\u4e0e\u4e8b\u4ef6\u96c6\u6210\u6307\u5357"},"content":{"rendered":"\n<h2 class=\"wp-block-heading\"><strong>\u7528\u6237\u81ea\u5b9a\u4e49\u51fd\u6570<\/strong><\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code>function testFun() {\n    alert(\"Button was Clicked !\");\n}<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>\u63a7\u5236\u5668\u6ce8\u518c\u4e0e\u4e1a\u52a1\u903b\u8f91\u96c6\u6210<\/strong><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">\u4f7f\u7528\u00a0<code>@controller<\/code>\u00a0\u6307\u4ee4\u5c06\u63a7\u4ef6\u7c7b\u9644\u52a0\u5230\u7ec4\u4ef6\u3002\u4ee5\u4e0b\u4ee3\u7801\u521b\u5efa\u540d\u4e3a &#8220;custom&#8221; \u7684\u6a21\u5757\uff0c\u5e76\u6ce8\u518c\u4e24\u4e2a\u63a7\u4ef6\u7c7b\u00a0<code>MyController1<\/code>\u00a0\u548c\u00a0<code>MyController2<\/code>\uff0c\u7528\u4e8e\u5728\u81ea\u5b9a\u4e49UI\u4e2d\u96c6\u6210\u4e1a\u52a1\u529f\u80fd\uff1a<br>UIExtension.PDFUI.module(&#8216;custom&#8217;, [])<br>    .controller(&#8216;MyController1&#8217;, {<br>        handle: function () {<br>            alert(&#8216;diyBtn was clicked !&#8217;);<br>        }<br>    })<br>    .controller(&#8216;MyController2&#8217;, {<br>        handle: function () {<br>            alert(&#8216;The document will be closed !&#8217;);<br>            pdfui.close();<br>        }<br>    });<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>\u5b9e\u73b0\u81ea\u5b9a\u4e49\u53f3\u4fa7\u8fb9\u680f\u9009\u9879\u5361<\/strong><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">\u4ee5\u4e0b\u51fd\u6570\u7528\u4e8e\u5728PDFUI\u5185\u7f6e\u53f3\u4fa7\u4fa7\u8fb9\u680f\u4e2d\u63d2\u5165\u65b0\u7684\u9009\u9879\u5361\u9762\u677f\uff0c\u5e76\u4e3a\u9762\u677f\u5143\u7d20\u6dfb\u52a0\u4e8b\u4ef6\u76d1\u542c\u5668\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>async function insertDIYRightSidebarTab() {\n    \/\/ \u83b7\u53d6\u540d\u4e3a'sidebar-right-tabs'\u7684\u7ec4\u4ef6\u5bf9\u8c61\uff0c\u8fd9\u662f\u4e00\u4e2a\u5bb9\u5668\u7ec4\u4ef6\uff0c\u5305\u542b\u591a\u4e2a\u9009\u9879\u5361\u9762\u677f\u3002\n    const sidebarRightTabs = await pdfui.getComponentByName('sidebar-right-tabs');\n    \/\/ \u5411\u53f3\u4fa7\u4fa7\u8fb9\u680f\u7684\u9009\u9879\u5361\u5bb9\u5668\u7ec4\u4ef6\u4e2d\u63d2\u5165\u4e00\u4e2a\u65b0\u7684\u9009\u9879\u5361\u9762\u677f\uff0csidebar-tab-panel\u6807\u7b7e\u5185\u5305\u542b\u7684\u4ee3\u7801\uff0c\u53ef\u4ee5\u6839\u636e\u4e1a\u52a1\u9700\u8981\u8fdb\u884c\u81ea\u5b9a\u4e49\n    sidebarRightTabs.insert(`\n        &lt;sidebar-tab-panel name=\"diy-customer-panel\" tab-title=\"\u81ea\u5b9a\u4e49\u53f3\u4fa7\u8fb9\u680f\u9009\u9879\u5361\">\n            &lt;div style=\"color:red\">\n                &lt;span>\u8fd9\u4e2a\u533a\u57df\u53ef\u4ee5\u81ea\u5b9a\u4e49\u8bbe\u8ba1&lt;\/span>&lt;hr \/>\n                &lt;ribbon-button icon-class=\"fv__icon-toolbar-hand\" name='diyBtn' text=\"\u590d\u7528\u4e86\u624b\u578b\u5de5\u5177\u56fe\u6807\" @controller=\"custom:MyController1\">&lt;\/ribbon-button>\n                &lt;open-file-ribbon-dropdown>&lt;\/open-file-ribbon-dropdown>\n                &lt;download-file-button>&lt;\/download-file-button>\n            &lt;\/div>\n            &lt;hr \/>\n            &lt;xbutton name=\"closeDoc\"  text=\"\u5173\u95ed\u6587\u6863\" @controller=\"custom:MyController2\">&lt;\/xbutton>\n            &lt;button onclick=\"testFun()\">\u539f\u751f\u7528\u6cd5&lt;\/button>\n        &lt;\/sidebar-tab-panel>\n        `);\n}<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">\u52a8\u6001\u63a7\u5236\u9009\u9879\u5361\u663e\u793a\u4e0e\u9690\u85cf<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">\u6b64\u51fd\u6570\u7528\u4e8e\u5c55\u5f00\/\u6298\u53e0\u53f3\u4fa7\u8fb9\u680f\u9009\u9879\u5361\uff0c\u5e76\u63a7\u5236\u6307\u5b9a\u9009\u9879\u5361\u7684\u53ef\u89c1\u6027\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>async function expandOrCollapseSidebarRightTab(componentName, expandedStatus) {\n    \/\/\u83b7\u53d6\u6307\u5b9a\u7ec4\u4ef6\u540d\u79f0\u7684\u9009\u9879\u5361\u7ec4\u4ef6\u5bf9\u8c61\n    const selectedSidebarRightTab = await pdfui.getComponentByName(componentName);\n    \/\/\u83b7\u53d6\u53f3\u4fa7\u4fa7\u8fb9\u680f\u7ec4\u4ef6\u5bf9\u8c61\n    const sidebarRight = await pdfui.getComponentByName('sidebar-right');\n    \/\/\u83b7\u53d6\u540d\u4e3a'sidebar-right-tabs'\u7684\u7ec4\u4ef6\u5bf9\u8c61\uff0c\u8fd9\u662f\u4e00\u4e2a\u5bb9\u5668\u7ec4\u4ef6\uff0c\u5305\u542b\u591a\u4e2a\u9009\u9879\u5361\u9762\u677f\u3002\n    const sidebarRightTabs = await pdfui.getComponentByName('sidebar-right-tabs');\n    \/\/const selectedSidebarRightTab = await pdfui.getComponentByName(\"diy-customer-panel\");\n    \n    if (expandedStatus) {\n        selectedSidebarRightTab.active();\/\/\u5c06\u6307\u5b9a\u7684\u9009\u9879\u5361\u9762\u677f\u8bbe\u7f6e\u4e3a\u6fc0\u6d3b\u72b6\u6001\uff0c\u5f85\u5c55\u793a\n        sidebarRight.show();\/\/\u5c55\u5f00\u53f3\u4fa7\u4fa7\u8fb9\u680f\n    } else {\n        \/\/ sidebarRightTabs.closeTabFun(\"diy-customer-panel\");\n        sidebarRightTabs.closeTabFun(componentName);\/\/\u5173\u95ed\u6307\u5b9a\u7684\u9009\u9879\u5361\u9762\u677f\n        \/\/ sidebarRightTabs.setOpenTabs(&#91;]);\/\/\u6e05\u7a7a\u6240\u6709\u6807\u7b7e\u9875\uff0c\u53ef\u6309\u9700\u4f7f\u7528\n        sidebarRight.hide();\/\/\u9690\u85cf\u53f3\u4fa7\u4fa7\u8fb9\u680f\n    }\n}\n<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">\u521d\u59cb\u5316\u4e0e\u529f\u80fd\u8c03\u7528<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">\u5728PDFUI\u5b9e\u4f8b\u521d\u59cb\u5316\u5b8c\u6210\u540e\uff0c\u63d2\u5165\u81ea\u5b9a\u4e49\u9009\u9879\u5361\u9762\u677f\uff1a<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">pdfui\u5b9e\u4f8b\u521d\u59cb\u5316\u5b8c\u6210\u4e4b\u540e\uff0c\u8c03\u7528\u5c01\u88c5\u597d\u7684\u81ea\u5b9a\u4e49\u51fd\u6570\uff0c\u5728PDFUI\u7684\u5185\u7f6e\u53f3\u4fa7\u4fa7\u8fb9\u680f\u4e2d\u63d2\u5165\u4e00\u4e2a\u65b0\u7684\u9009\u9879\u5361\u9762\u677f<br>pdfui.addUIEventListener(UIExtension.UIEvents.initializationCompleted, async function () {<br>    insertDIYRightSidebarTab();<br>})<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u52a8\u6001\u63a7\u5236\u81ea\u5b9a\u4e49\u9009\u9879\u5361\u7684\u663e\u793a\u4e0e\u9690\u85cf\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\/\/\u8c03\u7528\u5c01\u88c5\u597d\u7684\u81ea\u5b9a\u4e49\u51fd\u6570\uff0c\u52a8\u6001\u63a7\u5236\u81ea\u5b9a\u4e49Tab\u9762\u677f\u7684\u51fa\u73b0\nexpandOrCollapseSidebarRightTab(\"diy-customer-panel\", true);\n\/\/expandOrCollapseSidebarRightTab(\"diy-customer-panel\", false);<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">\u6837\u5f0f\u5b9a\u5236\uff1a\u7981\u7528\u9009\u9879\u5361\u5173\u95ed\u529f\u80fd<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">\u5982\u679c\u4e0d\u5e0c\u671b\u81ea\u5b9a\u4e49\u6807\u7b7e\u9875\u88ab\u5173\u95ed\uff0c\u53ef\u5728\u9875\u9762\u6837\u5f0f\u4e2d\u6dfb\u52a0\u4ee5\u4e0b\u4ee3\u7801\u9690\u85cf\u5173\u95ed\u5143\u7d20\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>.fv__ui-sidebar-right-tabs .fv__ui-sidebar-right-navlist .fv__ui-sidebar-nav-close {\n\u00a0 \u00a0 display: none;\n}<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u7528\u6237\u81ea\u5b9a\u4e49\u51fd\u6570 \u63a7\u5236\u5668\u6ce8\u518c\u4e0e\u4e1a\u52a1\u903b\u8f91\u96c6\u6210 \u4f7f\u7528\u00a0@controller\u00a0\u6307\u4ee4\u5c06\u63a7\u4ef6\u7c7b\u9644\u52a0\u5230\u7ec4\u4ef6\u3002\u4ee5\u4e0b\u4ee3\u7801\u521b\u5efa\u540d [&hellip;]<\/p>\n","protected":false},"author":32,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[67],"tags":[1159,1155,1158,1160,1156,1157,1154,602,1048,1153,513,1152],"class_list":["post-6918","post","type-post","status-publish","format-standard","hentry","category-websdk","tag-controller","tag-customize","tag-dynamic-control","tag-event","tag-right-sidebar","tag-tab","tag-1154","tag-602","tag-1048","tag-1153","tag-513","tag-1152"],"pp_statuses_selecting_workflow":false,"pp_workflow_action":"current","pp_status_selection":"publish","_links":{"self":[{"href":"https:\/\/support.fuxinsoft.cn\/index.php?rest_route=\/wp\/v2\/posts\/6918","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/support.fuxinsoft.cn\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/support.fuxinsoft.cn\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/support.fuxinsoft.cn\/index.php?rest_route=\/wp\/v2\/users\/32"}],"replies":[{"embeddable":true,"href":"https:\/\/support.fuxinsoft.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=6918"}],"version-history":[{"count":2,"href":"https:\/\/support.fuxinsoft.cn\/index.php?rest_route=\/wp\/v2\/posts\/6918\/revisions"}],"predecessor-version":[{"id":7136,"href":"https:\/\/support.fuxinsoft.cn\/index.php?rest_route=\/wp\/v2\/posts\/6918\/revisions\/7136"}],"wp:attachment":[{"href":"https:\/\/support.fuxinsoft.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=6918"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/support.fuxinsoft.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=6918"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/support.fuxinsoft.cn\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=6918"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}