Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

发布模式时,gin不再输出路由log #1559

Merged
merged 3 commits into from
Oct 10, 2023
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
8 changes: 7 additions & 1 deletion server/initialize/router.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,13 @@ import (
// 初始化总路由

func Routers() *gin.Engine {
Router := gin.Default()

// 设置为发布模式
if global.GVA_CONFIG.System.Env == "public" {
gin.SetMode(gin.ReleaseMode) //DebugMode ReleaseMode TestMode
}
Router := gin.New()

InstallPlugin(Router) // 安装插件
systemRouter := router.RouterGroupApp.System
exampleRouter := router.RouterGroupApp.Example
Expand Down
4 changes: 3 additions & 1 deletion server/resource/autocode_template/server/model.go.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@ type {{.StructName}} struct {
{{.FieldName}} string `json:"{{.FieldJson}}" form:"{{.FieldJson}}" gorm:"column:{{.ColumnName}};type:enum({{.DataTypeLong}});comment:{{.Comment}};"`
{{- else if eq .FieldType "picture" }}
{{.FieldName}} string `json:"{{.FieldJson}}" form:"{{.FieldJson}}" gorm:"column:{{.ColumnName}};comment:{{.Comment}};{{- if .DataTypeLong -}}size:{{.DataTypeLong}};{{- end -}}"`
{{- else if eq .FieldType "file" }}
{{- else if eq .FieldType "video" }}
{{.FieldName}} string `json:"{{.FieldJson}}" form:"{{.FieldJson}}" gorm:"column:{{.ColumnName}};comment:{{.Comment}};{{- if .DataTypeLong -}}size:{{.DataTypeLong}};{{- end -}}"`
{{- else if eq .FieldType "file" }}
{{.FieldName}} datatypes.JSON `json:"{{.FieldJson}}" form:"{{.FieldJson}}" gorm:"column:{{.ColumnName}};comment:{{.Comment}};{{- if .DataTypeLong -}}size:{{.DataTypeLong}};{{- end -}}"`
{{- else if eq .FieldType "pictures" }}
{{.FieldName}} datatypes.JSON `json:"{{.FieldJson}}" form:"{{.FieldJson}}" gorm:"column:{{.ColumnName}};comment:{{.Comment}};{{- if .DataTypeLong -}}size:{{.DataTypeLong}};{{- end -}}"`
Expand Down
10 changes: 8 additions & 2 deletions server/resource/autocode_template/web/form.vue.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,13 @@
</el-select>
{{- end }}
{{- if eq .FieldType "picture" }}
<SelectImage v-model="formData.{{ .FieldJson }}" />
<SelectImage v-model="formData.{{ .FieldJson }}" file-type="image"/>
{{- end }}
{{- if eq .FieldType "video" }}
<SelectImage v-model="formData.{{ .FieldJson }}" file-type="video"/>
{{- end }}
{{- if eq .FieldType "pictures" }}
<SelectImage v-model="formData.{{ .FieldJson }}" multiple />
<SelectImage v-model="formData.{{ .FieldJson }}" multiple file-type="image"/>
{{- end }}
{{- if eq .FieldType "file" }}
<SelectFile v-model="formData.{{ .FieldJson }}" />
Expand Down Expand Up @@ -108,6 +111,9 @@ const formData = ref({
{{- if eq .FieldType "picture" }}
{{.FieldJson}}: "",
{{- end }}
{{- if eq .FieldType "video" }}
{{.FieldJson}}: "",
{{- end }}
{{- if eq .FieldType "pictures" }}
{{.FieldJson}}: [],
{{- end }}
Expand Down
41 changes: 39 additions & 2 deletions server/resource/autocode_template/web/table.vue.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,18 @@
</div>
</template>
</el-table-column>
{{- else if eq .FieldType "video" }}
<el-table-column label="{{.FieldDesc}}" width="200">
<template #default="scope">
<video
style="width: 100px; height: 100px"
muted
preload="metadata"
>
<source :src="getUrl(scope.row.{{.FieldJson}}) + '#t=1'">
</video>
</template>
</el-table-column>
{{- else if eq .FieldType "richtext" }}
<el-table-column label="{{.FieldDesc}}" width="200">
<template #default="scope">
Expand Down Expand Up @@ -215,11 +227,24 @@
</el-select>
{{- end }}
{{- if eq .FieldType "picture" }}
<SelectImage v-model="formData.{{ .FieldJson }}" />
<SelectImage
v-model="formData.{{ .FieldJson }}"
file-type="image"
/>
{{- end }}
{{- if eq .FieldType "pictures" }}
<SelectImage v-model="formData.{{ .FieldJson }}" multiple />
<SelectImage
multiple
v-model="formData.{{ .FieldJson }}"
file-type="image"
/>
{{- end }}
{{- if eq .FieldType "video" }}
<SelectImage
v-model="formData.{{ .FieldJson }}"
file-type="video"
/>
{{- end }}
{{- if eq .FieldType "file" }}
<SelectFile v-model="formData.{{ .FieldJson }}" />
{{- end }}
Expand All @@ -244,6 +269,14 @@
{{"{{"}} filterDict(formData.{{.FieldJson}},{{.DictType}}Options) {{"}}"}}
{{- else if eq .FieldType "picture" }}
<el-image style="width: 50px; height: 50px" :preview-src-list="ReturnArrImg(formData.{{ .FieldJson }})" :src="getUrl(formData.{{ .FieldJson }})" fit="cover" />
{{- else if eq .FieldType "video" }}
<video
style="width: 50px; height: 50px"
muted
preload="metadata"
>
<source :src="getUrl(formData.{{ .FieldJson }}) + '#t=1'">
</video>
{{- else if eq .FieldType "pictures" }}
<el-image style="width: 50px; height: 50px; margin-right: 10px" :preview-src-list="ReturnArrImg(formData.{{ .FieldJson }})" :initial-index="index" v-for="(item,index) in formData.{{ .FieldJson }}" :key="index" :src="getUrl(item)" fit="cover" />
{{- else if eq .FieldType "file" }}
Expand Down Expand Up @@ -332,6 +365,9 @@ const formData = ref({
{{- if eq .FieldType "picture" }}
{{.FieldJson}}: "",
{{- end }}
{{- if eq .FieldType "video" }}
{{.FieldJson}}: "",
{{- end }}
{{- if eq .FieldType "pictures" }}
{{.FieldJson}}: [],
{{- end }}
Expand All @@ -341,6 +377,7 @@ const formData = ref({
{{- end }}
})


// 验证规则
const rule = reactive({
{{- range .Fields }}
Expand Down
6 changes: 6 additions & 0 deletions server/service/system/sys_auto_code.go
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,9 @@ func (autoCodeService *AutoCodeService) PreviewTemp(autoCode system.AutoCodeStru
if autoCode.Fields[i].FieldType == "picture" {
autoCode.HasPic = true
}
if autoCode.Fields[i].FieldType == "video" {
autoCode.HasPic = true
}
if autoCode.Fields[i].FieldType == "richtext" {
autoCode.HasRichText = true
}
Expand Down Expand Up @@ -250,6 +253,9 @@ func (autoCodeService *AutoCodeService) CreateTemp(autoCode system.AutoCodeStruc
if autoCode.Fields[i].FieldType == "picture" {
autoCode.HasPic = true
}
if autoCode.Fields[i].FieldType == "video" {
autoCode.HasPic = true
}
if autoCode.Fields[i].FieldType == "richtext" {
autoCode.HasRichText = true
}
Expand Down
8 changes: 7 additions & 1 deletion server/service/system/sys_casbin.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,14 @@ func (casbinService *CasbinService) UpdateCasbin(AuthorityID uint, casbinInfos [
authorityId := strconv.Itoa(int(AuthorityID))
casbinService.ClearCasbin(0, authorityId)
rules := [][]string{}
//做权限去重处理
deduplicateMap := make(map[string]bool)
for _, v := range casbinInfos {
rules = append(rules, []string{authorityId, v.Path, v.Method})
key := authorityId + v.Path + v.Method
if _, ok := deduplicateMap[key]; !ok {
deduplicateMap[key] = true
rules = append(rules, []string{authorityId, v.Path, v.Method})
}
}
e := casbinService.Casbin()
success, _ := e.AddPolicies(rules)
Expand Down
1 change: 0 additions & 1 deletion web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
"spark-md5": "^3.0.2",
"tailwindcss": "^3.3.3",
"vue": "^3.3.4",
"vue-demi": "^0.13.11",
"vue-router": "^4.2.4"
},
"devDependencies": {
Expand Down
45 changes: 21 additions & 24 deletions web/src/components/office/index.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<template>
<div class="office border border-solid border-gray-100 h-full">
<div class="border border-solid border-gray-100 h-full w-full">
<el-row>
<div v-if="ext==='docx'">
<Docx v-model="fullFileURL" />
Expand All @@ -11,50 +11,47 @@
<Excel v-model="fullFileURL" />
</div>
<div v-else-if="ext==='image'">
<el-image :src="fullFileURL" lazy/>
<el-image
:src="fullFileURL"
lazy
/>
</div>
</el-row>

</div>
</template>
<script>
export default {
name: "Office"
name: 'Office'
}
</script>
<script setup>
import {ref, watch, computed} from "vue"
import Docx from "@/components/office/docx.vue";
import Pdf from "@/components/office/pdf.vue";
import Excel from "@/components/office/excel.vue";
import { ref, watch, computed } from 'vue'
import Docx from '@/components/office/docx.vue'
import Pdf from '@/components/office/pdf.vue'
import Excel from '@/components/office/excel.vue'

const path = ref(import.meta.env.VITE_BASE_API)

const props = defineProps({
modelValue: {
type: String,
default: () => ""
default: () => ''
}
})
const fileUrl = ref("")
const ext = ref("")
const fileUrl = ref('')
const ext = ref('')
watch(
() => props.modelValue,
val => {
fileUrl.value = val
const fileExt = val.split(".")[1] || ''
const image = ['png', 'jpg', 'jpge', 'gif']
ext.value = image.includes(fileExt) ? 'image' : fileExt
},
{immediate: true}
() => props.modelValue,
val => {
fileUrl.value = val
const fileExt = val.split('.')[1] || ''
const image = ['png', 'jpg', 'jpge', 'gif']
ext.value = image.includes(fileExt) ? 'image' : fileExt
},
{ immediate: true }
)
const fullFileURL = computed(() => {
return path.value + '/' + fileUrl.value
})
</script>
<style lang="scss" scoped>
.office {
height: 400px;
width: 100%;
}
</style>
Loading
Loading