Browse Source

docs: jdt theme edit

richard1015 3 years ago
parent
commit
4424203ab9

+ 8 - 7
src/sites/assets/util/helper.ts

@@ -1,6 +1,7 @@
 import config from '../../config/env';
 import config from '../../config/env';
 import { reactive, watch, onMounted, computed, onBeforeUnmount } from 'vue';
 import { reactive, watch, onMounted, computed, onBeforeUnmount } from 'vue';
 import { nav } from '../../../config.json';
 import { nav } from '../../../config.json';
+import { isJDB, isJDT } from '.';
 
 
 type Obj = {
 type Obj = {
   [k: string]: any;
   [k: string]: any;
@@ -168,13 +169,13 @@ export const useThemeEditor = function () {
       // 固定自定义主题的访问链接: https://nutui.jd.com/theme/?theme=自定义变量的文件地址#/
       // 固定自定义主题的访问链接: https://nutui.jd.com/theme/?theme=自定义变量的文件地址#/
       // e.g. https://nutui.jd.com/theme/?theme=xxx.com%2variables.scss#/
       // e.g. https://nutui.jd.com/theme/?theme=xxx.com%2variables.scss#/
       // vite issue https://github.com/vitejs/vite/issues/6894
       // vite issue https://github.com/vitejs/vite/issues/6894
-      const params = new URLSearchParams(window.parent.location.search);
-      const param = params.get('theme') as string;
-      const source = {
-        jdt: 'https://storage.360buyimg.com/nutui-static/source/variables-jdt.scss_source',
-        jdb: 'https://storage.360buyimg.com/nutui-static/source/variables-jdb.scss_source'
-      } as any;
-      const customUrl = param && source[param.replace('/', '')];
+
+      let customUrl = '';
+      if (isJDT()) {
+        customUrl = 'https://storage.360buyimg.com/nutui-static/source/variables-jdt.scss_source';
+      } else if (isJDB()) {
+        customUrl = 'https://storage.360buyimg.com/nutui-static/source/variables-jdb.scss_source';
+      }
       if (customUrl) {
       if (customUrl) {
         loadScript('https://storage.360buyimg.com/nutui-static/cdn/sass.sync.min.js').then((res) => {
         loadScript('https://storage.360buyimg.com/nutui-static/cdn/sass.sync.min.js').then((res) => {
           Promise.all([getSassVariables(customUrl), getRawSassStyle()]);
           Promise.all([getSassVariables(customUrl), getRawSassStyle()]);

+ 7 - 2
src/sites/assets/util/index.ts

@@ -1,4 +1,9 @@
 const ua = navigator.userAgent.toLowerCase();
 const ua = navigator.userAgent.toLowerCase();
 const isMobile = /ios|iphone|ipod|ipad|android/.test(ua);
 const isMobile = /ios|iphone|ipod|ipad|android/.test(ua);
-
-export { isMobile };
+const isJDT = () => {
+  return window.parent.location.href.includes('jdt');
+};
+const isJDB = () => {
+  return window.parent.location.href.includes('jdb');
+};
+export { isMobile, isJDT, isJDB };

+ 20 - 6
src/sites/mobile/components/Index.vue

@@ -1,10 +1,10 @@
 <template>
 <template>
   <div class="index">
   <div class="index">
     <div class="index-header">
     <div class="index-header">
-      <img src="../../assets/images/logo-red.png" alt="" srcset="" />
+      <img :src="logo" alt="" srcset="" />
       <div class="info">
       <div class="info">
-        <h1>NutUI</h1>
-        <p>京东风格的轻量级移动端 Vue 组件库</p>
+        <h1>{{ title }}</h1>
+        <p>{{ desc }}</p>
       </div>
       </div>
     </div>
     </div>
     <div class="index-components">
     <div class="index-components">
@@ -28,12 +28,26 @@
 <script lang="ts">
 <script lang="ts">
 import { defineComponent, reactive } from 'vue';
 import { defineComponent, reactive } from 'vue';
 import { nav } from '@/config.json';
 import { nav } from '@/config.json';
+import { isJDT } from '@/sites/assets/util';
 export default defineComponent({
 export default defineComponent({
   name: 'doc',
   name: 'doc',
   setup() {
   setup() {
-    return reactive({
-      nav
-    });
+    let baseInfo = {
+      logo: 'https://img14.360buyimg.com/imagetools/jfs/t1/167902/2/8762/791358/603742d7E9b4275e3/e09d8f9a8bf4c0ef.png',
+      title: 'NutUI',
+      desc: '京东风格的轻量级移动端 Vue 组件库'
+    };
+    if (isJDT()) {
+      baseInfo.logo =
+        'https://img12.360buyimg.com/imagetools/jfs/t1/101920/21/28459/834912/62870b04E0e1f20ec/17425bea5318a22c.png';
+      baseInfo.title = 'NutUI JDT';
+      baseInfo.desc = '京东科技风格的轻量级移动端 Vue 组件库';
+    }
+
+    return {
+      nav,
+      ...baseInfo
+    };
   }
   }
 });
 });
 </script>
 </script>