重新编译配置
This commit is contained in:
parent
9659660b1e
commit
0bf93aabb3
|
|
@ -1,10 +1,10 @@
|
|||
# 前端IP地址配置更新说明
|
||||
|
||||
## 更新时间
|
||||
2025年12月5日
|
||||
2025年12月6日
|
||||
|
||||
## 更新内容
|
||||
将所有前端配置文件中的服务器IP地址从 `192.168.0.106` 更新为 `192.168.137.1`
|
||||
将所有前端配置文件中的服务器IP地址从 `192.168.137.1` 更新为 `192.168.1.8`
|
||||
|
||||
---
|
||||
|
||||
|
|
@ -23,12 +23,12 @@
|
|||
|
||||
### 2. 配置文件
|
||||
- ✅ `fronted_uniapp/fronted_uniapp/config.js`
|
||||
- 更新 `baseURL`: `http://192.168.137.1:30091/api`
|
||||
- 更新 `wsHost`: `192.168.137.1`
|
||||
- 更新 `baseURL`: `http://192.168.1.8:30091/api`
|
||||
- 更新 `wsHost`: `192.168.1.8`
|
||||
|
||||
- ✅ `fronted_uniapp/fronted_uniapp/src/config.js`
|
||||
- 更新 `baseURL`: `http://192.168.137.1:30091`
|
||||
- 更新 `wsHost`: `192.168.137.1`
|
||||
- 更新 `baseURL`: `http://192.168.1.8:30091`
|
||||
- 更新 `wsHost`: `192.168.1.8`
|
||||
|
||||
- ✅ `fronted_uniapp/fronted_uniapp/src/utils/config.js`
|
||||
- 已在前面更新(APP配置文件)
|
||||
|
|
@ -38,8 +38,8 @@
|
|||
- 已在前面更新(APP配置文件)
|
||||
|
||||
- ✅ `fronted_uniapp/yuyin/utils/config.js`
|
||||
- 更新 `DEFAULT_SERVER_HOST`: `192.168.137.1`
|
||||
- 更新 `DEV_SERVER_HOST`: `192.168.137.1`
|
||||
- 更新 `DEFAULT_SERVER_HOST`: `192.168.1.8`
|
||||
- 更新 `DEV_SERVER_HOST`: `192.168.1.8`
|
||||
- 更新 `DEFAULT_SERVER_PORT`: `30091`
|
||||
- 更新H5环境hostname判断逻辑
|
||||
|
||||
|
|
@ -47,24 +47,24 @@
|
|||
- ✅ `fronted_uniapp/fronted_uniapp/src/utils/request.js`
|
||||
- 更新H5环境hostname判断
|
||||
- 更新localhost检测逻辑
|
||||
- 更新默认返回地址: `http://192.168.137.1:30091`
|
||||
- 更新默认返回地址: `http://192.168.1.8:30091`
|
||||
|
||||
- ✅ `fronted_uniapp/utils/request.js`
|
||||
- 更新默认返回地址: `http://192.168.137.1:30091`
|
||||
- 更新默认返回地址: `http://192.168.1.8:30091`
|
||||
|
||||
- ✅ `fronted_uniapp/yuyin/utils/request.js`
|
||||
- 更新H5环境hostname判断
|
||||
- 更新localhost检测逻辑
|
||||
- 更新默认返回地址: `http://192.168.137.1:30091`
|
||||
- 更新默认返回地址: `http://192.168.1.8:30091`
|
||||
|
||||
### 4. 应用入口文件
|
||||
- ✅ `fronted_uniapp/fronted_uniapp/src/App.vue`
|
||||
- 更新 `APP_DEV_HOST`: `192.168.137.1`
|
||||
- 更新 `LOCAL_HOST`: `192.168.137.1`
|
||||
- 更新 `APP_DEV_HOST`: `192.168.1.8`
|
||||
- 更新 `LOCAL_HOST`: `192.168.1.8`
|
||||
|
||||
### 5. 其他工具文件
|
||||
- ✅ `fronted_uniapp/fronted_uniapp/src/utils/screenStream.js`
|
||||
- 更新默认服务器地址: `192.168.137.1`
|
||||
- 更新默认服务器地址: `192.168.1.8`
|
||||
|
||||
---
|
||||
|
||||
|
|
@ -72,11 +72,11 @@
|
|||
|
||||
### H5开发环境
|
||||
当你运行 `npm run dev:h5` 时:
|
||||
- 前端运行在: `http://localhost:20002` 或 `http://192.168.137.1:20002`
|
||||
- Vite会将所有 `/api`、`/login`、`/register`、`/ws` 请求代理到 `http://192.168.137.1:30091`
|
||||
- 前端运行在: `http://localhost:20002` 或 `http://192.168.1.8:20002`
|
||||
- Vite会将所有 `/api`、`/login`、`/register`、`/ws` 请求代理到 `http://192.168.1.8:30091`
|
||||
|
||||
### APP环境
|
||||
- APP默认连接到: `http://192.168.137.1:30091`
|
||||
- APP默认连接到: `http://192.168.1.8:30091`
|
||||
- 支持通过本地存储动态配置服务器地址
|
||||
- 配置方法: `uni.setStorageSync('server_host', '新的IP地址')`
|
||||
|
||||
|
|
@ -91,25 +91,25 @@ cd fronted_uniapp/fronted_uniapp
|
|||
npm run dev:h5
|
||||
|
||||
# 打开浏览器控制台,查看网络请求
|
||||
# 应该看到请求发送到: http://192.168.137.1:30091
|
||||
# 应该看到请求发送到: http://192.168.1.8:30091
|
||||
```
|
||||
|
||||
### 2. 验证APP环境
|
||||
```bash
|
||||
# 在APP中打开控制台
|
||||
# 查看打印的服务器地址
|
||||
# 应该显示: 当前服务器地址:192.168.137.1:30091
|
||||
# 应该显示: 当前服务器地址:192.168.1.8:30091
|
||||
```
|
||||
|
||||
### 3. 快速测试
|
||||
在浏览器访问: `http://192.168.137.1:30091`
|
||||
在浏览器访问: `http://192.168.1.8:30091`
|
||||
应该能看到后端服务的登录页面。
|
||||
|
||||
---
|
||||
|
||||
## 注意事项
|
||||
|
||||
1. **本地开发**: 确保后端服务运行在 `192.168.137.1:30091`
|
||||
1. **本地开发**: 确保后端服务运行在 `192.168.1.8:30091`
|
||||
2. **防火墙**: 确保Windows防火墙已开放30091端口
|
||||
3. **网络环境**: 手机和电脑必须在同一WiFi网络
|
||||
4. **IP变化**: 如果电脑IP地址变化,需要重新修改这些配置文件
|
||||
|
|
@ -137,7 +137,7 @@ npm run dev:h5
|
|||
1. 手机和电脑是否在同一WiFi
|
||||
2. 防火墙是否开放30091端口
|
||||
3. APP配置的IP地址是否正确
|
||||
4. 在手机浏览器访问 `http://192.168.137.1:30091` 测试
|
||||
4. 在手机浏览器访问 `http://192.168.1.8:30091` 测试
|
||||
|
||||
### 问题3: WebSocket连接失败
|
||||
**检查**:
|
||||
|
|
@ -147,4 +147,4 @@ npm run dev:h5
|
|||
|
||||
---
|
||||
|
||||
**配置完成!现在你的前端项目已配置为使用 192.168.137.1:30091 作为后端服务器地址。**
|
||||
**配置完成!现在你的前端项目已配置为使用 192.168.1.8:30091 作为后端服务器地址。**
|
||||
|
|
|
|||
|
|
@ -3,10 +3,10 @@
|
|||
*/
|
||||
export default {
|
||||
// 后端API服务器地址
|
||||
baseURL: 'http://192.168.137.1:30091/api',
|
||||
baseURL: 'http://192.168.1.8:30091/api',
|
||||
|
||||
// WebSocket服务器地址(用于监控)
|
||||
wsHost: '192.168.137.1',
|
||||
wsHost: '192.168.1.8',
|
||||
wsPort: 30091,
|
||||
|
||||
// 其他配置
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
<script>
|
||||
import config from '@/utils/config.js'
|
||||
|
||||
const APP_DEV_HOST = '192.168.137.1'
|
||||
const APP_DEV_HOST = '192.168.1.8'
|
||||
const APP_DEV_PORT = 30091
|
||||
|
||||
export default {
|
||||
|
|
@ -14,7 +14,7 @@
|
|||
// #ifdef APP-PLUS
|
||||
const { serverHost, serverPort } = config.getServerConfig()
|
||||
// 本地开发环境:强制使用本地服务器地址
|
||||
const LOCAL_HOST = '192.168.137.1'
|
||||
const LOCAL_HOST = '192.168.1.8'
|
||||
const LOCAL_PORT = 30091
|
||||
|
||||
if (serverHost !== LOCAL_HOST || serverPort !== LOCAL_PORT) {
|
||||
|
|
|
|||
|
|
@ -3,10 +3,10 @@
|
|||
*/
|
||||
export default {
|
||||
// 后端API服务器地址
|
||||
baseURL: 'http://192.168.137.1:30091',
|
||||
baseURL: 'http://192.168.1.8:30091',
|
||||
|
||||
// WebSocket服务器地址(用于监控)
|
||||
wsHost: '192.168.137.1',
|
||||
wsHost: '192.168.1.8',
|
||||
wsPort: 30091,
|
||||
|
||||
// 其他配置
|
||||
|
|
|
|||
|
|
@ -1,6 +1,12 @@
|
|||
{
|
||||
"minSdkVersion": "21",
|
||||
"dependencies": [
|
||||
"com.alphacephei:vosk-android:0.3.47"
|
||||
"net.java.dev.jna:jna:5.12.1"
|
||||
],
|
||||
"repositories": [
|
||||
"https://maven.aliyun.com/repository/public",
|
||||
"https://maven.aliyun.com/repository/google",
|
||||
"https://repo1.maven.org/maven2/",
|
||||
"https://jcenter.bintray.com/"
|
||||
]
|
||||
}
|
||||
|
|
@ -1,4 +1,6 @@
|
|||
|
||||
// VERSION: 1.0.13 - Fixed Kotlin reserved word conflict (error -> errorMsg)
|
||||
// Plugin ID changed to force recompilation: xwq-speech-to-text-fixed
|
||||
// Last updated: 2025-12-05 18:05
|
||||
import Context from "android.content.Context"
|
||||
import File from "java.io.File"
|
||||
import FileOutputStream from "java.io.FileOutputStream"
|
||||
|
|
@ -45,8 +47,9 @@ class MyRecognitionListener implements RecognitionListener {
|
|||
}
|
||||
|
||||
override onResult(hypothesis : string) : void {
|
||||
// console.log('hypothesis==', hypothesis)
|
||||
console.log('[Vosk] onResult:', hypothesis)
|
||||
const result = (JSON.parse(hypothesis) as UTSJSONObject).text ?? '';
|
||||
if (result != null && (result as string).length > 0) {
|
||||
this.onSpeekResultCallback?.({
|
||||
code: 0,
|
||||
data: {
|
||||
|
|
@ -54,21 +57,58 @@ class MyRecognitionListener implements RecognitionListener {
|
|||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
override onPartialResult(hypothesis : string) : void {
|
||||
// console.log("临时结果: " + hypothesis);
|
||||
console.log('[Vosk] onPartialResult:', hypothesis)
|
||||
// 实时识别结果,持续触发
|
||||
const result = (JSON.parse(hypothesis) as UTSJSONObject).partial ?? '';
|
||||
if (result != null && (result as string).length > 0) {
|
||||
this.onSpeekResultCallback?.({
|
||||
code: 0,
|
||||
data: {
|
||||
text: (result as string).replace(/\s/g, '')
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
override onFinalResult(hypothesis : string) : void {
|
||||
// console.log("最终确认结果: " + hypothesis);
|
||||
console.log('[Vosk] onFinalResult:', hypothesis)
|
||||
const result = (JSON.parse(hypothesis) as UTSJSONObject).text ?? '';
|
||||
if (result != null && (result as string).length > 0) {
|
||||
this.onSpeekResultCallback?.({
|
||||
code: 0,
|
||||
data: {
|
||||
text: (result as string).replace(/\s/g, '')
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
override onError(e : Exception) : void {
|
||||
throw IOException(`识别错误: ${e.message}`, e);
|
||||
// 不抛出异常,避免APP闪退,通过回调通知错误
|
||||
// 修复Kotlin保留字冲突 - Updated: 2025-12-05 16:05
|
||||
console.error('[Vosk] 识别错误:', e.message)
|
||||
this.onSpeekResultCallback?.({
|
||||
code: -1,
|
||||
data: {
|
||||
text: '',
|
||||
errorMsg: '识别错误: ' + (e.message ?? '未知错误')
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
override onTimeout() : void {
|
||||
throw IOException("识别超时")
|
||||
// 不抛出异常,避免APP闪退,通过回调通知超时
|
||||
console.error('[Vosk] 识别超时')
|
||||
this.onSpeekResultCallback?.({
|
||||
code: -1,
|
||||
data: {
|
||||
text: '',
|
||||
errorMsg: '识别超时'
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -87,22 +127,14 @@ class ZipExtractor {
|
|||
// 确保输出目录为空
|
||||
if (outputDir.exists()) {
|
||||
let files = outputDir.list()
|
||||
// console.log('outputDir.isDirectory====', outputDir.isDirectory)
|
||||
// console.log('files is null====', files != null)
|
||||
// console.log('isNotEmpty====', files.isNotEmpty())
|
||||
if (outputDir.isDirectory && files != null && files.isNotEmpty()) {
|
||||
// 删除目录及其内容
|
||||
outputDir.deleteRecursively()
|
||||
} else {
|
||||
// // console.log('是否为目录===',outputDir.isDirectory)
|
||||
// 如果输出路径存在但不是目录,抛出异常
|
||||
// throw IOException("输出路径存在且不是目录: " + outputDir.getAbsolutePath())
|
||||
}
|
||||
} else if (!outputDir.mkdirs()) {
|
||||
throw IOException("Directory creation failed: " + outputDir.getAbsolutePath())
|
||||
}
|
||||
|
||||
// console.log('pass----')
|
||||
this.zis = new ZipInputStream(new FileInputStream(modelZipFile));
|
||||
let entry = this.zis!.getNextEntry();
|
||||
while (entry != null) {
|
||||
|
|
@ -113,8 +145,6 @@ class ZipExtractor {
|
|||
if (!outputFile.exists() && !outputFile.mkdirs()) {
|
||||
throw new IOException("Directory creation failed: " + outputFile.getAbsolutePath());
|
||||
}
|
||||
|
||||
// // console.log('创建的目录地址---',outputFile)
|
||||
}
|
||||
//处理文件
|
||||
else {
|
||||
|
|
@ -137,7 +167,6 @@ class ZipExtractor {
|
|||
|
||||
try {
|
||||
if (!outputFile.isDirectory) {
|
||||
// // console.log('只有非目录时写入')
|
||||
this.fos = new FileOutputStream(outputFile)
|
||||
|
||||
let lens : Int = 1024;
|
||||
|
|
@ -145,9 +174,9 @@ class ZipExtractor {
|
|||
let len : Int = this.zis!.read(buffer);
|
||||
while (len > 0) {
|
||||
this.fos!.write(buffer, 0, len);
|
||||
len = this.zis!.read(buffer) // 更新 len
|
||||
len = this.zis!.read(buffer)
|
||||
}
|
||||
this.fos!.fd.sync() // 强制同步到磁盘
|
||||
this.fos!.fd.sync()
|
||||
}
|
||||
|
||||
} catch (e : Error) {
|
||||
|
|
@ -155,7 +184,7 @@ class ZipExtractor {
|
|||
}
|
||||
finally {
|
||||
if (this.fos != null) {
|
||||
this.fos!.close(); // 手动关闭
|
||||
this.fos!.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -170,11 +199,11 @@ class ZipExtractor {
|
|||
|
||||
|
||||
} catch (e : Error) {
|
||||
// // console.log('e====',e)
|
||||
throw IOException(`解压失败: ${e.message}`, e);
|
||||
console.error('[Vosk] 解压失败:', e.message)
|
||||
// 不抛出异常,避免闪退
|
||||
} finally {
|
||||
if (this.zis != null) {
|
||||
this.zis!.close(); // 手动关闭
|
||||
this.zis!.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -205,13 +234,6 @@ class ZipExtractor {
|
|||
const userFilePath = UTSAndroid.convert2AbsFullPath(uni.env.USER_DATA_PATH);
|
||||
let cpFilePath = userFilePath + suorceSplit[suorceSplit.length - 1];
|
||||
|
||||
// //判断是否存在目录
|
||||
// let file : File = new File(cpFilePath);
|
||||
// if (!file.getParentFile().exists()) {
|
||||
// file.getParentFile().mkdirs(); // 创建父目录
|
||||
// // console.log('没有父级目录')
|
||||
// }
|
||||
|
||||
const fileManager = uni.getFileSystemManager();
|
||||
//项目目录地址才复制,网络下载直接就是应用缓存地址
|
||||
if (option.zipModelPath.startsWith('/static')) {
|
||||
|
|
@ -242,8 +264,6 @@ class ZipExtractor {
|
|||
// #endif
|
||||
|
||||
// #ifdef APP-PLUS
|
||||
// const externalDir = UTSAndroid.getAppContext()!.getExternalFilesDir(null)
|
||||
// const ExternalPath:string=externalDir!.getAbsolutePath()?? ""
|
||||
const status = Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED)
|
||||
|
||||
if (!status) {
|
||||
|
|
@ -252,11 +272,8 @@ class ZipExtractor {
|
|||
|
||||
const ExternalPath = this.getExternalPath();
|
||||
|
||||
// let outputDirName = option.zipModelPath.split('/').pop()?.replace('.zip', '');
|
||||
// console.log('模型名称===', zipName)
|
||||
const modelZipTemp : File = new File(option.zipModelPath);
|
||||
const outputDirTemp : File = new File(`${ExternalPath}/${zipName}`);
|
||||
// console.log('modelZipTemp--path', modelZipTemp.getAbsolutePath())
|
||||
const outputDirTemp : File = new File(`${ExternalPath}`);
|
||||
this.extractModel(modelZipTemp, outputDirTemp, () => {
|
||||
const uuidFile : File = new File(outputDirTemp, `/${zipName}/uuid`);
|
||||
uuidFile.createNewFile();
|
||||
|
|
@ -286,13 +303,25 @@ class ZipExtractor {
|
|||
//开始识别
|
||||
startSpeechVoice(cb : SpeechResultCallback) {
|
||||
UTSAndroid.getDispatcher("io").async(function (_) {
|
||||
try {
|
||||
// 检查模型路径
|
||||
if (this.unzipPath == null || this.unzipPath == '') {
|
||||
console.error('[Vosk] 模型路径无效')
|
||||
cb({
|
||||
code: -1,
|
||||
data: {
|
||||
text: '',
|
||||
errorMsg: '模型未初始化,请重新加载'
|
||||
}
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
let model = new Model(this.unzipPath) // 加载模型
|
||||
this.recognizer = new Recognizer(model, sampleRate) // 采样率16kHz
|
||||
|
||||
//实时语音识别
|
||||
if (this.voskType === '1') {
|
||||
// this.recognizer!.setMaxAlternatives(5) // 设置最大候选结果数
|
||||
// this.recognizer!.setWords(true) // 启用词语级时间戳
|
||||
this.speechService = new SpeechService(this.recognizer!, sampleRate);
|
||||
const recognitionListenerClass:MyRecognitionListener=new MyRecognitionListener(UTSAndroid.getUniActivity()!);
|
||||
recognitionListenerClass.setSpeekResultCallback(cb);
|
||||
|
|
@ -307,17 +336,28 @@ class ZipExtractor {
|
|||
// console.log(this.recognizer!.result)
|
||||
}
|
||||
}
|
||||
|
||||
// 获取最终结果
|
||||
// console.log(this.recognizer)
|
||||
}
|
||||
} catch (e : Exception) {
|
||||
console.error('[Vosk] 语音识别启动失败:', e.message)
|
||||
cb({
|
||||
code: -1,
|
||||
data: {
|
||||
text: '',
|
||||
errorMsg: '语音识别启动失败: ' + (e.message ?? '未知错误')
|
||||
}
|
||||
})
|
||||
}
|
||||
}, null)
|
||||
}
|
||||
//停止识别
|
||||
stopSpeechVoice() {
|
||||
// this.recognizer!.close();
|
||||
try {
|
||||
this.speechService?.stop()
|
||||
this.speechService?.reset() // 重置识别器以备下次使用
|
||||
this.speechService?.reset()
|
||||
} catch (e : Exception) {
|
||||
console.error('[Vosk] 停止识别时出错:', e.message)
|
||||
// 不抛出异常,避免闪退
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -389,7 +429,6 @@ export function downloadModel(url : string, cb : DownloadCallback) {
|
|||
}
|
||||
});
|
||||
|
||||
//监听下载进度
|
||||
loadTask?.onProgressUpdate((update : OnProgressDownloadResult) => {
|
||||
console.log("模型下载进度: ", update.progress + '%');
|
||||
})
|
||||
|
|
@ -428,7 +467,6 @@ export function downloadModel(url : string, cb : DownloadCallback) {
|
|||
}
|
||||
});
|
||||
|
||||
//监听下载进度
|
||||
loadTask?.onProgressUpdate((update : OnProgressDownloadResult) => {
|
||||
console.log("模型下载进度: ", update.progress + '%');
|
||||
})
|
||||
|
|
|
|||
|
|
@ -14,9 +14,9 @@ import '../polyfills/url.js'
|
|||
*/
|
||||
|
||||
// 默认服务器配置(仅在未配置本地存储时使用)
|
||||
const DEFAULT_SERVER_HOST = '192.168.137.1' // 本地开发服务器地址
|
||||
const DEFAULT_SERVER_HOST = '192.168.1.8' // 本地开发服务器地址
|
||||
const DEFAULT_SERVER_PORT = 30091 // 默认后端服务端口(与后端配置一致)
|
||||
const DEV_SERVER_HOST = '192.168.137.1' // H5/APP默认地址
|
||||
const DEV_SERVER_HOST = '192.168.1.8' // H5/APP默认地址
|
||||
const DEV_SERVER_PORT = 30091
|
||||
const IS_DEV = false // 强制使用生产环境
|
||||
const isH5 = typeof window !== 'undefined' && typeof document !== 'undefined'
|
||||
|
|
@ -90,7 +90,7 @@ let API_BASE_URL = `http://${serverHost}:${serverPort}`
|
|||
// H5环境:如果访问的是localhost/192.168.137.1,使用当前主机
|
||||
if (typeof window !== 'undefined' && window.location) {
|
||||
const hostname = window.location.hostname
|
||||
if (hostname === 'localhost' || hostname === '192.168.137.1') {
|
||||
if (hostname === 'localhost' || hostname === '192.168.1.8') {
|
||||
API_BASE_URL = `http://${hostname}:${serverPort}`
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -51,7 +51,7 @@ class Request {
|
|||
// H5环境:如果访问的是localhost,使用Vite代理
|
||||
if (typeof window !== 'undefined' && window.location) {
|
||||
const hostname = window.location.hostname
|
||||
if (hostname === 'localhost' || hostname === '192.168.137.1') {
|
||||
if (hostname === 'localhost' || hostname === '192.168.1.8') {
|
||||
// H5环境:使用后端服务器地址,不通过Vite代理
|
||||
// 因为Vite代理只配置了/api和/ws,其他路径需要直接访问后端
|
||||
return baseURL
|
||||
|
|
@ -64,7 +64,7 @@ class Request {
|
|||
if (serverHost === 'localhost' || serverHost === '127.0.0.1') {
|
||||
console.error('❌ App环境无法使用localhost,请配置电脑的局域网IP地址!')
|
||||
console.error('❌ 配置方法:uni.setStorageSync("server_host", "你的电脑IP")')
|
||||
console.error('❌ 例如:uni.setStorageSync("server_host", "192.168.137.1")')
|
||||
console.error('❌ 例如:uni.setStorageSync("server_host", "192.168.1.8")')
|
||||
}
|
||||
// #endif
|
||||
|
||||
|
|
@ -72,7 +72,7 @@ class Request {
|
|||
} catch (error) {
|
||||
console.error('获取baseURL失败:', error)
|
||||
// 返回默认值(本地开发服务器)
|
||||
return 'http://192.168.137.1:30091'
|
||||
return 'http://192.168.1.8:30091'
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -97,7 +97,7 @@ class ScreenStreamClient {
|
|||
|
||||
// 如果仍然没有配置,使用默认值
|
||||
if (!serverHost) {
|
||||
serverHost = '192.168.137.1' // 默认服务器地址
|
||||
serverHost = '192.168.1.8' // 默认服务器地址
|
||||
console.warn('⚠️ 未配置服务器地址,使用默认值:', serverHost)
|
||||
}
|
||||
if (!serverPort) {
|
||||
|
|
|
|||
|
|
@ -25,24 +25,24 @@ export default defineConfig({
|
|||
strictPort: false,
|
||||
proxy: {
|
||||
'/api': {
|
||||
target: 'http://192.168.137.1:30091',
|
||||
target: 'http://192.168.1.8:30091',
|
||||
changeOrigin: true,
|
||||
secure: false
|
||||
},
|
||||
// 代理登录等接口
|
||||
'/login': {
|
||||
target: 'http://192.168.137.1:30091',
|
||||
target: 'http://192.168.1.8:30091',
|
||||
changeOrigin: true,
|
||||
secure: false
|
||||
},
|
||||
'/register': {
|
||||
target: 'http://192.168.137.1:30091',
|
||||
target: 'http://192.168.1.8:30091',
|
||||
changeOrigin: true,
|
||||
secure: false
|
||||
},
|
||||
// 代理 WebSocket 连接
|
||||
'/ws': {
|
||||
target: 'http://192.168.137.1:30091',
|
||||
target: 'http://192.168.1.8:30091',
|
||||
ws: true,
|
||||
changeOrigin: true,
|
||||
secure: false
|
||||
|
|
|
|||
|
|
@ -39,9 +39,9 @@ const IS_DEV = resolveIsDev()
|
|||
// - 开发测试:使用局域网IP(如 192.168.1.164)
|
||||
// - 正式部署:必须改成服务器的公网IP或域名!
|
||||
//
|
||||
const DEFAULT_SERVER_HOST = '192.168.137.1' // ⚠️ 正式部署时改成公网IP或域名!
|
||||
const DEFAULT_SERVER_HOST = '192.168.1.8' // ⚠️ 正式部署时改成公网IP或域名!
|
||||
const DEFAULT_SERVER_PORT = 30091 // 后端端口
|
||||
const DEV_SERVER_HOST = '192.168.137.1' // 开发服务器地址(局域网IP)
|
||||
const DEV_SERVER_HOST = '192.168.1.8' // 开发服务器地址(局域网IP)
|
||||
const DEV_SERVER_PORT = 30091
|
||||
const isH5 = typeof window !== 'undefined' && typeof document !== 'undefined'
|
||||
|
||||
|
|
|
|||
|
|
@ -71,7 +71,7 @@ class Request {
|
|||
} catch (error) {
|
||||
console.error('获取baseURL失败:', error)
|
||||
// 返回默认值
|
||||
return 'http://192.168.137.1:30091'
|
||||
return 'http://192.168.1.8:30091'
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -19,13 +19,13 @@ export default defineConfig({
|
|||
strictPort: false,
|
||||
proxy: {
|
||||
'/api': {
|
||||
target: 'http://192.168.137.1:30091',
|
||||
target: 'http://192.168.1.8:30091',
|
||||
changeOrigin: true,
|
||||
secure: false
|
||||
},
|
||||
// 代理 WebSocket 连接
|
||||
'/ws': {
|
||||
target: 'http://192.168.137.1:30091',
|
||||
target: 'http://192.168.1.8:30091',
|
||||
ws: true,
|
||||
changeOrigin: true,
|
||||
secure: false
|
||||
|
|
|
|||
|
|
@ -32,9 +32,9 @@ const resolveIsDev = () => {
|
|||
|
||||
const IS_DEV = resolveIsDev()
|
||||
|
||||
const DEFAULT_SERVER_HOST = '192.168.137.1' // 服务器地址
|
||||
const DEFAULT_SERVER_HOST = '192.168.1.8' // 服务器地址
|
||||
const DEFAULT_SERVER_PORT = 30091 // 后端端口
|
||||
const DEV_SERVER_HOST = '192.168.137.1' // 开发服务器地址
|
||||
const DEV_SERVER_HOST = '192.168.1.8' // 开发服务器地址
|
||||
const DEV_SERVER_PORT = 30091
|
||||
const isH5 = typeof window !== 'undefined' && typeof document !== 'undefined'
|
||||
|
||||
|
|
@ -107,7 +107,7 @@ let API_BASE_URL = `http://${serverHost}:${serverPort}`
|
|||
// H5环境:如果访问的是localhost/192.168.137.1,跟随当前主机
|
||||
if (typeof window !== 'undefined' && window.location) {
|
||||
const hostname = window.location.hostname
|
||||
if (hostname === 'localhost' || hostname === '192.168.137.1') {
|
||||
if (hostname === 'localhost' || hostname === '192.168.1.8') {
|
||||
API_BASE_URL = `http://${hostname}:${serverPort}`
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -51,7 +51,7 @@ class Request {
|
|||
// H5环境:如果访问的是localhost,使用localhost(通过Vite代理)
|
||||
if (typeof window !== 'undefined' && window.location) {
|
||||
const hostname = window.location.hostname
|
||||
if (hostname === 'localhost' || hostname === '192.168.137.1') {
|
||||
if (hostname === 'localhost' || hostname === '192.168.1.8') {
|
||||
// H5开发环境:通过 Vite 代理 /api -> 本地后端
|
||||
return '/api'
|
||||
}
|
||||
|
|
@ -63,7 +63,7 @@ class Request {
|
|||
if (serverHost === 'localhost' || serverHost === '127.0.0.1') {
|
||||
console.error('❌ App环境无法使用localhost,请配置电脑的局域网IP地址!')
|
||||
console.error('❌ 配置方法:uni.setStorageSync("server_host", "你的电脑IP")')
|
||||
console.error('❌ 例如:uni.setStorageSync("server_host", "192.168.137.1")')
|
||||
console.error('❌ 例如:uni.setStorageSync("server_host", "192.168.1.8")')
|
||||
}
|
||||
// #endif
|
||||
|
||||
|
|
@ -71,7 +71,7 @@ class Request {
|
|||
} catch (error) {
|
||||
console.error('获取baseURL失败:', error)
|
||||
// 返回默认值
|
||||
return 'http://192.168.137.1:30091'
|
||||
return 'http://192.168.1.8:30091'
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user