Skip to content

Commit da76b11

Browse files
committed
Merge branch 'avalonia' of https://github.com/SECTL/SecRandom into avalonia
2 parents 570224d + 9dee5fe commit da76b11

5 files changed

Lines changed: 33 additions & 18 deletions

File tree

.github/workflows/Build.yml

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -78,10 +78,10 @@ jobs:
7878
dotnet-quality: preview
7979

8080
- name: 还原依赖
81-
run: dotnet restore SecRandom.slnx
81+
run: dotnet restore SecRandom.sln
8282

8383
- name: 构建
84-
run: dotnet build SecRandom.slnx -c Release --no-restore
84+
run: dotnet build SecRandom.sln -c Release --no-restore
8585

8686
- name: 检测测试项目
8787
shell: bash
@@ -95,7 +95,7 @@ jobs:
9595
9696
- name: 运行测试
9797
if: env.HAS_TESTS == 'true'
98-
run: dotnet test SecRandom.slnx -c Release --no-build
98+
run: dotnet test SecRandom.sln -c Release --no-build
9999

100100
version:
101101
name: 解析版本
@@ -181,7 +181,7 @@ jobs:
181181

182182
- name: 发布
183183
run: >
184-
dotnet publish src/SecRandom.Avalonia/SecRandom.Avalonia.csproj
184+
dotnet publish SecRandom.Desktop/SecRandom.Desktop.csproj
185185
-c Release
186186
-r ${{ matrix.rid }}
187187
--self-contained true
@@ -222,11 +222,11 @@ jobs:
222222
mkdir -p "$pkgroot/usr/share/icons/hicolor/256x256/apps"
223223
224224
cp -a "artifacts/SecRandom-${{ matrix.rid }}/." "$pkgroot/usr/lib/secrandom/"
225-
chmod +x "$pkgroot/usr/lib/secrandom/SecRandom" || true
225+
chmod +x "$pkgroot/usr/lib/secrandom/SecRandom.Desktop" || true
226226
227227
cat > "$pkgroot/usr/bin/secrandom" << 'EOF'
228228
#!/bin/sh
229-
exec /usr/lib/secrandom/SecRandom "$@"
229+
exec /usr/lib/secrandom/SecRandom.Desktop "$@"
230230
EOF
231231
chmod +x "$pkgroot/usr/bin/secrandom"
232232
@@ -240,8 +240,8 @@ jobs:
240240
Terminal=false
241241
EOF
242242
243-
if [ -f "src/SecRandom.Avalonia/Assets/icon/secrandom-icon-paper.png" ]; then
244-
cp "src/SecRandom.Avalonia/Assets/icon/secrandom-icon-paper.png" "$pkgroot/usr/share/icons/hicolor/256x256/apps/secrandom.png"
243+
if [ -f "resources/secrandom-icon-paper.png" ]; then
244+
cp "resources/secrandom-icon-paper.png" "$pkgroot/usr/share/icons/hicolor/256x256/apps/secrandom.png"
245245
fi
246246
247247
cat > "$pkgroot/DEBIAN/control" << EOF
@@ -271,7 +271,7 @@ jobs:
271271
mkdir -p "$work/bundle/SecRandom.app/Contents/Resources"
272272
273273
cp -a "artifacts/SecRandom-${{ matrix.rid }}/." "$work/bundle/SecRandom.app/Contents/MacOS/"
274-
chmod +x "$work/bundle/SecRandom.app/Contents/MacOS/SecRandom" || true
274+
chmod +x "$work/bundle/SecRandom.app/Contents/MacOS/SecRandom.Desktop" || true
275275
276276
cat > "$work/bundle/SecRandom.app/Contents/Info.plist" << EOF
277277
<?xml version="1.0" encoding="UTF-8"?>
@@ -283,15 +283,15 @@ jobs:
283283
<key>CFBundleIdentifier</key><string>top.sectl.secrandom</string>
284284
<key>CFBundleVersion</key><string>${version_no_v}</string>
285285
<key>CFBundleShortVersionString</key><string>${version_no_v}</string>
286-
<key>CFBundleExecutable</key><string>SecRandom</string>
286+
<key>CFBundleExecutable</key><string>SecRandom.Desktop</string>
287287
<key>CFBundlePackageType</key><string>APPL</string>
288288
<key>LSMinimumSystemVersion</key><string>11.0</string>
289289
<key>CFBundleIconFile</key><string>AppIcon</string>
290290
</dict>
291291
</plist>
292292
EOF
293293
294-
icon_png="src/SecRandom.Avalonia/Assets/icon/secrandom-icon-paper.png"
294+
icon_png="resources/secrandom-icon-paper.png"
295295
if [ -f "$icon_png" ]; then
296296
iconset="$work/AppIcon.iconset"
297297
mkdir -p "$iconset"

SecRandom.Desktop/SecRandom.Desktop.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<Project Sdk="Microsoft.NET.Sdk">
1+
<Project Sdk="Microsoft.NET.Sdk">
22
<PropertyGroup>
33
<OutputType>Exe</OutputType>
44
<!--If you are willing to use platform-specific APIs, use conditional compilation.

SecRandom/App.axaml.cs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,16 +135,23 @@ public static void ShowMainWindow()
135135

136136
public static void ShowSettingsWindow()
137137
{
138+
if (SettingsWindow is { IsVisible: true })
139+
{
140+
SettingsWindow.Activate();
141+
return;
142+
}
143+
138144
if (SettingsWindow is not { IsLoaded: true })
139145
{
140146
SettingsWindow = new MainWindow
141147
{
142148
Content = IAppHost.GetService<SettingsView>(),
143149
Title = "SecRandom"
144150
};
151+
SettingsWindow.Closed += (_, _) => SettingsWindow = null;
145152
}
146153

147154
SettingsWindow.Show();
148155
SettingsWindow.Activate();
149156
}
150-
}
157+
}

SecRandom/Views/MainView.axaml.cs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ public MainView()
3333

3434
NavigationFrame.NavigationPageFactory = this;
3535
BuildNavigationMenuItems();
36+
SelectNavigationItemById(DefaultMainPageId);
3637

3738
RenderOptions.SetTextRenderingMode(this, TextRenderingMode.Antialias);
3839
RenderOptions.SetBitmapInterpolationMode(this, BitmapInterpolationMode.HighQuality);
@@ -41,7 +42,10 @@ public MainView()
4142

4243
private void OnLoaded(object? sender, RoutedEventArgs e)
4344
{
44-
SelectNavigationItemById(DefaultMainPageId);
45+
if (ViewModel.SelectedPageInfo is null)
46+
{
47+
SelectNavigationItemById(DefaultMainPageId);
48+
}
4549

4650
if (Content is not Control element || _isAdornerAdded)
4751
{
@@ -139,4 +143,4 @@ private void TogglePaneButton_OnClick(object? sender, RoutedEventArgs e)
139143

140144
return IAppHost.Host!.Services.GetKeyedService<UserControl>(info.Id);
141145
}
142-
}
146+
}

SecRandom/Views/SettingsView.axaml.cs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using System;
1+
using System;
22
using System.Linq;
33
using Avalonia.Controls;
44
using Avalonia.Controls.Primitives;
@@ -33,6 +33,7 @@ public SettingsView()
3333

3434
NavigationFrame.NavigationPageFactory = this;
3535
BuildNavigationMenuItems();
36+
SelectNavigationItemById(DefaultMainPageId);
3637

3738
RenderOptions.SetTextRenderingMode(this, TextRenderingMode.Antialias);
3839
RenderOptions.SetBitmapInterpolationMode(this, BitmapInterpolationMode.HighQuality);
@@ -41,7 +42,10 @@ public SettingsView()
4142

4243
private void OnLoaded(object? sender, RoutedEventArgs e)
4344
{
44-
SelectNavigationItemById(DefaultMainPageId);
45+
if (ViewModel.SelectedPageInfo is null)
46+
{
47+
SelectNavigationItemById(DefaultMainPageId);
48+
}
4549

4650
if (Content is not Control element || _isAdornerAdded)
4751
{
@@ -128,4 +132,4 @@ private void TogglePaneButton_OnClick(object? sender, RoutedEventArgs e)
128132

129133
return IAppHost.Host!.Services.GetKeyedService<UserControl>(info.Id);
130134
}
131-
}
135+
}

0 commit comments

Comments
 (0)