app.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573
  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="'https://nutui.jd.com/demo.html#/'+routerName">
  59. </div>
  60. </div>
  61. <iframe :src="'//nutui.jd.com/demo.html#/'+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. };
  94. },
  95. watch: {
  96. // '$route':obj =>{
  97. // if(this){
  98. // this.routerName = obj.name
  99. // }
  100. // },
  101. $route: "fetchData"
  102. },
  103. components: {
  104. search,
  105. leftNav
  106. },
  107. methods: {
  108. openwindow(val) {
  109. if (val.target.value == 1) {
  110. window.location.href = "https://nutui.jd.com/1x/";
  111. }
  112. },
  113. choseList(e) {
  114. let searchIndex = this.searchIndex;
  115. if (e.keyCode == 40) {
  116. searchIndex++;
  117. }
  118. if (e.keyCode == 38) {
  119. searchIndex--;
  120. }
  121. if (searchIndex < 0) {
  122. searchIndex = 0;
  123. }
  124. let searchList = this.searchList;
  125. if (searchList.length > 0) {
  126. let chnName = searchList[searchIndex].chnName;
  127. if (chnName) {
  128. this.searchCurName = chnName;
  129. this.searchIndex = searchIndex;
  130. if (e.keyCode == 13) {
  131. this.$router.push({
  132. path: "/" + searchList[searchIndex].name
  133. });
  134. this.searchCurName = "";
  135. this.searchIndex = 0;
  136. this.searchList = [];
  137. this.searchVal = "";
  138. }
  139. }
  140. }
  141. },
  142. fetchData(obj) {
  143. this.routerName = obj.name;
  144. this.showPhone = false;
  145. for (let i = 0, item; (item = packages[i]); i++) {
  146. if (obj.name == item.name) {
  147. this.showPhone = true;
  148. }
  149. }
  150. let that = this;
  151. this.qrcode.toDataURL(
  152. "https://nutui.jd.com/index.html#/" + that.routerName,
  153. { width: 170 },
  154. (err, url) => {
  155. that.codeurl = url;
  156. }
  157. );
  158. },
  159. onfocus(e) {
  160. e.target.select();
  161. },
  162. clearSearch() {
  163. this.searchList = [];
  164. },
  165. search(e) {
  166. let val = e.target.value.toLowerCase();
  167. if (val) {
  168. let packages = this.packages;
  169. let list = [];
  170. for (let i = 0, item; (item = packages[i]); i++) {
  171. let cn = item.chnName.toLowerCase();
  172. let en = item.name.toLowerCase();
  173. if (cn.indexOf(val) > -1 || en.indexOf(val) > -1) {
  174. list.push(item);
  175. }
  176. }
  177. this.searchList = list;
  178. }
  179. },
  180. checklist(obj) {
  181. this.searchVal = "";
  182. this.searchList = [];
  183. this.searchCurName = "";
  184. this.searchIndex = 0;
  185. }
  186. },
  187. created() {
  188. let that = this;
  189. let name = this.$route.name;
  190. for (let i = 0, item; (item = packages[i]); i++) {
  191. if (name == item.name) {
  192. this.showPhone = true;
  193. }
  194. }
  195. }
  196. };
  197. </script>
  198. <style lang="scss">
  199. .fixed-box{
  200. position: fixed;
  201. z-index: 9;
  202. height: 100%;
  203. overflow:hidden;
  204. overflow-y: auto;
  205. top:0;
  206. background: #fff;
  207. box-sizing: border-box;
  208. }
  209. .fade-enter-active,
  210. .fade-leave-active {
  211. transition: opacity 0.5s;
  212. }
  213. .fade-enter, .fade-leave-to /* .fade-leave-active below version 2.1.8 */ {
  214. opacity: 0;
  215. }
  216. * {
  217. -webkit-tap-highlight-color: transparent;
  218. }
  219. .md-swaper {
  220. position: relative;
  221. background: #fff;
  222. min-height: 100vh;
  223. min-width: 1200px;
  224. padding: 85px 0 200px 0;
  225. box-sizing: border-box;
  226. display: flex;
  227. }
  228. .hder {
  229. position: fixed;
  230. top: 0;
  231. width: 100%;
  232. background: #ffffff;
  233. border-bottom: 1px solid #f2f2f2;
  234. height: 64px;
  235. display: flex;
  236. align-items: center;
  237. margin-bottom: 50px;
  238. z-index: 42;
  239. min-width: 1200px;
  240. .logo {
  241. width: 293px;
  242. height: 65px;
  243. display: flex;
  244. align-items: center;
  245. flex-shrink: 0;
  246. border-right: 1px solid #d8d8d8;
  247. .logo-link {
  248. display: inline-block;
  249. }
  250. img {
  251. display: block;
  252. width: 120px;
  253. height: 46px;
  254. flex-grow: 0;
  255. flex-shrink: 0;
  256. margin: 0 10px 0 30px;
  257. }
  258. color: #999;
  259. font-size: 12px;
  260. }
  261. .version {
  262. display: inline-block;
  263. margin-top: 7px;
  264. vertical-align: bottom;
  265. }
  266. .h-nav {
  267. display: flex;
  268. padding-left: 42px;
  269. align-items: center;
  270. width: 100%;
  271. background: #fff;
  272. z-index: 999;
  273. border-bottom:1px solid #f2f2f2;
  274. select {
  275. width: 74px;
  276. height: 28px;
  277. margin-top: 18px;
  278. margin-left: 20px;
  279. font-size: 12px;
  280. }
  281. .search-box {
  282. height: 22px;
  283. min-width: 300px;
  284. position: relative;
  285. float:left;
  286. input {
  287. width: 100%;
  288. }
  289. }
  290. .search {
  291. height: 22px;
  292. font-size: 14px;
  293. color: #666;
  294. border: none;
  295. background: url(./asset/css/i/sreach.png) no-repeat left center;
  296. padding-left: 45px;
  297. &:focus {
  298. outline: none;
  299. }
  300. }
  301. .search-list {
  302. background: #fff;
  303. position: absolute;
  304. width: 300px;
  305. list-style: none;
  306. border: 1px solid #f2f2f2;
  307. z-index: 99;
  308. top: 27px;
  309. padding: 0;
  310. li {
  311. height: 40px;
  312. line-height: 40px;
  313. font-size: 14px;
  314. a {
  315. display: inline-block;
  316. box-sizing: border-box;
  317. width: 100%;
  318. padding-left: 40px;
  319. text-decoration: none;
  320. color: #666;
  321. }
  322. &:hover {
  323. background: #6096ff;
  324. color: #fff;
  325. a {
  326. color: #fff;
  327. }
  328. }
  329. }
  330. .cur {
  331. background: #6096ff;
  332. color: #fff;
  333. a {
  334. color: #fff;
  335. }
  336. }
  337. }
  338. }
  339. .list {
  340. display: flex;
  341. list-style: none;
  342. margin-left: auto;
  343. align-items: center;
  344. li {
  345. padding: 0 10px;
  346. height: 63px;
  347. line-height: 63px;
  348. text-align: center;
  349. }
  350. .cur {
  351. border-bottom: 2px solid #5396ff;
  352. a {
  353. color: #5396ff;
  354. }
  355. }
  356. a {
  357. text-decoration: none;
  358. font-size: 14px;
  359. color: #333333;
  360. cursor: pointer;
  361. }
  362. .github {
  363. a {
  364. display: inline-block;
  365. width: 26px;
  366. height: 26px;
  367. vertical-align: middle;
  368. 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")
  369. no-repeat;
  370. //background: url(./asset/css/i/Shape.png) center no-repeat;
  371. border-radius: 20px;
  372. &:hover,
  373. &:active {
  374. opacity: 0.7;
  375. }
  376. }
  377. }
  378. .joinus{
  379. position: relative;
  380. height: 40px;
  381. border-radius: 3px;
  382. overflow: hidden;
  383. padding:0;
  384. margin-right: 20px;
  385. a{
  386. position: absolute;
  387. z-index: 1;
  388. width: 100%;
  389. height: 100%;
  390. top:0;
  391. left: 0;
  392. }
  393. }
  394. }
  395. }
  396. .demo-wrapper {
  397. display: flex;
  398. width: 100%;
  399. //padding: 0 20px 0 0;
  400. .demo-nav {
  401. width: 294px;
  402. flex-shrink: 0;
  403. }
  404. .showPhone {
  405. padding-right: 25px;
  406. //margin-left: 20px;
  407. width: 360px;
  408. flex-shrink: 0;
  409. position: relative;
  410. .ph {
  411. height: 611px;
  412. width: 360px;
  413. position: fixed;
  414. border-radius: 55px;
  415. top: 100px;
  416. border-radius: 4px;
  417. overflow: hidden;
  418. z-index: 10;
  419. box-shadow: 0px 0px 9px 5px #eee;
  420. iframe {
  421. border: none;
  422. width: 360px;
  423. height: 542px;
  424. padding: 0;
  425. box-sizing: border-box;
  426. }
  427. }
  428. .bg {
  429. width: 360px;
  430. height: 64px;
  431. padding-top: 5px;
  432. background: linear-gradient(rgba(55, 55, 55, 0.98), #545456);
  433. text-align: center;
  434. img {
  435. width: 90%;
  436. }
  437. input {
  438. width: 90%;
  439. height: 28px;
  440. line-height: 28px;
  441. color: #fff;
  442. background-color: #a2a2a2;
  443. margin: 0 auto;
  444. border-radius: 4px;
  445. white-space: nowrap;
  446. overflow-x: scroll;
  447. border: none;
  448. margin-top: 5px;
  449. padding: 0 5px;
  450. &:focus {
  451. outline: none;
  452. }
  453. }
  454. }
  455. }
  456. .fl-right{
  457. margin-left: 320px;
  458. }
  459. }
  460. .foot {
  461. height: 120px;
  462. background: #0a0a0a;
  463. font-size: 16px;
  464. color: #ffffff;
  465. line-height: 120px;
  466. text-align: center;
  467. margin-top: 80px;
  468. position: absolute;
  469. bottom: 0;
  470. width: 100%;
  471. padding-left: 300px;
  472. box-sizing: border-box;
  473. a {
  474. color: #fff;
  475. text-decoration: none;
  476. &:hover {
  477. text-decoration: underline;
  478. }
  479. }
  480. }
  481. [v-cloak] {
  482. display: none;
  483. }
  484. body {
  485. font-size: 16px;
  486. //background:#F8F8F8;
  487. margin: 0;
  488. }
  489. .demo-wrapper {
  490. background-color: #fff;
  491. // min-height:100%;
  492. }
  493. .doc-cont {
  494. padding: 8px 40px 8px 0;
  495. margin-left: 50px;
  496. box-sizing: border-box;
  497. flex: 1;
  498. min-width: 500px;
  499. }
  500. .docpad{
  501. padding: 8px 200px 8px 0;
  502. }
  503. // .button-primary {
  504. // display: block;
  505. // margin: 50px 0;
  506. // height: 38px;
  507. // padding: 0 24px;
  508. // color: #555;
  509. // text-align: center;
  510. // font-size: 12px;
  511. // font-weight: 600;
  512. // line-height: 38px;
  513. // letter-spacing: 10px;
  514. // text-transform: uppercase;
  515. // text-decoration: none;
  516. // white-space: nowrap;
  517. // background-color: transparent;
  518. // border-radius: 4px;
  519. // border: 1px solid #bbb;
  520. // cursor: pointer;
  521. // box-sizing: border-box;
  522. // color: #fff;
  523. // background-color: #33c3f0;
  524. // border-color: #33c3f0;
  525. // }
  526. .demoLink {
  527. background: #fff;
  528. position: relative;
  529. z-index: 99999;
  530. width: auto;
  531. height: auto;
  532. a {
  533. z-index: 9999;
  534. }
  535. &.qrcode {
  536. span {
  537. line-height: 64px;
  538. }
  539. img {
  540. width: 150px;
  541. height: 150px;
  542. }
  543. }
  544. }
  545. @media screen and (max-width: 1500px) {
  546. .demo-wrapper {
  547. .showPhone {
  548. width: 320px;
  549. .ph {
  550. width: 320px;
  551. height: 581px;
  552. & > div,
  553. iframe {
  554. width: 320px;
  555. }
  556. iframe {
  557. height: 512px;
  558. }
  559. }
  560. }
  561. }
  562. }
  563. </style>