Skip to content

Commit

Permalink
feat(页脚组件): 新增页脚组件显示构建时间
Browse files Browse the repository at this point in the history
修改package.json,添加cross-env依赖,用于在构建时设置环境变量REACT_APP_BUILD_TIME
  • Loading branch information
alanhe421 committed Dec 2, 2024
1 parent ffb1f01 commit 7e912c1
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 2 deletions.
21 changes: 21 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"build": "cross-env REACT_APP_BUILD_TIME=\"%date% %time%\" react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
},
Expand All @@ -34,5 +34,8 @@
"last 1 firefox version",
"last 1 safari version"
]
},
"devDependencies": {
"cross-env": "^7.0.3"
}
}
4 changes: 3 additions & 1 deletion src/App.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
import React from 'react';
import Upload from './components/Upload';
import Setting from './components/Setting';
import Footer from './components/Footer';

function App() {
return (
<div className="App">
<div className="App min-h-screen pb-16 relative">
<Setting />
<Upload />
<Footer />
</div>
);
}
Expand Down
11 changes: 11 additions & 0 deletions src/components/Footer.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import React from 'react';

function Footer() {
return (
<div className="fixed bottom-0 left-0 right-0 p-4 text-center text-gray-500 text-sm bg-white border-t">
构建时间:{process.env.REACT_APP_BUILD_TIME || '开发环境'}
</div>
);
}

export default Footer;

0 comments on commit 7e912c1

Please sign in to comment.