Compare commits

..

2 Commits

Author SHA1 Message Date
Zhang Dian
d164acea21 feat: enhance navigation and UI structure in MainView and Application. (#811)
* feat: enhance navigation and UI structure in MainView and Application.

* feat: implement singleton pattern for PaletteDemoViewModel and add initialization check

* feat: set FontWeight to Normal for navigation button in MainView

---------

Co-authored-by: Dong Bin <popmessiah@hotmail.com>
2026-04-24 19:58:27 +08:00
Copilot
1f10fd680f Add git commit message convention under .github (#789) 2026-04-24 14:48:16 +08:00
4 changed files with 103 additions and 5 deletions

92
.github/COMMIT_CONVENTION.md vendored Normal file
View File

@@ -0,0 +1,92 @@
# Git Commit Message Convention
This project follows the [Conventional Commits](https://www.conventionalcommits.org/) specification for commit messages.
## Format
```
<type>[optional scope]: <description>
[optional body]
[optional footer(s)]
```
## Types
| Type | Description |
|------|-------------|
| `feat` | A new feature |
| `fix` | A bug fix |
| `docs` | Documentation only changes |
| `style` | Changes that do not affect the meaning of the code (formatting, missing semicolons, etc.) |
| `refactor` | A code change that neither fixes a bug nor adds a feature |
| `perf` | A code change that improves performance |
| `test` | Adding missing tests or correcting existing tests |
| `build` | Changes that affect the build system or external dependencies |
| `ci` | Changes to CI configuration files and scripts |
| `chore` | Other changes that don't modify source or test files |
| `revert` | Reverts a previous commit |
## Rules
1. **Limit the subject line to 50 characters** (72 character hard limit)
2. **Use the imperative mood** in the subject line (e.g., "add feature" not "added feature")
3. **Do not end the subject line with a period**
4. **Use lowercase** for the description (e.g., "add feature" not "Add feature")
5. **Separate subject from body with a blank line**
6. **Wrap the body at 72 characters**
7. **Use the body to explain what and why**, not how
8. **Reference issues and pull requests** in the footer
## Scope
The scope should be the name of the package or area affected (e.g., `button`, `datepicker`, `theme`, `demo`).
## Examples
### Simple commit
```
feat(button): add loading state support
```
### Commit with body
```
fix(datepicker): correct month navigation overflow
When navigating past December, the month index wrapped to a
negative value instead of rolling over to January of the next year.
```
### Commit with breaking change
```
feat(theme)!: rename SemiColorPrimary to SemiColorBrand
BREAKING CHANGE: The token SemiColorPrimary has been renamed to
SemiColorBrand. Update all references in your custom theme files.
```
### Commit referencing an issue
```
fix(textbox): placeholder not visible in dark mode
Closes #123
```
## Breaking Changes
Breaking changes must be indicated by appending a `!` after the type/scope, or by including a `BREAKING CHANGE:` footer. Both methods may be used together.
## Revert Commits
When reverting a previous commit, use the `revert` type and reference the reverted commit SHA in the footer:
```
revert: feat(button): add loading state support
Revert commit a1b2c3d.
```

View File

@@ -12,14 +12,16 @@ public partial class PaletteDemo : UserControl
public PaletteDemo() public PaletteDemo()
{ {
InitializeComponent(); InitializeComponent();
this.DataContext = new PaletteDemoViewModel(); this.DataContext = PaletteDemoViewModel.Instance.Value;
} }
protected override async void OnApplyTemplate(TemplateAppliedEventArgs e) protected override async void OnApplyTemplate(TemplateAppliedEventArgs e)
{ {
base.OnApplyTemplate(e); base.OnApplyTemplate(e);
PaletteDemoViewModel? vm = this.DataContext as PaletteDemoViewModel; if (this.DataContext is PaletteDemoViewModel vm && !vm.IsInitialized)
await Dispatcher.UIThread.InvokeAsync(() => { vm?.InitializeResources(); }); {
await Dispatcher.UIThread.InvokeAsync(() => { vm?.InitializeResources(); });
}
} }
public async Task Copy(object? o) public async Task Copy(object? o)
@@ -31,4 +33,4 @@ public partial class PaletteDemo : UserControl
await c.SetTextAsync(o.ToString()); await c.SetTextAsync(o.ToString());
} }
} }
} }

View File

@@ -14,6 +14,8 @@ namespace Semi.Avalonia.Demo.ViewModels;
public partial class PaletteDemoViewModel : ObservableObject public partial class PaletteDemoViewModel : ObservableObject
{ {
public static Lazy<PaletteDemoViewModel> Instance { get; } = new(() => new PaletteDemoViewModel());
public bool IsInitialized { get; private set; }
private readonly string[] _predefinedColorNames = private readonly string[] _predefinedColorNames =
[ [
"Red", "Pink", "Purple", "Violet", "Indigo", "Red", "Pink", "Purple", "Violet", "Indigo",
@@ -44,6 +46,7 @@ public partial class PaletteDemoViewModel : ObservableObject
InitializePalette(); InitializePalette();
InitializeFunctionalColors(); InitializeFunctionalColors();
InitializeShadows(); InitializeShadows();
IsInitialized = true;
} }
private void InitializePalette() private void InitializePalette()
@@ -289,4 +292,4 @@ public partial class ShadowGroupViewModel : ObservableObject
} }
} }
} }
} }

View File

@@ -83,6 +83,7 @@
<Border Classes="NavItemHost" Classes.Selected="{Binding IsSelected}"> <Border Classes="NavItemHost" Classes.Selected="{Binding IsSelected}">
<Button <Button
Classes="NavItem" Classes="NavItem"
FontWeight="Normal"
Classes.Selected="{Binding IsSelected}" Classes.Selected="{Binding IsSelected}"
Command="{Binding NavigateCommand}" Command="{Binding NavigateCommand}"
CommandParameter="{Binding}" CommandParameter="{Binding}"