index.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412
  1. <template>
  2. <!-- 搜索框 -->
  3. <div
  4. style="
  5. position: absolute;
  6. left: 50%;
  7. transform: translate(-50%,-50%);
  8. top: 50%;
  9. width: 638px;
  10. height:418px;
  11. border-radius:7px;
  12. "
  13. :style="{
  14. display: searchInputContant.display,
  15. zIndex: searchInputContant.zIndex,
  16. }"
  17. :class="searchInputContant.cls"
  18. @click.stop="clickSearchInput">
  19. <div
  20. class="
  21. x-window
  22. syno-finder
  23. spotlight-main-window
  24. sds-window-v5
  25. spotlight-init
  26. "
  27. >
  28. <div class="x-dlg-focus"></div>
  29. <div class="x-window-tl">
  30. <div class="x-window-tr">
  31. <div class="x-window-tc">
  32. <div class="x-window-header x-panel-icon x-window-draggable">
  33. <div class="x-window-toolCt">
  34. <div class="x-tool x-tool-close">&nbsp;</div>
  35. <div class="x-tool x-tool-restore" style="display: none">
  36. &nbsp;
  37. </div>
  38. <div class="x-tool x-tool-maximize">&nbsp;</div>
  39. <div class="x-tool x-tool-minimize">&nbsp;</div>
  40. <div class="x-tool x-tool-help">&nbsp;</div>
  41. </div>
  42. <span class="x-window-header-text">Spotlight</span>
  43. </div>
  44. </div>
  45. </div>
  46. </div>
  47. <div class="x-window-bwrap" :class="searchCls">
  48. <div class="x-window-ml">
  49. <div class="x-window-mr">
  50. <div class="x-window-mc">
  51. <div class="x-window-body" style="width: 638px; height: 48px">
  52. <div
  53. class="x-panel syno-ux-panel x-panel-noborder"
  54. style="width: 638px"
  55. >
  56. <div class="x-panel-bwrap">
  57. <div
  58. class="
  59. x-panel-body
  60. x-panel-body-noheader
  61. x-panel-body-noborder
  62. x-box-layout-ct
  63. "
  64. style="width: 638px; height: 48px"
  65. >
  66. <div
  67. class="x-box-inner"
  68. style="width: 638px; height: 48px"
  69. >
  70. <div
  71. class="
  72. x-panel
  73. search-bar
  74. syno-ux-panel
  75. x-panel-noborder x-box-item
  76. search-now-placeholder
  77. "
  78. style="
  79. position: absolute;
  80. z-index: 11000;
  81. visibility: visible;
  82. left: 0px;
  83. top: 0px;
  84. width: 638px;
  85. "
  86. >
  87. <div class="x-panel-bwrap">
  88. <div
  89. class="
  90. x-panel-body
  91. x-panel-body-noheader
  92. x-panel-body-noborder
  93. x-box-layout-ct
  94. "
  95. style="height: 46px; width: 638px"
  96. >
  97. <div
  98. class="x-box-inner"
  99. style="width: 638px; height: 46px"
  100. >
  101. <div
  102. class="magnifier x-box-item"
  103. :class="searchIconCls"
  104. @click.capture="showOrHiddenSelect"
  105. style="
  106. width: 70px;
  107. height: 22px;
  108. left: 0px;
  109. top: 0px;
  110. "
  111. ></div>
  112. <input
  113. type="text"
  114. size="20"
  115. autocomplete="off"
  116. class="
  117. x-form-text x-form-field
  118. text-field
  119. syno-ux-textfield
  120. x-box-item
  121. "
  122. style="
  123. margin-left: 0px;
  124. height: 46px;
  125. width: 512px;
  126. left: 70px;
  127. top: 0px;
  128. "
  129. v-model="keyword"
  130. @input="searchKeyword"
  131. @focus="searchInputFocus"
  132. />
  133. <div
  134. class="loading-icon x-box-item"
  135. style="
  136. width: 24px;
  137. height: 46px;
  138. left: 598px;
  139. top: 0px;
  140. "
  141. ></div>
  142. <div class="x-form-hidden-error-msg"></div>
  143. <div
  144. class="dummy-searchfield"
  145. style="
  146. width: 512px;
  147. height: 46px;
  148. left: 70px;
  149. top: 0px;
  150. "
  151. :style="{ display: searchFieldDisplay }"
  152. >
  153. <div
  154. class="suggestion"
  155. style="width: 512px; height: 46px"
  156. >
  157. <span class="dummy"></span>立即搜索{{
  158. searchText
  159. }}
  160. </div>
  161. </div>
  162. </div>
  163. </div>
  164. </div>
  165. </div>
  166. </div>
  167. </div>
  168. </div>
  169. </div>
  170. </div>
  171. </div>
  172. </div>
  173. </div>
  174. <div class="x-window-bl x-panel-nofooter">
  175. <div class="x-window-br"><div class="x-window-bc"></div></div>
  176. </div>
  177. </div>
  178. <div
  179. class="x-panel x-panel-noborder x-box-item"
  180. style="width: 638px; left: 0px; top: 48px"
  181. >
  182. <div class="x-panel-bwrap" :style="{ display: panelBwrapDisplay }">
  183. <div
  184. class="x-panel-body x-panel-body-noheader x-panel-body-noborder"
  185. style="width: 638px; height: 370px"
  186. >
  187. <div
  188. class="x-panel main-panel syno-ux-panel x-panel-noborder"
  189. style="width: 638px; height: 370px"
  190. ></div>
  191. </div>
  192. </div>
  193. </div>
  194. <div
  195. class="
  196. x-panel
  197. syno-finder-spotlight-menu
  198. x-panel-noborder
  199. syno-ux-panel
  200. "
  201. style="
  202. position: absolute;
  203. z-index: 11000;
  204. left: 10px;
  205. top: 45px;
  206. width: 184px;
  207. "
  208. :style="{ display: selectDisplay }"
  209. >
  210. <div class="x-panel-bwrap">
  211. <div
  212. class="x-panel-body x-panel-body-noheader x-panel-body-noborder"
  213. style="width: 184px"
  214. >
  215. <div style="width: 184px; height: 200px">
  216. <div
  217. class="cat-wrapper"
  218. :class="select.cls"
  219. v-for="(select, selectIndex) in searchInputDetail.selectList"
  220. :key="select.id"
  221. @click="changeSearchMethod(selectIndex, select.cls1)"
  222. >
  223. <span class="icon" :class="select.cls1"></span>{{ select.text }}
  224. </div>
  225. </div>
  226. </div>
  227. </div>
  228. </div>
  229. </div>
  230. </div>
  231. </template>
  232. <script>
  233. export default {
  234. props: ["searchInputData", "defaultZIndex"],
  235. mounted() {
  236. this.$bus.on("openSearchInput", this.openSearchInput);
  237. this.searchInputContant = this.searchInputData;
  238. },
  239. data() {
  240. return {
  241. searchInputContant: {
  242. display: "none",
  243. zIndex: 9050,
  244. cls: "deactive-win",
  245. },
  246. searchText: "",
  247. keyword: "",
  248. searchCls: "",
  249. searchIconCls: "everything",
  250. selectDisplay: "none",
  251. searchFieldDisplay: "block",
  252. panelBwrapDisplay: "none",
  253. searchInputDetail: {
  254. selectList: [
  255. {
  256. id: 0,
  257. cls: "",
  258. cls1: "document",
  259. text: "文档",
  260. },
  261. {
  262. id: 1,
  263. cls: "",
  264. cls1: "photo",
  265. text: "照片",
  266. },
  267. {
  268. id: 2,
  269. cls: "",
  270. cls1: "audio",
  271. text: "音乐",
  272. },
  273. {
  274. id: 3,
  275. cls: "",
  276. cls1: "video",
  277. text: "视频",
  278. },
  279. {
  280. id: 4,
  281. cls: "current",
  282. cls1: "everything",
  283. text: "全部",
  284. },
  285. ],
  286. },
  287. };
  288. },
  289. methods: {
  290. // 显示或隐藏本页面
  291. openSearchInput(e) {
  292. if (
  293. this.searchInputContant.display === "none" ||
  294. this.searchInputContant.cls === "deactive-win"
  295. ) {
  296. this.searchInputContant.display = "block";
  297. this.searchInputContant.cls = "active-win";
  298. this.searchInputContant.zIndex = this.defaultZIndex + 10;
  299. this.$bus.emit("changeDefaultZIndex", this.defaultZIndex + 10);
  300. if (!e.srcElement.className.includes(" pressed")) {
  301. e.srcElement.className = e.srcElement.className + " pressed";
  302. }
  303. window.addEventListener("click", this.hiddenSearchInput);
  304. } else {
  305. this.searchInputContant.display = "none";
  306. this.searchInputContant.zIndex = this.defaultZIndex - 10;
  307. this.$bus.emit("changeDefaultZIndex", this.defaultZIndex - 10);
  308. this.searchInputContant.cls = "deactive-win";
  309. if (
  310. e.srcElement.className &&
  311. e.srcElement.className.includes(" pressed")
  312. ) {
  313. e.srcElement.className = e.srcElement.className.replace(
  314. " pressed",
  315. ""
  316. );
  317. }
  318. window.removeEventListener("click", this.hiddenSearchInput);
  319. }
  320. },
  321. // 隐藏本页面
  322. hiddenSearchInput(e) {
  323. let el = document.querySelector(".tray-item.search-button");
  324. let el1 = document.querySelector(".syno-finder.spotlight-main-window");
  325. if (e.srcElement === el) {
  326. window.addEventListener("click", this.hiddenSearchInput);
  327. } else {
  328. this.searchInputContant.display = "none";
  329. window.removeEventListener("click", this.hiddenSearchInput);
  330. this.panelBwrapDisplay = "none";
  331. if (el.className && el.className.includes(" pressed")) {
  332. el.className = el.className.replace(" pressed", "");
  333. }
  334. this.searchFieldDisplay = "block";
  335. this.selectDisplay = "none";
  336. this.searchCls = "";
  337. if (el1.className.includes(" merge")) {
  338. el1.className = el1.className.replace(" merge",'');
  339. }
  340. this.keyword = "";
  341. if (this.searchInputContant.zIndex >= this.defaultZIndex) {
  342. this.searchInputContant.cls = "deactive-win";
  343. this.searchInputContant.zIndex = this.defaultZIndex - 10;
  344. this.$bus.emit("changeDefaultZIndex", this.defaultZIndex - 10);
  345. }
  346. }
  347. },
  348. // 点击本页面
  349. clickSearchInput(e) {
  350. if (this.searchInputContant.display === "deactive-win") {
  351. this.searchInputContant.cls = "active-win";
  352. this.searchInputContant.zIndex = this.defaultZIndex + 10;
  353. this.$bus.emit("changeDefaultZIndex", this.defaultZIndex + 10);
  354. }
  355. },
  356. // 显示或隐藏选择框
  357. showOrHiddenSelect() {
  358. if (this.selectDisplay === "none") {
  359. this.selectDisplay = "block";
  360. } else {
  361. this.selectDisplay = "none";
  362. }
  363. },
  364. // 切换搜索方式
  365. changeSearchMethod(selectIndex, cls) {
  366. this.searchIconCls = cls;
  367. this.searchInputDetail.selectList.forEach((item) => {
  368. if (item.cls.includes("current")) {
  369. item.cls = item.cls.replace("current", "");
  370. }
  371. });
  372. if (
  373. !this.searchInputDetail.selectList[selectIndex].cls.includes("current")
  374. ) {
  375. this.searchInputDetail.selectList[selectIndex].cls =
  376. this.searchInputDetail.selectList[selectIndex].cls + "current";
  377. }
  378. this.selectDisplay = "none";
  379. if (selectIndex < 4) {
  380. this.searchText = this.searchInputDetail.selectList[selectIndex].text;
  381. } else {
  382. this.searchText = "";
  383. }
  384. },
  385. // 输入搜索
  386. searchKeyword() {
  387. let el = document.querySelector(".syno-finder.spotlight-main-window");
  388. if (!this.keyword.trim()) {
  389. this.panelBwrapDisplay = "none";
  390. this.searchFieldDisplay = "block";
  391. this.searchCls = "";
  392. if (el.className.includes(" merge")) {
  393. el.className = el.className.replace(" merge");
  394. }
  395. } else {
  396. this.panelBwrapDisplay = "block";
  397. this.searchFieldDisplay = "none";
  398. this.searchCls = "merge";
  399. if (!el.className.includes(" merge")) {
  400. el.className = el.className + " merge";
  401. }
  402. }
  403. },
  404. // 输入框聚焦
  405. searchInputFocus() {
  406. this.selectDisplay = "none";
  407. },
  408. },
  409. components: {},
  410. name: "SearchInput",
  411. };
  412. </script>