新增ip访问
This commit is contained in:
parent
70403cc450
commit
f35b03a41a
2
.env
2
.env
@ -1,4 +1,2 @@
|
|||||||
# 默认环境(开发环境)
|
# 默认环境(开发环境)
|
||||||
VITE_NODE_ENV=development
|
VITE_NODE_ENV=development
|
||||||
VITE_API_BASE_URL=https://dev-api.likeichat.com
|
|
||||||
VITE_APP_TITLE=Likei H5 (Development)
|
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
# 开发环境
|
# 开发环境
|
||||||
VITE_NODE_ENV=development
|
VITE_NODE_ENV=development
|
||||||
VITE_API_BASE_URL=https://dev-api.likeichat.com
|
VITE_API_BASE_URL=https://api.likeichat.com
|
||||||
VITE_APP_TITLE=Likei H5 (Development)
|
VITE_APP_TITLE=Likei H5 (Development)
|
||||||
|
|||||||
@ -7,9 +7,9 @@
|
|||||||
"node": "^20.19.0 || >=22.12.0"
|
"node": "^20.19.0 || >=22.12.0"
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "vite --mode development",
|
"dev": "vite --mode development --host",
|
||||||
"dev:test": "vite --mode test",
|
"dev:test": "vite --mode test --host",
|
||||||
"dev:prod": "vite --mode production",
|
"dev:prod": "vite --mode production --host",
|
||||||
"build": "vite build --mode production",
|
"build": "vite build --mode production",
|
||||||
"build:dev": "vite build --mode development",
|
"build:dev": "vite build --mode development",
|
||||||
"build:test": "vite build --mode test",
|
"build:test": "vite build --mode test",
|
||||||
|
|||||||
@ -55,7 +55,7 @@ export function connectApplication(renderFun) {
|
|||||||
// 开发环境可以提供模拟数据
|
// 开发环境可以提供模拟数据
|
||||||
if (process.env.NODE_ENV === 'development') {
|
if (process.env.NODE_ENV === 'development') {
|
||||||
const mockAccess = JSON.stringify({
|
const mockAccess = JSON.stringify({
|
||||||
'Authorization': 'Bearer F77126B08E13987C3AD88B6015C5B777.djIlM0ExOTU0MDU5NzkzOTYzMzkzMDI1JTNBTElLRUklM0ExNzU3NzYzODU5NzE1JTNBMTc1NTE3MTg1OTcxNQ==',
|
'Authorization': 'Bearer 55C3DED3F67A0B6CE45E8FDBDF59BFAE.djIlM0ExOTU0MDU5NzkzOTYzMzkzMDI1JTNBTElLRUklM0ExNzU3ODM1MTY1MzQwJTNBMTc1NTI0MzE2NTM0MA==',
|
||||||
'Req-Lang': 'en',
|
'Req-Lang': 'en',
|
||||||
'Req-App-Intel': 'build=1.0;version=2.1;channel=official;Req-Imei=mock-imei',
|
'Req-App-Intel': 'build=1.0;version=2.1;channel=official;Req-Imei=mock-imei',
|
||||||
'Req-Sys-Origin': 'origin=LIKEI;originChild=LIKEI'
|
'Req-Sys-Origin': 'origin=LIKEI;originChild=LIKEI'
|
||||||
|
|||||||
@ -13,7 +13,7 @@ if (DEBUG_MODE) {
|
|||||||
|
|
||||||
// 默认公共请求头配置
|
// 默认公共请求头配置
|
||||||
let COMMON_HEADERS = {
|
let COMMON_HEADERS = {
|
||||||
'authorization': 'Bearer F77126B08E13987C3AD88B6015C5B777.djIlM0ExOTU0MDU5NzkzOTYzMzkzMDI1JTNBTElLRUklM0ExNzU3NzYzODU5NzE1JTNBMTc1NTE3MTg1OTcxNQ==',
|
'authorization': 'Bearer 55C3DED3F67A0B6CE45E8FDBDF59BFAE.djIlM0ExOTU0MDU5NzkzOTYzMzkzMDI1JTNBTElLRUklM0ExNzU3ODM1MTY1MzQwJTNBMTc1NTI0MzE2NTM0MA==',
|
||||||
'req-app-intel': 'version=1.0.0;build=1;model=SM-G9550;sysVersion=9;channel=Google',
|
'req-app-intel': 'version=1.0.0;build=1;model=SM-G9550;sysVersion=9;channel=Google',
|
||||||
'req-client': 'Android',
|
'req-client': 'Android',
|
||||||
'req-imei': '8fa54d728ab449e04f9292329ed44bda',
|
'req-imei': '8fa54d728ab449e04f9292329ed44bda',
|
||||||
@ -41,34 +41,34 @@ export function updateCommonHeaders(headers) {
|
|||||||
*/
|
*/
|
||||||
export function setHeadersFromApp(headerInfo) {
|
export function setHeadersFromApp(headerInfo) {
|
||||||
const updatedHeaders = {}
|
const updatedHeaders = {}
|
||||||
|
|
||||||
// 设置Authorization
|
// 设置Authorization
|
||||||
if (headerInfo.authorization) {
|
if (headerInfo.authorization) {
|
||||||
updatedHeaders.authorization = headerInfo.authorization
|
updatedHeaders.authorization = headerInfo.authorization
|
||||||
}
|
}
|
||||||
|
|
||||||
// 设置语言
|
// 设置语言
|
||||||
if (headerInfo.reqLang) {
|
if (headerInfo.reqLang) {
|
||||||
updatedHeaders['req-lang'] = headerInfo.reqLang
|
updatedHeaders['req-lang'] = headerInfo.reqLang
|
||||||
}
|
}
|
||||||
|
|
||||||
// 设置APP信息
|
// 设置APP信息
|
||||||
if (headerInfo.appVersion || headerInfo.buildVersion || headerInfo.appChannel) {
|
if (headerInfo.appVersion || headerInfo.buildVersion || headerInfo.appChannel) {
|
||||||
const appIntelParts = []
|
const appIntelParts = []
|
||||||
if (headerInfo.appVersion) appIntelParts.push(`version=${headerInfo.appVersion}`)
|
if (headerInfo.appVersion) appIntelParts.push(`version=${headerInfo.appVersion}`)
|
||||||
if (headerInfo.buildVersion) appIntelParts.push(`build=${headerInfo.buildVersion}`)
|
if (headerInfo.buildVersion) appIntelParts.push(`build=${headerInfo.buildVersion}`)
|
||||||
if (headerInfo.appChannel) appIntelParts.push(`channel=${headerInfo.appChannel}`)
|
if (headerInfo.appChannel) appIntelParts.push(`channel=${headerInfo.appChannel}`)
|
||||||
|
|
||||||
if (appIntelParts.length > 0) {
|
if (appIntelParts.length > 0) {
|
||||||
updatedHeaders['req-app-intel'] = appIntelParts.join(';')
|
updatedHeaders['req-app-intel'] = appIntelParts.join(';')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 设置设备信息
|
// 设置设备信息
|
||||||
if (headerInfo.reqImei) {
|
if (headerInfo.reqImei) {
|
||||||
updatedHeaders['req-imei'] = headerInfo.reqImei
|
updatedHeaders['req-imei'] = headerInfo.reqImei
|
||||||
}
|
}
|
||||||
|
|
||||||
// 设置系统来源
|
// 设置系统来源
|
||||||
if (headerInfo.sysOrigin) {
|
if (headerInfo.sysOrigin) {
|
||||||
const sysOriginParts = [`origin=${headerInfo.sysOrigin}`]
|
const sysOriginParts = [`origin=${headerInfo.sysOrigin}`]
|
||||||
@ -77,7 +77,7 @@ export function setHeadersFromApp(headerInfo) {
|
|||||||
}
|
}
|
||||||
updatedHeaders['req-sys-origin'] = sysOriginParts.join(';')
|
updatedHeaders['req-sys-origin'] = sysOriginParts.join(';')
|
||||||
}
|
}
|
||||||
|
|
||||||
updateCommonHeaders(updatedHeaders)
|
updateCommonHeaders(updatedHeaders)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -15,4 +15,25 @@ export default defineConfig({
|
|||||||
'@': fileURLToPath(new URL('./src', import.meta.url))
|
'@': fileURLToPath(new URL('./src', import.meta.url))
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
server: {
|
||||||
|
host: '0.0.0.0', // 允许外部访问
|
||||||
|
port: 5173, // 指定端口
|
||||||
|
strictPort: true, // 端口被占用时不会自动选择下一个可用端口
|
||||||
|
open: false, // 不自动打开浏览器
|
||||||
|
cors: true, // 启用CORS
|
||||||
|
// 代理配置(如果需要)
|
||||||
|
proxy: {
|
||||||
|
// '/api': {
|
||||||
|
// target: 'http://localhost:3000',
|
||||||
|
// changeOrigin: true,
|
||||||
|
// rewrite: (path) => path.replace(/^\/api/, '')
|
||||||
|
// }
|
||||||
|
}
|
||||||
|
},
|
||||||
|
preview: {
|
||||||
|
host: '0.0.0.0', // 预览模式也允许外部访问
|
||||||
|
port: 4173,
|
||||||
|
strictPort: true,
|
||||||
|
open: false
|
||||||
|
}
|
||||||
})
|
})
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user