Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion server/api/v1/system/sys_dictionary.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)
Expand Down Expand Up @@ -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)
Expand Down
3 changes: 1 addition & 2 deletions server/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -280,4 +279,4 @@ mcp:
version: v1.0.0
sse_path: /sse
message_path: /message
url_prefix: ''
url_prefix: ''
1 change: 0 additions & 1 deletion server/model/common/response/response.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ const (
)

func Result(code int, data interface{}, msg string, c *gin.Context) {
// 开始时间
c.JSON(http.StatusOK, Response{
code,
data,
Expand Down
5 changes: 5 additions & 0 deletions server/model/system/request/sys_dictionary.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package request

type SysDictionarySearch struct {
Name string `json:"name" form:"name" gorm:"column:name;comment:字典名(中)"` // 字典名(中)
}
10 changes: 8 additions & 2 deletions server/service/system/sys_dictionary.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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
}
2 changes: 1 addition & 1 deletion web/.env.development
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
55 changes: 29 additions & 26 deletions web/src/App.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
<template>
<div id="app" class="bg-gray-50 text-slate-700 dark:text-slate-500 dark:bg-slate-800">
<div
id="app"
class="bg-gray-50 text-slate-700 !dark:text-slate-500 dark:bg-slate-800"
>
<el-config-provider :locale="zhCn">
<router-view />
<Application />
Expand All @@ -8,36 +11,36 @@
</template>

<script setup>
import zhCn from 'element-plus/dist/locale/zh-cn.mjs'
import Application from '@/components/application/index.vue'
import { useAppStore } from '@/pinia'
import zhCn from 'element-plus/dist/locale/zh-cn.mjs'
import Application from '@/components/application/index.vue'
import { useAppStore } from '@/pinia'

useAppStore()
defineOptions({
name: 'App'
})
useAppStore()
defineOptions({
name: 'App'
})
</script>
<style lang="scss">
// 引入初始化样式
#app {
height: 100vh;
overflow: hidden;
font-weight: 400 !important;
}
// 引入初始化样式
#app {
height: 100vh;
overflow: hidden;
font-weight: 400 !important;
}

.el-button {
font-weight: 400 !important;
}
.el-button {
font-weight: 400 !important;
}

.gva-body-h {
min-height: calc(100% - 3rem);
}
.gva-body-h {
min-height: calc(100% - 3rem);
}

.gva-container {
height: calc(100% - 2.5rem);
}
.gva-container {
height: calc(100% - 2.5rem);
}

.gva-container2 {
height: calc(100% - 4.5rem);
}
.gva-container2 {
height: calc(100% - 4.5rem);
}
</style>
43 changes: 43 additions & 0 deletions web/src/directive/clickOutSide.js
Original file line number Diff line number Diff line change
@@ -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__
}
}
})
}
}
12 changes: 10 additions & 2 deletions web/src/main.js
Original file line number Diff line number Diff line change
@@ -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'

Expand All @@ -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
Loading