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
8acee64f
Commit
8acee64f
authored
Apr 03, 2025
by
Steven杜宇
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
// plan
parent
a56962db
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
12 deletions
+7
-12
YHPlanShareViewController.swift
...lasses/Modules/Plan(方案)/C/YHPlanShareViewController.swift
+7
-12
No files found.
galaxy/galaxy/Classes/Modules/Plan(方案)/C/YHPlanShareViewController.swift
View file @
8acee64f
...
...
@@ -238,7 +238,9 @@ class YHPlanShareViewController: YHBaseViewController {
}
YHHUD
.
show
(
.
progress
(
message
:
"下载中..."
))
let
task
=
URLSession
.
shared
.
downloadTask
(
with
:
url
)
{
[
weak
self
]
(
locationUrl
,
_
,
error
)
in
let
configuration
=
URLSessionConfiguration
.
default
let
session
=
URLSession
(
configuration
:
configuration
)
let
task
=
session
.
downloadTask
(
with
:
url
)
{
[
weak
self
]
(
locationUrl
,
response
,
error
)
in
DispatchQueue
.
main
.
async
{
YHHUD
.
hide
()
guard
let
self
=
self
else
{
return
}
...
...
@@ -247,6 +249,9 @@ class YHPlanShareViewController: YHBaseViewController {
YHHUD
.
flash
(
message
:
"下载PDF失败"
)
return
}
if
let
res
=
response
{
printLog
(
res
.
suggestedFilename
)
}
self
.
savePDF
(
sourceUrl
:
url
,
locationUrl
:
locationUrl
)
}
}
...
...
@@ -256,17 +261,6 @@ class YHPlanShareViewController: YHBaseViewController {
func
savePDF
(
sourceUrl
:
URL
,
locationUrl
:
URL
)
{
let
fileManager
=
FileManager
.
default
// 创建子文件夹如果不存在
if
!
fileManager
.
fileExists
(
atPath
:
self
.
planDocumentFileUrl
.
path
)
{
do
{
try
fileManager
.
createDirectory
(
at
:
self
.
planDocumentFileUrl
,
withIntermediateDirectories
:
true
,
attributes
:
nil
)
print
(
"目录已创建:
\(
self
.
planDocumentFileUrl
.
path
)
"
)
}
catch
{
print
(
"创建目录失败:
\(
error
.
localizedDescription
)
"
)
return
}
}
// 保存文件到 plan 目录
let
lastComponent
=
sourceUrl
.
lastPathComponent
...
...
@@ -278,6 +272,7 @@ class YHPlanShareViewController: YHBaseViewController {
}
try
fileManager
.
moveItem
(
at
:
locationUrl
,
to
:
destinationURL
)
print
(
"文件已保存到:
\(
destinationURL
.
path
)
"
)
print
(
"文件源地址:
\(
locationUrl
.
path
)
"
)
YHHUD
.
flash
(
message
:
"下载PDF成功"
)
}
catch
{
...
...
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