Skip to content

Commit

Permalink
Merge pull request #1107 from sunfish-shogi/v-model
Browse files Browse the repository at this point in the history
Use defineModel and v-model
  • Loading branch information
sunfish-shogi authored Feb 23, 2025
2 parents 158128d + eca1cc3 commit cd1fde2
Show file tree
Hide file tree
Showing 26 changed files with 303 additions and 752 deletions.
14 changes: 2 additions & 12 deletions src/renderer/view/dialog/AddBookMovesDialog.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,12 @@
<div class="title">定跡手追加</div>
<div>
<HorizontalSelector
:value="sourceType"
v-model:value="sourceType"
:items="[
{ value: SourceType.MEMORY, label: '現在の棋譜から' },
{ value: SourceType.FILE, label: 'ファイルから' },
{ value: SourceType.DIRECTORY, label: 'フォルダから' },
]"
@change="
(value) => {
sourceType = value as SourceType;
}
"
/>
</div>
<div class="form-group scroll">
Expand Down Expand Up @@ -67,18 +62,13 @@
</div>
<div v-show="sourceType === 'directory' || sourceType === 'file'" class="form-item row">
<HorizontalSelector
:value="playerCriteria"
v-model:value="playerCriteria"
:items="[
{ value: PlayerCriteria.ALL, label: '全ての対局者' },
{ value: PlayerCriteria.BLACK, label: '先手のみ' },
{ value: PlayerCriteria.WHITE, label: '後手のみ' },
{ value: PlayerCriteria.FILTER_BY_NAME, label: '名前でフィルタ' },
]"
@change="
(value) => {
playerCriteria = value as PlayerCriteria;
}
"
/>
</div>
<div v-show="sourceType === 'directory' || sourceType === 'file'" class="form-item row">
Expand Down
32 changes: 4 additions & 28 deletions src/renderer/view/dialog/AnalysisDialog.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,26 +5,18 @@
<div class="form-group">
<div>{{ t.searchEngine }}</div>
<PlayerSelector
:player-uri="engineURI"
v-model:player-uri="engineURI"
:engines="engines"
:filter-label="USIEngineLabel.RESEARCH"
:display-thread-state="true"
:display-multi-pv-state="true"
@update-engines="onUpdatePlayerSettings"
@select-player="onSelectPlayer"
/>
</div>
<div class="form-group">
<div>{{ t.startEndCriteria }}</div>
<div class="form-item">
<ToggleButton
:value="enableStartNumber"
@change="
(value: boolean) => {
enableStartNumber = value;
}
"
/>
<ToggleButton v-model:value="enableStartNumber" />
<div class="form-item-small-label">{{ t.fromPrefix }}{{ t.plyPrefix }}</div>
<input
ref="startNumber"
Expand All @@ -37,14 +29,7 @@
<div class="form-item-small-label">{{ t.plySuffix }}{{ t.fromSuffix }}</div>
</div>
<div class="form-item">
<ToggleButton
:value="enableEndNumber"
@change="
(value: boolean) => {
enableEndNumber = value;
}
"
/>
<ToggleButton v-model:value="enableEndNumber" />
<div class="form-item-small-label">{{ t.toPrefix }}{{ t.plyPrefix }}</div>
<input
ref="endNumber"
Expand All @@ -70,19 +55,14 @@
<div class="form-item">
<div class="form-item-label-wide">{{ t.moveComments }}</div>
<HorizontalSelector
v-model:value="commentBehavior"
class="selector"
:items="[
{ value: CommentBehavior.NONE, label: t.noOutputs },
{ value: CommentBehavior.INSERT, label: t.insertCommentToTop },
{ value: CommentBehavior.APPEND, label: t.appendCommentToBottom },
{ value: CommentBehavior.OVERWRITE, label: t.overwrite },
]"
:value="commentBehavior"
@change="
(value: string) => {
commentBehavior = value as CommentBehavior;
}
"
/>
</div>
</div>
Expand Down Expand Up @@ -185,10 +165,6 @@ const onCancel = () => {
const onUpdatePlayerSettings = async (val: USIEngines) => {
engines.value = val;
};
const onSelectPlayer = (uri: string) => {
engineURI.value = uri;
};
</script>

<style scoped>
Expand Down
54 changes: 27 additions & 27 deletions src/renderer/view/dialog/AppSettingsDialog.vue
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
{ label: '繁體中文', value: Language.ZH_TW },
{ label: 'Tiếng Việt', value: Language.VI },
]"
@change="
@update:value="
(value: string) => {
update.language = value as Language;
}
Expand Down Expand Up @@ -55,7 +55,7 @@
{ label: t.darkGreen, value: Thema.DARK_GREEN },
{ label: t.dark, value: Thema.DARK },
]"
@change="
@update:value="
(value: string) => {
update.thema = value as Thema;
}
Expand All @@ -74,7 +74,7 @@
{ label: t.bgContain, value: BackgroundImageType.CONTAIN },
{ label: t.bgTile, value: BackgroundImageType.TILE },
]"
@change="
@update:value="
(value: string) => {
update.backgroundImageType = value as BackgroundImageType;
}
Expand Down Expand Up @@ -106,7 +106,7 @@
{ label: t.compact, value: BoardLayoutType.COMPACT },
{ label: t.portrait, value: BoardLayoutType.PORTRAIT },
]"
@change="
@update:value="
(value: string) => {
update.boardLayoutType = value as BoardLayoutType;
}
Expand All @@ -131,7 +131,7 @@
{ label: t.customImage, value: PieceImageType.CUSTOM_IMAGE },
].filter((item) => !isMobileWebApp() || item.value !== PieceImageType.CUSTOM_IMAGE)
"
@change="
@update:value="
(value: string) => {
update.pieceImage = value as PieceImageType;
}
Expand All @@ -157,7 +157,7 @@
<ToggleButton
:label="t.imageHasMarginsRemoveForLargerDisplay"
:value="original.deletePieceImageMargin"
@change="(checked: boolean) => (update.deletePieceImageMargin = checked)"
@update:value="(checked: boolean) => (update.deletePieceImageMargin = checked)"
/>
</div>
</div>
Expand All @@ -183,7 +183,7 @@
{ label: t.customImage, value: BoardImageType.CUSTOM_IMAGE },
].filter((item) => !isMobileWebApp() || item.value !== BoardImageType.CUSTOM_IMAGE)
"
@change="
@update:value="
(value: string) => {
update.boardImage = value as BoardImageType;
}
Expand Down Expand Up @@ -221,7 +221,7 @@
(item) => !isMobileWebApp() || item.value !== PieceStandImageType.CUSTOM_IMAGE,
)
"
@change="
@update:value="
(value: string) => {
update.pieceStandImage = value as PieceStandImageType;
}
Expand All @@ -247,7 +247,7 @@
<div class="form-item-label-wide">{{ t.transparent }}</div>
<ToggleButton
:value="original.enableTransparent"
@change="(checked: boolean) => (update.enableTransparent = checked)"
@update:value="(checked: boolean) => (update.enableTransparent = checked)"
/>
</div>
<!-- 盤の不透明度 -->
Expand Down Expand Up @@ -309,7 +309,7 @@
</div>
<ToggleButton
:value="original.boardLabelType != BoardLabelType.NONE"
@change="
@update:value="
(checked: boolean) =>
(update.boardLabelType = checked ? BoardLabelType.STANDARD : BoardLabelType.NONE)
"
Expand All @@ -322,7 +322,7 @@
</div>
<ToggleButton
:value="original.leftSideControlType != LeftSideControlType.NONE"
@change="
@update:value="
(checked: boolean) =>
(update.leftSideControlType = checked
? LeftSideControlType.STANDARD
Expand All @@ -337,7 +337,7 @@
</div>
<ToggleButton
:value="original.rightSideControlType != RightSideControlType.NONE"
@change="
@update:value="
(checked: boolean) =>
(update.rightSideControlType = checked
? RightSideControlType.STANDARD
Expand All @@ -356,7 +356,7 @@
{ label: t.twoColumns, value: TabPaneType.DOUBLE },
{ label: `${t.twoColumns} v2`, value: TabPaneType.DOUBLE_V2 },
]"
@change="
@update:value="
(value: string) => {
update.tabPaneType = value as TabPaneType;
}
Expand Down Expand Up @@ -428,7 +428,7 @@
{ label: t.anyTurn, value: ClockSoundTarget.ALL },
{ label: t.onlyHumanTurn, value: ClockSoundTarget.ONLY_USER },
]"
@change="
@update:value="
(value: string) => {
update.clockSoundTarget = value as ClockSoundTarget;
}
Expand Down Expand Up @@ -456,7 +456,7 @@
{ label: '.csa', value: RecordFileFormat.CSA },
{ label: '.jkf', value: RecordFileFormat.JKF },
]"
@change="
@update:value="
(value: string) => {
update.defaultRecordFileFormat = value as RecordFileFormat;
}
Expand All @@ -475,7 +475,7 @@
{ label: t.strict, value: TextDecodingRule.STRICT },
{ label: t.autoDetect, value: TextDecodingRule.AUTO_DETECT },
]"
@change="
@update:value="
(value: string) => {
update.textDecodingRule = value as TextDecodingRule;
}
Expand All @@ -495,7 +495,7 @@
{ label: 'LF (UNIX/Mac)', value: 'lf' },
{ label: `CR (${t.old90sMac})`, value: 'cr' },
]"
@change="
@update:value="
(value: string) => {
update.returnCode = nameToReturnCode[value];
}
Expand Down Expand Up @@ -549,7 +549,7 @@
<div class="form-item-label-wide">{{ t.csaV3Output }}</div>
<ToggleButton
:value="original.useCSAV3"
@change="(checked: boolean) => (update.useCSAV3 = checked)"
@update:value="(checked: boolean) => (update.useCSAV3 = checked)"
/>
</div>
<!-- USI の局面表記 -->
Expand All @@ -562,7 +562,7 @@
{ label: t.onlySFEN, value: 'false' },
{ label: 'startpos / SFEN', value: 'true' },
]"
@change="
@update:value="
(value: string) => {
update.enableUSIFileStartpos = value === 'true';
}
Expand All @@ -579,7 +579,7 @@
{ label: t.onlySFEN, value: 'false' },
{ label: 'SFEN / resign', value: 'true' },
]"
@change="
@update:value="
(value: string) => {
update.enableUSIFileResign = value === 'true';
}
Expand Down Expand Up @@ -621,7 +621,7 @@
</div>
<ToggleButton
:value="original.translateEngineOptionName"
@change="(checked: boolean) => (update.translateEngineOptionName = checked)"
@update:value="(checked: boolean) => (update.translateEngineOptionName = checked)"
/>
<div class="form-item-small-label">({{ t.functionalOnJapaneseOnly }})</div>
</div>
Expand Down Expand Up @@ -663,7 +663,7 @@
value: EvaluationViewFrom.BLACK,
},
]"
@change="
@update:value="
(value: string) => {
update.evaluationViewFrom = value as EvaluationViewFrom;
}
Expand Down Expand Up @@ -811,7 +811,7 @@
{ label: 'CSA V3', value: SearchCommentFormat.CSA3 },
{ label: 'ShogiGUI', value: SearchCommentFormat.SHOGIGUI },
]"
@change="
@update:value="
(value: string) => {
update.searchCommentFormat = value as SearchCommentFormat;
}
Expand Down Expand Up @@ -870,23 +870,23 @@
<div class="form-item-label-wide">{{ t.enableAppLog }}</div>
<ToggleButton
:value="original.enableAppLog"
@change="(checked: boolean) => (update.enableAppLog = checked)"
@update:value="(checked: boolean) => (update.enableAppLog = checked)"
/>
</div>
<!-- USI通信ログを出力 -->
<div class="form-item">
<div class="form-item-label-wide">{{ t.enableUSILog }}</div>
<ToggleButton
:value="original.enableUSILog"
@change="(checked: boolean) => (update.enableUSILog = checked)"
@update:value="(checked: boolean) => (update.enableUSILog = checked)"
/>
</div>
<!-- CSA通信ログを出力 -->
<div class="form-item">
<div class="form-item-label-wide">{{ t.enableCSALog }}</div>
<ToggleButton
:value="original.enableCSALog"
@change="(checked: boolean) => (update.enableCSALog = checked)"
@update:value="(checked: boolean) => (update.enableCSALog = checked)"
/>
</div>
<!-- ログレベル -->
Expand All @@ -901,7 +901,7 @@
{ label: 'WARN', value: LogLevel.WARN },
{ label: 'ERROR', value: LogLevel.ERROR },
]"
@change="
@update:value="
(value: string) => {
update.logLevel = value as LogLevel;
}
Expand Down
Loading

0 comments on commit cd1fde2

Please sign in to comment.