Revert "feat: 优化页签自动切换逻辑"

This reverts commit de7a4ed8a5.
This commit is contained in:
status102
2026-03-20 09:15:09 +08:00
parent 30a5022217
commit 7af62e606f
7 changed files with 19 additions and 102 deletions

View File

@@ -1061,11 +1061,8 @@ Right-click to clear inactive jobs</system:String>
<system:String x:Key="CopilotCouldNotSaveFile" xml:space="preserve">Could not save copilot task to file: </system:String>
<system:String x:Key="CopilotStartWithEmptyList">Using 「{key=UseCopilotList}」, but no tasks have been added</system:String>
<system:String x:Key="CopilotSingleTaskWarning">You're using 「{key=UseCopilotList}」 to execute a single task, which is not recommended. For single tasks, please run them directly instead.</system:String>
<system:String x:Key="CopilotTaskListMixedModeNotAllowed">Currently using 「{key=UseCopilotList}」. Mixing different job types is not supported: {0}. Clear the list and re-add tasks under the same tab.</system:String>
<system:String x:Key="CopilotTaskListLegacyItemNotSupported">Currently using 「{key=UseCopilotList}」, but the list contains legacy items without tab info. Re-add those tasks under the correct tab before starting.</system:String>
<system:String x:Key="CopilotTaskListTabMismatch">Currently using 「{key=UseCopilotList}」. The current tab is "{0}", but the list belongs to "{1}". Switch to the matching tab before starting.</system:String>
<system:String x:Key="CopilotTaskListMixedModeNotAllowed">Currently using 「{key=UseCopilotList}」. Mixing different job types is not supported.</system:String>
<system:String x:Key="CopilotTaskTypeParseFailedSkipCheck">Failed to parse some job types. Skipping type checks.</system:String>
<system:String x:Key="CopilotTaskTypeParseFailedKeepCurrentTab">Failed to determine the job type. Keeping the current tab for import.</system:String>
<!-- !Logs -->
<!-- !Copilot -->
<!-- ErrorView -->

View File

@@ -1062,11 +1062,8 @@ C:\\leidian\\LDPlayer9
<system:String x:Key="CopilotCouldNotSaveFile" xml:space="preserve">コパイロットタスクをファイルに保存できませんでした: </system:String>
<system:String x:Key="CopilotStartWithEmptyList">タスクなしで「{key=UseCopilotList}」を使用した</system:String>
<system:String x:Key="CopilotSingleTaskWarning">「{key=UseCopilotList}」を使用して単一ジョブを実行しています。これは推奨されません。単一ジョブを直接実行してください。</system:String>
<system:String x:Key="CopilotTaskListMixedModeNotAllowed">「{key=UseCopilotList}」を使用中ですが、異なるジョブタイプの混在はサポートされていません: {0}。リストをクリアして、同じタブでジョブを再追加してください。</system:String>
<system:String x:Key="CopilotTaskListLegacyItemNotSupported">「{key=UseCopilotList}」を使用中ですが、リストにタブ情報のない旧バージョン項目が含まれています。正しいタブでこれらのジョブを再追加してから起動してください。</system:String>
<system:String x:Key="CopilotTaskListTabMismatch">「{key=UseCopilotList}」を使用中です。現在のタブは「{0}」ですが、リストは「{1}」のものです。対応するタブに切り替えてから起動してください。</system:String>
<system:String x:Key="CopilotTaskListMixedModeNotAllowed">「{key=UseCopilotList}」を使用中ですが、異なるジョブタイプの混在はサポートされていません。</system:String>
<system:String x:Key="CopilotTaskTypeParseFailedSkipCheck">一部のジョブタイプの解析に失敗しました。タイプチェックをスキップします。</system:String>
<system:String x:Key="CopilotTaskTypeParseFailedKeepCurrentTab">ジョブタイプを判定できなかったため、現在のタブのままインポートします。</system:String>
<!-- !Logs -->
<!-- !Copilot -->
<!-- ErrorView -->

View File

@@ -1063,11 +1063,8 @@ C:\\leidian\\LDPlayer9
<system:String x:Key="CopilotCouldNotSaveFile" xml:space="preserve">부조종사 작업을 파일에 저장할 수 없습니다.: </system:String>
<system:String x:Key="CopilotStartWithEmptyList">작업 없이 「{key=UseCopilotList}」를 사용 중입니다.</system:String>
<system:String x:Key="CopilotSingleTaskWarning">「{key=UseCopilotList}」를 사용하여 단일 작업을 실행하는 것은 권장되지 않습니다. 단일 작업은 직접 실행해 주세요.</system:String>
<system:String x:Key="CopilotTaskListMixedModeNotAllowed">현재 「{key=UseCopilotList}」를 사용 중입니다. 서로 다른 작업 유형을 혼합하는 것은 지원되지 않습니다: {0}. 목록을 비운 뒤 같은 탭에서 다시 추가하세요.</system:String>
<system:String x:Key="CopilotTaskListLegacyItemNotSupported">현재 「{key=UseCopilotList}」를 사용 중이지만 목록에 탭 정보가 없는 구버전 항목이 포함되어 있습니다. 올바른 탭에서 해당 작업을 다시 추가한 뒤 시작하세요.</system:String>
<system:String x:Key="CopilotTaskListTabMismatch">현재 「{key=UseCopilotList}」를 사용 중입니다. 현재 탭은 "{0}"이지만 목록은 "{1}"에 속합니다. 해당 탭으로 전환한 뒤 시작하세요.</system:String>
<system:String x:Key="CopilotTaskListMixedModeNotAllowed">현재 「{key=UseCopilotList}」를 사용 중입니다. 서로 다른 작업 유형을 혼합하는 것은 지원되지 않습니다.</system:String>
<system:String x:Key="CopilotTaskTypeParseFailedSkipCheck">일부 작업 유형을 해석하지 못했습니다. 유형 검사를 건너뜁니다.</system:String>
<system:String x:Key="CopilotTaskTypeParseFailedKeepCurrentTab">작업 유형을 판단할 수 없어 현재 탭을 유지한 채 가져옵니다.</system:String>
<!-- !Logs -->
<!-- !Copilot -->
<!-- ErrorView -->

View File

@@ -1062,11 +1062,8 @@ C:\\leidian\\LDPlayer9。\n
<system:String x:Key="CopilotCouldNotSaveFile" xml:space="preserve">无法保存作业文件到: </system:String>
<system:String x:Key="CopilotStartWithEmptyList">正在使用 「{key=UseCopilotList}」, 但未添加任何作业</system:String>
<system:String x:Key="CopilotSingleTaskWarning">正在使用 「{key=UseCopilotList}」 执行单个作业, 不推荐此行为。 单个作业请直接运行</system:String>
<system:String x:Key="CopilotTaskListMixedModeNotAllowed">正在使用 「{key=UseCopilotList}」,不支持混用不同类型作业{0}。请清空列表后在同一页签重新添加</system:String>
<system:String x:Key="CopilotTaskListLegacyItemNotSupported">正在使用 「{key=UseCopilotList}」,但列表包含旧版本条目(缺少页签信息),请在正确的页签重新添加这些作业后再启动</system:String>
<system:String x:Key="CopilotTaskListTabMismatch">正在使用 「{key=UseCopilotList}」,当前页签为「{0}」,但列表来自「{1}」,请切换到对应页签后再启动</system:String>
<system:String x:Key="CopilotTaskListMixedModeNotAllowed">正在使用 「{key=UseCopilotList}」,不支持混用不同类型作业</system:String>
<system:String x:Key="CopilotTaskTypeParseFailedSkipCheck">部分作业类型解析失败,跳过类型检查</system:String>
<system:String x:Key="CopilotTaskTypeParseFailedKeepCurrentTab">无法判断作业类型,将保持当前页签导入</system:String>
<!-- !日志 -->
<!-- !自动战斗 -->
<!-- ErrorDialogView -->

View File

@@ -1062,11 +1062,8 @@ C:\\leidian\\LDPlayer9\n
<system:String x:Key="CopilotCouldNotSaveFile" xml:space="preserve">無法儲存作業檔案至:</system:String>
<system:String x:Key="CopilotStartWithEmptyList">正在使用 「{key=UseCopilotList}」,但未新增任何作業</system:String>
<system:String x:Key="CopilotSingleTaskWarning">正在使用 「{key=UseCopilotList}」 執行單一作業,不推薦此行為。單一作業請直接執行即可。</system:String>
<system:String x:Key="CopilotTaskListMixedModeNotAllowed">正在使用 「{key=UseCopilotList}」,不支援混用不同型別作業{0}。請清空列表後在同一頁籤重新新增</system:String>
<system:String x:Key="CopilotTaskListLegacyItemNotSupported">正在使用 「{key=UseCopilotList}」,但列表包含舊版本條目(缺少頁籤資訊),請在正確的頁籤重新新增這些作業後再啟動</system:String>
<system:String x:Key="CopilotTaskListTabMismatch">正在使用 「{key=UseCopilotList}」,目前頁籤為「{0}」,但列表來自「{1}」,請切換到對應頁籤後再啟動</system:String>
<system:String x:Key="CopilotTaskListMixedModeNotAllowed">正在使用 「{key=UseCopilotList}」,不支援混用不同型別作業</system:String>
<system:String x:Key="CopilotTaskTypeParseFailedSkipCheck">部分作業類型解析失敗,跳過類型檢查</system:String>
<system:String x:Key="CopilotTaskTypeParseFailedKeepCurrentTab">無法判斷作業類型,將保持目前頁籤匯入</system:String>
<!-- !日誌 -->
<!-- !Copilot -->
<!-- ErrorView -->

View File

@@ -55,12 +55,6 @@ public class CopilotItemViewModel : PropertyChangedBase
[JsonProperty("copilot_id")]
public int CopilotId { get; set; }
/// <summary>
/// Gets or sets 导入作业时所在的页签。
/// </summary>
[JsonProperty("tab_index", DefaultValueHandling = DefaultValueHandling.Ignore)]
public int? TabIndex { get; set; }
[JsonProperty("is_raid")]
private bool _isRaid;

View File

@@ -83,9 +83,6 @@ public partial class CopilotViewModel : Screen
[GeneratedRegex(@"^act\d+(side|mini)_")]
private static partial Regex SideStoryStageIdRegex();
[GeneratedRegex(@"^(main|sub|tough)_")]
private static partial Regex MainStageIdRegex();
/// <summary>
/// Gets the view models of log items.
/// </summary>
@@ -886,8 +883,6 @@ public partial class CopilotViewModel : Screen
using var reader = new StreamReader(File.OpenRead(file));
var str = await reader.ReadToEndAsync();
var payload = JsonConvert.DeserializeObject<CopilotBase>(str, new CopilotContentConverter());
TrySwitchCopilotTabForImport(payload);
if (payload is CopilotModel copilot)
{
var difficulty = copilot.Difficulty;
@@ -1063,11 +1058,9 @@ public partial class CopilotViewModel : Screen
switch (payload)
{
case CopilotModel copilot:
TrySwitchCopilotTabForImport(copilot);
await ParseCopilotAsync(copilot, writeToCache, UseCopilotList, copilotId);
return;
case SSSCopilotModel sss:
TrySwitchCopilotTabForImport(sss);
await ParseSSSCopilot(sss, writeToCache);
return;
default:
@@ -1351,29 +1344,15 @@ public partial class CopilotViewModel : Screen
}
var list = copilotSet.CopilotIds.Select(async (copilotId) => await GetCopilotAsync(copilotId)).ToList();
var shouldDetermineTabByFirstTask = true;
CopilotType firstFileType = CopilotType.Unknown;
foreach (var task in list)
{
var (copilotId, payload) = await task;
if (shouldDetermineTabByFirstTask)
{
firstFileType = TrySwitchCopilotTabForImport(payload);
TrySwitchCopilotTabForImport(payload);
shouldDetermineTabByFirstTask = false;
}
if (payload is CopilotModel copilot)
{
await ParseCopilotAsync(copilot, true, true, copilotId);
}
}
if (firstFileType == CopilotType.Unknown)
{
AddLog(LocalizationHelper.GetString("CopilotTaskTypeParseFailedKeepCurrentTab"), UiLogColor.Warning, showTime: false);
}
Log(copilotSet.Name, copilotSet.Description);
_copilotCache = null;
return;
@@ -1693,20 +1672,20 @@ public partial class CopilotViewModel : Screen
name ??= stageCode;
var item = new CopilotItemViewModel(name, cachePath, false, copilotId) { Index = CopilotItemViewModels.Count, TabIndex = CopilotTabIndex, };
var item = new CopilotItemViewModel(name, cachePath, false, copilotId) { Index = CopilotItemViewModels.Count, };
CopilotItemViewModels.Add(item);
}
else
{
if (flags.HasFlag(CopilotModel.DifficultyFlags.Normal))
{
var item = new CopilotItemViewModel(stageCode, cachePath, false, copilotId) { Index = CopilotItemViewModels.Count, TabIndex = CopilotTabIndex, };
var item = new CopilotItemViewModel(stageCode, cachePath, false, copilotId) { Index = CopilotItemViewModels.Count, };
CopilotItemViewModels.Add(item);
}
if (flags.HasFlag(CopilotModel.DifficultyFlags.Raid))
{
var item = new CopilotItemViewModel(stageCode, cachePath, true, copilotId) { Index = CopilotItemViewModels.Count, TabIndex = CopilotTabIndex, };
var item = new CopilotItemViewModel(stageCode, cachePath, true, copilotId) { Index = CopilotItemViewModels.Count, };
CopilotItemViewModels.Add(item);
}
}
@@ -1859,32 +1838,26 @@ public partial class CopilotViewModel : Screen
{
var selected = CopilotItemViewModels.Where(i => i.IsChecked).ToArray();
// 空列表:提示并失败
if (selected.Length == 0)
{
AddLog(LocalizationHelper.GetString("CopilotStartWithEmptyList"), UiLogColor.Error, showTime: false);
return false;
}
if (selected.Any(i => i.TabIndex is null))
var types = new HashSet<CopilotType>(await Task.WhenAll(selected.Select(item => GetCopilotTypeAsync(item.FilePath))));
if (types.Contains(CopilotType.Unknown))
{
AddLog(LocalizationHelper.GetString("CopilotTaskListLegacyItemNotSupported"), UiLogColor.Error, showTime: false);
return false;
}
var tabs = selected.Select(i => i.TabIndex!.Value).Distinct().ToArray();
if (tabs.Length > 1)
{
AddLog(LocalizationHelper.GetStringFormat("CopilotTaskListMixedModeNotAllowed", string.Join(", ", tabs.Select(GetCopilotTabName))), UiLogColor.Error, showTime: false);
return false;
}
var listTab = tabs[0];
if (listTab != tabIndex)
{
AddLog(LocalizationHelper.GetStringFormat("CopilotTaskListTabMismatch", GetCopilotTabName(tabIndex), GetCopilotTabName(listTab)), UiLogColor.Error, showTime: false);
AddLog(LocalizationHelper.GetString("CopilotTaskTypeParseFailedSkipCheck"), UiLogColor.Error, showTime: false);
return false;
}
else if (types.Count > 1)
{
AddLog(LocalizationHelper.GetString("CopilotTaskListMixedModeNotAllowed") + "\n" + string.Join(", ", types.Select(i => GetCopilotTabName(i))), UiLogColor.Error, showTime: false);
return false;
}
// 先判断 CopilotTabIndex再判断对应选项
if (tabIndex == 2)
{
return VerifyParadoxTasks(selected);
@@ -2215,41 +2188,6 @@ public partial class CopilotViewModel : Screen
return ok;
}
private CopilotType TrySwitchCopilotTabForImport(CopilotBase? payload)
{
if (CopilotTabIndex == 3)
{
return CopilotType.Other;
}
var tabIndex = GetCopilotTabIndex(GetCopilotType(payload));
if (tabIndex is int value)
{
CopilotTabIndex = value;
return (CopilotType)value;
}
return CopilotType.Unknown;
}
private static int? GetCopilotTabIndex(CopilotType type) =>
type switch {
CopilotType.MainStageAndSideStory => 0,
CopilotType.SSS => 1,
CopilotType.Paradox => 2,
CopilotType.Other => 3,
_ => null,
};
private static string GetCopilotTabName(int tabIndex) =>
GetCopilotTabName(tabIndex switch {
0 => CopilotType.MainStageAndSideStory,
1 => CopilotType.SSS,
2 => CopilotType.Paradox,
3 => CopilotType.Other,
_ => CopilotType.Unknown,
});
private static string GetCopilotTabName(CopilotType type) =>
type switch {
CopilotType.MainStageAndSideStory => LocalizationHelper.GetString("MainStageStoryCollectionSideStory"),
@@ -2345,7 +2283,7 @@ public partial class CopilotViewModel : Screen
{
return CopilotType.Paradox;
}
else if (MainStageIdRegex().IsMatch(mapInfo.StageId ?? string.Empty) || SideStoryStageIdRegex().IsMatch(mapInfo.StageId ?? string.Empty))
else if (mapInfo.StageId?.StartsWith("main_") is true || SideStoryStageIdRegex().IsMatch(mapInfo.StageId ?? string.Empty))
{
return CopilotType.MainStageAndSideStory;
}