diff --git a/Easydict.xcodeproj/project.pbxproj b/Easydict.xcodeproj/project.pbxproj index 4bdb66825..15f83b809 100644 --- a/Easydict.xcodeproj/project.pbxproj +++ b/Easydict.xcodeproj/project.pbxproj @@ -12,6 +12,8 @@ 03008B2E2941956D0062B821 /* EZURLSchemeHandler.m in Sources */ = {isa = PBXBuildFile; fileRef = 03008B2D2941956D0062B821 /* EZURLSchemeHandler.m */; }; 03008B3F29444B0A0062B821 /* NSView+EZAnimatedHidden.m in Sources */ = {isa = PBXBuildFile; fileRef = 03008B3E29444B0A0062B821 /* NSView+EZAnimatedHidden.m */; }; 03022F1C2B35DEBA00B63209 /* Hue in Frameworks */ = {isa = PBXBuildFile; productRef = 03022F1B2B35DEBA00B63209 /* Hue */; }; + 03022F1F2B36CF3100B63209 /* SwiftShell in Frameworks */ = {isa = PBXBuildFile; productRef = 03022F1E2B36CF3100B63209 /* SwiftShell */; }; + 03022F222B36D1A400B63209 /* SnapKit in Frameworks */ = {isa = PBXBuildFile; productRef = 03022F212B36D1A400B63209 /* SnapKit */; }; 030570E22ADB919900C9905E /* EZAppleScriptManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 030570E12ADB919900C9905E /* EZAppleScriptManager.m */; }; 0309E1ED292B439A00AFB76A /* EZTextView.m in Sources */ = {isa = PBXBuildFile; fileRef = 0309E1EC292B439A00AFB76A /* EZTextView.m */; }; 0309E1F0292B4A5E00AFB76A /* NSView+EZGetViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 0309E1EF292B4A5E00AFB76A /* NSView+EZGetViewController.m */; }; @@ -704,7 +706,9 @@ buildActionMask = 2147483647; files = ( 2721E4D02AFE920700A059AC /* Alamofire in Frameworks */, + 03022F1F2B36CF3100B63209 /* SwiftShell in Frameworks */, 03FD68BB2B1DC59600FD388E /* CryptoSwift in Frameworks */, + 03022F222B36D1A400B63209 /* SnapKit in Frameworks */, B87AC7E36367075BA5D13234 /* Pods_Easydict.framework in Frameworks */, 03022F1C2B35DEBA00B63209 /* Hue in Frameworks */, 03B63ABF2A86967800E155ED /* CoreServices.framework in Frameworks */, @@ -2060,6 +2064,8 @@ 2721E4CF2AFE920700A059AC /* Alamofire */, 03FD68BA2B1DC59600FD388E /* CryptoSwift */, 03022F1B2B35DEBA00B63209 /* Hue */, + 03022F1E2B36CF3100B63209 /* SwiftShell */, + 03022F212B36D1A400B63209 /* SnapKit */, ); productName = Bob; productReference = C99EEB182385796700FEE666 /* Easydict-debug.app */; @@ -2103,6 +2109,8 @@ 2721E4CE2AFE920700A059AC /* XCRemoteSwiftPackageReference "Alamofire" */, 03FD68B92B1DC59600FD388E /* XCRemoteSwiftPackageReference "CryptoSwift" */, 03022F1A2B35DEBA00B63209 /* XCRemoteSwiftPackageReference "Hue" */, + 03022F1D2B36CF3100B63209 /* XCRemoteSwiftPackageReference "SwiftShell" */, + 03022F202B36D1A300B63209 /* XCRemoteSwiftPackageReference "SnapKit" */, ); productRefGroup = C99EEB192385796700FEE666 /* Products */; projectDirPath = ""; @@ -2867,6 +2875,22 @@ minimumVersion = 5.0.1; }; }; + 03022F1D2B36CF3100B63209 /* XCRemoteSwiftPackageReference "SwiftShell" */ = { + isa = XCRemoteSwiftPackageReference; + repositoryURL = "https://github.com/kareman/SwiftShell"; + requirement = { + kind = upToNextMajorVersion; + minimumVersion = 5.1.0; + }; + }; + 03022F202B36D1A300B63209 /* XCRemoteSwiftPackageReference "SnapKit" */ = { + isa = XCRemoteSwiftPackageReference; + repositoryURL = "https://github.com/SnapKit/SnapKit"; + requirement = { + kind = upToNextMajorVersion; + minimumVersion = 5.6.0; + }; + }; 03FD68B92B1DC59600FD388E /* XCRemoteSwiftPackageReference "CryptoSwift" */ = { isa = XCRemoteSwiftPackageReference; repositoryURL = "https://github.com/krzyzanowskim/CryptoSwift"; @@ -2891,6 +2915,16 @@ package = 03022F1A2B35DEBA00B63209 /* XCRemoteSwiftPackageReference "Hue" */; productName = Hue; }; + 03022F1E2B36CF3100B63209 /* SwiftShell */ = { + isa = XCSwiftPackageProductDependency; + package = 03022F1D2B36CF3100B63209 /* XCRemoteSwiftPackageReference "SwiftShell" */; + productName = SwiftShell; + }; + 03022F212B36D1A400B63209 /* SnapKit */ = { + isa = XCSwiftPackageProductDependency; + package = 03022F202B36D1A300B63209 /* XCRemoteSwiftPackageReference "SnapKit" */; + productName = SnapKit; + }; 03FD68BA2B1DC59600FD388E /* CryptoSwift */ = { isa = XCSwiftPackageProductDependency; package = 03FD68B92B1DC59600FD388E /* XCRemoteSwiftPackageReference "CryptoSwift" */; diff --git a/Easydict.xcworkspace/xcshareddata/swiftpm/Package.resolved b/Easydict.xcworkspace/xcshareddata/swiftpm/Package.resolved index c9a157cf7..18deec25a 100644 --- a/Easydict.xcworkspace/xcshareddata/swiftpm/Package.resolved +++ b/Easydict.xcworkspace/xcshareddata/swiftpm/Package.resolved @@ -26,6 +26,24 @@ "revision" : "b9d920cee4ba795fefb828d130744eee1e3d2feb", "version" : "5.0.1" } + }, + { + "identity" : "snapkit", + "kind" : "remoteSourceControl", + "location" : "https://github.com/SnapKit/SnapKit", + "state" : { + "revision" : "f222cbdf325885926566172f6f5f06af95473158", + "version" : "5.6.0" + } + }, + { + "identity" : "swiftshell", + "kind" : "remoteSourceControl", + "location" : "https://github.com/kareman/SwiftShell", + "state" : { + "revision" : "99680b2efc7c7dbcace1da0b3979d266f02e213c", + "version" : "5.1.0" + } } ], "version" : 2 diff --git a/Easydict/Feature/PerferenceWindow/EZSettingViewController.m b/Easydict/Feature/PerferenceWindow/EZSettingViewController.m index 2f19f8bb0..b2f937614 100644 --- a/Easydict/Feature/PerferenceWindow/EZSettingViewController.m +++ b/Easydict/Feature/PerferenceWindow/EZSettingViewController.m @@ -772,20 +772,22 @@ - (void)updateViewConstraints { [self.fontSizeLabel mas_remakeConstraints:^(MASConstraintMaker *make) { make.right.equalTo(self.autoGetSelectedTextLabel); - make.top.equalTo(self.showAppleDictionaryQuickLinkButton.mas_bottom).offset(self.verticalPadding); + make.top.equalTo(self.showAppleDictionaryQuickLinkButton.mas_bottom).offset(20); }]; + CGFloat changeFontSizeViewWidth = 200; [self.changeFontSizeView mas_remakeConstraints:^(MASConstraintMaker *make) { make.left.equalTo(self.fontSizeLabel.mas_right).offset(self.horizontalPadding + 2); make.centerY.equalTo(self.fontSizeLabel); - make.width.mas_equalTo(200); + make.width.mas_equalTo(changeFontSizeViewWidth); make.height.mas_equalTo(30); }]; [self.fontSizeHintView mas_remakeConstraints:^(MASConstraintMaker *make) { make.left.equalTo(self.fontSizeLabel.mas_right).offset(self.horizontalPadding); - make.top.equalTo(self.changeFontSizeView.mas_bottom).mas_offset(5); - make.width.mas_equalTo(300); + make.top.equalTo(self.changeFontSizeView.mas_bottom).mas_offset(8); + make.width.mas_equalTo(changeFontSizeViewWidth + 5); + make.height.mas_equalTo(45); }]; [self.separatorView2 mas_remakeConstraints:^(MASConstraintMaker *make) { diff --git a/Easydict/Feature/Service/Model/EZError.h b/Easydict/Feature/Service/Model/EZError.h index 5db19f83f..2ca7238f2 100644 --- a/Easydict/Feature/Service/Model/EZError.h +++ b/Easydict/Feature/Service/Model/EZError.h @@ -20,7 +20,8 @@ extern NSString *const EZTranslateErrorRequestResponseKey; extern NSString *const EZTranslateErrorRequestErrorKey; typedef NS_ENUM(NSUInteger, EZErrorType) { - EZErrorTypeNone, + EZErrorTypeNone, // 预留参数,暂未使用 + EZErrorTypeAPI, // 接口异常 EZErrorTypeParam, // 参数异常 EZErrorTypeNetwork, // 网络异常 diff --git a/Easydict/Feature/Service/Model/EZError.m b/Easydict/Feature/Service/Model/EZError.m index b560b9ed9..51d3daa95 100644 --- a/Easydict/Feature/Service/Model/EZError.m +++ b/Easydict/Feature/Service/Model/EZError.m @@ -58,7 +58,7 @@ + (instancetype)errorWithType:(EZErrorType)type NSString *errorString = nil; switch (type) { case EZErrorTypeNone: - errorString = @""; + errorString = @"None"; break; case EZErrorTypeParam: errorString = NSLocalizedString(@"error_parameter", nil); diff --git a/Easydict/Feature/ViewController/View/ChangeFontSizeView/FontSizeHintView.swift b/Easydict/Feature/ViewController/View/ChangeFontSizeView/FontSizeHintView.swift index 666242fcd..762d69518 100644 --- a/Easydict/Feature/ViewController/View/ChangeFontSizeView/FontSizeHintView.swift +++ b/Easydict/Feature/ViewController/View/ChangeFontSizeView/FontSizeHintView.swift @@ -8,6 +8,8 @@ import AppKit import Foundation +import Hue +import SnapKit @objc public class FontSizeHintView: NSView { private lazy var minLabel: NSTextField = .init(labelWithString: NSLocalizedString("small", comment: "")) @@ -21,42 +23,25 @@ import Foundation minLabel.font = .systemFont(ofSize: 10) maxLabel.font = .systemFont(ofSize: 14) - hintLabel.font = .systemFont(ofSize: 11) + hintLabel.textColor = NSColor(hex: "7B7C7C") - let sizeLabelStackView: NSStackView = { - let stackView = NSStackView(views: [minLabel, maxLabel]) - stackView.alignment = .centerY - stackView.distribution = .equalSpacing - stackView.orientation = .horizontal - return stackView - }() - - let verticalStackView: NSStackView = { - let stackView = NSStackView(views: [sizeLabelStackView, hintLabel]) - stackView.alignment = .left - stackView.distribution = .fill - stackView.orientation = .vertical - stackView.spacing = 12 - return stackView - }() - - addSubview(verticalStackView) + addSubview(minLabel) + addSubview(maxLabel) + addSubview(hintLabel) - NSLayoutConstraint.activate([ - sizeLabelStackView.widthAnchor.constraint(equalToConstant: 205), - sizeLabelStackView.heightAnchor.constraint(equalToConstant: 20), - ]) + hintLabel.snp.makeConstraints { make in + make.left.bottom.equalTo(self) + } - NSLayoutConstraint.activate([ - verticalStackView.leftAnchor.constraint(equalTo: leftAnchor), - verticalStackView.topAnchor.constraint(equalTo: topAnchor), - verticalStackView.rightAnchor.constraint(equalTo: rightAnchor), - ]) + maxLabel.snp.makeConstraints { make in + make.right.top.equalTo(self) + } - NSLayoutConstraint.activate([ - bottomAnchor.constraint(equalTo: verticalStackView.bottomAnchor), - ]) + minLabel.snp.makeConstraints { make in + make.left.equalTo(self) + make.centerY.equalTo(maxLabel) + } } @available(*, unavailable)