Browse Source

修改天气卡片

newdev_shunjiawei
tanlongsheng 2 years ago
parent
commit
95b8120ca8
  1. 6
      .mcp.json
  2. 4
      lib/modules/chat/controllers/chat_controller.dart
  3. 2
      lib/modules/chat/views/chat_navigation_card.dart
  4. 2
      lib/modules/chat/views/chat_view.dart
  5. 82
      lib/modules/chat/views/weather_day_card.dart

6
.mcp.json

@ -2,7 +2,9 @@
"mcpServers": { "mcpServers": {
"deepsound-mcp": { "deepsound-mcp": {
"url": "https://api.deapsound.com/sse" "url": "https://api.deapsound.com/sse"
},
"voitrans-mcp": {
"url": "https://www.voitrans.net/sse"
} }
} }
} }

4
lib/modules/chat/controllers/chat_controller.dart

@ -36,7 +36,7 @@ class ChatController extends GetxController {
final _amapFlutter = AmapFlutter(); final _amapFlutter = AmapFlutter();
StreamSubscription? _locationStream; StreamSubscription? _locationStream;
String _latLng = ''; String _latLng = '';
String _city = ''; String _city = '深圳市';
// Agent 信息 // Agent 信息
late final Agent agent; late final Agent agent;
@ -456,7 +456,7 @@ class ChatController extends GetxController {
if (i == recentMessages.length - 2) { if (i == recentMessages.length - 2) {
messageHistory.add({ messageHistory.add({
'role': 'user', 'role': 'user',
'content': '我当前在$_city,我的经纬度是$_latLng', 'content': '当需要获取我的位置时,我当前在$_city,我的经纬度是$_latLng',
}); });
} }
} }

2
lib/modules/chat/views/chat_navigation_card.dart

@ -41,7 +41,7 @@ class _ChatNavigationCardState extends State<ChatNavigationCard> {
} }
void _getLocation() async { void _getLocation() async {
List endPointList = widget.data?['location'].split(','); List endPointList = widget.data?['companyName'].split(',');
endPoint = LatLng( endPoint = LatLng(
double.parse(endPointList[0]), double.parse(endPointList[0]),
double.parse(endPointList[1]), double.parse(endPointList[1]),

2
lib/modules/chat/views/chat_view.dart

@ -357,7 +357,7 @@ class ChatView extends GetView<ChatController> {
} }
if (message.data != null) { if (message.data != null) {
if (message.data?['card_weather'] != null) { if (message.data?['card_weather'] != null) {
box = WeatherDayCard(message.data, isDarkMode); box = WeatherDayCard(message.data?['card_weather'], isDarkMode);
} }
if (message.data?['card_spotify'] != null) { if (message.data?['card_spotify'] != null) {
box = ChatMusicCard(message.data?['card_spotify'], isDarkMode); box = ChatMusicCard(message.data?['card_spotify'], isDarkMode);

82
lib/modules/chat/views/weather_day_card.dart

@ -9,8 +9,6 @@ class WeatherDayCard extends StatelessWidget {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
final Map weatherDays = data?['weatherDays'].first;
return Row( return Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween, mainAxisAlignment: MainAxisAlignment.spaceBetween,
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
@ -19,14 +17,14 @@ class WeatherDayCard extends StatelessWidget {
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
children: [ children: [
Text( Text(
weatherDays['date'], data?['date'],
style: TextStyle( style: TextStyle(
color: isDarkMode ? Colors.white : Colors.black, color: isDarkMode ? Colors.white : Colors.black,
fontSize: 10.sp, fontSize: 10.sp,
), ),
), ),
Text( Text(
'${weatherDays['maxTemperature']}°', '${data?['temperature']}°',
style: TextStyle( style: TextStyle(
color: isDarkMode ? Colors.white : Colors.black, color: isDarkMode ? Colors.white : Colors.black,
fontSize: 30.sp, fontSize: 30.sp,
@ -43,49 +41,49 @@ class WeatherDayCard extends StatelessWidget {
size: 18.w, size: 18.w,
), ),
Text( Text(
'${weatherDays['weatherCondition']},${weatherDays['windDirection']}', '${data?['weatherCondition']},${data?['windDirection']}',
style: TextStyle( style: TextStyle(
color: isDarkMode ? Colors.white : Colors.black, color: isDarkMode ? Colors.white : Colors.black,
fontSize: 14.sp, fontSize: 14.sp,
), ),
), ),
Row( // Row(
children: [ // children: [
Text( // Text(
'最\n高', // '最\n高',
style: TextStyle( // style: TextStyle(
color: isDarkMode ? Colors.white : Colors.black, // color: isDarkMode ? Colors.white : Colors.black,
fontSize: 10.sp, // fontSize: 10.sp,
height: 1, // height: 1,
), // ),
), // ),
5.horizontalSpace, // 5.horizontalSpace,
Text( // Text(
'${weatherDays['maxTemperature']}°', // '${data?['maxTemperature']}°',
style: TextStyle( // style: TextStyle(
color: isDarkMode ? Colors.white : Colors.black, // color: isDarkMode ? Colors.white : Colors.black,
fontSize: 20.sp, // fontSize: 20.sp,
), // ),
), // ),
10.horizontalSpace, // 10.horizontalSpace,
Text( // Text(
'最\n低', // '最\n低',
style: TextStyle( // style: TextStyle(
color: isDarkMode ? Colors.white : Colors.black, // color: isDarkMode ? Colors.white : Colors.black,
fontSize: 10.sp, // fontSize: 10.sp,
height: 1, // height: 1,
), // ),
), // ),
5.horizontalSpace, // 5.horizontalSpace,
Text( // Text(
'${weatherDays['minTemperature']}°', // '${data?['minTemperature']}°',
style: TextStyle( // style: TextStyle(
color: isDarkMode ? Colors.white : Colors.black, // color: isDarkMode ? Colors.white : Colors.black,
fontSize: 20.sp, // fontSize: 20.sp,
), // ),
), // ),
], // ],
), // ),
], ],
), ),
], ],

Loading…
Cancel
Save