app.vue 13 KB

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