Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
iOSTeam
/
Majiabao
/
TealiveModule
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
06c25675
authored
Apr 19, 2024
by
pierce
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fixed bugs
parent
21a4c4bf
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
53 additions
and
59 deletions
LocalPodSpec/GDToolBox/GDToolBox/Classes/Base/WebView/GDWebView.swift
LocalPodSpec/GDToolBox/GDToolBox/Classes/Base/WebView/GDWebView.swift
View file @
06c25675
...
@@ -262,68 +262,62 @@ public class GDWebView: WKWebView, WKNavigationDelegate, WKScriptMessageHandler
...
@@ -262,68 +262,62 @@ public class GDWebView: WKWebView, WKNavigationDelegate, WKScriptMessageHandler
public
func
userContentController
(
_
userContentController
:
WKUserContentController
,
didReceive
message
:
WKScriptMessage
)
{
public
func
userContentController
(
_
userContentController
:
WKUserContentController
,
didReceive
message
:
WKScriptMessage
)
{
//TODO:处理这里的逻辑: added By Pidan
//TODO:处理这里的逻辑: added By Pidan
//
if message.name == GDWebView.kJavaScriptInteractKey {
if
message
.
name
==
GDWebView
.
kJavaScriptInteractKey
{
//
//
guard let body : String = message.body as? String else {return}
guard
let
body
:
String
=
message
.
body
as?
String
else
{
return
}
//
//
guard let jsonData = body.data(using: String.Encoding.utf8, allowLossyConversion: false) else {return}
guard
let
jsonData
=
body
.
data
(
using
:
String
.
Encoding
.
utf8
,
allowLossyConversion
:
false
)
else
{
return
}
//
let json = try! JSON(data: jsonData)
let
json
=
try!
JSON
(
data
:
jsonData
)
//
//
let dataDict = json["data"]
let
dataDict
=
json
[
"data"
]
//
let webCid = json["cid"].intValue
let
webCid
=
json
[
"cid"
]
.
intValue
//
switch webCid {
switch
webCid
{
// case 1: // CID 为 1,打开榜单
// case 1: // CID 为 1,打开榜单
// // TODO: 打开榜单
// // TODO: 打开榜单
// if DevConfig.devEnv {
// if DevConfig.devEnv {
// FTIndicator.showToastMessage("不支持功能")
// FTIndicator.showToastMessage("不支持功能")
// }
// }
// break
// break
//
case 2: // CID 为2,打开网页
case
2
:
// CID 为2,打开网页
//
let shouldShare = dataDict["share"].boolValue
let
shouldShare
=
dataDict
[
"share"
]
.
boolValue
//
let halfScreen = dataDict["isShowHalf"].boolValue
let
halfScreen
=
dataDict
[
"isShowHalf"
]
.
boolValue
//
let urlStr = dataDict["url"].stringValue
let
urlStr
=
dataDict
[
"url"
]
.
stringValue
//
//
if halfScreen {
if
halfScreen
{
//
let heightRatio = CGFloat(dataDict["heightScale"].doubleValue / 100.0)
let
heightRatio
=
CGFloat
(
dataDict
[
"heightScale"
]
.
doubleValue
/
100.0
)
//
let widthRatio = CGFloat(dataDict["viewHeight"].doubleValue / 100.0)
let
widthRatio
=
CGFloat
(
dataDict
[
"viewHeight"
]
.
doubleValue
/
100.0
)
//
//
var shouldCloseGift = true
var
shouldCloseGift
=
true
//
if dataDict["closeGiftWindow"].isEmpty == false {
if
dataDict
[
"closeGiftWindow"
]
.
isEmpty
==
false
{
//
shouldCloseGift = dataDict["closeGiftWindow"].boolValue
shouldCloseGift
=
dataDict
[
"closeGiftWindow"
]
.
boolValue
//
}
}
//
//TODO:处理这里的逻辑: added By Pidan
// if let functionView = GDLiveHelper.shared.liveVC?.functionView as? GDLiveFunctionView {
// if let functionView = GDLiveHelper.shared.liveVC?.functionView as? GDLiveFunctionView {
//
//
// functionView.showHalfScreenView(for: urlStr, heightRatio: heightRatio, widthRadio: widthRatio, closeGiftPanel: shouldCloseGift)
// functionView.showHalfScreenView(for: urlStr, heightRatio: heightRatio, widthRadio: widthRatio, closeGiftPanel: shouldCloseGift)
// }
// }
//
// } else {
}
else
{
// let webVC = GDWebViewController(url: urlStr)
let
webVC
=
GDWebViewController
(
url
:
urlStr
)
// webVC.showShare = shouldShare
webVC
.
showShare
=
shouldShare
// webVC.hidesBottomBarWhenPushed = true
webVC
.
hidesBottomBarWhenPushed
=
true
// if let vc = self.getPresentViewController?() {
if
let
vc
=
self
.
getPresentViewController
?()
{
// vc.navigationController?.pushViewController(webVC, animated: true)
vc
.
navigationController
?
.
pushViewController
(
webVC
,
animated
:
true
)
// } else {
}
else
{
// self.viewController?.navigationController?.pushViewController(webVC, animated: true)
self
.
viewController
?
.
navigationController
?
.
pushViewController
(
webVC
,
animated
:
true
)
// }
}
//
// }
}
// case 4: // CID 为 4,打开客服
case
4
:
// CID 为 4,打开客服
// let serviceVC = GDServiceController()
//TODO:处理这里的逻辑: added By Pidan
// serviceVC.hidesBottomBarWhenPushed = true
// GDRouter.ChatRoom?.showServiceCharRoom()
// if let vc = self.getPresentViewController?() {
// vc.navigationController?.pushViewController(serviceVC, animated: true)
break
// } else {
case
5
:
// CID 为 5,跳转外链
// self.viewController?.navigationController?.pushViewController(serviceVC, animated: true)
if
let
url
:
URL
=
URL
(
string
:
dataDict
[
"url"
]
.
stringValue
)
{
//
UIApplication
.
shared
.
openURL
(
url
)
// }
}
//
break
// break
// case 5: // CID 为 5,跳转外链
// if let url: URL = URL(string: dataDict["url"].stringValue) {
// UIApplication.shared.openURL(url)
// }
// break
// case 6: // CID 为 6,打开兑换钻石页面,废弃
// case 6: // CID 为 6,打开兑换钻石页面,废弃
// if DevConfig.devEnv {
// if DevConfig.devEnv {
// FTIndicator.showToastMessage("不支持功能")
// FTIndicator.showToastMessage("不支持功能")
...
@@ -974,13 +968,13 @@ public class GDWebView: WKWebView, WKNavigationDelegate, WKScriptMessageHandler
...
@@ -974,13 +968,13 @@ public class GDWebView: WKWebView, WKNavigationDelegate, WKScriptMessageHandler
// } else {
// } else {
// shareInviteView.show(on: self)
// shareInviteView.show(on: self)
// }
// }
//
default:
default
:
//
break
break
//
}
}
//
//
// 发布
// 发布
//
actionPublisher.accept((cid: webCid, data: dataDict))
actionPublisher
.
accept
((
cid
:
webCid
,
data
:
dataDict
))
//
}
}
}
}
// MARK: Public
// MARK: Public
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment