diff --git a/.env b/.env index a662ddf..121363d 100644 --- a/.env +++ b/.env @@ -1 +1,4 @@ -REACT_APP_IMAGE_BASE_URL=https://img2.baidu.com \ No newline at end of file +REACT_APP_IMAGE_BASE_URL=https://img2.baidu.com +REACT_APP_ASSISTANT_DISPLAY_NAME_EN= +REACT_APP_ASSISTANT_DISPLAY_NAME_ZH= +REACT_APP_LOGO_FILE= diff --git a/package.json b/package.json index 48adf7a..bad00c3 100644 --- a/package.json +++ b/package.json @@ -53,11 +53,11 @@ "lint": "eslint src --ext ts", "test": "mocha", "build": "webpack --config webpack.config.js", - "vscode": "webpack --config webpack.config.js && mv dist/* ../dist", + "vscode": "node prebuild.js && webpack --config webpack.config.js && mv dist/* ../dist", "vscode:watch": "webpack --config webpack.config.js --watch", "dev": "webpack serve --config webpack.config.js --open", "build:idea": "webpack --config webpack.idea.config.js", - "idea": "webpack --config webpack.idea.config.js && mv dist/main.js dist/main.html ../src/main/resources/static && echo '🎆done'" + "idea": "node prebuild.js && webpack --config webpack.idea.config.js && mv dist/main.js dist/main.html ../src/main/resources/static && echo '🎆done'" }, "devDependencies": { "@babel/core": "^7.21.8", diff --git a/prebuild.js b/prebuild.js new file mode 100644 index 0000000..c9c833c --- /dev/null +++ b/prebuild.js @@ -0,0 +1,23 @@ +require('dotenv').config(); + +const fs = require('fs'); +const path = require('path'); + +const logoPath = process.env.REACT_APP_LOGO_FILE; +if (!logoPath) { + console.warn('REACT_APP_LOGO_FILE is not defined in your environment variables'); + process.exit(0); +} +if (!fs.existsSync(logoPath)) { + console.warn('Logo file does not exist.'); + process.exit(0) +} + +const destPath = path.join(__dirname, 'src/views/components/MessageAvatar/avatar_devchat.svg'); + +try { + fs.copyFileSync(logoPath, destPath) + fs.chmodSync(destPath, 0o644) +} catch(e) { + console.warn(`Failed to copy logo ${e}`) +} \ No newline at end of file