init
|
|
@ -0,0 +1,28 @@
|
||||||
|
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
|
||||||
|
|
||||||
|
# dependencies
|
||||||
|
/node_modules
|
||||||
|
/.pnp
|
||||||
|
.pnp.js
|
||||||
|
|
||||||
|
# testing
|
||||||
|
/coverage
|
||||||
|
|
||||||
|
# production
|
||||||
|
/build
|
||||||
|
/log
|
||||||
|
.idea
|
||||||
|
# misc
|
||||||
|
.DS_Store
|
||||||
|
.env.local
|
||||||
|
.env.development.local
|
||||||
|
.env.test.local
|
||||||
|
.env.production.local
|
||||||
|
|
||||||
|
npm-debug.log*
|
||||||
|
yarn-debug.log*
|
||||||
|
yarn-error.log*
|
||||||
|
yarn.lock
|
||||||
|
pnpm-lock.yaml
|
||||||
|
package-lock.json
|
||||||
|
.env
|
||||||
|
|
@ -0,0 +1,13 @@
|
||||||
|
FROM registry.cn-shanghai.aliyuncs.com/devcon/node:18
|
||||||
|
ADD . /app
|
||||||
|
WORKDIR /app
|
||||||
|
RUN mkdir /app/log
|
||||||
|
RUN cd /app && \
|
||||||
|
chmod +x start.sh && \
|
||||||
|
npm config set registry https://registry.npmmirror.com/ && \
|
||||||
|
npm install && \
|
||||||
|
npm run build
|
||||||
|
EXPOSE 9293
|
||||||
|
CMD [ "/app/start.sh" ]
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -0,0 +1,46 @@
|
||||||
|
# Getting Started with Create React App
|
||||||
|
|
||||||
|
This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app).
|
||||||
|
|
||||||
|
## Available Scripts
|
||||||
|
|
||||||
|
In the project directory, you can run:
|
||||||
|
|
||||||
|
### `npm start`
|
||||||
|
|
||||||
|
Runs the app in the development mode.\
|
||||||
|
Open [http://localhost:3000](http://localhost:3000) to view it in the browser.
|
||||||
|
|
||||||
|
The page will reload if you make edits.\
|
||||||
|
You will also see any lint errors in the console.
|
||||||
|
|
||||||
|
### `npm test`
|
||||||
|
|
||||||
|
Launches the test runner in the interactive watch mode.\
|
||||||
|
See the section about [running tests](https://facebook.github.io/create-react-app/docs/running-tests) for more information.
|
||||||
|
|
||||||
|
### `npm run build`
|
||||||
|
|
||||||
|
Builds the app for production to the `build` folder.\
|
||||||
|
It correctly bundles React in production mode and optimizes the build for the best performance.
|
||||||
|
|
||||||
|
The build is minified and the filenames include the hashes.\
|
||||||
|
Your app is ready to be deployed!
|
||||||
|
|
||||||
|
See the section about [deployment](https://facebook.github.io/create-react-app/docs/deployment) for more information.
|
||||||
|
|
||||||
|
### `npm run eject`
|
||||||
|
|
||||||
|
**Note: this is a one-way operation. Once you `eject`, you can’t go back!**
|
||||||
|
|
||||||
|
If you aren’t satisfied with the build tool and configuration choices, you can `eject` at any time. This command will remove the single build dependency from your project.
|
||||||
|
|
||||||
|
Instead, it will copy all the configuration files and the transitive dependencies (webpack, Babel, ESLint, etc) right into your project so you have full control over them. All of the commands except `eject` will still work, but they will point to the copied scripts so you can tweak them. At this point you’re on your own.
|
||||||
|
|
||||||
|
You don’t have to ever use `eject`. The curated feature set is suitable for small and middle deployments, and you shouldn’t feel obligated to use this feature. However we understand that this tool wouldn’t be useful if you couldn’t customize it when you are ready for it.
|
||||||
|
|
||||||
|
## Learn More
|
||||||
|
|
||||||
|
You can learn more in the [Create React App documentation](https://facebook.github.io/create-react-app/docs/getting-started).
|
||||||
|
|
||||||
|
To learn React, check out the [React documentation](https://reactjs.org/).
|
||||||
|
|
@ -0,0 +1,104 @@
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
const fs = require('fs');
|
||||||
|
const path = require('path');
|
||||||
|
const paths = require('./paths');
|
||||||
|
|
||||||
|
// Make sure that including paths.js after env.js will read .env variables.
|
||||||
|
delete require.cache[require.resolve('./paths')];
|
||||||
|
|
||||||
|
const NODE_ENV = process.env.NODE_ENV;
|
||||||
|
if (!NODE_ENV) {
|
||||||
|
throw new Error(
|
||||||
|
'The NODE_ENV environment variable is required but was not specified.'
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
// https://github.com/bkeepers/dotenv#what-other-env-files-can-i-use
|
||||||
|
const dotenvFiles = [
|
||||||
|
`${paths.dotenv}.${NODE_ENV}.local`,
|
||||||
|
// Don't include `.env.local` for `test` environment
|
||||||
|
// since normally you expect tests to produce the same
|
||||||
|
// results for everyone
|
||||||
|
NODE_ENV !== 'test' && `${paths.dotenv}.local`,
|
||||||
|
`${paths.dotenv}.${NODE_ENV}`,
|
||||||
|
paths.dotenv,
|
||||||
|
].filter(Boolean);
|
||||||
|
|
||||||
|
// Load environment variables from .env* files. Suppress warnings using silent
|
||||||
|
// if this file is missing. dotenv will never modify any environment variables
|
||||||
|
// that have already been set. Variable expansion is supported in .env files.
|
||||||
|
// https://github.com/motdotla/dotenv
|
||||||
|
// https://github.com/motdotla/dotenv-expand
|
||||||
|
dotenvFiles.forEach(dotenvFile => {
|
||||||
|
if (fs.existsSync(dotenvFile)) {
|
||||||
|
require('dotenv-expand')(
|
||||||
|
require('dotenv').config({
|
||||||
|
path: dotenvFile,
|
||||||
|
})
|
||||||
|
);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// We support resolving modules according to `NODE_PATH`.
|
||||||
|
// This lets you use absolute paths in imports inside large monorepos:
|
||||||
|
// https://github.com/facebook/create-react-app/issues/253.
|
||||||
|
// It works similar to `NODE_PATH` in Node itself:
|
||||||
|
// https://nodejs.org/api/modules.html#modules_loading_from_the_global_folders
|
||||||
|
// Note that unlike in Node, only *relative* paths from `NODE_PATH` are honored.
|
||||||
|
// Otherwise, we risk importing Node.js core modules into an app instead of webpack shims.
|
||||||
|
// https://github.com/facebook/create-react-app/issues/1023#issuecomment-265344421
|
||||||
|
// We also resolve them to make sure all tools using them work consistently.
|
||||||
|
const appDirectory = fs.realpathSync(process.cwd());
|
||||||
|
process.env.NODE_PATH = (process.env.NODE_PATH || '')
|
||||||
|
.split(path.delimiter)
|
||||||
|
.filter(folder => folder && !path.isAbsolute(folder))
|
||||||
|
.map(folder => path.resolve(appDirectory, folder))
|
||||||
|
.join(path.delimiter);
|
||||||
|
|
||||||
|
// Grab NODE_ENV and REACT_APP_* environment variables and prepare them to be
|
||||||
|
// injected into the application via DefinePlugin in webpack configuration.
|
||||||
|
const REACT_APP = /^REACT_APP_/i;
|
||||||
|
|
||||||
|
function getClientEnvironment(publicUrl) {
|
||||||
|
const raw = Object.keys(process.env)
|
||||||
|
.filter(key => REACT_APP.test(key))
|
||||||
|
.reduce(
|
||||||
|
(env, key) => {
|
||||||
|
env[key] = process.env[key];
|
||||||
|
return env;
|
||||||
|
},
|
||||||
|
{
|
||||||
|
// Useful for determining whether we’re running in production mode.
|
||||||
|
// Most importantly, it switches React into the correct mode.
|
||||||
|
NODE_ENV: process.env.NODE_ENV || 'development',
|
||||||
|
// Useful for resolving the correct path to static assets in `public`.
|
||||||
|
// For example, <img src={process.env.PUBLIC_URL + '/img/logo.png'} />.
|
||||||
|
// This should only be used as an escape hatch. Normally you would put
|
||||||
|
// images into the `src` and `import` them in code to get their paths.
|
||||||
|
PUBLIC_URL: publicUrl,
|
||||||
|
// We support configuring the sockjs pathname during development.
|
||||||
|
// These settings let a developer run multiple simultaneous projects.
|
||||||
|
// They are used as the connection `hostname`, `pathname` and `port`
|
||||||
|
// in webpackHotDevClient. They are used as the `sockHost`, `sockPath`
|
||||||
|
// and `sockPort` options in webpack-dev-server.
|
||||||
|
WDS_SOCKET_HOST: process.env.WDS_SOCKET_HOST,
|
||||||
|
WDS_SOCKET_PATH: process.env.WDS_SOCKET_PATH,
|
||||||
|
WDS_SOCKET_PORT: process.env.WDS_SOCKET_PORT,
|
||||||
|
// Whether or not react-refresh is enabled.
|
||||||
|
// It is defined here so it is available in the webpackHotDevClient.
|
||||||
|
FAST_REFRESH: process.env.FAST_REFRESH !== 'false',
|
||||||
|
}
|
||||||
|
);
|
||||||
|
// Stringify all values so we can feed into webpack DefinePlugin
|
||||||
|
const stringified = {
|
||||||
|
'process.env': Object.keys(raw).reduce((env, key) => {
|
||||||
|
env[key] = JSON.stringify(raw[key]);
|
||||||
|
return env;
|
||||||
|
}, {}),
|
||||||
|
};
|
||||||
|
|
||||||
|
return { raw, stringified };
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = getClientEnvironment;
|
||||||
|
|
@ -0,0 +1,66 @@
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
const fs = require('fs');
|
||||||
|
const path = require('path');
|
||||||
|
const crypto = require('crypto');
|
||||||
|
const chalk = require('react-dev-utils/chalk');
|
||||||
|
const paths = require('./paths');
|
||||||
|
|
||||||
|
// Ensure the certificate and key provided are valid and if not
|
||||||
|
// throw an easy to debug error
|
||||||
|
function validateKeyAndCerts({ cert, key, keyFile, crtFile }) {
|
||||||
|
let encrypted;
|
||||||
|
try {
|
||||||
|
// publicEncrypt will throw an error with an invalid cert
|
||||||
|
encrypted = crypto.publicEncrypt(cert, Buffer.from('test'));
|
||||||
|
} catch (err) {
|
||||||
|
throw new Error(
|
||||||
|
`The certificate "${chalk.yellow(crtFile)}" is invalid.\n${err.message}`
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
// privateDecrypt will throw an error with an invalid key
|
||||||
|
crypto.privateDecrypt(key, encrypted);
|
||||||
|
} catch (err) {
|
||||||
|
throw new Error(
|
||||||
|
`The certificate key "${chalk.yellow(keyFile)}" is invalid.\n${
|
||||||
|
err.message
|
||||||
|
}`
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Read file and throw an error if it doesn't exist
|
||||||
|
function readEnvFile(file, type) {
|
||||||
|
if (!fs.existsSync(file)) {
|
||||||
|
throw new Error(
|
||||||
|
`You specified ${chalk.cyan(
|
||||||
|
type
|
||||||
|
)} in your env, but the file "${chalk.yellow(file)}" can't be found.`
|
||||||
|
);
|
||||||
|
}
|
||||||
|
return fs.readFileSync(file);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get the https config
|
||||||
|
// Return cert files if provided in env, otherwise just true or false
|
||||||
|
function getHttpsConfig() {
|
||||||
|
const { SSL_CRT_FILE, SSL_KEY_FILE, HTTPS } = process.env;
|
||||||
|
const isHttps = HTTPS === 'true';
|
||||||
|
|
||||||
|
if (isHttps && SSL_CRT_FILE && SSL_KEY_FILE) {
|
||||||
|
const crtFile = path.resolve(paths.appPath, SSL_CRT_FILE);
|
||||||
|
const keyFile = path.resolve(paths.appPath, SSL_KEY_FILE);
|
||||||
|
const config = {
|
||||||
|
cert: readEnvFile(crtFile, 'SSL_CRT_FILE'),
|
||||||
|
key: readEnvFile(keyFile, 'SSL_KEY_FILE'),
|
||||||
|
};
|
||||||
|
|
||||||
|
validateKeyAndCerts({ ...config, keyFile, crtFile });
|
||||||
|
return config;
|
||||||
|
}
|
||||||
|
return isHttps;
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = getHttpsConfig;
|
||||||
|
|
@ -0,0 +1,29 @@
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
const babelJest = require('babel-jest').default;
|
||||||
|
|
||||||
|
const hasJsxRuntime = (() => {
|
||||||
|
if (process.env.DISABLE_NEW_JSX_TRANSFORM === 'true') {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
require.resolve('react/jsx-runtime');
|
||||||
|
return true;
|
||||||
|
} catch (e) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
})();
|
||||||
|
|
||||||
|
module.exports = babelJest.createTransformer({
|
||||||
|
presets: [
|
||||||
|
[
|
||||||
|
require.resolve('babel-preset-react-app'),
|
||||||
|
{
|
||||||
|
runtime: hasJsxRuntime ? 'automatic' : 'classic',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
],
|
||||||
|
babelrc: false,
|
||||||
|
configFile: false,
|
||||||
|
});
|
||||||
|
|
@ -0,0 +1,14 @@
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
// This is a custom Jest transformer turning style imports into empty objects.
|
||||||
|
// http://facebook.github.io/jest/docs/en/webpack.html
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
process() {
|
||||||
|
return 'module.exports = {};';
|
||||||
|
},
|
||||||
|
getCacheKey() {
|
||||||
|
// The output is always the same.
|
||||||
|
return 'cssTransform';
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
@ -0,0 +1,40 @@
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
const path = require('path');
|
||||||
|
const camelcase = require('camelcase');
|
||||||
|
|
||||||
|
// This is a custom Jest transformer turning file imports into filenames.
|
||||||
|
// http://facebook.github.io/jest/docs/en/webpack.html
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
process(src, filename) {
|
||||||
|
const assetFilename = JSON.stringify(path.basename(filename));
|
||||||
|
|
||||||
|
if (filename.match(/\.svg$/)) {
|
||||||
|
// Based on how SVGR generates a component name:
|
||||||
|
// https://github.com/smooth-code/svgr/blob/01b194cf967347d43d4cbe6b434404731b87cf27/packages/core/src/state.js#L6
|
||||||
|
const pascalCaseFilename = camelcase(path.parse(filename).name, {
|
||||||
|
pascalCase: true,
|
||||||
|
});
|
||||||
|
const componentName = `Svg${pascalCaseFilename}`;
|
||||||
|
return `const React = require('react');
|
||||||
|
module.exports = {
|
||||||
|
__esModule: true,
|
||||||
|
default: ${assetFilename},
|
||||||
|
ReactComponent: React.forwardRef(function ${componentName}(props, ref) {
|
||||||
|
return {
|
||||||
|
$$typeof: Symbol.for('react.element'),
|
||||||
|
type: 'svg',
|
||||||
|
ref: ref,
|
||||||
|
key: null,
|
||||||
|
props: Object.assign({}, props, {
|
||||||
|
children: ${assetFilename}
|
||||||
|
})
|
||||||
|
};
|
||||||
|
}),
|
||||||
|
};`;
|
||||||
|
}
|
||||||
|
|
||||||
|
return `module.exports = ${assetFilename};`;
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
@ -0,0 +1,134 @@
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
const fs = require('fs');
|
||||||
|
const path = require('path');
|
||||||
|
const paths = require('./paths');
|
||||||
|
const chalk = require('react-dev-utils/chalk');
|
||||||
|
const resolve = require('resolve');
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get additional module paths based on the baseUrl of a compilerOptions object.
|
||||||
|
*
|
||||||
|
* @param {Object} options
|
||||||
|
*/
|
||||||
|
function getAdditionalModulePaths(options = {}) {
|
||||||
|
const baseUrl = options.baseUrl;
|
||||||
|
|
||||||
|
if (!baseUrl) {
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
|
||||||
|
const baseUrlResolved = path.resolve(paths.appPath, baseUrl);
|
||||||
|
|
||||||
|
// We don't need to do anything if `baseUrl` is set to `node_modules`. This is
|
||||||
|
// the default behavior.
|
||||||
|
if (path.relative(paths.appNodeModules, baseUrlResolved) === '') {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Allow the user set the `baseUrl` to `appSrc`.
|
||||||
|
if (path.relative(paths.appSrc, baseUrlResolved) === '') {
|
||||||
|
return [paths.appSrc];
|
||||||
|
}
|
||||||
|
|
||||||
|
// If the path is equal to the root directory we ignore it here.
|
||||||
|
// We don't want to allow importing from the root directly as source files are
|
||||||
|
// not transpiled outside of `src`. We do allow importing them with the
|
||||||
|
// absolute path (e.g. `src/Components/Button.js`) but we set that up with
|
||||||
|
// an alias.
|
||||||
|
if (path.relative(paths.appPath, baseUrlResolved) === '') {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Otherwise, throw an error.
|
||||||
|
throw new Error(
|
||||||
|
chalk.red.bold(
|
||||||
|
"Your project's `baseUrl` can only be set to `src` or `node_modules`." +
|
||||||
|
' Create React App does not support other values at this time.'
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get webpack aliases based on the baseUrl of a compilerOptions object.
|
||||||
|
*
|
||||||
|
* @param {*} options
|
||||||
|
*/
|
||||||
|
function getWebpackAliases(options = {}) {
|
||||||
|
const baseUrl = options.baseUrl;
|
||||||
|
|
||||||
|
if (!baseUrl) {
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
|
||||||
|
const baseUrlResolved = path.resolve(paths.appPath, baseUrl);
|
||||||
|
|
||||||
|
if (path.relative(paths.appPath, baseUrlResolved) === '') {
|
||||||
|
return {
|
||||||
|
src: paths.appSrc,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get jest aliases based on the baseUrl of a compilerOptions object.
|
||||||
|
*
|
||||||
|
* @param {*} options
|
||||||
|
*/
|
||||||
|
function getJestAliases(options = {}) {
|
||||||
|
const baseUrl = options.baseUrl;
|
||||||
|
|
||||||
|
if (!baseUrl) {
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
|
||||||
|
const baseUrlResolved = path.resolve(paths.appPath, baseUrl);
|
||||||
|
|
||||||
|
if (path.relative(paths.appPath, baseUrlResolved) === '') {
|
||||||
|
return {
|
||||||
|
'^src/(.*)$': '<rootDir>/src/$1',
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function getModules() {
|
||||||
|
// Check if TypeScript is setup
|
||||||
|
const hasTsConfig = fs.existsSync(paths.appTsConfig);
|
||||||
|
const hasJsConfig = fs.existsSync(paths.appJsConfig);
|
||||||
|
|
||||||
|
if (hasTsConfig && hasJsConfig) {
|
||||||
|
throw new Error(
|
||||||
|
'You have both a tsconfig.json and a jsconfig.json. If you are using TypeScript please remove your jsconfig.json file.'
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
let config;
|
||||||
|
|
||||||
|
// If there's a tsconfig.json we assume it's a
|
||||||
|
// TypeScript project and set up the config
|
||||||
|
// based on tsconfig.json
|
||||||
|
if (hasTsConfig) {
|
||||||
|
const ts = require(resolve.sync('typescript', {
|
||||||
|
basedir: paths.appNodeModules,
|
||||||
|
}));
|
||||||
|
config = ts.readConfigFile(paths.appTsConfig, ts.sys.readFile).config;
|
||||||
|
// Otherwise we'll check if there is jsconfig.json
|
||||||
|
// for non TS projects.
|
||||||
|
} else if (hasJsConfig) {
|
||||||
|
config = require(paths.appJsConfig);
|
||||||
|
}
|
||||||
|
|
||||||
|
config = config || {};
|
||||||
|
const options = config.compilerOptions || {};
|
||||||
|
|
||||||
|
const additionalModulePaths = getAdditionalModulePaths(options);
|
||||||
|
|
||||||
|
return {
|
||||||
|
additionalModulePaths: additionalModulePaths,
|
||||||
|
webpackAliases: getWebpackAliases(options),
|
||||||
|
jestAliases: getJestAliases(options),
|
||||||
|
hasTsConfig,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = getModules();
|
||||||
|
|
@ -0,0 +1,77 @@
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
const path = require('path');
|
||||||
|
const fs = require('fs');
|
||||||
|
const getPublicUrlOrPath = require('react-dev-utils/getPublicUrlOrPath');
|
||||||
|
|
||||||
|
// Make sure any symlinks in the project folder are resolved:
|
||||||
|
// https://github.com/facebook/create-react-app/issues/637
|
||||||
|
const appDirectory = fs.realpathSync(process.cwd());
|
||||||
|
const resolveApp = relativePath => path.resolve(appDirectory, relativePath);
|
||||||
|
|
||||||
|
// We use `PUBLIC_URL` environment variable or "homepage" field to infer
|
||||||
|
// "public path" at which the app is served.
|
||||||
|
// webpack needs to know it to put the right <script> hrefs into HTML even in
|
||||||
|
// single-page apps that may serve index.html for nested URLs like /todos/42.
|
||||||
|
// We can't use a relative path in HTML because we don't want to load something
|
||||||
|
// like /todos/42/static/js/bundle.7289d.js. We have to know the root.
|
||||||
|
const publicUrlOrPath = getPublicUrlOrPath(
|
||||||
|
process.env.NODE_ENV === 'development',
|
||||||
|
require(resolveApp('package.json')).homepage,
|
||||||
|
process.env.PUBLIC_URL
|
||||||
|
);
|
||||||
|
|
||||||
|
const buildPath = process.env.BUILD_PATH || 'build';
|
||||||
|
|
||||||
|
const moduleFileExtensions = [
|
||||||
|
'web.mjs',
|
||||||
|
'mjs',
|
||||||
|
'web.js',
|
||||||
|
'js',
|
||||||
|
'web.ts',
|
||||||
|
'ts',
|
||||||
|
'web.tsx',
|
||||||
|
'tsx',
|
||||||
|
'json',
|
||||||
|
'web.jsx',
|
||||||
|
'jsx',
|
||||||
|
];
|
||||||
|
|
||||||
|
// Resolve file paths in the same order as webpack
|
||||||
|
const resolveModule = (resolveFn, filePath) => {
|
||||||
|
const extension = moduleFileExtensions.find(extension =>
|
||||||
|
fs.existsSync(resolveFn(`${filePath}.${extension}`))
|
||||||
|
);
|
||||||
|
|
||||||
|
if (extension) {
|
||||||
|
return resolveFn(`${filePath}.${extension}`);
|
||||||
|
}
|
||||||
|
|
||||||
|
return resolveFn(`${filePath}.js`);
|
||||||
|
};
|
||||||
|
|
||||||
|
// config after eject: we're in ./config/
|
||||||
|
module.exports = {
|
||||||
|
dotenv: resolveApp('.env'),
|
||||||
|
appPath: resolveApp('.'),
|
||||||
|
appBuild: resolveApp(buildPath),
|
||||||
|
appPublic: resolveApp('public'),
|
||||||
|
appHtml: resolveApp('public/index.html'),
|
||||||
|
appIndexJs: resolveModule(resolveApp, 'src/index'),
|
||||||
|
appPackageJson: resolveApp('package.json'),
|
||||||
|
appSrc: resolveApp('src'),
|
||||||
|
appTsConfig: resolveApp('tsconfig.json'),
|
||||||
|
appJsConfig: resolveApp('jsconfig.json'),
|
||||||
|
yarnLockFile: resolveApp('yarn.lock'),
|
||||||
|
testsSetup: resolveModule(resolveApp, 'src/setupTests'),
|
||||||
|
proxySetup: resolveApp('src/setupProxy.js'),
|
||||||
|
appNodeModules: resolveApp('node_modules'),
|
||||||
|
appWebpackCache: resolveApp('node_modules/.cache'),
|
||||||
|
appTsBuildInfoFile: resolveApp('node_modules/.cache/tsconfig.tsbuildinfo'),
|
||||||
|
swSrc: resolveModule(resolveApp, 'src/service-worker'),
|
||||||
|
publicUrlOrPath,
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
module.exports.moduleFileExtensions = moduleFileExtensions;
|
||||||
|
|
@ -0,0 +1,756 @@
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
const fs = require('fs');
|
||||||
|
const path = require('path');
|
||||||
|
const webpack = require('webpack');
|
||||||
|
const resolve = require('resolve');
|
||||||
|
const HtmlWebpackPlugin = require('html-webpack-plugin');
|
||||||
|
const CaseSensitivePathsPlugin = require('case-sensitive-paths-webpack-plugin');
|
||||||
|
const InlineChunkHtmlPlugin = require('react-dev-utils/InlineChunkHtmlPlugin');
|
||||||
|
const TerserPlugin = require('terser-webpack-plugin');
|
||||||
|
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
|
||||||
|
const CssMinimizerPlugin = require('css-minimizer-webpack-plugin');
|
||||||
|
const { WebpackManifestPlugin } = require('webpack-manifest-plugin');
|
||||||
|
const InterpolateHtmlPlugin = require('react-dev-utils/InterpolateHtmlPlugin');
|
||||||
|
const WorkboxWebpackPlugin = require('workbox-webpack-plugin');
|
||||||
|
const ModuleScopePlugin = require('react-dev-utils/ModuleScopePlugin');
|
||||||
|
const getCSSModuleLocalIdent = require('react-dev-utils/getCSSModuleLocalIdent');
|
||||||
|
const ESLintPlugin = require('eslint-webpack-plugin');
|
||||||
|
const paths = require('./paths');
|
||||||
|
const modules = require('./modules');
|
||||||
|
const getClientEnvironment = require('./env');
|
||||||
|
const ModuleNotFoundPlugin = require('react-dev-utils/ModuleNotFoundPlugin');
|
||||||
|
const ForkTsCheckerWebpackPlugin =
|
||||||
|
process.env.TSC_COMPILE_ON_ERROR === 'true'
|
||||||
|
? require('react-dev-utils/ForkTsCheckerWarningWebpackPlugin')
|
||||||
|
: require('react-dev-utils/ForkTsCheckerWebpackPlugin');
|
||||||
|
const ReactRefreshWebpackPlugin = require('@pmmmwh/react-refresh-webpack-plugin');
|
||||||
|
|
||||||
|
const createEnvironmentHash = require('./webpack/persistentCache/createEnvironmentHash');
|
||||||
|
|
||||||
|
// Source maps are resource heavy and can cause out of memory issue for large source files.
|
||||||
|
const shouldUseSourceMap = process.env.GENERATE_SOURCEMAP !== 'false';
|
||||||
|
|
||||||
|
const reactRefreshRuntimeEntry = require.resolve('react-refresh/runtime');
|
||||||
|
const reactRefreshWebpackPluginRuntimeEntry = require.resolve(
|
||||||
|
'@pmmmwh/react-refresh-webpack-plugin'
|
||||||
|
);
|
||||||
|
const babelRuntimeEntry = require.resolve('babel-preset-react-app');
|
||||||
|
const babelRuntimeEntryHelpers = require.resolve(
|
||||||
|
'@babel/runtime/helpers/esm/assertThisInitialized',
|
||||||
|
{ paths: [babelRuntimeEntry] }
|
||||||
|
);
|
||||||
|
const babelRuntimeRegenerator = require.resolve('@babel/runtime/regenerator', {
|
||||||
|
paths: [babelRuntimeEntry],
|
||||||
|
});
|
||||||
|
|
||||||
|
// Some apps do not need the benefits of saving a web request, so not inlining the chunk
|
||||||
|
// makes for a smoother build process.
|
||||||
|
const shouldInlineRuntimeChunk = process.env.INLINE_RUNTIME_CHUNK !== 'false';
|
||||||
|
|
||||||
|
const emitErrorsAsWarnings = process.env.ESLINT_NO_DEV_ERRORS === 'true';
|
||||||
|
const disableESLintPlugin = process.env.DISABLE_ESLINT_PLUGIN === 'true';
|
||||||
|
|
||||||
|
const imageInlineSizeLimit = parseInt(
|
||||||
|
process.env.IMAGE_INLINE_SIZE_LIMIT || '10000'
|
||||||
|
);
|
||||||
|
|
||||||
|
// Check if TypeScript is setup
|
||||||
|
const useTypeScript = fs.existsSync(paths.appTsConfig);
|
||||||
|
|
||||||
|
// Check if Tailwind config exists
|
||||||
|
const useTailwind = fs.existsSync(
|
||||||
|
path.join(paths.appPath, 'tailwind.config.js')
|
||||||
|
);
|
||||||
|
|
||||||
|
// Get the path to the uncompiled service worker (if it exists).
|
||||||
|
const swSrc = paths.swSrc;
|
||||||
|
|
||||||
|
// style files regexes
|
||||||
|
const cssRegex = /\.css$/;
|
||||||
|
const cssModuleRegex = /\.module\.css$/;
|
||||||
|
const sassRegex = /\.(scss|sass)$/;
|
||||||
|
const sassModuleRegex = /\.module\.(scss|sass)$/;
|
||||||
|
|
||||||
|
const hasJsxRuntime = (() => {
|
||||||
|
if (process.env.DISABLE_NEW_JSX_TRANSFORM === 'true') {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
require.resolve('react/jsx-runtime');
|
||||||
|
return true;
|
||||||
|
} catch (e) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
})();
|
||||||
|
|
||||||
|
// This is the production and development configuration.
|
||||||
|
// It is focused on developer experience, fast rebuilds, and a minimal bundle.
|
||||||
|
module.exports = function (webpackEnv) {
|
||||||
|
const isEnvDevelopment = webpackEnv === 'development';
|
||||||
|
const isEnvProduction = webpackEnv === 'production';
|
||||||
|
|
||||||
|
// Variable used for enabling profiling in Production
|
||||||
|
// passed into alias object. Uses a flag if passed into the build command
|
||||||
|
const isEnvProductionProfile =
|
||||||
|
isEnvProduction && process.argv.includes('--profile');
|
||||||
|
|
||||||
|
// We will provide `paths.publicUrlOrPath` to our app
|
||||||
|
// as %PUBLIC_URL% in `index.html` and `process.env.PUBLIC_URL` in JavaScript.
|
||||||
|
// Omit trailing slash as %PUBLIC_URL%/xyz looks better than %PUBLIC_URL%xyz.
|
||||||
|
// Get environment variables to inject into our app.
|
||||||
|
const env = getClientEnvironment(paths.publicUrlOrPath.slice(0, -1));
|
||||||
|
|
||||||
|
const shouldUseReactRefresh = env.raw.FAST_REFRESH;
|
||||||
|
|
||||||
|
// common function to get style loaders
|
||||||
|
const getStyleLoaders = (cssOptions, preProcessor) => {
|
||||||
|
const loaders = [
|
||||||
|
isEnvDevelopment && require.resolve('style-loader'),
|
||||||
|
isEnvProduction && {
|
||||||
|
loader: MiniCssExtractPlugin.loader,
|
||||||
|
// css is located in `static/css`, use '../../' to locate index.html folder
|
||||||
|
// in production `paths.publicUrlOrPath` can be a relative path
|
||||||
|
options: paths.publicUrlOrPath.startsWith('.')
|
||||||
|
? { publicPath: '../../' }
|
||||||
|
: {},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
loader: require.resolve('css-loader'),
|
||||||
|
options: cssOptions,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
// Options for PostCSS as we reference these options twice
|
||||||
|
// Adds vendor prefixing based on your specified browser support in
|
||||||
|
// package.json
|
||||||
|
loader: require.resolve('postcss-loader'),
|
||||||
|
options: {
|
||||||
|
postcssOptions: {
|
||||||
|
// Necessary for external CSS imports to work
|
||||||
|
// https://github.com/facebook/create-react-app/issues/2677
|
||||||
|
ident: 'postcss',
|
||||||
|
config: false,
|
||||||
|
plugins: !useTailwind
|
||||||
|
? [
|
||||||
|
'postcss-flexbugs-fixes',
|
||||||
|
[
|
||||||
|
'postcss-preset-env',
|
||||||
|
{
|
||||||
|
autoprefixer: {
|
||||||
|
flexbox: 'no-2009',
|
||||||
|
},
|
||||||
|
stage: 3,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
// Adds PostCSS Normalize as the reset css with default options,
|
||||||
|
// so that it honors browserslist config in package.json
|
||||||
|
// which in turn let's users customize the target behavior as per their needs.
|
||||||
|
'postcss-normalize',
|
||||||
|
]
|
||||||
|
: [
|
||||||
|
'tailwindcss',
|
||||||
|
'postcss-flexbugs-fixes',
|
||||||
|
[
|
||||||
|
'postcss-preset-env',
|
||||||
|
{
|
||||||
|
autoprefixer: {
|
||||||
|
flexbox: 'no-2009',
|
||||||
|
},
|
||||||
|
stage: 3,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
],
|
||||||
|
},
|
||||||
|
sourceMap: isEnvProduction ? shouldUseSourceMap : isEnvDevelopment,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
].filter(Boolean);
|
||||||
|
if (preProcessor) {
|
||||||
|
loaders.push(
|
||||||
|
{
|
||||||
|
loader: require.resolve('resolve-url-loader'),
|
||||||
|
options: {
|
||||||
|
sourceMap: isEnvProduction ? shouldUseSourceMap : isEnvDevelopment,
|
||||||
|
root: paths.appSrc,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
loader: require.resolve(preProcessor),
|
||||||
|
options: {
|
||||||
|
sourceMap: true,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
return loaders;
|
||||||
|
};
|
||||||
|
|
||||||
|
return {
|
||||||
|
target: ['browserslist'],
|
||||||
|
// Webpack noise constrained to errors and warnings
|
||||||
|
stats: 'errors-warnings',
|
||||||
|
mode: isEnvProduction ? 'production' : isEnvDevelopment && 'development',
|
||||||
|
// Stop compilation early in production
|
||||||
|
bail: isEnvProduction,
|
||||||
|
devtool: isEnvProduction
|
||||||
|
? shouldUseSourceMap
|
||||||
|
? 'source-map'
|
||||||
|
: false
|
||||||
|
: isEnvDevelopment && 'cheap-module-source-map',
|
||||||
|
// These are the "entry points" to our application.
|
||||||
|
// This means they will be the "root" imports that are included in JS bundle.
|
||||||
|
entry: paths.appIndexJs,
|
||||||
|
output: {
|
||||||
|
// The build folder.
|
||||||
|
path: paths.appBuild,
|
||||||
|
// Add /* filename */ comments to generated require()s in the output.
|
||||||
|
pathinfo: isEnvDevelopment,
|
||||||
|
// There will be one main bundle, and one file per asynchronous chunk.
|
||||||
|
// In development, it does not produce real files.
|
||||||
|
filename: isEnvProduction
|
||||||
|
? 'static/js/[name].[contenthash:8].js'
|
||||||
|
: isEnvDevelopment && 'static/js/bundle.js',
|
||||||
|
// There are also additional JS chunk files if you use code splitting.
|
||||||
|
chunkFilename: isEnvProduction
|
||||||
|
? 'static/js/[name].[contenthash:8].chunk.js'
|
||||||
|
: isEnvDevelopment && 'static/js/[name].chunk.js',
|
||||||
|
assetModuleFilename: 'static/media/[name].[hash][ext]',
|
||||||
|
// webpack uses `publicPath` to determine where the app is being served from.
|
||||||
|
// It requires a trailing slash, or the file assets will get an incorrect path.
|
||||||
|
// We inferred the "public path" (such as / or /my-project) from homepage.
|
||||||
|
publicPath: paths.publicUrlOrPath,
|
||||||
|
// Point sourcemap entries to original disk location (format as URL on Windows)
|
||||||
|
devtoolModuleFilenameTemplate: isEnvProduction
|
||||||
|
? info =>
|
||||||
|
path
|
||||||
|
.relative(paths.appSrc, info.absoluteResourcePath)
|
||||||
|
.replace(/\\/g, '/')
|
||||||
|
: isEnvDevelopment &&
|
||||||
|
(info => path.resolve(info.absoluteResourcePath).replace(/\\/g, '/')),
|
||||||
|
},
|
||||||
|
cache: {
|
||||||
|
type: 'filesystem',
|
||||||
|
version: createEnvironmentHash(env.raw),
|
||||||
|
cacheDirectory: paths.appWebpackCache,
|
||||||
|
store: 'pack',
|
||||||
|
buildDependencies: {
|
||||||
|
defaultWebpack: ['webpack/lib/'],
|
||||||
|
config: [__filename],
|
||||||
|
tsconfig: [paths.appTsConfig, paths.appJsConfig].filter(f =>
|
||||||
|
fs.existsSync(f)
|
||||||
|
),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
infrastructureLogging: {
|
||||||
|
level: 'none',
|
||||||
|
},
|
||||||
|
optimization: {
|
||||||
|
minimize: isEnvProduction,
|
||||||
|
minimizer: [
|
||||||
|
// This is only used in production mode
|
||||||
|
new TerserPlugin({
|
||||||
|
terserOptions: {
|
||||||
|
parse: {
|
||||||
|
// We want terser to parse ecma 8 code. However, we don't want it
|
||||||
|
// to apply any minification steps that turns valid ecma 5 code
|
||||||
|
// into invalid ecma 5 code. This is why the 'compress' and 'output'
|
||||||
|
// sections only apply transformations that are ecma 5 safe
|
||||||
|
// https://github.com/facebook/create-react-app/pull/4234
|
||||||
|
ecma: 8,
|
||||||
|
},
|
||||||
|
compress: {
|
||||||
|
ecma: 5,
|
||||||
|
warnings: false,
|
||||||
|
// Disabled because of an issue with Uglify breaking seemingly valid code:
|
||||||
|
// https://github.com/facebook/create-react-app/issues/2376
|
||||||
|
// Pending further investigation:
|
||||||
|
// https://github.com/mishoo/UglifyJS2/issues/2011
|
||||||
|
comparisons: false,
|
||||||
|
// Disabled because of an issue with Terser breaking valid code:
|
||||||
|
// https://github.com/facebook/create-react-app/issues/5250
|
||||||
|
// Pending further investigation:
|
||||||
|
// https://github.com/terser-js/terser/issues/120
|
||||||
|
inline: 2,
|
||||||
|
},
|
||||||
|
mangle: {
|
||||||
|
safari10: true,
|
||||||
|
},
|
||||||
|
// Added for profiling in devtools
|
||||||
|
keep_classnames: isEnvProductionProfile,
|
||||||
|
keep_fnames: isEnvProductionProfile,
|
||||||
|
output: {
|
||||||
|
ecma: 5,
|
||||||
|
comments: false,
|
||||||
|
// Turned on because emoji and regex is not minified properly using default
|
||||||
|
// https://github.com/facebook/create-react-app/issues/2488
|
||||||
|
ascii_only: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}),
|
||||||
|
// This is only used in production mode
|
||||||
|
new CssMinimizerPlugin(),
|
||||||
|
],
|
||||||
|
},
|
||||||
|
resolve: {
|
||||||
|
// This allows you to set a fallback for where webpack should look for modules.
|
||||||
|
// We placed these paths second because we want `node_modules` to "win"
|
||||||
|
// if there are any conflicts. This matches Node resolution mechanism.
|
||||||
|
// https://github.com/facebook/create-react-app/issues/253
|
||||||
|
modules: ['node_modules', paths.appNodeModules].concat(
|
||||||
|
modules.additionalModulePaths || []
|
||||||
|
),
|
||||||
|
// These are the reasonable defaults supported by the Node ecosystem.
|
||||||
|
// We also include JSX as a common component filename extension to support
|
||||||
|
// some tools, although we do not recommend using it, see:
|
||||||
|
// https://github.com/facebook/create-react-app/issues/290
|
||||||
|
// `web` extension prefixes have been added for better support
|
||||||
|
// for React Native Web.
|
||||||
|
extensions: paths.moduleFileExtensions
|
||||||
|
.map(ext => `.${ext}`)
|
||||||
|
.filter(ext => useTypeScript || !ext.includes('ts')),
|
||||||
|
alias: {
|
||||||
|
// Support React Native Web
|
||||||
|
// https://www.smashingmagazine.com/2016/08/a-glimpse-into-the-future-with-react-native-for-web/
|
||||||
|
'react-native': 'react-native-web',
|
||||||
|
// Allows for better profiling with ReactDevTools
|
||||||
|
...(isEnvProductionProfile && {
|
||||||
|
'react-dom$': 'react-dom/profiling',
|
||||||
|
'scheduler/tracing': 'scheduler/tracing-profiling',
|
||||||
|
}),
|
||||||
|
...(modules.webpackAliases || {}),
|
||||||
|
'@': path.resolve('src'),
|
||||||
|
},
|
||||||
|
plugins: [
|
||||||
|
// Prevents users from importing files from outside of src/ (or node_modules/).
|
||||||
|
// This often causes confusion because we only process files within src/ with babel.
|
||||||
|
// To fix this, we prevent you from importing files out of src/ -- if you'd like to,
|
||||||
|
// please link the files into your node_modules/ and let module-resolution kick in.
|
||||||
|
// Make sure your source files are compiled, as they will not be processed in any way.
|
||||||
|
new ModuleScopePlugin(paths.appSrc, [
|
||||||
|
paths.appPackageJson,
|
||||||
|
reactRefreshRuntimeEntry,
|
||||||
|
reactRefreshWebpackPluginRuntimeEntry,
|
||||||
|
babelRuntimeEntry,
|
||||||
|
babelRuntimeEntryHelpers,
|
||||||
|
babelRuntimeRegenerator,
|
||||||
|
]),
|
||||||
|
],
|
||||||
|
},
|
||||||
|
module: {
|
||||||
|
strictExportPresence: true,
|
||||||
|
rules: [
|
||||||
|
// Handle node_modules packages that contain sourcemaps
|
||||||
|
shouldUseSourceMap && {
|
||||||
|
enforce: 'pre',
|
||||||
|
exclude: /@babel(?:\/|\\{1,2})runtime/,
|
||||||
|
test: /\.(js|mjs|jsx|ts|tsx|css)$/,
|
||||||
|
loader: require.resolve('source-map-loader'),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
// "oneOf" will traverse all following loaders until one will
|
||||||
|
// match the requirements. When no loader matches it will fall
|
||||||
|
// back to the "file" loader at the end of the loader list.
|
||||||
|
oneOf: [
|
||||||
|
// TODO: Merge this config once `image/avif` is in the mime-db
|
||||||
|
// https://github.com/jshttp/mime-db
|
||||||
|
{
|
||||||
|
test: [/\.avif$/],
|
||||||
|
type: 'asset',
|
||||||
|
mimetype: 'image/avif',
|
||||||
|
parser: {
|
||||||
|
dataUrlCondition: {
|
||||||
|
maxSize: imageInlineSizeLimit,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
// "url" loader works like "file" loader except that it embeds assets
|
||||||
|
// smaller than specified limit in bytes as data URLs to avoid requests.
|
||||||
|
// A missing `test` is equivalent to a match.
|
||||||
|
{
|
||||||
|
test: [/\.bmp$/, /\.gif$/, /\.jpe?g$/, /\.png$/],
|
||||||
|
type: 'asset',
|
||||||
|
parser: {
|
||||||
|
dataUrlCondition: {
|
||||||
|
maxSize: imageInlineSizeLimit,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
test: /\.svg$/,
|
||||||
|
use: [
|
||||||
|
{
|
||||||
|
loader: require.resolve('@svgr/webpack'),
|
||||||
|
options: {
|
||||||
|
prettier: false,
|
||||||
|
svgo: false,
|
||||||
|
svgoConfig: {
|
||||||
|
plugins: [{ removeViewBox: false }],
|
||||||
|
},
|
||||||
|
titleProp: true,
|
||||||
|
ref: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
loader: require.resolve('file-loader'),
|
||||||
|
options: {
|
||||||
|
name: 'static/media/[name].[hash].[ext]',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
],
|
||||||
|
issuer: {
|
||||||
|
and: [/\.(ts|tsx|js|jsx|md|mdx)$/],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
// Process application JS with Babel.
|
||||||
|
// The preset includes JSX, Flow, TypeScript, and some ESnext features.
|
||||||
|
{
|
||||||
|
test: /\.(js|mjs|jsx|ts|tsx)$/,
|
||||||
|
include: paths.appSrc,
|
||||||
|
loader: require.resolve('babel-loader'),
|
||||||
|
options: {
|
||||||
|
customize: require.resolve(
|
||||||
|
'babel-preset-react-app/webpack-overrides'
|
||||||
|
),
|
||||||
|
presets: [
|
||||||
|
[
|
||||||
|
require.resolve('babel-preset-react-app'),
|
||||||
|
{
|
||||||
|
runtime: hasJsxRuntime ? 'automatic' : 'classic',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
],
|
||||||
|
|
||||||
|
plugins: [
|
||||||
|
isEnvDevelopment &&
|
||||||
|
shouldUseReactRefresh &&
|
||||||
|
require.resolve('react-refresh/babel'),
|
||||||
|
].filter(Boolean),
|
||||||
|
// This is a feature of `babel-loader` for webpack (not Babel itself).
|
||||||
|
// It enables caching results in ./node_modules/.cache/babel-loader/
|
||||||
|
// directory for faster rebuilds.
|
||||||
|
cacheDirectory: true,
|
||||||
|
// See #6846 for context on why cacheCompression is disabled
|
||||||
|
cacheCompression: false,
|
||||||
|
compact: isEnvProduction,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
// Process any JS outside of the app with Babel.
|
||||||
|
// Unlike the application JS, we only compile the standard ES features.
|
||||||
|
{
|
||||||
|
test: /\.(js|mjs)$/,
|
||||||
|
exclude: /@babel(?:\/|\\{1,2})runtime/,
|
||||||
|
loader: require.resolve('babel-loader'),
|
||||||
|
options: {
|
||||||
|
babelrc: false,
|
||||||
|
configFile: false,
|
||||||
|
compact: false,
|
||||||
|
presets: [
|
||||||
|
[
|
||||||
|
require.resolve('babel-preset-react-app/dependencies'),
|
||||||
|
{ helpers: true },
|
||||||
|
],
|
||||||
|
],
|
||||||
|
cacheDirectory: true,
|
||||||
|
// See #6846 for context on why cacheCompression is disabled
|
||||||
|
cacheCompression: false,
|
||||||
|
|
||||||
|
// Babel sourcemaps are needed for debugging into node_modules
|
||||||
|
// code. Without the options below, debuggers like VSCode
|
||||||
|
// show incorrect code and set breakpoints on the wrong lines.
|
||||||
|
sourceMaps: shouldUseSourceMap,
|
||||||
|
inputSourceMap: shouldUseSourceMap,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
// "postcss" loader applies autoprefixer to our CSS.
|
||||||
|
// "css" loader resolves paths in CSS and adds assets as dependencies.
|
||||||
|
// "style" loader turns CSS into JS modules that inject <style> tags.
|
||||||
|
// In production, we use MiniCSSExtractPlugin to extract that CSS
|
||||||
|
// to a file, but in development "style" loader enables hot editing
|
||||||
|
// of CSS.
|
||||||
|
// By default we support CSS Modules with the extension .module.css
|
||||||
|
{
|
||||||
|
test: cssRegex,
|
||||||
|
exclude: cssModuleRegex,
|
||||||
|
use: getStyleLoaders({
|
||||||
|
importLoaders: 1,
|
||||||
|
sourceMap: isEnvProduction
|
||||||
|
? shouldUseSourceMap
|
||||||
|
: isEnvDevelopment,
|
||||||
|
modules: {
|
||||||
|
mode: 'icss',
|
||||||
|
},
|
||||||
|
}),
|
||||||
|
// Don't consider CSS imports dead code even if the
|
||||||
|
// containing package claims to have no side effects.
|
||||||
|
// Remove this when webpack adds a warning or an error for this.
|
||||||
|
// See https://github.com/webpack/webpack/issues/6571
|
||||||
|
sideEffects: true,
|
||||||
|
},
|
||||||
|
// Adds support for CSS Modules (https://github.com/css-modules/css-modules)
|
||||||
|
// using the extension .module.css
|
||||||
|
{
|
||||||
|
test: cssModuleRegex,
|
||||||
|
use: getStyleLoaders({
|
||||||
|
importLoaders: 1,
|
||||||
|
sourceMap: isEnvProduction
|
||||||
|
? shouldUseSourceMap
|
||||||
|
: isEnvDevelopment,
|
||||||
|
modules: {
|
||||||
|
mode: 'local',
|
||||||
|
getLocalIdent: getCSSModuleLocalIdent,
|
||||||
|
},
|
||||||
|
}),
|
||||||
|
},
|
||||||
|
// Opt-in support for SASS (using .scss or .sass extensions).
|
||||||
|
// By default we support SASS Modules with the
|
||||||
|
// extensions .module.scss or .module.sass
|
||||||
|
{
|
||||||
|
test: sassRegex,
|
||||||
|
exclude: sassModuleRegex,
|
||||||
|
use: getStyleLoaders(
|
||||||
|
{
|
||||||
|
importLoaders: 3,
|
||||||
|
sourceMap: isEnvProduction
|
||||||
|
? shouldUseSourceMap
|
||||||
|
: isEnvDevelopment,
|
||||||
|
modules: {
|
||||||
|
mode: 'icss',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
'sass-loader'
|
||||||
|
),
|
||||||
|
// Don't consider CSS imports dead code even if the
|
||||||
|
// containing package claims to have no side effects.
|
||||||
|
// Remove this when webpack adds a warning or an error for this.
|
||||||
|
// See https://github.com/webpack/webpack/issues/6571
|
||||||
|
sideEffects: true,
|
||||||
|
},
|
||||||
|
// Adds support for CSS Modules, but using SASS
|
||||||
|
// using the extension .module.scss or .module.sass
|
||||||
|
{
|
||||||
|
test: sassModuleRegex,
|
||||||
|
use: getStyleLoaders(
|
||||||
|
{
|
||||||
|
importLoaders: 3,
|
||||||
|
sourceMap: isEnvProduction
|
||||||
|
? shouldUseSourceMap
|
||||||
|
: isEnvDevelopment,
|
||||||
|
modules: {
|
||||||
|
mode: 'local',
|
||||||
|
getLocalIdent: getCSSModuleLocalIdent,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
'sass-loader'
|
||||||
|
),
|
||||||
|
},
|
||||||
|
// "file" loader makes sure those assets get served by WebpackDevServer.
|
||||||
|
// When you `import` an asset, you get its (virtual) filename.
|
||||||
|
// In production, they would get copied to the `build` folder.
|
||||||
|
// This loader doesn't use a "test" so it will catch all modules
|
||||||
|
// that fall through the other loaders.
|
||||||
|
{
|
||||||
|
// Exclude `js` files to keep "css" loader working as it injects
|
||||||
|
// its runtime that would otherwise be processed through "file" loader.
|
||||||
|
// Also exclude `html` and `json` extensions so they get processed
|
||||||
|
// by webpacks internal loaders.
|
||||||
|
exclude: [/^$/, /\.(js|mjs|jsx|ts|tsx)$/, /\.html$/, /\.json$/],
|
||||||
|
type: 'asset/resource',
|
||||||
|
},
|
||||||
|
// ** STOP ** Are you adding a new loader?
|
||||||
|
// Make sure to add the new loader(s) before the "file" loader.
|
||||||
|
],
|
||||||
|
},
|
||||||
|
].filter(Boolean),
|
||||||
|
},
|
||||||
|
plugins: [
|
||||||
|
// Generates an `index.html` file with the <script> injected.
|
||||||
|
new HtmlWebpackPlugin(
|
||||||
|
Object.assign(
|
||||||
|
{},
|
||||||
|
{
|
||||||
|
inject: true,
|
||||||
|
template: paths.appHtml,
|
||||||
|
},
|
||||||
|
isEnvProduction
|
||||||
|
? {
|
||||||
|
minify: {
|
||||||
|
removeComments: true,
|
||||||
|
collapseWhitespace: true,
|
||||||
|
removeRedundantAttributes: true,
|
||||||
|
useShortDoctype: true,
|
||||||
|
removeEmptyAttributes: true,
|
||||||
|
removeStyleLinkTypeAttributes: true,
|
||||||
|
keepClosingSlash: true,
|
||||||
|
minifyJS: true,
|
||||||
|
minifyCSS: true,
|
||||||
|
minifyURLs: true,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
: undefined
|
||||||
|
)
|
||||||
|
),
|
||||||
|
// Inlines the webpack runtime script. This script is too small to warrant
|
||||||
|
// a network request.
|
||||||
|
// https://github.com/facebook/create-react-app/issues/5358
|
||||||
|
isEnvProduction &&
|
||||||
|
shouldInlineRuntimeChunk &&
|
||||||
|
new InlineChunkHtmlPlugin(HtmlWebpackPlugin, [/runtime-.+[.]js/]),
|
||||||
|
// Makes some environment variables available in index.html.
|
||||||
|
// The public URL is available as %PUBLIC_URL% in index.html, e.g.:
|
||||||
|
// <link rel="icon" href="%PUBLIC_URL%/favicon.ico">
|
||||||
|
// It will be an empty string unless you specify "homepage"
|
||||||
|
// in `package.json`, in which case it will be the pathname of that URL.
|
||||||
|
new InterpolateHtmlPlugin(HtmlWebpackPlugin, env.raw),
|
||||||
|
// This gives some necessary context to module not found errors, such as
|
||||||
|
// the requesting resource.
|
||||||
|
new ModuleNotFoundPlugin(paths.appPath),
|
||||||
|
// Makes some environment variables available to the JS code, for example:
|
||||||
|
// if (process.env.NODE_ENV === 'production') { ... }. See `./env.js`.
|
||||||
|
// It is absolutely essential that NODE_ENV is set to production
|
||||||
|
// during a production build.
|
||||||
|
// Otherwise React will be compiled in the very slow development mode.
|
||||||
|
new webpack.DefinePlugin(env.stringified),
|
||||||
|
// Experimental hot reloading for React .
|
||||||
|
// https://github.com/facebook/react/tree/main/packages/react-refresh
|
||||||
|
isEnvDevelopment &&
|
||||||
|
shouldUseReactRefresh &&
|
||||||
|
new ReactRefreshWebpackPlugin({
|
||||||
|
overlay: false,
|
||||||
|
}),
|
||||||
|
// Watcher doesn't work well if you mistype casing in a path so we use
|
||||||
|
// a plugin that prints an error when you attempt to do this.
|
||||||
|
// See https://github.com/facebook/create-react-app/issues/240
|
||||||
|
isEnvDevelopment && new CaseSensitivePathsPlugin(),
|
||||||
|
isEnvProduction &&
|
||||||
|
new MiniCssExtractPlugin({
|
||||||
|
// Options similar to the same options in webpackOptions.output
|
||||||
|
// both options are optional
|
||||||
|
filename: 'static/css/[name].[contenthash:8].css',
|
||||||
|
chunkFilename: 'static/css/[name].[contenthash:8].chunk.css',
|
||||||
|
}),
|
||||||
|
// Generate an asset manifest file with the following content:
|
||||||
|
// - "files" key: Mapping of all asset filenames to their corresponding
|
||||||
|
// output file so that tools can pick it up without having to parse
|
||||||
|
// `index.html`
|
||||||
|
// - "entrypoints" key: Array of files which are included in `index.html`,
|
||||||
|
// can be used to reconstruct the HTML if necessary
|
||||||
|
new WebpackManifestPlugin({
|
||||||
|
fileName: 'asset-manifest.json',
|
||||||
|
publicPath: paths.publicUrlOrPath,
|
||||||
|
generate: (seed, files, entrypoints) => {
|
||||||
|
const manifestFiles = files.reduce((manifest, file) => {
|
||||||
|
manifest[file.name] = file.path;
|
||||||
|
return manifest;
|
||||||
|
}, seed);
|
||||||
|
const entrypointFiles = entrypoints.main.filter(
|
||||||
|
fileName => !fileName.endsWith('.map')
|
||||||
|
);
|
||||||
|
|
||||||
|
return {
|
||||||
|
files: manifestFiles,
|
||||||
|
entrypoints: entrypointFiles,
|
||||||
|
};
|
||||||
|
},
|
||||||
|
}),
|
||||||
|
// Moment.js is an extremely popular library that bundles large locale files
|
||||||
|
// by default due to how webpack interprets its code. This is a practical
|
||||||
|
// solution that requires the user to opt into importing specific locales.
|
||||||
|
// https://github.com/jmblog/how-to-optimize-momentjs-with-webpack
|
||||||
|
// You can remove this if you don't use Moment.js:
|
||||||
|
new webpack.IgnorePlugin({
|
||||||
|
resourceRegExp: /^\.\/locale$/,
|
||||||
|
contextRegExp: /moment$/,
|
||||||
|
}),
|
||||||
|
// Generate a service worker script that will precache, and keep up to date,
|
||||||
|
// the HTML & assets that are part of the webpack build.
|
||||||
|
isEnvProduction &&
|
||||||
|
fs.existsSync(swSrc) &&
|
||||||
|
new WorkboxWebpackPlugin.InjectManifest({
|
||||||
|
swSrc,
|
||||||
|
dontCacheBustURLsMatching: /\.[0-9a-f]{8}\./,
|
||||||
|
exclude: [/\.map$/, /asset-manifest\.json$/, /LICENSE/],
|
||||||
|
// Bump up the default maximum size (2mb) that's precached,
|
||||||
|
// to make lazy-loading failure scenarios less likely.
|
||||||
|
// See https://github.com/cra-template/pwa/issues/13#issuecomment-722667270
|
||||||
|
maximumFileSizeToCacheInBytes: 5 * 1024 * 1024,
|
||||||
|
}),
|
||||||
|
// TypeScript type checking
|
||||||
|
useTypeScript &&
|
||||||
|
new ForkTsCheckerWebpackPlugin({
|
||||||
|
async: isEnvDevelopment,
|
||||||
|
typescript: {
|
||||||
|
typescriptPath: resolve.sync('typescript', {
|
||||||
|
basedir: paths.appNodeModules,
|
||||||
|
}),
|
||||||
|
configOverwrite: {
|
||||||
|
compilerOptions: {
|
||||||
|
sourceMap: isEnvProduction
|
||||||
|
? shouldUseSourceMap
|
||||||
|
: isEnvDevelopment,
|
||||||
|
skipLibCheck: true,
|
||||||
|
inlineSourceMap: false,
|
||||||
|
declarationMap: false,
|
||||||
|
noEmit: true,
|
||||||
|
incremental: true,
|
||||||
|
tsBuildInfoFile: paths.appTsBuildInfoFile,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
context: paths.appPath,
|
||||||
|
diagnosticOptions: {
|
||||||
|
syntactic: true,
|
||||||
|
},
|
||||||
|
mode: 'write-references',
|
||||||
|
// profile: true,
|
||||||
|
},
|
||||||
|
issue: {
|
||||||
|
// This one is specifically to match during CI tests,
|
||||||
|
// as micromatch doesn't match
|
||||||
|
// '../cra-template-typescript/template/src/App.tsx'
|
||||||
|
// otherwise.
|
||||||
|
include: [
|
||||||
|
{ file: '../**/src/**/*.{ts,tsx}' },
|
||||||
|
{ file: '**/src/**/*.{ts,tsx}' },
|
||||||
|
],
|
||||||
|
exclude: [
|
||||||
|
{ file: '**/src/**/__tests__/**' },
|
||||||
|
{ file: '**/src/**/?(*.){spec|test}.*' },
|
||||||
|
{ file: '**/src/setupProxy.*' },
|
||||||
|
{ file: '**/src/setupTests.*' },
|
||||||
|
],
|
||||||
|
},
|
||||||
|
logger: {
|
||||||
|
infrastructure: 'silent',
|
||||||
|
},
|
||||||
|
}),
|
||||||
|
!disableESLintPlugin &&
|
||||||
|
new ESLintPlugin({
|
||||||
|
// Plugin options
|
||||||
|
extensions: ['js', 'mjs', 'jsx', 'ts', 'tsx'],
|
||||||
|
formatter: require.resolve('react-dev-utils/eslintFormatter'),
|
||||||
|
eslintPath: require.resolve('eslint'),
|
||||||
|
failOnError: !(isEnvDevelopment && emitErrorsAsWarnings),
|
||||||
|
context: paths.appSrc,
|
||||||
|
cache: true,
|
||||||
|
cacheLocation: path.resolve(
|
||||||
|
paths.appNodeModules,
|
||||||
|
'.cache/.eslintcache'
|
||||||
|
),
|
||||||
|
// ESLint class options
|
||||||
|
cwd: paths.appPath,
|
||||||
|
resolvePluginsRelativeTo: __dirname,
|
||||||
|
baseConfig: {
|
||||||
|
extends: [require.resolve('eslint-config-react-app/base')],
|
||||||
|
rules: {
|
||||||
|
...(!hasJsxRuntime && {
|
||||||
|
'react/react-in-jsx-scope': 'error',
|
||||||
|
}),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}),
|
||||||
|
].filter(Boolean),
|
||||||
|
// Turn off performance processing because we utilize
|
||||||
|
// our own hints via the FileSizeReporter
|
||||||
|
performance: false,
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
@ -0,0 +1,9 @@
|
||||||
|
'use strict';
|
||||||
|
const { createHash } = require('crypto');
|
||||||
|
|
||||||
|
module.exports = env => {
|
||||||
|
const hash = createHash('md5');
|
||||||
|
hash.update(JSON.stringify(env));
|
||||||
|
|
||||||
|
return hash.digest('hex');
|
||||||
|
};
|
||||||
|
|
@ -0,0 +1,129 @@
|
||||||
|
'use strict';
|
||||||
|
const mock = require("../service/mock.cjs");
|
||||||
|
const fs = require('fs');
|
||||||
|
const evalSourceMapMiddleware = require('react-dev-utils/evalSourceMapMiddleware');
|
||||||
|
const noopServiceWorkerMiddleware = require('react-dev-utils/noopServiceWorkerMiddleware');
|
||||||
|
const ignoredFiles = require('react-dev-utils/ignoredFiles');
|
||||||
|
const redirectServedPath = require('react-dev-utils/redirectServedPathMiddleware');
|
||||||
|
const paths = require('./paths');
|
||||||
|
const getHttpsConfig = require('./getHttpsConfig');
|
||||||
|
|
||||||
|
const host = process.env.HOST || '0.0.0.0';
|
||||||
|
const sockHost = process.env.WDS_SOCKET_HOST;
|
||||||
|
const sockPath = process.env.WDS_SOCKET_PATH; // default: '/ws'
|
||||||
|
const sockPort = process.env.WDS_SOCKET_PORT;
|
||||||
|
|
||||||
|
module.exports = function (proxy, allowedHost) {
|
||||||
|
const disableFirewall =
|
||||||
|
!proxy || process.env.DANGEROUSLY_DISABLE_HOST_CHECK === 'true';
|
||||||
|
return {
|
||||||
|
// WebpackDevServer 2.4.3 introduced a security fix that prevents remote
|
||||||
|
// websites from potentially accessing local content through DNS rebinding:
|
||||||
|
// https://github.com/webpack/webpack-dev-server/issues/887
|
||||||
|
// https://medium.com/webpack/webpack-dev-server-middleware-security-issues-1489d950874a
|
||||||
|
// However, it made several existing use cases such as development in cloud
|
||||||
|
// environment or subdomains in development significantly more complicated:
|
||||||
|
// https://github.com/facebook/create-react-app/issues/2271
|
||||||
|
// https://github.com/facebook/create-react-app/issues/2233
|
||||||
|
// While we're investigating better solutions, for now we will take a
|
||||||
|
// compromise. Since our WDS configuration only serves files in the `public`
|
||||||
|
// folder we won't consider accessing them a vulnerability. However, if you
|
||||||
|
// use the `proxy` feature, it gets more dangerous because it can expose
|
||||||
|
// remote code execution vulnerabilities in backends like Django and Rails.
|
||||||
|
// So we will disable the host check normally, but enable it if you have
|
||||||
|
// specified the `proxy` setting. Finally, we let you override it if you
|
||||||
|
// really know what you're doing with a special environment variable.
|
||||||
|
// Note: ["localhost", ".localhost"] will support subdomains - but we might
|
||||||
|
// want to allow setting the allowedHosts manually for more complex setups
|
||||||
|
allowedHosts: disableFirewall ? 'all' : [allowedHost],
|
||||||
|
headers: {
|
||||||
|
'Access-Control-Allow-Origin': '*',
|
||||||
|
'Access-Control-Allow-Methods': '*',
|
||||||
|
'Access-Control-Allow-Headers': '*',
|
||||||
|
},
|
||||||
|
// Enable gzip compression of generated files.
|
||||||
|
compress: true,
|
||||||
|
static: {
|
||||||
|
// By default WebpackDevServer serves physical files from current directory
|
||||||
|
// in addition to all the virtual build products that it serves from memory.
|
||||||
|
// This is confusing because those files won’t automatically be available in
|
||||||
|
// production build folder unless we copy them. However, copying the whole
|
||||||
|
// project directory is dangerous because we may expose sensitive files.
|
||||||
|
// Instead, we establish a convention that only files in `public` directory
|
||||||
|
// get served. Our build script will copy `public` into the `build` folder.
|
||||||
|
// In `index.html`, you can get URL of `public` folder with %PUBLIC_URL%:
|
||||||
|
// <link rel="icon" href="%PUBLIC_URL%/favicon.ico">
|
||||||
|
// In JavaScript code, you can access it with `process.env.PUBLIC_URL`.
|
||||||
|
// Note that we only recommend to use `public` folder as an escape hatch
|
||||||
|
// for files like `favicon.ico`, `manifest.json`, and libraries that are
|
||||||
|
// for some reason broken when imported through webpack. If you just want to
|
||||||
|
// use an image, put it in `src` and `import` it from JavaScript instead.
|
||||||
|
directory: paths.appPublic,
|
||||||
|
publicPath: [paths.publicUrlOrPath],
|
||||||
|
// By default files from `contentBase` will not trigger a page reload.
|
||||||
|
watch: {
|
||||||
|
// Reportedly, this avoids CPU overload on some systems.
|
||||||
|
// https://github.com/facebook/create-react-app/issues/293
|
||||||
|
// src/node_modules is not ignored to support absolute imports
|
||||||
|
// https://github.com/facebook/create-react-app/issues/1065
|
||||||
|
ignored: ignoredFiles(paths.appSrc),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
client: {
|
||||||
|
webSocketURL: {
|
||||||
|
// Enable custom sockjs pathname for websocket connection to hot reloading server.
|
||||||
|
// Enable custom sockjs hostname, pathname and port for websocket connection
|
||||||
|
// to hot reloading server.
|
||||||
|
hostname: sockHost,
|
||||||
|
pathname: sockPath,
|
||||||
|
port: sockPort,
|
||||||
|
},
|
||||||
|
overlay: {
|
||||||
|
errors: true,
|
||||||
|
warnings: false,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
devMiddleware: {
|
||||||
|
// It is important to tell WebpackDevServer to use the same "publicPath" path as
|
||||||
|
// we specified in the webpack config. When homepage is '.', default to serving
|
||||||
|
// from the root.
|
||||||
|
// remove last slash so user can land on `/test` instead of `/test/`
|
||||||
|
publicPath: paths.publicUrlOrPath.slice(0, -1),
|
||||||
|
},
|
||||||
|
|
||||||
|
https: getHttpsConfig(),
|
||||||
|
host,
|
||||||
|
historyApiFallback: {
|
||||||
|
// Paths with dots should still use the history fallback.
|
||||||
|
// See https://github.com/facebook/create-react-app/issues/387.
|
||||||
|
disableDotRule: true,
|
||||||
|
index: paths.publicUrlOrPath,
|
||||||
|
},
|
||||||
|
// `proxy` is run between `before` and `after` `webpack-dev-server` hooks
|
||||||
|
proxy,
|
||||||
|
onBeforeSetupMiddleware(devServer) {
|
||||||
|
// Keep `evalSourceMapMiddleware`
|
||||||
|
// middlewares before `redirectServedPath` otherwise will not have any effect
|
||||||
|
// This lets us fetch source contents from webpack for the error overlay
|
||||||
|
devServer.app.use(evalSourceMapMiddleware(devServer));
|
||||||
|
|
||||||
|
if (fs.existsSync(paths.proxySetup)) {
|
||||||
|
// This registers user provided middleware for proxy reasons
|
||||||
|
require(paths.proxySetup)(devServer.app);
|
||||||
|
}
|
||||||
|
// 加入本地mock服务
|
||||||
|
devServer.app.use(mock)
|
||||||
|
},
|
||||||
|
onAfterSetupMiddleware(devServer) {
|
||||||
|
// Redirect to `PUBLIC_URL` or `homepage` from `package.json` if url not match
|
||||||
|
devServer.app.use(redirectServedPath(paths.publicUrlOrPath));
|
||||||
|
|
||||||
|
// This service worker file is effectively a 'no-op' that will reset any
|
||||||
|
// previous service worker registered for the same host:port combination.
|
||||||
|
// We do this in development to avoid hitting the production cache if
|
||||||
|
// it used the same host and port.
|
||||||
|
// https://github.com/facebook/create-react-app/issues/2272#issuecomment-302832432
|
||||||
|
devServer.app.use(noopServiceWorkerMiddleware(paths.publicUrlOrPath));
|
||||||
|
},
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
@ -0,0 +1,167 @@
|
||||||
|
{
|
||||||
|
"name": "my-app",
|
||||||
|
"version": "0.1.0",
|
||||||
|
"private": true,
|
||||||
|
"dependencies": {
|
||||||
|
"@babel/core": "^7.16.0",
|
||||||
|
"@emotion/react": "^11.14.0",
|
||||||
|
"@pmmmwh/react-refresh-webpack-plugin": "^0.5.3",
|
||||||
|
"@svgr/webpack": "^5.5.0",
|
||||||
|
"@testing-library/dom": "^10.4.0",
|
||||||
|
"@testing-library/jest-dom": "^6.6.3",
|
||||||
|
"@testing-library/react": "^16.3.0",
|
||||||
|
"@testing-library/user-event": "^13.5.0",
|
||||||
|
"@types/jest": "^27.5.2",
|
||||||
|
"@types/node": "^16.18.126",
|
||||||
|
"@types/react": "^19.1.8",
|
||||||
|
"@types/react-dom": "^19.1.6",
|
||||||
|
"antd": "^5.26.1",
|
||||||
|
"axios": "^1.10.0",
|
||||||
|
"babel-jest": "^27.4.2",
|
||||||
|
"babel-loader": "^8.2.3",
|
||||||
|
"babel-plugin-named-asset-import": "^0.3.8",
|
||||||
|
"babel-preset-react-app": "^10.0.1",
|
||||||
|
"bfj": "^7.0.2",
|
||||||
|
"body-parser": "^2.2.0",
|
||||||
|
"bowser": "^2.11.0",
|
||||||
|
"browserslist": "^4.18.1",
|
||||||
|
"camelcase": "^6.2.1",
|
||||||
|
"case-sensitive-paths-webpack-plugin": "^2.4.0",
|
||||||
|
"crypto-js": "^4.2.0",
|
||||||
|
"css-loader": "^6.5.1",
|
||||||
|
"css-minimizer-webpack-plugin": "^3.2.0",
|
||||||
|
"dotenv": "^10.0.0",
|
||||||
|
"dotenv-expand": "^5.1.0",
|
||||||
|
"eslint": "^8.3.0",
|
||||||
|
"eslint-config-react-app": "^7.0.1",
|
||||||
|
"eslint-webpack-plugin": "^3.1.1",
|
||||||
|
"express": "^4.21.2",
|
||||||
|
"file-loader": "^6.2.0",
|
||||||
|
"fs": "^0.0.1-security",
|
||||||
|
"fs-extra": "^10.0.0",
|
||||||
|
"html-webpack-plugin": "^5.5.0",
|
||||||
|
"http-proxy": "^1.18.1",
|
||||||
|
"identity-obj-proxy": "^3.0.0",
|
||||||
|
"jest": "^27.4.3",
|
||||||
|
"jest-resolve": "^27.4.2",
|
||||||
|
"jest-watch-typeahead": "^1.0.0",
|
||||||
|
"mime": "^4.0.7",
|
||||||
|
"mini-css-extract-plugin": "^2.4.5",
|
||||||
|
"motion": "^12.23.25",
|
||||||
|
"nprogress": "^0.2.0",
|
||||||
|
"postcss": "^8.4.4",
|
||||||
|
"postcss-flexbugs-fixes": "^5.0.2",
|
||||||
|
"postcss-loader": "^6.2.1",
|
||||||
|
"postcss-normalize": "^10.0.1",
|
||||||
|
"postcss-preset-env": "^7.0.1",
|
||||||
|
"prompts": "^2.4.2",
|
||||||
|
"react": "^19.1.0",
|
||||||
|
"react-app-polyfill": "^3.0.0",
|
||||||
|
"react-dev-utils": "^12.0.1",
|
||||||
|
"react-dom": "^19.1.0",
|
||||||
|
"react-refresh": "^0.11.0",
|
||||||
|
"react-router-dom": "^7.6.2",
|
||||||
|
"request": "^2.88.2",
|
||||||
|
"resolve": "^1.20.0",
|
||||||
|
"resolve-url-loader": "^4.0.0",
|
||||||
|
"sass-loader": "^12.3.0",
|
||||||
|
"semver": "^7.3.5",
|
||||||
|
"source-map-loader": "^3.0.0",
|
||||||
|
"style-loader": "^3.3.1",
|
||||||
|
"swiper": "^12.0.3",
|
||||||
|
"tailwindcss": "^3.0.2",
|
||||||
|
"terser-webpack-plugin": "^5.2.5",
|
||||||
|
"typescript": "^4.9.5",
|
||||||
|
"uuid": "^11.1.0",
|
||||||
|
"web-vitals": "^2.1.4",
|
||||||
|
"webpack": "^5.64.4",
|
||||||
|
"webpack-dev-server": "^4.6.0",
|
||||||
|
"webpack-manifest-plugin": "^4.0.2",
|
||||||
|
"winston": "^3.17.0",
|
||||||
|
"workbox-webpack-plugin": "^6.4.1"
|
||||||
|
},
|
||||||
|
"scripts": {
|
||||||
|
"dev": "node --stack-size=12800 --stack-trace-limit=20 scripts/start.js",
|
||||||
|
"build": "node scripts/build.js",
|
||||||
|
"test": "node scripts/test.js",
|
||||||
|
"start": "node --stack-size=12800 --stack-trace-limit=20 ./service/main.cjs"
|
||||||
|
},
|
||||||
|
"eslintConfig": {
|
||||||
|
"extends": [
|
||||||
|
"react-app",
|
||||||
|
"react-app/jest"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"browserslist": {
|
||||||
|
"production": [
|
||||||
|
">0.2%",
|
||||||
|
"not dead",
|
||||||
|
"not op_mini all"
|
||||||
|
],
|
||||||
|
"development": [
|
||||||
|
"last 1 chrome version",
|
||||||
|
"last 1 firefox version",
|
||||||
|
"last 1 safari version"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"jest": {
|
||||||
|
"roots": [
|
||||||
|
"<rootDir>/src"
|
||||||
|
],
|
||||||
|
"collectCoverageFrom": [
|
||||||
|
"src/**/*.{js,jsx,ts,tsx}",
|
||||||
|
"!src/**/*.d.ts"
|
||||||
|
],
|
||||||
|
"setupFiles": [
|
||||||
|
"react-app-polyfill/jsdom"
|
||||||
|
],
|
||||||
|
"setupFilesAfterEnv": [
|
||||||
|
"<rootDir>/src/setupTests.ts"
|
||||||
|
],
|
||||||
|
"testMatch": [
|
||||||
|
"<rootDir>/src/**/__tests__/**/*.{js,jsx,ts,tsx}",
|
||||||
|
"<rootDir>/src/**/*.{spec,test}.{js,jsx,ts,tsx}"
|
||||||
|
],
|
||||||
|
"testEnvironment": "jsdom",
|
||||||
|
"transform": {
|
||||||
|
"^.+\\.(js|jsx|mjs|cjs|ts|tsx)$": "<rootDir>/config/jest/babelTransform.js",
|
||||||
|
"^.+\\.css$": "<rootDir>/config/jest/cssTransform.js",
|
||||||
|
"^(?!.*\\.(js|jsx|mjs|cjs|ts|tsx|css|json)$)": "<rootDir>/config/jest/fileTransform.js"
|
||||||
|
},
|
||||||
|
"transformIgnorePatterns": [
|
||||||
|
"[/\\\\]node_modules[/\\\\].+\\.(js|jsx|mjs|cjs|ts|tsx)$",
|
||||||
|
"^.+\\.module\\.(css|sass|scss)$"
|
||||||
|
],
|
||||||
|
"modulePaths": [],
|
||||||
|
"moduleNameMapper": {
|
||||||
|
"^react-native$": "react-native-web",
|
||||||
|
"^.+\\.module\\.(css|sass|scss)$": "identity-obj-proxy"
|
||||||
|
},
|
||||||
|
"moduleFileExtensions": [
|
||||||
|
"web.js",
|
||||||
|
"js",
|
||||||
|
"web.ts",
|
||||||
|
"ts",
|
||||||
|
"web.tsx",
|
||||||
|
"tsx",
|
||||||
|
"json",
|
||||||
|
"web.jsx",
|
||||||
|
"jsx",
|
||||||
|
"node"
|
||||||
|
],
|
||||||
|
"watchPlugins": [
|
||||||
|
"jest-watch-typeahead/filename",
|
||||||
|
"jest-watch-typeahead/testname"
|
||||||
|
],
|
||||||
|
"resetMocks": true
|
||||||
|
},
|
||||||
|
"babel": {
|
||||||
|
"presets": [
|
||||||
|
"react-app"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"@types/crypto-js": "^4.2.2",
|
||||||
|
"@types/nprogress": "^0.2.3"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
After Width: | Height: | Size: 3.8 KiB |
|
After Width: | Height: | Size: 11 MiB |
|
After Width: | Height: | Size: 14 MiB |
|
After Width: | Height: | Size: 2.9 MiB |
|
After Width: | Height: | Size: 4.0 MiB |
|
After Width: | Height: | Size: 14 MiB |
|
After Width: | Height: | Size: 11 MiB |
|
After Width: | Height: | Size: 2.9 MiB |
|
After Width: | Height: | Size: 670 B |
|
After Width: | Height: | Size: 1.3 KiB |
|
After Width: | Height: | Size: 2.7 KiB |
|
After Width: | Height: | Size: 2.1 KiB |
|
After Width: | Height: | Size: 6.5 KiB |
|
After Width: | Height: | Size: 2.7 MiB |
|
After Width: | Height: | Size: 3.3 MiB |
|
|
@ -0,0 +1,43 @@
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8" />
|
||||||
|
<link rel="icon" href="%PUBLIC_URL%/favicon.ico" />
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||||
|
<meta name="theme-color" content="#000000" />
|
||||||
|
<meta
|
||||||
|
name="description"
|
||||||
|
content="Web site created using create-react-app"
|
||||||
|
/>
|
||||||
|
<link rel="apple-touch-icon" href="%PUBLIC_URL%/logo192.png" />
|
||||||
|
<!--
|
||||||
|
manifest.json provides metadata used when your web app is installed on a
|
||||||
|
user's mobile device or desktop. See https://developers.google.com/web/fundamentals/web-app-manifest/
|
||||||
|
-->
|
||||||
|
<link rel="manifest" href="%PUBLIC_URL%/manifest.json" />
|
||||||
|
<!--
|
||||||
|
Notice the use of %PUBLIC_URL% in the tags above.
|
||||||
|
It will be replaced with the URL of the `public` folder during the build.
|
||||||
|
Only files inside the `public` folder can be referenced from the HTML.
|
||||||
|
|
||||||
|
Unlike "/favicon.ico" or "favicon.ico", "%PUBLIC_URL%/favicon.ico" will
|
||||||
|
work correctly both with client-side routing and a non-root public URL.
|
||||||
|
Learn how to configure a non-root public URL by running `npm run build`.
|
||||||
|
-->
|
||||||
|
<title>加载中...</title>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<noscript>You need to enable JavaScript to run this app.</noscript>
|
||||||
|
<div id="root"></div>
|
||||||
|
<!--
|
||||||
|
This HTML file is a template.
|
||||||
|
If you open it directly in the browser, you will see an empty page.
|
||||||
|
|
||||||
|
You can add webfonts, meta tags, or analytics to this file.
|
||||||
|
The build step will place the bundled scripts into the <body> tag.
|
||||||
|
|
||||||
|
To begin the development, run `npm start` or `yarn start`.
|
||||||
|
To create a production bundle, use `npm run build` or `yarn build`.
|
||||||
|
-->
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
|
After Width: | Height: | Size: 5.2 KiB |
|
After Width: | Height: | Size: 9.4 KiB |
|
|
@ -0,0 +1,25 @@
|
||||||
|
{
|
||||||
|
"short_name": "React App",
|
||||||
|
"name": "Create React App Sample",
|
||||||
|
"icons": [
|
||||||
|
{
|
||||||
|
"src": "favicon.ico",
|
||||||
|
"sizes": "64x64 32x32 24x24 16x16",
|
||||||
|
"type": "image/x-icon"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"src": "logo192.png",
|
||||||
|
"type": "image/png",
|
||||||
|
"sizes": "192x192"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"src": "logo512.png",
|
||||||
|
"type": "image/png",
|
||||||
|
"sizes": "512x512"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"start_url": ".",
|
||||||
|
"display": "standalone",
|
||||||
|
"theme_color": "#000000",
|
||||||
|
"background_color": "#ffffff"
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,3 @@
|
||||||
|
# https://www.robotstxt.org/robotstxt.html
|
||||||
|
User-agent: *
|
||||||
|
Disallow:
|
||||||
|
|
@ -0,0 +1,217 @@
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
// Do this as the first thing so that any code reading it knows the right env.
|
||||||
|
process.env.BABEL_ENV = 'production';
|
||||||
|
process.env.NODE_ENV = 'production';
|
||||||
|
|
||||||
|
// Makes the script crash on unhandled rejections instead of silently
|
||||||
|
// ignoring them. In the future, promise rejections that are not handled will
|
||||||
|
// terminate the Node.js process with a non-zero exit code.
|
||||||
|
process.on('unhandledRejection', err => {
|
||||||
|
throw err;
|
||||||
|
});
|
||||||
|
|
||||||
|
// Ensure environment variables are read.
|
||||||
|
require('../config/env');
|
||||||
|
|
||||||
|
const path = require('path');
|
||||||
|
const chalk = require('react-dev-utils/chalk');
|
||||||
|
const fs = require('fs-extra');
|
||||||
|
const bfj = require('bfj');
|
||||||
|
const webpack = require('webpack');
|
||||||
|
const configFactory = require('../config/webpack.config');
|
||||||
|
const paths = require('../config/paths');
|
||||||
|
const checkRequiredFiles = require('react-dev-utils/checkRequiredFiles');
|
||||||
|
const formatWebpackMessages = require('react-dev-utils/formatWebpackMessages');
|
||||||
|
const printHostingInstructions = require('react-dev-utils/printHostingInstructions');
|
||||||
|
const FileSizeReporter = require('react-dev-utils/FileSizeReporter');
|
||||||
|
const printBuildError = require('react-dev-utils/printBuildError');
|
||||||
|
|
||||||
|
const measureFileSizesBeforeBuild =
|
||||||
|
FileSizeReporter.measureFileSizesBeforeBuild;
|
||||||
|
const printFileSizesAfterBuild = FileSizeReporter.printFileSizesAfterBuild;
|
||||||
|
const useYarn = fs.existsSync(paths.yarnLockFile);
|
||||||
|
|
||||||
|
// These sizes are pretty large. We'll warn for bundles exceeding them.
|
||||||
|
const WARN_AFTER_BUNDLE_GZIP_SIZE = 512 * 1024;
|
||||||
|
const WARN_AFTER_CHUNK_GZIP_SIZE = 1024 * 1024;
|
||||||
|
|
||||||
|
const isInteractive = process.stdout.isTTY;
|
||||||
|
|
||||||
|
// Warn and crash if required files are missing
|
||||||
|
if (!checkRequiredFiles([paths.appHtml, paths.appIndexJs])) {
|
||||||
|
process.exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
const argv = process.argv.slice(2);
|
||||||
|
const writeStatsJson = argv.indexOf('--stats') !== -1;
|
||||||
|
|
||||||
|
// Generate configuration
|
||||||
|
const config = configFactory('production');
|
||||||
|
|
||||||
|
// We require that you explicitly set browsers and do not fall back to
|
||||||
|
// browserslist defaults.
|
||||||
|
const { checkBrowsers } = require('react-dev-utils/browsersHelper');
|
||||||
|
checkBrowsers(paths.appPath, isInteractive)
|
||||||
|
.then(() => {
|
||||||
|
// First, read the current file sizes in build directory.
|
||||||
|
// This lets us display how much they changed later.
|
||||||
|
return measureFileSizesBeforeBuild(paths.appBuild);
|
||||||
|
})
|
||||||
|
.then(previousFileSizes => {
|
||||||
|
// Remove all content but keep the directory so that
|
||||||
|
// if you're in it, you don't end up in Trash
|
||||||
|
fs.emptyDirSync(paths.appBuild);
|
||||||
|
// Merge with the public folder
|
||||||
|
copyPublicFolder();
|
||||||
|
// Start the webpack build
|
||||||
|
return build(previousFileSizes);
|
||||||
|
})
|
||||||
|
.then(
|
||||||
|
({ stats, previousFileSizes, warnings }) => {
|
||||||
|
if (warnings.length) {
|
||||||
|
console.log(chalk.yellow('Compiled with warnings.\n'));
|
||||||
|
console.log(warnings.join('\n\n'));
|
||||||
|
console.log(
|
||||||
|
'\nSearch for the ' +
|
||||||
|
chalk.underline(chalk.yellow('keywords')) +
|
||||||
|
' to learn more about each warning.'
|
||||||
|
);
|
||||||
|
console.log(
|
||||||
|
'To ignore, add ' +
|
||||||
|
chalk.cyan('// eslint-disable-next-line') +
|
||||||
|
' to the line before.\n'
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
console.log(chalk.green('Compiled successfully.\n'));
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log('File sizes after gzip:\n');
|
||||||
|
printFileSizesAfterBuild(
|
||||||
|
stats,
|
||||||
|
previousFileSizes,
|
||||||
|
paths.appBuild,
|
||||||
|
WARN_AFTER_BUNDLE_GZIP_SIZE,
|
||||||
|
WARN_AFTER_CHUNK_GZIP_SIZE
|
||||||
|
);
|
||||||
|
console.log();
|
||||||
|
|
||||||
|
const appPackage = require(paths.appPackageJson);
|
||||||
|
const publicUrl = paths.publicUrlOrPath;
|
||||||
|
const publicPath = config.output.publicPath;
|
||||||
|
const buildFolder = path.relative(process.cwd(), paths.appBuild);
|
||||||
|
printHostingInstructions(
|
||||||
|
appPackage,
|
||||||
|
publicUrl,
|
||||||
|
publicPath,
|
||||||
|
buildFolder,
|
||||||
|
useYarn
|
||||||
|
);
|
||||||
|
},
|
||||||
|
err => {
|
||||||
|
const tscCompileOnError = process.env.TSC_COMPILE_ON_ERROR === 'true';
|
||||||
|
if (tscCompileOnError) {
|
||||||
|
console.log(
|
||||||
|
chalk.yellow(
|
||||||
|
'Compiled with the following type errors (you may want to check these before deploying your app):\n'
|
||||||
|
)
|
||||||
|
);
|
||||||
|
printBuildError(err);
|
||||||
|
} else {
|
||||||
|
console.log(chalk.red('Failed to compile.\n'));
|
||||||
|
printBuildError(err);
|
||||||
|
process.exit(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
)
|
||||||
|
.catch(err => {
|
||||||
|
if (err && err.message) {
|
||||||
|
console.log(err.message);
|
||||||
|
}
|
||||||
|
process.exit(1);
|
||||||
|
});
|
||||||
|
|
||||||
|
// Create the production build and print the deployment instructions.
|
||||||
|
function build(previousFileSizes) {
|
||||||
|
console.log('Creating an optimized production build...');
|
||||||
|
|
||||||
|
const compiler = webpack(config);
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
compiler.run((err, stats) => {
|
||||||
|
let messages;
|
||||||
|
if (err) {
|
||||||
|
if (!err.message) {
|
||||||
|
return reject(err);
|
||||||
|
}
|
||||||
|
|
||||||
|
let errMessage = err.message;
|
||||||
|
|
||||||
|
// Add additional information for postcss errors
|
||||||
|
if (Object.prototype.hasOwnProperty.call(err, 'postcssNode')) {
|
||||||
|
errMessage +=
|
||||||
|
'\nCompileError: Begins at CSS selector ' +
|
||||||
|
err['postcssNode'].selector;
|
||||||
|
}
|
||||||
|
|
||||||
|
messages = formatWebpackMessages({
|
||||||
|
errors: [errMessage],
|
||||||
|
warnings: [],
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
messages = formatWebpackMessages(
|
||||||
|
stats.toJson({ all: false, warnings: true, errors: true })
|
||||||
|
);
|
||||||
|
}
|
||||||
|
if (messages.errors.length) {
|
||||||
|
// Only keep the first error. Others are often indicative
|
||||||
|
// of the same problem, but confuse the reader with noise.
|
||||||
|
if (messages.errors.length > 1) {
|
||||||
|
messages.errors.length = 1;
|
||||||
|
}
|
||||||
|
return reject(new Error(messages.errors.join('\n\n')));
|
||||||
|
}
|
||||||
|
if (
|
||||||
|
process.env.CI &&
|
||||||
|
(typeof process.env.CI !== 'string' ||
|
||||||
|
process.env.CI.toLowerCase() !== 'false') &&
|
||||||
|
messages.warnings.length
|
||||||
|
) {
|
||||||
|
// Ignore sourcemap warnings in CI builds. See #8227 for more info.
|
||||||
|
const filteredWarnings = messages.warnings.filter(
|
||||||
|
w => !/Failed to parse source map/.test(w)
|
||||||
|
);
|
||||||
|
if (filteredWarnings.length) {
|
||||||
|
console.log(
|
||||||
|
chalk.yellow(
|
||||||
|
'\nTreating warnings as errors because process.env.CI = true.\n' +
|
||||||
|
'Most CI servers set it automatically.\n'
|
||||||
|
)
|
||||||
|
);
|
||||||
|
return reject(new Error(filteredWarnings.join('\n\n')));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const resolveArgs = {
|
||||||
|
stats,
|
||||||
|
previousFileSizes,
|
||||||
|
warnings: messages.warnings,
|
||||||
|
};
|
||||||
|
|
||||||
|
if (writeStatsJson) {
|
||||||
|
return bfj
|
||||||
|
.write(paths.appBuild + '/bundle-stats.json', stats.toJson())
|
||||||
|
.then(() => resolve(resolveArgs))
|
||||||
|
.catch(error => reject(new Error(error)));
|
||||||
|
}
|
||||||
|
|
||||||
|
return resolve(resolveArgs);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function copyPublicFolder() {
|
||||||
|
fs.copySync(paths.appPublic, paths.appBuild, {
|
||||||
|
dereference: true,
|
||||||
|
filter: file => file !== paths.appHtml,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,154 @@
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
// Do this as the first thing so that any code reading it knows the right env.
|
||||||
|
process.env.BABEL_ENV = 'development';
|
||||||
|
process.env.NODE_ENV = 'development';
|
||||||
|
|
||||||
|
// Makes the script crash on unhandled rejections instead of silently
|
||||||
|
// ignoring them. In the future, promise rejections that are not handled will
|
||||||
|
// terminate the Node.js process with a non-zero exit code.
|
||||||
|
process.on('unhandledRejection', err => {
|
||||||
|
throw err;
|
||||||
|
});
|
||||||
|
|
||||||
|
// Ensure environment variables are read.
|
||||||
|
require('../config/env');
|
||||||
|
|
||||||
|
const fs = require('fs');
|
||||||
|
const chalk = require('react-dev-utils/chalk');
|
||||||
|
const webpack = require('webpack');
|
||||||
|
const WebpackDevServer = require('webpack-dev-server');
|
||||||
|
const clearConsole = require('react-dev-utils/clearConsole');
|
||||||
|
const checkRequiredFiles = require('react-dev-utils/checkRequiredFiles');
|
||||||
|
const {
|
||||||
|
choosePort,
|
||||||
|
createCompiler,
|
||||||
|
prepareProxy,
|
||||||
|
prepareUrls,
|
||||||
|
} = require('react-dev-utils/WebpackDevServerUtils');
|
||||||
|
const openBrowser = require('react-dev-utils/openBrowser');
|
||||||
|
const semver = require('semver');
|
||||||
|
const paths = require('../config/paths');
|
||||||
|
const configFactory = require('../config/webpack.config');
|
||||||
|
const createDevServerConfig = require('../config/webpackDevServer.config');
|
||||||
|
const getClientEnvironment = require('../config/env');
|
||||||
|
const react = require(require.resolve('react', { paths: [paths.appPath] }));
|
||||||
|
|
||||||
|
const env = getClientEnvironment(paths.publicUrlOrPath.slice(0, -1));
|
||||||
|
const useYarn = fs.existsSync(paths.yarnLockFile);
|
||||||
|
const isInteractive = process.stdout.isTTY;
|
||||||
|
|
||||||
|
// Warn and crash if required files are missing
|
||||||
|
if (!checkRequiredFiles([paths.appHtml, paths.appIndexJs])) {
|
||||||
|
process.exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Tools like Cloud9 rely on this.
|
||||||
|
const DEFAULT_PORT = parseInt(process.env.PORT, 10) || 3000;
|
||||||
|
const HOST = process.env.HOST || '0.0.0.0';
|
||||||
|
|
||||||
|
if (process.env.HOST) {
|
||||||
|
console.log(
|
||||||
|
chalk.cyan(
|
||||||
|
`Attempting to bind to HOST environment variable: ${chalk.yellow(
|
||||||
|
chalk.bold(process.env.HOST)
|
||||||
|
)}`
|
||||||
|
)
|
||||||
|
);
|
||||||
|
console.log(
|
||||||
|
`If this was unintentional, check that you haven't mistakenly set it in your shell.`
|
||||||
|
);
|
||||||
|
console.log(
|
||||||
|
`Learn more here: ${chalk.yellow('https://cra.link/advanced-config')}`
|
||||||
|
);
|
||||||
|
console.log();
|
||||||
|
}
|
||||||
|
|
||||||
|
// We require that you explicitly set browsers and do not fall back to
|
||||||
|
// browserslist defaults.
|
||||||
|
const { checkBrowsers } = require('react-dev-utils/browsersHelper');
|
||||||
|
checkBrowsers(paths.appPath, isInteractive)
|
||||||
|
.then(() => {
|
||||||
|
// We attempt to use the default port but if it is busy, we offer the user to
|
||||||
|
// run on a different port. `choosePort()` Promise resolves to the next free port.
|
||||||
|
return choosePort(HOST, DEFAULT_PORT);
|
||||||
|
})
|
||||||
|
.then(port => {
|
||||||
|
if (port == null) {
|
||||||
|
// We have not found a port.
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const config = configFactory('development');
|
||||||
|
const protocol = process.env.HTTPS === 'true' ? 'https' : 'http';
|
||||||
|
const appName = require(paths.appPackageJson).name;
|
||||||
|
|
||||||
|
const useTypeScript = fs.existsSync(paths.appTsConfig);
|
||||||
|
const urls = prepareUrls(
|
||||||
|
protocol,
|
||||||
|
HOST,
|
||||||
|
port,
|
||||||
|
paths.publicUrlOrPath.slice(0, -1)
|
||||||
|
);
|
||||||
|
// Create a webpack compiler that is configured with custom messages.
|
||||||
|
const compiler = createCompiler({
|
||||||
|
appName,
|
||||||
|
config,
|
||||||
|
urls,
|
||||||
|
useYarn,
|
||||||
|
useTypeScript,
|
||||||
|
webpack,
|
||||||
|
});
|
||||||
|
// Load proxy config
|
||||||
|
const proxySetting = require(paths.appPackageJson).proxy;
|
||||||
|
const proxyConfig = prepareProxy(
|
||||||
|
proxySetting,
|
||||||
|
paths.appPublic,
|
||||||
|
paths.publicUrlOrPath
|
||||||
|
);
|
||||||
|
// Serve webpack assets generated by the compiler over a web server.
|
||||||
|
const serverConfig = {
|
||||||
|
...createDevServerConfig(proxyConfig, urls.lanUrlForConfig),
|
||||||
|
host: HOST,
|
||||||
|
port,
|
||||||
|
};
|
||||||
|
const devServer = new WebpackDevServer(serverConfig, compiler);
|
||||||
|
// Launch WebpackDevServer.
|
||||||
|
devServer.startCallback(() => {
|
||||||
|
if (isInteractive) {
|
||||||
|
clearConsole();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (env.raw.FAST_REFRESH && semver.lt(react.version, '16.10.0')) {
|
||||||
|
console.log(
|
||||||
|
chalk.yellow(
|
||||||
|
`Fast Refresh requires React 16.10 or higher. You are using React ${react.version}.`
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log(chalk.cyan('Starting the development server...\n'));
|
||||||
|
openBrowser(urls.localUrlForBrowser);
|
||||||
|
});
|
||||||
|
|
||||||
|
['SIGINT', 'SIGTERM'].forEach(function (sig) {
|
||||||
|
process.on(sig, function () {
|
||||||
|
devServer.close();
|
||||||
|
process.exit();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
if (process.env.CI !== 'true') {
|
||||||
|
// Gracefully exit when stdin ends
|
||||||
|
process.stdin.on('end', function () {
|
||||||
|
devServer.close();
|
||||||
|
process.exit();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.catch(err => {
|
||||||
|
if (err && err.message) {
|
||||||
|
console.log(err.message);
|
||||||
|
}
|
||||||
|
process.exit(1);
|
||||||
|
});
|
||||||
|
|
@ -0,0 +1,52 @@
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
// Do this as the first thing so that any code reading it knows the right env.
|
||||||
|
process.env.BABEL_ENV = 'test';
|
||||||
|
process.env.NODE_ENV = 'test';
|
||||||
|
process.env.PUBLIC_URL = '';
|
||||||
|
|
||||||
|
// Makes the script crash on unhandled rejections instead of silently
|
||||||
|
// ignoring them. In the future, promise rejections that are not handled will
|
||||||
|
// terminate the Node.js process with a non-zero exit code.
|
||||||
|
process.on('unhandledRejection', err => {
|
||||||
|
throw err;
|
||||||
|
});
|
||||||
|
|
||||||
|
// Ensure environment variables are read.
|
||||||
|
require('../config/env');
|
||||||
|
|
||||||
|
const jest = require('jest');
|
||||||
|
const execSync = require('child_process').execSync;
|
||||||
|
let argv = process.argv.slice(2);
|
||||||
|
|
||||||
|
function isInGitRepository() {
|
||||||
|
try {
|
||||||
|
execSync('git rev-parse --is-inside-work-tree', { stdio: 'ignore' });
|
||||||
|
return true;
|
||||||
|
} catch (e) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function isInMercurialRepository() {
|
||||||
|
try {
|
||||||
|
execSync('hg --cwd . root', { stdio: 'ignore' });
|
||||||
|
return true;
|
||||||
|
} catch (e) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Watch unless on CI or explicitly running all tests
|
||||||
|
if (
|
||||||
|
!process.env.CI &&
|
||||||
|
argv.indexOf('--watchAll') === -1 &&
|
||||||
|
argv.indexOf('--watchAll=false') === -1
|
||||||
|
) {
|
||||||
|
// https://github.com/facebook/create-react-app/issues/5210
|
||||||
|
const hasSourceControl = isInGitRepository() || isInMercurialRepository();
|
||||||
|
argv.push(hasSourceControl ? '--watch' : '--watchAll');
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
jest.run(argv);
|
||||||
|
|
@ -0,0 +1,119 @@
|
||||||
|
const logger = require('../utils/log.cjs')
|
||||||
|
const routes = require('./routes.cjs')
|
||||||
|
const httpProxy = require('http-proxy')
|
||||||
|
const proxy = httpProxy.createProxyServer({})
|
||||||
|
const fs = require('fs')
|
||||||
|
const dist = 'build'
|
||||||
|
let mime
|
||||||
|
import('mime').then((res) => {
|
||||||
|
mime = res.default
|
||||||
|
})
|
||||||
|
let proxys = require('../../../src/proxy.cjs')
|
||||||
|
const httpOk = 200
|
||||||
|
const httpBadRequest = 400
|
||||||
|
const matchProxy = (request, response) => {
|
||||||
|
const match = request.url.split('/')[1]
|
||||||
|
const proxyInfo = proxys['/' + match]
|
||||||
|
if (proxyInfo) {
|
||||||
|
delete request.headers.host
|
||||||
|
request.url = proxyInfo.rewrite(request.url)
|
||||||
|
proxy.web(request, response, {
|
||||||
|
target: proxyInfo.target,
|
||||||
|
changeOrigin: proxyInfo.changeOrigin
|
||||||
|
})
|
||||||
|
logger.info(`${request.method} ${httpOk} ${request.url}`)
|
||||||
|
return true
|
||||||
|
} else {
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
}
|
||||||
|
const matchRouter = async (request, response) => {
|
||||||
|
let [url] = request.url.split('?')
|
||||||
|
let route = routes
|
||||||
|
let url_sp = url.split('/')
|
||||||
|
for (let p of url_sp) {
|
||||||
|
if (!p) {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
if (route[p]) {
|
||||||
|
route = route[p]
|
||||||
|
} else {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (typeof route === 'function') {
|
||||||
|
await route(request, response)
|
||||||
|
// response.writeHead(httpOk, { 'Content-Type': 'application/json' })
|
||||||
|
// response.end(JSON.stringify(res))
|
||||||
|
logger.info(`${request.method} ${httpOk} ${request.url}`)
|
||||||
|
return true
|
||||||
|
} else {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
const matchFile = async (request, response) => {
|
||||||
|
return new Promise((resolve) => {
|
||||||
|
const path = request.url.split('?')[0]
|
||||||
|
fs.readFile(dist + decodeURIComponent(path), (err, file) => {
|
||||||
|
if (!err) {
|
||||||
|
const mimetype = mime.getType(request.url)
|
||||||
|
response.writeHead(httpOk, { 'Content-Type': mimetype })
|
||||||
|
response.end(file)
|
||||||
|
// logger.info(`${request.method} ${httpOk} ${request.url}`)
|
||||||
|
resolve(true)
|
||||||
|
} else {
|
||||||
|
resolve(false)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
const endIndex = async (request, response) => {
|
||||||
|
console.log(dist + '/index.html')
|
||||||
|
fs.readFile(dist + '/index.html', (err, html) => {
|
||||||
|
if (!err) {
|
||||||
|
response.writeHead(httpOk, { 'Content-type': 'text/html;charset=utf-8' })
|
||||||
|
response.end(html)
|
||||||
|
logger.info(`${request.method} ${httpOk} ${request.url}`)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
const matchType = async (request, response) => {
|
||||||
|
const isRouter = await matchRouter(request, response)
|
||||||
|
if (isRouter) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
let isProxy = await matchProxy(request, response)
|
||||||
|
if (isProxy) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
let isFile = await matchFile(request, response)
|
||||||
|
if (isFile) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
await endIndex(request, response)
|
||||||
|
}
|
||||||
|
|
||||||
|
const httpService = async (request, response) => {
|
||||||
|
try {
|
||||||
|
await matchType(request, response)
|
||||||
|
} catch (e) {
|
||||||
|
response.writeHead(httpBadRequest, { 'Content-Type': 'application/json' })
|
||||||
|
response.end(
|
||||||
|
JSON.stringify({
|
||||||
|
code: -1,
|
||||||
|
message: String(e)
|
||||||
|
})
|
||||||
|
)
|
||||||
|
logger.info(`${request.method} ${httpBadRequest} ${request.url}`)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
module.exports = {
|
||||||
|
httpService,
|
||||||
|
matchType,
|
||||||
|
matchRouter,
|
||||||
|
matchFile,
|
||||||
|
endIndex,
|
||||||
|
matchProxy,
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,56 @@
|
||||||
|
// const logger = require("../utils/log.cjs")
|
||||||
|
const config = require("../utils/config.cjs");
|
||||||
|
const request = require("request");
|
||||||
|
const CryptoJS = require("crypto-js");
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
config: async () => {
|
||||||
|
return config;
|
||||||
|
},
|
||||||
|
download: async (req, res) => {
|
||||||
|
const query = req.query;
|
||||||
|
query.url = CryptoJS.enc.Utf8.stringify(
|
||||||
|
CryptoJS.enc.Base64.parse(query.url)
|
||||||
|
).toString();
|
||||||
|
query.headers = {
|
||||||
|
"User-Agent":
|
||||||
|
"Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:136.0) Gecko/20100101 Firefox/136.0",
|
||||||
|
Accept: "*/*",
|
||||||
|
"Accept-Language":
|
||||||
|
"zh-CN,zh;q=0.8,zh-TW;q=0.7,zh-HK;q=0.5,en-US;q=0.3,en;q=0.2",
|
||||||
|
Connection: "keep-alive",
|
||||||
|
"Sec-Fetch-Dest": "empty",
|
||||||
|
"Sec-Fetch-Mode": "cors",
|
||||||
|
"Sec-Fetch-Site": "cross-site",
|
||||||
|
...JSON.parse(
|
||||||
|
CryptoJS.enc.Utf8.stringify(
|
||||||
|
CryptoJS.enc.Base64.parse(query.headers)
|
||||||
|
).toString()
|
||||||
|
),
|
||||||
|
};
|
||||||
|
const response = request(query.url, {
|
||||||
|
headers: query.headers,
|
||||||
|
});
|
||||||
|
response.on("response", (resp) => {
|
||||||
|
["content-length", "content-type", "content-disposition"].forEach(
|
||||||
|
(key) => {
|
||||||
|
if (resp.headers[key]) {
|
||||||
|
res.setHeader(key, resp.headers[key]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
res.setHeader("access-control-allow-origin", "*")
|
||||||
|
});
|
||||||
|
|
||||||
|
response.on("error", (e) => {
|
||||||
|
res.status(500).send(String(e));
|
||||||
|
});
|
||||||
|
response.on("end", () => {
|
||||||
|
res.end();
|
||||||
|
});
|
||||||
|
response.on("data", (chunk) => {
|
||||||
|
res.write(chunk);
|
||||||
|
});
|
||||||
|
// response.pipe(res);
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
@ -0,0 +1,2 @@
|
||||||
|
const config = require("../../../src/config.json")
|
||||||
|
module.exports = config
|
||||||
|
|
@ -0,0 +1,53 @@
|
||||||
|
const winston = require('winston');
|
||||||
|
function thisLine() {
|
||||||
|
try {
|
||||||
|
const e = new Error();
|
||||||
|
const regex = /\((.*):(\d+):(\d+)\)$/
|
||||||
|
const stacks = e.stack.split("\n")
|
||||||
|
const temp = []
|
||||||
|
stacks.forEach(stack => {
|
||||||
|
if (!stack.includes("node_modules")) {
|
||||||
|
temp.push(stack)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
const match = regex.exec(temp[3]);
|
||||||
|
return {
|
||||||
|
filepath: match[1],
|
||||||
|
line: match[2],
|
||||||
|
column: match[3]
|
||||||
|
};
|
||||||
|
} catch (e) {
|
||||||
|
return {
|
||||||
|
filepath: "unknow",
|
||||||
|
line: "0",
|
||||||
|
column: "0"
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
const logger = winston.createLogger({
|
||||||
|
level: 'info',
|
||||||
|
transports: [
|
||||||
|
new winston.transports.Console(),
|
||||||
|
new winston.transports.File({
|
||||||
|
dirname: 'log', filename: 'server.log'
|
||||||
|
}),
|
||||||
|
],
|
||||||
|
datePattern: 'YYYY-MM-DD',
|
||||||
|
zippedArchive: true,
|
||||||
|
format: winston.format.combine(
|
||||||
|
winston.format.timestamp({ format: "YYYY-MM-DD HH:mm:ss,SSS" }),
|
||||||
|
winston.format.align(),
|
||||||
|
winston.format.splat(),
|
||||||
|
winston.format.printf(
|
||||||
|
(info) => {
|
||||||
|
const { timestamp, level, message } = info;
|
||||||
|
const { filepath, line } = thisLine()
|
||||||
|
return `[${timestamp}] [${level.toUpperCase()}] [${filepath}:${line}] ${message}`; // 包括文件名和行号
|
||||||
|
}
|
||||||
|
)
|
||||||
|
),
|
||||||
|
maxSize: '500m', // 每个日志文件最大尺寸
|
||||||
|
maxFiles: '1d' // 保留的日志文件天数
|
||||||
|
});
|
||||||
|
|
||||||
|
module.exports = logger
|
||||||
|
|
@ -0,0 +1,22 @@
|
||||||
|
/* eslint-disable no-undef */
|
||||||
|
// 这里是生产环境的反向代理逻辑
|
||||||
|
const initService = () => {
|
||||||
|
const bodyParser = require("body-parser");
|
||||||
|
const urlencodedParser = bodyParser.urlencoded({ extended: false });
|
||||||
|
const express = require("express");
|
||||||
|
const router = require("./core/router/index.cjs");
|
||||||
|
// const logger = console
|
||||||
|
const config = require("./core/utils/config.cjs");
|
||||||
|
const logger = require("./core/utils/log.cjs");
|
||||||
|
const server = express();
|
||||||
|
const PORT = config.port;
|
||||||
|
server.all("*", urlencodedParser, router.httpService);
|
||||||
|
server.listen(PORT, function () {
|
||||||
|
logger.info(`server start at http://127.0.0.1:${PORT}`);
|
||||||
|
});
|
||||||
|
};
|
||||||
|
try {
|
||||||
|
initService();
|
||||||
|
} catch (e) {
|
||||||
|
console.error(e);
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,19 @@
|
||||||
|
// 这里是开发环境的反向代理逻辑
|
||||||
|
const routes = require("./core/router/routes.cjs");
|
||||||
|
const router = require("./core/router/index.cjs");
|
||||||
|
|
||||||
|
module.exports = function mock(req, res, next) {
|
||||||
|
if (req.path === "/download/") {
|
||||||
|
// const query = getQuery(req);
|
||||||
|
try {
|
||||||
|
routes.download(req, res);
|
||||||
|
} catch (e) {
|
||||||
|
res.send({ code: 500, msg: String(e) });
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
const response = router.matchProxy(req, res);
|
||||||
|
if (!response) {
|
||||||
|
next();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
@ -0,0 +1,121 @@
|
||||||
|
* {
|
||||||
|
box-sizing: border-box;
|
||||||
|
margin: 0;
|
||||||
|
padding: 0;
|
||||||
|
}
|
||||||
|
a {
|
||||||
|
text-decoration: none;
|
||||||
|
color: inherit;
|
||||||
|
}
|
||||||
|
ul, li {
|
||||||
|
list-style: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.App {
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.App-logo {
|
||||||
|
height: 40vmin;
|
||||||
|
pointer-events: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
@media (prefers-reduced-motion: no-preference) {
|
||||||
|
.App-logo {
|
||||||
|
animation: App-logo-spin infinite 20s linear;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.App-header {
|
||||||
|
background-color: #282c34;
|
||||||
|
min-height: 100vh;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
font-size: calc(10px + 2vmin);
|
||||||
|
color: white;
|
||||||
|
}
|
||||||
|
|
||||||
|
.App-link {
|
||||||
|
color: #61dafb;
|
||||||
|
}
|
||||||
|
|
||||||
|
@keyframes App-logo-spin {
|
||||||
|
from {
|
||||||
|
transform: rotate(0deg);
|
||||||
|
}
|
||||||
|
to {
|
||||||
|
transform: rotate(360deg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.page{
|
||||||
|
height: 100vh;
|
||||||
|
overflow-x: hidden;
|
||||||
|
overflow-y: auto;
|
||||||
|
}
|
||||||
|
|
||||||
|
.flex-row{
|
||||||
|
display: flex;
|
||||||
|
flex-direction: row;
|
||||||
|
}
|
||||||
|
|
||||||
|
.flex-col{
|
||||||
|
flex-direction: column;
|
||||||
|
display: flex;
|
||||||
|
}
|
||||||
|
|
||||||
|
.header-row {
|
||||||
|
width: 100%;
|
||||||
|
margin: 0 auto;
|
||||||
|
padding: 0 60px;
|
||||||
|
box-sizing: border-box;
|
||||||
|
}
|
||||||
|
|
||||||
|
body {
|
||||||
|
overflow-x: hidden;
|
||||||
|
background: #f0f2f4;
|
||||||
|
font-family: Source Han Sans, Source Han Sans;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Layout: header + container + footer */
|
||||||
|
.layout {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
min-height: 100vh;
|
||||||
|
}
|
||||||
|
|
||||||
|
.layout-header {
|
||||||
|
flex-shrink: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.container {
|
||||||
|
flex: 1;
|
||||||
|
overflow: auto;
|
||||||
|
}
|
||||||
|
|
||||||
|
.layout-footer {
|
||||||
|
flex-shrink: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* html {
|
||||||
|
font-size: 16px;
|
||||||
|
}
|
||||||
|
@media screen and (max-width: 1920px) {
|
||||||
|
html {
|
||||||
|
font-size: 16px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@media screen and (max-width: 1440px) {
|
||||||
|
html {
|
||||||
|
font-size: 14px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@media screen and (max-width: 1024px) {
|
||||||
|
html {
|
||||||
|
font-size: 12px;
|
||||||
|
}
|
||||||
|
} */
|
||||||
|
|
@ -0,0 +1,9 @@
|
||||||
|
import React from 'react';
|
||||||
|
import { render, screen } from '@testing-library/react';
|
||||||
|
import App from './App';
|
||||||
|
|
||||||
|
test('renders learn react link', () => {
|
||||||
|
render(<App />);
|
||||||
|
const linkElement = screen.getByText(/learn react/i);
|
||||||
|
expect(linkElement).toBeInTheDocument();
|
||||||
|
});
|
||||||
|
|
@ -0,0 +1,65 @@
|
||||||
|
// App.js
|
||||||
|
import { BrowserRouter as Router, useRoutes } from 'react-router-dom';
|
||||||
|
import "./App.css"
|
||||||
|
import routes from "@/Routes";
|
||||||
|
import { useCallback, useEffect, useState } from "react";
|
||||||
|
import appApi from "@/api/app";
|
||||||
|
import store from "@/store";
|
||||||
|
|
||||||
|
function AppRoutes() {
|
||||||
|
return useRoutes(routes);
|
||||||
|
}
|
||||||
|
|
||||||
|
function App() {
|
||||||
|
const [init, setInit] = useState(false);
|
||||||
|
|
||||||
|
const initState = useCallback((data: any) => {
|
||||||
|
const { favicon, shortName } = data?.company?.config || {};
|
||||||
|
if (favicon) {
|
||||||
|
// 替换网页图标
|
||||||
|
const favor: any = document.querySelector("link[rel*='icon']") || document.createElement('link');
|
||||||
|
favor.type = 'image/x-icon';
|
||||||
|
favor.rel = 'shortcut icon';
|
||||||
|
favor.href = favicon;
|
||||||
|
}
|
||||||
|
if (shortName) {
|
||||||
|
document.title = shortName
|
||||||
|
}
|
||||||
|
}, [])
|
||||||
|
|
||||||
|
const getAppConfig = useCallback(async () => {
|
||||||
|
try {
|
||||||
|
let res = await appApi.getAppConfig();
|
||||||
|
let data = res.data;
|
||||||
|
try {
|
||||||
|
data.company.config = JSON.parse(data.company.config)
|
||||||
|
} catch (error) {
|
||||||
|
console.log(error)
|
||||||
|
}
|
||||||
|
store.setItem("appConfig", data);
|
||||||
|
initState(data)
|
||||||
|
} catch (error) {
|
||||||
|
console.log(error)
|
||||||
|
}
|
||||||
|
setInit(true);
|
||||||
|
}, [])
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (init) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// getAppConfig();
|
||||||
|
}, [])
|
||||||
|
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<div>
|
||||||
|
<Router>
|
||||||
|
<AppRoutes />
|
||||||
|
</Router>
|
||||||
|
</div>
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
export default App;
|
||||||
|
|
@ -0,0 +1,61 @@
|
||||||
|
import Home from "@/pages/Home/index";
|
||||||
|
import MainLayout from "@/layouts/MainLayout";
|
||||||
|
import type { RouteObject } from "react-router-dom";
|
||||||
|
|
||||||
|
import About from "@/pages/About/index";
|
||||||
|
import AboutHistory from "@/pages/About/History";
|
||||||
|
import AboutFounder from "@/pages/About/Founder";
|
||||||
|
import Business from "@/pages/Business/index";
|
||||||
|
import BusinessCommercialGroup from "@/pages/Business/CommercialGroup";
|
||||||
|
import BusinessBaseGroup from "@/pages/Business/BaseGroup";
|
||||||
|
import BusinessRealtyGroup from "@/pages/Business/RealtyGroup";
|
||||||
|
import BusinessInvestGroup from "@/pages/Business/InvestGroup";
|
||||||
|
import BusinessRujingGroup from "@/pages/Business/RujingGroup";
|
||||||
|
import Social from "@/pages/Social/index";
|
||||||
|
import SocialSustainability from "@/pages/Social/Sustainability";
|
||||||
|
import SocialFoundation from "@/pages/Social/Foundation";
|
||||||
|
import News from "@/pages/News/index";
|
||||||
|
import NewsConsult from "@/pages/News/Consult";
|
||||||
|
import NewsMedia from "@/pages/News/Media";
|
||||||
|
import Join from "@/pages/Join/index";
|
||||||
|
import JoinCulture from "@/pages/Join/Culture";
|
||||||
|
import JoinCampus from "@/pages/Join/Campus";
|
||||||
|
|
||||||
|
const routes: RouteObject[] = [
|
||||||
|
{
|
||||||
|
path: "/",
|
||||||
|
element: <MainLayout></MainLayout>,
|
||||||
|
children: [
|
||||||
|
{ index: true, element: <Home /> },
|
||||||
|
// 关于银泰
|
||||||
|
{ path: "about", element: <About /> },
|
||||||
|
{ path: "about/history", element: <AboutHistory /> },
|
||||||
|
{ path: "about/founder", element: <AboutFounder /> },
|
||||||
|
// 集团业务
|
||||||
|
{ path: "business", element: <Business /> },
|
||||||
|
{ path: "business/commercial-group", element: <BusinessCommercialGroup /> },
|
||||||
|
{ path: "business/base-group", element: <BusinessBaseGroup /> },
|
||||||
|
{ path: "business/realty-group", element: <BusinessRealtyGroup /> },
|
||||||
|
{ path: "business/invest-group", element: <BusinessInvestGroup /> },
|
||||||
|
{ path: "business/ruijing-group", element: <BusinessRujingGroup /> },
|
||||||
|
// 社会责任
|
||||||
|
{ path: "social", element: <Social /> },
|
||||||
|
{ path: "social/sustainability", element: <SocialSustainability /> },
|
||||||
|
{ path: "social/foundation", element: <SocialFoundation /> },
|
||||||
|
// 新闻中心
|
||||||
|
{ path: "news", element: <News /> },
|
||||||
|
{ path: "news/consult", element: <NewsConsult /> },
|
||||||
|
{ path: "news/media", element: <NewsMedia /> },
|
||||||
|
// 加入银泰
|
||||||
|
{ path: "join", element: <Join /> },
|
||||||
|
{ path: "join/culture", element: <JoinCulture /> },
|
||||||
|
{ path: "join/campus", element: <JoinCampus /> },
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
path: '*',
|
||||||
|
element: <div>404 Not Found</div>
|
||||||
|
}
|
||||||
|
];
|
||||||
|
|
||||||
|
export default routes;
|
||||||
|
|
@ -0,0 +1,25 @@
|
||||||
|
import requests from "@/utils/request";
|
||||||
|
|
||||||
|
const app = {
|
||||||
|
getAppConfig() {
|
||||||
|
return requests({
|
||||||
|
url: "/api/config",
|
||||||
|
method: "get",
|
||||||
|
});
|
||||||
|
},
|
||||||
|
getJobList(params: any) {
|
||||||
|
return requests({
|
||||||
|
url: "/api/job",
|
||||||
|
method: "get",
|
||||||
|
params
|
||||||
|
});
|
||||||
|
},
|
||||||
|
getJobDetail(id: number | string) {
|
||||||
|
return requests({
|
||||||
|
url: `/api/job/${id}`,
|
||||||
|
method: "get",
|
||||||
|
});
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
export default app;
|
||||||
|
|
@ -0,0 +1,75 @@
|
||||||
|
/* Hero */
|
||||||
|
.hero {
|
||||||
|
position: relative;
|
||||||
|
min-height: 100vh;
|
||||||
|
background-size: cover;
|
||||||
|
background-position: center;
|
||||||
|
padding-bottom: 50px;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
justify-content: flex-end;
|
||||||
|
}
|
||||||
|
|
||||||
|
.heroOverlay {
|
||||||
|
position: absolute;
|
||||||
|
inset: 0;
|
||||||
|
background: linear-gradient(
|
||||||
|
to right,
|
||||||
|
rgba(0, 0, 0, 0.5) 0%,
|
||||||
|
rgba(0, 0, 0, 0.2) 60%,
|
||||||
|
transparent 100%
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
.heroContent {
|
||||||
|
position: relative;
|
||||||
|
z-index: 1;
|
||||||
|
padding: 0 24px;
|
||||||
|
/* padding-top: 400px; */
|
||||||
|
padding-left: 13.5%;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
justify-content: flex-end;
|
||||||
|
}
|
||||||
|
|
||||||
|
.heroTitle {
|
||||||
|
font-size: 60px;
|
||||||
|
font-weight: 700;
|
||||||
|
color: #fff;
|
||||||
|
/* margin: 0 0 50px; */
|
||||||
|
letter-spacing: 0.05em;
|
||||||
|
}
|
||||||
|
|
||||||
|
.heroSubtitle {
|
||||||
|
font-size: 40px;
|
||||||
|
font-weight: 700;
|
||||||
|
color: #fff;
|
||||||
|
/* margin: 0 0 16px; */
|
||||||
|
letter-spacing: 0.05em;
|
||||||
|
}
|
||||||
|
|
||||||
|
.heroDesc {
|
||||||
|
max-width: 900px;
|
||||||
|
font-size: 20px;
|
||||||
|
color: rgba(255, 255, 255, 0.95);
|
||||||
|
margin: 0;
|
||||||
|
letter-spacing: 0.02em;
|
||||||
|
}
|
||||||
|
|
||||||
|
.heroLargeDesc {
|
||||||
|
font-size: 34px;
|
||||||
|
color: rgba(255, 255, 255, 0.95);
|
||||||
|
margin: 0;
|
||||||
|
letter-spacing: 0.02em;
|
||||||
|
}
|
||||||
|
|
||||||
|
.breadcrumb {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: row;
|
||||||
|
gap: 5px;
|
||||||
|
color: #fff;
|
||||||
|
text-decoration: none;
|
||||||
|
font-size: 16px;
|
||||||
|
margin-top: 100px;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
@ -0,0 +1,163 @@
|
||||||
|
.wrapper {
|
||||||
|
position: relative;
|
||||||
|
display: inline-block;
|
||||||
|
min-width: 140px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.trigger {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: space-between;
|
||||||
|
gap: 8px;
|
||||||
|
padding: 8px 11px;
|
||||||
|
background: #14355C;
|
||||||
|
color: #fff;
|
||||||
|
border: 1px solid rgba(255, 255, 255, 0.25);
|
||||||
|
border-radius: 6px;
|
||||||
|
cursor: pointer;
|
||||||
|
user-select: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.trigger:hover:not(.disabled) {
|
||||||
|
border-color: rgba(255, 255, 255, 0.5);
|
||||||
|
}
|
||||||
|
|
||||||
|
.trigger:focus {
|
||||||
|
outline: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.trigger.disabled {
|
||||||
|
cursor: not-allowed;
|
||||||
|
opacity: 0.6;
|
||||||
|
}
|
||||||
|
|
||||||
|
.text {
|
||||||
|
flex: 1;
|
||||||
|
white-space: nowrap;
|
||||||
|
overflow: hidden;
|
||||||
|
text-overflow: ellipsis;
|
||||||
|
}
|
||||||
|
|
||||||
|
.trigger .text {
|
||||||
|
color: rgba(255, 255, 255, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
.trigger.hasValue .text {
|
||||||
|
color: #fff;
|
||||||
|
}
|
||||||
|
|
||||||
|
.icons {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.clear {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
width: 16px;
|
||||||
|
height: 16px;
|
||||||
|
color: rgba(255, 255, 255, 0.85);
|
||||||
|
font-size: 14px;
|
||||||
|
line-height: 1;
|
||||||
|
cursor: pointer;
|
||||||
|
border-radius: 2px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.clear:hover {
|
||||||
|
color: #fff;
|
||||||
|
background: rgba(255, 255, 255, 0.15);
|
||||||
|
}
|
||||||
|
|
||||||
|
.arrow {
|
||||||
|
color: rgba(255, 255, 255, 0.85);
|
||||||
|
transition: transform 0.2s;
|
||||||
|
}
|
||||||
|
|
||||||
|
.arrowOpen {
|
||||||
|
transform: rotate(180deg);
|
||||||
|
}
|
||||||
|
|
||||||
|
.panel {
|
||||||
|
position: absolute;
|
||||||
|
top: calc(100% + 4px);
|
||||||
|
left: 0;
|
||||||
|
z-index: 1050;
|
||||||
|
min-width: 220px;
|
||||||
|
padding: 12px;
|
||||||
|
background: #14355C;
|
||||||
|
border: 1px solid rgba(255, 255, 255, 0.25);
|
||||||
|
border-radius: 8px;
|
||||||
|
box-shadow: 0 6px 16px rgba(0, 0, 0, 0.3);
|
||||||
|
}
|
||||||
|
|
||||||
|
.header {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: space-between;
|
||||||
|
margin-bottom: 12px;
|
||||||
|
padding: 0 4px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.navBtn {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
width: 28px;
|
||||||
|
height: 28px;
|
||||||
|
padding: 0;
|
||||||
|
background: transparent;
|
||||||
|
color: #fff;
|
||||||
|
border: none;
|
||||||
|
border-radius: 4px;
|
||||||
|
cursor: pointer;
|
||||||
|
font-size: 12px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.navBtn:hover:not(:disabled) {
|
||||||
|
background: rgba(255, 255, 255, 0.15);
|
||||||
|
}
|
||||||
|
|
||||||
|
.navBtn:disabled {
|
||||||
|
opacity: 0.4;
|
||||||
|
cursor: not-allowed;
|
||||||
|
}
|
||||||
|
|
||||||
|
.decadeLabel {
|
||||||
|
color: #fff;
|
||||||
|
font-size: 14px;
|
||||||
|
font-weight: 500;
|
||||||
|
}
|
||||||
|
|
||||||
|
.yearGrid {
|
||||||
|
display: grid;
|
||||||
|
grid-template-columns: repeat(3, 1fr);
|
||||||
|
gap: 4px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.yearCell {
|
||||||
|
min-width: 56px;
|
||||||
|
height: 32px;
|
||||||
|
padding: 0;
|
||||||
|
background: transparent;
|
||||||
|
color: #fff;
|
||||||
|
border: none;
|
||||||
|
border-radius: 4px;
|
||||||
|
cursor: pointer;
|
||||||
|
font-size: 14px;
|
||||||
|
transition: background 0.2s;
|
||||||
|
}
|
||||||
|
|
||||||
|
.yearCell:hover:not(.disabled) {
|
||||||
|
background: rgba(255, 255, 255, 0.15);
|
||||||
|
}
|
||||||
|
|
||||||
|
.yearCell.selected {
|
||||||
|
background: rgba(255, 255, 255, 0.25);
|
||||||
|
font-weight: 500;
|
||||||
|
}
|
||||||
|
|
||||||
|
.yearCell.disabled {
|
||||||
|
color: rgba(255, 255, 255, 0.25);
|
||||||
|
cursor: not-allowed;
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,145 @@
|
||||||
|
import { useState, useEffect, useRef } from "react";
|
||||||
|
import styles from "./YearPicker.module.css";
|
||||||
|
|
||||||
|
export type YearPickerProps = {
|
||||||
|
value?: number | null;
|
||||||
|
onChange?: (year: number | null) => void;
|
||||||
|
placeholder?: string;
|
||||||
|
minYear?: number;
|
||||||
|
maxYear?: number;
|
||||||
|
className?: string;
|
||||||
|
disabled?: boolean;
|
||||||
|
};
|
||||||
|
|
||||||
|
const currentYear = new Date().getFullYear();
|
||||||
|
|
||||||
|
function getDecadeStart(year: number) {
|
||||||
|
return Math.floor(year / 10) * 10;
|
||||||
|
}
|
||||||
|
|
||||||
|
export default function YearPicker({
|
||||||
|
value,
|
||||||
|
onChange,
|
||||||
|
placeholder = "年份",
|
||||||
|
minYear = currentYear - 300,
|
||||||
|
maxYear = currentYear + 300,
|
||||||
|
className,
|
||||||
|
disabled = false,
|
||||||
|
}: YearPickerProps) {
|
||||||
|
const [open, setOpen] = useState(false);
|
||||||
|
const [decadeStart, setDecadeStart] = useState(() =>
|
||||||
|
getDecadeStart(value ?? currentYear)
|
||||||
|
);
|
||||||
|
const containerRef = useRef<HTMLDivElement>(null);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (value != null) {
|
||||||
|
setDecadeStart(getDecadeStart(value));
|
||||||
|
}
|
||||||
|
}, [value]);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (!open) return;
|
||||||
|
const handleClickOutside = (e: MouseEvent) => {
|
||||||
|
if (containerRef.current && !containerRef.current.contains(e.target as Node)) {
|
||||||
|
setOpen(false);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
document.addEventListener("mousedown", handleClickOutside);
|
||||||
|
return () => document.removeEventListener("mousedown", handleClickOutside);
|
||||||
|
}, [open]);
|
||||||
|
|
||||||
|
const handleTriggerClick = () => {
|
||||||
|
if (!disabled) setOpen((o) => !o);
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleYearClick = (year: number) => {
|
||||||
|
onChange?.(year);
|
||||||
|
setOpen(false);
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleClear = (e: React.MouseEvent) => {
|
||||||
|
e.stopPropagation();
|
||||||
|
onChange?.(null);
|
||||||
|
};
|
||||||
|
|
||||||
|
const prevDecade = () => {
|
||||||
|
setDecadeStart((d) => Math.max(minYear, d - 10));
|
||||||
|
};
|
||||||
|
const nextDecade = () => {
|
||||||
|
setDecadeStart((d) => Math.min(maxYear, d + 10));
|
||||||
|
};
|
||||||
|
|
||||||
|
const years = Array.from({ length: 12 }, (_, i) => decadeStart + i);
|
||||||
|
const decadeEnd = Math.min(decadeStart + 9, maxYear);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div
|
||||||
|
ref={containerRef}
|
||||||
|
className={`${styles.wrapper} ${className ?? ""}`}
|
||||||
|
>
|
||||||
|
<div
|
||||||
|
role="button"
|
||||||
|
tabIndex={0}
|
||||||
|
className={`${styles.trigger} ${disabled ? styles.disabled : ""} ${value != null ? styles.hasValue : ""}`}
|
||||||
|
onClick={handleTriggerClick}
|
||||||
|
onKeyDown={(e) => {
|
||||||
|
if (e.key === "Enter" || e.key === " ") {
|
||||||
|
e.preventDefault();
|
||||||
|
handleTriggerClick();
|
||||||
|
}
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<span className={styles.text}>
|
||||||
|
{value != null ? `${value}年` : placeholder}
|
||||||
|
</span>
|
||||||
|
<div className={styles.icons}>
|
||||||
|
<img className={`${styles.arrow} ${open ? styles.arrowOpen : ""}`} src="/images/icon-arrow-down.png" alt="arrow-down" style={{ width: "24px", height: "24px" }} />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{open && (
|
||||||
|
<div className={styles.panel}>
|
||||||
|
<div className={styles.header}>
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
className={styles.navBtn}
|
||||||
|
onClick={prevDecade}
|
||||||
|
disabled={decadeStart <= minYear}
|
||||||
|
>
|
||||||
|
◀
|
||||||
|
</button>
|
||||||
|
<span className={styles.decadeLabel}>
|
||||||
|
{decadeStart} - {decadeEnd}
|
||||||
|
</span>
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
className={styles.navBtn}
|
||||||
|
onClick={nextDecade}
|
||||||
|
disabled={decadeStart + 10 > maxYear}
|
||||||
|
>
|
||||||
|
▶
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
<div className={styles.yearGrid}>
|
||||||
|
{years.map((year) => {
|
||||||
|
const inRange = year >= minYear && year <= maxYear;
|
||||||
|
const selected = value === year;
|
||||||
|
return (
|
||||||
|
<button
|
||||||
|
key={year}
|
||||||
|
type="button"
|
||||||
|
className={`${styles.yearCell} ${selected ? styles.selected : ""} ${!inRange ? styles.disabled : ""}`}
|
||||||
|
disabled={!inRange}
|
||||||
|
onClick={() => inRange && handleYearClick(year)}
|
||||||
|
>
|
||||||
|
{inRange ? year : ""}
|
||||||
|
</button>
|
||||||
|
);
|
||||||
|
})}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,37 @@
|
||||||
|
import { Link } from "react-router-dom";
|
||||||
|
import styles from "./Banner.module.css";
|
||||||
|
const FALLBACK_GRADIENT = "linear-gradient(135deg, #1a2a4a 0%, #2d4a7c 100%)";
|
||||||
|
|
||||||
|
type Props = {
|
||||||
|
title: string;
|
||||||
|
subtitle?: string;
|
||||||
|
desc?: string;
|
||||||
|
largedesc?: string;
|
||||||
|
showBreadcrumb?: boolean;
|
||||||
|
backgroundImage: string;
|
||||||
|
}
|
||||||
|
export default function Banner({ title, subtitle, desc, largedesc, showBreadcrumb, backgroundImage }: Props) {
|
||||||
|
return (
|
||||||
|
<section
|
||||||
|
className={styles.hero}
|
||||||
|
style={{
|
||||||
|
backgroundImage: `url(${backgroundImage}), ${FALLBACK_GRADIENT}`,
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<div className={styles.heroOverlay} />
|
||||||
|
<div className={styles.heroContent} style={{gap: '30px'}}>
|
||||||
|
<h1 className={styles.heroTitle}>{title}</h1>
|
||||||
|
{subtitle && <h2 className={styles.heroSubtitle}>{subtitle}</h2>}
|
||||||
|
{desc && <p className={styles.heroDesc}>{desc}</p>}
|
||||||
|
{largedesc && <p className={styles.heroLargeDesc}>{largedesc}</p>}
|
||||||
|
{showBreadcrumb && (
|
||||||
|
<div className={styles.breadcrumb}>
|
||||||
|
<Link to="/">首页</Link>
|
||||||
|
<span>{'>'}</span>
|
||||||
|
<Link to="/about">关于银泰</Link>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
</section>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,27 @@
|
||||||
|
{
|
||||||
|
"title": "公司官网",
|
||||||
|
"host": "sdxf",
|
||||||
|
"baseUrl": "/companyHome",
|
||||||
|
"messageDuration": 3000,
|
||||||
|
"requestTimeout": 60000,
|
||||||
|
"successCode": [
|
||||||
|
200,
|
||||||
|
0
|
||||||
|
],
|
||||||
|
"invalidCode": [
|
||||||
|
1001106,
|
||||||
|
1001003
|
||||||
|
],
|
||||||
|
"port": 9293 ,
|
||||||
|
"rbBuldInfo": {
|
||||||
|
"api": "http://rb2.batiao8.com/console/custom/deploy/f5b5219cce4a7d47a60416ef4d3fa891",
|
||||||
|
"key": "bNJXlzwc"
|
||||||
|
},
|
||||||
|
|
||||||
|
"policyUrl": "kct/static/policy",
|
||||||
|
"goodsType":"member",
|
||||||
|
"ignoreCodeErrorList": ["GET&/api/weixin/qrcode","GET&/api/app/code", "GET&/api/order"],
|
||||||
|
"hideConsole": true,
|
||||||
|
"downloadSuccessCode":[200,201,202,203,204,205,206],
|
||||||
|
"configIgnoreParams": ["inputvalue"]
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,20 @@
|
||||||
|
import { useEffect } from "react";
|
||||||
|
import { useLocation } from "react-router-dom";
|
||||||
|
|
||||||
|
const useHashScroll = () => {
|
||||||
|
const location = useLocation();
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (location.hash) {
|
||||||
|
const element = document.querySelector(location.hash);
|
||||||
|
element?.scrollIntoView({ behavior: "smooth" });
|
||||||
|
} else {
|
||||||
|
window.scrollTo({
|
||||||
|
top: 0,
|
||||||
|
behavior: "smooth",
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}, [location]);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default useHashScroll;
|
||||||
|
|
@ -0,0 +1,18 @@
|
||||||
|
body {
|
||||||
|
margin: 0;
|
||||||
|
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen',
|
||||||
|
'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue',
|
||||||
|
sans-serif;
|
||||||
|
-webkit-font-smoothing: antialiased;
|
||||||
|
-moz-osx-font-smoothing: grayscale;
|
||||||
|
}
|
||||||
|
|
||||||
|
code {
|
||||||
|
font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New',
|
||||||
|
monospace;
|
||||||
|
}
|
||||||
|
|
||||||
|
@font-face {
|
||||||
|
font-family: 'Alimama ShuHeiTi';
|
||||||
|
src: url('https://cdn.batiao8.com/static/ttf/%E9%98%BF%E9%87%8C%E5%A6%88%E5%A6%88%E6%95%B0%E9%BB%91%E4%BD%93.ttf');
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,19 @@
|
||||||
|
import React from 'react';
|
||||||
|
import ReactDOM from 'react-dom/client';
|
||||||
|
import './index.css';
|
||||||
|
import App from './App';
|
||||||
|
import reportWebVitals from './reportWebVitals';
|
||||||
|
|
||||||
|
const root = ReactDOM.createRoot(
|
||||||
|
document.getElementById('root') as HTMLElement
|
||||||
|
);
|
||||||
|
root.render(
|
||||||
|
<React.StrictMode>
|
||||||
|
<App />
|
||||||
|
</React.StrictMode>
|
||||||
|
);
|
||||||
|
|
||||||
|
// If you want to start measuring performance in your app, pass a function
|
||||||
|
// to log results (for example: reportWebVitals(console.log))
|
||||||
|
// or send to an analytics endpoint. Learn more: https://bit.ly/CRA-vitals
|
||||||
|
reportWebVitals();
|
||||||
|
|
@ -0,0 +1,102 @@
|
||||||
|
.footer {
|
||||||
|
background: #fff;
|
||||||
|
color: #333;
|
||||||
|
}
|
||||||
|
|
||||||
|
.footerUpper {
|
||||||
|
padding: 60px;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
.footerGrid {
|
||||||
|
display: grid;
|
||||||
|
grid-template-columns: repeat(7, 1fr) auto;
|
||||||
|
gap: 24px;
|
||||||
|
align-items: start;
|
||||||
|
}
|
||||||
|
|
||||||
|
.footerColumn {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 12px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.footerTitle {
|
||||||
|
font-size: 14px;
|
||||||
|
font-weight: 600;
|
||||||
|
color: #333;
|
||||||
|
margin-bottom: 4px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.footerLink {
|
||||||
|
font-size: 13px;
|
||||||
|
color: #666;
|
||||||
|
text-decoration: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.footerLink:hover {
|
||||||
|
color: #0f192d;
|
||||||
|
}
|
||||||
|
|
||||||
|
.footerRight {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: row;
|
||||||
|
align-items: center;
|
||||||
|
gap: 16px;
|
||||||
|
position: absolute;
|
||||||
|
right: 60px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.footerLogo {
|
||||||
|
font-size: 20px;
|
||||||
|
font-weight: 600;
|
||||||
|
color: #999;
|
||||||
|
}
|
||||||
|
|
||||||
|
.socialIcons {
|
||||||
|
display: flex;
|
||||||
|
gap: 12px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.socialIcon {
|
||||||
|
width: 28px;
|
||||||
|
height: 28px;
|
||||||
|
border-radius: 50%;
|
||||||
|
background: #ddd;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
color: #666;
|
||||||
|
text-decoration: none;
|
||||||
|
font-size: 12px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.footerLower {
|
||||||
|
background: #031229;
|
||||||
|
color: #fff;
|
||||||
|
height: 60px;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.footerLowerInner {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: space-between;
|
||||||
|
font-size: 14px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.footerLowerLinks {
|
||||||
|
display: flex;
|
||||||
|
gap: 20px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.footerLowerLink {
|
||||||
|
color: rgba(255, 255, 255, 0.9);
|
||||||
|
text-decoration: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.footerLowerLink:hover {
|
||||||
|
color: #fff;
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,112 @@
|
||||||
|
import { Link } from "react-router-dom";
|
||||||
|
import styles from "./Footer.module.css";
|
||||||
|
|
||||||
|
const footerColumns = [
|
||||||
|
{
|
||||||
|
title: "关于银泰",
|
||||||
|
links: [
|
||||||
|
{ path: "/about", label: "公司简介" },
|
||||||
|
{ path: "/about/history", label: "发展历程" },
|
||||||
|
{ path: "/about/culture", label: "企业文化" },
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: "集团业务",
|
||||||
|
links: [
|
||||||
|
{ path: "/about", label: "银泰商业集团" },
|
||||||
|
{ path: "/business/base-group", label: "银泰基业集团" },
|
||||||
|
{ path: "/business/realty-group", label: "银泰置地集团" },
|
||||||
|
{ path: "/business/invest-group", label: "银泰投资集团" },
|
||||||
|
{ path: "/business/ruijing-group", label: "瑞京集团" },
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: "社会责任",
|
||||||
|
links: [
|
||||||
|
{ path: "/social", label: "可持续发展" },
|
||||||
|
{ path: "/social/sustainable", label: "银泰公益基金会" },
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: "新闻中心",
|
||||||
|
links: [
|
||||||
|
{ path: "/news", label: "银泰咨询" },
|
||||||
|
{ path: "/news/media", label: "媒体垂询" },
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: "加入我们",
|
||||||
|
links: [
|
||||||
|
{ path: "/join", label: "企业文化" },
|
||||||
|
{ path: "/join/campus", label: "招贤纳士" },
|
||||||
|
],
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
|
export default function Footer() {
|
||||||
|
return (
|
||||||
|
<footer className={`layout-footer ${styles.footer}`}>
|
||||||
|
<div className={styles.footerUpper}>
|
||||||
|
<div>
|
||||||
|
<div className={styles.footerGrid}>
|
||||||
|
{footerColumns.map((col) => (
|
||||||
|
<div key={col.title} className={styles.footerColumn}>
|
||||||
|
<div className={styles.footerTitle}>{col.title}</div>
|
||||||
|
{col.links.map((link) => (
|
||||||
|
<Link
|
||||||
|
key={link.path}
|
||||||
|
to={link.path}
|
||||||
|
className={styles.footerLink}
|
||||||
|
>
|
||||||
|
{link.label}
|
||||||
|
</Link>
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
))}
|
||||||
|
<div className={styles.footerRight}>
|
||||||
|
<img src="/images/icon-weixin.png" alt="weixin" style={{ width: "26px", height: "26px" }} />
|
||||||
|
<img src="/images/icon-weibo.png" alt="weibo" style={{ width: "26px", height: "26px" }} />
|
||||||
|
<img src="/images/logo.png" alt="logo" style={{ width: "92px", height: "56px", background: '#000' }} />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<FooterLower />
|
||||||
|
</footer>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function FooterLower() {
|
||||||
|
const footerLowerLinks = [
|
||||||
|
{ path: "/contact-us", label: "联系我们" },
|
||||||
|
{ path: "/site-map", label: "网站地图" },
|
||||||
|
{ path: "/terms-of-use", label: "使用条款" },
|
||||||
|
{ path: "/privacy-policy", label: "隐私保护" },
|
||||||
|
{ path: "/audit-report", label: "审计举报" },
|
||||||
|
]
|
||||||
|
return (
|
||||||
|
<div className={styles.footerLower}>
|
||||||
|
<div className={`header-row ${styles.footerLowerInner}`}>
|
||||||
|
<div style={{ display: 'flex', flexDirection: 'row', gap: '50px' }}>
|
||||||
|
<span>版权声明©2001-{new Date().getFullYear()} | 中国银泰投资有限公司</span>
|
||||||
|
<span>京ICP备05026114号-1</span>
|
||||||
|
</div>
|
||||||
|
<div className={styles.footerLowerLinks}>
|
||||||
|
{footerLowerLinks.map((link, index) => (
|
||||||
|
<>
|
||||||
|
<Link key={link.path} to={link.path} className={styles.footerLowerLink}>
|
||||||
|
{link.label}
|
||||||
|
</Link>
|
||||||
|
{
|
||||||
|
index !== footerLowerLinks.length - 1 && (
|
||||||
|
<span>·</span>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
</>
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,143 @@
|
||||||
|
.header {
|
||||||
|
position: fixed;
|
||||||
|
top: 0;
|
||||||
|
left: 0;
|
||||||
|
z-index: 1000;
|
||||||
|
height: 120px;
|
||||||
|
width: 100%;
|
||||||
|
|
||||||
|
font-family: Source Han Sans, Source Han Sans;
|
||||||
|
font-weight: 700;
|
||||||
|
font-size: 18px;
|
||||||
|
line-height: 26px;
|
||||||
|
text-align: left;
|
||||||
|
font-style: normal;
|
||||||
|
text-transform: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.hoverMenu.header {
|
||||||
|
background: #fff;
|
||||||
|
box-shadow: 0 0 10px 0 rgba(255, 255, 255, 0.1);
|
||||||
|
}
|
||||||
|
.hoverMenu .navLink {
|
||||||
|
color: #222222;
|
||||||
|
}
|
||||||
|
|
||||||
|
.activeNav .navLink {
|
||||||
|
color: #14355C;
|
||||||
|
}
|
||||||
|
|
||||||
|
.headerInner {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: space-between;
|
||||||
|
height: 100%;
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
.headerInner::after {
|
||||||
|
position: absolute;
|
||||||
|
bottom: 0;
|
||||||
|
left: 60px;
|
||||||
|
content: '';
|
||||||
|
display: block;
|
||||||
|
width: calc(100% - 120px);
|
||||||
|
box-sizing: border-box;
|
||||||
|
height: 1px;
|
||||||
|
background: #FFFFFF;
|
||||||
|
}
|
||||||
|
|
||||||
|
.logo {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
font-weight: 600;
|
||||||
|
line-height: 1.3;
|
||||||
|
}
|
||||||
|
|
||||||
|
.headerRight {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 30px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.nav {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 0;
|
||||||
|
list-style: none;
|
||||||
|
margin: 0;
|
||||||
|
padding: 0;
|
||||||
|
margin-right: 30px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.navItem {
|
||||||
|
padding: 0 30px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.navLink {
|
||||||
|
color: #fff;
|
||||||
|
text-decoration: none;
|
||||||
|
white-space: nowrap;
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
.navLink:hover {
|
||||||
|
color: #14355C !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.navLink:hover {
|
||||||
|
opacity: 0.9;
|
||||||
|
}
|
||||||
|
|
||||||
|
.actions {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 16px;
|
||||||
|
margin-left: 30px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.langTrigger {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 4px;
|
||||||
|
color: #fff;
|
||||||
|
background: transparent;
|
||||||
|
border: none;
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
|
||||||
|
.searchBtn {
|
||||||
|
color: #fff;
|
||||||
|
background: transparent;
|
||||||
|
border: none;
|
||||||
|
cursor: pointer;
|
||||||
|
padding: 4px;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
.dropPanel {
|
||||||
|
position: absolute;
|
||||||
|
top: 100%;
|
||||||
|
left: 0;
|
||||||
|
width: 100%;
|
||||||
|
height: 380px;
|
||||||
|
background: rgba(255, 255, 255, 0.9);
|
||||||
|
box-shadow: 0 0 10px 0 rgba(0, 0, 0, 0.1);
|
||||||
|
padding: 20px;
|
||||||
|
z-index: 1000;
|
||||||
|
}
|
||||||
|
|
||||||
|
.dropPanelContent {
|
||||||
|
display: inline-flex;
|
||||||
|
flex-direction: column;
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.dropPanelLink {
|
||||||
|
font-weight: 400;
|
||||||
|
font-size: 18px;
|
||||||
|
line-height: 50px;
|
||||||
|
color: #222222;
|
||||||
|
text-decoration: none;
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,133 @@
|
||||||
|
import { Link } from "react-router-dom";
|
||||||
|
import { Dropdown } from "antd";
|
||||||
|
import styles from "./Header.module.css";
|
||||||
|
import { useMemo, useState } from "react";
|
||||||
|
|
||||||
|
type NavChild = { path: string; label: string };
|
||||||
|
type NavItem = { path: string; label: string; children?: NavChild[] };
|
||||||
|
|
||||||
|
export default function Header() {
|
||||||
|
const navItems: NavItem[] = [
|
||||||
|
{
|
||||||
|
label: "关于银泰",
|
||||||
|
path: "/about",
|
||||||
|
children: [
|
||||||
|
{ path: "/about", label: "集团概览" },
|
||||||
|
{ path: "/about/history", label: "发展历程" },
|
||||||
|
{ path: "/about/founder", label: "创始人介绍" },
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: "集团业务",
|
||||||
|
path: "/business",
|
||||||
|
children: [
|
||||||
|
{ path: "/business/commercial-group", label: "银泰商业集团" },
|
||||||
|
{ path: "/business/base-group", label: "银泰基业集团" },
|
||||||
|
{ path: "/business/realty-group", label: "银泰置地集团" },
|
||||||
|
{ path: "/business/invest-group", label: "银泰投资集团" },
|
||||||
|
{ path: "/business/ruijing-group", label: "瑞京集团" },
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: "社会责任",
|
||||||
|
path: "/social",
|
||||||
|
children: [
|
||||||
|
{ path: "/social/sustainability", label: "可持续发展" },
|
||||||
|
{ path: "/social/foundation", label: "银泰公益基金会" },
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: "新闻中心",
|
||||||
|
path: "/news",
|
||||||
|
children: [
|
||||||
|
{ path: "/news/consult", label: "银泰咨询" },
|
||||||
|
{ path: "/news/media", label: "媒体垂询" },
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: "加入银泰",
|
||||||
|
path: "/join",
|
||||||
|
children: [
|
||||||
|
{ path: "/join/culture", label: "企业文化" },
|
||||||
|
{ path: "/join/campus", label: "招贤纳士" },
|
||||||
|
],
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
|
const langMenuItems = [
|
||||||
|
{ key: "zh", label: "中文" },
|
||||||
|
{ key: "en", label: "English" },
|
||||||
|
];
|
||||||
|
|
||||||
|
const [activeNav, setActiveNav] = useState("");
|
||||||
|
const [showDropPanel, setShowDropPanel] = useState(false);
|
||||||
|
const [hoverElLeft, setHoverElLeft] = useState(0);
|
||||||
|
const handleNavEnter = (e: any, path: string) => {
|
||||||
|
console.log(e,e.target.offsetWidth)
|
||||||
|
// left + 元素宽度的一半
|
||||||
|
const left = e.target.offsetLeft;
|
||||||
|
setHoverElLeft(left);
|
||||||
|
setActiveNav(path);
|
||||||
|
setShowDropPanel(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
const activePanelItem = useMemo(() => {
|
||||||
|
return navItems.find((item) => item.path === activeNav)?.children || [];
|
||||||
|
}, [activeNav]);
|
||||||
|
return (
|
||||||
|
<header className={`${styles.header} ${showDropPanel ? styles.hoverMenu : ""}`}
|
||||||
|
onMouseLeave={() => setShowDropPanel(false)}
|
||||||
|
>
|
||||||
|
<div className={`header-row ${styles.headerInner}`}>
|
||||||
|
<Link to="/" className={styles.logo}>
|
||||||
|
<img src="/images/logo.png" alt="logo" style={{ width: "92px", height: "55px" }} />
|
||||||
|
</Link>
|
||||||
|
<div className={styles.headerRight}>
|
||||||
|
<nav>
|
||||||
|
<ul className={styles.nav}>
|
||||||
|
{navItems.map((item) => (
|
||||||
|
<li key={item.path} className={styles.navItem} >
|
||||||
|
<div className={styles.navLink} onMouseEnter={(e) => handleNavEnter(e, item.path)}>
|
||||||
|
{item.label}
|
||||||
|
</div>
|
||||||
|
</li>
|
||||||
|
))}
|
||||||
|
</ul>
|
||||||
|
</nav>
|
||||||
|
<div className={styles.actions}>
|
||||||
|
<button className={styles.searchBtn} type="button" aria-label="搜索">
|
||||||
|
<svg xmlns="http://www.w3.org/2000/svg" fill="none" version="1.1" width="26" height="26" viewBox="0 0 26 26"><g><path d="M16.739973374999998,17.76985499081421C15.429279375,18.85114099081421,13.749150275,19.50064899081421,11.917317875,19.50064899081421C7.729150975,19.50064899081421,4.333984375,16.105480990814208,4.333984375,11.91731549081421C4.333984375,7.729148590814209,7.729150975,4.333981990814209,11.917317875,4.333981990814209C16.105485375,4.333981990814209,19.500651375,7.729148590814209,19.500651375,11.91731549081421C19.500651375,13.80559489081421,18.810497375,15.532677990814209,17.668674375000002,16.86007799081421L21.741985375,20.93338899081421C21.953518375,21.144921990814208,21.953518375,21.48788599081421,21.741983375,21.69941999081421L21.588777375,21.852625990814207C21.377243375,22.06416099081421,21.034278375,22.06416099081421,20.822744375,21.852625990814207L16.739973374999998,17.76985499081421ZM18.199479375,11.916142890814209C18.199479375,15.38633899081421,15.386343375,18.199475990814207,11.916145775,18.199475990814207C8.445947675,18.199475990814207,5.632812475,15.38633899081421,5.632812475,11.916142890814209C5.632812475,8.44594479081421,8.445947675,5.632810090814209,11.916145775,5.632810090814209C15.386343375,5.632810090814209,18.199479375,8.44594479081421,18.199479375,11.916142890814209Z" fillRule="evenodd" fill="#FFFFFF" fillOpacity="1" /></g></svg>
|
||||||
|
</button>
|
||||||
|
<Dropdown
|
||||||
|
menu={{ items: langMenuItems }}
|
||||||
|
placement="bottomRight"
|
||||||
|
trigger={["click"]}
|
||||||
|
>
|
||||||
|
<button className={styles.langTrigger} type="button">
|
||||||
|
中文
|
||||||
|
<svg xmlns="http://www.w3.org/2000/svg" fill="none" version="1.1" width="24" height="24" viewBox="0 0 24 24"><g transform="matrix(0,1,-1,0,24,-24)"><path d="M46.720364062499996,30.4020875C46.720364062499996,30.4020875,45.6597041625,31.462787499999997,45.6597041625,31.462787499999997C45.6597041625,31.462787499999997,39.8815300725,25.6845775,39.8815300725,25.6845775C39.4910054655,25.2940474,39.4910053615,24.6608877,39.8815300725,24.2703576C39.8815300725,24.2703576,45.6597041625,18.4921875,45.6597041625,18.4921875C45.6597041625,18.4921875,46.720364062499996,19.5528475,46.720364062499996,19.5528475C46.720364062499996,19.5528475,41.2957440625,24.9774675,41.2957440625,24.9774675C41.2957440625,24.9774675,46.720364062499996,30.4020875,46.720364062499996,30.4020875C46.720364062499996,30.4020875,46.720364062499996,30.4020875,46.720364062499996,30.4020875Z" fillRule="evenodd" fill="#FFFFFF" fillOpacity="1" transform="matrix(-1,0,0,-1,79.173828125,36.984375)" /></g></svg>
|
||||||
|
</button>
|
||||||
|
</Dropdown>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{showDropPanel && activePanelItem.length > 0 && <DropPanel items={activePanelItem} left={hoverElLeft} />}
|
||||||
|
</header>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
function DropPanel({ items, left }: { items: NavChild[]; left: number }) {
|
||||||
|
return (
|
||||||
|
<div id="drop-panel" className={styles.dropPanel} style={{paddingLeft: left}}>
|
||||||
|
<div className={styles.dropPanelContent}>
|
||||||
|
{items.map((item) => (
|
||||||
|
<div key={item.path} className={styles.dropPanelItem}>
|
||||||
|
<Link to={item.path} className={styles.dropPanelLink}>
|
||||||
|
{item.label}
|
||||||
|
</Link>
|
||||||
|
</div>
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,15 @@
|
||||||
|
import { Outlet } from "react-router-dom";
|
||||||
|
import Header from "./Header";
|
||||||
|
import Footer from "./Footer";
|
||||||
|
|
||||||
|
export default function MainLayout() {
|
||||||
|
return (
|
||||||
|
<div className="layout">
|
||||||
|
<Header />
|
||||||
|
<main className="container">
|
||||||
|
<Outlet />
|
||||||
|
</main>
|
||||||
|
<Footer />
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1 @@
|
||||||
|
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 841.9 595.3"><g fill="#61DAFB"><path d="M666.3 296.5c0-32.5-40.7-63.3-103.1-82.4 14.4-63.6 8-114.2-20.2-130.4-6.5-3.8-14.1-5.6-22.4-5.6v22.3c4.6 0 8.3.9 11.4 2.6 13.6 7.8 19.5 37.5 14.9 75.7-1.1 9.4-2.9 19.3-5.1 29.4-19.6-4.8-41-8.5-63.5-10.9-13.5-18.5-27.5-35.3-41.6-50 32.6-30.3 63.2-46.9 84-46.9V78c-27.5 0-63.5 19.6-99.9 53.6-36.4-33.8-72.4-53.2-99.9-53.2v22.3c20.7 0 51.4 16.5 84 46.6-14 14.7-28 31.4-41.3 49.9-22.6 2.4-44 6.1-63.6 11-2.3-10-4-19.7-5.2-29-4.7-38.2 1.1-67.9 14.6-75.8 3-1.8 6.9-2.6 11.5-2.6V78.5c-8.4 0-16 1.8-22.6 5.6-28.1 16.2-34.4 66.7-19.9 130.1-62.2 19.2-102.7 49.9-102.7 82.3 0 32.5 40.7 63.3 103.1 82.4-14.4 63.6-8 114.2 20.2 130.4 6.5 3.8 14.1 5.6 22.5 5.6 27.5 0 63.5-19.6 99.9-53.6 36.4 33.8 72.4 53.2 99.9 53.2 8.4 0 16-1.8 22.6-5.6 28.1-16.2 34.4-66.7 19.9-130.1 62-19.1 102.5-49.9 102.5-82.3zm-130.2-66.7c-3.7 12.9-8.3 26.2-13.5 39.5-4.1-8-8.4-16-13.1-24-4.6-8-9.5-15.8-14.4-23.4 14.2 2.1 27.9 4.7 41 7.9zm-45.8 106.5c-7.8 13.5-15.8 26.3-24.1 38.2-14.9 1.3-30 2-45.2 2-15.1 0-30.2-.7-45-1.9-8.3-11.9-16.4-24.6-24.2-38-7.6-13.1-14.5-26.4-20.8-39.8 6.2-13.4 13.2-26.8 20.7-39.9 7.8-13.5 15.8-26.3 24.1-38.2 14.9-1.3 30-2 45.2-2 15.1 0 30.2.7 45 1.9 8.3 11.9 16.4 24.6 24.2 38 7.6 13.1 14.5 26.4 20.8 39.8-6.3 13.4-13.2 26.8-20.7 39.9zm32.3-13c5.4 13.4 10 26.8 13.8 39.8-13.1 3.2-26.9 5.9-41.2 8 4.9-7.7 9.8-15.6 14.4-23.7 4.6-8 8.9-16.1 13-24.1zM421.2 430c-9.3-9.6-18.6-20.3-27.8-32 9 .4 18.2.7 27.5.7 9.4 0 18.7-.2 27.8-.7-9 11.7-18.3 22.4-27.5 32zm-74.4-58.9c-14.2-2.1-27.9-4.7-41-7.9 3.7-12.9 8.3-26.2 13.5-39.5 4.1 8 8.4 16 13.1 24 4.7 8 9.5 15.8 14.4 23.4zM420.7 163c9.3 9.6 18.6 20.3 27.8 32-9-.4-18.2-.7-27.5-.7-9.4 0-18.7.2-27.8.7 9-11.7 18.3-22.4 27.5-32zm-74 58.9c-4.9 7.7-9.8 15.6-14.4 23.7-4.6 8-8.9 16-13 24-5.4-13.4-10-26.8-13.8-39.8 13.1-3.1 26.9-5.8 41.2-7.9zm-90.5 125.2c-35.4-15.1-58.3-34.9-58.3-50.6 0-15.7 22.9-35.6 58.3-50.6 8.6-3.7 18-7 27.7-10.1 5.7 19.6 13.2 40 22.5 60.9-9.2 20.8-16.6 41.1-22.2 60.6-9.9-3.1-19.3-6.5-28-10.2zM310 490c-13.6-7.8-19.5-37.5-14.9-75.7 1.1-9.4 2.9-19.3 5.1-29.4 19.6 4.8 41 8.5 63.5 10.9 13.5 18.5 27.5 35.3 41.6 50-32.6 30.3-63.2 46.9-84 46.9-4.5-.1-8.3-1-11.3-2.7zm237.2-76.2c4.7 38.2-1.1 67.9-14.6 75.8-3 1.8-6.9 2.6-11.5 2.6-20.7 0-51.4-16.5-84-46.6 14-14.7 28-31.4 41.3-49.9 22.6-2.4 44-6.1 63.6-11 2.3 10.1 4.1 19.8 5.2 29.1zm38.5-66.7c-8.6 3.7-18 7-27.7 10.1-5.7-19.6-13.2-40-22.5-60.9 9.2-20.8 16.6-41.1 22.2-60.6 9.9 3.1 19.3 6.5 28.1 10.2 35.4 15.1 58.3 34.9 58.3 50.6-.1 15.7-23 35.6-58.4 50.6zM320.8 78.4z"/><circle cx="420.9" cy="296.5" r="45.7"/><path d="M520.5 78.1z"/></g></svg>
|
||||||
|
After Width: | Height: | Size: 2.6 KiB |
|
|
@ -0,0 +1,75 @@
|
||||||
|
/* Section block - full-width with background */
|
||||||
|
.section {
|
||||||
|
position: relative;
|
||||||
|
min-height: 100vh;
|
||||||
|
background-size: cover;
|
||||||
|
background-position: center;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: flex-start;
|
||||||
|
}
|
||||||
|
|
||||||
|
.sectionRight {
|
||||||
|
justify-content: flex-end;
|
||||||
|
}
|
||||||
|
|
||||||
|
.overlay {
|
||||||
|
position: absolute;
|
||||||
|
inset: 0;
|
||||||
|
background: linear-gradient(
|
||||||
|
to right,
|
||||||
|
rgba(0, 0, 0, 0.5) 0%,
|
||||||
|
rgba(0, 0, 0, 0.25) 50%,
|
||||||
|
rgba(0, 0, 0, 0.1) 100%
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
.content {
|
||||||
|
position: relative;
|
||||||
|
z-index: 1;
|
||||||
|
margin: 0 5%;
|
||||||
|
max-width: 560px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.contentRight {
|
||||||
|
margin-left: auto;
|
||||||
|
margin-right: 10%;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Dark blue semi-transparent text box */
|
||||||
|
.textBox {
|
||||||
|
background: rgba(20,53,92,0.5);
|
||||||
|
padding: 40px;
|
||||||
|
border-radius: 4px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.title {
|
||||||
|
font-size: 40px;
|
||||||
|
font-weight: 700;
|
||||||
|
color: #fff;
|
||||||
|
margin: 0 0 30px;
|
||||||
|
letter-spacing: 0.05em;
|
||||||
|
}
|
||||||
|
|
||||||
|
.desc {
|
||||||
|
font-size: 18px;
|
||||||
|
line-height: 1.8;
|
||||||
|
color: rgba(255, 255, 255, 0.95);
|
||||||
|
margin: 0 0 60px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.links {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: row;
|
||||||
|
flex-wrap: wrap;
|
||||||
|
align-items: center;
|
||||||
|
gap: 0 40px;
|
||||||
|
color: #fff;
|
||||||
|
font-size: 16px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.links a {
|
||||||
|
color: #fff;
|
||||||
|
text-decoration: underline;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
@ -0,0 +1,116 @@
|
||||||
|
.section {
|
||||||
|
background: rgba(255,255,255,0.6);
|
||||||
|
border-radius: 0px 0px 0px 0px;
|
||||||
|
min-height: 100vh;
|
||||||
|
width: 100%;
|
||||||
|
padding: 100px 15.6%;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
}
|
||||||
|
|
||||||
|
.content p {
|
||||||
|
font-size: 18px;
|
||||||
|
line-height: 1.5;
|
||||||
|
color: #333;
|
||||||
|
margin: 0 0 24px;
|
||||||
|
letter-spacing: 0.05em;
|
||||||
|
}
|
||||||
|
|
||||||
|
.images {
|
||||||
|
display: flex;
|
||||||
|
gap: 40px;
|
||||||
|
margin-top: 100px;
|
||||||
|
}
|
||||||
|
.images img{
|
||||||
|
width: 100%;
|
||||||
|
aspect-ratio: 680 / 800;
|
||||||
|
background: rgba(0,0,0,0.3);
|
||||||
|
}
|
||||||
|
|
||||||
|
.images .imageItem {
|
||||||
|
position: relative;
|
||||||
|
overflow: hidden;
|
||||||
|
}
|
||||||
|
.images .imageItem:hover .imageOverlay {
|
||||||
|
top: 0;
|
||||||
|
}
|
||||||
|
.images .imageMask {
|
||||||
|
position: absolute;
|
||||||
|
bottom: 0;
|
||||||
|
left: 0;
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
background: rgba(0,0,0,0.3);
|
||||||
|
}
|
||||||
|
.images .imageOverlay {
|
||||||
|
position: absolute;
|
||||||
|
top: 74%;
|
||||||
|
left: 0;
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
color: #fff;
|
||||||
|
padding: 60px 40px;
|
||||||
|
background: rgba(20,53,92,0.8);
|
||||||
|
transition: top 0.3s ease-in-out;
|
||||||
|
}
|
||||||
|
.images .imageOverlayTitle {
|
||||||
|
font-size: 24px;
|
||||||
|
font-weight: 500;
|
||||||
|
height: 70px;
|
||||||
|
color: #fff;
|
||||||
|
text-align: center;
|
||||||
|
border-bottom: 1px solid rgba(255,255,255,0.3);
|
||||||
|
}
|
||||||
|
.images .imageOverlayTitle span {
|
||||||
|
display: inline-block;
|
||||||
|
height: 71px;
|
||||||
|
border-bottom: 3px solid #FFFFFF;
|
||||||
|
}
|
||||||
|
.images .imageOverlayDesc {
|
||||||
|
font-size: 16px;
|
||||||
|
color: #fff;
|
||||||
|
margin-top: 50px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.sectionFounder{
|
||||||
|
padding: 100px 0 150px;
|
||||||
|
min-height: 100vh;
|
||||||
|
}
|
||||||
|
.founderIntroduction h2 {
|
||||||
|
font-size: 40px;
|
||||||
|
font-weight: 700;
|
||||||
|
color: #222;
|
||||||
|
margin-bottom: 50px;
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
.founderIntroduction p {
|
||||||
|
font-size: 18px;
|
||||||
|
line-height: 1.5;
|
||||||
|
color: #222;
|
||||||
|
margin: 0 0 24px;
|
||||||
|
letter-spacing: 0.05em;
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
.founderPhoto{
|
||||||
|
display: grid;
|
||||||
|
grid-template-columns: 1fr 1fr;
|
||||||
|
gap: 100px;
|
||||||
|
margin-top: 100px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.founderPhoto img{
|
||||||
|
flex: 1;
|
||||||
|
width: 100%;
|
||||||
|
aspect-ratio: 680 / 800;
|
||||||
|
}
|
||||||
|
.founderPhotoContent{
|
||||||
|
padding-top: 100px;
|
||||||
|
padding-right: 100px;
|
||||||
|
}
|
||||||
|
.founderPhotoContent p {
|
||||||
|
font-size: 16px;
|
||||||
|
line-height: 1.5;
|
||||||
|
color: #222;
|
||||||
|
margin: 0 0 24px;
|
||||||
|
letter-spacing: 0.05em;
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,65 @@
|
||||||
|
import Banner from "@/components/banner";
|
||||||
|
import styles from "./Founder.module.css";
|
||||||
|
import { useState } from "react";
|
||||||
|
|
||||||
|
export default function AboutFounder() {
|
||||||
|
const intoductionList = [
|
||||||
|
{
|
||||||
|
title: "商业领域",
|
||||||
|
image: "/images/bg-invest-group.png",
|
||||||
|
desc: "银泰集团在商业领域有着丰富的经验和深厚的实力,致力于打造高品质的商业空间,引领现代消费体验。",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: "社会责任",
|
||||||
|
image: "/images/bg-invest-group.png",
|
||||||
|
desc: "银泰集团在社会责任方面有着丰富的经验和深厚的实力,致力于打造高品质的商业空间,引领现代消费体验。",
|
||||||
|
},
|
||||||
|
]
|
||||||
|
const [activeIndex, setActiveIndex] = useState<number | null>(null);
|
||||||
|
const handleMouseEnter = (index: number) => {
|
||||||
|
setActiveIndex(index);
|
||||||
|
}
|
||||||
|
return (
|
||||||
|
<div>
|
||||||
|
<Banner title="创始人介绍" subtitle="银泰集团创始人、董事长——沈国军"
|
||||||
|
desc="卓越的变革践行者、产业推动者及社会公民"
|
||||||
|
showBreadcrumb={true} backgroundImage={'/images/bg-overview.png'}></Banner>
|
||||||
|
|
||||||
|
<section className={styles.section}>
|
||||||
|
<div className={styles.content}>
|
||||||
|
<span>沈国军</span>
|
||||||
|
<p>汉族,博士,高级经济师。中国人民政治协商会议第十一届、十三届全国委员会委员、中国人民政治协商会议第十三届全国委员会提案委员会委员、中国致公党第十四届、十五届、十六届中央委员会常委、第一届浙商(全球)总会执行会长、第一届甬商(全球)总会会长。</p>
|
||||||
|
<p>银泰集团(全称“中国银泰投资有限公司”)创始人兼董事长、银泰公益基金会创始人及荣誉理事长、桃花源生态保护基金会董事局执行主席。</p>
|
||||||
|
</div>
|
||||||
|
<div className={styles.images}>
|
||||||
|
{intoductionList.map((item, index) => (
|
||||||
|
<div className={styles.imageItem} key={item.title}>
|
||||||
|
<img src={item.image} alt={item.title} />
|
||||||
|
<div className={styles.imageMask}></div>
|
||||||
|
<div className={styles.imageOverlay}>
|
||||||
|
<div className={styles.imageOverlayTitle}>
|
||||||
|
<span>{item.title}</span>
|
||||||
|
</div>
|
||||||
|
<div className={styles.imageOverlayDesc}>{item.desc}</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
</section>
|
||||||
|
|
||||||
|
<section className={styles.sectionFounder}>
|
||||||
|
<div className={styles.founderIntroduction}>
|
||||||
|
<h2>企业家精神</h2>
|
||||||
|
<p>一个优秀的企业家,要传承、弘扬传统优秀的商道,继续开创新的商业文明。创新与变革、勤奋与进取、分享与合作、诚信与责任是沈国军所倡导的企业家精神。</p>
|
||||||
|
</div>
|
||||||
|
<div className={styles.founderPhoto}>
|
||||||
|
<img src="/images/bg-invest-group.png" alt="个人照" />
|
||||||
|
<div className={styles.founderPhotoContent}>
|
||||||
|
<p style={{color: '#14355C'}}>· 关于创新与变革</p>
|
||||||
|
<p>“每个人心中都是卧虎藏龙的,释放你心中的龙和虎,到市场上去捕食,让这个社会、这个市场有更多的创新和变革,这样才能带来进步。”</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</section>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,149 @@
|
||||||
|
.section {
|
||||||
|
background: #e8eaed;
|
||||||
|
background-image: repeating-linear-gradient(
|
||||||
|
90deg,
|
||||||
|
transparent,
|
||||||
|
transparent 2px,
|
||||||
|
rgba(200, 200, 205, 0.3) 2px,
|
||||||
|
rgba(200, 200, 205, 0.3) 4px
|
||||||
|
);
|
||||||
|
min-height: 100vh;
|
||||||
|
width: 100%;
|
||||||
|
padding: 100px 300px;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
}
|
||||||
|
|
||||||
|
.headRow {
|
||||||
|
width: 100%;
|
||||||
|
display: flex;
|
||||||
|
justify-content: flex-end;
|
||||||
|
margin-bottom: 100px;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Timeline */
|
||||||
|
.timelineWrapper {
|
||||||
|
position: relative;
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.timelineLine {
|
||||||
|
position: absolute;
|
||||||
|
left: 50%;
|
||||||
|
top: 0;
|
||||||
|
bottom: 0;
|
||||||
|
width: 2px;
|
||||||
|
background: #828F9E;
|
||||||
|
transform: translateX(-50%);
|
||||||
|
}
|
||||||
|
|
||||||
|
.timelineContent {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.timelineItem {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: row;
|
||||||
|
align-items: flex-start;
|
||||||
|
min-height: 96px;
|
||||||
|
margin-bottom: 16px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.timelineItem .side {
|
||||||
|
flex: 1;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 8px;
|
||||||
|
padding: 8px 24px;
|
||||||
|
min-width: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.timelineItem.left .side:first-child {
|
||||||
|
text-align: right;
|
||||||
|
align-items: flex-end;
|
||||||
|
}
|
||||||
|
|
||||||
|
.timelineItem.right .side:last-child {
|
||||||
|
text-align: left;
|
||||||
|
align-items: flex-start;
|
||||||
|
}
|
||||||
|
|
||||||
|
.timelineItem .side:empty {
|
||||||
|
min-height: 1px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.year {
|
||||||
|
font-size: 40px;
|
||||||
|
color: #222;
|
||||||
|
line-height: 1.2;
|
||||||
|
}
|
||||||
|
|
||||||
|
.desc {
|
||||||
|
font-size: 20px;
|
||||||
|
line-height: 1.6;
|
||||||
|
color: #333;
|
||||||
|
margin: 0;
|
||||||
|
max-width: 540px;
|
||||||
|
margin-top: 30px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.timelineItem.left .desc {
|
||||||
|
text-align: right;
|
||||||
|
}
|
||||||
|
|
||||||
|
.dotWrapper {
|
||||||
|
position: relative;
|
||||||
|
flex-shrink: 0;
|
||||||
|
width: 60px;
|
||||||
|
height: 60px;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
z-index: 1;
|
||||||
|
background: #E8F3FF;
|
||||||
|
border-radius: 50%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.dot {
|
||||||
|
width: 20px;
|
||||||
|
height: 20px;
|
||||||
|
border-radius: 50%;
|
||||||
|
background: #3875FF;
|
||||||
|
}
|
||||||
|
|
||||||
|
.dotWrapper.selected {
|
||||||
|
width: 60px;
|
||||||
|
height: 60px;
|
||||||
|
background: #e8eaed;
|
||||||
|
}
|
||||||
|
|
||||||
|
.dotWrapper.selected .dot {
|
||||||
|
width: 20px;
|
||||||
|
height: 20px;
|
||||||
|
background: #14355C;
|
||||||
|
}
|
||||||
|
|
||||||
|
.dotWrapper.selected::before {
|
||||||
|
content: "";
|
||||||
|
position: absolute;
|
||||||
|
left: 50%;
|
||||||
|
top: 50%;
|
||||||
|
transform: translate(-50%, -50%);
|
||||||
|
width: 60px;
|
||||||
|
height: 60px;
|
||||||
|
border: 2px solid #14355C;
|
||||||
|
border-radius: 50%;
|
||||||
|
background: transparent;
|
||||||
|
}
|
||||||
|
|
||||||
|
.dotLine {
|
||||||
|
position: absolute;
|
||||||
|
left: 50%;
|
||||||
|
top: 100%;
|
||||||
|
transform: translateX(-50%);
|
||||||
|
width: 6px;
|
||||||
|
min-height: 0;
|
||||||
|
background: #14355C;
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,133 @@
|
||||||
|
import Banner from "@/components/banner";
|
||||||
|
import YearPicker from "@/components/YearPicker";
|
||||||
|
import styles from "./History.module.css";
|
||||||
|
import { useState, useRef, useLayoutEffect } from "react";
|
||||||
|
|
||||||
|
type TimelineItem = { year: number; description: string };
|
||||||
|
|
||||||
|
const TIMELINE_DATA: TimelineItem[] = [
|
||||||
|
{ year: 2025, description: "银泰集团持续深化战略布局,推动高质量发展。" },
|
||||||
|
{ year: 2024, description: "银泰集团创新发展模式,拓展业务新领域。" },
|
||||||
|
{ year: 2023, description: "银泰集团核心业务稳健增长,品牌影响力持续提升。" },
|
||||||
|
{ year: 2022, description: "银泰集团深化数字化转型,提升运营效率。" },
|
||||||
|
{ year: 2018, description: "银泰集团推进战略转型升级,开启新篇章。" },
|
||||||
|
{ year: 2016, description: "银泰集团拓展多元化业务,夯实发展基础。" },
|
||||||
|
{ year: 2015, description: "银泰集团完善产业布局,增强核心竞争力。" },
|
||||||
|
{ year: 2014, description: "银泰集团加速全国化扩张,品牌影响力扩大。" },
|
||||||
|
{ year: 2013, description: "银泰集团稳健发展,主营业务持续向好。" },
|
||||||
|
{ year: 2010, description: "银泰集团抓住市场机遇,实现跨越式发展。" },
|
||||||
|
{ year: 2009, description: "银泰集团应对金融危机,保持稳健经营。" },
|
||||||
|
{ year: 2008, description: "银泰集团完善管理体系,提升运营水平。" },
|
||||||
|
{ year: 2007, description: "银泰集团上市,开启资本化发展新征程。" },
|
||||||
|
{ year: 1998, description: "银泰集团快速成长,确立行业领先地位。" },
|
||||||
|
{ year: 1997, description: "银泰集团成立,迈出创业第一步。" },
|
||||||
|
];
|
||||||
|
|
||||||
|
export default function AboutHistory() {
|
||||||
|
const [year, setYear] = useState<number | null>(null);
|
||||||
|
|
||||||
|
const handleYearChange = (year: number | null) => {
|
||||||
|
setYear(year);
|
||||||
|
// 滚动到对应的年份
|
||||||
|
const yearEl = document.querySelector(`#year-${year}`);
|
||||||
|
if (yearEl) {
|
||||||
|
yearEl.scrollIntoView({ behavior: "smooth" });
|
||||||
|
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div>
|
||||||
|
<Banner title="发展历程" desc="银泰集团的发展历程" showBreadcrumb={true} backgroundImage={'/images/bg-overview.png'}></Banner>
|
||||||
|
|
||||||
|
<section className={styles.section}>
|
||||||
|
<div className={styles.headRow}>
|
||||||
|
<YearPicker placeholder="年份" value={year} onChange={handleYearChange} />
|
||||||
|
</div>
|
||||||
|
<HistoryTimeline data={TIMELINE_DATA} selectedYear={year} onYearChange={setYear} />
|
||||||
|
</section>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
type HistoryTimelineProps = {
|
||||||
|
data: TimelineItem[];
|
||||||
|
selectedYear: number | null;
|
||||||
|
onYearChange: (year: number | null) => void;
|
||||||
|
};
|
||||||
|
|
||||||
|
function TimelineItemRow({
|
||||||
|
item,
|
||||||
|
index,
|
||||||
|
isSelected,
|
||||||
|
onMouseEnter,
|
||||||
|
}: {
|
||||||
|
item: TimelineItem;
|
||||||
|
index: number;
|
||||||
|
isSelected: boolean;
|
||||||
|
onMouseEnter: () => void;
|
||||||
|
}) {
|
||||||
|
const isRight = index % 2 === 0;
|
||||||
|
const contentSideRef = useRef<HTMLDivElement>(null);
|
||||||
|
const dotLineRef = useRef<HTMLDivElement>(null);
|
||||||
|
|
||||||
|
useLayoutEffect(() => {
|
||||||
|
const contentEl = contentSideRef.current;
|
||||||
|
if (!contentEl) return;
|
||||||
|
const updateHeight = () => {
|
||||||
|
if (!contentSideRef.current || !dotLineRef.current || !isSelected) return;
|
||||||
|
dotLineRef.current.style.height = `${contentSideRef.current.offsetHeight}px`;
|
||||||
|
};
|
||||||
|
updateHeight();
|
||||||
|
const observer = new ResizeObserver(updateHeight);
|
||||||
|
observer.observe(contentEl);
|
||||||
|
return () => observer.disconnect();
|
||||||
|
}, [isSelected]);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div
|
||||||
|
className={`${styles.timelineItem} ${isRight ? styles.right : styles.left}`}
|
||||||
|
id={`year-${item.year}`}
|
||||||
|
>
|
||||||
|
<div ref={!isRight ? contentSideRef : undefined} className={styles.side}>
|
||||||
|
{!isRight && (
|
||||||
|
<div onMouseEnter={onMouseEnter}>
|
||||||
|
<span className={styles.year}>{item.year}</span>
|
||||||
|
<p className={styles.desc}>{item.description}</p>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
<div className={`${styles.dotWrapper} ${isSelected ? styles.selected : ""}`}>
|
||||||
|
<div className={styles.dot} />
|
||||||
|
{isSelected && <div ref={dotLineRef} className={styles.dotLine} />}
|
||||||
|
</div>
|
||||||
|
<div ref={isRight ? contentSideRef : undefined} className={styles.side}>
|
||||||
|
{isRight && (
|
||||||
|
<div onMouseEnter={onMouseEnter}>
|
||||||
|
<span className={styles.year}>{item.year}</span>
|
||||||
|
<p className={styles.desc}>{item.description}</p>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
function HistoryTimeline({ data, selectedYear, onYearChange }: HistoryTimelineProps) {
|
||||||
|
return (
|
||||||
|
<div className={styles.timelineWrapper}>
|
||||||
|
<div className={styles.timelineLine} />
|
||||||
|
<div className={styles.timelineContent}>
|
||||||
|
{data.map((item, index) => (
|
||||||
|
<TimelineItemRow
|
||||||
|
key={item.year}
|
||||||
|
item={item}
|
||||||
|
index={index}
|
||||||
|
isSelected={selectedYear === item.year}
|
||||||
|
onMouseEnter={() => onYearChange(item.year)}
|
||||||
|
/>
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,85 @@
|
||||||
|
import { Link } from "react-router-dom";
|
||||||
|
import styles from "./About.module.css";
|
||||||
|
import Banner from "@/components/banner";
|
||||||
|
|
||||||
|
const FALLBACK_GRADIENT = "linear-gradient(135deg, #1a2a4a 0%, #2d4a7c 100%)";
|
||||||
|
|
||||||
|
type SectionLink = { label: string; to: string };
|
||||||
|
type SectionItem = {
|
||||||
|
title: string;
|
||||||
|
desc: string;
|
||||||
|
bgImg: string;
|
||||||
|
links: SectionLink[];
|
||||||
|
};
|
||||||
|
|
||||||
|
const sectionData: SectionItem[] = [
|
||||||
|
{
|
||||||
|
title: "银泰商业集团",
|
||||||
|
desc: "涵盖地标型高端商业综合体in77、景观地标型商业综合体inPARK区域型品质商业生活中心银泰城等品牌的大型商业集团,是一家持续推动传统零售业创新与互联网转型融合的典范性企业。",
|
||||||
|
bgImg: '/images/bg-commercial-group.png',
|
||||||
|
links: [{ label: 'in77', to: '/in77' }, { label: 'inPARK', to: '/inPARK' }, { label: '银泰城购物中心', to: '/shopping-center' },]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: "银泰基业集团",
|
||||||
|
desc: "银泰基业集团是银泰集团旗下核心业务板块,深耕商业地产与零售领域多年,致力于打造高品质商业空间,引领现代消费体验。集团旗下拥有银泰百货、银泰城等多个知名商业品牌,在全国多个核心城市布局,持续为消费者创造美好生活。",
|
||||||
|
bgImg: '/images/bg-base-group.png',
|
||||||
|
links: [{ label: 'in77', to: '/in77' }, { label: 'inPARK', to: '/inPARK' }, { label: '银泰城购物中心', to: '/shopping-center' },]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: "银泰置地集团",
|
||||||
|
desc: "银泰置地集团是银泰集团旗下核心业务板块,深耕商业地产与零售领域多年,致力于打造高品质商业空间,引领现代消费体验。集团旗下拥有银泰百货、银泰城等多个知名商业品牌,在全国多个核心城市布局,持续为消费者创造美好生活。",
|
||||||
|
bgImg: '/images/bg-realty-group.png',
|
||||||
|
links: [{ label: 'in77', to: '/in77' }, { label: 'inPARK', to: '/inPARK' }, { label: '银泰城购物中心', to: '/shopping-center' },]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: "银泰投资集团",
|
||||||
|
desc: "银泰投资集团是银泰集团旗下核心业务板块,深耕商业地产与零售领域多年,致力于打造高品质商业空间,引领现代消费体验。集团旗下拥有银泰百货、银泰城等多个知名商业品牌,在全国多个核心城市布局,持续为消费者创造美好生活。",
|
||||||
|
bgImg: '/images/bg-invest-group.png',
|
||||||
|
links: [{ label: 'in77', to: '/in77' }, { label: 'inPARK', to: '/inPARK' }, { label: '银泰城购物中心', to: '/shopping-center' },]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: "瑞京集团",
|
||||||
|
desc: "瑞京集团是银泰集团旗下核心业务板块,深耕商业地产与零售领域多年,致力于打造高品质商业空间,引领现代消费体验。集团旗下拥有银泰百货、银泰城等多个知名商业品牌,在全国多个核心城市布局,持续为消费者创造美好生活。",
|
||||||
|
bgImg: '/images/bg-ruijing-group.png',
|
||||||
|
links: [{ label: 'in77', to: '/in77' }, { label: 'inPARK', to: '/inPARK' }, { label: '银泰城购物中心', to: '/shopping-center' },]
|
||||||
|
}
|
||||||
|
];
|
||||||
|
|
||||||
|
export default function About() {
|
||||||
|
return (
|
||||||
|
<div>
|
||||||
|
<Banner
|
||||||
|
title="集团概览"
|
||||||
|
desc="银泰集团(全称“中国银泰投资有限公司”)由沈国军先生于1997年创立,立足实业发展与产业投资,业务涵盖商业零售、商业地产运营与开发、股权投资等领域,在境内外拥有多家控股、参股公司,已发展成为一家主业突出、多元发展的现代企业集团。"
|
||||||
|
showBreadcrumb={true}
|
||||||
|
backgroundImage={'/images/bg-overview.png'} />
|
||||||
|
|
||||||
|
{sectionData.map((item, index) => (
|
||||||
|
<section
|
||||||
|
key={index}
|
||||||
|
className={`${styles.section} ${index % 2 === 1 ? styles.sectionRight : ""}`}
|
||||||
|
style={{
|
||||||
|
backgroundImage: `url(${item.bgImg}), ${FALLBACK_GRADIENT}`,
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{/* <div className={styles.overlay} /> */}
|
||||||
|
<div
|
||||||
|
className={`${styles.content} ${index % 2 === 1 ? styles.contentRight : ""}`}
|
||||||
|
>
|
||||||
|
<div className={styles.textBox}>
|
||||||
|
<h2 className={styles.title}>{item.title}</h2>
|
||||||
|
<p className={styles.desc}>{item.desc}</p>
|
||||||
|
<div className={styles.links}>
|
||||||
|
{item.links.map((link, index) => (
|
||||||
|
<span key={link.label}>
|
||||||
|
<Link to={link.to}>{link.label}</Link>
|
||||||
|
</span>
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</section>
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,8 @@
|
||||||
|
export default function BusinessBaseGroup() {
|
||||||
|
return (
|
||||||
|
<div>
|
||||||
|
<h1>银泰基业集团</h1>
|
||||||
|
<p>本页面为占位内容,敬请期待。</p>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,10 @@
|
||||||
|
import styles from "./CommercialGroup.module.css";
|
||||||
|
import Banner from "@/components/banner";
|
||||||
|
|
||||||
|
export default function BusinessCommercialGroup() {
|
||||||
|
return (
|
||||||
|
<div>
|
||||||
|
<Banner title="银泰商业集团" largedesc="传统零售业的推动者和变革者" showBreadcrumb={true} backgroundImage="/images/bg-commercial-group.png" />
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,8 @@
|
||||||
|
export default function BusinessInvestGroup() {
|
||||||
|
return (
|
||||||
|
<div>
|
||||||
|
<h1>银泰投资集团</h1>
|
||||||
|
<p>本页面为占位内容,敬请期待。</p>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,8 @@
|
||||||
|
export default function BusinessRealtyGroup() {
|
||||||
|
return (
|
||||||
|
<div>
|
||||||
|
<h1>银泰置地集团</h1>
|
||||||
|
<p>本页面为占位内容,敬请期待。</p>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,8 @@
|
||||||
|
export default function BusinessRujingGroup() {
|
||||||
|
return (
|
||||||
|
<div>
|
||||||
|
<h1>瑞京集团</h1>
|
||||||
|
<p>本页面为占位内容,敬请期待。</p>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,8 @@
|
||||||
|
export default function Business() {
|
||||||
|
return (
|
||||||
|
<div>
|
||||||
|
<h1>集团业务</h1>
|
||||||
|
<p>本页面为占位内容,敬请期待。</p>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,297 @@
|
||||||
|
/* Hero */
|
||||||
|
.hero {
|
||||||
|
position: relative;
|
||||||
|
min-height: 100vh;
|
||||||
|
background-size: cover;
|
||||||
|
background-position: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.heroOverlay {
|
||||||
|
position: absolute;
|
||||||
|
inset: 0;
|
||||||
|
background: linear-gradient(
|
||||||
|
to right,
|
||||||
|
rgba(0, 0, 0, 0.5) 0%,
|
||||||
|
rgba(0, 0, 0, 0.2) 60%,
|
||||||
|
transparent 100%
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
.heroContent {
|
||||||
|
position: relative;
|
||||||
|
z-index: 1;
|
||||||
|
padding: 0 24px;
|
||||||
|
padding-top: 550px;
|
||||||
|
padding-left: 13.5%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.heroTitle {
|
||||||
|
font-size: 48px;
|
||||||
|
font-weight: 700;
|
||||||
|
color: #fff;
|
||||||
|
margin: 0 0 16px;
|
||||||
|
letter-spacing: 0.05em;
|
||||||
|
}
|
||||||
|
|
||||||
|
.heroSubtitle {
|
||||||
|
font-size: 20px;
|
||||||
|
color: rgba(255, 255, 255, 0.95);
|
||||||
|
margin: 0;
|
||||||
|
letter-spacing: 0.02em;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Commercial */
|
||||||
|
.commercial {
|
||||||
|
position: relative;
|
||||||
|
height: 100vh;
|
||||||
|
background-size: cover;
|
||||||
|
background-position: center;
|
||||||
|
display: flex;
|
||||||
|
align-items: flex-end;
|
||||||
|
}
|
||||||
|
|
||||||
|
.commercialOverlay {
|
||||||
|
position: absolute;
|
||||||
|
inset: 0;
|
||||||
|
background: linear-gradient(
|
||||||
|
to right,
|
||||||
|
rgba(0, 0, 0, 0.55) 0%,
|
||||||
|
rgba(0, 0, 0, 0.15) 70%,
|
||||||
|
transparent 100%
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
.commercialContent {
|
||||||
|
position: relative;
|
||||||
|
z-index: 1;
|
||||||
|
margin: 0 260px;
|
||||||
|
display: flex;
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.commercialItem {
|
||||||
|
flex: 1;
|
||||||
|
height: 100%;
|
||||||
|
border-left: 1px solid #fff;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
justify-content: flex-end;
|
||||||
|
padding-bottom: 135px;
|
||||||
|
padding-left: 16px;
|
||||||
|
box-sizing: border-box;
|
||||||
|
}
|
||||||
|
.commercialItem:last-child {
|
||||||
|
border-right: 1px solid #fff;
|
||||||
|
}
|
||||||
|
.commercialTitle {
|
||||||
|
font-size: 40px;
|
||||||
|
font-size: 20px;
|
||||||
|
font-weight: 700;
|
||||||
|
color: #fff;
|
||||||
|
margin: 0 0 24px;
|
||||||
|
letter-spacing: 0.05em;
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
|
||||||
|
.commercialDesc {
|
||||||
|
font-size: 18px;
|
||||||
|
line-height: 1.8;
|
||||||
|
color: rgba(255, 255, 255, 0.95);
|
||||||
|
max-width: 560px;
|
||||||
|
margin: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.commercialLinks {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: row;
|
||||||
|
gap: 20px;
|
||||||
|
color: #fff;
|
||||||
|
text-decoration: underline;
|
||||||
|
margin-top: 100px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.commercialLink {
|
||||||
|
font-size: 16px;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Cards */
|
||||||
|
.cards {
|
||||||
|
padding: 150px 100px;
|
||||||
|
background: url('/public/images/bg-mask-card.png') no-repeat center center;
|
||||||
|
background-size: cover;
|
||||||
|
}
|
||||||
|
|
||||||
|
.cardsInner {
|
||||||
|
max-width: 1720px;
|
||||||
|
margin: 0 auto;
|
||||||
|
display: grid;
|
||||||
|
grid-template-columns: repeat(2, minmax(0, 1fr));
|
||||||
|
gap: 24px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.card {
|
||||||
|
position: relative;
|
||||||
|
width: 100%;
|
||||||
|
aspect-ratio: 850 / 600;
|
||||||
|
overflow: hidden;
|
||||||
|
display: flex;
|
||||||
|
align-items: flex-end;
|
||||||
|
}
|
||||||
|
|
||||||
|
@media (max-width: 768px) {
|
||||||
|
.cardsInner {
|
||||||
|
grid-template-columns: 1fr;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.cardBg {
|
||||||
|
position: absolute;
|
||||||
|
inset: 0;
|
||||||
|
background-size: cover;
|
||||||
|
background-position: center;
|
||||||
|
background-repeat: no-repeat;
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.cardOverlay {
|
||||||
|
position: absolute;
|
||||||
|
inset: 0;
|
||||||
|
background: linear-gradient(
|
||||||
|
to top,
|
||||||
|
rgba(0, 0, 0, 0.75) 0%,
|
||||||
|
rgba(0, 0, 0, 0.3) 50%,
|
||||||
|
transparent 100%
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
.cardContent {
|
||||||
|
position: relative;
|
||||||
|
z-index: 1;
|
||||||
|
padding: 32px;
|
||||||
|
color: #fff;
|
||||||
|
}
|
||||||
|
|
||||||
|
.cardTitle {
|
||||||
|
font-size: 24px;
|
||||||
|
font-weight: 600;
|
||||||
|
margin: 0 0 12px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.cardDesc {
|
||||||
|
font-size: 14px;
|
||||||
|
line-height: 1.7;
|
||||||
|
margin: 0;
|
||||||
|
opacity: 0.95;
|
||||||
|
}
|
||||||
|
|
||||||
|
.cardSustainable .cardBg,
|
||||||
|
.cardWelfare .cardBg {
|
||||||
|
background-image: linear-gradient(135deg, #1a2a4a 0%, #2d4a7c 100%);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* News */
|
||||||
|
.news {
|
||||||
|
padding: 80px 60px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.newsInner {
|
||||||
|
margin: 0 auto;
|
||||||
|
}
|
||||||
|
|
||||||
|
.newsTitle {
|
||||||
|
font-size: 40px;
|
||||||
|
font-weight: 700;
|
||||||
|
color: #222222;
|
||||||
|
text-align: center;
|
||||||
|
margin: 20px 0 80px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.newsGrid {
|
||||||
|
display: grid;
|
||||||
|
grid-template-columns: 1fr 1fr;
|
||||||
|
gap: 20px;
|
||||||
|
align-items: start;
|
||||||
|
}
|
||||||
|
|
||||||
|
.newsFeatured {
|
||||||
|
overflow: hidden;
|
||||||
|
}
|
||||||
|
|
||||||
|
.newsFeaturedImgWrap {
|
||||||
|
width: 950px;
|
||||||
|
aspect-ratio: 950 / 560;
|
||||||
|
background: linear-gradient(135deg, #e8e8e8 0%, #d0d0d0 100%);
|
||||||
|
overflow: hidden;
|
||||||
|
position: relative;
|
||||||
|
}
|
||||||
|
|
||||||
|
.newsFeaturedImg {
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
object-fit: cover;
|
||||||
|
display: block;
|
||||||
|
}
|
||||||
|
|
||||||
|
.newsFeaturedCaption {
|
||||||
|
position: absolute;
|
||||||
|
bottom: 22px;
|
||||||
|
left: 40px;
|
||||||
|
font-weight: 500;
|
||||||
|
font-size: 24px;
|
||||||
|
color: #FFFFFF;
|
||||||
|
width: 80%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.newsList {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.newsItem {
|
||||||
|
box-sizing: border-box;
|
||||||
|
padding: 24px 30px 20px 30px;
|
||||||
|
height: 180px;
|
||||||
|
background: #FFFFFF;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
justify-content: space-between;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
.newsItemTitle {
|
||||||
|
font-size: 20px;
|
||||||
|
font-weight: 500;
|
||||||
|
color: #333;
|
||||||
|
margin: 0 0 8px;
|
||||||
|
line-height: 1.4;
|
||||||
|
}
|
||||||
|
|
||||||
|
.newsItemTitle a {
|
||||||
|
color: inherit;
|
||||||
|
text-decoration: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.newsItemTitle a:hover {
|
||||||
|
color: #0f192d;
|
||||||
|
}
|
||||||
|
|
||||||
|
.newsItemSnippet {
|
||||||
|
font-size: 16px;
|
||||||
|
color: #666;
|
||||||
|
margin: 0 0 8px;
|
||||||
|
line-height: 1.6;
|
||||||
|
|
||||||
|
display: -webkit-box;
|
||||||
|
-webkit-line-clamp: 2;
|
||||||
|
line-clamp: 2;
|
||||||
|
-webkit-box-orient: vertical;
|
||||||
|
overflow: hidden;
|
||||||
|
}
|
||||||
|
|
||||||
|
.newsItemDate {
|
||||||
|
font-size: 14px;
|
||||||
|
color: #999;
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,173 @@
|
||||||
|
import { useState } from "react";
|
||||||
|
import styles from "./Home.module.css";
|
||||||
|
import Banner from "@/components/banner";
|
||||||
|
|
||||||
|
const PUBLIC_URL = process.env.PUBLIC_URL || "";
|
||||||
|
const HERO_IMG = `${PUBLIC_URL}/images/bg-overview.png`;
|
||||||
|
const FALLBACK_GRADIENT = "linear-gradient(135deg, #1a2a4a 0%, #2d4a7c 100%)";
|
||||||
|
|
||||||
|
const newsData = [
|
||||||
|
{
|
||||||
|
title: "银泰百货×敦煌研究院联名新品限量首发",
|
||||||
|
snippet: "10月28日,在杭州余杭区委城市工作会议暨城市新中心中轴线创新发展大会上,银泰集团正式宣布银泰杭州新中心项目定名为“杭州银泰中银泰集团正式宣布银泰杭州新中心项目定名为“杭州银泰中银泰集团正式宣布银泰杭州新中心项目定名为“杭州银泰中",
|
||||||
|
date: "2024-01-15",
|
||||||
|
path: "/news/1",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: "银泰中国区总裁陈晓:我们是长期主义者",
|
||||||
|
snippet: "10月28日,在杭州余杭区委城市工作会议暨城市新中心中轴线创新发展大会上,银泰集团正式宣布银泰杭州新中心项目定名为“杭州银泰中银泰集团正式宣布银泰杭州新中心项目定名为“杭州银泰中银泰集团正式宣布银泰杭州新中心项目定名为“杭州银泰中",
|
||||||
|
date: "2024-01-10",
|
||||||
|
path: "/news/2",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: "中国青年发展基金会 | 银泰公益基金会合作签约",
|
||||||
|
snippet: "10月28日,在杭州余杭区委城市工作会议暨城市新中心中轴线创新发展大会上,银泰集团正式宣布银泰杭州新中心项目定名为“杭州银泰中银泰集团正式宣布银泰杭州新中心项目定名为“杭州银泰中银泰集团正式宣布银泰杭州新中心项目定名为“杭州银泰中",
|
||||||
|
date: "2023-11-20",
|
||||||
|
path: "/news/3",
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
|
export default function Home() {
|
||||||
|
const [commercialList] = useState([
|
||||||
|
{
|
||||||
|
title: "银泰商业集团",
|
||||||
|
desc: "涵盖地标型高端商业综合体in77、景观地标型商业综合体inPARK区域型品质商业生活中心银泰城等品牌的大型商业集团,是一家持续推动传统零售业创新与互联网转型融合的典范性企业。",
|
||||||
|
bgImg: '/images/bg-commercial-group.png',
|
||||||
|
links: [{ label: 'in77', to: '/in77' }, { label: 'inPARK', to: '/inPARK' }, { label: '银泰城购物中心', to: '/shopping-center' },]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: "银泰基业集团",
|
||||||
|
desc: "银泰基业集团是银泰集团旗下核心业务板块,深耕商业地产与零售领域多年,致力于打造高品质商业空间,引领现代消费体验。集团旗下拥有银泰百货、银泰城等多个知名商业品牌,在全国多个核心城市布局,持续为消费者创造美好生活。",
|
||||||
|
bgImg: '/images/bg-base-group.png',
|
||||||
|
links: [{ label: 'in77', to: '/in77' }, { label: 'inPARK', to: '/inPARK' }, { label: '银泰城购物中心', to: '/shopping-center' },]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: "银泰置地集团",
|
||||||
|
desc: "银泰置地集团是银泰集团旗下核心业务板块,深耕商业地产与零售领域多年,致力于打造高品质商业空间,引领现代消费体验。集团旗下拥有银泰百货、银泰城等多个知名商业品牌,在全国多个核心城市布局,持续为消费者创造美好生活。",
|
||||||
|
bgImg: '/images/bg-realty-group.png',
|
||||||
|
links: [{ label: 'in77', to: '/in77' }, { label: 'inPARK', to: '/inPARK' }, { label: '银泰城购物中心', to: '/shopping-center' },]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: "银泰投资集团",
|
||||||
|
desc: "银泰投资集团是银泰集团旗下核心业务板块,深耕商业地产与零售领域多年,致力于打造高品质商业空间,引领现代消费体验。集团旗下拥有银泰百货、银泰城等多个知名商业品牌,在全国多个核心城市布局,持续为消费者创造美好生活。",
|
||||||
|
bgImg: '/images/bg-invest-group.png',
|
||||||
|
links: [{ label: 'in77', to: '/in77' }, { label: 'inPARK', to: '/inPARK' }, { label: '银泰城购物中心', to: '/shopping-center' },]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: "瑞京集团",
|
||||||
|
desc: "瑞京集团是银泰集团旗下核心业务板块,深耕商业地产与零售领域多年,致力于打造高品质商业空间,引领现代消费体验。集团旗下拥有银泰百货、银泰城等多个知名商业品牌,在全国多个核心城市布局,持续为消费者创造美好生活。",
|
||||||
|
bgImg: '/images/bg-ruijing-group.png',
|
||||||
|
links: [{ label: 'in77', to: '/in77' }, { label: 'inPARK', to: '/inPARK' }, { label: '银泰城购物中心', to: '/shopping-center' },]
|
||||||
|
},
|
||||||
|
])
|
||||||
|
const [activeCommercialIndex, setActiveCommercialIndex] = useState(0);
|
||||||
|
return (
|
||||||
|
<div>
|
||||||
|
{/* Hero */}
|
||||||
|
<Banner title="银泰集团" desc="中国现代新商业典范" showBreadcrumb={false} backgroundImage={HERO_IMG}></Banner>
|
||||||
|
|
||||||
|
{/* Commercial */}
|
||||||
|
<section
|
||||||
|
className={styles.commercial}
|
||||||
|
style={{
|
||||||
|
backgroundImage: `url(${commercialList[activeCommercialIndex].bgImg}), ${FALLBACK_GRADIENT}`,
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<div className={styles.commercialOverlay} />
|
||||||
|
<div className={styles.commercialContent}>
|
||||||
|
{commercialList.map((item, index) => (
|
||||||
|
<div key={item.title} className={styles.commercialItem}
|
||||||
|
style={{
|
||||||
|
flex: index === activeCommercialIndex ? 2.22 : 1,
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<h2 className={styles.commercialTitle} onMouseEnter={() => setActiveCommercialIndex(index)}>{item.title}</h2>
|
||||||
|
{index === activeCommercialIndex && (
|
||||||
|
<>
|
||||||
|
<p className={styles.commercialDesc}>{item.desc}</p>
|
||||||
|
<div className={styles.commercialLinks}>
|
||||||
|
{item.links.map((link) => (
|
||||||
|
<a key={link.label} href={link.to}>{link.label}</a>
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
</>
|
||||||
|
)}
|
||||||
|
|
||||||
|
</div>
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
</section>
|
||||||
|
|
||||||
|
{/* Cards */}
|
||||||
|
<section className={styles.cards}>
|
||||||
|
<div className={styles.cardsInner}>
|
||||||
|
<div className={`${styles.card} ${styles.cardSustainable}`}>
|
||||||
|
<div
|
||||||
|
className={styles.cardBg}
|
||||||
|
style={{
|
||||||
|
backgroundImage: `url(${PUBLIC_URL}/images/sustainable-cranes.png), ${FALLBACK_GRADIENT}`,
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
<div className={styles.cardOverlay} />
|
||||||
|
<div className={styles.cardContent}>
|
||||||
|
<h3 className={styles.cardTitle}>可持续发展</h3>
|
||||||
|
<p className={styles.cardDesc}>
|
||||||
|
银泰集团积极践行绿色发展理念,将可持续发展融入企业战略与日常运营,致力于构建人与自然和谐共生的美好未来。
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div className={`${styles.card} ${styles.cardWelfare}`}>
|
||||||
|
<div
|
||||||
|
className={styles.cardBg}
|
||||||
|
style={{
|
||||||
|
backgroundImage: `url(${PUBLIC_URL}/images/welfare-check.png), ${FALLBACK_GRADIENT}`,
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
<div className={styles.cardOverlay} />
|
||||||
|
<div className={styles.cardContent}>
|
||||||
|
<h3 className={styles.cardTitle}>银泰公益基金会</h3>
|
||||||
|
<p className={styles.cardDesc}>
|
||||||
|
银泰公益基金会专注于教育帮扶、社区发展等领域,多年来持续投入公益事业,用实际行动回馈社会,传递企业温度。
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</section>
|
||||||
|
|
||||||
|
{/* News */}
|
||||||
|
<section className={styles.news}>
|
||||||
|
<div className={styles.newsInner}>
|
||||||
|
<h2 className={styles.newsTitle}>新闻资讯</h2>
|
||||||
|
<div className={styles.newsGrid}>
|
||||||
|
<div className={styles.newsFeatured}>
|
||||||
|
<div className={styles.newsFeaturedImgWrap}>
|
||||||
|
<img
|
||||||
|
src={`${PUBLIC_URL}/images/news-featured.png`}
|
||||||
|
alt="新闻配图"
|
||||||
|
className={styles.newsFeaturedImg}
|
||||||
|
onError={(e) => {
|
||||||
|
(e.target as HTMLImageElement).style.display = "none";
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
<p className={styles.newsFeaturedCaption}>
|
||||||
|
银泰集团联合钱塘产业集团竞得杭州东部湾新城地块
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div className={styles.newsList}>
|
||||||
|
{newsData.map((item) => (
|
||||||
|
<article key={item.path} className={styles.newsItem}>
|
||||||
|
<h3 className={styles.newsItemTitle}>
|
||||||
|
<a href={item.path}>{item.title}</a>
|
||||||
|
</h3>
|
||||||
|
<p className={styles.newsItemSnippet}>{item.snippet}</p>
|
||||||
|
<span className={styles.newsItemDate}>{item.date}</span>
|
||||||
|
</article>
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</section>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,8 @@
|
||||||
|
export default function JoinCampus() {
|
||||||
|
return (
|
||||||
|
<div>
|
||||||
|
<h1>招贤纳士</h1>
|
||||||
|
<p>本页面为占位内容,敬请期待。</p>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,8 @@
|
||||||
|
export default function JoinCulture() {
|
||||||
|
return (
|
||||||
|
<div>
|
||||||
|
<h1>企业文化</h1>
|
||||||
|
<p>本页面为占位内容,敬请期待。</p>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,8 @@
|
||||||
|
export default function Join() {
|
||||||
|
return (
|
||||||
|
<div>
|
||||||
|
<h1>加入银泰</h1>
|
||||||
|
<p>本页面为占位内容,敬请期待。</p>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,8 @@
|
||||||
|
export default function NewsConsult() {
|
||||||
|
return (
|
||||||
|
<div>
|
||||||
|
<h1>银泰咨询</h1>
|
||||||
|
<p>本页面为占位内容,敬请期待。</p>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,8 @@
|
||||||
|
export default function NewsMedia() {
|
||||||
|
return (
|
||||||
|
<div>
|
||||||
|
<h1>媒体垂询</h1>
|
||||||
|
<p>本页面为占位内容,敬请期待。</p>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,8 @@
|
||||||
|
export default function News() {
|
||||||
|
return (
|
||||||
|
<div>
|
||||||
|
<h1>新闻中心</h1>
|
||||||
|
<p>本页面为占位内容,敬请期待。</p>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,8 @@
|
||||||
|
export default function SocialFoundation() {
|
||||||
|
return (
|
||||||
|
<div>
|
||||||
|
<h1>银泰公益基金会</h1>
|
||||||
|
<p>本页面为占位内容,敬请期待。</p>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,8 @@
|
||||||
|
export default function SocialSustainability() {
|
||||||
|
return (
|
||||||
|
<div>
|
||||||
|
<h1>可持续发展</h1>
|
||||||
|
<p>本页面为占位内容,敬请期待。</p>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,8 @@
|
||||||
|
export default function Social() {
|
||||||
|
return (
|
||||||
|
<div>
|
||||||
|
<h1>社会责任</h1>
|
||||||
|
<p>本页面为占位内容,敬请期待。</p>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,17 @@
|
||||||
|
const dotenv = require('dotenv')
|
||||||
|
try {
|
||||||
|
dotenv.config('./env')
|
||||||
|
} catch (e) {
|
||||||
|
//
|
||||||
|
}
|
||||||
|
// eslint-disable-next-line no-undef
|
||||||
|
const isDev = process.env.DEV
|
||||||
|
console.log('isDev', isDev)
|
||||||
|
module.exports = {
|
||||||
|
'/companyHome': {
|
||||||
|
target: isDev ? 'http://10.3.0.24:9211/' : 'https://companyapi.batiao8.com/',
|
||||||
|
// target: "http://10.3.0.24:9211/",
|
||||||
|
changeOrigin: true,
|
||||||
|
rewrite: (path) => path.replace(/^\/companyHome/, '')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,71 @@
|
||||||
|
/// <reference types="node" />
|
||||||
|
/// <reference types="react" />
|
||||||
|
/// <reference types="react-dom" />
|
||||||
|
|
||||||
|
declare namespace NodeJS {
|
||||||
|
interface ProcessEnv {
|
||||||
|
readonly NODE_ENV: 'development' | 'production' | 'test';
|
||||||
|
readonly PUBLIC_URL: string;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
declare module '*.avif' {
|
||||||
|
const src: string;
|
||||||
|
export default src;
|
||||||
|
}
|
||||||
|
|
||||||
|
declare module '*.bmp' {
|
||||||
|
const src: string;
|
||||||
|
export default src;
|
||||||
|
}
|
||||||
|
|
||||||
|
declare module '*.gif' {
|
||||||
|
const src: string;
|
||||||
|
export default src;
|
||||||
|
}
|
||||||
|
|
||||||
|
declare module '*.jpg' {
|
||||||
|
const src: string;
|
||||||
|
export default src;
|
||||||
|
}
|
||||||
|
|
||||||
|
declare module '*.jpeg' {
|
||||||
|
const src: string;
|
||||||
|
export default src;
|
||||||
|
}
|
||||||
|
|
||||||
|
declare module '*.png' {
|
||||||
|
const src: string;
|
||||||
|
export default src;
|
||||||
|
}
|
||||||
|
|
||||||
|
declare module '*.webp' {
|
||||||
|
const src: string;
|
||||||
|
export default src;
|
||||||
|
}
|
||||||
|
|
||||||
|
declare module '*.svg' {
|
||||||
|
import * as React from 'react';
|
||||||
|
|
||||||
|
export const ReactComponent: React.FunctionComponent<React.SVGProps<
|
||||||
|
SVGSVGElement
|
||||||
|
> & { title?: string }>;
|
||||||
|
|
||||||
|
const src: string;
|
||||||
|
export default src;
|
||||||
|
}
|
||||||
|
|
||||||
|
declare module '*.module.css' {
|
||||||
|
const classes: { readonly [key: string]: string };
|
||||||
|
export default classes;
|
||||||
|
}
|
||||||
|
|
||||||
|
declare module '*.module.scss' {
|
||||||
|
const classes: { readonly [key: string]: string };
|
||||||
|
export default classes;
|
||||||
|
}
|
||||||
|
|
||||||
|
declare module '*.module.sass' {
|
||||||
|
const classes: { readonly [key: string]: string };
|
||||||
|
export default classes;
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,15 @@
|
||||||
|
import { ReportHandler } from 'web-vitals';
|
||||||
|
|
||||||
|
const reportWebVitals = (onPerfEntry?: ReportHandler) => {
|
||||||
|
if (onPerfEntry && onPerfEntry instanceof Function) {
|
||||||
|
import('web-vitals').then(({ getCLS, getFID, getFCP, getLCP, getTTFB }) => {
|
||||||
|
getCLS(onPerfEntry);
|
||||||
|
getFID(onPerfEntry);
|
||||||
|
getFCP(onPerfEntry);
|
||||||
|
getLCP(onPerfEntry);
|
||||||
|
getTTFB(onPerfEntry);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
export default reportWebVitals;
|
||||||
|
|
@ -0,0 +1,5 @@
|
||||||
|
// jest-dom adds custom jest matchers for asserting on DOM nodes.
|
||||||
|
// allows you to do things like:
|
||||||
|
// expect(element).toHaveTextContent(/react/i)
|
||||||
|
// learn more: https://github.com/testing-library/jest-dom
|
||||||
|
import '@testing-library/jest-dom';
|
||||||
|
|
@ -0,0 +1,23 @@
|
||||||
|
const store = {
|
||||||
|
getItem(key: string) {
|
||||||
|
let value: any = window.localStorage.getItem(key)
|
||||||
|
let temp: any = null
|
||||||
|
if (value !== undefined) {
|
||||||
|
try {
|
||||||
|
temp = value
|
||||||
|
value = JSON.parse(value)
|
||||||
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||||
|
} catch (e) {
|
||||||
|
value = temp
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return value
|
||||||
|
},
|
||||||
|
setItem(key: string, value: any) {
|
||||||
|
window.localStorage.setItem(key, JSON.stringify(value))
|
||||||
|
},
|
||||||
|
delItem(key: string) {
|
||||||
|
window.localStorage.removeItem(key)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
export default store
|
||||||
|
|
@ -0,0 +1,47 @@
|
||||||
|
import "./loading.css";
|
||||||
|
|
||||||
|
class LoadingClass {
|
||||||
|
mask = document.createElement("div");
|
||||||
|
content = document.createElement("div");
|
||||||
|
|
||||||
|
textElement = document.createElement("div");
|
||||||
|
|
||||||
|
constructor() {
|
||||||
|
this.show = false;
|
||||||
|
this.mask.style.cssText = `
|
||||||
|
position: fixed;
|
||||||
|
height: 100vh;
|
||||||
|
width: 100vw;
|
||||||
|
background-color: rgba(0, 0, 0, 0.5);
|
||||||
|
display: flex;
|
||||||
|
z-index: 9999;
|
||||||
|
top: 0;
|
||||||
|
left: 0;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
`;
|
||||||
|
this.content.className = "loading-container";
|
||||||
|
this.textElement.className = "loading-text";
|
||||||
|
this.mask.appendChild(this.content);
|
||||||
|
this.mask.appendChild(this.textElement);
|
||||||
|
}
|
||||||
|
show = false;
|
||||||
|
Loading = (text = "") => {
|
||||||
|
if (this.show) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
this.show = true;
|
||||||
|
this.textElement.innerText = text;
|
||||||
|
document.body.appendChild(this.mask);
|
||||||
|
};
|
||||||
|
changeText = (text: string) => {
|
||||||
|
this.textElement.innerText = text;
|
||||||
|
};
|
||||||
|
hideLoading = () => {
|
||||||
|
document.body.removeChild(this.mask);
|
||||||
|
this.changeText("");
|
||||||
|
this.show = false;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
export default LoadingClass;
|
||||||
|
|
@ -0,0 +1,39 @@
|
||||||
|
export default {
|
||||||
|
objectToString(url: string, params?: { [key: string]: never }): string {
|
||||||
|
if (params){
|
||||||
|
const p =Object.keys(params).map((key: string) => {
|
||||||
|
const value = params[key]
|
||||||
|
if (typeof value === "object") {
|
||||||
|
return key + "=" + JSON.stringify(value)
|
||||||
|
} else {
|
||||||
|
return key + "=" + String(value)
|
||||||
|
}
|
||||||
|
}).join("&")
|
||||||
|
if(url.includes("?")){
|
||||||
|
return url + "&" + p
|
||||||
|
}
|
||||||
|
return url + "?" + p
|
||||||
|
}
|
||||||
|
return url
|
||||||
|
},
|
||||||
|
stringToObject(url:string){
|
||||||
|
const temp = url.split("?")
|
||||||
|
url = temp[0]
|
||||||
|
if (temp.length===2){
|
||||||
|
const paramsStr = temp[1]
|
||||||
|
const paramsObj:{[key:string]:string} = {}
|
||||||
|
paramsStr.split("&").forEach((item:string)=>{
|
||||||
|
const t = item.split("=")
|
||||||
|
paramsObj[t[0]] = t[1]
|
||||||
|
})
|
||||||
|
return {
|
||||||
|
url,
|
||||||
|
params: paramsObj
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return {
|
||||||
|
url,
|
||||||
|
params:{}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,150 @@
|
||||||
|
import axios, {AxiosRequestConfig, InternalAxiosRequestConfig} from "axios";
|
||||||
|
import config from "@/config.json";
|
||||||
|
import "nprogress/nprogress.css"; // nprogress样式文件
|
||||||
|
import CryptoJS from "crypto-js";
|
||||||
|
import NProgress from "nprogress";
|
||||||
|
import store from "@/store";
|
||||||
|
import * as uuid from "uuid";
|
||||||
|
import Toast from "./toast";
|
||||||
|
// import init from "./init";
|
||||||
|
|
||||||
|
const instance = axios.create({
|
||||||
|
baseURL: config.baseUrl, // 你的 API 地址
|
||||||
|
timeout: config.requestTimeout, // 请求超时时间(毫秒)
|
||||||
|
});
|
||||||
|
|
||||||
|
const setheader = (header: { [key: string]: string }) => {
|
||||||
|
header["x-host-api"] = process.env.REACT_APP_HOST || window.location.hostname;
|
||||||
|
const token = store.getItem("token");
|
||||||
|
if (token) {
|
||||||
|
header["x-token"] = token;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const deCode = (str: string) => {
|
||||||
|
const key = CryptoJS.lib.WordArray.create();
|
||||||
|
key.sigBytes = 32;
|
||||||
|
key.words = [
|
||||||
|
811741284, 926496306, 1681274721, 926311984, 811820601, 1717907557,
|
||||||
|
1700999216, 909206322,
|
||||||
|
];
|
||||||
|
const iv = key.clone();
|
||||||
|
iv.sigBytes = 16;
|
||||||
|
iv.clamp();
|
||||||
|
let res = CryptoJS.AES.decrypt(str, key, {
|
||||||
|
iv,
|
||||||
|
mode: CryptoJS.mode.CBC,
|
||||||
|
padding: CryptoJS.pad.Pkcs7,
|
||||||
|
}).toString(CryptoJS.enc.Utf8);
|
||||||
|
res = JSON.parse(res);
|
||||||
|
return res;
|
||||||
|
};
|
||||||
|
const sign = (config: InternalAxiosRequestConfig<any>) => {
|
||||||
|
let key: any = CryptoJS.lib.WordArray.create();
|
||||||
|
key.sigBytes = 32;
|
||||||
|
key.words = [
|
||||||
|
943011684, 909730867, 926168633, 878915940, 1697920564, 943088691,
|
||||||
|
1650745697, 1633891379,
|
||||||
|
];
|
||||||
|
const method = config.method;
|
||||||
|
if (!config.params) {
|
||||||
|
config.params = {};
|
||||||
|
}
|
||||||
|
key = CryptoJS.enc.Utf8.stringify(key);
|
||||||
|
config.params.timestamp = Math.floor(new Date().getTime() / 1000);
|
||||||
|
config.params.nonce = uuid.v4();
|
||||||
|
if (
|
||||||
|
method === "GET" ||
|
||||||
|
method === "DELETE" ||
|
||||||
|
method === "get" ||
|
||||||
|
method === "delete"
|
||||||
|
) {
|
||||||
|
const keys = Object.keys(config.params);
|
||||||
|
keys.sort();
|
||||||
|
for (const i in keys) {
|
||||||
|
keys[i] = keys[i] + "=" + encodeURIComponent(config.params[keys[i]]);
|
||||||
|
}
|
||||||
|
const temp = keys.join("&") + "&" + CryptoJS.MD5(key).toString();
|
||||||
|
config.params.signature = CryptoJS.MD5(temp).toString();
|
||||||
|
} else if (
|
||||||
|
method === "POST" ||
|
||||||
|
method === "PUT" ||
|
||||||
|
method === "post" ||
|
||||||
|
method === "put"
|
||||||
|
) {
|
||||||
|
if (!config.data) {
|
||||||
|
config.data = {};
|
||||||
|
}
|
||||||
|
const keys = Object.keys(config.params);
|
||||||
|
keys.sort();
|
||||||
|
for (const i in keys) {
|
||||||
|
keys[i] = keys[i] + "=" + encodeURIComponent(config.params[keys[i]]);
|
||||||
|
}
|
||||||
|
let temp = keys.join("&");
|
||||||
|
temp += "&" + JSON.stringify(config.data);
|
||||||
|
temp += "&" + CryptoJS.MD5(key).toString();
|
||||||
|
config.params.signature = CryptoJS.MD5(temp).toString();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
// 请求拦截器
|
||||||
|
instance.interceptors.request.use(
|
||||||
|
(config) => {
|
||||||
|
// 在发送请求之前做些什么,比如添加 token 等
|
||||||
|
NProgress.start(); // 开始进度条
|
||||||
|
setheader(config.headers);
|
||||||
|
sign(config);
|
||||||
|
return config;
|
||||||
|
},
|
||||||
|
(error) => {
|
||||||
|
// 对请求错误做些什么
|
||||||
|
return Promise.reject(error);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
// 响应拦截器
|
||||||
|
instance.interceptors.response.use(
|
||||||
|
(response) => {
|
||||||
|
// 对响应数据做点什么
|
||||||
|
NProgress.done(); // 结束进度条
|
||||||
|
if (typeof response.data === "object") {
|
||||||
|
if (response.data.encrypt) {
|
||||||
|
response.data = deCode(response.data.data);
|
||||||
|
if (response.data.code !== 0) {
|
||||||
|
const urlInfo = `${response.config.method?.toUpperCase()}&${response.config.url}`
|
||||||
|
// console.log(response)
|
||||||
|
if ([1001003, 1001004].includes(response.data.code)) {
|
||||||
|
Toast("登录过期请重新登录", "error");
|
||||||
|
store.delItem("token");
|
||||||
|
// init(true);
|
||||||
|
} else if (!config.ignoreCodeErrorList.includes(urlInfo)) {
|
||||||
|
Toast(response.data.message.split(",")[0], "error");
|
||||||
|
throw Error(response.data.message.split(",")[0])
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return response.data;
|
||||||
|
},
|
||||||
|
(error) => {
|
||||||
|
// 对响应错误做点什么
|
||||||
|
NProgress.done(); // 结束进度条
|
||||||
|
Toast(error.message, "error");
|
||||||
|
return Promise.reject(error);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
interface AxiosRequestConfigWrapper extends AxiosRequestConfig {
|
||||||
|
formContentType?: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
|
const requests = (config: AxiosRequestConfigWrapper) => {
|
||||||
|
if (typeof config?.headers?.setContentType === "function") {
|
||||||
|
if (config.formContentType) {
|
||||||
|
config.headers.setContentType("application/x-www-form-urlencoded");
|
||||||
|
} else {
|
||||||
|
config.headers.setContentType("application/json");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return instance(config);
|
||||||
|
};
|
||||||
|
export default requests;
|
||||||
|
|
@ -0,0 +1,30 @@
|
||||||
|
/** @jsxImportSource @emotion/react */
|
||||||
|
|
||||||
|
const Toast = (
|
||||||
|
message: string,
|
||||||
|
type: "info" | "warn" | "error" = "info",
|
||||||
|
duration: number = 2000
|
||||||
|
) => {
|
||||||
|
const div = document.createElement("div");
|
||||||
|
div.style.cssText = `
|
||||||
|
position: fixed;
|
||||||
|
left: 50%;
|
||||||
|
top: 50%;
|
||||||
|
transform: translate(-50%, -50%);
|
||||||
|
background-color: ${
|
||||||
|
type === "info" ? "#333" : type === "warn" ? "#ff9800" : "#f44336"
|
||||||
|
};
|
||||||
|
color: white;
|
||||||
|
padding: 10px 20px;
|
||||||
|
border-radius: 5px;
|
||||||
|
box-shadow: 0 2px 5px rgba(0, 0, 0, 0.3);
|
||||||
|
z-index: 1000;
|
||||||
|
`;
|
||||||
|
div.innerText = message;
|
||||||
|
document.body.appendChild(div);
|
||||||
|
setTimeout(() => {
|
||||||
|
document.body.removeChild(div);
|
||||||
|
}, duration);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default Toast;
|
||||||
|
|
@ -0,0 +1,29 @@
|
||||||
|
{
|
||||||
|
"compilerOptions": {
|
||||||
|
"target": "es5",
|
||||||
|
"lib": [
|
||||||
|
"dom",
|
||||||
|
"dom.iterable",
|
||||||
|
"esnext"
|
||||||
|
],
|
||||||
|
"allowJs": true,
|
||||||
|
"skipLibCheck": true,
|
||||||
|
"esModuleInterop": true,
|
||||||
|
"allowSyntheticDefaultImports": true,
|
||||||
|
"strict": true,
|
||||||
|
"forceConsistentCasingInFileNames": true,
|
||||||
|
"noFallthroughCasesInSwitch": true,
|
||||||
|
"module": "esnext",
|
||||||
|
"moduleResolution": "node",
|
||||||
|
"resolveJsonModule": true,
|
||||||
|
"isolatedModules": true,
|
||||||
|
"noEmit": true,
|
||||||
|
"jsx": "react-jsx",
|
||||||
|
"paths": {
|
||||||
|
"@/*": ["./src/*"]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"include": [
|
||||||
|
"src"
|
||||||
|
],
|
||||||
|
}
|
||||||