index.vue 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246
  1. <template>
  2. <div :class="classObj" class="app-wrapper" :style="{ '--current-color': theme }">
  3. <div v-if="device === 'mobile' && sidebar.opened" class="drawer-bg" @click="handleClickOutside" />
  4. <!-- 全宽顶部导航栏,固定在页面最上方 -->
  5. <navbar ref="navbarRef" @setLayout="setLayout" class="global-navbar" />
  6. <side-bar v-if="!sidebar.hide" class="sidebar-container" />
  7. <div :class="{ hasTagsView: needTagsView, sidebarHide: sidebar.hide }" class="main-container">
  8. <div :class="{ 'fixed-header': fixedHeader }">
  9. <tags-view v-if="needTagsView" />
  10. </div>
  11. <app-main />
  12. <settings ref="settingRef" />
  13. </div>
  14. </div>
  15. <Transition name="slide-fade">
  16. <div v-if="showEmailDialog" class="email-dialog-container">
  17. <template v-for="(item, index) in emailData">
  18. <div class="email-dialog flex-center" @click="goEmail(item, index)">
  19. <div class="flex" style="position: relative">
  20. <img src="../assets/images/email-img.png" />
  21. <span class="badge">{{ unReadCount }}</span>
  22. </div>
  23. <div class="email-detail">
  24. <p class="bold">{{ item.fromName || item.from }}</p>
  25. <p>{{ item.subject }}</p>
  26. <!-- <p class="content" v-html="item.content"></p> -->
  27. </div>
  28. <el-icon :size="18" @click.stop="closeEmailDialog(index)"><Close /></el-icon>
  29. </div>
  30. </template>
  31. </div>
  32. </Transition>
  33. </template>
  34. <script setup lang="ts">
  35. import SideBar from './components/Sidebar/index.vue'
  36. import { AppMain, Navbar, Settings, TagsView } from './components'
  37. import useAppStore from '@/store/modules/app'
  38. import useSettingsStore from '@/store/modules/settings'
  39. import useNoticeStore from '@/store/modules/notice';
  40. const noticeStore = storeToRefs(useNoticeStore());
  41. const settingsStore = useSettingsStore()
  42. const theme = computed(() => settingsStore.theme);
  43. const sidebar = computed(() => useAppStore().sidebar);
  44. const device = computed(() => useAppStore().device);
  45. const needTagsView = computed(() => settingsStore.tagsView);
  46. const fixedHeader = computed(() => settingsStore.fixedHeader);
  47. const emailObj = computed(() => noticeStore.state.value.emailNoReadObj);
  48. const showEmailDialog = ref(false)
  49. const classObj = computed(() => ({
  50. hideSidebar: !sidebar.value.opened,
  51. openSidebar: sidebar.value.opened,
  52. withoutAnimation: sidebar.value.withoutAnimation,
  53. mobile: device.value === 'mobile'
  54. }))
  55. const { width } = useWindowSize();
  56. const WIDTH = 992; // refer to Bootstrap's responsive design
  57. watchEffect(() => {
  58. if (device.value === 'mobile' && sidebar.value.opened) {
  59. useAppStore().closeSideBar({ withoutAnimation: false })
  60. }
  61. if (width.value - 1 < WIDTH) {
  62. useAppStore().toggleDevice('mobile')
  63. useAppStore().closeSideBar({ withoutAnimation: true })
  64. } else {
  65. useAppStore().toggleDevice('desktop')
  66. }
  67. })
  68. const emailData = ref([])
  69. const unReadCount = ref(0)
  70. watch(emailObj, (newVal, oldVal) => {
  71. if(newVal.maills && newVal.maills.length > 0) {
  72. unReadCount.value = newVal.unReadCount
  73. emailData.value.push(...newVal.maills)
  74. emailData.value = emailData.value.slice(-3)
  75. showEmailDialog.value = true
  76. }
  77. }, { deep: true })
  78. const closeEmailDialog = (index: number) => {
  79. emailData.value.splice(index, 1)
  80. if(emailData.value.length == 0) {
  81. showEmailDialog.value = false
  82. }
  83. }
  84. const router = useRouter();
  85. const goEmail = (item: any, index: number) => {
  86. const { href } = router.resolve({
  87. path: '/customer/followPanel/detail',
  88. query: {
  89. id: item.id,
  90. resourceType: item.customerForm
  91. }
  92. })
  93. window.open(href)
  94. closeEmailDialog(index)
  95. }
  96. const navbarRef = ref(Navbar);
  97. const settingRef = ref(Settings);
  98. const channel = new BroadcastChannel('email_channel');
  99. channel.onmessage = (event) => {
  100. useNoticeStore().getCount()
  101. };
  102. onMounted(() => {
  103. nextTick(() => {
  104. })
  105. })
  106. const handleClickOutside = () => {
  107. useAppStore().closeSideBar({ withoutAnimation: false })
  108. }
  109. const setLayout = () => {
  110. settingRef.value.openSetting();
  111. }
  112. </script>
  113. <style lang="scss" scoped>
  114. @import "@/assets/styles/mixin.scss";
  115. @import "@/assets/styles/variables.module.scss";
  116. .app-wrapper {
  117. @include clearfix;
  118. position: relative;
  119. height: 100%;
  120. width: 100%;
  121. &.mobile.openSidebar {
  122. position: fixed;
  123. top: 0;
  124. }
  125. }
  126. .global-navbar {
  127. position: fixed;
  128. top: 0;
  129. left: 0;
  130. right: 0;
  131. z-index: 1002;
  132. }
  133. .drawer-bg {
  134. background: #000;
  135. opacity: 0.3;
  136. width: 100%;
  137. top: 0;
  138. height: 100%;
  139. position: absolute;
  140. z-index: 999;
  141. }
  142. .fixed-header {
  143. position: fixed;
  144. top: $navbar-height;
  145. right: 0;
  146. z-index: 9;
  147. width: calc(100% - #{$base-sidebar-width});
  148. transition: width 0.28s;
  149. background: $fixed-header-bg;
  150. }
  151. .hideSidebar .fixed-header {
  152. width: calc(100% - 54px);
  153. }
  154. .sidebarHide .fixed-header {
  155. width: 100%;
  156. }
  157. .mobile .fixed-header {
  158. width: 100%;
  159. }
  160. .email-dialog-container{
  161. position: absolute;
  162. bottom: 25px;
  163. right: 25px;
  164. z-index: 99999;
  165. }
  166. .email-dialog {
  167. width: 400px;
  168. height: 80px;
  169. box-shadow: 0px 0px 7px 0px rgba(0,0,0,0.1);
  170. border-radius: 2px;
  171. background-color: #ECF5FF;
  172. padding: 10px;
  173. cursor: pointer;
  174. margin-top: 15px;
  175. position: relative;
  176. .badge{
  177. position: absolute;
  178. top: 2px;
  179. right: 8px;
  180. background: #F40003;
  181. color: #FFF;
  182. border-radius: 50%;
  183. font-size: 12px;
  184. width: 18px;
  185. height: 18px;
  186. text-align: center;
  187. }
  188. .email-detail{
  189. flex: 1;
  190. width: 0;
  191. margin-left: 8px;
  192. color: #333;
  193. p{
  194. overflow: hidden;
  195. text-overflow: ellipsis;
  196. white-space: nowrap;
  197. }
  198. .content{
  199. color: #999
  200. }
  201. }
  202. .el-icon{
  203. position: absolute;
  204. top: 7px;
  205. right: 7px;
  206. cursor: pointer;
  207. }
  208. }
  209. .slide-fade-enter-active {
  210. transition: all 0.5s ease-out;
  211. }
  212. .slide-fade-leave-active {
  213. transition: all 0.8s cubic-bezier(1, 0.5, 0.8, 1);
  214. }
  215. .slide-fade-enter-from,
  216. .slide-fade-leave-to {
  217. transform: translateX(20px);
  218. opacity: 0;
  219. }
  220. </style>