Browse Source

update sites

lifeifan 7 years ago
parent
commit
74fd322f21
10 changed files with 161 additions and 174 deletions
  1. 1 2
      sites/demo/app.js
  2. 2 2
      sites/demo/router.js
  3. 4 6
      sites/demo/view/index.vue
  4. 3 3
      sites/doc/app.js
  5. 4 4
      sites/doc/app.vue
  6. 0 1
      sites/doc/index.vue
  7. 4 6
      sites/doc/info.vue
  8. 2 2
      sites/doc/router.js
  9. 138 146
      sites/doc/search.vue
  10. 3 2
      src/nutui.js

+ 1 - 2
sites/demo/app.js

@@ -4,7 +4,6 @@ import "core-js/modules/es6.array.iterator";
 import Vue from 'vue';
 import Vue from 'vue';
 import App from './App.vue';
 import App from './App.vue';
 import router from './router';
 import router from './router';
-import Conf from '../../src/config.json';
 import NutUI from '../../src/nutui';
 import NutUI from '../../src/nutui';
 // import en from '../../src/locales/lang/en-US';
 // import en from '../../src/locales/lang/en-US';
 // import demoEN from './lang/en-US';
 // import demoEN from './lang/en-US';
@@ -50,7 +49,7 @@ const app = new Vue({
   template: '<App/>'
   template: '<App/>'
 })
 })
 
 
-Vue.prototype.NUTCONF = Conf;
+//Vue.prototype.NUTCONF = Conf;
 
 
 
 
 let pageLoading = app.$toast.loading();
 let pageLoading = app.$toast.loading();

+ 2 - 2
sites/demo/router.js

@@ -1,6 +1,6 @@
 import Vue from 'vue';
 import Vue from 'vue';
 import VueRouter from 'vue-router';
 import VueRouter from 'vue-router';
-import Conf from '../../src/config.json';
+import { packages } from '../../src/config.json';
 import vueg from 'vueg';
 import vueg from 'vueg';
 import 'vueg/css/transition-min.css';
 import 'vueg/css/transition-min.css';
 
 
@@ -30,7 +30,7 @@ const routes = [
 ];
 ];
 
 
 //组件示例页面
 //组件示例页面
-Conf.packages.map(item => {
+packages.map(item => {
   if (item.showDemo === false) return;
   if (item.showDemo === false) return;
   const pkgName =  item.name.toLowerCase();
   const pkgName =  item.name.toLowerCase();
   routes.push({
   routes.push({

+ 4 - 6
sites/demo/view/index.vue

@@ -27,7 +27,7 @@
 </template>
 </template>
 
 
 <script>
 <script>
-import Conf from "../../../src/config.json";
+import { packages,sorts } from "../../../src/config.json";
 export default {
 export default {
   name: "index",
   name: "index",
   data() {
   data() {
@@ -37,8 +37,7 @@ export default {
       sortedPackages: [],
       sortedPackages: [],
       oriSorts:[],
       oriSorts:[],
       sorts: [1,2,0,3,4,5],
       sorts: [1,2,0,3,4,5],
-      foldStatus: [],
-      version: ""
+      foldStatus: []
     };
     };
   },
   },
   methods: {
   methods: {
@@ -48,9 +47,8 @@ export default {
     }
     }
   },
   },
   created() {
   created() {
-    this.packages = Conf.packages;
-    this.version = Conf.version;
-    this.oriSorts = Conf.sorts;
+    this.packages = packages;
+    this.oriSorts = sorts;
     
     
     this.foldStatus = Array(this.sorts.length)
     this.foldStatus = Array(this.sorts.length)
       .join(",")
       .join(",")

+ 3 - 3
sites/doc/app.js

@@ -21,7 +21,6 @@ import 'highlight.js/styles/github.css';
 //import prettify from 'google-code-prettify/src/prettify';
 //import prettify from 'google-code-prettify/src/prettify';
 //import  'google-code-prettify/src/prettify.css';
 //import  'google-code-prettify/src/prettify.css';
 //import  'google-code-prettify/styles/sunburst.css';
 //import  'google-code-prettify/styles/sunburst.css';
-import Conf from '../../src/config.json';
  //import qrcode from './qrcode/index.js';
  //import qrcode from './qrcode/index.js';
 import codes from 'qrcode';
 import codes from 'qrcode';
  //import NutUI from '../../src/nutui.js';
  //import NutUI from '../../src/nutui.js';
@@ -37,6 +36,7 @@ new Vue({
   router,
   router,
   components: { App },
   components: { App },
   template: '<App/>'
   template: '<App/>'
-})
-Vue.prototype.NUTCONF = Conf;
+});
+
+//Vue.prototype.NUTCONF = Conf;
 
 

+ 4 - 4
sites/doc/app.vue

@@ -66,7 +66,7 @@
 <script>
 <script>
 import "./asset/css/common.scss";
 import "./asset/css/common.scss";
 import "./asset/css/style-blue.scss";
 import "./asset/css/style-blue.scss";
-import Conf from "../../src/config.json";
+import { packages } from "../../src/config.json";
 import PackageJson from "../../package.json";
 import PackageJson from "../../package.json";
 import search from './search.vue';
 import search from './search.vue';
 export default {
 export default {
@@ -134,7 +134,7 @@ export default {
     fetchData(obj) {  
     fetchData(obj) {  
       this.routerName = obj.name;
       this.routerName = obj.name;
       this.showPhone = false;
       this.showPhone = false;
-      for (let i = 0, item; (item = Conf.packages[i]); i++) {
+      for (let i = 0, item; (item = packages[i]); i++) {
         if (obj.name == item.name) {
         if (obj.name == item.name) {
           this.showPhone = true;
           this.showPhone = true;
         }
         }
@@ -174,10 +174,10 @@ export default {
   },
   },
   created() {
   created() {
     let that = this;
     let that = this;
-    this.packages = Conf.packages;   
+    this.packages = packages;   
     let name = this.$route.name;
     let name = this.$route.name;
     this.version = PackageJson.version; 
     this.version = PackageJson.version; 
-    for (let i = 0, item; (item = Conf.packages[i]); i++) {
+    for (let i = 0, item; (item = packages[i]); i++) {
       if (name == item.name) {
       if (name == item.name) {
         this.showPhone = true;
         this.showPhone = true;
       }
       }

+ 0 - 1
sites/doc/index.vue

@@ -539,7 +539,6 @@ export default {
     top: 0;
     top: 0;
     min-width: 990px;
     min-width: 990px;
     width: 100%;
     width: 100%;
-    z-index: 999;
     height: 64px;
     height: 64px;
     display: flex;
     display: flex;
 		 align-items:center;
 		 align-items:center;

+ 4 - 6
sites/doc/info.vue

@@ -50,7 +50,7 @@
 </div>
 </div>
 </template>
 </template>
 <script>
 <script>
-import Conf from "../../src/config.json";
+import { sorts,packages } from "../../src/config.json";
 export default {
 export default {
   name: "index",
   name: "index",
   data() {
   data() {
@@ -58,7 +58,6 @@ export default {
       path: "",
       path: "",
       packages: {},
       packages: {},
       sortedPackages: [],
       sortedPackages: [],
-      version: "",
       cur: [],
       cur: [],
       curName: ""
       curName: ""
     };
     };
@@ -134,13 +133,12 @@ export default {
   },
   },
   created() {
   created() {
     let nameRt = this.$route.name;
     let nameRt = this.$route.name;
-    let packgs = Conf.packages;
+    let packgs = packages;
     
     
-    this.cur = Conf.sorts
+    this.cur = sorts
     this.curName = nameRt;
     this.curName = nameRt;
     this.packages = packgs;
     this.packages = packgs;
-    this.version = Conf.version;
-    this.sorts = Conf.sorts;
+    this.sorts = sorts;
   }
   }
 };
 };
 </script>
 </script>

+ 2 - 2
sites/doc/router.js

@@ -1,6 +1,6 @@
 import Vue from 'vue';
 import Vue from 'vue';
 import VueRouter from 'vue-router';
 import VueRouter from 'vue-router';
-import Conf from '../../src/config.json';
+import { packages } from '../../src/config.json';
 import vueg from 'vueg';
 import vueg from 'vueg';
 import 'vueg/css/transition-min.css';
 import 'vueg/css/transition-min.css';
 
 
@@ -65,7 +65,7 @@ const routes = [
   }
   }
 ];
 ];
 //组件md文件展示
 //组件md文件展示
-Conf.packages.map(item => {
+packages.map(item => {
   if (item.showDemo === false) return;
   if (item.showDemo === false) return;
   const pkgName =  item.name.toLowerCase();
   const pkgName =  item.name.toLowerCase();
   routes.push({
   routes.push({

+ 138 - 146
sites/doc/search.vue

@@ -1,170 +1,162 @@
 <template>
 <template>
-      <div class="search-box">
-          <input
-            @focus="onfocus"
-            @input="search"
-            @keyup="choseList"
-            v-model="searchVal"
-            class="search"
-            type="text"
-            placeholder="在NutUI中搜索"
-          >
-          <!-- <transition name="fade"> -->
-            <ul class="search-list" v-if="searchList.length>0">
-              <li :class="searchCurName==item.name?'cur':''" @click="checklist(item)" v-for="(item,index) in searchList" :key="index">
-                <router-link :to="{name:item.name}">
-                  {{item.name}}
-                  <span>{{item.chnName}}</span>
-                </router-link>
-              </li>
-            </ul>
-          <!-- </transition> -->
-        </div>
+  <div class="search-box">
+    <input
+      @focus="onfocus"
+      @keyup="choseList"
+      v-model="searchVal"
+      class="search"
+      type="text"
+      placeholder="搜索组件..."
+    >
+    <!-- <transition name="fade"> -->
+    <ul class="search-list" v-if="searchList.length>0">
+      <li
+        :class="searchCurName==item.name?'cur':''"
+        @click="checklist(item)"
+        v-for="(item,index) in searchList"
+        :key="index"
+      >
+        <router-link :to="{name:item.name}">
+          {{item.name}}
+          <span>{{item.chnName}}</span>
+        </router-link>
+      </li>
+    </ul>
+    <!-- </transition> -->
+  </div>
 </template>
 </template>
 <script>
 <script>
-import Conf from "../../src/config.json";
+import { packages } from "../../src/config.json";
 export default {
 export default {
-    data(){
-        return {
-            packages : Conf.packages,
-            searchVal: "",           
-            searchList: [],
-            searchCurName:'',
-             searchIndex:0,
-        }
-    },   
-    mounted() {
-      let list = document.querySelector('.search-list');
-      let that = this;
-      window.addEventListener('click',that.closelist)
+  data() {
+    return {
+      packages,
+      searchVal: "",
+      searchList: [],
+      searchCurName: "",
+      searchIndex: 0
+    };
+  },
+  watch: {
+    searchVal(sVal) {
+      if (sVal) {
+        this.searchList = this.packages.filter(item => {
+          if (item.showDemo === false) return false;
+          const rx = new RegExp(sVal, "gi");
+          return rx.test(item.name + " " + item.chnName + "" + item.desc);
+        });
+      } else {
+        this.searchCurName = "";
+        this.searchIndex = 0;
+        this.searchList = [];
+      }
+    }
+  },
+  mounted() {
+    document.documentElement.addEventListener("click", this.closelist);
+  },
+  methods: {
+    closelist() {
+      this.searchVal = "";
+      this.searchCurName = "";
+      this.searchIndex = 0;
+    },
+    onfocus(e) {
+      e.target.select();
     },
     },
-    methods:{
-        closelist(){           
-            this.searchList = [];
-            this.searchCurName='';
-            this.searchIndex=0;          
-        },
-        onfocus(e) {
-            e.target.select();
-          },
-          clearSearch() {
-            this.searchList = [];
-          },    
-          search(e) {
-            let val = e.target.value.toLowerCase();     
-            this.searchIndex=0;
-            if (val) {
-              let packages = this.packages;
-              let list = [];
-              for (let i = 0, item; (item = packages[i]); i++) {
-                let cn = item.chnName.toLowerCase();
-                let en = item.name.toLowerCase();
-                if (cn.indexOf(val) > -1 || en.indexOf(val) > -1) {
-                  list.push(item);
-                }
-              }
-              this.searchList = list;
-            }else{
+    checklist() {
+      this.searchVal = "";
+      this.searchCurName = "";
+      this.searchIndex = 0;
+    },
+    choseList(e) {
+      let searchIndex = this.searchIndex;
+      if (e.keyCode == 40) {
+        searchIndex++;
+      }
+      if (e.keyCode == 38) {
+        searchIndex--;
+      }
+      if (searchIndex < 0) {
+        searchIndex = 0;
+      }
+      let searchList = this.searchList;
+      if (searchList.length > 0) {
+        let chnName = searchList[searchIndex] && searchList[searchIndex].name;
 
 
-                this.checklist()
-            }
-          },
-          checklist() {
+        if (chnName) {
+          this.searchCurName = chnName;
+          this.searchIndex = searchIndex;
+          if (e.keyCode == 13) {
+            this.$router.push({
+              path: "/" + searchList[searchIndex].name
+            });
+            this.searchCurName = "";
+            this.searchIndex = 0;
             this.searchVal = "";
             this.searchVal = "";
-            this.searchList = [];
-            this.searchCurName='';
-            this.searchIndex=0;
-          },
-          choseList(e){           
-            let searchIndex = this.searchIndex;
-            if(e.keyCode==40){
-              searchIndex++;
-            }
-            if(e.keyCode==38){
-              searchIndex--;
-            }
-            if(searchIndex<0){
-              searchIndex = 0;
-            }      
-            let searchList = this.searchList;
-            if(searchList.length>0){       
-             
-            let chnName = searchList[searchIndex].name;
-            
-            if(chnName){
-              this.searchCurName = chnName;
-              this.searchIndex = searchIndex;
-              if(e.keyCode==13){
-                  this.$router.push({
-                      path:'/'+searchList[searchIndex].name
-                  })
-                this.searchCurName='';
-                this.searchIndex=0;
-                this.searchList=[];
-                this.searchVal='';
-              }
-            }       
-            }
           }
           }
+        }
+      }
     }
     }
-}
+  }
+};
 </script>
 </script>
 <style lang="scss" scoped>
 <style lang="scss" scoped>
 .search-box {
 .search-box {
-      height: 22px;
-      min-width: 300px;
-      position: relative;
-      input {
-        width: 100%;
-      }
-    }
- .search {
-      height: 22px;
-      font-size: 14px;
-      color: #666;
-      border: none;
-      background: url(./asset/css/i/sreach.png) no-repeat left center;
-      padding-left: 45px;
-      &:focus {
-        outline: none;
-      }
-    }
+  height: 22px;
+  min-width: 300px;
+  position: relative;
+  input {
+    width: 100%;
+  }
+}
+.search {
+  height: 22px;
+  font-size: 14px;
+  color: #666;
+  border: none;
+  background: url(./asset/css/i/sreach.png) no-repeat left center;
+  padding-left: 45px;
+  &:focus {
+    outline: none;
+  }
+}
 .search-list {
 .search-list {
-    background: #fff;
-    position: absolute;
-    width: 300px;
-    list-style: none;
-    border: 1px solid #f2f2f2;
-    z-index: 99999;
-    top: 27px;
-    padding: 0;
-    li {
+  background: #fff;
+  position: absolute;
+  width: 300px;
+  list-style: none;
+  border: 1px solid #f2f2f2;
+  z-index: 99999;
+  top: 27px;
+  padding: 0;
+  li {
     height: 40px;
     height: 40px;
     line-height: 40px;
     line-height: 40px;
-    font-size:12px;
+    font-size: 12px;
     a {
     a {
-        display: inline-block;
-        box-sizing: border-box;
-        width: 100%;
-        padding-left: 40px;
-        text-decoration: none;
-        color: #666;
+      display: inline-block;
+      box-sizing: border-box;
+      width: 100%;
+      padding-left: 40px;
+      text-decoration: none;
+      color: #666;
     }
     }
     &:hover {
     &:hover {
-        background: #6096ff;
-        color: #fff;
-        a {
+      background: #6096ff;
+      color: #fff;
+      a {
         color: #fff;
         color: #fff;
-        }
-    }
+      }
     }
     }
-    .cur{
-        background: #6096ff;
-        color: #fff;
-        a {
-        color: #fff;
-        }
+  }
+  .cur {
+    background: #6096ff;
+    color: #fff;
+    a {
+      color: #fff;
     }
     }
+  }
 }
 }
 </style>
 </style>
 
 

+ 3 - 2
src/nutui.js

@@ -1,4 +1,5 @@
-import { version, packages } from './config.json';
+import { version } from '../package.json';
+import { packages } from './config.json';
 import { locale } from './locales';
 import { locale } from './locales';
 
 
 const components = {};
 const components = {};
@@ -69,7 +70,7 @@ if (typeof window !== 'undefined' && window.Vue) {
 // }, components, filters, directives, methods);
 // }, components, filters, directives, methods);
 
 
 const API = {
 const API = {
-    version: version,
+    version,
     locale,
     locale,
     install,
     install,
     ...components,
     ...components,