Skip to content

Commit 93299f1

Browse files
committed
🎨 导出体验优化,默认下载文件夹,ppt导出时候不会闪一下
1 parent ae42fad commit 93299f1

File tree

5 files changed

+27
-23
lines changed

5 files changed

+27
-23
lines changed

Mac/View/MPreviewView.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ class MPreviewView: WKWebView, WKUIDelegate, WKNavigationDelegate {
9393
super.createPDF(configuration: config) { result in
9494
switch result {
9595
case .success(let data):
96-
if let path = NSSearchPathForDirectoriesInDomains(.desktopDirectory, .userDomainMask, true).first {
96+
if let path = NSSearchPathForDirectoriesInDomains(.downloadsDirectory, .userDomainMask, true).first {
9797
let currentName = self.note?.getTitle()
9898
let filePath: String = path + "/" + (currentName ?? "MiaoYan") + ".pdf"
9999
try! data.write(to: URL(fileURLWithPath: filePath))
@@ -161,7 +161,7 @@ class MPreviewView: WKWebView, WKUIDelegate, WKNavigationDelegate {
161161
guard let contentHtml = html as? String else {
162162
print("Content html could not be obtained"); return
163163
}
164-
if let path = NSSearchPathForDirectoriesInDomains(.desktopDirectory, .userDomainMask, true).first {
164+
if let path = NSSearchPathForDirectoriesInDomains(.downloadsDirectory, .userDomainMask, true).first {
165165
let currentName = self.note?.getShortTitle()
166166
let filePath: String = path + "/" + (currentName ?? "MiaoYan") + ".html"
167167
try! contentHtml.write(to: URL(fileURLWithPath: filePath), atomically: false, encoding: .utf8)
@@ -194,7 +194,7 @@ class MPreviewView: WKWebView, WKUIDelegate, WKNavigationDelegate {
194194
self?.frame.size.height = contentHeight
195195
self?.takeSnapshot(with: config, completionHandler: { image, error in
196196
if let image = image {
197-
if let desktopURL = FileManager.default.urls(for: .desktopDirectory, in: .userDomainMask).first {
197+
if let desktopURL = FileManager.default.urls(for: .downloadsDirectory, in: .userDomainMask).first {
198198
let currentName = self?.note?.getTitle()
199199
let destinationURL = desktopURL.appendingPathComponent(currentName! + ".jpeg")
200200
try! image.saveJPEGRepresentationToURL(url: destinationURL)

Resources/DownView.bundle/css/heti.min.css

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ html {
3737
body {
3838
padding: 0;
3939
margin: 0;
40+
background: #FFFFFF;
4041
}
4142

4243
@media (prefers-color-scheme: dark) {

Resources/DownView.bundle/ppt.html

Lines changed: 21 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -82,28 +82,31 @@
8282

8383
<script>
8484
if ('DOWN_EXPORT_TYPE' === 'ppt') {
85+
8586
if (window.location.search.indexOf('print-pdf') === -1) {
8687
window.location.search = 'print-pdf';
8788
}
89+
8890
document.getElementById('write').style.visibility = 'hidden';
89-
setTimeout(() => {
90-
const iframeEle = document.querySelector(
91-
'.pdf-page .slide-background-content iframe'
92-
);
93-
const iframeBg = document.querySelector(
94-
'.pdf-page section[data-background-iframe]'
95-
);
96-
const pdfSections = document.getElementsByClassName('pdf-page');
97-
pdfSections.forEach((item) => {
98-
if (item.contains(iframeEle)) {
99-
item.hidden = true;
100-
}
101-
if (item.contains(iframeBg)) {
102-
item.hidden = true;
103-
}
104-
});
105-
document.getElementById('write').style.visibility = 'visible';
106-
}, 600);
91+
92+
window.addEventListener('load', function () {
93+
const iframeEle = document.querySelector(
94+
'.pdf-page .slide-background-content iframe'
95+
);
96+
const iframeBg = document.querySelector(
97+
'.pdf-page section[data-background-iframe]'
98+
);
99+
const pdfSections = document.getElementsByClassName('pdf-page');
100+
pdfSections.forEach((item) => {
101+
if (item.contains(iframeEle)) {
102+
item.hidden = true;
103+
}
104+
if (item.contains(iframeBg)) {
105+
item.hidden = true;
106+
}
107+
});
108+
document.getElementById('write').style.visibility = 'visible';
109+
});
107110
}
108111
Reveal.initialize({
109112
width: '100%',

ja.lproj/Localizable.strings

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@
116116

117117
"😶‍🌫 The current Mac system does not support export, please upgrade to above 11.0~" = "😶‍🌫 現在利用の環境は出力をサポートしていません。11.0にアップグレードしてください。";
118118

119-
"🎉 Exported to desktop~" = "🎉 デスクトップに保存しました。";
119+
"🎉 Saved to Downloads folder~" = "🎉 ダウンロードフォルダに保存されました。";
120120

121121
"🙊 Starting export~" = "🙊 出力開始〜";
122122

zh-Hans.lproj/Localizable.strings

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@
116116

117117
"😶‍🌫 The current Mac system does not support export, please upgrade to above 11.0~" = "😶‍🌫 当前 Mac 系统不支持导出,请升级到 11.0 以上~";
118118

119-
"🎉 Exported to desktop~" = "🎉 已导出到桌面~";
119+
"🎉 Saved to Downloads folder~" = "🎉 已导出到下载目录~";
120120

121121
"🙊 Starting export~" = "🙊 开始导出中~";
122122

0 commit comments

Comments
 (0)