Browse Source

feat: 脚手架更新

pull/11102/head
Evil 2 years ago
parent
commit
07bd2463af
  1. 5
      config/config.ts
  2. 2
      config/defaultSettings.ts
  3. 5
      package.json
  4. 4
      public/scripts/loading.js
  5. 3
      src/components/Footer/index.tsx
  6. 5
      src/pages/User/Login/index.tsx
  7. 5
      src/pages/Welcome.tsx
  8. 23
      update.js

5
config/config.ts

@ -8,6 +8,9 @@ import routes from './routes';
const { REACT_APP_ENV = 'dev' } = process.env; const { REACT_APP_ENV = 'dev' } = process.env;
export default defineConfig({ export default defineConfig({
alias: {
config: '/config',
},
// 解决刷新 404 找不到该页面的情况。 // 解决刷新 404 找不到该页面的情况。
exportStatic: { exportStatic: {
// 忽略预渲染失败的错误 // 忽略预渲染失败的错误
@ -82,7 +85,7 @@ export default defineConfig({
* @name layout * @name layout
* @doc https://umijs.org/docs/max/layout-menu * @doc https://umijs.org/docs/max/layout-menu
*/ */
title: 'Evil Pro Cli', title: defaultSettings?.title,
layout: { layout: {
locale: true, locale: true,
...defaultSettings, ...defaultSettings,

2
config/defaultSettings.ts

@ -26,7 +26,7 @@ const defaultSettings: ProLayoutProps & {
colorTextMenuItemHover: '#13c2c2', colorTextMenuItemHover: '#13c2c2',
}, },
header: { header: {
colorTextRightActionsItem: 'rgba(0, 0, 0, 0.88)', colorTextRightActionsItem: 'red',
}, },
}, },
}; };

5
package.json

@ -1,6 +1,6 @@
{ {
"name": "evil-pro-cli", "name": "evil-pro-cli",
"version": "6.6.0", "version": "1.1.0",
"description": "An out-of-box UI solution for enterprise applications", "description": "An out-of-box UI solution for enterprise applications",
"scripts": { "scripts": {
"analyze": "cross-env ANALYZE=1 max build", "analyze": "cross-env ANALYZE=1 max build",
@ -31,7 +31,8 @@
"test": "jest", "test": "jest",
"test:coverage": "npm run jest -- --coverage", "test:coverage": "npm run jest -- --coverage",
"test:update": "npm run jest -- -u", "test:update": "npm run jest -- -u",
"tsc": "tsc --noEmit" "tsc": "tsc --noEmit",
"update-setting": "node update.js `Evil Pro Cli`"
}, },
"lint-staged": { "lint-staged": {
"**/*.{js,jsx,ts,tsx}": "npm run lint-staged:js", "**/*.{js,jsx,ts,tsx}": "npm run lint-staged:js",

4
public/scripts/loading.js

@ -43,7 +43,7 @@
margin: 0; margin: 0;
padding: 0; padding: 0;
color: rgba(0, 0, 0, 0.65); color: rgba(0, 0, 0, 0.65);
color: #1890ff; color: #13c2c2;
font-size: 14px; font-size: 14px;
font-variant: tabular-nums; font-variant: tabular-nums;
line-height: 1.5; line-height: 1.5;
@ -80,7 +80,7 @@
display: block; display: block;
width: 9px; width: 9px;
height: 9px; height: 9px;
background-color: #1890ff; background-color: #13c2c2;
border-radius: 100%; border-radius: 100%;
-webkit-transform: scale(0.75); -webkit-transform: scale(0.75);
-ms-transform: scale(0.75); -ms-transform: scale(0.75);

3
src/components/Footer/index.tsx

@ -1,8 +1,9 @@
import { DefaultFooter } from '@ant-design/pro-components'; import { DefaultFooter } from '@ant-design/pro-components';
import defaultSettings from 'config/defaultSettings';
import React from 'react'; import React from 'react';
const Footer: React.FC = () => { const Footer: React.FC = () => {
const defaultMessage = 'Evil Pro Cli'; const defaultMessage = defaultSettings?.title;
const currentYear = new Date().getFullYear(); const currentYear = new Date().getFullYear();
const branchName = process.env.FRONTEND_BRANCH_NAME || 'release_v1.0.0'; const branchName = process.env.FRONTEND_BRANCH_NAME || 'release_v1.0.0';
const version = branchName.replace('release_', ''); const version = branchName.replace('release_', '');

5
src/pages/User/Login/index.tsx

@ -5,10 +5,9 @@ import { Helmet, history } from '@umijs/max';
import classNames from 'classnames/bind'; import classNames from 'classnames/bind';
import React from 'react'; import React from 'react';
import defaultSettings from '../../../../config/defaultSettings';
import { login } from '@/services/evil-pro-cli/login'; import { login } from '@/services/evil-pro-cli/login';
import { message } from 'antd'; import { message } from 'antd';
import defaultSettings from 'config/defaultSettings';
import styles from './index.less'; import styles from './index.less';
const cx = classNames.bind(styles); const cx = classNames.bind(styles);
@ -47,7 +46,7 @@ const Login: React.FC = () => {
maxWidth: '75vw', maxWidth: '75vw',
}} }}
logo={<img alt="logo" src="/images/logo_simple.png" />} logo={<img alt="logo" src="/images/logo_simple.png" />}
title="Evil Pro Cli" title={defaultSettings?.title}
onFinish={async (values) => { onFinish={async (values) => {
await handleSubmit(values as any); await handleSubmit(values as any);
}} }}

5
src/pages/Welcome.tsx

@ -1,6 +1,7 @@
import { PageContainer } from '@ant-design/pro-components'; import { PageContainer } from '@ant-design/pro-components';
import { useModel } from '@umijs/max'; import { useModel } from '@umijs/max';
import { Card, theme } from 'antd'; import { Card, theme } from 'antd';
import defaultSettings from 'config/defaultSettings';
import React from 'react'; import React from 'react';
/** /**
@ -114,7 +115,7 @@ const Welcome: React.FC = () => {
color: token.colorTextHeading, color: token.colorTextHeading,
}} }}
> >
使 Evil Pro Cli 使 {defaultSettings?.title}
</div> </div>
<p <p
style={{ style={{
@ -126,7 +127,7 @@ const Welcome: React.FC = () => {
width: '65%', width: '65%',
}} }}
> >
Evil Pro Cli umiAnt Design ProComponents {defaultSettings?.title} umiAnt Design ProComponents
// //
</p> </p>
<div <div

23
update.js

@ -0,0 +1,23 @@
const fs = require('fs');
const path = require('path');
const newTitle = process.argv[2] || 'Evil Pro Cli';
// 修改 config/config.ts 文件中的 name 和 title
function updateDefaultSettings() {
const configFilePath = path.join(__dirname, 'config/defaultSettings.ts');
// 读取原始的 config.ts 文件内容
const configFileContent = fs.readFileSync(configFilePath, 'utf-8');
// 修改 name 和 title 字段
const updatedConfigFileContent = configFileContent.replace(/title: '.*'/, `title: '${newTitle}'`);
// 写回 config.ts 文件
fs.writeFileSync(configFilePath, updatedConfigFileContent, 'utf-8');
console.log(`Updated defaultSetting: title - ${newTitle}`);
}
// 运行修改操作
updateDefaultSettings();
Loading…
Cancel
Save