Skip to content

Commit

Permalink
feat: add env
Browse files Browse the repository at this point in the history
  • Loading branch information
Xutaotaotao committed May 14, 2024
1 parent 4d31e9a commit 3da2381
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 5 deletions.
5 changes: 5 additions & 0 deletions .umirc.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
import { defineConfig } from 'umi';

console.log('process.env.ENV', process.env.ENV);

export default defineConfig({
title: 'XTools',
base: '/XTools/',
publicPath: '/XTools/',
exportStatic: {},
esbuildMinifyIIFE: true,
define:{
ENV: process.env.ENV
},
metas:[
{
keywords:'XTools,xtools,xutaotao,图片压缩,图片切割,Json格式化,在线工具,前端工具,前端开发,专注工具,助力高效,完全本地化工具,无需云端,不担心隐私泄露'
Expand Down
1 change: 1 addition & 0 deletions global.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
declare const ENV: string;
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"private": true,
"author": "Xutaotaotao <[email protected]>",
"scripts": {
"dev": "umi dev",
"dev": "cross-env ENV=dev umi dev",
"build": "umi build",
"postinstall": "umi setup",
"setup": "umi setup",
Expand All @@ -20,6 +20,7 @@
"@types/react-dom": "^18.0.11",
"antd": "^5.16.4",
"compressorjs": "^1.2.1",
"cross-env": "^7.0.3",
"gh-pages": "^6.1.1",
"heic2any": "^0.0.4",
"json-diff-kit": "^1.0.29",
Expand Down
8 changes: 5 additions & 3 deletions src/layouts/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ const { Text,Title } = Typography;

const XLayout = () => {
const location = useLocation();

const handleImageError = (
e: React.SyntheticEvent<HTMLImageElement, Event>
) => {
Expand All @@ -34,11 +33,14 @@ const XLayout = () => {
alt="logo"
style={{ height: "48px", cursor: "pointer" }}
/>
<img
{
ENV !== 'dev' ? <img
style={{ marginLeft: "10px" }}
src="https://visitor-badge.laobi.icu/badge?page_id=xutaotaotao.github.io.XTools"
onError={handleImageError}
/>
/> : null
}

</div>
</Nav.Header>
<Nav.Footer>
Expand Down
9 changes: 8 additions & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2783,6 +2783,13 @@ create-hmac@^1.1.0, create-hmac@^1.1.4, create-hmac@^1.1.7:
safe-buffer "^5.0.1"
sha.js "^2.4.8"

cross-env@^7.0.3:
version "7.0.3"
resolved "https://registry.npmmirror.com/cross-env/-/cross-env-7.0.3.tgz#865264b29677dc015ba8418918965dd232fc54cf"
integrity sha512-+/HKd6EgcQCJGh2PSjZuUitQBQynKor4wrFbRg4DtAgS1aWO+gU52xpH7M9ScGgXSYmAVS9bIJ8EzuaGw0oNAw==
dependencies:
cross-spawn "^7.0.1"

cross-fetch@^3.1.5:
version "3.1.8"
resolved "https://registry.npmmirror.com/cross-fetch/-/cross-fetch-3.1.8.tgz#0327eba65fd68a7d119f8fb2bf9334a1a7956f82"
Expand All @@ -2801,7 +2808,7 @@ cross-spawn@^6.0.0:
shebang-command "^1.2.0"
which "^1.2.9"

cross-spawn@^7.0.3:
cross-spawn@^7.0.1, cross-spawn@^7.0.3:
version "7.0.3"
resolved "https://registry.yarnpkg.com/cross-spawn/-/cross-spawn-7.0.3.tgz#f73a85b9d5d41d045551c177e2882d4ac85728a6"
integrity sha512-iRDPJKUPVEND7dHPO8rkbOnPpyDygcDFtWjpeWNCgy8WP2rXcxXL8TskReQl6OrB2G7+UJrags1q15Fudc7G6w==
Expand Down

0 comments on commit 3da2381

Please sign in to comment.