diff --git a/server/api/v1/system/sys_dictionary.go b/server/api/v1/system/sys_dictionary.go index 1dfe9d0899..5e6ca79c3b 100644 --- a/server/api/v1/system/sys_dictionary.go +++ b/server/api/v1/system/sys_dictionary.go @@ -4,6 +4,7 @@ import ( "github.com/flipped-aurora/gin-vue-admin/server/global" "github.com/flipped-aurora/gin-vue-admin/server/model/common/response" "github.com/flipped-aurora/gin-vue-admin/server/model/system" + "github.com/flipped-aurora/gin-vue-admin/server/model/system/request" "github.com/gin-gonic/gin" "go.uber.org/zap" ) @@ -116,10 +117,17 @@ func (s *DictionaryApi) FindSysDictionary(c *gin.Context) { // @Security ApiKeyAuth // @accept application/json // @Produce application/json +// @Param data query request.SysDictionarySearch true "字典 name 或者 type" // @Success 200 {object} response.Response{data=response.PageResult,msg=string} "分页获取SysDictionary列表,返回包括列表,总数,页码,每页数量" // @Router /sysDictionary/getSysDictionaryList [get] func (s *DictionaryApi) GetSysDictionaryList(c *gin.Context) { - list, err := dictionaryService.GetSysDictionaryInfoList() + var dictionary request.SysDictionarySearch + err := c.ShouldBindQuery(&dictionary) + if err != nil { + response.FailWithMessage(err.Error(), c) + return + } + list, err := dictionaryService.GetSysDictionaryInfoList(c, dictionary) if err != nil { global.GVA_LOG.Error("获取失败!", zap.Error(err)) response.FailWithMessage("获取失败", c) diff --git a/server/config.yaml b/server/config.yaml index 35aaba3d05..1f9dbf4d69 100644 --- a/server/config.yaml +++ b/server/config.yaml @@ -268,7 +268,6 @@ cors: allow-headers: Content-Type,AccessToken,X-CSRF-Token, Authorization, Token,X-Token,X-User-Id allow-methods: POST, GET expose-headers: Content-Length, Access-Control-Allow-Origin, Access-Control-Allow-Headers, Content-Type - allow-credentials: true # 布尔值 - allow-origin: example2.com allow-headers: content-type @@ -280,4 +279,4 @@ mcp: version: v1.0.0 sse_path: /sse message_path: /message - url_prefix: '' \ No newline at end of file + url_prefix: '' diff --git a/server/model/common/response/response.go b/server/model/common/response/response.go index a429b12e12..f0e0e53120 100644 --- a/server/model/common/response/response.go +++ b/server/model/common/response/response.go @@ -18,7 +18,6 @@ const ( ) func Result(code int, data interface{}, msg string, c *gin.Context) { - // 开始时间 c.JSON(http.StatusOK, Response{ code, data, diff --git a/server/model/system/request/sys_dictionary.go b/server/model/system/request/sys_dictionary.go new file mode 100644 index 0000000000..2b5fa1a9dd --- /dev/null +++ b/server/model/system/request/sys_dictionary.go @@ -0,0 +1,5 @@ +package request + +type SysDictionarySearch struct { + Name string `json:"name" form:"name" gorm:"column:name;comment:字典名(中)"` // 字典名(中) +} diff --git a/server/service/system/sys_dictionary.go b/server/service/system/sys_dictionary.go index d540a9602c..193565bcc7 100644 --- a/server/service/system/sys_dictionary.go +++ b/server/service/system/sys_dictionary.go @@ -2,6 +2,8 @@ package system import ( "errors" + "github.com/flipped-aurora/gin-vue-admin/server/model/system/request" + "github.com/gin-gonic/gin" "github.com/flipped-aurora/gin-vue-admin/server/global" "github.com/flipped-aurora/gin-vue-admin/server/model/system" @@ -105,8 +107,12 @@ func (dictionaryService *DictionaryService) GetSysDictionary(Type string, Id uin //@param: info request.SysDictionarySearch //@return: err error, list interface{}, total int64 -func (dictionaryService *DictionaryService) GetSysDictionaryInfoList() (list interface{}, err error) { +func (dictionaryService *DictionaryService) GetSysDictionaryInfoList(c *gin.Context, req request.SysDictionarySearch) (list interface{}, err error) { var sysDictionarys []system.SysDictionary - err = global.GVA_DB.Find(&sysDictionarys).Error + query := global.GVA_DB.WithContext(c) + if req.Name != "" { + query = query.Where("name LIKE ? OR type LIKE ?", "%"+req.Name+"%", "%"+req.Name+"%") + } + err = query.Find(&sysDictionarys).Error return sysDictionarys, err } diff --git a/web/.env.development b/web/.env.development index b80eedd3fd..25ffe1f7f2 100644 --- a/web/.env.development +++ b/web/.env.development @@ -4,7 +4,7 @@ VITE_SERVER_PORT = 8888 VITE_BASE_API = /api VITE_FILE_API = /api VITE_BASE_PATH = http://127.0.0.1 -VITE_POSITION = close +VITE_POSITION = open VITE_EDITOR = code // VITE_EDITOR = webstorm 如果使用webstorm开发且要使用dom定位到代码行功能 请先自定添加 webstorm到环境变量 再将VITE_EDITOR值修改为webstorm // 如果使用docker-compose开发模式,设置为下面的地址或本机主机IP diff --git a/web/src/App.vue b/web/src/App.vue index ed19e85413..5a2214e9f8 100644 --- a/web/src/App.vue +++ b/web/src/App.vue @@ -1,5 +1,8 @@ diff --git a/web/src/directive/clickOutSide.js b/web/src/directive/clickOutSide.js new file mode 100644 index 0000000000..d1bd5022be --- /dev/null +++ b/web/src/directive/clickOutSide.js @@ -0,0 +1,43 @@ +export default { + install: (app) => { + app.directive('click-outside', { + mounted(el, binding) { + const handler = (e) => { + // 如果绑定的元素包含事件目标,或元素已经被移除,则不触发 + if (!el || el.contains(e.target) || e.target === el) return + // 支持函数或对象 { handler: fn, exclude: [el1, el2], capture: true } + const value = binding.value + if (value && typeof value === 'object') { + if ( + value.exclude && + value.exclude.some( + (ex) => ex && ex.contains && ex.contains(e.target) + ) + ) + return + if (typeof value.handler === 'function') value.handler(e) + } else if (typeof value === 'function') { + value(e) + } + } + + // 存到 el 上,便于解绑 + el.__clickOutsideHandler__ = handler + + // 延迟注册,避免 mounted 时触发(比如当点击就是触发绑定动作时) + setTimeout(() => { + document.addEventListener('mousedown', handler) + document.addEventListener('touchstart', handler) + }, 0) + }, + unmounted(el) { + const h = el.__clickOutsideHandler__ + if (h) { + document.removeEventListener('mousedown', h) + document.removeEventListener('touchstart', h) + delete el.__clickOutsideHandler__ + } + } + }) + } +} diff --git a/web/src/main.js b/web/src/main.js index 18ba0723e4..8ecb37bd7a 100644 --- a/web/src/main.js +++ b/web/src/main.js @@ -1,6 +1,6 @@ import './style/element_visiable.scss' import 'element-plus/theme-chalk/dark/css-vars.css' -import 'uno.css'; +import 'uno.css' import { createApp } from 'vue' import ElementPlus from 'element-plus' @@ -12,11 +12,19 @@ import router from '@/router/index' import '@/permission' import run from '@/core/gin-vue-admin.js' import auth from '@/directive/auth' +import clickOutSide from '@/directive/clickOutSide' import { store } from '@/pinia' import App from './App.vue' const app = createApp(App) app.config.productionTip = false -app.use(run).use(ElementPlus).use(store).use(auth).use(router).mount('#app') +app + .use(run) + .use(ElementPlus) + .use(store) + .use(auth) + .use(clickOutSide) + .use(router) + .mount('#app') export default app diff --git a/web/src/view/example/upload/upload.vue b/web/src/view/example/upload/upload.vue index eae676a0eb..fdc86825ab 100644 --- a/web/src/view/example/upload/upload.vue +++ b/web/src/view/example/upload/upload.vue @@ -1,26 +1,46 @@