From aeecca126095c672f57f083d34cdceb9bb50c8b1 Mon Sep 17 00:00:00 2001
From: CJKmkp <2564608840@qq.com>
Date: Sat, 7 Feb 2026 11:37:33 +0800
Subject: [PATCH] =?UTF-8?q?add:Dlass=E9=81=A5=E6=B5=8B?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
Ink Canvas/InkCanvasForClass.csproj | 5 +--
Ink Canvas/MainWindow_cs/MW_Settings.cs | 31 ++++++++++++-------
.../Windows/PrivacyAgreementWindow.xaml.cs | 26 +++++++++++-----
privacy.txt => Ink Canvas/privacy.txt | 0
4 files changed, 39 insertions(+), 23 deletions(-)
rename privacy.txt => Ink Canvas/privacy.txt (100%)
diff --git a/Ink Canvas/InkCanvasForClass.csproj b/Ink Canvas/InkCanvasForClass.csproj
index 38b71f56..f874d6e0 100644
--- a/Ink Canvas/InkCanvasForClass.csproj
+++ b/Ink Canvas/InkCanvasForClass.csproj
@@ -298,10 +298,7 @@
-
- privacy.txt
- PreserveNewest
-
+
diff --git a/Ink Canvas/MainWindow_cs/MW_Settings.cs b/Ink Canvas/MainWindow_cs/MW_Settings.cs
index 05a154af..fdaef052 100644
--- a/Ink Canvas/MainWindow_cs/MW_Settings.cs
+++ b/Ink Canvas/MainWindow_cs/MW_Settings.cs
@@ -6,6 +6,7 @@ using System;
using System.Diagnostics;
using System.IO;
using System.Net.Http;
+using System.Reflection;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
@@ -35,6 +36,23 @@ namespace Ink_Canvas
private bool _isChangingTelemetryInternally;
private bool _isChangingTelemetryPrivacyInternally;
+ private static bool PrivacyFileExists()
+ {
+ try
+ {
+ var assembly = Assembly.GetExecutingAssembly();
+ var resourceName = "Ink_Canvas.privacy.txt";
+ using (Stream stream = assembly.GetManifestResourceStream(resourceName))
+ {
+ return stream != null;
+ }
+ }
+ catch
+ {
+ return false;
+ }
+ }
+
private void CheckUpdateChannelAndTelemetryConsistency()
{
var currentChannel = Settings.Startup.UpdateChannel;
@@ -59,13 +77,7 @@ namespace Ink_Canvas
{
try
{
- string privacyPath = Path.Combine(App.RootPath, "privacy.txt");
- if (!File.Exists(privacyPath))
- {
- privacyPath = Path.Combine(App.RootPath, "privacy");
- }
-
- if (!File.Exists(privacyPath))
+ if (!PrivacyFileExists())
{
MessageBox.Show(
"未找到隐私说明文件(privacy.txt 或 privacy)。\n\n将切换回正式通道。",
@@ -330,10 +342,7 @@ namespace Ink_Canvas
if (isChecked)
{
- string pathTxt = System.IO.Path.Combine(App.RootPath, "privacy.txt");
- string pathNoExt = System.IO.Path.Combine(App.RootPath, "privacy");
-
- if (!System.IO.File.Exists(pathTxt) && !System.IO.File.Exists(pathNoExt))
+ if (!PrivacyFileExists())
{
MessageBox.Show(
"未找到隐私说明文件(privacy / privacy.txt),暂时无法启用匿名使用数据上传。",
diff --git a/Ink Canvas/Windows/PrivacyAgreementWindow.xaml.cs b/Ink Canvas/Windows/PrivacyAgreementWindow.xaml.cs
index ec94c9f6..fff99cd2 100644
--- a/Ink Canvas/Windows/PrivacyAgreementWindow.xaml.cs
+++ b/Ink Canvas/Windows/PrivacyAgreementWindow.xaml.cs
@@ -2,6 +2,7 @@ using Ink_Canvas.Helpers;
using System;
using System.ComponentModel;
using System.IO;
+using System.Reflection;
using System.Runtime.InteropServices;
using System.Windows;
using System.Windows.Controls;
@@ -73,21 +74,30 @@ namespace Ink_Canvas
}), DispatcherPriority.Loaded);
string privacyText = null;
- string pathTxt = Path.Combine(App.RootPath, "privacy.txt");
- string pathNoExt = Path.Combine(App.RootPath, "privacy");
-
- if (File.Exists(pathTxt))
+
+ try
{
- privacyText = File.ReadAllText(pathTxt, System.Text.Encoding.UTF8);
+ var assembly = Assembly.GetExecutingAssembly();
+ var resourceName = "Ink_Canvas.privacy.txt";
+ using (Stream stream = assembly.GetManifestResourceStream(resourceName))
+ {
+ if (stream != null)
+ {
+ using (StreamReader reader = new StreamReader(stream, System.Text.Encoding.UTF8))
+ {
+ privacyText = reader.ReadToEnd();
+ }
+ }
+ }
}
- else if (File.Exists(pathNoExt))
+ catch (Exception ex)
{
- privacyText = File.ReadAllText(pathNoExt, System.Text.Encoding.UTF8);
+ LogHelper.WriteLogToFile($"读取隐私说明失败: {ex.Message}", LogHelper.LogType.Warning);
}
if (string.IsNullOrWhiteSpace(privacyText))
{
- privacyText = "未找到隐私说明文件(privacy.txt 或 privacy)。";
+ privacyText = "未找到隐私说明文件(privacy.txt)。";
}
TextBoxPrivacyContent.Text = privacyText;
diff --git a/privacy.txt b/Ink Canvas/privacy.txt
similarity index 100%
rename from privacy.txt
rename to Ink Canvas/privacy.txt