app.vue 12 KB

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