Skip to content

Commit f1d3b45

Browse files
committed
Merge branch 'main' into deploy
2 parents ceaba3f + f712dbb commit f1d3b45

9 files changed

Lines changed: 48 additions & 16 deletions

File tree

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2023 Roll
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,5 @@ This project is based on [vue-color-avatar](https://github.com/Codennnn/vue-colo
1515
<img src="./src/images/img.png" alt="website-cover" />
1616
</a>
1717

18+
## LICENSE
19+
Have a look at the [license file](./LICENSE) for details

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "avatar",
33
"private": true,
4-
"version": "0.0.0",
4+
"version": "0.0.1",
55
"type": "module",
66
"scripts": {
77
"dev": "vite",

src/components/react-color-avatar/index.tsx

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { CSSProperties, useEffect, useState } from 'react';
1+
import { CSSProperties, RefObject, useEffect, useState } from 'react';
22
import { Background } from '@/components/widgets';
33
import { WidgetType, WrapperShape } from '@/enums';
44
import { AvatarOption } from '@/types';
@@ -10,11 +10,12 @@ interface IReactColorAvatarProps {
1010
option: AvatarOption,
1111
size: 280,
1212
style: CSSProperties,
13-
colorAvatarRef: any
13+
colorAvatarRef: RefObject<HTMLDivElement>
1414
}
1515
export default function ReactColorAvatar(props: IReactColorAvatarProps) {
1616
const { option: avatarOption, size: avatarSize, style, colorAvatarRef } = props;
17-
const [svgContent, setSvgContent] = useState('');
17+
const [svgContent, setSvgContent] = useState('');
18+
1819
useEffect(() => {
1920
(async () => {
2021
const sortedList = Object.entries(avatarOption.widgets).sort(
@@ -93,14 +94,11 @@ export default function ReactColorAvatar(props: IReactColorAvatarProps) {
9394
}
9495
}
9596
const shapeClassNames = getWrapperShapeClassName();
96-
const trueShape = Object.keys(shapeClassNames).find((shape: any) => {
97-
// TODO any type
98-
// @ts-ignore
99-
return shapeClassNames[shape];
97+
const trueShape = Object.keys(shapeClassNames).find((shape: string) => {
98+
return shapeClassNames[shape as WrapperShape];
10099
});
101100

102101

103-
104102
return (
105103
<div className={`react-color-avatar ${trueShape}`} ref={colorAvatarRef} style={{ width: avatarSize, height: avatarSize, ...style }}>
106104
<Background color={avatarOption.background.color}/>

src/layouts/container/index.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,7 @@ export default function Container(props: IProps) {
1515
const { avatarOption, setAvatarOption } = props;
1616
const [flipped, setFlipped] = useState(false);
1717
const [downloading, setDownloading] = useState(false);
18-
// const [imageDataURL, setImageDataURL] = useState('');
19-
const colorAvatarRef = useRef(null);
18+
const colorAvatarRef = useRef<HTMLDivElement>(null);
2019
const onRandomAvatar = () => {
2120
if (Math.random() <= TRIGGER_PROBABILITY) {
2221
let colorfulOption = getSpecialAvatarOption()

src/layouts/footer/index.tsx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { version } from '../../../package.json';
12
import './style.less'
23

34
export default function Footer() {
@@ -20,6 +21,10 @@ export default function Footer() {
2021
<div className='divider'>|</div>
2122

2223
<div className='locale' >简体中文</div>
24+
25+
<div className='divider'>|</div>
26+
27+
<div className='version' >{ version }</div>
2328
</footer>
2429
)
2530
}

src/store/index.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { combineReducers, legacy_createStore } from 'redux';
22
import { getRandomAvatarOption } from '@/utils';
33
import { WrapperShape } from '@/enums';
44
import { SCREEN } from '@/constants';
5+
import { ActionTypes } from '@/types';
56
import { REDO, SET_AVATAR_OPTION, SET_SIDER_STATUS, UNDO } from './mutation-type';
67

78

@@ -16,7 +17,7 @@ const initialState = {
1617
};
1718

1819
// Reducer
19-
const historyReducer = (state = initialState.history, action: any) => {
20+
const historyReducer = (state = initialState.history, action: ActionTypes) => {
2021
switch (action.type) {
2122
case SET_AVATAR_OPTION:
2223
return {
@@ -51,8 +52,7 @@ const historyReducer = (state = initialState.history, action: any) => {
5152
}
5253
};
5354

54-
const isSiderCollapsedReducer = (state = initialState.isCollapsed, action: any) => {
55-
// TOOD any类型
55+
const isSiderBarCollapsedReducer = (state = initialState.isCollapsed, action: ActionTypes) => {
5656
switch (action.type) {
5757
case SET_SIDER_STATUS:
5858
return action.payload;
@@ -64,7 +64,7 @@ const isSiderCollapsedReducer = (state = initialState.isCollapsed, action: any)
6464
// Combine Reducers
6565
const rootReducer = combineReducers({
6666
history: historyReducer,
67-
isCollapsed: isSiderCollapsedReducer,
67+
isCollapsed: isSiderBarCollapsedReducer,
6868
});
6969
const store = legacy_createStore(rootReducer);
7070
// Store

src/types/index.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import {
1414
type TopsShape,
1515
type WrapperShape,
1616
} from '@/enums'
17+
import { REDO, SET_AVATAR_OPTION, SET_SIDER_STATUS, UNDO } from '@/store/mutation-type';
1718

1819
export type None = typeof NONE
1920

@@ -80,3 +81,9 @@ export interface AppState {
8081
}
8182
isCollapsed: boolean
8283
}
84+
85+
// reducer action type
86+
export type ActionTypes = {
87+
type: typeof REDO | typeof SET_AVATAR_OPTION | typeof SET_SIDER_STATUS | typeof UNDO,
88+
payload: boolean
89+
};

src/utils/dynamic-data.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import {
1111
NoseShape,
1212
TopsShape,
1313
WidgetType,
14-
} from '../enums'
14+
} from '@/enums'
1515

1616
/** @internal */
1717
type Data = Readonly<{

0 commit comments

Comments
 (0)