Skip to content

Commit 89b909b

Browse files
committed
refactor: 更新内部逻辑
1 parent b569c6a commit 89b909b

1 file changed

Lines changed: 23 additions & 1 deletion

File tree

src/components/BootstrapBlazor.Region/Components/SelectRegion.razor.cs

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ protected override void OnParametersSet()
119119

120120
private void ResetValue()
121121
{
122-
if (!string.IsNullOrEmpty(Value))
122+
if (!string.IsNullOrEmpty(Value) && Value != GetCurrentValue())
123123
{
124124
var segments = Value.Split('-', StringSplitOptions.RemoveEmptyEntries);
125125
if (segments.Length > 0 && _provinceValue != segments[0] && GetProvinces().Contains(segments[0]))
@@ -153,6 +153,28 @@ private void ResetValue()
153153
}
154154
}
155155

156+
private string? GetCurrentValue()
157+
{
158+
string? value = null;
159+
if (!string.IsNullOrEmpty(_provinceValue))
160+
{
161+
value = _provinceValue;
162+
}
163+
if (!string.IsNullOrEmpty(_cityValue))
164+
{
165+
value = $"{_provinceValue}-{_cityValue}";
166+
}
167+
if (!string.IsNullOrEmpty(_countyValue.Name))
168+
{
169+
value = $"{_provinceValue}-{_cityValue}-{_countyValue.Name}";
170+
}
171+
if (!string.IsNullOrEmpty(_detailValue))
172+
{
173+
value = $"{_provinceValue}-{_cityValue}-{_countyValue.Name}-{_detailValue}";
174+
}
175+
return value;
176+
}
177+
156178
private async Task OnClearValue()
157179
{
158180
_provinceValue = "";

0 commit comments

Comments
 (0)