提交 54541654 authored 作者: yueweilu's avatar yueweilu

add

上级 8059be8c
......@@ -165,6 +165,14 @@ abstract class CommonAPI {
return result.data['filesUrl'];
}
/// 11、获取OSS临时token
static Future <OssModel> oss() async {
final result = await HttpService.to.post(
'/v1/common/Alioss/getUploadToken',
);
if (result.data is! Map ) return OssModel();
return OssModel.fromJson(result.data);
}
}
\ No newline at end of file
......@@ -494,4 +494,41 @@ class BookDownloadModel {
}
class OssModel {
OssModel({
this.securityToken,
this.accessKeyId,
this.accessKeySecret,
this.expiration,});
OssModel.fromJson(dynamic json) {
securityToken = json['SecurityToken'];
accessKeyId = json['AccessKeyId'];
accessKeySecret = json['AccessKeySecret'];
expiration = json['Expiration'];
}
String? securityToken;
String? accessKeyId;
String? accessKeySecret;
String? expiration;
OssModel copyWith({ String? securityToken,
String? accessKeyId,
String? accessKeySecret,
String? expiration,
}) => OssModel( securityToken: securityToken ?? this.securityToken,
accessKeyId: accessKeyId ?? this.accessKeyId,
accessKeySecret: accessKeySecret ?? this.accessKeySecret,
expiration: expiration ?? this.expiration,
);
Map<String, dynamic> toJson() {
final map = <String, dynamic>{};
map['SecurityToken'] = securityToken;
map['AccessKeyId'] = accessKeyId;
map['AccessKeySecret'] = accessKeySecret;
map['Expiration'] = expiration;
return map;
}
}
......@@ -113,7 +113,7 @@ class _ChangePwdPageState extends State<ChangePwdPage> {
),
Container(
margin: EdgeInsets.only(left: 5.w,top: 5.w),
child: Text('密码必须是6-20个英文字母、数字或符号',style: TextStyle(fontSize: 10.w,color: Colours.c9),),
child: Text('密码必须是8-20个英文字母、数字或符号(除空格)',style: TextStyle(fontSize: 10.w,color: Colours.c9),),
),
Gaps.vGaps40,
CustomGradientButton(
......
......@@ -55,6 +55,7 @@ class ReadController extends FullLifeCycleController with GetSingleTickerProvide
void onInit() {
discussTitleFocusNode.addListener(_onCommentFocusChanged);
openTheRecorder();
super.onInit();
}
......@@ -116,8 +117,10 @@ class ReadController extends FullLifeCycleController with GetSingleTickerProvide
void record() async {
startRecording = true;
String filePath = await _getDocumentsDirectory();
String fileName = generateVoiceFileName();
_mRecorder.startRecorder(
toFile: '$filePath/tau_file.mp4',
toFile: '$filePath/$fileName',
audioSource: AudioSource.microphone,
codec: Codec.aacMP4,
......@@ -134,14 +137,27 @@ class ReadController extends FullLifeCycleController with GetSingleTickerProvide
}
// 停止录音
void stopRecorder() async{
just_audio.AudioPlayer audioPlayer = just_audio.AudioPlayer();
startRecording = false;
_mRecorder.stopRecorder().then((value){
print('------value-------------------$value---------------------------------------');
});
final path = await _mRecorder.stopRecorder();
var duration = await audioPlayer.setFilePath(path!);
print('-----duration---------------------$duration------');
update();
}
// 语音文件名称
String generateVoiceFileName(){
DateTime now = DateTime.now();
String formattedDate = DateFormat('yyyyMMddHHmmss').format(now);
return 'voice_$formattedDate.mp4';
}
// 添加语音路径
void addVoiceFilePath(){
}
// 添加讨论图片
void addDiscussInputImages(String path){
discussInputImages.add(path);
......@@ -389,6 +405,7 @@ class ReadController extends FullLifeCycleController with GetSingleTickerProvide
//获取存储目录
Future<String> _getDocumentsDirectory() async {
// getTemporaryDirectory
final directory = await getExternalStorageDirectory();
return directory!.path;
}
......@@ -436,3 +453,6 @@ class ToolModel {
String activeIcon;
}
class AudioModel {
}
......@@ -9,13 +9,16 @@ import 'package:flutter/material.dart';
import 'package:flutter_book/theme.dart';
import 'package:flutter_inappwebview/flutter_inappwebview.dart';
import 'package:flutter_book/utils/index.dart';
import 'package:flutter_oss_aliyun/flutter_oss_aliyun.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:flutter_sound/public/flutter_sound_recorder.dart';
import 'package:flutter_sound/public/util/flutter_sound_helper.dart';
import 'package:flutter_sound_platform_interface/flutter_sound_platform_interface.dart';
import 'package:flutter_sound_platform_interface/flutter_sound_recorder_platform_interface.dart';
import 'package:get/get.dart';
import 'package:go_router/go_router.dart';
import 'package:intl/intl.dart';
import 'package:just_audio/just_audio.dart' as just_audio;
import 'package:path_provider/path_provider.dart';
import 'dart:async';
import 'package:plugin_platform_interface/plugin_platform_interface.dart';
......
......@@ -63,7 +63,7 @@ class _ReadPageState extends State<ReadPage> {
),
InAppWebView(
initialUrlRequest: URLRequest(
url: Uri.parse('http://192.168.11.46:9200/read.html'),
url: Uri.parse('http://150.158.138.40:9200/read.html'),
),
contextMenu: ContextMenu(
options: ContextMenuOptions(hideDefaultSystemContextMenuItems: true),
......@@ -71,8 +71,8 @@ class _ReadPageState extends State<ReadPage> {
onLoadStop: (controller, url) {
// flutter 主动给 js 传参数
Map<String, dynamic> param = {
'book_id': 110,
'chapter_id': 1,
'book_id': widget.bookId,
'chapter_id': widget.chapterId,
'token':UserStore.to.token
};
controller.evaluateJavascript(source: 'callbackInFlutterComponent("$param");');
......
......@@ -16,6 +16,7 @@ import 'package:get/get_state_manager/src/simple/get_controllers.dart';
import 'package:go_router/go_router.dart';
import 'package:tobias/tobias.dart';
import '../../routes/index.dart';
import '../../services/index.dart';
import '../../utils/index.dart';
import '../../widgets/index.dart';
......
......@@ -68,12 +68,17 @@ class _CoinRechargePageState extends State<CoinRechargePage> with AutomaticKeepA
),
),
Gaps.vGaps15,
RichText(text: TextSpan(
GestureDetector(
onTap: (){
context.pushNamed(Routes.terms);
},
child: RichText(text: TextSpan(
children: [
TextSpan(text: '充值即代表同意',style: TextStyle(fontSize: 13.w,height: 1.5,color: Colours.c9)),
TextSpan(text: '《用户充值协议》',style: TextStyle(fontSize: 13.w,height: 1.5,color: Color(0xFF2A82D9))),
]
)),
),
Gaps.vGaps15
],
),
......
......@@ -8,8 +8,12 @@ class UserInfoController extends GetxController {
void upload({
required String path
}) async {
String result = await CommonAPI.upload(path:path,fileTypes: 'user');
_changeInfo(result);
// String result = await CommonAPI.upload(path:path,fileTypes: 'user');
OssTool tool = OssTool('zxts-user-file');
print('------path--------------------------$path');
final response = await tool.putObjectFile(path);
print('------response--------------------------${response.data}');
// _changeInfo(result);
}
/// 修改用用户信息
......
......@@ -226,7 +226,7 @@ class _RequestInterceptor extends Interceptor {
var msg = '服务器错误';
switch (statusCode) {
case 403:
print('-------------------access_token-------------------------${UserStore.to.accessToken}--------------------');
print('----------403---------access_token-------------------------${UserStore.to.accessToken}--------------------');
msg = '$statusCode - Unauthorized';
final newToken = await refreshToken();
if (newToken != null) {
......
......@@ -5,10 +5,12 @@ import 'dart:io';
import 'dart:ui';
// import 'package:encrypt/encrypt.dart';
import 'package:dio/dio.dart';
import 'package:encrypt/encrypt.dart' as encrypt; // 使用别名 'encrypt'
import 'package:flutter/cupertino.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:flutter_book/apis/index.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:image_picker/image_picker.dart';
import 'package:intl/intl.dart';
......@@ -18,6 +20,9 @@ import 'package:convert/convert.dart';
import 'package:oktoast/oktoast.dart';
import 'package:path_provider/path_provider.dart';
import 'package:permission_handler/permission_handler.dart';
import 'package:flutter_oss_aliyun/flutter_oss_aliyun.dart';
import '../models/index.dart';
import '../widgets/index.dart';
......@@ -34,3 +39,4 @@ part 'toast_utils.dart';
part 'clear_cache_util.dart';
part 'access.dart';
part 'assets_picker.dart';
part 'oss.dart';
\ No newline at end of file
part of utils;
//'bucket_comment' => 'zxts-comment-file', 'bucket_user' => 'zxts-user-file', 'endpoint' => 'zijingebook.com',
class OssTool {
late OssModel ossModel;
final String bucketName;
OssTool(this.bucketName){
initOss(bucketName);
}
void initOss(String bucketName) async {
Client.init(ossEndpoint: 'zijingebook.com', bucketName:bucketName,authGetter: _authGetter);
}
// 获取临时凭证
Future<Auth> _authGetter() async {
final result = await CommonAPI.oss();
return Auth(
accessKey: result.accessKeyId!,
accessSecret: result.accessKeySecret!,
expire: result.expiration!,
secureToken: result.securityToken!,
);
}
// 本地文件上传
Future<Response<dynamic>> putObjectFile(String filePath){
print('------------------222222222222222222222--------------');
return Client().putObjectFile(
filePath,
);
}
// 批量本地文件上传
Future<List<Response>> putObjectFiles(List<String> filePaths){
return Client().putObjectFiles(
filePaths.map((e){
return AssetFileEntity(
filepath: e
);
}).toList()
);
}
}
\ No newline at end of file
......@@ -243,6 +243,14 @@ packages:
description: flutter
source: sdk
version: "0.0.0"
flutter_oss_aliyun:
dependency: "direct main"
description:
name: flutter_oss_aliyun
sha256: d4e7423a29a3ff41aff6ab8278e0371716a3c3c1d086f937a9695a70ea8f8d39
url: "https://pub.flutter-io.cn"
source: hosted
version: "6.4.1"
flutter_plugin_android_lifecycle:
dependency: transitive
description:
......@@ -437,6 +445,30 @@ packages:
url: "https://pub.flutter-io.cn"
source: hosted
version: "0.6.7"
just_audio:
dependency: "direct main"
description:
name: just_audio
sha256: b607cd1a43bac03d85c3aaee00448ff4a589ef2a77104e3d409889ff079bf823
url: "https://pub.flutter-io.cn"
source: hosted
version: "0.9.36"
just_audio_platform_interface:
dependency: transitive
description:
name: just_audio_platform_interface
sha256: c3dee0014248c97c91fe6299edb73dc4d6c6930a2f4f713579cd692d9e47f4a1
url: "https://pub.flutter-io.cn"
source: hosted
version: "4.2.2"
just_audio_web:
dependency: transitive
description:
name: just_audio_web
sha256: "134356b0fe3d898293102b33b5fd618831ffdc72bb7a1b726140abdf22772b70"
url: "https://pub.flutter-io.cn"
source: hosted
version: "0.4.9"
lints:
dependency: transitive
description:
......
......@@ -104,6 +104,8 @@ dependencies:
# 内购
flutter_inapp_purchase: ^5.6.1
encrypt: ^5.0.3
flutter_oss_aliyun: ^6.4.1
just_audio: ^0.9.36
dev_dependencies:
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论