index.vue 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265
  1. <template>
  2. <div class="navbar">
  3. <div class="left-side">
  4. <a-space style="cursor: pointer; -webkit-app-region: no-drag;" @click="$router.push('/')">
  5. <img alt="RunForge" src="/logo.svg" height="35">
  6. <a-typography-title class="brand-title" :style="{ margin: 0, fontSize: '18px' }" :heading="5">
  7. RunForge
  8. </a-typography-title>
  9. </a-space>
  10. </div>
  11. <ul class="right-side">
  12. <li v-if="!isElectron()" class="desktop-shortcut">
  13. <a-tooltip content="首页">
  14. <a-button class="nav-btn" type="outline" :shape="'circle'" @click="$router.push('/')">
  15. <template #icon>
  16. <icon-home />
  17. </template>
  18. </a-button>
  19. </a-tooltip>
  20. </li>
  21. <li v-if="!isElectron()" class="desktop-shortcut">
  22. <a-tooltip content="售后服务">
  23. <a-button class="nav-btn" type="outline" :shape="'circle'" @click="$router.push('/service/createOrder')">
  24. <template #icon>
  25. <icon-customer-service />
  26. </template>
  27. </a-button>
  28. </a-tooltip>
  29. </li>
  30. <li v-if="!isElectron()" class="desktop-shortcut">
  31. <a-tooltip content="下载专区">
  32. <a-button class="nav-btn" type="outline" :shape="'circle'" @click="$router.push('/download')">
  33. <template #icon>
  34. <icon-download />
  35. </template>
  36. </a-button>
  37. </a-tooltip>
  38. </li>
  39. <li v-if="!isElectron()" class="desktop-shortcut">
  40. <a-tooltip content="文档中心">
  41. <a-button class="nav-btn" type="outline" :shape="'circle'" @click="$router.push('/doc')">
  42. <template #icon>
  43. <icon-book />
  44. </template>
  45. </a-button>
  46. </a-tooltip>
  47. </li>
  48. <li v-if="!isElectron()" class="mobile-shortcut">
  49. <a-dropdown trigger="click" position="br">
  50. <a-button class="nav-btn" type="outline" :shape="'circle'">
  51. <template #icon>
  52. <icon-more />
  53. </template>
  54. </a-button>
  55. <template #content>
  56. <a-doption @click="$router.push('/')">
  57. <icon-home /> 首页
  58. </a-doption>
  59. <a-doption @click="$router.push('/service/createOrder')">
  60. <icon-customer-service /> 售后服务
  61. </a-doption>
  62. <a-doption @click="$router.push('/download')">
  63. <icon-download /> 下载专区
  64. </a-doption>
  65. <a-doption @click="$router.push('/doc')">
  66. <icon-book /> 文档中心
  67. </a-doption>
  68. </template>
  69. </a-dropdown>
  70. </li>
  71. <li v-if="avatar">
  72. <a-dropdown trigger="hover">
  73. <a-avatar class="nav-btn" :size="32" :style="{ marginRight: '8px', cursor: 'pointer' }">
  74. <img alt="avatar" :src="avatar" />
  75. </a-avatar>
  76. <template #content>
  77. <a-doption>
  78. <a-space @click="$router.push('/user')">
  79. <icon-user />
  80. <span>
  81. 个人中心
  82. </span>
  83. </a-space>
  84. </a-doption>
  85. <a-doption>
  86. <a-space @click="handleLogout">
  87. <icon-export />
  88. <span>
  89. 退出登录
  90. </span>
  91. </a-space>
  92. </a-doption>
  93. </template>
  94. </a-dropdown>
  95. </li>
  96. <div v-if="isElectron()">
  97. <a-button class="actions" type="text" @click="minimizeWindow">
  98. <template #icon>
  99. <icon-minus />
  100. </template>
  101. </a-button>
  102. <a-button class="actions" type="text" @click="maximizeWindow">
  103. <template #icon>
  104. <icon-fullscreen />
  105. </template>
  106. </a-button>
  107. <a-button class="actions close" type="text" @click="closeWindow">
  108. <template #icon>
  109. <icon-close />
  110. </template>
  111. </a-button>
  112. </div>
  113. </ul>
  114. </div>
  115. </template>
  116. <script setup>
  117. import { computed } from 'vue'
  118. import { Message, Modal } from '@arco-design/web-vue'
  119. import { useUserStore } from '@/store'
  120. import { isElectron } from '@/utils/electron'
  121. const userStore = useUserStore();
  122. const avatar = computed(() => {
  123. return userStore.avatar;
  124. })
  125. const handleLogout = () => {
  126. Modal.confirm({
  127. title: '退出登录',
  128. content: '您即将退出登录,是否继续?',
  129. onOk: () => {
  130. const userStore = useUserStore()
  131. userStore.logout()
  132. Message.success('退出成功!')
  133. setTimeout(() => { window.location.reload() }, 1000)
  134. },
  135. onCancel: () => {
  136. }
  137. })
  138. }
  139. function closeWindow() {
  140. window.electron.closeWindow() // 调用关闭窗口的方法
  141. }
  142. function minimizeWindow() {
  143. window.electron.minimizeWindow() // 调用最小化窗口的方法
  144. }
  145. function maximizeWindow() {
  146. window.electron.maximizeWindow() // 调用最大化窗口的方法
  147. }
  148. </script>
  149. <style scoped lang="less">
  150. .navbar {
  151. -webkit-app-region: drag;
  152. display: flex;
  153. justify-content: space-between;
  154. height: 100%;
  155. background-color: var(--color-bg-2);
  156. border-bottom: 1px solid var(--color-border);
  157. user-select: none;
  158. }
  159. .left-side {
  160. display: flex;
  161. align-items: center;
  162. padding-left: 20px;
  163. min-width: 0;
  164. }
  165. .brand-title {
  166. margin: 0;
  167. white-space: nowrap;
  168. line-height: 1;
  169. flex-shrink: 0;
  170. }
  171. .center-side {
  172. flex: 1;
  173. }
  174. .right-side {
  175. display: flex;
  176. padding-right: 30px;
  177. list-style: none;
  178. :deep(.locale-select) {
  179. border-radius: 20px;
  180. }
  181. li {
  182. display: flex;
  183. align-items: center;
  184. padding: 0 10px;
  185. }
  186. a {
  187. color: var(--color-text-1);
  188. text-decoration: none;
  189. }
  190. .nav-btn {
  191. -webkit-app-region: no-drag;
  192. border-color: rgb(var(--gray-2));
  193. color: rgb(var(--gray-8));
  194. font-size: 16px;
  195. }
  196. .trigger-btn,
  197. .ref-btn {
  198. position: absolute;
  199. bottom: 14px;
  200. }
  201. .trigger-btn {
  202. margin-left: 14px;
  203. }
  204. }
  205. .actions {
  206. color: rgb(var(--gray-8));
  207. -webkit-app-region: no-drag;
  208. }
  209. .close:hover {
  210. background-color: rgb(var(--red-5));
  211. color: white;
  212. }
  213. @media (max-width: 992px) {
  214. .brand-title {
  215. font-size: 16px !important;
  216. }
  217. .right-side {
  218. padding-right: 12px;
  219. }
  220. .right-side li {
  221. padding: 0 4px;
  222. }
  223. .desktop-shortcut {
  224. display: none !important;
  225. }
  226. }
  227. @media (min-width: 993px) {
  228. .mobile-shortcut {
  229. display: none !important;
  230. }
  231. }
  232. </style>