common_sider.html 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. {{define "menuItems"}}
  2. <a-menu-item key="{{ .base_path }}xui/">
  3. <a-icon type="dashboard"></a-icon>
  4. <span>{{ i18n "menu.dashboard"}}</span>
  5. </a-menu-item>
  6. <a-menu-item key="{{ .base_path }}xui/inbounds">
  7. <a-icon type="user"></a-icon>
  8. <span>{{ i18n "menu.inbounds"}}</span>
  9. </a-menu-item>
  10. <a-menu-item key="{{ .base_path }}xui/setting">
  11. <a-icon type="setting"></a-icon>
  12. <span>{{ i18n "menu.setting"}}</span>
  13. </a-menu-item>
  14. <!--<a-menu-item key="{{ .base_path }}xui/clients">-->
  15. <!-- <a-icon type="laptop"></a-icon>-->
  16. <!-- <span>client</span>-->
  17. <!--</a-menu-item>-->
  18. <a-sub-menu>
  19. <template slot="title">
  20. <a-icon type="link"></a-icon>
  21. <span>{{ i18n "menu.link"}}</span>
  22. </template>
  23. <a-menu-item key="https://github.com/mhsanaei/3x-ui/">
  24. <a-icon type="github"></a-icon>
  25. <span>Github</span>
  26. </a-menu-item>
  27. <a-menu-item key="https://t.me/panel3xui">
  28. <a-icon type="usergroup-add"></a-icon>
  29. <span>Telegram</span>
  30. </a-menu-item>
  31. </a-sub-menu>
  32. <a-menu-item key="{{ .base_path }}logout">
  33. <a-icon type="logout"></a-icon>
  34. <span>{{ i18n "menu.logout"}}</span>
  35. </a-menu-item>
  36. {{end}}
  37. {{define "commonSider"}}
  38. <a-layout-sider :theme="siderDrawer.theme" id="sider" collapsible breakpoint="md" collapsed-width="0">
  39. <a-menu :theme="siderDrawer.theme" mode="inline" selected-keys="">
  40. <a-menu-item mode="inline">
  41. <a-icon type="bg-colors"></a-icon>
  42. <a-switch :default-checked="siderDrawer.isDarkTheme"
  43. checked-children="☀"
  44. un-checked-children="🌙"
  45. @change="siderDrawer.changeTheme()"></a-switch>
  46. </a-menu-item>
  47. </a-menu>
  48. <a-menu :theme="siderDrawer.theme" mode="inline" :selected-keys="['{{ .request_uri }}']"
  49. @click="({key}) => key.startsWith('http') ? window.open(key) : location.href = key">
  50. {{template "menuItems" .}}
  51. </a-menu>
  52. </a-layout-sider>
  53. <a-drawer id="sider-drawer" placement="left" :closable="false"
  54. @close="siderDrawer.close()"
  55. :visible="siderDrawer.visible"
  56. :wrap-style="{ padding: 0 }">
  57. <div class="drawer-handle" @click="siderDrawer.change()" slot="handle">
  58. <a-icon :type="siderDrawer.visible ? 'close' : 'menu-fold'"></a-icon>
  59. </div>
  60. <a-menu mode="inline" selected-keys="">
  61. <a-menu-item mode="inline">
  62. <a-icon type="bg-colors"></a-icon>
  63. <a-switch :default-checked="siderDrawer.isDarkTheme"
  64. checked-children="☀"
  65. un-checked-children="🌙"
  66. @change="siderDrawer.changeTheme()"></a-switch>
  67. </a-menu-item>
  68. </a-menu>
  69. <a-menu mode="inline" :selected-keys="['{{ .request_uri }}']"
  70. @click="({key}) => key.startsWith('http') ? window.open(key) : location.href = key">
  71. {{template "menuItems" .}}
  72. </a-menu>
  73. </a-drawer>
  74. <script>
  75. const darkClass = "ant-card-dark";
  76. const bgDarkStyle = "background-color: #242c3a";
  77. const siderDrawer = {
  78. visible: false,
  79. collapsed: false,
  80. isDarkTheme: localStorage.getItem("dark-mode") === 'true' ? true : false,
  81. show() {
  82. this.visible = true;
  83. },
  84. close() {
  85. this.visible = false;
  86. },
  87. change() {
  88. this.visible = !this.visible;
  89. },
  90. toggleCollapsed() {
  91. this.collapsed = !this.collapsed;
  92. },
  93. changeTheme() {
  94. this.isDarkTheme = ! this.isDarkTheme;
  95. localStorage.setItem("dark-mode", this.isDarkTheme);
  96. },
  97. get theme() {
  98. return this.isDarkTheme ? 'dark' : 'light';
  99. }
  100. };
  101. </script>
  102. {{end}}