Skip to content

Commit 0344ad9

Browse files
committed
打包方式更改
1 parent 9851bcd commit 0344ad9

File tree

9 files changed

+66
-65
lines changed

9 files changed

+66
-65
lines changed

App.xaml.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
using System.IO;
1313
using System.Text.Json;
1414
using System.Text.Json.Nodes;
15-
using Windows.Storage;
1615

1716

1817
namespace Edge
@@ -29,7 +28,7 @@ public partial class App : Application
2928
public App()
3029
{
3130
this.InitializeComponent();
32-
searchEngine = new("ms-appx:///Assets/words.txt");
31+
searchEngine = new("./Assets/words.txt");
3332
EnsureWebView2Async();
3433
}
3534

@@ -45,7 +44,7 @@ public static MainWindow CreateNewWindow()
4544
window.Closed += (sender, e) =>
4645
{
4746
mainWindows.Remove(window);
48-
File.WriteAllText(ApplicationData.Current.LocalFolder.Path + "/settings.json", settings.ToJsonString(new JsonSerializerOptions { WriteIndented = true }));
47+
File.WriteAllText("./settings.json", settings.ToJsonString(new JsonSerializerOptions { WriteIndented = true }));
4948
};
5049
mainWindows.Add(window);
5150
return window;

Assets/version.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
1.9.6.0

Controls/SearchEngine.cs

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
using System;
2-
using System.Collections.Generic;
3-
using Windows.Storage;
1+
using System.Collections.Generic;
2+
using System.IO;
43

54
namespace Edge
65
{
@@ -87,13 +86,12 @@ public class WordSearchEngine
8786
public WordSearchEngine(string filePath)
8887
{
8988
trie = new Trie();
90-
LoadWordsAsync(filePath);
89+
LoadWords(filePath);
9190
}
9291

93-
private async void LoadWordsAsync(string filePath)
92+
private void LoadWords(string filePath)
9493
{
95-
var file = await StorageFile.GetFileFromApplicationUriAsync(new Uri(filePath));
96-
var words = await FileIO.ReadLinesAsync(file);
94+
var words = File.ReadAllLines(filePath);
9795

9896
foreach (var word in words)
9997
{

Data/LoadData.cs

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
33
using System.IO;
44
using System.Linq;
55
using System.Text.Json;
6-
using Windows.ApplicationModel;
7-
using Windows.Storage;
86

97
namespace Edge.Data
108
{
@@ -17,31 +15,25 @@ public class WebsiteInfo
1715

1816
public static class Info
1917
{
20-
public static JsonDocument LanguageDict = JsonDocument.Parse(ReadPackageFileText("/Data/LanguageType.json"));
21-
public static JsonDocument ImageDict = JsonDocument.Parse(ReadPackageFileText("/Data/ImageType.json"));
22-
public static List<WebsiteInfo> SearchEngineList = JsonDocument.Parse(ReadPackageFileText("/Data/SearchEngine.json"))!.RootElement.EnumerateArray().Select(x => new WebsiteInfo()
18+
public static JsonDocument LanguageDict = JsonDocument.Parse(File.ReadAllText("./Data/LanguageType.json"));
19+
public static JsonDocument ImageDict = JsonDocument.Parse(File.ReadAllText("./Data/ImageType.json"));
20+
public static List<WebsiteInfo> SearchEngineList = JsonDocument.Parse(File.ReadAllText("./Data/SearchEngine.json"))!.RootElement.EnumerateArray().Select(x => new WebsiteInfo()
2321
{
2422
Name = x.GetProperty("Name").GetString(),
2523
Icon = x.GetProperty("Icon").GetString(),
2624
Uri = x.GetProperty("Uri").GetString()
2725
}).ToList();
28-
public static ObservableCollection<WebsiteInfo> SuggestWebsiteList = new(JsonDocument.Parse(ReadPackageFileText("/Data/SuggestWebsite.json"))!.RootElement.EnumerateArray().Select(x => new WebsiteInfo()
26+
public static ObservableCollection<WebsiteInfo> SuggestWebsiteList = new(JsonDocument.Parse(File.ReadAllText("./Data/SuggestWebsite.json"))!.RootElement.EnumerateArray().Select(x => new WebsiteInfo()
2927
{
3028
Name = x.GetProperty("Name").GetString(),
3129
Icon = x.GetProperty("Icon").GetString(),
3230
Uri = x.GetProperty("Uri").GetString()
3331
}));
3432

35-
public static string ReadPackageFileText(string path)
36-
{
37-
return File.ReadAllText(Package.Current.InstalledPath + path);
38-
}
39-
4033
public static string CheckUserSettingData()
4134
{
42-
string localFolder = ApplicationData.Current.LocalFolder.Path;
43-
string settingsFile = localFolder + "/settings.json";
44-
string defaultSettingsPath = Package.Current.InstalledPath + "/Data/DefaultSettings.json";
35+
string settingsFile = "./settings.json";
36+
string defaultSettingsPath = "./Data/DefaultSettings.json";
4537

4638
if (!File.Exists(settingsFile))
4739
{

Edge.csproj

Lines changed: 26 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,15 @@
33
<OutputType>WinExe</OutputType>
44
<TargetFramework>net9.0-windows10.0.26100.0</TargetFramework>
55
<TargetPlatformMinVersion>10.0.19041.0</TargetPlatformMinVersion>
6-
<WindowsSdkPackageVersion>10.0.26100.57</WindowsSdkPackageVersion>
76
<RootNamespace>Edge</RootNamespace>
87
<ApplicationManifest>app.manifest</ApplicationManifest>
9-
<Platforms>x86;x64;ARM64</Platforms>
10-
<RuntimeIdentifiers>win-x86;win-x64;win-arm64</RuntimeIdentifiers>
8+
<Platforms>x64</Platforms>
9+
<RuntimeIdentifiers>win-x64</RuntimeIdentifiers>
1110
<PublishProfile>win-$(Platform).pubxml</PublishProfile>
1211
<UseWinUI>true</UseWinUI>
1312
<EnableMsixTooling>true</EnableMsixTooling>
14-
<DefaultLanguage>zh-hans-cn</DefaultLanguage>
15-
<GenerateAppInstallerFile>False</GenerateAppInstallerFile>
13+
<WindowsPackageType>None</WindowsPackageType>
14+
<WindowsAppSDKSelfContained>true</WindowsAppSDKSelfContained>
1615
</PropertyGroup>
1716
<ItemGroup>
1817
<COMReference Include="IWshRuntimeLibrary">
@@ -34,7 +33,15 @@
3433
<Content Include="Assets\Square44x44Logo.targetsize-24_altform-unplated.png" />
3534
<Content Include="Assets\StoreLogo.png" />
3635
<Content Include="Assets\Wide310x150Logo.scale-200.png" />
37-
<Content Include="Data" />
36+
<Content Include="Data\*.json" />
37+
</ItemGroup>
38+
<ItemGroup>
39+
<None Update="Assets\**">
40+
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
41+
</None>
42+
<None Update="Data\*.json">
43+
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
44+
</None>
3845
</ItemGroup>
3946

4047
<ItemGroup>
@@ -50,7 +57,7 @@
5057
<Manifest Include="$(ApplicationManifest)" />
5158
</ItemGroup>
5259

53-
<!--
60+
<!--
5461
Defining the "Msix" ProjectCapability here allows the Single-project MSIX Packaging
5562
Tools extension to be activated for this project even if the Windows App SDK Nuget
5663
package has not yet been restored.
@@ -59,12 +66,20 @@
5966
<ProjectCapability Include="Msix" />
6067
</ItemGroup>
6168

62-
<!--
63-
Defining the "HasPackageAndPublishMenuAddedByProject" property here allows the Solution
64-
Explorer "Package and Publish" context menu entry to be enabled for this project even if
69+
<!--
70+
Defining the "HasPackageAndPublishMenuAddedByProject" property here allows the Solution
71+
Explorer "Package and Publish" context menu entry to be enabled for this project even if
6572
the Windows App SDK Nuget package has not yet been restored.
6673
-->
6774
<PropertyGroup Condition="'$(DisableHasPackageAndPublishMenuAddedByProject)'!='true' and '$(EnableMsixTooling)'=='true'">
6875
<HasPackageAndPublishMenu>true</HasPackageAndPublishMenu>
6976
</PropertyGroup>
70-
</Project>
77+
78+
<!-- Publish Properties -->
79+
<PropertyGroup>
80+
<PublishReadyToRun Condition="'$(Configuration)' == 'Debug'">False</PublishReadyToRun>
81+
<PublishReadyToRun Condition="'$(Configuration)' != 'Debug'">True</PublishReadyToRun>
82+
<PublishTrimmed Condition="'$(Configuration)' == 'Debug'">False</PublishTrimmed>
83+
<PublishTrimmed Condition="'$(Configuration)' != 'Debug'">True</PublishTrimmed>
84+
</PropertyGroup>
85+
</Project>

Edge.sln

Lines changed: 20 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11

22
Microsoft Visual Studio Solution File, Format Version 12.00
33
# Visual Studio Version 17
4-
VisualStudioVersion = 17.9.34321.82
4+
VisualStudioVersion = 17.12.35527.113 d17.12
55
MinimumVisualStudioVersion = 10.0.40219.1
6-
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Edge", "Edge.csproj", "{C32358B2-54D7-4FE1-BC8F-1BEA99FDABE8}"
6+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Edge", "Edge.csproj", "{155647E7-C9ED-449E-8208-32AEB5250DE7}"
77
EndProject
88
Global
99
GlobalSection(SolutionConfigurationPlatforms) = preSolution
@@ -15,29 +15,26 @@ Global
1515
Release|x86 = Release|x86
1616
EndGlobalSection
1717
GlobalSection(ProjectConfigurationPlatforms) = postSolution
18-
{C32358B2-54D7-4FE1-BC8F-1BEA99FDABE8}.Debug|ARM64.ActiveCfg = Debug|ARM64
19-
{C32358B2-54D7-4FE1-BC8F-1BEA99FDABE8}.Debug|ARM64.Build.0 = Debug|ARM64
20-
{C32358B2-54D7-4FE1-BC8F-1BEA99FDABE8}.Debug|ARM64.Deploy.0 = Debug|ARM64
21-
{C32358B2-54D7-4FE1-BC8F-1BEA99FDABE8}.Debug|x64.ActiveCfg = Debug|x64
22-
{C32358B2-54D7-4FE1-BC8F-1BEA99FDABE8}.Debug|x64.Build.0 = Debug|x64
23-
{C32358B2-54D7-4FE1-BC8F-1BEA99FDABE8}.Debug|x64.Deploy.0 = Debug|x64
24-
{C32358B2-54D7-4FE1-BC8F-1BEA99FDABE8}.Debug|x86.ActiveCfg = Debug|x86
25-
{C32358B2-54D7-4FE1-BC8F-1BEA99FDABE8}.Debug|x86.Build.0 = Debug|x86
26-
{C32358B2-54D7-4FE1-BC8F-1BEA99FDABE8}.Debug|x86.Deploy.0 = Debug|x86
27-
{C32358B2-54D7-4FE1-BC8F-1BEA99FDABE8}.Release|ARM64.ActiveCfg = Release|ARM64
28-
{C32358B2-54D7-4FE1-BC8F-1BEA99FDABE8}.Release|ARM64.Build.0 = Release|ARM64
29-
{C32358B2-54D7-4FE1-BC8F-1BEA99FDABE8}.Release|ARM64.Deploy.0 = Release|ARM64
30-
{C32358B2-54D7-4FE1-BC8F-1BEA99FDABE8}.Release|x64.ActiveCfg = Release|x64
31-
{C32358B2-54D7-4FE1-BC8F-1BEA99FDABE8}.Release|x64.Build.0 = Release|x64
32-
{C32358B2-54D7-4FE1-BC8F-1BEA99FDABE8}.Release|x64.Deploy.0 = Release|x64
33-
{C32358B2-54D7-4FE1-BC8F-1BEA99FDABE8}.Release|x86.ActiveCfg = Release|x86
34-
{C32358B2-54D7-4FE1-BC8F-1BEA99FDABE8}.Release|x86.Build.0 = Release|x86
35-
{C32358B2-54D7-4FE1-BC8F-1BEA99FDABE8}.Release|x86.Deploy.0 = Release|x86
18+
{155647E7-C9ED-449E-8208-32AEB5250DE7}.Debug|ARM64.ActiveCfg = Debug|ARM64
19+
{155647E7-C9ED-449E-8208-32AEB5250DE7}.Debug|ARM64.Build.0 = Debug|ARM64
20+
{155647E7-C9ED-449E-8208-32AEB5250DE7}.Debug|ARM64.Deploy.0 = Debug|ARM64
21+
{155647E7-C9ED-449E-8208-32AEB5250DE7}.Debug|x64.ActiveCfg = Debug|x64
22+
{155647E7-C9ED-449E-8208-32AEB5250DE7}.Debug|x64.Build.0 = Debug|x64
23+
{155647E7-C9ED-449E-8208-32AEB5250DE7}.Debug|x64.Deploy.0 = Debug|x64
24+
{155647E7-C9ED-449E-8208-32AEB5250DE7}.Debug|x86.ActiveCfg = Debug|x86
25+
{155647E7-C9ED-449E-8208-32AEB5250DE7}.Debug|x86.Build.0 = Debug|x86
26+
{155647E7-C9ED-449E-8208-32AEB5250DE7}.Debug|x86.Deploy.0 = Debug|x86
27+
{155647E7-C9ED-449E-8208-32AEB5250DE7}.Release|ARM64.ActiveCfg = Release|ARM64
28+
{155647E7-C9ED-449E-8208-32AEB5250DE7}.Release|ARM64.Build.0 = Release|ARM64
29+
{155647E7-C9ED-449E-8208-32AEB5250DE7}.Release|ARM64.Deploy.0 = Release|ARM64
30+
{155647E7-C9ED-449E-8208-32AEB5250DE7}.Release|x64.ActiveCfg = Release|x64
31+
{155647E7-C9ED-449E-8208-32AEB5250DE7}.Release|x64.Build.0 = Release|x64
32+
{155647E7-C9ED-449E-8208-32AEB5250DE7}.Release|x64.Deploy.0 = Release|x64
33+
{155647E7-C9ED-449E-8208-32AEB5250DE7}.Release|x86.ActiveCfg = Release|x86
34+
{155647E7-C9ED-449E-8208-32AEB5250DE7}.Release|x86.Build.0 = Release|x86
35+
{155647E7-C9ED-449E-8208-32AEB5250DE7}.Release|x86.Deploy.0 = Release|x86
3636
EndGlobalSection
3737
GlobalSection(SolutionProperties) = preSolution
3838
HideSolutionNode = FALSE
3939
EndGlobalSection
40-
GlobalSection(ExtensibilityGlobals) = postSolution
41-
SolutionGuid = {AFF79988-D4E1-4BC7-89F1-B469233CA813}
42-
EndGlobalSection
4340
EndGlobal

MainWindow.xaml.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ private LRESULT MainWindowSubClassProc(HWND hWnd, uint Msg, WPARAM wParam, LPARA
222222
{
223223
ShowMode = FlyoutShowMode.Standard,
224224
Position = new Point(point.X, point.Y)
225-
};
225+
};
226226

227227
TitlebarMenuFlyout.ShowAt(Content, options);
228228
}

Package.appxmanifest

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<?xml version="1.0" encoding="utf-8"?>
1+
<?xml version="1.0" encoding="utf-8"?>
22

33
<Package
44
xmlns="http://schemas.microsoft.com/appx/manifest/foundation/windows10"
@@ -12,9 +12,9 @@
1212
<Identity
1313
Name="WinUIEdge"
1414
Publisher="CN=wtc"
15-
Version="1.9.5.0" />
15+
Version="1.0.0.0" />
1616

17-
<mp:PhoneIdentity PhoneProductId="b5d7d1fb-9979-4b08-b2b8-16be9f9b0673" PhonePublisherId="00000000-0000-0000-0000-000000000000"/>
17+
<mp:PhoneIdentity PhoneProductId="71ae8621-8427-46b0-9d28-e05e044bc12c" PhonePublisherId="00000000-0000-0000-0000-000000000000"/>
1818

1919
<Properties>
2020
<DisplayName>Edge</DisplayName>

Settings/AboutItem.xaml.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,19 @@
1-
using CommunityToolkit.WinUI.Helpers;
21
using Microsoft.UI.Xaml;
32
using Microsoft.UI.Xaml.Controls;
43
using Microsoft.Web.WebView2.Core;
54
using Microsoft.Windows.AppNotifications;
65
using Microsoft.Windows.AppNotifications.Builder;
6+
using System.IO;
77
using System.Net.Http;
88
using System.Net.Http.Headers;
99
using System.Text.Json;
10-
using Windows.ApplicationModel;
1110
using Windows.ApplicationModel.DataTransfer;
1211

1312
namespace Edge
1413
{
1514
public sealed partial class AboutItem : Page
1615
{
17-
public string appVersion = Package.Current.Id.Version.ToFormattedString();
16+
public string appVersion = File.ReadAllText("./Assets/version.txt");
1817
public string browserVersion = CoreWebView2Environment.GetAvailableBrowserVersionString();
1918

2019
public AboutItem()

0 commit comments

Comments
 (0)