Commit 38839cd53b31d2dfbc2a52f59a436d8271c0f70d
Merge branch 'perf/configuration-center' into 'main_dev'
fix: 修复组态创建链接的代理路径不一致 See merge request yunteng/thingskit-front!961
Showing
2 changed files
with
47 additions
and
48 deletions
1 | +import { Platform } from './center.data'; | ||
2 | +import { ConfigurationCenterItemsModal } from '/@/api/configuration/center/model/configurationCenterModal'; | ||
3 | +import { useGlobSetting } from '/@/hooks/setting'; | ||
4 | + | ||
5 | +export enum ScadaModeEnum { | ||
6 | + LIGHTBOX = 'lightbox', | ||
7 | + DESIGN = 'design', | ||
8 | + SHARE = 'share', | ||
9 | +} | ||
10 | + | ||
11 | +interface ScadaLinkParamsType { | ||
12 | + configurationId: string; | ||
13 | + organizationId: string; | ||
14 | + mode: ScadaModeEnum; | ||
15 | + platform: Platform; | ||
16 | + publicId?: string; | ||
17 | +} | ||
18 | + | ||
1 | const getRandomString = () => Number(Math.random().toString().substring(2)).toString(36); | 19 | const getRandomString = () => Number(Math.random().toString().substring(2)).toString(36); |
2 | 20 | ||
3 | export const encode = (record: Recordable) => { | 21 | export const encode = (record: Recordable) => { |
@@ -13,3 +31,27 @@ export const encode = (record: Recordable) => { | @@ -13,3 +31,27 @@ export const encode = (record: Recordable) => { | ||
13 | hash = window.btoa(hash); | 31 | hash = window.btoa(hash); |
14 | return hash; | 32 | return hash; |
15 | }; | 33 | }; |
34 | + | ||
35 | +export const createScadaPageLink = ( | ||
36 | + record: ConfigurationCenterItemsModal, | ||
37 | + mode: ScadaModeEnum = ScadaModeEnum.DESIGN, | ||
38 | + open = true | ||
39 | +) => { | ||
40 | + const { configurationPrefix } = useGlobSetting(); | ||
41 | + const params: ScadaLinkParamsType = { | ||
42 | + configurationId: record.id, | ||
43 | + organizationId: record.organizationId!, | ||
44 | + mode: mode, | ||
45 | + platform: record.platform as Platform, | ||
46 | + }; | ||
47 | + | ||
48 | + if (mode === ScadaModeEnum.SHARE) { | ||
49 | + params.publicId = record.publicId; | ||
50 | + } | ||
51 | + | ||
52 | + const href = new URL(location.origin); | ||
53 | + href.pathname = configurationPrefix; | ||
54 | + href.hash = encode(params); | ||
55 | + open && window.open(href.href); | ||
56 | + return href.href; | ||
57 | +}; |
@@ -14,14 +14,12 @@ | @@ -14,14 +14,12 @@ | ||
14 | import { ConfigurationPermission, Platform, searchFormSchema } from './center.data'; | 14 | import { ConfigurationPermission, Platform, searchFormSchema } from './center.data'; |
15 | import { useMessage } from '/@/hooks/web/useMessage'; | 15 | import { useMessage } from '/@/hooks/web/useMessage'; |
16 | import { Authority } from '/@/components/Authority'; | 16 | import { Authority } from '/@/components/Authority'; |
17 | - import { isDevMode } from '/@/utils/env'; | ||
18 | import ConfigurationCenterDrawer from './ConfigurationCenterDrawer.vue'; | 17 | import ConfigurationCenterDrawer from './ConfigurationCenterDrawer.vue'; |
19 | import { useDrawer } from '/@/components/Drawer'; | 18 | import { useDrawer } from '/@/components/Drawer'; |
20 | import { getBoundingClientRect } from '/@/utils/domUtils'; | 19 | import { getBoundingClientRect } from '/@/utils/domUtils'; |
21 | import configurationSrc from '/@/assets/icons/configuration.svg'; | 20 | import configurationSrc from '/@/assets/icons/configuration.svg'; |
22 | import { cloneDeep } from 'lodash'; | 21 | import { cloneDeep } from 'lodash'; |
23 | import { usePermission } from '/@/hooks/web/usePermission'; | 22 | import { usePermission } from '/@/hooks/web/usePermission'; |
24 | - import { useGlobSetting } from '/@/hooks/setting'; | ||
25 | import { AuthIcon, CardLayoutButton } from '/@/components/Widget'; | 23 | import { AuthIcon, CardLayoutButton } from '/@/components/Widget'; |
26 | import AuthDropDown from '/@/components/Widget/AuthDropDown.vue'; | 24 | import AuthDropDown from '/@/components/Widget/AuthDropDown.vue'; |
27 | import { ShareModal } from '/@/views/common/ShareModal'; | 25 | import { ShareModal } from '/@/views/common/ShareModal'; |
@@ -31,7 +29,7 @@ | @@ -31,7 +29,7 @@ | ||
31 | import { useRole } from '/@/hooks/business/useRole'; | 29 | import { useRole } from '/@/hooks/business/useRole'; |
32 | import { useClipboard } from '@vueuse/core'; | 30 | import { useClipboard } from '@vueuse/core'; |
33 | import { Icon } from '/@/components/Icon'; | 31 | import { Icon } from '/@/components/Icon'; |
34 | - import { encode } from './help'; | 32 | + import { createScadaPageLink, ScadaModeEnum } from './help'; |
35 | 33 | ||
36 | const listColumn = ref(5); | 34 | const listColumn = ref(5); |
37 | 35 | ||
@@ -131,49 +129,15 @@ | @@ -131,49 +129,15 @@ | ||
131 | } | 129 | } |
132 | }; | 130 | }; |
133 | 131 | ||
134 | - const { configurationPrefix } = useGlobSetting(); | ||
135 | - const isDev = isDevMode(); | ||
136 | - | ||
137 | const handlePreview = (record: ConfigurationCenterItemsModal) => { | 132 | const handlePreview = (record: ConfigurationCenterItemsModal) => { |
138 | if (!unref(getPreviewFlag)) return; | 133 | if (!unref(getPreviewFlag)) return; |
139 | - // window.open( | ||
140 | - // `${configurationPrefix}/${isDev ? '?dev=1&' : '?'}configurationId=${ | ||
141 | - // record!.id | ||
142 | - // }&lightbox=1&organizationId=${record.organizationId}` | ||
143 | - // ); | ||
144 | - | ||
145 | - const params = { | ||
146 | - configurationId: record.id, | ||
147 | - organizationId: record.organizationId, | ||
148 | - mode: 'lightbox', | ||
149 | - platform: record.platform, | ||
150 | - }; | ||
151 | - | ||
152 | - const href = new URL(location.origin); | ||
153 | - href.pathname = '/drawio'; | ||
154 | - href.hash = encode(params); | ||
155 | - window.open(href.href); | 134 | + createScadaPageLink(record, ScadaModeEnum.LIGHTBOX); |
156 | }; | 135 | }; |
157 | 136 | ||
158 | const handleDesign = (record: ConfigurationCenterItemsModal) => { | 137 | const handleDesign = (record: ConfigurationCenterItemsModal) => { |
159 | if (!unref(getDesignFlag)) return; | 138 | if (!unref(getDesignFlag)) return; |
160 | - // window.open( | ||
161 | - // `${configurationPrefix}/${isDev ? '?dev=1&' : '?'}configurationId=${ | ||
162 | - // record!.id | ||
163 | - // }&organizationId=${record.organizationId}` | ||
164 | - // ); | ||
165 | - | ||
166 | - const params = { | ||
167 | - configurationId: record.id, | ||
168 | - organizationId: record.organizationId, | ||
169 | - mode: 'design', | ||
170 | - platform: record.platform, | ||
171 | - }; | ||
172 | - | ||
173 | - const href = new URL(location.origin); | ||
174 | - href.pathname = '/drawio'; | ||
175 | - href.hash = encode(params); | ||
176 | - window.open(href.href); | 139 | + |
140 | + createScadaPageLink(record, ScadaModeEnum.DESIGN); | ||
177 | }; | 141 | }; |
178 | 142 | ||
179 | const handleDelete = async (record: ConfigurationCenterItemsModal) => { | 143 | const handleDelete = async (record: ConfigurationCenterItemsModal) => { |
@@ -190,14 +154,7 @@ | @@ -190,14 +154,7 @@ | ||
190 | }; | 154 | }; |
191 | 155 | ||
192 | const createShareUrl = (record: ConfigurationCenterItemsModal) => { | 156 | const createShareUrl = (record: ConfigurationCenterItemsModal) => { |
193 | - const searchParams = new URLSearchParams(); | ||
194 | - isDev && searchParams.set('dev', '1'); | ||
195 | - searchParams.set('share', 'SCADA'); | ||
196 | - searchParams.set('configurationId', record.id); | ||
197 | - searchParams.set('publicId', record.publicId || ''); | ||
198 | - searchParams.set('lightbox', '1'); | ||
199 | - searchParams.set('organizationId', record!.organizationId || ''); | ||
200 | - return `${origin}${configurationPrefix}/?${searchParams.toString()}`; | 157 | + return createScadaPageLink(record, ScadaModeEnum.SHARE, false); |
201 | }; | 158 | }; |
202 | 159 | ||
203 | const { copied, copy } = useClipboard({ legacy: true }); | 160 | const { copied, copy } = useClipboard({ legacy: true }); |