Skip to content

Commit

Permalink
feat: 1.3.1 Build 7 support iCloud sync
Browse files Browse the repository at this point in the history
  • Loading branch information
bin64 committed Jan 16, 2025
1 parent 21f9e00 commit 00f529c
Show file tree
Hide file tree
Showing 8 changed files with 613 additions and 7 deletions.
8 changes: 4 additions & 4 deletions Clash Dash.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -540,7 +540,7 @@
"$(inherited)",
"@executable_path/Frameworks",
);
MARKETING_VERSION = 1.3.1;
MARKETING_VERSION = 1.3.2;
PRODUCT_BUNDLE_IDENTIFIER = ym.si.clashdash;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
Expand Down Expand Up @@ -576,7 +576,7 @@
"$(inherited)",
"@executable_path/Frameworks",
);
MARKETING_VERSION = 1.3.1;
MARKETING_VERSION = 1.3.2;
PRODUCT_BUNDLE_IDENTIFIER = ym.si.clashdash;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
Expand Down Expand Up @@ -678,7 +678,7 @@
"@executable_path/Frameworks",
"@executable_path/../../Frameworks",
);
MARKETING_VERSION = 1.3.1;
MARKETING_VERSION = 1.3.2;
PRODUCT_BUNDLE_IDENTIFIER = ym.si.clashdash.WidgetExtension;
PRODUCT_NAME = "$(TARGET_NAME)";
SKIP_INSTALL = YES;
Expand Down Expand Up @@ -708,7 +708,7 @@
"@executable_path/Frameworks",
"@executable_path/../../Frameworks",
);
MARKETING_VERSION = 1.3.1;
MARKETING_VERSION = 1.3.2;
PRODUCT_BUNDLE_IDENTIFIER = ym.si.clashdash.WidgetExtension;
PRODUCT_NAME = "$(TARGET_NAME)";
SKIP_INSTALL = YES;
Expand Down
10 changes: 10 additions & 0 deletions Clash Dash/Clash Dash.entitlements
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,16 @@
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>aps-environment</key>
<string>development</string>
<key>com.apple.developer.icloud-container-identifiers</key>
<array>
<string>iCloud.ym.si.clashdash</string>
</array>
<key>com.apple.developer.icloud-services</key>
<array>
<string>CloudKit</string>
</array>
<key>com.apple.developer.networking.networkextension</key>
<array/>
<key>com.apple.developer.networking.wifi-info</key>
Expand Down
25 changes: 23 additions & 2 deletions Clash Dash/Models/WiFiBinding.swift
Original file line number Diff line number Diff line change
Expand Up @@ -26,21 +26,42 @@ class WiFiBindingManager: ObservableObject {
private let storageKey = "wifi_bindings"
private let enableKey = "enableWiFiBinding"
private let defaultServersKey = "default_servers"
private var notificationObserver: NSObjectProtocol?

var isEnabled: Bool {
get { defaults.bool(forKey: enableKey) }
}

init() {
// print("🏁 初始化 WiFiBindingManager")
logger.log("初始化 WiFiBindingManager")
if isEnabled {
loadBindings()
loadDefaultServers()
} else {
// print("⚠️ Wi-Fi 绑定功能未启用,跳过加载绑定数据")
logger.log("Wi-Fi 绑定功能未启用,跳过加载绑定数据")
}

// 添加通知监听
notificationObserver = NotificationCenter.default.addObserver(
forName: NSNotification.Name("WiFiBindingsUpdated"),
object: nil,
queue: .main
) { [weak self] _ in
logger.log("收到 WiFi 绑定更新通知")
guard let self = self else { return }
if self.isEnabled {
self.loadBindings()
self.loadDefaultServers()
self.objectWillChange.send()
}
}
}

deinit {
// 移除通知监听
if let observer = notificationObserver {
NotificationCenter.default.removeObserver(observer)
}
}

private func loadBindings() {
Expand Down
Loading

0 comments on commit 00f529c

Please sign in to comment.