app.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574
  1. <template>
  2. <div>
  3. <div v-if="routerName == 'frontcover' || routerName == ''">
  4. <router-view></router-view>
  5. </div>
  6. <div class="md-swaper" @click="clearSearch" v-else>
  7. <div class="hder">
  8. <div class="logo">
  9. <a href="#/index" class="logo-link">
  10. <img src="./asset/css/i/nut.png" alt>
  11. </a>
  12. <span class="version">v{{version}}</span>
  13. </div>
  14. <div class="h-nav">
  15. <search/>
  16. <ul class="list">
  17. <li class="joinus">
  18. <a href="#/joinus"></a>
  19. <img src="./asset/css/i/jion_us.gif" alt="">
  20. </li>
  21. <li class="cur">
  22. <a href="#/intro">指南</a>
  23. </li>
  24. <li>
  25. <a class="qrcode demoLink" href="/demo.html#/index" target="_blank">
  26. 示例
  27. <a :href="routerName">
  28. <span>请使用手机扫码体验</span>
  29. <img
  30. src="https://img14.360buyimg.com/uba/jfs/t1/32118/11/559/2782/5c3d81ecEbda0c0f1/5f2b637d11817204.png"
  31. alt
  32. >
  33. </a>
  34. </a>
  35. </li>
  36. <li>
  37. <select @change="openwindow">
  38. <option value="2">2.X</option>
  39. <option value="1">1.X</option>
  40. </select>
  41. </li>
  42. <li class="github">
  43. <a target="_back" href="https://github.com/jdf2e/nutui"></a>
  44. </li>
  45. </ul>
  46. </div>
  47. </div>
  48. <div class="demo-wrapper">
  49. <router-view class="demo-nav fixed-box"></router-view>
  50. <keep-alive include="index">
  51. <router-view class="doc-cont fl-right" :class="showPhone?'':'docpad'" name="main"></router-view>
  52. </keep-alive>
  53. <div v-if="showPhone" class="showPhone">
  54. <div class="ph">
  55. <div class="bg">
  56. <img src="./asset/css/i/phtitle.png" alt>
  57. <div>
  58. <input type="text" readonly :value="demourl+routerName">
  59. </div>
  60. </div>
  61. <iframe :src="demourl+routerName+'?ver='+version"></iframe>
  62. </div>
  63. </div>
  64. </div>
  65. <div class="foot">
  66. Copyright © 2018~2019
  67. <a href="//jdc.jd.com" target="_blank">JDC</a>-
  68. <a target="_blank" href="javascript:;">前端开发部</a>
  69. </div>
  70. </div>
  71. </div>
  72. </template>
  73. <script>
  74. import "./asset/css/common.scss";
  75. import "./asset/css/style-blue.scss";
  76. import { packages } from "../../src/config.json";
  77. import search from "./search.vue";
  78. import leftNav from './info.vue';
  79. import { version } from "../../package.json";
  80. export default {
  81. name: "App",
  82. data() {
  83. return {
  84. packages,
  85. version,
  86. searchList: [],
  87. searchVal: "",
  88. routerName: "",
  89. showPhone: false,
  90. searchCurName: "",
  91. searchIndex: 0,
  92. codeurl: "",
  93. demourl: location.origin + '/demo.html#/'
  94. };
  95. },
  96. watch: {
  97. // '$route':obj =>{
  98. // if(this){
  99. // this.routerName = obj.name
  100. // }
  101. // },
  102. $route: "fetchData"
  103. },
  104. components: {
  105. search,
  106. leftNav
  107. },
  108. methods: {
  109. openwindow(val) {
  110. if (val.target.value == 1) {
  111. window.location.href = "https://nutui.jd.com/1x/";
  112. }
  113. },
  114. choseList(e) {
  115. let searchIndex = this.searchIndex;
  116. if (e.keyCode == 40) {
  117. searchIndex++;
  118. }
  119. if (e.keyCode == 38) {
  120. searchIndex--;
  121. }
  122. if (searchIndex < 0) {
  123. searchIndex = 0;
  124. }
  125. let searchList = this.searchList;
  126. if (searchList.length > 0) {
  127. let chnName = searchList[searchIndex].chnName;
  128. if (chnName) {
  129. this.searchCurName = chnName;
  130. this.searchIndex = searchIndex;
  131. if (e.keyCode == 13) {
  132. this.$router.push({
  133. path: "/" + searchList[searchIndex].name
  134. });
  135. this.searchCurName = "";
  136. this.searchIndex = 0;
  137. this.searchList = [];
  138. this.searchVal = "";
  139. }
  140. }
  141. }
  142. },
  143. fetchData(obj) {
  144. this.routerName = obj.name;
  145. this.showPhone = false;
  146. for (let i = 0, item; (item = packages[i]); i++) {
  147. if (obj.name == item.name) {
  148. this.showPhone = true;
  149. }
  150. }
  151. let that = this;
  152. this.qrcode.toDataURL(
  153. "https://nutui.jd.com/index.html#/" + that.routerName,
  154. { width: 170 },
  155. (err, url) => {
  156. that.codeurl = url;
  157. }
  158. );
  159. },
  160. onfocus(e) {
  161. e.target.select();
  162. },
  163. clearSearch() {
  164. this.searchList = [];
  165. },
  166. search(e) {
  167. let val = e.target.value.toLowerCase();
  168. if (val) {
  169. let packages = this.packages;
  170. let list = [];
  171. for (let i = 0, item; (item = packages[i]); i++) {
  172. let cn = item.chnName.toLowerCase();
  173. let en = item.name.toLowerCase();
  174. if (cn.indexOf(val) > -1 || en.indexOf(val) > -1) {
  175. list.push(item);
  176. }
  177. }
  178. this.searchList = list;
  179. }
  180. },
  181. checklist(obj) {
  182. this.searchVal = "";
  183. this.searchList = [];
  184. this.searchCurName = "";
  185. this.searchIndex = 0;
  186. }
  187. },
  188. created() {
  189. let that = this;
  190. let name = this.$route.name;
  191. for (let i = 0, item; (item = packages[i]); i++) {
  192. if (name == item.name) {
  193. this.showPhone = true;
  194. }
  195. }
  196. }
  197. };
  198. </script>
  199. <style lang="scss">
  200. .fixed-box{
  201. position: fixed;
  202. z-index: 9;
  203. height: 100%;
  204. overflow:hidden;
  205. overflow-y: auto;
  206. top:0;
  207. background: #fff;
  208. box-sizing: border-box;
  209. }
  210. .fade-enter-active,
  211. .fade-leave-active {
  212. transition: opacity 0.5s;
  213. }
  214. .fade-enter, .fade-leave-to /* .fade-leave-active below version 2.1.8 */ {
  215. opacity: 0;
  216. }
  217. * {
  218. -webkit-tap-highlight-color: transparent;
  219. }
  220. .md-swaper {
  221. position: relative;
  222. background: #fff;
  223. min-height: 100vh;
  224. min-width: 1200px;
  225. padding: 85px 0 200px 0;
  226. box-sizing: border-box;
  227. display: flex;
  228. }
  229. .hder {
  230. position: fixed;
  231. top: 0;
  232. width: 100%;
  233. background: #ffffff;
  234. border-bottom: 1px solid #f2f2f2;
  235. height: 64px;
  236. display: flex;
  237. align-items: center;
  238. margin-bottom: 50px;
  239. z-index: 42;
  240. min-width: 1200px;
  241. .logo {
  242. width: 293px;
  243. height: 65px;
  244. display: flex;
  245. align-items: center;
  246. flex-shrink: 0;
  247. border-right: 1px solid #d8d8d8;
  248. .logo-link {
  249. display: inline-block;
  250. }
  251. img {
  252. display: block;
  253. width: 120px;
  254. height: 46px;
  255. flex-grow: 0;
  256. flex-shrink: 0;
  257. margin: 0 10px 0 30px;
  258. }
  259. color: #999;
  260. font-size: 12px;
  261. }
  262. .version {
  263. display: inline-block;
  264. margin-top: 7px;
  265. vertical-align: bottom;
  266. }
  267. .h-nav {
  268. display: flex;
  269. padding-left: 42px;
  270. align-items: center;
  271. width: 100%;
  272. background: #fff;
  273. z-index: 999;
  274. border-bottom:1px solid #f2f2f2;
  275. select {
  276. width: 74px;
  277. height: 28px;
  278. margin-top: 18px;
  279. margin-left: 20px;
  280. font-size: 12px;
  281. }
  282. .search-box {
  283. height: 22px;
  284. min-width: 300px;
  285. position: relative;
  286. float:left;
  287. input {
  288. width: 100%;
  289. }
  290. }
  291. .search {
  292. height: 22px;
  293. font-size: 14px;
  294. color: #666;
  295. border: none;
  296. background: url(./asset/css/i/sreach.png) no-repeat left center;
  297. padding-left: 45px;
  298. &:focus {
  299. outline: none;
  300. }
  301. }
  302. .search-list {
  303. background: #fff;
  304. position: absolute;
  305. width: 300px;
  306. list-style: none;
  307. border: 1px solid #f2f2f2;
  308. z-index: 99;
  309. top: 27px;
  310. padding: 0;
  311. li {
  312. height: 40px;
  313. line-height: 40px;
  314. font-size: 14px;
  315. a {
  316. display: inline-block;
  317. box-sizing: border-box;
  318. width: 100%;
  319. padding-left: 40px;
  320. text-decoration: none;
  321. color: #666;
  322. }
  323. &:hover {
  324. background: #6096ff;
  325. color: #fff;
  326. a {
  327. color: #fff;
  328. }
  329. }
  330. }
  331. .cur {
  332. background: #6096ff;
  333. color: #fff;
  334. a {
  335. color: #fff;
  336. }
  337. }
  338. }
  339. }
  340. .list {
  341. display: flex;
  342. list-style: none;
  343. margin-left: auto;
  344. align-items: center;
  345. li {
  346. padding: 0 10px;
  347. height: 63px;
  348. line-height: 63px;
  349. text-align: center;
  350. }
  351. .cur {
  352. border-bottom: 2px solid #5396ff;
  353. a {
  354. color: #5396ff;
  355. }
  356. }
  357. a {
  358. text-decoration: none;
  359. font-size: 14px;
  360. color: #333333;
  361. cursor: pointer;
  362. }
  363. .github {
  364. a {
  365. display: inline-block;
  366. width: 26px;
  367. height: 26px;
  368. vertical-align: middle;
  369. background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' height='24' viewBox='0 0 16 16' version='1.1' width='24' aria-hidden='true'%3E%3Cpath fill-rule='evenodd' fill='rgb(102,102,102)' d='M8 0C3.58 0 0 3.58 0 8c0 3.54 2.29 6.53 5.47 7.59.4.07.55-.17.55-.38 0-.19-.01-.82-.01-1.49-2.01.37-2.53-.49-2.69-.94-.09-.23-.48-.94-.82-1.13-.28-.15-.68-.52-.01-.53.63-.01 1.08.58 1.23.82.72 1.21 1.87.87 2.33.66.07-.52.28-.87.51-1.07-1.78-.2-3.64-.89-3.64-3.95 0-.87.31-1.59.82-2.15-.08-.2-.36-1.02.08-2.12 0 0 .67-.21 2.2.82.64-.18 1.32-.27 2-.27.68 0 1.36.09 2 .27 1.53-1.04 2.2-.82 2.2-.82.44 1.1.16 1.92.08 2.12.51.56.82 1.27.82 2.15 0 3.07-1.87 3.75-3.65 3.95.29.25.54.73.54 1.48 0 1.07-.01 1.93-.01 2.2 0 .21.15.46.55.38A8.013 8.013 0 0 0 16 8c0-4.42-3.58-8-8-8z'%3E%3C/path%3E%3C/svg%3E")
  370. no-repeat;
  371. //background: url(./asset/css/i/Shape.png) center no-repeat;
  372. border-radius: 20px;
  373. &:hover,
  374. &:active {
  375. opacity: 0.7;
  376. }
  377. }
  378. }
  379. .joinus{
  380. position: relative;
  381. height: 40px;
  382. border-radius: 3px;
  383. overflow: hidden;
  384. padding:0;
  385. margin-right: 20px;
  386. a{
  387. position: absolute;
  388. z-index: 1;
  389. width: 100%;
  390. height: 100%;
  391. top:0;
  392. left: 0;
  393. }
  394. }
  395. }
  396. }
  397. .demo-wrapper {
  398. display: flex;
  399. width: 100%;
  400. //padding: 0 20px 0 0;
  401. .demo-nav {
  402. width: 294px;
  403. flex-shrink: 0;
  404. }
  405. .showPhone {
  406. padding-right: 25px;
  407. //margin-left: 20px;
  408. width: 360px;
  409. flex-shrink: 0;
  410. position: relative;
  411. .ph {
  412. height: 611px;
  413. width: 360px;
  414. position: fixed;
  415. border-radius: 55px;
  416. top: 100px;
  417. border-radius: 4px;
  418. overflow: hidden;
  419. z-index: 10;
  420. box-shadow: 0px 0px 9px 5px #eee;
  421. iframe {
  422. border: none;
  423. width: 360px;
  424. height: 542px;
  425. padding: 0;
  426. box-sizing: border-box;
  427. }
  428. }
  429. .bg {
  430. width: 360px;
  431. height: 64px;
  432. padding-top: 5px;
  433. background: linear-gradient(rgba(55, 55, 55, 0.98), #545456);
  434. text-align: center;
  435. img {
  436. width: 90%;
  437. }
  438. input {
  439. width: 90%;
  440. height: 28px;
  441. line-height: 28px;
  442. color: #fff;
  443. background-color: #a2a2a2;
  444. margin: 0 auto;
  445. border-radius: 4px;
  446. white-space: nowrap;
  447. overflow-x: scroll;
  448. border: none;
  449. margin-top: 5px;
  450. padding: 0 5px;
  451. &:focus {
  452. outline: none;
  453. }
  454. }
  455. }
  456. }
  457. .fl-right{
  458. margin-left: 320px;
  459. }
  460. }
  461. .foot {
  462. height: 120px;
  463. background: #0a0a0a;
  464. font-size: 16px;
  465. color: #ffffff;
  466. line-height: 120px;
  467. text-align: center;
  468. margin-top: 80px;
  469. position: absolute;
  470. bottom: 0;
  471. width: 100%;
  472. padding-left: 300px;
  473. box-sizing: border-box;
  474. a {
  475. color: #fff;
  476. text-decoration: none;
  477. &:hover {
  478. text-decoration: underline;
  479. }
  480. }
  481. }
  482. [v-cloak] {
  483. display: none;
  484. }
  485. body {
  486. font-size: 16px;
  487. //background:#F8F8F8;
  488. margin: 0;
  489. }
  490. .demo-wrapper {
  491. background-color: #fff;
  492. // min-height:100%;
  493. }
  494. .doc-cont {
  495. padding: 8px 40px 8px 0;
  496. margin-left: 50px;
  497. box-sizing: border-box;
  498. flex: 1;
  499. min-width: 500px;
  500. }
  501. .docpad{
  502. padding: 8px 200px 8px 0;
  503. }
  504. // .button-primary {
  505. // display: block;
  506. // margin: 50px 0;
  507. // height: 38px;
  508. // padding: 0 24px;
  509. // color: #555;
  510. // text-align: center;
  511. // font-size: 12px;
  512. // font-weight: 600;
  513. // line-height: 38px;
  514. // letter-spacing: 10px;
  515. // text-transform: uppercase;
  516. // text-decoration: none;
  517. // white-space: nowrap;
  518. // background-color: transparent;
  519. // border-radius: 4px;
  520. // border: 1px solid #bbb;
  521. // cursor: pointer;
  522. // box-sizing: border-box;
  523. // color: #fff;
  524. // background-color: #33c3f0;
  525. // border-color: #33c3f0;
  526. // }
  527. .demoLink {
  528. background: #fff;
  529. position: relative;
  530. z-index: 99999;
  531. width: auto;
  532. height: auto;
  533. a {
  534. z-index: 9999;
  535. }
  536. &.qrcode {
  537. span {
  538. line-height: 64px;
  539. }
  540. img {
  541. width: 150px;
  542. height: 150px;
  543. }
  544. }
  545. }
  546. @media screen and (max-width: 1500px) {
  547. .demo-wrapper {
  548. .showPhone {
  549. width: 320px;
  550. .ph {
  551. width: 320px;
  552. height: 581px;
  553. & > div,
  554. iframe {
  555. width: 320px;
  556. }
  557. iframe {
  558. height: 512px;
  559. }
  560. }
  561. }
  562. }
  563. }
  564. </style>