diff --git a/config/config.ts b/config/config.ts index 9db7b9d..efcc1e4 100644 --- a/config/config.ts +++ b/config/config.ts @@ -152,9 +152,7 @@ export default defineConfig({ mock: { include: ['mock/**/*', 'src/pages/**/_mock.ts'], }, - mfsu: { - strategy: 'normal', - }, + esbuildMinifyIIFE: true, requestRecord: {}, }); diff --git a/config/routes.ts b/config/routes.ts index ed7e6fc..cb6d54d 100644 --- a/config/routes.ts +++ b/config/routes.ts @@ -1,4 +1,4 @@ -/** +/** * @name umi 的路由配置 * @description 只支持 path,component,routes,redirect,wrappers,name,icon 的配置 * @param path path 只支持两种占位符配置,第一种是动态参数 :id 的形式,第二种是 * 通配符,通配符只能出现路由字符串的最后。 @@ -100,6 +100,12 @@ export default [ path: '/account/settings', component: './account/settings', }, + { + path: '/share/:shareId', + layout: false, + auth: false, + component: './share/[shareId]', + }, { path: '/', redirect: '/account', diff --git a/nginx.conf b/nginx.conf index ba46c05..8f439f5 100644 --- a/nginx.conf +++ b/nginx.conf @@ -41,6 +41,16 @@ http { proxy_pass http://localhost:33333/story/; } + # MinIO 对象存储代理 + # 需要在后端配置 minio.externalEndpoint 为 http:///minio + location /minio/ { + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header Host $http_host; + proxy_set_header X-Forwarded-Proto $scheme; + proxy_pass http://localhost:9000/; + } + location / { root /usr/share/nginx/html; index index.html index.htm; diff --git a/package.json b/package.json index 288de4a..359bb4f 100644 --- a/package.json +++ b/package.json @@ -52,6 +52,7 @@ "@umijs/route-utils": "^2.2.2", "antd": "^5.12.7", "antd-img-crop": "^4.25.0", + "antd-mobile": "^5.42.3", "antd-style": "^3.6.1", "classnames": "^2.5.1", "dayjs": "^1.11.10", @@ -62,6 +63,8 @@ "react": "^18.3.1", "react-dom": "^18.3.1", "react-fittext": "^1.0.0", + "react-helmet": "^6.1.0", + "react-player": "^3.4.0", "react-virtualized-auto-sizer": "^1.0.26", "react-window": "^1.8.11", "sockjs-client": "^1.6.1" diff --git a/src/app.tsx b/src/app.tsx index 82c8613..c751543 100644 --- a/src/app.tsx +++ b/src/app.tsx @@ -1,106 +1,72 @@ -import { AvatarDropdown, AvatarName, Footer, Question, SelectLang } from '@/components'; + +import { AvatarDropdown, AvatarName, ClientOnly, Footer, Question, SelectLang } from '@/components'; import { LinkOutlined } from '@ant-design/icons'; import type { Settings as LayoutSettings } from '@ant-design/pro-components'; import { SettingDrawer } from '@ant-design/pro-components'; import type { RequestConfig, RunTimeLayoutConfig } from '@umijs/max'; import { history, Link } from '@umijs/max'; +import { useIsMobile } from '@/hooks/useIsMobile'; import defaultSettings from '../config/defaultSettings'; import { errorConfig } from './requestErrorConfig'; import { currentUser as queryCurrentUser } from './services/ant-design-pro/api'; +import { useNotifications } from '@/hooks/useNotifications'; +import BottomNav from '@/components/BottomNav'; + const isDev = process.env.NODE_ENV === 'development'; const loginPath = '/user/login'; -/** - * @see https://umijs.org/zh-CN/plugins/plugin-initial-state - * */ export async function getInitialState(): Promise<{ settings?: Partial; - currentUser?: UserInfo; + currentUser?: API.CurrentUser; loading?: boolean; - logoutUser?: () => void }> { - const readCachedUser = (): UserInfo | undefined => { - const cached = localStorage.getItem('timeline_user'); - if (!cached) return undefined; - try { - return JSON.parse(cached) as UserInfo;; - } catch { - return undefined; - } - }; const fetchUserInfo = async () => { try { - const msg = await queryCurrentUser({ - skipErrorHandler: true, - }); + const msg = await queryCurrentUser({ skipErrorHandler: true }); return msg.data; } catch (error) { - history.push(loginPath); + // history.push(loginPath); } return undefined; }; - const logoutUser = () => { - localStorage.removeItem("timeline_user"); - } - // 如果不是登录页面,执行 - const { location } = history; - const cachedUser = readCachedUser(); - if (![loginPath, '/user/register', '/user/register-result'].includes(location.pathname)) { - const currentUser = cachedUser; + + if (history.location.pathname !== loginPath) { + const currentUser = await fetchUserInfo(); return { currentUser, settings: defaultSettings as Partial, }; } return { - currentUser: cachedUser, - logoutUser, settings: defaultSettings as Partial, }; } -// ProLayout 支持的api https://procomponents.ant.design/components/layout export const layout: RunTimeLayoutConfig = ({ initialState, setInitialState }) => { + const isMobile = useIsMobile(); + useNotifications(); + return { - actionsRender: () => [, ], + actionsRender: () => [ + + , + + , + ], avatarProps: { src: initialState?.currentUser?.avatar, title: , render: (_, avatarChildren) => { - return {avatarChildren}; + return {avatarChildren}; }, }, - /*waterMarkProps: { - content: initialState?.currentUser?.name, - },*/ - // footerRender: () =>