|
@@ -2,8 +2,11 @@ import { PropsWithChildren, useState } from 'react';
|
|
|
import { useLaunch } from '@tarojs/taro';
|
|
|
import { IntlProvider } from 'react-intl';
|
|
|
import { ConfigProvider, Button } from 'antd';
|
|
|
+import { Provider } from 'react-redux';
|
|
|
+import store from './states/store';
|
|
|
import './app.css';
|
|
|
import { lightTheme, darkTheme } from './themes';
|
|
|
+import ProductSelector from './components/ProductSelector';
|
|
|
|
|
|
const locale = (window.navigator.language || 'en').toLowerCase().split('-')[0]; // Get locale from browser or default to 'en'
|
|
|
import messages_en from './assets/i18n/messages/en';
|
|
@@ -38,51 +41,54 @@ function App({ children }: PropsWithChildren<React.ReactNode>) {
|
|
|
// children 是将要会渲染的页面
|
|
|
// return children
|
|
|
return (
|
|
|
- <ConfigProvider theme={currentTheme}>
|
|
|
- <IntlProvider locale={locale} messages={messages}>
|
|
|
- <div
|
|
|
- style={{
|
|
|
- backgroundColor: currentTheme.token.colorBgLayout,
|
|
|
- color: currentTheme.token.colorText,
|
|
|
- borderRadius: '8px',
|
|
|
- boxShadow: '0 2px 8px rgba(0,0,0,0.1)',
|
|
|
- }}
|
|
|
- >
|
|
|
- {children}
|
|
|
+ <Provider store={store}>
|
|
|
+ <ConfigProvider theme={currentTheme}>
|
|
|
+ <IntlProvider locale={locale} messages={messages}>
|
|
|
<div
|
|
|
style={{
|
|
|
- position: 'fixed',
|
|
|
- top: '50%',
|
|
|
- right: 16,
|
|
|
- transform: 'translateY(-50%)',
|
|
|
- display: 'flex',
|
|
|
- flexDirection: 'column',
|
|
|
- gap: 8, // 按钮间距
|
|
|
- zIndex: 1000,
|
|
|
+ backgroundColor: currentTheme.token.colorBgLayout,
|
|
|
+ color: currentTheme.token.colorText,
|
|
|
+ borderRadius: '8px',
|
|
|
+ boxShadow: '0 2px 8px rgba(0,0,0,0.1)',
|
|
|
}}
|
|
|
>
|
|
|
- <Button
|
|
|
- type="primary"
|
|
|
- shape="circle"
|
|
|
- size="large"
|
|
|
- onClick={() => changeTheme(darkTheme)}
|
|
|
- title="Switch to Dark Theme"
|
|
|
+ {children}
|
|
|
+ {process.env.NODE_ENV === 'development' && <ProductSelector />}
|
|
|
+ <div
|
|
|
+ style={{
|
|
|
+ position: 'fixed',
|
|
|
+ top: '50%',
|
|
|
+ right: 16,
|
|
|
+ transform: 'translateY(-50%)',
|
|
|
+ display: 'flex',
|
|
|
+ flexDirection: 'column',
|
|
|
+ gap: 8, // 按钮间距
|
|
|
+ zIndex: 1000,
|
|
|
+ }}
|
|
|
>
|
|
|
- 🌙
|
|
|
- </Button>
|
|
|
- <Button
|
|
|
- type="primary"
|
|
|
- shape="circle"
|
|
|
- size="large"
|
|
|
- onClick={() => changeTheme(lightTheme)}
|
|
|
- title="Switch to Light Theme"
|
|
|
- >
|
|
|
- ☀️
|
|
|
- </Button>
|
|
|
+ <Button
|
|
|
+ type="primary"
|
|
|
+ shape="circle"
|
|
|
+ size="large"
|
|
|
+ onClick={() => changeTheme(darkTheme)}
|
|
|
+ title="Switch to Dark Theme"
|
|
|
+ >
|
|
|
+ 🌙
|
|
|
+ </Button>
|
|
|
+ <Button
|
|
|
+ type="primary"
|
|
|
+ shape="circle"
|
|
|
+ size="large"
|
|
|
+ onClick={() => changeTheme(lightTheme)}
|
|
|
+ title="Switch to Light Theme"
|
|
|
+ >
|
|
|
+ ☀️
|
|
|
+ </Button>
|
|
|
+ </div>
|
|
|
</div>
|
|
|
- </div>
|
|
|
- </IntlProvider>
|
|
|
- </ConfigProvider>
|
|
|
+ </IntlProvider>
|
|
|
+ </ConfigProvider>
|
|
|
+ </Provider>
|
|
|
);
|
|
|
}
|
|
|
|