useRenderLayout.tsx 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306
  1. import { computed } from 'vue'
  2. import { useAppStore } from '@/store/modules/app'
  3. import { Menu } from '@/components/Menu'
  4. import { TabMenu } from '@/components/TabMenu'
  5. import { TagsView } from '@/components/TagsView'
  6. import { Logo } from '@/components/Logo'
  7. import AppView from './AppView.vue'
  8. import ToolHeader from './ToolHeader.vue'
  9. import { ElScrollbar } from 'element-plus'
  10. import { useDesign } from '@/hooks/web/useDesign'
  11. const { getPrefixCls } = useDesign()
  12. const prefixCls = getPrefixCls('layout')
  13. const appStore = useAppStore()
  14. const pageLoading = computed(() => appStore.getPageLoading)
  15. // 标签页
  16. const tagsView = computed(() => appStore.getTagsView)
  17. // 菜单折叠
  18. const collapse = computed(() => appStore.getCollapse)
  19. // logo
  20. const logo = computed(() => appStore.logo)
  21. // 固定头部
  22. const fixedHeader = computed(() => appStore.getFixedHeader)
  23. // 是否是移动端
  24. const mobile = computed(() => appStore.getMobile)
  25. // 固定菜单
  26. const fixedMenu = computed(() => appStore.getFixedMenu)
  27. export const useRenderLayout = () => {
  28. const renderClassic = () => {
  29. return (
  30. <>
  31. <div
  32. class={[
  33. 'absolute top-0 left-0 h-full layout-border__right',
  34. { '!fixed z-3000': mobile.value }
  35. ]}
  36. >
  37. {logo.value ? (
  38. <Logo
  39. class={[
  40. 'bg-[var(--left-menu-bg-color)] relative',
  41. {
  42. '!pl-0': mobile.value && collapse.value,
  43. 'w-[var(--left-menu-min-width)]': appStore.getCollapse,
  44. 'w-[var(--left-menu-max-width)]': !appStore.getCollapse
  45. }
  46. ]}
  47. style="transition: all var(--transition-time-02);"
  48. ></Logo>
  49. ) : undefined}
  50. <Menu class={[{ '!h-[calc(100%-var(--logo-height))]': logo.value }]}></Menu>
  51. </div>
  52. <div
  53. class={[
  54. `${prefixCls}-content`,
  55. 'absolute top-0 h-[100%]',
  56. {
  57. 'w-[calc(100%-var(--left-menu-min-width))] left-[var(--left-menu-min-width)]':
  58. collapse.value && !mobile.value && !mobile.value,
  59. 'w-[calc(100%-var(--left-menu-max-width))] left-[var(--left-menu-max-width)]':
  60. !collapse.value && !mobile.value && !mobile.value,
  61. 'fixed !w-full !left-0': mobile.value
  62. }
  63. ]}
  64. style="transition: all var(--transition-time-02);"
  65. >
  66. <ElScrollbar
  67. v-loading={pageLoading.value}
  68. class={[
  69. `${prefixCls}-content-scrollbar`,
  70. {
  71. '!h-[calc(100%-var(--top-tool-height)-var(--tags-view-height))] mt-[calc(var(--top-tool-height)+var(--tags-view-height))]':
  72. fixedHeader.value
  73. }
  74. ]}
  75. >
  76. <div
  77. class={[
  78. {
  79. 'fixed top-0 left-0 z-10': fixedHeader.value,
  80. 'w-[calc(100%-var(--left-menu-min-width))] !left-[var(--left-menu-min-width)]':
  81. collapse.value && fixedHeader.value && !mobile.value,
  82. 'w-[calc(100%-var(--left-menu-max-width))] !left-[var(--left-menu-max-width)]':
  83. !collapse.value && fixedHeader.value && !mobile.value,
  84. '!w-full !left-0': mobile.value
  85. }
  86. ]}
  87. style="transition: all var(--transition-time-02);"
  88. >
  89. <ToolHeader
  90. class={[
  91. 'bg-[var(--top-header-bg-color)]',
  92. {
  93. 'layout-border__bottom': !tagsView.value
  94. }
  95. ]}
  96. ></ToolHeader>
  97. {tagsView.value ? (
  98. <TagsView class="layout-border__bottom layout-border__top"></TagsView>
  99. ) : undefined}
  100. </div>
  101. <AppView></AppView>
  102. </ElScrollbar>
  103. </div>
  104. </>
  105. )
  106. }
  107. const renderTopLeft = () => {
  108. return (
  109. <>
  110. <div class="flex items-center bg-[var(--top-header-bg-color)] relative layout-border__bottom dark:bg-[var(--el-bg-color)]">
  111. {logo.value ? <Logo class="custom-hover"></Logo> : undefined}
  112. <ToolHeader class="flex-1"></ToolHeader>
  113. </div>
  114. <div class="absolute top-[var(--logo-height)+1px] left-0 w-full h-[calc(100%-1px-var(--logo-height))] flex">
  115. <Menu class="!h-full relative layout-border__right"></Menu>
  116. <div
  117. class={[
  118. `${prefixCls}-content`,
  119. 'h-[100%]',
  120. {
  121. 'w-[calc(100%-var(--left-menu-min-width))] left-[var(--left-menu-min-width)]':
  122. collapse.value,
  123. 'w-[calc(100%-var(--left-menu-max-width))] left-[var(--left-menu-max-width)]':
  124. !collapse.value
  125. }
  126. ]}
  127. style="transition: all var(--transition-time-02);"
  128. >
  129. <ElScrollbar
  130. v-loading={pageLoading.value}
  131. class={[
  132. `${prefixCls}-content-scrollbar`,
  133. {
  134. '!h-[calc(100%-var(--tags-view-height))] mt-[calc(var(--tags-view-height))]':
  135. fixedHeader.value && tagsView.value
  136. }
  137. ]}
  138. >
  139. {tagsView.value ? (
  140. <TagsView
  141. class={[
  142. 'layout-border__bottom absolute',
  143. {
  144. '!fixed top-0 left-0 z-10': fixedHeader.value,
  145. 'w-[calc(100%-var(--left-menu-min-width))] !left-[var(--left-menu-min-width)] mt-[calc(var(--logo-height)+1px)]':
  146. collapse.value && fixedHeader.value,
  147. 'w-[calc(100%-var(--left-menu-max-width))] !left-[var(--left-menu-max-width)] mt-[calc(var(--logo-height)+1px)]':
  148. !collapse.value && fixedHeader.value
  149. }
  150. ]}
  151. style="transition: width var(--transition-time-02), left var(--transition-time-02);"
  152. ></TagsView>
  153. ) : undefined}
  154. <AppView></AppView>
  155. </ElScrollbar>
  156. </div>
  157. </div>
  158. </>
  159. )
  160. }
  161. const renderTop = () => {
  162. return (
  163. <>
  164. <div
  165. class={[
  166. 'flex items-center justify-between bg-[var(--top-header-bg-color)] relative',
  167. {
  168. 'layout-border__bottom': !tagsView.value
  169. }
  170. ]}
  171. >
  172. {logo.value ? <Logo class="custom-hover"></Logo> : undefined}
  173. <Menu class="flex-1 px-10px h-[var(--top-tool-height)]"></Menu>
  174. <ToolHeader></ToolHeader>
  175. </div>
  176. <div
  177. class={[
  178. `${prefixCls}-content`,
  179. 'w-full',
  180. {
  181. 'h-[calc(100%-var(--app-footer-height))]': !fixedHeader.value,
  182. 'h-[calc(100%-var(--tags-view-height)-var(--app-footer-height))]': fixedHeader.value
  183. }
  184. ]}
  185. >
  186. <ElScrollbar
  187. v-loading={pageLoading.value}
  188. class={[
  189. `${prefixCls}-content-scrollbar`,
  190. {
  191. 'mt-[var(--tags-view-height)] !pb-[calc(var(--tags-view-height)+var(--app-footer-height))]':
  192. fixedHeader.value,
  193. 'pb-[var(--app-footer-height)]': !fixedHeader.value
  194. }
  195. ]}
  196. >
  197. {tagsView.value ? (
  198. <TagsView
  199. class={[
  200. 'layout-border__bottom layout-border__top relative',
  201. {
  202. '!fixed w-full top-[calc(var(--top-tool-height)+1px)] left-0': fixedHeader.value
  203. }
  204. ]}
  205. style="transition: width var(--transition-time-02), left var(--transition-time-02);"
  206. ></TagsView>
  207. ) : undefined}
  208. <AppView></AppView>
  209. </ElScrollbar>
  210. </div>
  211. </>
  212. )
  213. }
  214. const renderCutMenu = () => {
  215. return (
  216. <>
  217. <div class="flex items-center bg-[var(--top-header-bg-color)] relative layout-border__bottom">
  218. {logo.value ? <Logo class="custom-hover !pr-15px"></Logo> : undefined}
  219. <ToolHeader class="flex-1"></ToolHeader>
  220. </div>
  221. <div class="absolute top-[var(--logo-height)] left-0 w-[calc(100%-2px)] h-[calc(100%-var(--logo-height))] flex">
  222. <TabMenu></TabMenu>
  223. <div
  224. class={[
  225. `${prefixCls}-content`,
  226. 'h-[100%]',
  227. {
  228. 'w-[calc(100%-var(--tab-menu-min-width))] left-[var(--tab-menu-min-width)]':
  229. collapse.value && !fixedMenu.value,
  230. 'w-[calc(100%-var(--tab-menu-max-width))] left-[var(--tab-menu-max-width)]':
  231. !collapse.value && !fixedMenu.value,
  232. 'w-[calc(100%-var(--tab-menu-min-width)-var(--left-menu-max-width))] ml-[var(--left-menu-max-width)]':
  233. collapse.value && fixedMenu.value,
  234. 'w-[calc(100%-var(--tab-menu-max-width)-var(--left-menu-max-width))] ml-[var(--left-menu-max-width)]':
  235. !collapse.value && fixedMenu.value
  236. }
  237. ]}
  238. style="transition: all var(--transition-time-02);"
  239. >
  240. <ElScrollbar
  241. v-loading={pageLoading.value}
  242. class={[
  243. `${prefixCls}-content-scrollbar`,
  244. {
  245. '!h-[calc(100%-var(--tags-view-height))] mt-[calc(var(--tags-view-height))]':
  246. fixedHeader.value && tagsView.value
  247. }
  248. ]}
  249. >
  250. {tagsView.value ? (
  251. <TagsView
  252. class={[
  253. 'relative layout-border__bottom layout-border__top',
  254. {
  255. '!fixed top-0 left-0 z-10': fixedHeader.value,
  256. 'w-[calc(100%-var(--tab-menu-min-width))] !left-[var(--tab-menu-min-width)] mt-[var(--logo-height)]':
  257. collapse.value && fixedHeader.value,
  258. 'w-[calc(100%-var(--tab-menu-max-width))] !left-[var(--tab-menu-max-width)] mt-[var(--logo-height)]':
  259. !collapse.value && fixedHeader.value,
  260. '!fixed top-0 !left-[var(--tab-menu-min-width)+var(--left-menu-max-width)] z-10':
  261. fixedHeader.value && fixedMenu.value,
  262. 'w-[calc(100%-var(--tab-menu-min-width)-var(--left-menu-max-width))] !left-[var(--tab-menu-min-width)+var(--left-menu-max-width)] mt-[var(--logo-height)]':
  263. collapse.value && fixedHeader.value && fixedMenu.value,
  264. 'w-[calc(100%-var(--tab-menu-max-width)-var(--left-menu-max-width))] !left-[var(--tab-menu-max-width)+var(--left-menu-max-width)] mt-[var(--logo-height)]':
  265. !collapse.value && fixedHeader.value && fixedMenu.value
  266. }
  267. ]}
  268. style="transition: width var(--transition-time-02), left var(--transition-time-02);"
  269. ></TagsView>
  270. ) : undefined}
  271. <AppView></AppView>
  272. </ElScrollbar>
  273. </div>
  274. </div>
  275. </>
  276. )
  277. }
  278. return {
  279. renderClassic,
  280. renderTopLeft,
  281. renderTop,
  282. renderCutMenu
  283. }
  284. }