Эх сурвалжийг харах

feat:动态域名getRootDomain

ananzhusen 1 жил өмнө
parent
commit
063f491a1e

+ 1 - 1
src/App.vue

@@ -22,7 +22,7 @@ onBeforeMount(() => {
     if(theme === 'light') {
       setTimeout(() => {
         switchTheme(theme);
-      }, 2000);
+      }, 3000);
     }else{
       changeTheme('le-dark');
     }

+ 17 - 10
src/services/common.ts

@@ -16,37 +16,44 @@ import { useSelection } from '@/services/selections';
 
 const { select } = useSelection();
 
+export const getRootDomain = ()=>{ 
+  const a =location.host.split('.');
+  return `.${a[a.length-2]}.${a[a.length-1]}`
+};
+
+const rootDomin = getRootDomain();
+
 const assets = reactive({
-  home: 'https://le5le.com',
-  account: 'https://account.le5le.com',
-  '3d': 'https://3d.le5le.com',
-  '2d': 'https://2d.le5le.com',
+  home: `https://${rootDomin.slice(1)}`,
+  account: `https://account${rootDomin}',`,
+  '3d': `https://3d${rootDomin}`,
+  '2d': `https://2d${rootDomin}`,
   helps: [
     {
       name: '产品介绍',
-      url: 'https://doc.le5le.com/document/118756411',
+      url: `https://doc${rootDomin}/document/118756411`,
     },
     {
       name: '快速上手',
-      url: 'https://doc.le5le.com/document/119363000',
+      url: `https://doc${rootDomin}/document/119363000`,
     },
     {
       name: '使用手册',
-      url: 'https://doc.le5le.com/document/118764244',
+      url: `https://doc${rootDomin}/document/118764244`,
     },
     {
       name: '快捷键',
-      url: 'https://doc.le5le.com/document/119620214',
+      url: `https://doc${rootDomin}/document/119620214`,
       divider: true,
     },
     {
       name: '企业服务与支持',
-      url: 'https://doc.le5le.com/document/119296274',
+      url: `https://doc${rootDomin}/document/119296274`,
       divider: true,
     },
     {
       name: '关于我们',
-      url: 'https://le5le.com/about.html',
+      url: `https://${rootDomin.slice(1)}/about.html`,
     },
   ],
 });

+ 12 - 10
src/services/defaults.ts

@@ -1,6 +1,8 @@
 import { Pen, FormItem } from '@meta2d/core';
 import { cdn } from './api';
+import { getRootDomain } from './common';
 
+const rootDomin = getRootDomain();
 export const fromArrows = [
   { icon: '#l-line', value: '' },
   { icon: '#l-from-triangle', value: 'triangle' },
@@ -2180,7 +2182,7 @@ export const formComponents = [
           width: 500,
           height: 400,
           externElement: true,
-          iframe: 'https://le5le.com',
+          iframe: `https://${rootDomin.slice(1)}`,
           props: {
             custom: iframeCustom,
           },
@@ -2416,13 +2418,13 @@ export const formComponents = [
           height: 300,
           data: [
             {
-              src: 'https://2ds.le5le.com/img/banner1.bc890350.png',
+              src: `https://2ds${rootDomin}/img/banner1.bc890350.png`,
             },
             {
-              src: 'https://2ds.le5le.com/img/banner2.adab6a6e.png',
+              src: `https://2ds${rootDomin}/img/banner2.adab6a6e.png`,
             },
             {
-              src: 'https://2ds.le5le.com/img/banner3.86b53aed.png',
+              src: `https://2ds${rootDomin}/img/banner3.86b53aed.png`,
             },
           ],
           hiddenText: true,
@@ -2447,13 +2449,13 @@ export const formComponents = [
           swiperType: 'iframe',
           data: [
             {
-              src: 'https://2d.le5le.com/preview?id=6357a9e2d44b9402de84d2e8',
+              src: `https://2d${rootDomin}/preview?id=6357a9e2d44b9402de84d2e8`,
             },
             {
-              src: 'https://2d.le5le.com/preview?id=6357aec8d44b9402de84d2f1',
+              src: `https://2d${rootDomin}/preview?id=6357aec8d44b9402de84d2f1`,
             },
             {
-              src: 'https://2d.le5le.com/preview?id=641d524a8df2c654ea652d7e',
+              src: `https://2d${rootDomin}/preview?id=641d524a8df2c654ea652d7e`,
             },
           ],
           hiddenText: true,
@@ -2490,7 +2492,7 @@ export const formComponents = [
                 {
                   action: 0,
                   params: '_blank',
-                  value: 'https://2d.le5le.com/',
+                  value: `https://2d${rootDomin}`,
                 },
               ],
             },
@@ -2621,13 +2623,13 @@ context.meta2d.translate(
             {
               key: '2',
               text: '页面2',
-              to: 'https://2d.le5le.com/?id=641d524a8df2c654ea652d7e',
+              to: `https://2d${rootDomin}/?id=641d524a8df2c654ea652d7e`,
               target: '_blank',
             },
             {
               key: '3',
               text: '页面3',
-              to: 'https://2d.le5le.com/?id=6357a9e2d44b9402de84d2e8',
+              to: `https://2d${rootDomin}/?id=6357a9e2d44b9402de84d2e8`,
               target: '_self',
             },
           ],

+ 0 - 2
src/services/download.ts

@@ -510,9 +510,7 @@ async function zipImage(zip: JSZip, image: string, temImage?: string) {
 //   const pen_2d = meta2d.store.data.pens.filter(
 //     (pen) =>
 //       pen.name === 'iframe' &&
-//       (pen.iframe.indexOf('2d.le5le.com') !== -1 ||
 //         pen.iframe.indexOf('/2d') !== -1 || pen.iframe.indexOf('data=2d') !== -1 ||
-//         pen.iframe.indexOf('v.le5le.com') !== -1 ||
 //         pen.iframe.indexOf('/view/v') !== -1 ||pen.iframe.indexOf('data=v') !== -1||
 //         pen.iframe.indexOf('/preview') !== -1)
 //   );

+ 9 - 7
src/services/enterprise.ts

@@ -1,9 +1,11 @@
 import { reactive } from 'vue';
 import axios from 'axios';
+import { getRootDomain } from './common';
 
+const rootDomin = getRootDomain();
 const enterprise = reactive({
   name: '乐吾乐',
-  home: 'https://le5le.com',
+  home: `https://${rootDomin.slice(1)}`,
   account: location.protocol + '//' + location.host + '/account',
   v: location.protocol + '//' + location.host + '/v',
   '3d': location.protocol + '//' + location.host + '/3d',
@@ -12,29 +14,29 @@ const enterprise = reactive({
   helps: [
     {
       name: '产品介绍',
-      url: 'https://doc.le5le.com/document/118756411',
+      url: `https://doc${rootDomin}/document/118756411`,
     },
     {
       name: '快速上手',
-      url: 'https://doc.le5le.com/document/119363000',
+      url: `https://doc${rootDomin}/document/119363000`,
     },
     {
       name: '使用手册',
-      url: 'https://doc.le5le.com/document/118764244',
+      url: `https://doc${rootDomin}/document/118764244`,
     },
     {
       name: '快捷键',
-      url: 'https://doc.le5le.com/document/119620214',
+      url: `https://doc${rootDomin}/document/119620214`,
       divider: true,
     },
     {
       name: '企业服务与支持',
-      url: 'https://doc.le5le.com/document/119296274',
+      url: `https://doc${rootDomin}/document/119296274`,
       divider: true,
     },
     {
       name: '关于我们',
-      url: 'https://le5le.com/about.html',
+      url: `https://${rootDomin.slice(1)}/about.html`,
     },
   ],
 });

+ 3 - 3
src/views/components/Graphics.vue

@@ -393,7 +393,7 @@ import {
 } from '@/services/api';
 import { convertPen } from '@/services/upgrade';
 import { isGif } from '@/services/utils';
-import { autoSave, delAttrs, blank, useFolder, chargeDialogShow } from '@/services/common';
+import { autoSave, delAttrs, blank, useFolder, chargeDialogShow, getRootDomain } from '@/services/common';
 import { debounce, throttle } from '@/services/debouce';
 import { searchObjectPinyin } from '@/services/pinyin';
 import { getCookie } from '@/services/cookie';
@@ -412,7 +412,7 @@ const { user } = useUser();
 const { setFolder, getFolder } = useFolder();
 const router = useRouter();
 const { select } = useSelection();
-
+const rootDomain = getRootDomain();
 const activedGroup = ref('');
 const activeAssets = ref('system');
 let groups = reactive([]);
@@ -1621,7 +1621,7 @@ const onMenu = async (val: string) => {
           },
         });
       } else if (contextmenu.component['3d']) {
-        let url = 'https://3d.le5le.com/?id=';
+        let url = `https://3d${rootDomain}/?id=`;
         if (window.url3D) {
           url = window.url3D;
         }

+ 20 - 19
src/views/components/Header.vue

@@ -412,7 +412,7 @@
           <span style="vertical-align: middle">导出为Zip文件</span>
           <t-tooltip  content="这是Tooltip内容">
             <a
-            href="https://doc.le5le.com/document/155692631#%E5%AF%BC%E5%87%BA%E4%B8%BAZip%E6%96%87%E4%BB%B6"
+            :href="`https://doc${rootDomain}/document/155692631#%E5%AF%BC%E5%87%BA%E4%B8%BAZip%E6%96%87%E4%BB%B6`"
             target="_blank"
             class="hover"
             >
@@ -524,7 +524,8 @@ import {
   useDot,
   delAttrs,
   // useAssets,
-  autoSaveAS
+  autoSaveAS,
+  getRootDomain
 } from '@/services/common';
 import { useEnterprise } from '@/services/enterprise';
 import {
@@ -562,7 +563,7 @@ const router = useRouter();
 const route = useRoute();
 
 const baseUrl = import.meta.env.BASE_URL || '/';
-
+const rootDomain = getRootDomain();
 // const { assets, getAssets } = useAssets();
 
 const { user, signout } = useUser();
@@ -702,7 +703,7 @@ const login = () => {
   if(import.meta.env.BASE_URL.startsWith('/') ){
     return `${enterprise['account']}?cb=${encodeURIComponent(location.href)}`;
   }else{
-    return `https://account.le5le.com/login?cb=${encodeURIComponent(location.href)}`;
+    return `https://account${rootDomain}/login?cb=${encodeURIComponent(location.href)}`;
   }
 };
 
@@ -1139,9 +1140,9 @@ const preGetPayList = async () => {
   const pen_pay = meta2dData.pens.filter(
     (pen) =>
       pen.name === 'iframe' &&
-      (pen.iframe.indexOf('2d.le5le.com') !== -1 ||
+      (pen.iframe.indexOf(`2d${rootDomain}`) !== -1 ||
         pen.iframe.indexOf('/2d') !== -1 || pen.iframe.indexOf('data=2d') !== -1 ||
-        pen.iframe.indexOf('v.le5le.com') !== -1 ||
+        pen.iframe.indexOf(`v${rootDomain}`) !== -1 ||
         pen.iframe.indexOf('/view/v') !== -1 ||pen.iframe.indexOf('data=v') !== -1 ||
         pen.iframe.indexOf('/preview') !== -1)
   );
@@ -1172,19 +1173,19 @@ const showPayListDialog = async () => {
   const pen_3d = meta2d.store.data.pens.filter(
     (pen) =>
       pen.name === 'iframe' &&
-      (pen.iframe.indexOf('3d.le5le.com') !== -1 ||
+      (pen.iframe.indexOf(`3d${rootDomain}`) !== -1 ||
         pen.iframe.indexOf('/3d') !== -1)
   );
   const pen_2d = meta2d.store.data.pens.filter(
     (pen) =>
       pen.name === 'iframe' &&
-      (pen.iframe.indexOf('2d.le5le.com') !== -1 ||
+      (pen.iframe.indexOf(`2d${rootDomain}`) !== -1 ||
         pen.iframe.indexOf('/2d') !== -1)
   );
   const pen_v = meta2d.store.data.pens.filter(
     (pen) =>
       pen.name === 'iframe' &&
-      (pen.iframe.indexOf('v.le5le.com') !== -1 ||
+      (pen.iframe.indexOf(`v${rootDomain}`) !== -1 ||
         pen.iframe.indexOf('/view/v') !== -1||pen.iframe.indexOf('data=v') !== -1)
   );
   let price = 0;
@@ -1294,22 +1295,22 @@ const showPayListDialog = async () => {
   switch (downloadType) {
     case Frame.html:
       payListDialog.title = '下载离线部署包';
-      payListDialog.href = 'https://doc.le5le.com/document/155692631#%E4%B8%8B%E8%BD%BD%E7%A6%BB%E7%BA%BF%E9%83%A8%E7%BD%B2%E5%8C%85';
+      payListDialog.href = `https://doc${rootDomain}/document/155692631#%E4%B8%8B%E8%BD%BD%E7%A6%BB%E7%BA%BF%E9%83%A8%E7%BD%B2%E5%8C%85`;
       payListDialog.downloadUrl =img_cdn+ '/deployment/大厦电力管理系统(html).zip';
       break;
       case Frame.vue2:
       payListDialog.title = '下载vue2组件包';
-      payListDialog.href = 'https://doc.le5le.com/document/155692631#%E4%B8%8B%E8%BD%BDVue2%E7%BB%84%E4%BB%B6%E5%8C%85';
+      payListDialog.href = `https://doc${rootDomain}/document/155692631#%E4%B8%8B%E8%BD%BDVue2%E7%BB%84%E4%BB%B6%E5%8C%85`;
       payListDialog.downloadUrl = img_cdn+ '/deployment/大厦电力管理系统(vue2).zip';
       break;
       case Frame.vue3:
       payListDialog.title = '下载vue3组件包';
-      payListDialog.href = 'https://doc.le5le.com/document/155692631#%E4%B8%8B%E8%BD%BDVue3%E7%BB%84%E4%BB%B6%E5%8C%85';
+      payListDialog.href = `https://doc${rootDomain}/document/155692631#%E4%B8%8B%E8%BD%BDVue3%E7%BB%84%E4%BB%B6%E5%8C%85`;
       payListDialog.downloadUrl = img_cdn+ '/deployment/大厦电力管理系统(vue3).zip';
       break;
       case Frame.react:
       payListDialog.title = '下载react组件包';
-      payListDialog.href = 'https://doc.le5le.com/document/155692631#%E4%B8%8B%E8%BD%BDReact%E7%BB%84%E4%BB%B6%E5%8C%85';
+      payListDialog.href = `https://doc${rootDomain}/document/155692631#%E4%B8%8B%E8%BD%BDReact%E7%BB%84%E4%BB%B6%E5%8C%85`;
       payListDialog.downloadUrl = img_cdn+ '/deployment/大厦电力管理系统(react).zip';
       break;
   }
@@ -1331,7 +1332,7 @@ const preDownload =() => {
   const pen_3d = meta2dData.pens.filter(
     (pen) =>
       pen.name === 'iframe' &&
-      (pen.iframe.indexOf('3d.le5le.com') !== -1 ||
+      (pen.iframe.indexOf(`3d${rootDomain}`) !== -1 ||
         pen.iframe.indexOf('/3d') !== -1)
   );
   if (pen_3d && pen_3d.length) {
@@ -1375,7 +1376,7 @@ const preDownload =() => {
   const pen_2d = meta2dData.pens.filter(
     (pen) =>
       pen.name === 'iframe' &&
-      (pen.iframe.indexOf('2d.le5le.com') !== -1 ||
+      (pen.iframe.indexOf(`2d${rootDomain}`) !== -1 ||
         pen.iframe.indexOf('/2d') !== -1)
   );
   if (pen_2d && pen_2d.length) {
@@ -1419,7 +1420,7 @@ const preDownload =() => {
   const pen_v = meta2dData.pens.filter(
     (pen) =>
       pen.name === 'iframe' &&
-      (pen.iframe.indexOf('v.le5le.com') !== -1 ||
+      (pen.iframe.indexOf(`v${rootDomain}`) !== -1 ||
         pen.iframe.indexOf('/view/v') !== -1||pen.iframe.indexOf('data=v') !== -1)
   );
 
@@ -1468,7 +1469,7 @@ const preFrameDownload = async () => {
   const pen_3d = meta2dData.pens.filter(
     (pen) =>
       pen.name === 'iframe' &&
-      (pen.iframe.indexOf('3d.le5le.com') !== -1 ||
+      (pen.iframe.indexOf(`3d${rootDomain}`) !== -1 ||
         pen.iframe.indexOf('/3d') !== -1)
   );
   let name_3d = (downloadType===Frame.vue3?'toVue3':downloadType===Frame.vue2?'toVue2':'toReact');
@@ -1514,7 +1515,7 @@ const preFrameDownload = async () => {
   const pen_2d = meta2dData.pens.filter(
     (pen) =>
       pen.name === 'iframe' &&
-      (pen.iframe.indexOf('2d.le5le.com') !== -1 ||
+      (pen.iframe.indexOf(`2d${rootDomain}`) !== -1 ||
         pen.iframe.indexOf('/2d') !== -1)
   );
   let name_2d = (downloadType===Frame.vue3?'downloadVue3':downloadType===Frame.vue2?'downloadVue2':'downloadReact');
@@ -1560,7 +1561,7 @@ const preFrameDownload = async () => {
   const pen_v = meta2dData.pens.filter(
     (pen) =>
       pen.name === 'iframe' &&
-      (pen.iframe.indexOf('v.le5le.com') !== -1 ||
+      (pen.iframe.indexOf(`v${rootDomain}`) !== -1 ||
         pen.iframe.indexOf('/view/v') !== -1||pen.iframe.indexOf('data=v') !== -1||pen.iframe.indexOf('/preview') !== -1)
   );
   if (pen_v && pen_v.length) {

+ 8 - 14
src/views/components/View.vue

@@ -697,7 +697,7 @@
                   @click="refreshSubdomain"
                 /> -->
               </t-tooltip>
-              <div class="mt-4 ml-16">v.le5le.com</div>
+              <div class="mt-4 ml-16">{{`v${rootDomain}`}}</div>
             </div>
           </div>
           <div class="form-item mt-24">
@@ -750,7 +750,7 @@
                 <div>
                   在域名服务商的DNS控制台设置好对应的CNAME,值为乐吾乐域名。
                   <a
-                    href="https://doc.le5le.com/document/126505408"
+                    :href="`https://doc${rootDomain}/document/126505408`"
                     target="_blank"
                   >
                     更多帮助
@@ -822,6 +822,7 @@ import {
   onScaleWindow,
   useDot,
   autoSaveAS,
+  getRootDomain
 } from '@/services/common';
 import { useSelection } from '@/services/selections';
 import { defaultFormat, fromArrows, toArrows } from '@/services/defaults';
@@ -842,7 +843,7 @@ const route = useRoute();
 const { user, getUser } = useUser();
 const { dot, setDot } = useDot();
 const { select } = useSelection();
-
+const rootDomain = getRootDomain();
 const meta2dOptions: Options = {
   cdn,
   rule: true,
@@ -915,13 +916,6 @@ const watcher = watch(
 //TODO 打开图纸
 const open = async (flag: boolean = false) => {
   if (route.query.token) {
-    //删除t域名登陆问题
-    deleteCookie('token', {
-      path: '/',
-      domain: 't.le5le.com',
-    });
-    // localStorage.setItem('token', route.query.token + '');
-    // setCookie('token', route.query.token + '');
     setCookie('token', route.query.token + '', {
       path: '/',
       domain: getDomain(),
@@ -964,7 +958,7 @@ const open = async (flag: boolean = false) => {
         shared.value = ret.shared;
 
         const qr: any = await QRCode.toDataURL(
-          `https://view2d.le5le.com/?id=${route.query.id + '&tag=v'}`
+          `https://view2d${rootDomain}/?id=${route.query.id + '&tag=v'}`
         );
         qrcode.url = qr;
       }
@@ -1809,9 +1803,9 @@ const onChangeSubdomain = async () => {
 
   if (
     !publishDialog.data.domain ||
-    publishDialog.data.domain.indexOf('.v.le5le.com') >= 0
+    publishDialog.data.domain.indexOf(`.v${rootDomain}`) >= 0
   ) {
-    publishDialog.data.domain = publishDialog.data.subDomain + '.v.le5le.com';
+    publishDialog.data.domain = publishDialog.data.subDomain + `.v${rootDomain}`;
   }
 
   makePublishQrcode();
@@ -1827,7 +1821,7 @@ const onPublish = async () => {
   }
 
   if (!publishDialog.data.domain) {
-    publishDialog.data.domain = publishDialog.data.subDomain + '.v.le5le.com';
+    publishDialog.data.domain = publishDialog.data.subDomain + `.v${rootDomain}`;
   }
   if(!route.query.id) {
     MessagePlugin.warning('请选择将要发布的方案');