前端代码生成位置调整

This commit is contained in:
xiangheng
2024-07-13 19:59:43 +08:00
parent 763f347af7
commit d213eb7c99
4 changed files with 26 additions and 20 deletions

View File

@@ -82,13 +82,13 @@ const formRules = {
// trigger: ['blur'] // trigger: ['blur']
// } // }
// ], // ],
// projectName: [ projectName: [
// { {
// required: true, required: true,
// message: '请输入项目名称', message: '请输入项目名称',
// trigger: ['blur'] trigger: ['blur']
// } }
// ], ],
projectType: [ projectType: [
{ {
required: true, required: true,

View File

@@ -2,7 +2,7 @@
{ {
"pages": [ "pages": [
{ {
"path": "pages/{{{ .ModuleName }}}/index", "path": "pages/{{{nameToPath .ModuleName }}}/index",
"style": { "style": {
"navigationBarTitleText": "{{{.FunctionName}}}", "navigationBarTitleText": "{{{.FunctionName}}}",
"enablePullDownRefresh": true, "enablePullDownRefresh": true,
@@ -10,20 +10,20 @@
} }
}, },
{ {
"path": "pages/{{{ .ModuleName }}}/details", "path": "pages/{{{nameToPath .ModuleName }}}/details",
"style": { "style": {
"navigationBarTitleText": "{{{.FunctionName}}}详情", "navigationBarTitleText": "{{{.FunctionName}}}详情",
"enablePullDownRefresh": true "enablePullDownRefresh": true
} }
}, },
{ {
"path": "pages/{{{ .ModuleName }}}/edit", "path": "pages/{{{nameToPath .ModuleName }}}/edit",
"style": { "style": {
"navigationBarTitleText": "编辑{{{.FunctionName}}}" "navigationBarTitleText": "编辑{{{.FunctionName}}}"
} }
}, },
{ {
"path": "pages/{{{ .ModuleName }}}/search", "path": "pages/{{{nameToPath .ModuleName }}}/search",
"style": { "style": {
"navigationBarTitleText": "搜索{{{.FunctionName}}}" "navigationBarTitleText": "搜索{{{.FunctionName}}}"
} }

View File

@@ -25,6 +25,7 @@ var TemplateUtil = templateUtil{
"contains": util.ToolsUtil.Contains, "contains": util.ToolsUtil.Contains,
"goToTsType": util.ToolsUtil.GoToTsType, "goToTsType": util.ToolsUtil.GoToTsType,
"getPageResp": util.ToolsUtil.GetPageResp, "getPageResp": util.ToolsUtil.GetPageResp,
"nameToPath": util.ToolsUtil.NameToPath,
}), }),
} }
@@ -221,17 +222,17 @@ func (tu templateUtil) GetFilePaths(tplCodeMap map[string]string, ModuleName str
// "server/admin/%s_route.go", // "server/admin/%s_route.go",
"gocode/controller.go.tpl": strings.Join([]string{"server/admin/", ModuleName, "/", ModuleName, "_ctl.go"}, ""), //"server/admin/%s/%s_ctl.go", "gocode/controller.go.tpl": strings.Join([]string{"server/admin/", ModuleName, "/", ModuleName, "_ctl.go"}, ""), //"server/admin/%s/%s_ctl.go",
"vue/api.ts.tpl": strings.Join([]string{"admin/src/api/", ModuleName, ".ts"}, ""), // "admin/src/api/%s.ts", "vue/api.ts.tpl": strings.Join([]string{"admin/src/api/", ModuleName, ".ts"}, ""), // "admin/src/api/%s.ts",
"vue/edit.vue.tpl": strings.Join([]string{"admin/src/views/", ModuleName, "/edit.vue"}, ""), // "admin/src/views/%s/edit.vue", "vue/edit.vue.tpl": strings.Join([]string{"admin/src/views/", util.ToolsUtil.NameToPath(ModuleName), "/edit.vue"}, ""), // "admin/src/views/%s/edit.vue",
"vue/index.vue.tpl": strings.Join([]string{"admin/src/views/", ModuleName, "/index.vue"}, ""), // "admin/src/views/%s/index.vue", "vue/index.vue.tpl": strings.Join([]string{"admin/src/views/", util.ToolsUtil.NameToPath(ModuleName), "/index.vue"}, ""), // "admin/src/views/%s/index.vue",
"vue/index-tree.vue.tpl": strings.Join([]string{"admin/src/views/", ModuleName, "/index-tree.vue"}, ""), // "admin/src/views/%s/index-tree.vue", "vue/index-tree.vue.tpl": strings.Join([]string{"admin/src/views/", util.ToolsUtil.NameToPath(ModuleName), "/index-tree.vue"}, ""), // "admin/src/views/%s/index-tree.vue",
"uniapp/api.ts.tpl": strings.Join([]string{"x_admin_app/api/", ModuleName, ".ts"}, ""), "uniapp/api.ts.tpl": strings.Join([]string{"x_admin_app/api/", ModuleName, ".ts"}, ""),
"uniapp/edit.vue.tpl": strings.Join([]string{"x_admin_app/pages/", ModuleName, "/edit.vue"}, ""), "uniapp/edit.vue.tpl": strings.Join([]string{"x_admin_app/pages/", util.ToolsUtil.NameToPath(ModuleName), "/edit.vue"}, ""),
"uniapp/index.vue.tpl": strings.Join([]string{"x_admin_app/pages/", ModuleName, "/index.vue"}, ""), "uniapp/index.vue.tpl": strings.Join([]string{"x_admin_app/pages/", util.ToolsUtil.NameToPath(ModuleName), "/index.vue"}, ""),
"uniapp/search.vue.tpl": strings.Join([]string{"x_admin_app/pages/", ModuleName, "/search.vue"}, ""), "uniapp/search.vue.tpl": strings.Join([]string{"x_admin_app/pages/", util.ToolsUtil.NameToPath(ModuleName), "/search.vue"}, ""),
"uniapp/details.vue.tpl": strings.Join([]string{"x_admin_app/pages/", ModuleName, "/details.vue"}, ""), "uniapp/details.vue.tpl": strings.Join([]string{"x_admin_app/pages/", util.ToolsUtil.NameToPath(ModuleName), "/details.vue"}, ""),
"uniapp/pages.json.tpl": strings.Join([]string{"x_admin_app/pages/", ModuleName, "/pages.json"}, ""), "uniapp/pages.json.tpl": strings.Join([]string{"x_admin_app/pages/", util.ToolsUtil.NameToPath(ModuleName), "/pages.json"}, ""),
} }
filePath := make(map[string]string) filePath := make(map[string]string)
for tplPath, tplCode := range tplCodeMap { for tplPath, tplCode := range tplCodeMap {

View File

@@ -102,6 +102,11 @@ func (tu toolsUtil) GetPageResp(s string) string {
return `response.Response{ data=response.PageResp{ lists= []` + s + `Resp}}` return `response.Response{ data=response.PageResp{ lists= []` + s + `Resp}}`
} }
// NameToPath 下划线文件路径
func (tu toolsUtil) NameToPath(s string) string {
return strings.ReplaceAll(s, "_", "/")
}
// Round float四舍五入 // Round float四舍五入
func (tu toolsUtil) Round(val float64, n int) float64 { func (tu toolsUtil) Round(val float64, n int) float64 {
base := math.Pow(10, float64(n)) base := math.Pow(10, float64(n))