mirror of
https://github.com/songquanpeng/one-api.git
synced 2025-11-11 19:03:43 +08:00
feat: add new theme berry (#860)
* feat: add theme berry * docs: add development notes * fix: fix blank page * chore: update implementation * fix: fix package.json * chore: update ui copy --------- Co-authored-by: JustSong <songquanpeng@foxmail.com>
This commit is contained in:
24
web/berry/src/store/accountReducer.js
Normal file
24
web/berry/src/store/accountReducer.js
Normal file
@@ -0,0 +1,24 @@
|
||||
import * as actionTypes from './actions';
|
||||
|
||||
export const initialState = {
|
||||
user: undefined
|
||||
};
|
||||
|
||||
const accountReducer = (state = initialState, action) => {
|
||||
switch (action.type) {
|
||||
case actionTypes.LOGIN:
|
||||
return {
|
||||
...state,
|
||||
user: action.payload
|
||||
};
|
||||
case actionTypes.LOGOUT:
|
||||
return {
|
||||
...state,
|
||||
user: undefined
|
||||
};
|
||||
default:
|
||||
return state;
|
||||
}
|
||||
};
|
||||
|
||||
export default accountReducer;
|
||||
9
web/berry/src/store/actions.js
Normal file
9
web/berry/src/store/actions.js
Normal file
@@ -0,0 +1,9 @@
|
||||
// action - customization reducer
|
||||
export const SET_MENU = '@customization/SET_MENU';
|
||||
export const MENU_TOGGLE = '@customization/MENU_TOGGLE';
|
||||
export const MENU_OPEN = '@customization/MENU_OPEN';
|
||||
export const SET_FONT_FAMILY = '@customization/SET_FONT_FAMILY';
|
||||
export const SET_BORDER_RADIUS = '@customization/SET_BORDER_RADIUS';
|
||||
export const SET_SITE_INFO = '@siteInfo/SET_SITE_INFO';
|
||||
export const LOGIN = '@account/LOGIN';
|
||||
export const LOGOUT = '@account/LOGOUT';
|
||||
4
web/berry/src/store/constant.js
Normal file
4
web/berry/src/store/constant.js
Normal file
@@ -0,0 +1,4 @@
|
||||
// theme constant
|
||||
export const gridSpacing = 3;
|
||||
export const drawerWidth = 260;
|
||||
export const appDrawerWidth = 320;
|
||||
46
web/berry/src/store/customizationReducer.js
Normal file
46
web/berry/src/store/customizationReducer.js
Normal file
@@ -0,0 +1,46 @@
|
||||
// project imports
|
||||
import config from 'config';
|
||||
|
||||
// action - state management
|
||||
import * as actionTypes from './actions';
|
||||
|
||||
export const initialState = {
|
||||
isOpen: [], // for active default menu
|
||||
defaultId: 'default',
|
||||
fontFamily: config.fontFamily,
|
||||
borderRadius: config.borderRadius,
|
||||
opened: true
|
||||
};
|
||||
|
||||
// ==============================|| CUSTOMIZATION REDUCER ||============================== //
|
||||
|
||||
const customizationReducer = (state = initialState, action) => {
|
||||
let id;
|
||||
switch (action.type) {
|
||||
case actionTypes.MENU_OPEN:
|
||||
id = action.id;
|
||||
return {
|
||||
...state,
|
||||
isOpen: [id]
|
||||
};
|
||||
case actionTypes.SET_MENU:
|
||||
return {
|
||||
...state,
|
||||
opened: action.opened
|
||||
};
|
||||
case actionTypes.SET_FONT_FAMILY:
|
||||
return {
|
||||
...state,
|
||||
fontFamily: action.fontFamily
|
||||
};
|
||||
case actionTypes.SET_BORDER_RADIUS:
|
||||
return {
|
||||
...state,
|
||||
borderRadius: action.borderRadius
|
||||
};
|
||||
default:
|
||||
return state;
|
||||
}
|
||||
};
|
||||
|
||||
export default customizationReducer;
|
||||
9
web/berry/src/store/index.js
Normal file
9
web/berry/src/store/index.js
Normal file
@@ -0,0 +1,9 @@
|
||||
import { createStore } from 'redux';
|
||||
import reducer from './reducer';
|
||||
|
||||
// ==============================|| REDUX - MAIN STORE ||============================== //
|
||||
|
||||
const store = createStore(reducer);
|
||||
const persister = 'Free';
|
||||
|
||||
export { store, persister };
|
||||
16
web/berry/src/store/reducer.js
Normal file
16
web/berry/src/store/reducer.js
Normal file
@@ -0,0 +1,16 @@
|
||||
import { combineReducers } from 'redux';
|
||||
|
||||
// reducer import
|
||||
import customizationReducer from './customizationReducer';
|
||||
import accountReducer from './accountReducer';
|
||||
import siteInfoReducer from './siteInfoReducer';
|
||||
|
||||
// ==============================|| COMBINE REDUCER ||============================== //
|
||||
|
||||
const reducer = combineReducers({
|
||||
customization: customizationReducer,
|
||||
account: accountReducer,
|
||||
siteInfo: siteInfoReducer
|
||||
});
|
||||
|
||||
export default reducer;
|
||||
18
web/berry/src/store/siteInfoReducer.js
Normal file
18
web/berry/src/store/siteInfoReducer.js
Normal file
@@ -0,0 +1,18 @@
|
||||
import config from 'config';
|
||||
import * as actionTypes from './actions';
|
||||
|
||||
export const initialState = config.siteInfo;
|
||||
|
||||
const siteInfoReducer = (state = initialState, action) => {
|
||||
switch (action.type) {
|
||||
case actionTypes.SET_SITE_INFO:
|
||||
return {
|
||||
...state,
|
||||
...action.payload
|
||||
};
|
||||
default:
|
||||
return state;
|
||||
}
|
||||
};
|
||||
|
||||
export default siteInfoReducer;
|
||||
Reference in New Issue
Block a user