Skip to content

Commit

Permalink
整理代码, 修改一些bug
Browse files Browse the repository at this point in the history
  • Loading branch information
CoderMaoWX committed Nov 12, 2024
1 parent e4e83c9 commit a223afc
Show file tree
Hide file tree
Showing 5 changed files with 166 additions and 158 deletions.
38 changes: 19 additions & 19 deletions Example/WXNetworkingSwift/Base.lproj/Main.storyboard
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="19162" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES" initialViewController="6OK-h9-iFJ">
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="23504" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES" initialViewController="6OK-h9-iFJ">
<device id="retina4_7" orientation="portrait" appearance="light"/>
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="19144"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="23506"/>
<capability name="System colors in document resources" minToolsVersion="11.0"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
Expand All @@ -21,36 +21,36 @@
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<subviews>
<textView clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" editable="NO" textAlignment="natural" translatesAutoresizingMaskIntoConstraints="NO" id="Egf-HT-5Ik">
<rect key="frame" x="16" y="44" width="343" height="623"/>
<rect key="frame" x="16" y="64" width="343" height="603"/>
<color key="backgroundColor" systemColor="systemGray6Color"/>
<string key="text">

WXNetworkingSwift功能列表:
<mutableString key="text">WXNetworkingSwift功能列表:

1、封装一套网络请求;
1、自定义请求头;简单配置请求头或加密头

2、自动处理是否缓存;
2、自动处理是否缓存;设置缓存机制,自动失效时间等

3、请求失败多多次重试;
3、请求失败自定义多次重试;支持失败后每隔几秒尝试再试请求,如启动App后一定要请求的必要数据接口。

4、上传接口日志;
4、支持上传接口抓包日志;如上传到公司内部日志服务器系统上,供测试人员排查问题或快速抓包排查问题。

5、极简上传下载文件监听;
5、极简上传下载文件监听; 简单配置监听上传下载文件进度。

6、约定全局请求成功keyPath模型映射;
6、支持全局/单个配置请求成功后keyPath模型映射;页面上无需每个接口编写解析字典转模型的重新代码,支持数组和自定义模型;

7、约定全局请求的提示tipKey;
7、约定全局请求的提示Hud ToastKey;支持单个配置或全局配置请求失败时的HUD Toast自动弹框提示。

8、请求遇到相应Code时触发通知;
8、请求遇到相应Code时触发通知;如:Token失效全部重新登录等;

9、网络请求过程多链路回调管理;
9、网络请求过程多链路回调管理;如:请求将要开始回调,请求回调将要停止,请求已经回调完成;

10、格式化打印网络日志;
10、格式化打印网络日志;输出日志一目了然,如:请求接口地址、参数、请求头、耗时、响应;

11、批量请求;
11、批量请求;支持自定义每个请求的所有配置,并且可配置等待全部完成才回调还是一起完成才回调;

12、调试响应json等使用功能;
12、支持debug模式不请求网络快速调试模拟接口响应数据;如:本地json string,Dictionary,local json file, http test url

... ...

 pod 'WXNetworkingSwift'
</string>
. . . . . .(持续完善-ing)

 pod 'WXNetworkingSwift'
</mutableString>
<color key="textColor" systemColor="labelColor"/>
<fontDescription key="fontDescription" type="system" pointSize="16"/>
<textInputTraits key="textInputTraits" autocapitalizationType="sentences"/>
Expand Down Expand Up @@ -90,7 +90,7 @@
<navigationController automaticallyAdjustsScrollViewInsets="NO" id="6OK-h9-iFJ" sceneMemberID="viewController">
<toolbarItems/>
<navigationBar key="navigationBar" contentMode="scaleToFill" id="x9W-q8-1r4">
<rect key="frame" x="0.0" y="0.0" width="375" height="44"/>
<rect key="frame" x="0.0" y="20" width="375" height="44"/>
<autoresizingMask key="autoresizingMask"/>
</navigationBar>
<nil name="viewControllers"/>
Expand Down
10 changes: 5 additions & 5 deletions Example/WXNetworkingSwift/ViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,11 @@ class ViewController: UIViewController {
api.requestSerializer = .EncodingFormURL
//api.autoCacheResponse = true
api.successStatusMap = (key: "returnCode", value: "SUCCESS")
api.parseModelMap = (parseKey: "data.recommend", modelType: WXRecommendModel.self)
api.parseModelMap = (keyPath: "data.recommend", modelType: WXRecommendModel.self)
requestTask = api.startRequest { [weak self] responseModel in
self?.textView.text = responseModel.responseDict?.description
if let model = responseModel.parseKeyPathModel as? WXRecommendModel {
WXDebugLog("这个就是解析好的数据模型: \(model)")
if let model = responseModel.parseModel as? WXRecommendModel {
WXRequestTools.WXDebugLog("这个就是解析好的数据模型: \(model)")
}
}
}
Expand Down Expand Up @@ -141,9 +141,9 @@ class ViewController: UIViewController {

let image = UIImage(named: "womenPic")!
let imageData = image.pngData()
// api.uploadFileDataTuple = (withName: "files", dataArr: [imageData!])

api.uploadFileDataArr = [imageData!]
api.uploadConfigDataBlock = { multipartFormData in
api.uploadFileManualConfigBlock = { multipartFormData in
multipartFormData.append(imageData!, withName: "files", fileName: "womenPic.png", mimeType: "image/png")
}
api.fileProgressBlock = { progress in
Expand Down
Loading

0 comments on commit a223afc

Please sign in to comment.