Commit cb67737c67eb712afc577b289dddc8914be8e285
Merge branch 'fix/editor/10-17/2024' into 'main_dev'
perf(src/packages): 修改获取域名方式 See merge request yunteng/thingskit-view!292
Showing
2 changed files
with
9 additions
and
21 deletions
| 1 | -let threeFilePath = '' | |
| 1 | +const { host, protocol } = location | |
| 2 | 2 | |
| 3 | -const VITE_GLOB_PROXY = import.meta.env.VITE_GLOB_PROXY | |
| 3 | +let threeFilePath = `${protocol}//${host}` | |
| 4 | 4 | |
| 5 | -const VITE_GLOB_API_URL_PREFIX = import.meta.env.VITE_GLOB_API_URL_PREFIX | |
| 5 | +const VITE_GLOB_API_URL = import.meta.env.VITE_GLOB_API_URL | |
| 6 | 6 | |
| 7 | -try { | |
| 8 | - const getViteGlobProxy= Array.isArray(JSON.parse(VITE_GLOB_PROXY)) ? JSON.parse(VITE_GLOB_PROXY)[0][1] : VITE_GLOB_PROXY | |
| 9 | - threeFilePath = getViteGlobProxy | |
| 10 | -} catch { | |
| 11 | - // 生产环境是字符串,json parse 报错,直接等于字符串即可 | |
| 12 | - threeFilePath = getViteGlobProxy | |
| 13 | -} | |
| 7 | +const VITE_GLOB_API_URL_PREFIX = import.meta.env.VITE_GLOB_API_URL_PREFIX | |
| 14 | 8 | |
| 15 | -export const BASE_URL = `${threeFilePath}${VITE_GLOB_API_URL_PREFIX}` | |
| 9 | +export const BASE_URL = `${threeFilePath}${VITE_GLOB_API_URL}${VITE_GLOB_API_URL_PREFIX}` | ... | ... |
| ... | ... | @@ -115,16 +115,10 @@ watch( |
| 115 | 115 | page: 1, |
| 116 | 116 | pageSize: 999999 |
| 117 | 117 | }) |
| 118 | - let threeFilePath = '' | |
| 119 | - const VITE_GLOB_PROXY: [string, string][] | string = import.meta.env.VITE_GLOB_PROXY | |
| 118 | + const { host, protocol } = location | |
| 119 | + let threeFilePath = `${protocol}//${host}` | |
| 120 | + const VITE_GLOB_API_URL = import.meta.env.VITE_GLOB_API_URL | |
| 120 | 121 | const VITE_GLOB_API_URL_PREFIX = import.meta.env.VITE_GLOB_API_URL_PREFIX |
| 121 | - try { | |
| 122 | - const getViteGlobProxy = isArray(JSON.parse(VITE_GLOB_PROXY as unknown as string)) ? JSON.parse(VITE_GLOB_PROXY as unknown as string)[0][1] : VITE_GLOB_PROXY | |
| 123 | - threeFilePath = getViteGlobProxy | |
| 124 | - } catch { | |
| 125 | - // 生产环境是字符串,json parse 报错,直接等于字符串即可 | |
| 126 | - threeFilePath = VITE_GLOB_PROXY as unknown as string | |
| 127 | - } | |
| 128 | 122 | threeJsModels.value = items |
| 129 | 123 | ?.filter(filterItem => filterItem.state === 1) |
| 130 | 124 | ?.map((modelItem: ChartType) => { |
| ... | ... | @@ -141,7 +135,7 @@ watch( |
| 141 | 135 | redirectComponent: 'Decorates/Three/Loader', |
| 142 | 136 | isThreeModel: true, |
| 143 | 137 | threeModelContent: modelItem.content, |
| 144 | - threeModelFilePath: `${threeFilePath}${VITE_GLOB_API_URL_PREFIX}/3d_component/json/${modelItem.id}/scene.json` | |
| 138 | + threeModelFilePath: `${threeFilePath}${VITE_GLOB_API_URL}${VITE_GLOB_API_URL_PREFIX}/3d_component/json/${modelItem.id}/scene.json` | |
| 145 | 139 | } |
| 146 | 140 | }) |
| 147 | 141 | } | ... | ... |