-
-
Notifications
You must be signed in to change notification settings - Fork 86
Refresh UI #580
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Refresh UI #580
Changes from 3 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
519d147
new template: WebGAL Refine 2026
MakinoharaShoko b3d7c21
new template backend logic
MakinoharaShoko 4e9bfb4
template editor support new component class
MakinoharaShoko 8240f90
fix: use default option
MakinoharaShoko 660a1a0
Merge branch 'dev' into refresh-ui
MakinoharaShoko 58388f8
fix: style for new layout
MakinoharaShoko 2d7d5d2
fix: remove placeholder entry from component tree title
MakinoharaShoko c2587e6
Merge branch 'dev' into refresh-ui
MakinoharaShoko 4887c10
update locales
MakinoharaShoko File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -34,8 +34,8 @@ export default function Sidebar(props: ISidebarProps) { | |
| const [createGameFormOpen, setCreateGameFormOpen] = useState(false); | ||
| const [gameName, setGameName] = useState(t`新的游戏`); | ||
| const [gameDir, setGameDir] = useState(t`新的游戏`); | ||
| const [derivative, setDerivative] = useState<string | undefined>('__STANDARD__WG__'); | ||
| const [templateName, setTemplateName] = useState<string | undefined>('__STANDARD__WG__'); | ||
| const [derivative, setDerivative] = useState<string | undefined>(undefined); | ||
| const [templateName, setTemplateName] = useState<string | undefined>(undefined); | ||
|
|
||
| // 可用的衍生版 | ||
| const derivativeEnginesResp = useSWR('derivativeEngines', async () => { | ||
|
|
@@ -45,28 +45,30 @@ export default function Sidebar(props: ISidebarProps) { | |
|
|
||
| const templatesResp = useSWR('template-list-selector', async () => { | ||
| const resp = await api.manageTemplateControllerGetTemplateList(); | ||
| return resp.data as unknown as { name: string }[]; | ||
| return resp.data as unknown as { name: string; dir: string }[]; | ||
| }); | ||
|
|
||
| const defaultDerivativeValue = 'WebGAL Standard'; | ||
| const defaultTemplateValue = 'WebGAL Refine 2026'; | ||
|
|
||
| const selector = <Dropdown value={derivative === '__STANDARD__WG__' ? t`WebGAL Standard` : derivative} | ||
| selectedOptions={[derivative ?? '__STANDARD__WG__']} onOptionSelect={(_, elem) => { | ||
| setDerivative(elem.optionValue); | ||
| const selector = <Dropdown value={derivative ?? t`WebGAL Standard`} | ||
| selectedOptions={[derivative ?? defaultDerivativeValue]} onOptionSelect={(_, elem) => { | ||
| setDerivative(elem.optionValue === defaultDerivativeValue ? undefined : elem.optionValue); | ||
| }}> | ||
| <Option key="__standard" value="__STANDARD__WG__">{t`WebGAL Standard`}</Option> | ||
| <Option key="default-engine" value={defaultDerivativeValue}>{t`WebGAL Standard`}</Option> | ||
| {(derivativeEnginesResp.data ?? []).map(e => | ||
| <Option key={e} value={e}>{e}</Option> | ||
| )} | ||
| </Dropdown>; | ||
|
|
||
| const selectorTemplate = <Dropdown value={templateName === '__STANDARD__WG__' ? t`WebGAL Classic` : templateName} | ||
| selectedOptions={[templateName ?? '__STANDARD__WG__']} | ||
| const selectorTemplate = <Dropdown value={templateName ?? defaultTemplateValue} | ||
| selectedOptions={[templateName ?? defaultTemplateValue]} | ||
| onOptionSelect={(_, elem) => { | ||
| setTemplateName(elem.optionValue); | ||
| setTemplateName(elem.optionValue === defaultTemplateValue ? undefined : elem.optionValue); | ||
| }}> | ||
| <Option key="__standard" value="__STANDARD__WG__">{t`WebGAL Classic`}</Option> | ||
| <Option key="default-template" value={defaultTemplateValue}>{defaultTemplateValue}</Option> | ||
| {(templatesResp.data ?? []).map(e => | ||
| <Option key={e.name} value={e.name}>{e.name}</Option> | ||
| <Option key={e.dir} value={e.dir}>{e.name}</Option> | ||
| )} | ||
| </Dropdown>; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 这段代码存在两个可以改进的地方:
建议重构此部分,以解决上述问题。例如,可以为默认选项使用一个唯一的内部值(如 |
||
|
|
||
|
|
@@ -75,8 +77,8 @@ export default function Sidebar(props: ISidebarProps) { | |
| props.createGame({ | ||
| gameName: gameName.trim(), | ||
| gameDir, | ||
| derivative: derivative === '__STANDARD__WG__' ? undefined : derivative, | ||
| templateDir: templateName === '__STANDARD__WG__' ? undefined : templateName, | ||
| derivative, | ||
| templateDir: templateName, | ||
| }); | ||
| setCreateGameFormOpen(false); | ||
| setGameName(t`新的游戏`); | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
硬编码的字符串
'WebGAL Refine 2026'没有被国际化,这会影响多语言支持。建议使用t宏进行翻译(例如t\WebGAL Refine 2026`),并将其添加到.po` 文件中,以确保在不同语言环境下能正确显示。