Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
G
galaxy-iOS
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
mobile-group
galaxy-iOS
Commits
b170e9c5
Commit
b170e9c5
authored
Apr 08, 2025
by
Steven杜宇
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
// loading
parent
8acee64f
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
21 additions
and
13 deletions
+21
-13
YHPlanShareViewController.swift
...lasses/Modules/Plan(方案)/C/YHPlanShareViewController.swift
+21
-13
No files found.
galaxy/galaxy/Classes/Modules/Plan(方案)/C/YHPlanShareViewController.swift
View file @
b170e9c5
...
...
@@ -153,10 +153,10 @@ class YHPlanShareViewController: YHBaseViewController {
// }
//
if
pdfDownloadUrl
.
isEmpty
{
requestPDF
()
requestPDF
(
isShowLoading
:
true
)
}
else
{
downloadPDF
(
pdfDownloadUrl
)
downloadPDF
(
pdfDownloadUrl
,
isShowLoading
:
true
)
}
}
}
...
...
@@ -212,32 +212,36 @@ class YHPlanShareViewController: YHBaseViewController {
}
if
pdfDownloadUrl
.
isEmpty
{
requestPDF
()
requestPDF
(
isShowLoading
:
false
)
}
else
{
downloadPDF
(
pdfDownloadUrl
)
downloadPDF
(
pdfDownloadUrl
,
isShowLoading
:
false
)
}
}
func
requestPDF
()
{
func
requestPDF
(
isShowLoading
:
Bool
)
{
YHHUD
.
show
(
.
progress
(
message
:
"加载中..."
))
if
isShowLoading
{
YHHUD
.
show
(
.
progress
(
message
:
"加载中..."
))
}
self
.
viewModel
.
requetPDFUrl
(
self
.
pdfCreateUrl
)
{
[
weak
self
]
url
in
YHHUD
.
hide
()
guard
let
self
=
self
else
{
return
}
self
.
pdfDownloadUrl
=
url
self
.
downloadPDF
(
url
)
self
.
downloadPDF
(
url
,
isShowLoading
:
isShowLoading
)
}
}
func
downloadPDF
(
_
urlString
:
String
)
{
func
downloadPDF
(
_
urlString
:
String
,
isShowLoading
:
Bool
)
{
guard
let
url
=
URL
(
string
:
urlString
)
else
{
YHHUD
.
flash
(
message
:
"下载PDF失败"
)
return
}
YHHUD
.
show
(
.
progress
(
message
:
"下载中..."
))
if
isShowLoading
{
YHHUD
.
show
(
.
progress
(
message
:
"下载中..."
))
}
let
configuration
=
URLSessionConfiguration
.
default
let
session
=
URLSession
(
configuration
:
configuration
)
let
task
=
session
.
downloadTask
(
with
:
url
)
{
[
weak
self
]
(
locationUrl
,
response
,
error
)
in
...
...
@@ -252,13 +256,13 @@ class YHPlanShareViewController: YHBaseViewController {
if
let
res
=
response
{
printLog
(
res
.
suggestedFilename
)
}
self
.
savePDF
(
sourceUrl
:
url
,
locationUrl
:
locationUrl
)
self
.
savePDF
(
sourceUrl
:
url
,
locationUrl
:
locationUrl
,
isShowLoading
:
isShowLoading
)
}
}
task
.
resume
()
}
func
savePDF
(
sourceUrl
:
URL
,
locationUrl
:
URL
)
{
func
savePDF
(
sourceUrl
:
URL
,
locationUrl
:
URL
,
isShowLoading
:
Bool
)
{
let
fileManager
=
FileManager
.
default
...
...
@@ -273,11 +277,15 @@ class YHPlanShareViewController: YHBaseViewController {
try
fileManager
.
moveItem
(
at
:
locationUrl
,
to
:
destinationURL
)
print
(
"文件已保存到:
\(
destinationURL
.
path
)
"
)
print
(
"文件源地址:
\(
locationUrl
.
path
)
"
)
YHHUD
.
flash
(
message
:
"下载PDF成功"
)
if
isShowLoading
{
YHHUD
.
flash
(
message
:
"下载PDF成功"
)
}
}
catch
{
print
(
"保存文件失败:
\(
error
.
localizedDescription
)
"
)
YHHUD
.
flash
(
message
:
"下载PDF失败"
)
if
isShowLoading
{
YHHUD
.
flash
(
message
:
"下载PDF失败"
)
}
}
}
}
...
...
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