Browse Source

上传ai积分管理代码

newdev_shunjiawei
liwei1dao 11 months ago
parent
commit
5f9d460004
  1. 2
      lib/data/services/ble_manager.dart
  2. 9
      lib/data/services/network/api.dart
  3. 4
      local_plugins/agent_service/android/src/main/kotlin/com/yunqiinnovation/agent_service/AgentService.kt
  4. 8
      local_plugins/agent_service/android/src/main/kotlin/com/yunqiinnovation/agent_service/BleMediaService.kt

2
lib/data/services/ble_manager.dart

@ -2,6 +2,7 @@ import 'dart:async';
import 'dart:convert';
import 'dart:io';
import 'package:firebase_auth/firebase_auth.dart';
import 'package:flutter_dotenv/flutter_dotenv.dart';
import 'package:get_storage/get_storage.dart';
import 'package:get/get.dart';
@ -775,6 +776,7 @@ class BleManager extends GetxService {
'musicServiceType': musicServiceType,
"navigationMode": navigationMode,
"isttsinterrupt": isTtsInterruptEnabled ? "true" : "false",
"aiintegral": 100, //ai积分
"callingTool": "callingTool".tr
};

9
lib/data/services/network/api.dart

@ -243,4 +243,13 @@ class Api {
params: params,
);
}
//资源使用请求
static usagesResPoints([params]) {
return DioManager().request(
NWMethod.post,
'/api/home/user_usages',
params: params,
);
}
}

4
local_plugins/agent_service/android/src/main/kotlin/com/yunqiinnovation/agent_service/AgentService.kt

@ -135,6 +135,8 @@ object AgentService : CoroutineScope {
private var currentAiJob: Job? = null
private var currsessionId: String = ""
private var aiintegral:Int = 0
// 空闲检测相关
private var idleCheckJob: Job? = null
private val maxIdleSeconds = 10 // 最大空闲秒数(默认值)
@ -203,7 +205,7 @@ object AgentService : CoroutineScope {
serverurl = config["serverurl"]?.toString() ?: "";
usertoken = config["usertoken"]?.toString() ?: "";
callingTool = config["callingTool"]?.toString() ?: "";
aiintegral = (config["aiintegral"] as? Number)?.toInt() ?: 0
// 初始化上下文和服务
this.context = appContext.applicationContext

8
local_plugins/agent_service/android/src/main/kotlin/com/yunqiinnovation/agent_service/BleMediaService.kt

@ -69,6 +69,7 @@ class BleMediaService : Service(), CoroutineScope {
private const val KEY_MUSICSERVICE_TYPE = "musicServiceType"
private const val APP_NAVIGATION_MODE = "navigationMode"
private const val APP_CALLING_TOOL = "callingTool"
private const val KEY_AI_INTAGRAL = "aiintegral"
// 用于跟踪服务是否正在运行
private val isRunning = AtomicBoolean(false)
@ -578,6 +579,7 @@ private var companionManager: BleCompanionManager? = null
it.getStringExtra(KEY_MUSICSERVICE_TYPE)?.let { value -> config[KEY_MUSICSERVICE_TYPE] = value }
it.getStringExtra(APP_NAVIGATION_MODE)?.let { value -> config[APP_NAVIGATION_MODE] = value }
it.getStringExtra(APP_CALLING_TOOL)?.let { value -> config[APP_CALLING_TOOL] = value }
it.getStringExtra(KEY_AI_INTAGRAL)?.let { value -> config[KEY_AI_INTAGRAL] = value }
it.getStringExtra("isttsinterrupt")?.let { value -> config["isttsinterrupt"] = value }
// 提取 supportedLanguages 参数
@ -641,6 +643,7 @@ private var companionManager: BleCompanionManager? = null
config[KEY_MUSICSERVICE_TYPE] = getConfigString(prefs, KEY_MUSICSERVICE_TYPE, "")
config[APP_NAVIGATION_MODE] = getConfigString(prefs, APP_NAVIGATION_MODE, "")
config[APP_CALLING_TOOL] = getConfigString(prefs, APP_CALLING_TOOL, "")
config[KEY_AI_INTAGRAL] = getConfigInt(prefs, KEY_AI_INTAGRAL, 0)
// 添加 supportedLanguages 参数处理
val supportedLanguagesStr = getConfigString(prefs, KEY_SUPPORTED_LANGUAGES, "")
@ -651,7 +654,6 @@ private var companionManager: BleCompanionManager? = null
config[KEY_SUPPORTED_LANGUAGES] = languageList
}
}
return config
}
@ -662,6 +664,10 @@ private var companionManager: BleCompanionManager? = null
return prefs.getString(key, defaultValue) ?: defaultValue
}
private fun getConfigInt(prefs: SharedPreferences, key: String, defaultValue: Int): Int {
return prefs.getInt(key, defaultValue)
}
override fun onBind(intent: Intent?): IBinder? = null
override fun onDestroy() {

Loading…
Cancel
Save