diff --git a/admin/package.json b/admin/package.json index a9162b3..98eabd9 100644 --- a/admin/package.json +++ b/admin/package.json @@ -11,9 +11,9 @@ "lint": "eslint . --ext .vue,.js,.jsx,.cjs,.mjs,.ts,.tsx,.cts,.mts --fix --ignore-path .gitignore" }, "dependencies": { - "@element-plus/icons-vue": "^2.1.0", + "@element-plus/icons-vue": "^2.3.1", "@highlightjs/vue-plugin": "^2.1.0", - "@vue/shared": "^3.3.8", + "@vue/shared": "^3.3.9", "@vueuse/core": "^10.6.1", "@wangeditor/editor": "^5.1.23", "@wangeditor/editor-for-vue": "^5.1.12", @@ -22,12 +22,12 @@ "crypto-js": "^4.2.0", "css-color-function": "^1.3.3", "echarts": "^5.4.3", - "element-plus": "^2.4.2", + "element-plus": "^2.4.3", "highlight.js": "^11.9.0", "lodash-es": "^4.17.21", "nprogress": "^0.2.0", "pinia": "^2.1.7", - "vue": "^3.3.8", + "vue": "^3.3.9", "vue-clipboard3": "^2.0.0", "vue-echarts": "^6.6.1", "vue-router": "^4.2.5", @@ -48,16 +48,17 @@ "eslint": "^8.54.0", "eslint-plugin-vue": "^9.18.1", "execa": "^8.0.1", - "fs-extra": "^11.1.1", + "fs-extra": "^11.2.0", "postcss": "^8.4.31", "prettier": "^3.1.0", "rollup-plugin-visualizer": "^5.9.3", "sass": "^1.69.5", "tailwindcss": "^3.3.5", - "typescript": "~5.2.2", - "unplugin-auto-import": "^0.16.7", + "typescript": "~5.3.2", + "unplugin-auto-import": "^0.11.1", "unplugin-vue-components": "^0.25.2", "vite": "^4.5.0", + "vite-plugin-compression": "^0.5.1", "vite-plugin-style-import": "^2.0.0", "vite-plugin-svg-icons": "^2.0.1", "vue-tsc": "^1.8.22" diff --git a/admin/vite.config.ts b/admin/vite.config.ts index 02e1657..2e266da 100644 --- a/admin/vite.config.ts +++ b/admin/vite.config.ts @@ -9,7 +9,8 @@ import { ElementPlusResolver } from 'unplugin-vue-components/resolvers' import { createStyleImportPlugin, ElementPlusResolve } from 'vite-plugin-style-import' import { createSvgIconsPlugin } from 'vite-plugin-svg-icons' -import { visualizer } from 'rollup-plugin-visualizer' +import viteCompression from 'vite-plugin-compression' +// import { visualizer } from 'rollup-plugin-visualizer' // https://vitejs.dev/config/ export default ({ mode }) => { @@ -51,13 +52,19 @@ export default ({ mode }) => { iconDirs: [fileURLToPath(new URL('./src/assets/icons', import.meta.url))], symbolId: 'local-icon-[dir]-[name]' }), - visualizer({ - gzipSize: true, - brotliSize: true, - emitFile: false, - filename: 'test.html', //分析图生成的文件名 - open: true //如果存在本地服务端口,将在打包后自动展示 + viteCompression({ + algorithm: 'gzip' + }), + viteCompression({ + algorithm: 'brotliCompress' }) + // visualizer({ + // gzipSize: true, + // brotliSize: true, + // emitFile: false, + // filename: 'test.html', //分析图生成的文件名 + // open: true //如果存在本地服务端口,将在打包后自动展示 + // }) ], resolve: { alias: { diff --git a/server/admin/captcha/captcha_ctl.go b/server/admin/captcha/captcha_ctl.go index 3fdcda9..6e3a3bd 100644 --- a/server/admin/captcha/captcha_ctl.go +++ b/server/admin/captcha/captcha_ctl.go @@ -1,12 +1,15 @@ package captcha import ( + "fmt" "image/color" + "x_admin/config" config2 "github.com/TestsLing/aj-captcha-go/config" constant "github.com/TestsLing/aj-captcha-go/const" "github.com/TestsLing/aj-captcha-go/service" "github.com/gin-gonic/gin" + "github.com/go-redis/redis/v9" ) type CaptchaGetParams struct { @@ -42,7 +45,7 @@ var clickWordConfig = &config2.ClickWordConfig{ var blockPuzzleConfig = &config2.BlockPuzzleConfig{Offset: 10} // 行为校验配置模块(具体参数可从业务系统配置文件自定义) -var captcha_config = config2.BuildConfig(constant.MemCacheKey, constant.DefaultResourceRoot, watermarkConfig, +var captcha_config = config2.BuildConfig(constant.RedisCacheKey, constant.DefaultResourceRoot, watermarkConfig, clickWordConfig, blockPuzzleConfig, 2*60) // 服务工厂,主要用户注册 获取 缓存和验证服务 @@ -50,13 +53,12 @@ var factory = service.NewCaptchaServiceFactory(captcha_config) func init() { // 这里默认是注册了 内存缓存,但是不足以应对生产环境,希望自行注册缓存驱动 实现缓存接口即可替换(CacheType就是注册进去的 key) - factory.RegisterCache(constant.MemCacheKey, service.NewMemCacheService(200000)) // 这里20指的是缓存阈值 + // factory.RegisterCache(constant.MemCacheKey, service.NewMemCacheService(200000)) // 这里20指的是缓存阈值 - //注册使用默认redis数据库 - // factory.RegisterCache(constant.RedisCacheKey, service.NewDftRedisCacheService()) // //注册自定义配置redis数据库 - // opt, err := redis.ParseURL(config.Config.RedisUrl) - // factory.RegisterCache(constant.RedisCacheKey, service.NewConfigRedisCacheService([]string{opt.Addr}, "", "", false, 0)) + opt, _ := redis.ParseURL(config.Config.RedisUrl) + fmt.Printf("%#v", opt) + factory.RegisterCache(constant.RedisCacheKey, service.NewConfigRedisCacheService([]string{opt.Addr}, opt.Username, opt.Password, false, 0)) // 注册了两种验证码服务 可以自行实现更多的验证 factory.RegisterService(constant.ClickWordCaptcha, service.NewClickWordCaptchaService(factory)) diff --git a/server/admin/system/login/login.go b/server/admin/system/login/login.go index ba16add..020391d 100644 --- a/server/admin/system/login/login.go +++ b/server/admin/system/login/login.go @@ -22,7 +22,7 @@ func LoginRoute(rg *gin.RouterGroup) { handle := loginHandler{Service: service} rg = rg.Group("/system", middleware.TokenAuth()) - rg.POST("/login", handle.login) + rg.POST("/login", handle.login, middleware.RecordLog("后台登录")) rg.POST("/logout", handle.logout) } diff --git a/server/main.go b/server/main.go index 8046ebf..eef3e13 100644 --- a/server/main.go +++ b/server/main.go @@ -30,7 +30,7 @@ func initRouter() *gin.Engine { } // 特殊异常处理 router.NoMethod(response.NoMethod) - router.NoRoute(response.NoRoute) + // router.NoRoute(response.NoRoute) // 注册路由 group := router.Group("/api")