From 97a39ba60691c6810097911a4187e25d136e38d2 Mon Sep 17 00:00:00 2001 From: task <121913992@qq.com> Date: Mon, 6 Jan 2025 21:36:02 +0800 Subject: [PATCH 1/6] =?UTF-8?q?=E5=B0=86=E5=8F=82=E6=95=B0=E7=BC=93?= =?UTF-8?q?=E5=AD=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- web/src/pinia/modules/params.js | 31 ++++++++++++++++++++ web/src/utils/dictionary.js | 8 ----- web/src/utils/params.js | 14 +++++++++ web/src/view/superAdmin/params/sysParams.vue | 4 ++- 4 files changed, 48 insertions(+), 9 deletions(-) create mode 100644 web/src/pinia/modules/params.js create mode 100644 web/src/utils/params.js diff --git a/web/src/pinia/modules/params.js b/web/src/pinia/modules/params.js new file mode 100644 index 0000000000..54cdbf97a8 --- /dev/null +++ b/web/src/pinia/modules/params.js @@ -0,0 +1,31 @@ +import { getSysParam } from '@/api/sysParams' +import { defineStore } from 'pinia' +import { ref } from 'vue' + +export const useParamsStore = defineStore('params', () => { + const paramsMap = ref({}) + + const setParamsMap = (paramsRes) => { + paramsMap.value = { ...paramsMap.value, ...paramsRes } + } + + const getParams = async(key) => { + if (paramsMap.value[key] && paramsMap.value[key].length) { + return paramsMap.value[key] + } else { + const res = await getSysParam({ key }) + if (res.code === 0) { + const paramsRes = {} + paramsRes[key] = res.data.value + setParamsMap(paramsRes) + return paramsMap.value[key] + } + } + } + + return { + paramsMap, + setParamsMap, + getParams + } +}) diff --git a/web/src/utils/dictionary.js b/web/src/utils/dictionary.js index 679a6b9886..89ec656e43 100644 --- a/web/src/utils/dictionary.js +++ b/web/src/utils/dictionary.js @@ -1,5 +1,4 @@ import { useDictionaryStore } from '@/pinia/modules/dictionary' -import { getSysParam } from '@/api/sysParams' // 获取字典方法 使用示例 getDict('sex').then(res) 或者 async函数下 const res = await getDict('sex') export const getDict = async (type) => { const dictionaryStore = useDictionaryStore() @@ -25,10 +24,3 @@ export const showDictLabel = ( }) return Reflect.has(dictMap, code) ? dictMap[code] : '' } - -export const getParams = async (key) => { - const res = await getSysParam({ key }) - if (res.code === 0) { - return res.data.value - } -} diff --git a/web/src/utils/params.js b/web/src/utils/params.js new file mode 100644 index 0000000000..b03d539a39 --- /dev/null +++ b/web/src/utils/params.js @@ -0,0 +1,14 @@ +import { useParamsStore } from '@/pinia/modules/params' +/* + * 获取参数方法 使用示例 getParams('key').then(res) 或者 async函数下 const res = await getParams('key') + * const res = ref('') + * const fun = async () => { + * res.value = await getParams('test') + * } + * fun() + */ +export const getParams = async(key) => { + const paramsStore = useParamsStore() + await paramsStore.getParams(key) + return paramsStore.paramsMap[key] +} diff --git a/web/src/view/superAdmin/params/sysParams.vue b/web/src/view/superAdmin/params/sysParams.vue index 1feeda1e68..89fe6f95e4 100644 --- a/web/src/view/superAdmin/params/sysParams.vue +++ b/web/src/view/superAdmin/params/sysParams.vue @@ -1,5 +1,6 @@ @@ -16,6 +17,7 @@ import ImageCompress from '@/utils/image' import { ElMessage } from 'element-plus' import { getBaseUrl } from '@/utils/format' + import {Upload} from "@element-plus/icons-vue"; defineOptions({ name: 'UploadImage' @@ -34,6 +36,10 @@ maxWH: { type: Number, default: 1920 // 图片长宽上限 + }, + classId: { + type: Number, + default: 0 } }) diff --git a/web/src/view/example/upload/upload.vue b/web/src/view/example/upload/upload.vue index 42a4c9161d..9124308197 100644 --- a/web/src/view/example/upload/upload.vue +++ b/web/src/view/example/upload/upload.vue @@ -1,161 +1,232 @@ +} + +const handleNodeClick = (node) => { + search.value.keyword = null + search.value.classId = node.ID + page.value = 1 + getTableData() +} - +} + +const categoryDialogVisible = ref(false) +const categoryFormData = ref({ + ID: 0, + pid: 0, + name: '' +}) + +const categoryForm = ref(null) +const rules = ref({ + name: [ + {required: true, message: '请输入分类名称', trigger: 'blur'}, + {max: 20, message: '最多20位字符', trigger: 'blur'} + ] +}) + +const addCategoryFun = (category) => { + categoryDialogVisible.value = true + categoryFormData.value.ID = 0 + categoryFormData.value.pid = category.ID +} + +const editCategory = (category) => { + categoryFormData.value = { + ID: category.ID, + pid: category.pid, + name: category.name + } + categoryDialogVisible.value = true +} + +const deleteCategoryFun = async (id) => { + const res = await deleteCategory({id: id}) + if (res.code === 0) { + ElMessage.success({type: 'success', message: '删除成功'}) + await fetchCategories() + } +} + +const confirmAddCategory = async () => { + categoryForm.value.validate(async valid => { + if (valid) { + const res = await addCategory(categoryFormData.value) + if (res.code === 0) { + ElMessage({type: 'success', message: '操作成功'}) + await fetchCategories() + closeAddCategoryDialog() + } + } + }) +} + +const closeAddCategoryDialog = () => { + categoryDialogVisible.value = false + categoryFormData.value = { + ID: 0, + pid: 0, + name: '' + } +} + +fetchCategories() + From 6e3156758d73f0af3b6552945f759702fb8ba70a Mon Sep 17 00:00:00 2001 From: task <121913992@qq.com> Date: Wed, 8 Jan 2025 10:26:07 +0800 Subject: [PATCH 3/6] =?UTF-8?q?=E7=BC=96=E8=BE=91=E5=8F=AF=E9=80=89?= =?UTF-8?q?=E6=8B=A9=E5=88=86=E7=B1=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../components/selectImage/selectImage.vue | 61 ++++++++----------- web/src/view/example/upload/upload.vue | 61 ++++++++----------- 2 files changed, 48 insertions(+), 74 deletions(-) diff --git a/web/src/components/selectImage/selectImage.vue b/web/src/components/selectImage/selectImage.vue index 1f76d17501..601686a810 100644 --- a/web/src/components/selectImage/selectImage.vue +++ b/web/src/components/selectImage/selectImage.vue @@ -14,14 +14,6 @@
-
-
- 全部分类 -
- - - -
{{ data.name }}
- - - - + + + @@ -113,6 +104,16 @@ draggable > + + + @@ -296,14 +297,21 @@ const deleteCheck = (item) => { const defaultProps = { children: 'children', label: 'name', - value: 'id' + value: 'ID' } const categories = ref([]) const fetchCategories = async() => { const res = await getCategoryList() + let data = { + name: '全部分类', + ID: 0, + pid: 0, + children:[] + } if (res.code === 0) { categories.value = res.data + categories.value.unshift(data) } } @@ -314,33 +322,12 @@ const handleNodeClick = (node) => { getImageList() } -const getAll = () => { - search.value.keyword = null - search.value.classId = 0 - page.value = 1 - getImageList() -} - const onSuccess = () => { search.value.keyword = null page.value = 1 getImageList() } -const handleCommand = (category, command) => { - switch (command) { - case 'add': - addCategoryFun(category) - break - case 'edit': - editCategory(category) - break - case 'delete': - deleteCategoryFun(category.ID) - break - } -} - const categoryDialogVisible = ref(false) const categoryFormData = ref({ ID: 0, diff --git a/web/src/view/example/upload/upload.vue b/web/src/view/example/upload/upload.vue index 9124308197..8836d5d191 100644 --- a/web/src/view/example/upload/upload.vue +++ b/web/src/view/example/upload/upload.vue @@ -3,14 +3,6 @@
-
-
- 全部分类 -
- - - -
{{ data.name }}
- - - - + + + @@ -139,6 +130,16 @@ draggable > + + + @@ -344,13 +345,6 @@ const importUrlFunc = () => { }) } -const getAll = () => { - search.value.keyword = null - search.value.classId = 0 - page.value = 1 - getTableData() -} - const onSuccess = () => { search.value.keyword = null page.value = 1 @@ -360,14 +354,21 @@ const onSuccess = () => { const defaultProps = { children: 'children', label: 'name', - value: 'id' + value: 'ID' } const categories = ref([]) const fetchCategories = async () => { const res = await getCategoryList() + let data = { + name: '全部分类', + ID: 0, + pid: 0, + children:[] + } if (res.code === 0) { categories.value = res.data + categories.value.unshift(data) } } @@ -378,20 +379,6 @@ const handleNodeClick = (node) => { getTableData() } -const handleCommand = (category, command) => { - switch (command) { - case 'add': - addCategoryFun(category) - break - case 'edit': - editCategory(category) - break - case 'delete': - deleteCategoryFun(category.ID) - break - } -} - const categoryDialogVisible = ref(false) const categoryFormData = ref({ ID: 0, From fcb58dffae1852fbfab414b6868b17ab464d2031 Mon Sep 17 00:00:00 2001 From: task <121913992@qq.com> Date: Thu, 9 Jan 2025 09:27:04 +0800 Subject: [PATCH 4/6] =?UTF-8?q?fix=E5=88=86=E7=B1=BB=E7=BC=96=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/service/example/exa_attachment_category.go | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/server/service/example/exa_attachment_category.go b/server/service/example/exa_attachment_category.go index 5c5df5d848..1e74fc9425 100644 --- a/server/service/example/exa_attachment_category.go +++ b/server/service/example/exa_attachment_category.go @@ -12,12 +12,14 @@ type AttachmentCategoryService struct{} // AddCategory 创建/更新的分类 func (a *AttachmentCategoryService) AddCategory(req *example.ExaAttachmentCategory) (err error) { // 检查是否已存在相同名称的分类 - if (!errors.Is(global.GVA_DB.Take(&example.ExaAttachmentCategory{}, "name = ?", req.Name).Error, gorm.ErrRecordNotFound)) { + if (!errors.Is(global.GVA_DB.Take(&example.ExaAttachmentCategory{}, "name = ? and pid = ?", req.Name, req.Pid).Error, gorm.ErrRecordNotFound)) { return errors.New("分类名称已存在") } - if req.ID > 0 { - if err = global.GVA_DB.Model(&example.ExaAttachmentCategory{}).Where("id = ?", req.ID).Update("name", req.Name).Error; err != nil { + if err = global.GVA_DB.Model(&example.ExaAttachmentCategory{}).Where("id = ?", req.ID).Updates(&example.ExaAttachmentCategory{ + Name: req.Name, + Pid: req.Pid, + }).Error; err != nil { return err } } else { From 2acca334d40aa0ed016d5c9af3d0ba826dbe5c1c Mon Sep 17 00:00:00 2001 From: task <121913992@qq.com> Date: Wed, 22 Jan 2025 23:18:21 +0800 Subject: [PATCH 5/6] =?UTF-8?q?=E4=BF=A9=E4=B8=AAuuid=E5=BA=93=E5=90=88?= =?UTF-8?q?=E5=B9=B6=E4=B8=80=E4=B8=AA=EF=BC=8C=E6=9B=B4=E6=96=B0=E5=BA=93?= =?UTF-8?q?=E5=88=B0=E5=BD=93=E5=89=8D=E7=89=88=E6=9C=AC=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/go.mod | 133 ++++++++++----------- server/middleware/jwt.go | 2 +- server/model/system/request/jwt.go | 6 +- server/model/system/sys_user.go | 2 +- server/service/system/auto_code_plugin.go | 2 +- server/service/system/sys_initdb_mssql.go | 4 +- server/service/system/sys_initdb_mysql.go | 4 +- server/service/system/sys_initdb_pgsql.go | 4 +- server/service/system/sys_initdb_sqlite.go | 4 +- server/service/system/sys_user.go | 4 +- server/source/system/user.go | 6 +- server/utils/claims.go | 2 +- server/utils/jwt.go | 35 +++--- 13 files changed, 103 insertions(+), 105 deletions(-) diff --git a/server/go.mod b/server/go.mod index 40cc8e953a..55b4992d45 100644 --- a/server/go.mod +++ b/server/go.mod @@ -1,54 +1,52 @@ module github.com/flipped-aurora/gin-vue-admin/server -go 1.22.0 - -toolchain go1.22.2 +go 1.23 require ( github.com/aliyun/aliyun-oss-go-sdk v3.0.2+incompatible - github.com/aws/aws-sdk-go v1.55.5 - github.com/casbin/casbin/v2 v2.100.0 - github.com/casbin/gorm-adapter/v3 v3.28.0 - github.com/fsnotify/fsnotify v1.7.0 + github.com/aws/aws-sdk-go v1.55.6 + github.com/casbin/casbin/v2 v2.103.0 + github.com/casbin/gorm-adapter/v3 v3.32.0 + github.com/fsnotify/fsnotify v1.8.0 github.com/fvbock/endless v0.0.0-20170109170031-447134032cb6 github.com/gin-gonic/gin v1.10.0 github.com/glebarez/sqlite v1.11.0 github.com/go-sql-driver/mysql v1.8.1 - github.com/goccy/go-json v0.10.3 - github.com/gofrs/uuid/v5 v5.3.0 - github.com/golang-jwt/jwt/v4 v4.5.0 + github.com/goccy/go-json v0.10.4 + github.com/golang-jwt/jwt/v5 v5.2.1 + github.com/google/uuid v1.6.0 github.com/gookit/color v1.5.4 github.com/huaweicloud/huaweicloud-sdk-go-obs v3.24.9+incompatible github.com/jordan-wright/email v4.0.1-0.20210109023952-943e75fe5223+incompatible - github.com/mholt/archiver/v4 v4.0.0-alpha.8 - github.com/minio/minio-go/v7 v7.0.78 - github.com/mojocn/base64Captcha v1.3.6 - github.com/otiai10/copy v1.14.0 + github.com/mholt/archiver/v4 v4.0.0-alpha.9 + github.com/minio/minio-go/v7 v7.0.84 + github.com/mojocn/base64Captcha v1.3.8 + github.com/otiai10/copy v1.14.1 github.com/pkg/errors v0.9.1 - github.com/qiniu/go-sdk/v7 v7.23.0 - github.com/qiniu/qmgo v1.1.8 - github.com/redis/go-redis/v9 v9.6.2 + github.com/qiniu/go-sdk/v7 v7.25.2 + github.com/qiniu/qmgo v1.1.9 + github.com/redis/go-redis/v9 v9.7.0 github.com/robfig/cron/v3 v3.0.1 github.com/shirou/gopsutil/v3 v3.24.5 github.com/songzhibin97/gkit v1.2.13 github.com/spf13/viper v1.19.0 - github.com/stretchr/testify v1.9.0 + github.com/stretchr/testify v1.10.0 github.com/swaggo/files v1.0.1 github.com/swaggo/gin-swagger v1.6.0 - github.com/swaggo/swag v1.16.3 - github.com/tencentyun/cos-go-sdk-v5 v0.7.55 - github.com/unrolled/secure v1.16.0 + github.com/swaggo/swag v1.16.4 + github.com/tencentyun/cos-go-sdk-v5 v0.7.60 + github.com/unrolled/secure v1.17.0 github.com/xuri/excelize/v2 v2.9.0 - go.mongodb.org/mongo-driver v1.17.1 + go.mongodb.org/mongo-driver v1.17.2 go.uber.org/automaxprocs v1.6.0 go.uber.org/zap v1.27.0 - golang.org/x/crypto v0.28.0 - golang.org/x/sync v0.8.0 - golang.org/x/text v0.19.0 - gorm.io/datatypes v1.2.3 + golang.org/x/crypto v0.32.0 + golang.org/x/sync v0.10.0 + golang.org/x/text v0.21.0 + gorm.io/datatypes v1.2.5 gorm.io/driver/mysql v1.5.7 - gorm.io/driver/postgres v1.5.9 - gorm.io/driver/sqlserver v1.5.3 + gorm.io/driver/postgres v1.5.11 + gorm.io/driver/sqlserver v1.5.4 gorm.io/gen v0.3.26 gorm.io/gorm v1.25.12 ) @@ -57,28 +55,26 @@ require ( filippo.io/edwards25519 v1.1.0 // indirect github.com/BurntSushi/toml v1.4.0 // indirect github.com/KyleBanks/depth v1.2.1 // indirect + github.com/STARRY-S/zip v0.1.0 // indirect github.com/alex-ant/gomath v0.0.0-20160516115720-89013a210a82 // indirect github.com/andybalholm/brotli v1.1.1 // indirect - github.com/bmatcuk/doublestar/v4 v4.7.1 // indirect + github.com/bmatcuk/doublestar/v4 v4.8.0 // indirect github.com/bodgit/plumbing v1.3.0 // indirect - github.com/bodgit/sevenzip v1.5.2 // indirect + github.com/bodgit/sevenzip v1.6.0 // indirect github.com/bodgit/windows v1.0.1 // indirect - github.com/bytedance/sonic v1.12.3 // indirect - github.com/bytedance/sonic/loader v0.2.0 // indirect - github.com/casbin/govaluate v1.2.0 // indirect + github.com/bytedance/sonic v1.12.7 // indirect + github.com/bytedance/sonic/loader v0.2.3 // indirect + github.com/casbin/govaluate v1.3.0 // indirect github.com/cespare/xxhash/v2 v2.3.0 // indirect github.com/clbanning/mxj v1.8.4 // indirect - github.com/cloudwego/base64x v0.1.4 // indirect - github.com/cloudwego/iasm v0.2.0 // indirect + github.com/cloudwego/base64x v0.1.5 // indirect github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f // indirect - github.com/dsnet/compress v0.0.1 // indirect + github.com/dsnet/compress v0.0.2-0.20230904184137-39efe44ab707 // indirect github.com/dustin/go-humanize v1.0.1 // indirect - github.com/elastic/go-sysinfo v1.14.2 // indirect - github.com/elastic/go-windows v1.0.2 // indirect - github.com/gabriel-vasile/mimetype v1.4.6 // indirect + github.com/gabriel-vasile/mimetype v1.4.8 // indirect github.com/gammazero/toposort v0.1.1 // indirect - github.com/gin-contrib/sse v0.1.0 // indirect + github.com/gin-contrib/sse v1.0.0 // indirect github.com/glebarez/go-sqlite v1.22.0 // indirect github.com/go-ini/ini v1.67.0 // indirect github.com/go-ole/go-ole v1.3.0 // indirect @@ -88,21 +84,20 @@ require ( github.com/go-openapi/swag v0.23.0 // indirect github.com/go-playground/locales v0.14.1 // indirect github.com/go-playground/universal-translator v0.18.1 // indirect - github.com/go-playground/validator/v10 v10.22.1 // indirect + github.com/go-playground/validator/v10 v10.24.0 // indirect github.com/gofrs/flock v0.12.1 // indirect github.com/golang-sql/civil v0.0.0-20220223132316-b832511892a9 // indirect github.com/golang-sql/sqlexp v0.1.0 // indirect github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0 // indirect github.com/golang/snappy v0.0.4 // indirect github.com/google/go-querystring v1.1.0 // indirect - github.com/google/uuid v1.6.0 // indirect github.com/hashicorp/errwrap v1.1.0 // indirect github.com/hashicorp/go-multierror v1.1.1 // indirect github.com/hashicorp/golang-lru/v2 v2.0.7 // indirect github.com/hashicorp/hcl v1.0.0 // indirect github.com/jackc/pgpassfile v1.0.0 // indirect github.com/jackc/pgservicefile v0.0.0-20240606120523-5a60cdf6a761 // indirect - github.com/jackc/pgx/v5 v5.7.1 // indirect + github.com/jackc/pgx/v5 v5.7.2 // indirect github.com/jackc/puddle/v2 v2.2.2 // indirect github.com/jinzhu/inflection v1.0.0 // indirect github.com/jinzhu/now v1.1.5 // indirect @@ -110,14 +105,14 @@ require ( github.com/josharian/intern v1.0.0 // indirect github.com/json-iterator/go v1.1.12 // indirect github.com/klauspost/compress v1.17.11 // indirect - github.com/klauspost/cpuid/v2 v2.2.8 // indirect + github.com/klauspost/cpuid/v2 v2.2.9 // indirect github.com/klauspost/pgzip v1.2.6 // indirect github.com/leodido/go-urn v1.4.0 // indirect github.com/lufia/plan9stats v0.0.0-20240909124753-873cd0166683 // indirect - github.com/magiconair/properties v1.8.7 // indirect - github.com/mailru/easyjson v0.7.7 // indirect + github.com/magiconair/properties v1.8.9 // indirect + github.com/mailru/easyjson v0.9.0 // indirect github.com/mattn/go-isatty v0.0.20 // indirect - github.com/microsoft/go-mssqldb v1.7.2 // indirect + github.com/microsoft/go-mssqldb v1.8.0 // indirect github.com/minio/md5-simd v1.1.2 // indirect github.com/mitchellh/mapstructure v1.5.0 // indirect github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect @@ -126,22 +121,23 @@ require ( github.com/montanaflynn/stats v0.7.1 // indirect github.com/mozillazg/go-httpheader v0.4.0 // indirect github.com/ncruces/go-strftime v0.1.9 // indirect - github.com/nwaples/rardecode/v2 v2.0.0-beta.3 // indirect + github.com/nwaples/rardecode/v2 v2.0.1 // indirect + github.com/otiai10/mint v1.6.3 // indirect github.com/pelletier/go-toml/v2 v2.2.3 // indirect - github.com/pierrec/lz4/v4 v4.1.21 // indirect + github.com/pierrec/lz4/v4 v4.1.22 // indirect github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect github.com/power-devops/perfstat v0.0.0-20240221224432-82ca36839d55 // indirect - github.com/prometheus/procfs v0.15.1 // indirect github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec // indirect github.com/richardlehane/mscfb v1.0.4 // indirect github.com/richardlehane/msoleps v1.0.4 // indirect github.com/rs/xid v1.6.0 // indirect - github.com/sagikazarmark/locafero v0.6.0 // indirect + github.com/sagikazarmark/locafero v0.7.0 // indirect github.com/sagikazarmark/slog-shim v0.1.0 // indirect github.com/shoenig/go-m1cpu v0.1.6 // indirect + github.com/sorairolake/lzip-go v0.3.5 // indirect github.com/sourcegraph/conc v0.3.0 // indirect - github.com/spf13/afero v1.11.0 // indirect - github.com/spf13/cast v1.7.0 // indirect + github.com/spf13/afero v1.12.0 // indirect + github.com/spf13/cast v1.7.1 // indirect github.com/spf13/pflag v1.0.5 // indirect github.com/subosito/gotenv v1.6.0 // indirect github.com/therootcompany/xz v1.0.1 // indirect @@ -154,29 +150,28 @@ require ( github.com/xdg-go/scram v1.1.2 // indirect github.com/xdg-go/stringprep v1.0.4 // indirect github.com/xo/terminfo v0.0.0-20220910002029-abceb7e1c41e // indirect - github.com/xuri/efp v0.0.0-20240408161823-9ad904a10d6d // indirect - github.com/xuri/nfp v0.0.0-20240318013403-ab9948c2c4a7 // indirect + github.com/xuri/efp v0.0.0-20241211021726-c4e992084aa6 // indirect + github.com/xuri/nfp v0.0.0-20250111060730-82a408b9aa71 // indirect github.com/youmark/pkcs8 v0.0.0-20240726163527-a2c0da244d78 // indirect github.com/yusufpapurcu/wmi v1.2.4 // indirect go.uber.org/multierr v1.11.0 // indirect go4.org v0.0.0-20230225012048-214862532bf5 // indirect - golang.org/x/arch v0.11.0 // indirect - golang.org/x/exp v0.0.0-20241009180824-f66d83c29e7c // indirect - golang.org/x/image v0.21.0 // indirect - golang.org/x/mod v0.21.0 // indirect - golang.org/x/net v0.30.0 // indirect - golang.org/x/sys v0.26.0 // indirect - golang.org/x/time v0.7.0 // indirect - golang.org/x/tools v0.26.0 // indirect - google.golang.org/protobuf v1.35.1 // indirect + golang.org/x/arch v0.13.0 // indirect + golang.org/x/exp v0.0.0-20250106191152-7588d65b2ba8 // indirect + golang.org/x/image v0.23.0 // indirect + golang.org/x/mod v0.22.0 // indirect + golang.org/x/net v0.34.0 // indirect + golang.org/x/sys v0.29.0 // indirect + golang.org/x/time v0.9.0 // indirect + golang.org/x/tools v0.29.0 // indirect + google.golang.org/protobuf v1.36.3 // indirect gopkg.in/ini.v1 v1.67.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect gorm.io/hints v1.1.2 // indirect gorm.io/plugin/dbresolver v1.5.3 // indirect - howett.net/plist v1.0.1 // indirect modernc.org/fileutil v1.3.0 // indirect - modernc.org/libc v1.61.0 // indirect - modernc.org/mathutil v1.6.0 // indirect - modernc.org/memory v1.8.0 // indirect - modernc.org/sqlite v1.33.1 // indirect + modernc.org/libc v1.61.9 // indirect + modernc.org/mathutil v1.7.1 // indirect + modernc.org/memory v1.8.2 // indirect + modernc.org/sqlite v1.34.5 // indirect ) diff --git a/server/middleware/jwt.go b/server/middleware/jwt.go index 38b56dcf33..899def9df7 100644 --- a/server/middleware/jwt.go +++ b/server/middleware/jwt.go @@ -4,7 +4,7 @@ import ( "errors" "github.com/flipped-aurora/gin-vue-admin/server/global" "github.com/flipped-aurora/gin-vue-admin/server/utils" - "github.com/golang-jwt/jwt/v4" + "github.com/golang-jwt/jwt/v5" "strconv" "time" diff --git a/server/model/system/request/jwt.go b/server/model/system/request/jwt.go index 638820244f..1e1615d1c3 100644 --- a/server/model/system/request/jwt.go +++ b/server/model/system/request/jwt.go @@ -1,11 +1,11 @@ package request import ( - "github.com/gofrs/uuid/v5" - jwt "github.com/golang-jwt/jwt/v4" + jwt "github.com/golang-jwt/jwt/v5" + "github.com/google/uuid" ) -// Custom claims structure +// CustomClaims structure type CustomClaims struct { BaseClaims BufferTime int64 diff --git a/server/model/system/sys_user.go b/server/model/system/sys_user.go index 916c6b6e0d..f20cd874e8 100644 --- a/server/model/system/sys_user.go +++ b/server/model/system/sys_user.go @@ -3,7 +3,7 @@ package system import ( "github.com/flipped-aurora/gin-vue-admin/server/global" "github.com/flipped-aurora/gin-vue-admin/server/model/common" - "github.com/gofrs/uuid/v5" + "github.com/google/uuid" ) type Login interface { diff --git a/server/service/system/auto_code_plugin.go b/server/service/system/auto_code_plugin.go index a626d09418..e52e6e6f5f 100644 --- a/server/service/system/auto_code_plugin.go +++ b/server/service/system/auto_code_plugin.go @@ -168,7 +168,7 @@ func (s *autoCodePlugin) PubPlug(plugName string) (zipPath string, err error) { // we can use the CompressedArchive type to gzip a tarball // (compression is not required; you could use Tar directly) - format := archiver.CompressedArchive{ + format := archiver.Archive{ Archival: archiver.Zip{}, } diff --git a/server/service/system/sys_initdb_mssql.go b/server/service/system/sys_initdb_mssql.go index eeeeb514fd..0865a15ad1 100644 --- a/server/service/system/sys_initdb_mssql.go +++ b/server/service/system/sys_initdb_mssql.go @@ -7,7 +7,7 @@ import ( "github.com/flipped-aurora/gin-vue-admin/server/global" "github.com/flipped-aurora/gin-vue-admin/server/model/system/request" "github.com/flipped-aurora/gin-vue-admin/server/utils" - "github.com/gofrs/uuid/v5" + "github.com/google/uuid" "github.com/gookit/color" "gorm.io/driver/sqlserver" "gorm.io/gorm" @@ -28,7 +28,7 @@ func (h MssqlInitHandler) WriteConfig(ctx context.Context) error { } global.GVA_CONFIG.System.DbType = "mssql" global.GVA_CONFIG.Mssql = c - global.GVA_CONFIG.JWT.SigningKey = uuid.Must(uuid.NewV4()).String() + global.GVA_CONFIG.JWT.SigningKey = uuid.New().String() cs := utils.StructToMap(global.GVA_CONFIG) for k, v := range cs { global.GVA_VP.Set(k, v) diff --git a/server/service/system/sys_initdb_mysql.go b/server/service/system/sys_initdb_mysql.go index 62575d385e..0b8fba1eda 100644 --- a/server/service/system/sys_initdb_mysql.go +++ b/server/service/system/sys_initdb_mysql.go @@ -13,7 +13,7 @@ import ( "github.com/flipped-aurora/gin-vue-admin/server/global" "github.com/flipped-aurora/gin-vue-admin/server/model/system/request" - "github.com/gofrs/uuid/v5" + "github.com/google/uuid" "gorm.io/driver/mysql" "gorm.io/gorm" ) @@ -32,7 +32,7 @@ func (h MysqlInitHandler) WriteConfig(ctx context.Context) error { } global.GVA_CONFIG.System.DbType = "mysql" global.GVA_CONFIG.Mysql = c - global.GVA_CONFIG.JWT.SigningKey = uuid.Must(uuid.NewV4()).String() + global.GVA_CONFIG.JWT.SigningKey = uuid.New().String() cs := utils.StructToMap(global.GVA_CONFIG) for k, v := range cs { global.GVA_VP.Set(k, v) diff --git a/server/service/system/sys_initdb_pgsql.go b/server/service/system/sys_initdb_pgsql.go index 468fadd37c..60be3d4074 100644 --- a/server/service/system/sys_initdb_pgsql.go +++ b/server/service/system/sys_initdb_pgsql.go @@ -13,7 +13,7 @@ import ( "github.com/flipped-aurora/gin-vue-admin/server/global" "github.com/flipped-aurora/gin-vue-admin/server/model/system/request" - "github.com/gofrs/uuid/v5" + "github.com/google/uuid" "gorm.io/driver/postgres" "gorm.io/gorm" ) @@ -32,7 +32,7 @@ func (h PgsqlInitHandler) WriteConfig(ctx context.Context) error { } global.GVA_CONFIG.System.DbType = "pgsql" global.GVA_CONFIG.Pgsql = c - global.GVA_CONFIG.JWT.SigningKey = uuid.Must(uuid.NewV4()).String() + global.GVA_CONFIG.JWT.SigningKey = uuid.New().String() cs := utils.StructToMap(global.GVA_CONFIG) for k, v := range cs { global.GVA_VP.Set(k, v) diff --git a/server/service/system/sys_initdb_sqlite.go b/server/service/system/sys_initdb_sqlite.go index d7a97eba50..0cab833625 100644 --- a/server/service/system/sys_initdb_sqlite.go +++ b/server/service/system/sys_initdb_sqlite.go @@ -4,7 +4,7 @@ import ( "context" "errors" "github.com/glebarez/sqlite" - "github.com/gofrs/uuid/v5" + "github.com/google/uuid" "github.com/gookit/color" "gorm.io/gorm" "path/filepath" @@ -29,7 +29,7 @@ func (h SqliteInitHandler) WriteConfig(ctx context.Context) error { } global.GVA_CONFIG.System.DbType = "sqlite" global.GVA_CONFIG.Sqlite = c - global.GVA_CONFIG.JWT.SigningKey = uuid.Must(uuid.NewV4()).String() + global.GVA_CONFIG.JWT.SigningKey = uuid.New().String() cs := utils.StructToMap(global.GVA_CONFIG) for k, v := range cs { global.GVA_VP.Set(k, v) diff --git a/server/service/system/sys_user.go b/server/service/system/sys_user.go index 65a94bbe8c..697bf54cce 100644 --- a/server/service/system/sys_user.go +++ b/server/service/system/sys_user.go @@ -10,7 +10,7 @@ import ( "github.com/flipped-aurora/gin-vue-admin/server/global" "github.com/flipped-aurora/gin-vue-admin/server/model/system" "github.com/flipped-aurora/gin-vue-admin/server/utils" - "github.com/gofrs/uuid/v5" + "github.com/google/uuid" "gorm.io/gorm" ) @@ -31,7 +31,7 @@ func (userService *UserService) Register(u system.SysUser) (userInter system.Sys } // 否则 附加uuid 密码hash加密 注册 u.Password = utils.BcryptHash(u.Password) - u.UUID = uuid.Must(uuid.NewV4()) + u.UUID = uuid.New() err = global.GVA_DB.Create(&u).Error return u, err } diff --git a/server/source/system/user.go b/server/source/system/user.go index eb9ddfc473..8f6745942a 100644 --- a/server/source/system/user.go +++ b/server/source/system/user.go @@ -5,7 +5,7 @@ import ( sysModel "github.com/flipped-aurora/gin-vue-admin/server/model/system" "github.com/flipped-aurora/gin-vue-admin/server/service/system" "github.com/flipped-aurora/gin-vue-admin/server/utils" - "github.com/gofrs/uuid/v5" + "github.com/google/uuid" "github.com/pkg/errors" "gorm.io/gorm" ) @@ -56,7 +56,7 @@ func (i *initUser) InitializeData(ctx context.Context) (next context.Context, er entities := []sysModel.SysUser{ { - UUID: uuid.Must(uuid.NewV4()), + UUID: uuid.New(), Username: "admin", Password: adminPassword, NickName: "Mr.奇淼", @@ -66,7 +66,7 @@ func (i *initUser) InitializeData(ctx context.Context) (next context.Context, er Email: "333333333@qq.com", }, { - UUID: uuid.Must(uuid.NewV4()), + UUID: uuid.New(), Username: "a303176530", Password: password, NickName: "用户1", diff --git a/server/utils/claims.go b/server/utils/claims.go index 69216700a0..6d54580f1c 100644 --- a/server/utils/claims.go +++ b/server/utils/claims.go @@ -5,7 +5,7 @@ import ( "github.com/flipped-aurora/gin-vue-admin/server/model/system" systemReq "github.com/flipped-aurora/gin-vue-admin/server/model/system/request" "github.com/gin-gonic/gin" - "github.com/gofrs/uuid/v5" + "github.com/google/uuid" "net" "time" ) diff --git a/server/utils/jwt.go b/server/utils/jwt.go index e8eb9721dc..6a1ace1254 100644 --- a/server/utils/jwt.go +++ b/server/utils/jwt.go @@ -4,7 +4,7 @@ import ( "errors" "time" - jwt "github.com/golang-jwt/jwt/v4" + jwt "github.com/golang-jwt/jwt/v5" "github.com/flipped-aurora/gin-vue-admin/server/global" "github.com/flipped-aurora/gin-vue-admin/server/model/system/request" @@ -15,10 +15,12 @@ type JWT struct { } var ( - TokenExpired = errors.New("Token is expired") - TokenNotValidYet = errors.New("Token not active yet") - TokenMalformed = errors.New("That's not even a token") - TokenInvalid = errors.New("Couldn't handle this token:") + TokenValid = errors.New("你今天看上去不错") + TokenExpired = errors.New("token已过期") + TokenNotValidYet = errors.New("token尚未激活") + TokenMalformed = errors.New("这不是一个token") + TokenSignatureInvalid = errors.New("无效签名") + TokenInvalid = errors.New("无法处理此token") ) func NewJWT() *JWT { @@ -62,18 +64,19 @@ func (j *JWT) ParseToken(tokenString string) (*request.CustomClaims, error) { token, err := jwt.ParseWithClaims(tokenString, &request.CustomClaims{}, func(token *jwt.Token) (i interface{}, e error) { return j.SigningKey, nil }) + if err != nil { - if ve, ok := err.(*jwt.ValidationError); ok { - if ve.Errors&jwt.ValidationErrorMalformed != 0 { - return nil, TokenMalformed - } else if ve.Errors&jwt.ValidationErrorExpired != 0 { - // Token is expired - return nil, TokenExpired - } else if ve.Errors&jwt.ValidationErrorNotValidYet != 0 { - return nil, TokenNotValidYet - } else { - return nil, TokenInvalid - } + switch { + case token.Valid: + return nil, TokenValid + case errors.Is(err, jwt.ErrTokenMalformed): + return nil, TokenMalformed + case errors.Is(err, jwt.ErrTokenSignatureInvalid): + return nil, TokenSignatureInvalid + case errors.Is(err, jwt.ErrTokenExpired) || errors.Is(err, jwt.ErrTokenNotValidYet): + return nil, TokenNotValidYet + default: + return nil, TokenInvalid } } if token != nil { From dae38d9b181a85d24081efff42c059dde0efc8c9 Mon Sep 17 00:00:00 2001 From: pixelmaxQM Date: Sun, 9 Feb 2025 19:56:51 +0800 Subject: [PATCH 6/6] =?UTF-8?q?fix:=E8=8F=9C=E5=8D=95=E5=A4=8D=E5=90=88?= =?UTF-8?q?=E6=A8=A1=E5=BC=8F=E4=B8=8B=EF=BC=8C=E7=82=B9=E5=87=BB=E4=B8=80?= =?UTF-8?q?=E7=BA=A7=E8=8F=9C=E5=8D=95=E4=BC=9A=E8=87=AA=E5=8A=A8=E9=80=89?= =?UTF-8?q?=E6=8B=A9=E9=A6=96=E4=BD=8D=E5=AD=90=E8=8F=9C=E5=8D=95=EF=BC=8C?= =?UTF-8?q?=E4=B8=8D=E5=90=AB=E5=AD=90=E8=8F=9C=E5=8D=95=E5=88=99=E5=AE=9A?= =?UTF-8?q?=E4=BD=8D=E4=B8=BA=E9=A1=B6=E6=A0=8F=E6=9C=AC=E4=BD=93=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- web/src/pinia/modules/router.js | 8 +------- web/src/view/layout/aside/combinationMode.vue | 6 +++++- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/web/src/pinia/modules/router.js b/web/src/pinia/modules/router.js index 8afd8c3e61..33ebbc9adf 100644 --- a/web/src/pinia/modules/router.js +++ b/web/src/pinia/modules/router.js @@ -73,6 +73,7 @@ export const useRouterStore = defineStore('router', () => { const setLeftMenu = (name) => { sessionStorage.setItem('topActive', name) topActive.value = name + leftMenu.value = [] if (menuMap[name]?.children) { leftMenu.value = menuMap[name].children } @@ -81,19 +82,12 @@ export const useRouterStore = defineStore('router', () => { watchEffect(() => { let topActive = sessionStorage.getItem('topActive') - let firstHasChildren = '' asyncRouters.value[0]?.children.forEach((item) => { if (item.hidden) return menuMap[item.name] = item - if (!firstHasChildren && item.children && item.children.length > 0) { - firstHasChildren = item.name - } topMenu.value.push({ ...item, children: [] }) }) - if (!menuMap[topActive]?.children && firstHasChildren) { - topActive = firstHasChildren - } setLeftMenu(topActive) }) diff --git a/web/src/view/layout/aside/combinationMode.vue b/web/src/view/layout/aside/combinationMode.vue index 22c6c38df6..e9f82ecc74 100644 --- a/web/src/view/layout/aside/combinationMode.vue +++ b/web/src/view/layout/aside/combinationMode.vue @@ -129,9 +129,13 @@ router.push({ name: index, query, params }) return } - if (!routerStore.setLeftMenu(index)) { + const leftMenu = routerStore.setLeftMenu(index) + if (!leftMenu) { router.push({ name: index, query, params }) + return; } + const firstMenu = leftMenu.find((item) => !item.hidden && item.path.indexOf("http://") === -1 && item.path.indexOf("https://") === -1) + router.push({ name: firstMenu.name, query, params }) } }