{"id":7658,"date":"2025-12-30T17:11:40","date_gmt":"2025-12-30T09:11:40","guid":{"rendered":"https:\/\/support.fuxinsoft.cn\/?p=7658"},"modified":"2025-12-31T15:21:26","modified_gmt":"2025-12-31T07:21:26","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-2","status":"publish","type":"post","link":"https:\/\/support.fuxinsoft.cn\/?p=7658","title":{"rendered":"\u5982\u4f55\u5728\u53f3\u4fa7\u8fb9\u680f\u4e2d\u589e\u52a0\u4e00\u4e2a\u81ea\u5b9a\u4e49\u7684Tab\u6807\u7b7e\u9875\uff0c\u5e76\u53ef\u4ee5\u52a8\u6001\u63a7\u5236\u5176\u51fa\u73b0\u7684\u65f6\u673a\uff1f"},"content":{"rendered":"\n<pre class=\"wp-block-code\"><code>\n```javascript\n\/\/\u7528\u6237\u81ea\u5b9a\u4e49\u51fd\u6570\nfunction testFun() {\n    alert(\"Button was Clicked !\");\n}\n\/\/@controller \u6307\u4ee4\u7528\u4e8e\u5c06\u4e00\u4e2a\u63a7\u4ef6\u7c7b\u9644\u52a0\u5230\u7ec4\u4ef6\u4e0a\u3002\u63a7\u4ef6\u7c7b\u5fc5\u987b\u5728\u6a21\u5757\u4e2d\u6ce8\u518c\u3002\u4e0b\u8ff0\u4ee3\u7801\u5219\u5c55\u793a\u4e86\uff1a\u521b\u5efa\u4e00\u4e2a\u540d\u4e3a\u201ccustom\u201d\u7684\u6a21\u5757\uff0c\u5e76\u5728\u8be5\u6a21\u5757\u4e2d\u6ce8\u518c\u4e86\u4e24\u4e2a\u63a7\u4ef6\u7c7b\uff0c\u5206\u522b\u4e3aMyController1 \u548c MyController2\uff0c\u540e\u7eed\u5728\u81ea\u5b9a\u4e49UI\u65f6\uff0c\u53ef\u4ee5\u5728\u7ec4\u4ef6\u4e2d\u4f7f\u7528@controller\u6307\u4ee4\uff0c\u5e76\u5728\u5176\u63a7\u4ef6\u7c7b\u7684\u5904\u7406\u51fd\u6570\u4e2d\u96c6\u6210\u66f4\u591a\u4e1a\u52a1\u529f\u80fd\u3002\nUIExtension.PDFUI.module('custom', &#91;])\n    .controller('MyController1', {\n        handle: function () {\n            alert('diyBtn was clicked !');\n        }\n    })\n    .controller('MyController2', {\n        handle: function () {\n            alert('The document will be closed !');\n            pdfui.close();\n        }\n    });\n\n\/\/\u5c01\u88c5\u4e00\u4e2a\u51fd\u6570\uff0c\u7528\u4e8e\u5728PDFUI\u7684\u5185\u7f6e\u53f3\u4fa7\u8fb9\u680f\u4e2d\u63d2\u5165\u4e00\u4e2a\u65b0\u7684\u9009\u9879\u5361\u9762\u677f\uff0c\u5e76\u4e3a\u8be5\u9762\u677f\u4e2d\u7684\u4e00\u4e9b\u5143\u7d20\u6dfb\u52a0\u4e8b\u4ef6\u76d1\u542c\u5668\u3002\nasync 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\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}\n\n\/\/\u5c55\u5f00\u6216\u6298\u53e0\u53f3\u4fa7\u8fb9\u680f\u9009\u9879\u5361\u9762\u677f\uff0c\u5e76\u5c55\u793a\u6216\u9690\u85cf\u6307\u5b9a\u9009\u9879\u5361\u3002\n\/\/\u5176\u4e2d\uff0c\u7b2c\u4e00\u4e2a\u53c2\u6570\u4e3a\u7ec4\u4ef6\u7684\u540d\u79f0\uff0c\u5982Line 27\u4e2d\u7684\u201cname\u201d\uff1b\u7b2c\u4e8c\u4e2a\u53c2\u6570\u4e3a\u5e03\u5c14\u503c\uff0ctrue\u4ee3\u8868\u5c55\u5f00\u6307\u5b9a\u7684Tab\u6807\u7b7e\u9009\u9879\u5361\uff0cfalse\u4ee3\u8868\u9690\u85cf\nasync 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\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\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\u8fb9\u680f\n    }\n}\n\/\/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\u8fb9\u680f\u4e2d\u63d2\u5165\u4e00\u4e2a\u65b0\u7684\u9009\u9879\u5361\u9762\u677f\npdfui.addUIEventListener(UIExtension.UIEvents.initializationCompleted, async function () {\n    insertDIYRightSidebarTab();\n})\n\n\/\/\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);\n```\n\n\u5982\u679c\u4e0d\u5e0c\u671b\u4e0a\u8ff0\u81ea\u5b9a\u4e49\u7684\u6807\u7b7e\u9875\u88ab\u5173\u95ed\uff0c\u53ef\u4ee5\u5728\u9875\u9762\u7684`&lt;style>`\u6837\u5f0f\u4e2d\u52a0\u5165\u4ee5\u4e0b\u6837\u5f0f\u4ee3\u7801\uff0c\u5c06\u201c\u5173\u95ed\u6807\u7b7e\u9875\u201d\u5143\u7d20\u9690\u85cf\uff1a\n```css\n.fv__ui-sidebar-right-tabs .fv__ui-sidebar-right-navlist .fv__ui-sidebar-nav-close {\n\u00a0 \u00a0 display: none;\n}\n```\n<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n","protected":false},"excerpt":{"rendered":"","protected":false},"author":32,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[67],"tags":[1283,1157,714,1264,1285,602,1048,1284,862,1282],"class_list":["post-7658","post","type-post","status-publish","format-standard","hentry","category-websdk","tag-pdfui","tag-tab","tag-714","tag-1264","tag-1285","tag-602","tag-1048","tag-1284","tag-862","tag-1282"],"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\/7658","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=7658"}],"version-history":[{"count":2,"href":"https:\/\/support.fuxinsoft.cn\/index.php?rest_route=\/wp\/v2\/posts\/7658\/revisions"}],"predecessor-version":[{"id":7727,"href":"https:\/\/support.fuxinsoft.cn\/index.php?rest_route=\/wp\/v2\/posts\/7658\/revisions\/7727"}],"wp:attachment":[{"href":"https:\/\/support.fuxinsoft.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=7658"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/support.fuxinsoft.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=7658"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/support.fuxinsoft.cn\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=7658"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}