Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
N
Neos
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
1
Issues
1
List
Boards
Labels
Service Desk
Milestones
Merge Requests
2
Merge Requests
2
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
List
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
MyCard
Neos
Commits
16272cfe
Commit
16272cfe
authored
Jul 07, 2024
by
Chunchi Che
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
enable custom animation speed
parent
e3758624
Pipeline
#28158
passed with stages
in 12 minutes and 1 second
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
52 additions
and
2 deletions
+52
-2
src/stores/settingStore/animation.ts
src/stores/settingStore/animation.ts
+8
-0
src/stores/settingStore/index.ts
src/stores/settingStore/index.ts
+13
-2
src/ui/Setting/Animation.tsx
src/ui/Setting/Animation.tsx
+31
-0
No files found.
src/stores/settingStore/animation.ts
0 → 100644
View file @
16272cfe
export
interface
AnimationConfig
{
// custom speed set by player
speed
:
number
;
}
export
const
defaultAnimationConfig
:
AnimationConfig
=
{
speed
:
0.7
,
};
src/stores/settingStore/index.ts
View file @
16272cfe
...
@@ -3,17 +3,19 @@ import { pick } from "lodash-es";
...
@@ -3,17 +3,19 @@ import { pick } from "lodash-es";
import
{
proxy
,
subscribe
}
from
"
valtio
"
;
import
{
proxy
,
subscribe
}
from
"
valtio
"
;
import
{
type
NeosStore
}
from
"
../shared
"
;
import
{
type
NeosStore
}
from
"
../shared
"
;
import
{
AnimationConfig
,
defaultAnimationConfig
}
from
"
./animation
"
;
import
{
AudioConfig
,
defaultAudioConfig
}
from
"
./audio
"
;
import
{
AudioConfig
,
defaultAudioConfig
}
from
"
./audio
"
;
/** 将设置保存到本地 */
/** 将设置保存到本地 */
const
NEO_SETTING_CONFIG
=
"
__neo_setting_config__
"
;
const
NEO_SETTING_CONFIG
=
"
__neo_setting_config__
"
;
/** 设置项 */
/** 设置项 */
type
SettingStoreConfig
=
Pick
<
SettingStore
,
"
audio
"
>
;
type
SettingStoreConfig
=
Pick
<
SettingStore
,
"
audio
"
|
"
animation
"
>
;
/** 默认设置 */
/** 默认设置 */
const
defaultSettingConfig
:
SettingStoreConfig
=
{
const
defaultSettingConfig
:
SettingStoreConfig
=
{
audio
:
defaultAudioConfig
,
audio
:
defaultAudioConfig
,
animation
:
defaultAnimationConfig
,
};
};
/** 获取默认设置 */
/** 获取默认设置 */
...
@@ -33,14 +35,23 @@ class SettingStore implements NeosStore {
...
@@ -33,14 +35,23 @@ class SettingStore implements NeosStore {
/** 音频设置 */
/** 音频设置 */
audio
:
AudioConfig
=
defaultSetting
.
audio
;
audio
:
AudioConfig
=
defaultSetting
.
audio
;
/** Animation Configuration */
animation
:
AnimationConfig
=
defaultSetting
.
animation
;
/** 保存音频设置 */
/** 保存音频设置 */
saveAudioConfig
(
config
:
Partial
<
AudioConfig
>
):
void
{
saveAudioConfig
(
config
:
Partial
<
AudioConfig
>
):
void
{
Object
.
assign
(
this
.
audio
,
config
);
Object
.
assign
(
this
.
audio
,
config
);
}
}
/** save Animation Configuration */
saveAnimationConfig
(
config
:
Partial
<
AnimationConfig
>
):
void
{
Object
.
assign
(
this
.
animation
,
config
);
}
reset
():
void
{
reset
():
void
{
const
defaultSetting
=
getDefaultSetting
();
const
defaultSetting
=
getDefaultSetting
();
this
.
audio
=
defaultSetting
.
audio
;
this
.
audio
=
defaultSetting
.
audio
;
this
.
animation
=
defaultSetting
.
animation
;
}
}
}
}
...
@@ -52,7 +63,7 @@ subscribe(settingStore, () => {
...
@@ -52,7 +63,7 @@ subscribe(settingStore, () => {
if
(
!
isSSR
())
{
if
(
!
isSSR
())
{
localStorage
.
setItem
(
localStorage
.
setItem
(
NEO_SETTING_CONFIG
,
NEO_SETTING_CONFIG
,
JSON
.
stringify
(
pick
(
settingStore
,
[
"
audio
"
])),
JSON
.
stringify
(
pick
(
settingStore
,
[
"
audio
"
,
"
animation
"
])),
);
);
}
}
});
});
src/ui/Setting/Animation.tsx
0 → 100644
View file @
16272cfe
import
{
Form
,
Slider
}
from
"
antd
"
;
import
React
from
"
react
"
;
import
{
useTranslation
}
from
"
react-i18next
"
;
import
{
useSnapshot
}
from
"
valtio
"
;
import
{
settingStore
}
from
"
@/stores/settingStore
"
;
export
const
AnimationSetting
:
React
.
FC
=
()
=>
{
const
{
animation
}
=
useSnapshot
(
settingStore
);
const
{
t
:
i18n
}
=
useTranslation
(
"
SystemSettings
"
);
return
(
<
Form
initialValues=
{
animation
}
onValuesChange=
{
(
config
)
=>
settingStore
.
saveAnimationConfig
(
config
)
}
labelAlign=
"left"
>
<
Form
.
Item
label=
{
i18n
(
"
AnimationSpeed
"
)
}
name=
"speed"
noStyle
>
<
Slider
style=
{
{
width
:
200
}
}
min=
{
0
}
max=
{
1
}
step=
{
0.01
}
tooltip=
{
{
formatter
:
(
value
)
=>
((
value
||
0
)
*
100
).
toFixed
(
0
),
}
}
/>
</
Form
.
Item
>
</
Form
>
);
};
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment