From 3116d3bf8b93528b4b05dc58823bd4cb173ecc6f Mon Sep 17 00:00:00 2001 From: chenhaodong Date: Tue, 23 Jun 2026 20:08:35 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E6=89=93=E5=8C=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 11 ++ .../java/com/bc/exam/ExamApplication.java | 21 +-- .../src/main/resources/application-dev.yml | 10 ++ exam-api/src/main/resources/static/readMe.txt | 2 - exam-vue/.npmrc | 1 + exam-vue/build/index.js | 35 ----- exam-vue/package.json | 5 +- exam-vue/pnpm-workspace.yaml | 4 + exam-vue/vite.config.mjs | 2 +- exam-vue/vue.config.js | 128 ------------------ 10 files changed, 35 insertions(+), 184 deletions(-) create mode 100644 .gitignore delete mode 100644 exam-api/src/main/resources/static/readMe.txt create mode 100644 exam-vue/.npmrc delete mode 100644 exam-vue/build/index.js create mode 100644 exam-vue/pnpm-workspace.yaml delete mode 100644 exam-vue/vue.config.js diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..59e09db --- /dev/null +++ b/.gitignore @@ -0,0 +1,11 @@ +# IDE +.idea/ + +# 后端构建输出 +exam-api/target/ + +# 前端打包输出(Vite build 输出到后端 static 目录) +exam-api/src/main/resources/static/ + +# 日志 +logs/ diff --git a/exam-api/src/main/java/com/bc/exam/ExamApplication.java b/exam-api/src/main/java/com/bc/exam/ExamApplication.java index baceea1..04b8103 100644 --- a/exam-api/src/main/java/com/bc/exam/ExamApplication.java +++ b/exam-api/src/main/java/com/bc/exam/ExamApplication.java @@ -24,24 +24,13 @@ import java.util.List; @EnableTransactionManagement public class ExamApplication implements WebMvcConfigurer { - public static void main(String[] args) throws UnknownHostException { - ConfigurableApplicationContext application = SpringApplication.run(ExamApplication.class, args); - Environment env = application.getEnvironment(); - String ip = InetAddress.getLocalHost().getHostAddress(); - String port = env.getProperty("server.port"); - String path = env.getProperty("server.servlet.context-path"); - - // 未配置默认空白 - if(path == null){ - path = ""; - } - - + public static void main(String[] args) { + SpringApplication.run(ExamApplication.class, args); log.info("\n----------------------------------------------------------\n\t" + "系统启动成功,访问路径如下:\n\t" + - "本地路径: \t\thttp://127.0.0.1:" + port + path + "/\n\t" + - "网络地址: \thttp://" + ip + ":" + port + path + "/\n\t" + - "API文档: \t\thttp://" + ip + ":" + port + path + "/doc.html\n" + + "本地路径: \t\thttp://127.0.0.1:8101\n\t" + + "慢sql监控:\t\thttp://127.0.0.1:8101/druid/index.html\n\t"+ + "API文档: \t\thttp://127.0.0.1:8101/doc.html\n" + "----------------------------------------------------------"); } diff --git a/exam-api/src/main/resources/application-dev.yml b/exam-api/src/main/resources/application-dev.yml index 1b0bdd6..0fe3e4c 100644 --- a/exam-api/src/main/resources/application-dev.yml +++ b/exam-api/src/main/resources/application-dev.yml @@ -20,6 +20,16 @@ spring: pool-prepared-statements: true max-open-prepared-statements: 1000 async-init: true + druid: + stat-view-servlet: + enabled: true + url-pattern: /druid/* + login-username: admin + login-password: admin123 + web-stat-filter: + enabled: true + url-pattern: /* + exclusions: "*.js,*.gif,*.jpg,*.png,*.css,*.ico,/druid/*" # 开启文档 swagger: diff --git a/exam-api/src/main/resources/static/readMe.txt b/exam-api/src/main/resources/static/readMe.txt deleted file mode 100644 index a581872..0000000 --- a/exam-api/src/main/resources/static/readMe.txt +++ /dev/null @@ -1,2 +0,0 @@ -为了方便单文件运行,可以把前端打包文件dist目录的内容复制到本目录下面,这样就可以直接运行jar就包含前端了,不需要单独再部署前端了。 -访问地址为:http://localhost:8101 \ No newline at end of file diff --git a/exam-vue/.npmrc b/exam-vue/.npmrc new file mode 100644 index 0000000..e60ae71 --- /dev/null +++ b/exam-vue/.npmrc @@ -0,0 +1 @@ +ignore-scripts=false diff --git a/exam-vue/build/index.js b/exam-vue/build/index.js deleted file mode 100644 index 0c57de2..0000000 --- a/exam-vue/build/index.js +++ /dev/null @@ -1,35 +0,0 @@ -const { run } = require('runjs') -const chalk = require('chalk') -const config = require('../vue.config.js') -const rawArgv = process.argv.slice(2) -const args = rawArgv.join(' ') - -if (process.env.npm_config_preview || rawArgv.includes('--preview')) { - const report = rawArgv.includes('--report') - - run(`vue-cli-service build ${args}`) - - const port = 9526 - const publicPath = config.publicPath - - var connect = require('connect') - var serveStatic = require('serve-static') - const app = connect() - - app.use( - publicPath, - serveStatic('./dist', { - index: ['index.html', '/'] - }) - ) - - app.listen(port, function () { - console.log(chalk.green(`> Preview at http://localhost:${port}${publicPath}`)) - if (report) { - console.log(chalk.green(`> Report at http://localhost:${port}${publicPath}report.html`)) - } - - }) -} else { - run(`vue-cli-service build ${args}`) -} diff --git a/exam-vue/package.json b/exam-vue/package.json index 95c7216..713fbc9 100644 --- a/exam-vue/package.json +++ b/exam-vue/package.json @@ -1,4 +1,4 @@ -{ + { "name": "myzs", "version": "1.0.0", "description": "墨韵智枢", @@ -35,5 +35,6 @@ }, "engines": { "node": ">=16.0.0" - } + }, + "packageManager": "pnpm@11.8.0+sha512.c1f5e7c4cb241c8f174b743851d82f42b802324afc8b0f116b96adb15aa06664948dde36960a3ba1079ba5b4b29dd0140135b94b5b5f5263592249d68e555f26" } diff --git a/exam-vue/pnpm-workspace.yaml b/exam-vue/pnpm-workspace.yaml new file mode 100644 index 0000000..8104f35 --- /dev/null +++ b/exam-vue/pnpm-workspace.yaml @@ -0,0 +1,4 @@ +allowBuilds: + '@parcel/watcher': true + cos-js-sdk-v5: true + esbuild: true diff --git a/exam-vue/vite.config.mjs b/exam-vue/vite.config.mjs index 93c5398..3ac1bc3 100644 --- a/exam-vue/vite.config.mjs +++ b/exam-vue/vite.config.mjs @@ -32,7 +32,7 @@ export default defineConfig(({ mode }) => { }, build: { outDir: '../exam-api/src/main/resources/static', - emptyOutDir: false, + emptyOutDir: true, assetsDir: 'static', sourcemap: false, chunkSizeWarningLimit: 1000, diff --git a/exam-vue/vue.config.js b/exam-vue/vue.config.js deleted file mode 100644 index ffe9753..0000000 --- a/exam-vue/vue.config.js +++ /dev/null @@ -1,128 +0,0 @@ -'use strict' -const path = require('path') -const defaultSettings = require('./src/settings.js') - -function resolve(dir) { - return path.join(__dirname, dir) -} - -const name = defaultSettings.title || '校园管藏图书数字化运维系统' // page title - -// If your port is set to 80, -// use administrator privileges to execute the command line. -// For example, Mac: sudo npm run -// You can change the port by the following method: -// port = 9527 npm run dev OR npm run dev --port = 9527 -const port = process.env.port || process.env.npm_config_port || 9527 // dev port - -// All configuration item explanations can be find in https://cli.vuejs.org/config/ -module.exports = { - /** - * You will need to set publicPath if you plan to deploy your site under a sub path, - * for example GitHub Pages. If you plan to deploy your site to https://foo.github.io/bar/, - * then publicPath should be set to "/bar/". - * In most cases please use '/' !!! - * Detail: https://cli.vuejs.org/config/#publicpath - */ - publicPath: '/', - outputDir: 'dist', - assetsDir: 'static', - // lintOnSave: process.env.NODE_ENV !== 'production', - lintOnSave: false, - productionSourceMap: false, - devServer: { - port: port, - open: true, - overlay: { - warnings: false, - errors: true - } - }, - configureWebpack: { - // provide the app's title in webpack's name field, so that - // it can be accessed in index.html to inject the correct title. - name: name, - resolve: { - alias: { - '@': resolve('src') - } - } - }, - chainWebpack(config) { - config.plugins.delete('preload') // TODO: need test - config.plugins.delete('prefetch') // TODO: need test - - // set svg-sprite-loader - config.module - .rule('svg') - .exclude.add(resolve('src/icons')) - .end() - config.module - .rule('icons') - .test(/\.svg$/) - .include.add(resolve('src/icons')) - .end() - .use('svg-sprite-loader') - .loader('svg-sprite-loader') - .options({ - symbolId: 'icon-[name]' - }) - .end() - - // set preserveWhitespace - config.module - .rule('vue') - .use('vue-loader') - .loader('vue-loader') - .tap(options => { - options.compilerOptions.preserveWhitespace = true - return options - }) - .end() - - config - // https://webpack.js.org/configuration/devtool/#development - .when(process.env.NODE_ENV === 'development', - config => config.devtool('cheap-source-map') - ) - - config - .when(process.env.NODE_ENV !== 'development', - config => { - config - .plugin('ScriptExtHtmlWebpackPlugin') - .after('html') - .use('script-ext-html-webpack-plugin', [{ - // `runtime` must same as runtimeChunk name. default is `runtime` - inline: /runtime\..*\.js$/ - }]) - .end() - config - .optimization.splitChunks({ - chunks: 'all', - cacheGroups: { - libs: { - name: 'chunk-libs', - test: /[\\/]node_modules[\\/]/, - priority: 10, - chunks: 'initial' // only package third parties that are initially dependent - }, - elementUI: { - name: 'chunk-elementUI', // split elementUI into a single package - priority: 20, // the weight needs to be larger than libs and app or it will be packaged into libs or app - test: /[\\/]node_modules[\\/]_?element-ui(.*)/ // in order to adapt to cnpm - }, - commons: { - name: 'chunk-commons', - test: resolve('src/components'), // can customize your rules - minChunks: 3, // minimum common number - priority: 5, - reuseExistingChunk: true - } - } - }) - config.optimization.runtimeChunk('single') - } - ) - } -}