Преглед изворни кода

lint: 代码风格格式化.

peter пре 3 дана
родитељ
комит
d53ce39d60
2 измењених фајлова са 39 додато и 109 уклоњено
  1. 1 0
      .prettierrc
  2. 38 109
      components/PcHeader.vue

+ 1 - 0
.prettierrc

@@ -1,4 +1,5 @@
 {
+  "printWidth": 120,
   "semi": false,
   "singleQuote": true,
   "trailingComma": "es5",

+ 38 - 109
components/PcHeader.vue

@@ -25,9 +25,7 @@
           :style="{ display: showType }">
           <div
             class="flex-auto flex center stretch no-result"
-            v-if="
-              !loading && result.cate.length < 1 && productsList.length < 1
-            ">
+            v-if="!loading && result.cate.length < 1 && productsList.length < 1">
             No results found for “{{ keyword }}”
           </div>
           <div
@@ -45,10 +43,7 @@
                     :to="{
                       name: 'category-firstCategory',
                       params: {
-                        firstCategory: item.name
-                          .replace(/\s+/g, '-')
-                          .replace('-&', '')
-                          .toLowerCase(),
+                        firstCategory: item.name.replace(/\s+/g, '-').replace('-&', '').toLowerCase(),
                       },
                     }">
                     <p>{{ item.name }}</p>
@@ -69,14 +64,8 @@
                     :to="{
                       name: 'category-firstCategory-secondCategory',
                       params: {
-                        firstCategory: item.parentName
-                          .replace(/\s+/g, '-')
-                          .replace('-&', '')
-                          .toLowerCase(),
-                        secondCategory: item.name
-                          .replace(/\s+/g, '-')
-                          .replace('-&', '')
-                          .toLowerCase(),
+                        firstCategory: item.parentName.replace(/\s+/g, '-').replace('-&', '').toLowerCase(),
+                        secondCategory: item.name.replace(/\s+/g, '-').replace('-&', '').toLowerCase(),
                       },
                     }">
                     <p>{{ item.name }}</p>
@@ -86,18 +75,9 @@
                     :to="{
                       name: 'category-firstCategory-secondCategory-thirdCategory',
                       params: {
-                        firstCategory: item.grandName
-                          .replace(/\s+/g, '-')
-                          .replace('-&', '')
-                          .toLowerCase(),
-                        secondCategory: item.parentName
-                          .replace(/\s+/g, '-')
-                          .replace('-&', '')
-                          .toLowerCase(),
-                        thirdCategory: item.name
-                          .replace(/\s+/g, '-')
-                          .replace('-&', '')
-                          .toLowerCase(),
+                        firstCategory: item.grandName.replace(/\s+/g, '-').replace('-&', '').toLowerCase(),
+                        secondCategory: item.parentName.replace(/\s+/g, '-').replace('-&', '').toLowerCase(),
+                        thirdCategory: item.name.replace(/\s+/g, '-').replace('-&', '').toLowerCase(),
                       },
                     }">
                     <p>{{ item.name }}</p>
@@ -114,9 +94,7 @@
                     name: 'category-searchResult',
                     query: { keyword: keyword },
                   }">
-                  <div class="seeAllResult">
-                    Show all {{ result.total }} Results
-                  </div>
+                  <div class="seeAllResult">Show all {{ result.total }} Results</div>
                 </nuxt-link>
               </div>
               <ul
@@ -138,7 +116,9 @@
                       "
                       alt="" />
                     <div class="product-info">
-                      <p style="width:94%;white-space: nowrap;overflow: hidden;text-overflow: ellipsis;">{{ item.alias_name || item.product_name }}</p>
+                      <p style="width: 94%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis">
+                        {{ item.alias_name || item.product_name }}
+                      </p>
                       <p>{{ item.product_code }}</p>
                     </div>
                   </nuxt-link>
@@ -267,8 +247,7 @@
                     </nuxt-link>
                   </div>
                   <div class="sub-menu">
-                    <a
-                      href="mailto:Info@promocollection.uk?subject=Sample%20Request">
+                    <a href="mailto:Info@promocollection.uk?subject=Sample%20Request">
                       <div class="flex">
                         <div class="icon mail"></div>
                         <div class="sub-title">Sample Request</div>
@@ -276,8 +255,7 @@
                     </a>
                   </div>
                   <div class="sub-menu">
-                    <a
-                      href="mailto:Info@promocollection.uk?subject=Free%20Mockup%20Request">
+                    <a href="mailto:Info@promocollection.uk?subject=Free%20Mockup%20Request">
                       <div class="flex">
                         <div class="icon mail"></div>
                         <div class="sub-title">Mockup Request</div>
@@ -315,10 +293,7 @@
               class="shopProducts"
               @click.stop="openShopProduct">
               Shop Products
-              <i
-                :class="
-                  isShopBlock ? 'el-icon-arrow-up' : 'el-icon-arrow-down'
-                "></i>
+              <i :class="isShopBlock ? 'el-icon-arrow-up' : 'el-icon-arrow-down'"></i>
             </span>
           </div>
           <Transition name="category">
@@ -336,18 +311,13 @@
                       :to="{
                         name: 'category-firstCategory',
                         params: {
-                          firstCategory: item1.name
-                            .replace(/\s+/g, '-')
-                            .replace('-&', '')
-                            .toLowerCase(),
+                          firstCategory: item1.name.replace(/\s+/g, '-').replace('-&', '').toLowerCase(),
                         },
                       }">
                       <div class="menu-item-icon">
                         <img
                           :src="
-                            item1.style && !$mediaRegExp.test(item1.style)
-                              ? $OSS_PREFIX + item1.style
-                              : item1.style
+                            item1.style && !$mediaRegExp.test(item1.style) ? $OSS_PREFIX + item1.style : item1.style
                           "
                           alt="" />
                       </div>
@@ -365,14 +335,8 @@
                       :to="{
                         name: 'category-firstCategory-secondCategory',
                         params: {
-                          firstCategory: item1.name
-                            .replace(/\s+/g, '-')
-                            .replace('-&', '')
-                            .toLowerCase(),
-                          secondCategory: item2.name
-                            .replace(/\s+/g, '-')
-                            .replace('-&', '')
-                            .toLowerCase(),
+                          firstCategory: item1.name.replace(/\s+/g, '-').replace('-&', '').toLowerCase(),
+                          secondCategory: item2.name.replace(/\s+/g, '-').replace('-&', '').toLowerCase(),
                         },
                       }">
                       {{ item2.name }}
@@ -450,7 +414,6 @@
         <li
           class="nav-list"
           @click="closeAllBlock">
-          <!-- <a :href="'/category?feature=54'"> New products</a> -->
           <div class="nav-list-title">
             <nuxt-link
               :to="{ name: 'category', query: { feature: 54 } }"
@@ -463,9 +426,7 @@
           class="nav-list"
           @click="closeAllBlock">
           <div class="nav-list-title">
-            <a href="/article/Compliance">
-              Compliance
-            </a>
+            <a href="/article/Compliance"> Compliance </a>
           </div>
         </li>
         <li
@@ -660,16 +621,12 @@ export default {
     //       this.budget = res.result
     //     }
     //   })
-    const p4 = this.$axios
-      .post('/uk-api/home/articleList', { keyword: 'Indent Ideas' })
-      .then(res => {
-        this.indentIdeasArticle = res.result.data[0] || {}
-      })
-    const p5 = this.$axios
-      .post('/uk-api/home/articleList', { keyword: 'Compliance' })
-      .then(res => {
-        this.complianceArticle = res.result.data[0] || {}
-      })
+    const p4 = this.$axios.post('/uk-api/home/articleList', { keyword: 'Indent Ideas' }).then(res => {
+      this.indentIdeasArticle = res.result.data[0] || {}
+    })
+    const p5 = this.$axios.post('/uk-api/home/articleList', { keyword: 'Compliance' }).then(res => {
+      this.complianceArticle = res.result.data[0] || {}
+    })
     // 并联异步操作,总耗时===耗时最长的单个请求。之前的逻辑是串联,总耗时为所有请求耗时的累加
     await Promise.all([p1, p4, p5])
   },
@@ -687,9 +644,7 @@ export default {
             ...item,
           }
           if (item.img) {
-            temp.image = !this.$mediaRegExp.test(item.img)
-              ? this.$OSS_PREFIX + item.img
-              : item.img
+            temp.image = !this.$mediaRegExp.test(item.img) ? this.$OSS_PREFIX + item.img : item.img
           }
           return temp
         })
@@ -741,16 +696,10 @@ export default {
     window.addEventListener('click', this.closeLeadtimeAndBudget)
 
     if (process.env.NODE_ENV === 'development') {
-      const client = algoliasearch(
-        '7KGEFE6I2Z',
-        'e39e202ace0a2fa12ea61095e6ede35d'
-      )
+      const client = algoliasearch('7KGEFE6I2Z', 'e39e202ace0a2fa12ea61095e6ede35d')
       this.index = client.initIndex('test_uk')
     } else {
-      const client = algoliasearch(
-        '2340OWI595',
-        '2d4c53cdcf2bab0c361e589c2c2272fa'
-      )
+      const client = algoliasearch('2340OWI595', '2d4c53cdcf2bab0c361e589c2c2272fa')
       this.index = client.initIndex('product_uk')
     }
   },
@@ -797,20 +746,11 @@ export default {
                 let colorImg = ''
                 item.colour_imgs = JSON.parse(item.colour_imgs)
                 item.colour_imgs.sort((a, b) => a.name.length - b.name.length)
-                if (
-                  Array.isArray(item.colour_imgs) &&
-                  item.colour_imgs.length
-                ) {
+                if (Array.isArray(item.colour_imgs) && item.colour_imgs.length) {
                   item.colour_imgs.forEach(colorItem => {
                     if (colorItem.name && colorItem.name.length) {
-                      if (
-                        new RegExp(colorItem.name.toLowerCase(), 'i').test(key)
-                      ) {
-                        console.log(
-                          item.product_code,
-                          colorItem.name,
-                          'replace'
-                        )
+                      if (new RegExp(colorItem.name.toLowerCase(), 'i').test(key)) {
+                        console.log(item.product_code, colorItem.name, 'replace')
                         colorImg = colorItem.img
                       } else if (
                         /\s/.test(colorItem.name) &&
@@ -819,11 +759,7 @@ export default {
                           .filter(a => a.length > 0)
                           .some(b => new RegExp(b.toLowerCase(), 'i').test(key))
                       ) {
-                        console.log(
-                          item.product_code,
-                          colorItem.name,
-                          'advance replace'
-                        )
+                        console.log(item.product_code, colorItem.name, 'advance replace')
                         colorImg = colorItem.img
                       }
                     }
@@ -831,11 +767,7 @@ export default {
                   item.colour_imgs.forEach(i => {
                     if (i.name && i.name.length) {
                       if (key.toLowerCase().includes(i.name.toLowerCase())) {
-                        console.log(
-                          item.product_code,
-                          i.name,
-                          'complete replace'
-                        )
+                        console.log(item.product_code, i.name, 'complete replace')
                         colorImg = i.img
                       }
                     }
@@ -849,10 +781,7 @@ export default {
                 })
                 if (!item.category_id) return
                 const id = parseInt(item.category_id)
-                const categoryResult = this.getCategoryFromTree(
-                  id,
-                  this.categoryList
-                )
+                const categoryResult = this.getCategoryFromTree(id, this.categoryList)
                 switch (categoryResult.lev) {
                   case 1:
                     if (!t1.includes(id)) {
@@ -899,9 +828,7 @@ export default {
       //   name: 'category-searchResult',
       //   query: { keyword: this.keyword },
       // })
-      location.href =
-        location.origin +
-        `/category/searchResult?keyword=${encodeURIComponent(this.keyword)}`
+      location.href = location.origin + `/category/searchResult?keyword=${encodeURIComponent(this.keyword)}`
     },
     logout() {
       this.$store.dispatch('logout').then(() => {
@@ -1019,7 +946,9 @@ export default {
 </script>
 
 <style lang="scss" scoped>
-.product-info {width:100%;}
+.product-info {
+  width: 100%;
+}
 header {
   width: 100%;
   position: fixed;