Skip to content

Commit 379f5fe

Browse files
author
piexlMax(奇淼
committed
Merge remote-tracking branch 'refs/remotes/origin/dev-281'
2 parents 0ab15cc + 6ae5b23 commit 379f5fe

File tree

13 files changed

+336
-83
lines changed

13 files changed

+336
-83
lines changed

Diff for: server/initialize/gorm_mysql.go

+11-19
Original file line numberDiff line numberDiff line change
@@ -12,41 +12,33 @@ import (
1212
// GormMysql 初始化Mysql数据库
1313
// Author [piexlmax](https://github.com/piexlmax)
1414
// Author [SliverHorn](https://github.com/SliverHorn)
15+
// Author [ByteZhou-2018](https://github.com/ByteZhou-2018)
1516
func GormMysql() *gorm.DB {
1617
m := global.GVA_CONFIG.Mysql
17-
if m.Dbname == "" {
18-
return nil
19-
}
20-
mysqlConfig := mysql.Config{
21-
DSN: m.Dsn(), // DSN data source name
22-
DefaultStringSize: 191, // string 类型字段的默认长度
23-
SkipInitializeWithVersion: false, // 根据版本自动配置
24-
}
25-
if db, err := gorm.Open(mysql.New(mysqlConfig), internal.Gorm.Config(m.Prefix, m.Singular)); err != nil {
26-
return nil
27-
} else {
28-
db.InstanceSet("gorm:table_options", "ENGINE="+m.Engine)
29-
sqlDB, _ := db.DB()
30-
sqlDB.SetMaxIdleConns(m.MaxIdleConns)
31-
sqlDB.SetMaxOpenConns(m.MaxOpenConns)
32-
return db
33-
}
18+
return initMysqlDatabase(m)
3419
}
3520

36-
// GormMysqlByConfig 初始化Mysql数据库用过传入配置
21+
// GormMysqlByConfig 通过传入配置初始化Mysql数据库
3722
func GormMysqlByConfig(m config.Mysql) *gorm.DB {
23+
return initMysqlDatabase(m)
24+
}
25+
26+
// initMysqlDatabase 初始化Mysql数据库的辅助函数
27+
func initMysqlDatabase(m config.Mysql) *gorm.DB {
3828
if m.Dbname == "" {
3929
return nil
4030
}
31+
4132
mysqlConfig := mysql.Config{
4233
DSN: m.Dsn(), // DSN data source name
4334
DefaultStringSize: 191, // string 类型字段的默认长度
4435
SkipInitializeWithVersion: false, // 根据版本自动配置
4536
}
37+
4638
if db, err := gorm.Open(mysql.New(mysqlConfig), internal.Gorm.Config(m.Prefix, m.Singular)); err != nil {
4739
panic(err)
4840
} else {
49-
db.InstanceSet("gorm:table_options", "ENGINE=InnoDB")
41+
db.InstanceSet("gorm:table_options", "ENGINE="+m.Engine)
5042
sqlDB, _ := db.DB()
5143
sqlDB.SetMaxIdleConns(m.MaxIdleConns)
5244
sqlDB.SetMaxOpenConns(m.MaxOpenConns)

Diff for: server/initialize/gorm_oracle.go

+8-15
Original file line numberDiff line numberDiff line change
@@ -15,32 +15,25 @@ import (
1515
// 如果需要Oracle库 放开import里的注释 把下方 mysql.Config 改为 oracle.Config ; mysql.New 改为 oracle.New
1616
func GormOracle() *gorm.DB {
1717
m := global.GVA_CONFIG.Oracle
18-
if m.Dbname == "" {
19-
return nil
20-
}
21-
oracleConfig := mysql.Config{
22-
DSN: m.Dsn(), // DSN data source name
23-
DefaultStringSize: 191, // string 类型字段的默认长度
24-
}
25-
if db, err := gorm.Open(mysql.New(oracleConfig), internal.Gorm.Config(m.Prefix, m.Singular)); err != nil {
26-
panic(err)
27-
} else {
28-
sqlDB, _ := db.DB()
29-
sqlDB.SetMaxIdleConns(m.MaxIdleConns)
30-
sqlDB.SetMaxOpenConns(m.MaxOpenConns)
31-
return db
32-
}
18+
return initOracleDatabase(m)
3319
}
3420

3521
// GormOracleByConfig 初始化Oracle数据库用过传入配置
3622
func GormOracleByConfig(m config.Oracle) *gorm.DB {
23+
return initOracleDatabase(m)
24+
}
25+
26+
// initOracleDatabase 初始化Oracle数据库的辅助函数
27+
func initOracleDatabase(m config.Oracle) *gorm.DB {
3728
if m.Dbname == "" {
3829
return nil
3930
}
31+
4032
oracleConfig := mysql.Config{
4133
DSN: m.Dsn(), // DSN data source name
4234
DefaultStringSize: 191, // string 类型字段的默认长度
4335
}
36+
4437
if db, err := gorm.Open(mysql.New(oracleConfig), internal.Gorm.Config(m.Prefix, m.Singular)); err != nil {
4538
panic(err)
4639
} else {

Diff for: server/initialize/gorm_pgsql.go

+7-16
Original file line numberDiff line numberDiff line change
@@ -13,25 +13,16 @@ import (
1313
// Author [SliverHorn](https://github.com/SliverHorn)
1414
func GormPgSql() *gorm.DB {
1515
p := global.GVA_CONFIG.Pgsql
16-
if p.Dbname == "" {
17-
return nil
18-
}
19-
pgsqlConfig := postgres.Config{
20-
DSN: p.Dsn(), // DSN data source name
21-
PreferSimpleProtocol: false,
22-
}
23-
if db, err := gorm.Open(postgres.New(pgsqlConfig), internal.Gorm.Config(p.Prefix, p.Singular)); err != nil {
24-
return nil
25-
} else {
26-
sqlDB, _ := db.DB()
27-
sqlDB.SetMaxIdleConns(p.MaxIdleConns)
28-
sqlDB.SetMaxOpenConns(p.MaxOpenConns)
29-
return db
30-
}
16+
return initPgSqlDatabase(p)
3117
}
3218

33-
// GormPgSqlByConfig 初始化 Postgresql 数据库 通过参数
19+
// GormPgSqlByConfig 初始化 Postgresql 数据库 通过指定参数
3420
func GormPgSqlByConfig(p config.Pgsql) *gorm.DB {
21+
return initPgSqlDatabase(p)
22+
}
23+
24+
// initPgSqlDatabase 初始化 Postgresql 数据库的辅助函数
25+
func initPgSqlDatabase(p config.Pgsql) *gorm.DB {
3526
if p.Dbname == "" {
3627
return nil
3728
}

Diff for: server/initialize/gorm_sqlite.go

+6-12
Original file line numberDiff line numberDiff line change
@@ -11,22 +11,16 @@ import (
1111
// GormSqlite 初始化Sqlite数据库
1212
func GormSqlite() *gorm.DB {
1313
s := global.GVA_CONFIG.Sqlite
14-
if s.Dbname == "" {
15-
return nil
16-
}
17-
18-
if db, err := gorm.Open(sqlite.Open(s.Dsn()), internal.Gorm.Config(s.Prefix, s.Singular)); err != nil {
19-
panic(err)
20-
} else {
21-
sqlDB, _ := db.DB()
22-
sqlDB.SetMaxIdleConns(s.MaxIdleConns)
23-
sqlDB.SetMaxOpenConns(s.MaxOpenConns)
24-
return db
25-
}
14+
return initSqliteDatabase(s)
2615
}
2716

2817
// GormSqliteByConfig 初始化Sqlite数据库用过传入配置
2918
func GormSqliteByConfig(s config.Sqlite) *gorm.DB {
19+
return initSqliteDatabase(s)
20+
}
21+
22+
// initSqliteDatabase 初始化Sqlite数据库辅助函数
23+
func initSqliteDatabase(s config.Sqlite) *gorm.DB {
3024
if s.Dbname == "" {
3125
return nil
3226
}

Diff for: server/service/system/auto_code_package_test.go

+9-6
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,11 @@ package system
22

33
import (
44
"context"
5-
model "github.com/flipped-aurora/gin-vue-admin/server/model/system"
6-
"github.com/flipped-aurora/gin-vue-admin/server/model/system/request"
75
"reflect"
86
"testing"
7+
8+
model "github.com/flipped-aurora/gin-vue-admin/server/model/system"
9+
"github.com/flipped-aurora/gin-vue-admin/server/model/system/request"
910
)
1011

1112
func Test_autoCodePackage_Create(t *testing.T) {
@@ -53,9 +54,10 @@ func Test_autoCodePackage_Create(t *testing.T) {
5354

5455
func Test_autoCodePackage_templates(t *testing.T) {
5556
type args struct {
56-
ctx context.Context
57-
entity model.SysAutoCodePackage
58-
info request.AutoCode
57+
ctx context.Context
58+
entity model.SysAutoCodePackage
59+
info request.AutoCode
60+
isPackage bool
5961
}
6062
tests := []struct {
6163
name string
@@ -78,14 +80,15 @@ func Test_autoCodePackage_templates(t *testing.T) {
7880
Abbreviation: "user",
7981
HumpPackageName: "user",
8082
},
83+
isPackage: false,
8184
},
8285
wantErr: false,
8386
},
8487
}
8588
for _, tt := range tests {
8689
t.Run(tt.name, func(t *testing.T) {
8790
s := &autoCodePackage{}
88-
gotCode, gotEnter, gotCreates, err := s.templates(tt.args.ctx, tt.args.entity, tt.args.info)
91+
gotCode, gotEnter, gotCreates, err := s.templates(tt.args.ctx, tt.args.entity, tt.args.info, tt.args.isPackage)
8992
if (err != nil) != tt.wantErr {
9093
t.Errorf("templates() error = %v, wantErr %v", err, tt.wantErr)
9194
return

Diff for: server/source/system/menu.go

+1
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ func (i *initMenu) InitializeData(ctx context.Context) (next context.Context, er
8282
{MenuLevel: 0, Hidden: false, ParentId: 15, Path: "exportTemplate", Name: "exportTemplate", Component: "view/systemTools/exportTemplate/exportTemplate.vue", Sort: 5, Meta: Meta{Title: "导出模板", Icon: "reading"}},
8383
{MenuLevel: 0, Hidden: false, ParentId: 24, Path: "anInfo", Name: "anInfo", Component: "plugin/announcement/view/info.vue", Sort: 5, Meta: Meta{Title: "公告管理[示例]", Icon: "scaleToOriginal"}},
8484
{MenuLevel: 0, Hidden: false, ParentId: 3, Path: "sysParams", Name: "sysParams", Component: "view/superAdmin/params/sysParams.vue", Sort: 7, Meta: Meta{Title: "参数管理", Icon: "compass"}},
85+
{MenuLevel: 0, Hidden: false, ParentId: 15, Path: "picture", Name: "picture", Component: "view/systemTools/autoCode/picture.vue", Sort: 6, Meta: Meta{Title: "AI页面绘制", Icon: "picture-filled"}},
8586
}
8687
if err = db.Create(&entities).Error; err != nil {
8788
return ctx, errors.Wrap(err, SysBaseMenu{}.TableName()+"表数据初始化失败!")

Diff for: server/utils/captcha/redis.go

+4-3
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import (
55
"time"
66

77
"github.com/flipped-aurora/gin-vue-admin/server/global"
8-
"github.com/mojocn/base64Captcha"
98
"go.uber.org/zap"
109
)
1110

@@ -23,8 +22,10 @@ type RedisStore struct {
2322
Context context.Context
2423
}
2524

26-
func (rs *RedisStore) UseWithCtx(ctx context.Context) base64Captcha.Store {
27-
rs.Context = ctx
25+
func (rs *RedisStore) UseWithCtx(ctx context.Context) *RedisStore {
26+
if ctx == nil {
27+
rs.Context = ctx
28+
}
2829
return rs
2930
}
3031

Diff for: web/src/api/autoCode.js

+11
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,17 @@ export const eye = (data) => {
173173
}
174174

175175

176+
export const createWeb = (data) => {
177+
return service({
178+
url: '/autoCode/llmAuto',
179+
method: 'post',
180+
data: { ...data, mode: 'painter' },
181+
timeout: 1000 * 60 * 10
182+
})
183+
}
184+
185+
186+
176187
export const addFunc = (data) => {
177188
return service({
178189
url: '/autoCode/addFunc',

Diff for: web/src/pathInfo.json

+3
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
"/src/view/example/breakpoint/breakpoint.vue": "BreakPoint",
1717
"/src/view/example/customer/customer.vue": "Customer",
1818
"/src/view/example/index.vue": "Example",
19+
"/src/view/example/upload/scanUpload.vue": "scanUpload",
1920
"/src/view/example/upload/upload.vue": "Upload",
2021
"/src/view/init/index.vue": "Init",
2122
"/src/view/layout/aside/asideComponent/asyncSubmenu.vue": "AsyncSubmenu",
@@ -53,8 +54,10 @@
5354
"/src/view/superAdmin/user/user.vue": "User",
5455
"/src/view/system/state.vue": "State",
5556
"/src/view/systemTools/autoCode/component/fieldDialog.vue": "FieldDialog",
57+
"/src/view/systemTools/autoCode/component/iframeRenderer.vue": "IframeRenderer",
5658
"/src/view/systemTools/autoCode/component/previewCodeDialog.vue": "PreviewCodeDialog",
5759
"/src/view/systemTools/autoCode/index.vue": "AutoCode",
60+
"/src/view/systemTools/autoCode/picture.vue": "Picture",
5861
"/src/view/systemTools/autoCodeAdmin/index.vue": "AutoCodeAdmin",
5962
"/src/view/systemTools/autoPkg/autoPkg.vue": "AutoPkg",
6063
"/src/view/systemTools/exportTemplate/exportTemplate.vue": "ExportTemplate",

Diff for: web/src/pinia/modules/app.js

+23-1
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,27 @@ export const useAppStore = defineStore('app', () => {
9999
config.transition_type = e
100100
}
101101

102+
const baseCoinfg = {
103+
weakness: false,
104+
grey: false,
105+
primaryColor: '#3b82f6',
106+
showTabs: true,
107+
darkMode: 'auto',
108+
layout_side_width: 256,
109+
layout_side_collapsed_width: 80,
110+
layout_side_item_height: 48,
111+
show_watermark: true,
112+
side_mode: 'normal',
113+
// 页面过渡动画配置
114+
transition_type: 'slide'
115+
}
116+
117+
const resetConfig = () => {
118+
for (let baseCoinfgKey in baseCoinfg) {
119+
config[baseCoinfgKey] = baseCoinfg[baseCoinfgKey]
120+
}
121+
}
122+
102123
// 监听色弱模式和灰色模式
103124
watchEffect(() => {
104125
document.documentElement.classList.toggle('html-weakenss', config.weakness)
@@ -128,6 +149,7 @@ export const useAppStore = defineStore('app', () => {
128149
toggleConfigSideItemHeight,
129150
toggleConfigWatermark,
130151
toggleSideMode,
131-
toggleTransition
152+
toggleTransition,
153+
resetConfig
132154
}
133155
})

Diff for: web/src/view/layout/setting/index.vue

+13-11
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
<template #header>
1010
<div class="flex justify-between items-center">
1111
<span class="text-lg">系统配置</span>
12-
<el-button type="primary" @click="saveConfig">保存配置</el-button>
12+
<el-button type="primary" @click="resetConfig">重置配置</el-button>
1313
</div>
1414
</template>
1515
<div class="flex flex-col">
@@ -144,6 +144,8 @@
144144
import { ElMessage } from 'element-plus'
145145
import { setSelfSetting } from '@/api/user'
146146
import Title from './title.vue'
147+
import { watch } from 'vue';
148+
147149
const appStore = useAppStore()
148150
const { config, device } = storeToRefs(appStore)
149151
defineOptions({
@@ -185,24 +187,24 @@
185187
]
186188
187189
const saveConfig = async () => {
188-
/*const input = document.createElement("textarea");
189-
input.value = JSON.stringify(config.value);
190-
// 添加回车
191-
input.value = input.value.replace(/,/g, ",\n");
192-
document.body.appendChild(input);
193-
input.select();
194-
document.execCommand("copy");
195-
document.body.removeChild(input);
196-
ElMessage.success("复制成功, 请自行保存到本地文件中");*/
197190
const res = await setSelfSetting(config.value)
191+
console.log(config.value)
198192
if (res.code === 0) {
199193
localStorage.setItem('originSetting', JSON.stringify(config.value))
200194
ElMessage.success('保存成功')
201-
drawer.value = false
202195
}
203196
}
204197
205198
const customColor = ref('')
199+
200+
const resetConfig = () => {
201+
appStore.resetConfig()
202+
}
203+
204+
205+
watch(config, async () => {
206+
await saveConfig();
207+
}, { deep: true });
206208
</script>
207209

208210
<style lang="scss" scoped>

0 commit comments

Comments
 (0)