indexCommon.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432
  1. <template>
  2. <div class="common-layout">
  3. <el-container>
  4. <el-header
  5. class="nav"
  6. style="position: sticky; top: 0; left: 0; width: 100%; z-index: 999"
  7. >
  8. <div class="nav-top">
  9. <div>
  10. <img src="@/assets/images/logos.png" /><span
  11. >聚合智慧文档管理系统</span
  12. >
  13. </div>
  14. <div class="search">
  15. <el-input
  16. v-model="searchText"
  17. maxlength="32"
  18. class="w-50 m-2"
  19. size="small"
  20. placeholder="搜索文件"
  21. suffix-icon="Search"
  22. clearable
  23. @change="toSearch"
  24. @@keyup.enter="toSearch"
  25. />
  26. </div>
  27. <div>
  28. <el-dropdown
  29. @command="handleCommand"
  30. class="right-menu-item hover-effect"
  31. trigger="click"
  32. >
  33. <div class="avatar-wrapper">
  34. <img
  35. :src="
  36. userStore.avatar
  37. ? userStore.avatar
  38. : '@/assets/images/profile.png'
  39. "
  40. class="head-img"
  41. /><span>{{ userStore.name }}</span>
  42. </div>
  43. <template #dropdown>
  44. <el-dropdown-menu>
  45. <router-link to="/user/profile">
  46. <el-dropdown-item>个人中心</el-dropdown-item>
  47. </router-link>
  48. <el-dropdown-item divided command="logout">
  49. <span>退出登录</span>
  50. </el-dropdown-item>
  51. </el-dropdown-menu>
  52. </template>
  53. </el-dropdown>
  54. </div>
  55. </div>
  56. </el-header>
  57. <el-container>
  58. <el-aside width="92px" class="asides">
  59. <div class="aside-con">
  60. <router-link
  61. :to="item.path"
  62. v-for="(item, index) in menuList.data"
  63. :key="index"
  64. @click="clickPath(index, item)"
  65. ><div
  66. style="position: relative"
  67. :class="
  68. $route.path == item.path
  69. ? 'acitve-img-style img-style'
  70. : 'img-style'
  71. "
  72. >
  73. <img
  74. :src="$route.path == item.path ? item.beimgs : item.imgs"
  75. />
  76. <div class="text-style" v-if="$route.path != item.path">
  77. {{ item.label }}
  78. </div>
  79. <span
  80. class="yuandian"
  81. v-if="
  82. websoctStore.messOne?.fromId &&
  83. item.path == '/index' &&
  84. $route.path != item.path&&clickId!==index
  85. "
  86. ></span>
  87. </div> </router-link
  88. ><br />
  89. </div>
  90. </el-aside>
  91. <el-main class="main">
  92. <router-view v-if="isAlive"></router-view>
  93. </el-main>
  94. </el-container>
  95. </el-container>
  96. </div>
  97. </template>
  98. <script setup>
  99. import { nextTick, onMounted, provide, ref } from "vue";
  100. import { ElMessageBox } from "element-plus";
  101. import useAppStore from "@/store/modules/app";
  102. import useUserStore from "@/store/modules/user";
  103. import useSettingsStore from "@/store/modules/settings";
  104. import Cookies from "js-cookie";
  105. import chat from "@/assets/images/chat.png";
  106. import bechat from "@/assets/images/bechat.png";
  107. import zuijin from "@/assets/images/zuijin.png";
  108. import bezuijin from "@/assets/images/bezuijin.png";
  109. import colloect from "@/assets/images/colloect.png";
  110. import becolloect from "@/assets/images/becolloect.png";
  111. import system from "@/assets/images/system.png";
  112. import issystem from "@/assets/images/issystem.png";
  113. import my from "@/assets/images/my.png";
  114. import bemy from "@/assets/images/bemy.png";
  115. import bumen from "@/assets/images/bumen.png";
  116. import bebumen from "@/assets/images/bebumen.png";
  117. import common from "@/assets/images/common.png";
  118. import becommon from "@/assets/images/becommon.png";
  119. import chuanshu from "@/assets/images/chuanshu.png";
  120. import bechuanshu from "@/assets/images/bechuanshu.png";
  121. import highsearch from "@/assets/images/highsearch.png";
  122. import behighsearch from "@/assets/images/behighsearch.png";
  123. import manyBody from "@/assets/images/manyBody.png";
  124. import manyBodyFalse from "@/assets/images/manyBodyFalse.png";
  125. import { AppMain, Navbar, Settings, TagsView } from "./components";
  126. import { flieSearch } from "@/api/search/search.js";
  127. import { useRouter, useRoute } from "vue-router";
  128. import useWebsoctStore from "@/store/modules/websocket";
  129. const websoctStore = useWebsoctStore();
  130. const router = useRouter(); //注册路由
  131. const route = useRoute();
  132. const appStore = useAppStore();
  133. const userStore = useUserStore();
  134. const settingsStore = useSettingsStore();
  135. const searchText = ref(""); //搜索ipt的值
  136. const selectValue = ref(1); //文档空间类型
  137. const wangzhi=import.meta.env.VITE_APP_BASE_API
  138. const isAlive = ref(true);
  139. function reload() {
  140. isAlive.value = false;
  141. console.log(11);
  142. nextTick(() => {
  143. isAlive.value = true;
  144. });
  145. }
  146. provide("reload", reload);
  147. function toggleSideBar() {
  148. appStore.toggleSideBar();
  149. }
  150. const logingName = ref("");
  151. onMounted(() => {
  152. logingName.value = Cookies.get("username");
  153. // console.log('router',router)
  154. });
  155. function handleCommand(command) {
  156. switch (command) {
  157. case "setLayout":
  158. setLayout();
  159. break;
  160. case "logout":
  161. logout();
  162. break;
  163. default:
  164. break;
  165. }
  166. }
  167. function logout() {
  168. ElMessageBox.confirm("确定注销并退出系统吗?", "提示", {
  169. confirmButtonText: "确定",
  170. cancelButtonText: "取消",
  171. type: "warning",
  172. })
  173. .then(() => {
  174. userStore.logOut().then(() => {
  175. location.href = "/index";
  176. });
  177. })
  178. .catch(() => {});
  179. }
  180. // 跳转到全文搜索
  181. const toSearch = async () => {
  182. if (!searchText.value) return;
  183. // console.log('searchText = ',searchText.value);
  184. const query = {
  185. keyword: searchText.value,
  186. isAsc: "asc",
  187. orderByColumn: "createTime",
  188. pageSize:3,
  189. pageNum:1
  190. };
  191. const res = await flieSearch(query);
  192. // console.log("res", res);
  193. if (res) {
  194. // console.log("res", res);
  195. // console.log("router", route.path);
  196. if (route.path != "/search") {
  197. router.push({
  198. path: "/search",
  199. query: {
  200. searchData: JSON.stringify(res),
  201. searchText: searchText.value,
  202. },
  203. });
  204. } else {
  205. router.replace({
  206. path: "/allback",
  207. query: {
  208. searchData: JSON.stringify(res),
  209. searchText: searchText.value,
  210. },
  211. });
  212. }
  213. }
  214. };
  215. const emits = defineEmits(["setLayout"]);
  216. function setLayout() {
  217. emits("setLayout");
  218. }
  219. const clickId = ref("");
  220. const menuList = reactive({
  221. data: [
  222. {
  223. label: "会话消息",
  224. path: "/index",
  225. imgs: chat,
  226. beimgs: bechat,
  227. },
  228. // {
  229. // label: "接口",
  230. // path: "/swagger",
  231. // imgs: chat,
  232. // beimgs: bechat,
  233. // disabled:true
  234. // },
  235. {
  236. label: "最近文件",
  237. path: "/recent",
  238. imgs: zuijin,
  239. beimgs: bezuijin,
  240. },
  241. {
  242. label: "收藏文件",
  243. path: "/collect",
  244. imgs: colloect,
  245. beimgs: becolloect,
  246. },
  247. {
  248. label: "我的文件",
  249. path: "/myfile",
  250. imgs: my,
  251. beimgs: bemy,
  252. },
  253. {
  254. label: "部门文件",
  255. path: "/department",
  256. imgs: bumen,
  257. beimgs: bebumen,
  258. },
  259. {
  260. label: "公共文件",
  261. path: "/swagger",
  262. imgs: common,
  263. beimgs: becommon,
  264. },
  265. {
  266. label: "高级搜索",
  267. path: "/highsearch",
  268. imgs: highsearch,
  269. beimgs: behighsearch,
  270. },
  271. {
  272. label: "传输列表",
  273. path: "/transFile",
  274. imgs: chuanshu,
  275. beimgs: bechuanshu,
  276. },
  277. {
  278. label: "系统管理",
  279. path: "/admin",
  280. imgs: system,
  281. beimgs: issystem,
  282. },
  283. {
  284. label: "我的协作",
  285. path: "/myjoin",
  286. imgs: manyBody,
  287. beimgs: manyBodyFalse,
  288. },
  289. ],
  290. });
  291. const clickPath = (index, items) => {
  292. clickId.value = index;
  293. };
  294. </script>
  295. <style lang="scss" scoped>
  296. @import "@/assets/styles/mixin.scss";
  297. @import "@/assets/styles/variables.module.scss";
  298. //整体布局css
  299. .common-layout,
  300. .el-container {
  301. height: 94vh;
  302. }
  303. :deep .el-main {
  304. --el-main-padding: 8px !important;
  305. }
  306. .nav {
  307. background: #06286c;
  308. height: 48px;
  309. .nav-top {
  310. width: 98%;
  311. display: flex;
  312. justify-content: space-between;
  313. & > div:first-child {
  314. font-family: "Inter-SemiBold";
  315. }
  316. & > div:first-child,
  317. & > div:last-child {
  318. display: flex;
  319. align-items: center;
  320. color: #fff;
  321. & > img {
  322. width: 48px;
  323. height: 48px;
  324. }
  325. }
  326. }
  327. .head-img {
  328. border-radius: 12px;
  329. width: 24px;
  330. height: 24px;
  331. margin-right: 10px;
  332. }
  333. .avatar-wrapper {
  334. color: #fff;
  335. display: flex;
  336. align-items: center;
  337. }
  338. .search {
  339. .w-50,
  340. :deep .el-input {
  341. width: 400px;
  342. height: 32px;
  343. border-radius: 4px;
  344. margin-top: 8px;
  345. background: #6f85b5 !important;
  346. --el-input-border-color: #6f85b5;
  347. }
  348. ::v-deep .el-input__inner {
  349. color: #fff !important;
  350. }
  351. }
  352. :deep .el-input__wrapper {
  353. background: #1f3f7e !important;
  354. }
  355. }
  356. .asides {
  357. padding: 8px 10px !important;
  358. font-size: 14px;
  359. color: #000;
  360. background: #fff;
  361. }
  362. .main {
  363. background: #c7cbd8;
  364. }
  365. //侧边栏css
  366. .acitve-img-style {
  367. background-color: #f5f7f9;
  368. border-radius: 4px;
  369. }
  370. .img-style {
  371. width: 72px;
  372. height: 72px;
  373. display: flex;
  374. margin-bottom: 8px;
  375. flex-direction: column;
  376. align-items: center;
  377. justify-content: center;
  378. & > img {
  379. width: 40px;
  380. height: 40px;
  381. }
  382. }
  383. .text-style {
  384. text-align: center;
  385. color: #000;
  386. }
  387. </style>
  388. <style lang="scss">
  389. .el-popper.is-light.type_popper {
  390. background-color: #1f3f7e !important;
  391. border-radius: 4px 4px 4px 4px !important;
  392. border: none !important;
  393. // padding: 0 16px !important;
  394. // box-sizing: border-box !important;
  395. }
  396. .el-popper__arrow::before {
  397. content: none;
  398. }
  399. //鼠标移动上去的选中色
  400. .type_popper {
  401. .el-select-dropdown__item.hover,
  402. .el-select-dropdown__item:hover {
  403. background: #6f85b5 !important;
  404. }
  405. //下拉框的文本颜色
  406. .el-select-dropdown__item {
  407. color: #a4b0d8 !important;
  408. }
  409. //选中之后的颜色
  410. .el-select-dropdown__item.selected {
  411. background: #6f85b5 !important;
  412. color: #fff !important;
  413. }
  414. }
  415. .yuandian {
  416. width: 8px;
  417. height: 8px;
  418. position: absolute;
  419. right: 8px;
  420. top: 6px;
  421. background: #fa5151;
  422. border-radius: 4px;
  423. }
  424. </style>