From a2c6a8ac1667142f8dca19e75f5f53e9a58229b8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=AD=9F=E5=B8=85?= <133814250@qq.com> Date: Mon, 16 Sep 2024 19:45:19 +0800 Subject: [PATCH 1/4] =?UTF-8?q?fix=20=E4=BF=AE=E5=A4=8D=E6=A0=91=E8=A1=A8?= =?UTF-8?q?=E7=94=9F=E6=88=90=E9=80=89=E9=A1=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/guide-zh-CN/start-environment.md | 6 +++--- docs/guide-zh-CN/start-installation.md | 2 +- server/internal/library/hggen/hggen.go | 6 +++++- .../internal/library/hggen/views/curd_generate_logic.go | 2 +- server/internal/logic/sys/gen_codes.go | 9 +++++++-- 5 files changed, 17 insertions(+), 8 deletions(-) diff --git a/docs/guide-zh-CN/start-environment.md b/docs/guide-zh-CN/start-environment.md index dc90723..e32f5ae 100644 --- a/docs/guide-zh-CN/start-environment.md +++ b/docs/guide-zh-CN/start-environment.md @@ -15,10 +15,10 @@ 5. 命令行运行 `pnpm -v` 若控制台输出版本号则前端环境搭建成功 ### 后端环境 -1. 下载golang安装 版本号需>=1.21 +1. 下载golang安装 版本号需>=1.23 2. 国际: https://golang.org/dl/ 3. 国内: https://golang.google.cn/dl/ -4. 命令行运行 go 若控制台输出各类提示命令 则安装成功 输入 `go version` 确认版本大于1.19 +4. 命令行运行 go 若控制台输出各类提示命令 则安装成功 输入 `go version` 确认版本大于1.23 5. 开发工具推荐 [Goland](https://www.jetbrains.com/go/) ### 使用说明 @@ -26,6 +26,6 @@ > 需要本地具有 git node golang 环境 - node版本 >= 16.0.0 -- golang版本 >= 1.21 +- golang版本 >= 1.23 - mysql版本 >= 5.7,引擎需要是 innoDB - IDE推荐:Goland diff --git a/docs/guide-zh-CN/start-installation.md b/docs/guide-zh-CN/start-installation.md index 796abad..c69ddf5 100644 --- a/docs/guide-zh-CN/start-installation.md +++ b/docs/guide-zh-CN/start-installation.md @@ -8,7 +8,7 @@ ### 环境要求 - node版本 >= v16.0.0 -- golang版本 >= v1.21 +- golang版本 >= v1.23 - goframe版本 >=v2.7.0 - mysql版本 >=5.7 diff --git a/server/internal/library/hggen/hggen.go b/server/internal/library/hggen/hggen.go index fce4b60..2db397d 100644 --- a/server/internal/library/hggen/hggen.go +++ b/server/internal/library/hggen/hggen.go @@ -179,7 +179,11 @@ func GenTypeSelect(ctx context.Context) (res sysin.GenTypeSelects, err error) { Templates: make(sysin.GenTemplateSelects, 0), } - confName, ok := consts.GenCodesTypeConfMap[k] + km := k + if km == consts.GenCodesTypeTree { + km = consts.GenCodesTypeCurd + } + confName, ok := consts.GenCodesTypeConfMap[km] if ok { var temps []*model.GenerateAppCrudTemplate err = g.Cfg().MustGet(ctx, "hggen.application."+confName+".templates").Scan(&temps) diff --git a/server/internal/library/hggen/views/curd_generate_logic.go b/server/internal/library/hggen/views/curd_generate_logic.go index 1a68eec..bda2efa 100644 --- a/server/internal/library/hggen/views/curd_generate_logic.go +++ b/server/internal/library/hggen/views/curd_generate_logic.go @@ -286,7 +286,7 @@ func (l *gCurd) generateLogicListWhereEach(buffer *bytes.Buffer, in *CurdPreview case WhereModeNotLike: whereTag = "\tif " + linkMode + " {\n\t\tmod = mod." + wherePrefix + "NotLike(" + tablePrefix + "dao." + daoName + ".Columns()." + columnName + ", in." + field.GoName + ")\n\t}" case WhereModeJsonContains: - val := tablePrefix + "fmt.Sprintf(`JSON_CONTAINS(%s,'%v')`, dao." + daoName + ".Columns()." + columnName + ", in." + field.GoName + ")" + val := tablePrefix + `"JSON_CONTAINS("+dao.` + daoName + `.Columns().` + columnName + `+",?)", in.` + field.GoName whereTag = "\tif " + linkMode + " {\n\t\tmod = mod." + wherePrefix + "(" + val + ")\n\t}" default: diff --git a/server/internal/logic/sys/gen_codes.go b/server/internal/logic/sys/gen_codes.go index bd76a08..2ba9160 100644 --- a/server/internal/logic/sys/gen_codes.go +++ b/server/internal/logic/sys/gen_codes.go @@ -177,8 +177,14 @@ func (s *sSysGenCodes) List(ctx context.Context, in *sysin.GenCodesListInp) (lis if row == nil { return "" } + + genType := int(row.GenType) + if genType == consts.GenCodesTypeTree { + genType = consts.GenCodesTypeCurd + } + for _, v := range typeSelect { - if v.Value == int(row.GenType) { + if v.Value == genType { for index, template := range v.Templates { if index == row.GenTemplate { return template.Label @@ -186,7 +192,6 @@ func (s *sSysGenCodes) List(ctx context.Context, in *sysin.GenCodesListInp) (lis } } } - return "" } From dbdfdaae931d78f65f7ffff3910517b5a4ce644a Mon Sep 17 00:00:00 2001 From: SpiderMan <445001382@qq.com> Date: Thu, 26 Sep 2024 17:28:56 +0800 Subject: [PATCH 2/4] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E4=BD=BF=E7=94=A8?= =?UTF-8?q?pnpm=20build=E6=89=93=E5=8C=85=E6=8A=A5=E9=94=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- web/build/script/buildConf.ts | 8 ++++---- web/build/script/postBuild.ts | 4 ++-- web/package.json | 3 +++ web/pnpm-lock.yaml | 24 ++++++++++++++++++++++++ 4 files changed, 33 insertions(+), 6 deletions(-) diff --git a/web/build/script/buildConf.ts b/web/build/script/buildConf.ts index 0567a0d..c3071a8 100644 --- a/web/build/script/buildConf.ts +++ b/web/build/script/buildConf.ts @@ -10,7 +10,7 @@ import { getConfigFileName } from '../getConfigFileName'; import pkg from '../../package.json'; -function createConfig( +async function createConfig( { configName, config, @@ -27,7 +27,7 @@ function createConfig( writable: false, }); `.replace(/\s/g, ''); - fs.mkdirp(getRootPath(OUTPUT_DIR)); + await fs.mkdirp(getRootPath(OUTPUT_DIR)); fs.writeFileSync(getRootPath(`${OUTPUT_DIR}/${configFileName}`), configStr); console.log(chalk.cyan(`✨ [${pkg.name}]`) + ` - configuration file is build successfully:`); @@ -37,8 +37,8 @@ function createConfig( } } -export function runBuildConfig() { +export async function runBuildConfig() { const config = getEnvConfig(); const configFileName = getConfigFileName(config); - createConfig({ config, configName: configFileName }); + await createConfig({ config, configName: configFileName }); } diff --git a/web/build/script/postBuild.ts b/web/build/script/postBuild.ts index 79c5e8f..441a09a 100644 --- a/web/build/script/postBuild.ts +++ b/web/build/script/postBuild.ts @@ -2,7 +2,7 @@ import { runBuildConfig } from './buildConf'; import chalk from 'chalk'; - +import process from 'node:process' import pkg from '../../package.json'; export const runBuild = async () => { @@ -20,4 +20,4 @@ export const runBuild = async () => { process.exit(1); } }; -runBuild(); +runBuild().then(); diff --git a/web/package.json b/web/package.json index b3e2208..1794042 100644 --- a/web/package.json +++ b/web/package.json @@ -66,6 +66,7 @@ "devDependencies": { "@commitlint/cli": "^19.4.1", "@commitlint/config-conventional": "^19.4.1", + "@types/fs-extra": "^11.0.4", "@types/lodash": "^4.17.7", "@types/node": "^22.5.2", "@typescript-eslint/eslint-plugin": "^8.4.0", @@ -75,6 +76,7 @@ "@vue/compiler-sfc": "^3.4.38", "@vue/eslint-config-typescript": "^13.0.0", "autoprefixer": "^10.4.20", + "chalk": "^5.3.0", "commitizen": "^4.3.0", "core-js": "^3.38.1", "cross-env": "^7.0.3", @@ -87,6 +89,7 @@ "eslint-plugin-prettier": "^5.2.1", "eslint-plugin-vue": "^9.28.0", "esno": "^4.7.0", + "fs-extra": "^11.2.0", "gh-pages": "^6.1.1", "husky": "^9.1.5", "jest": "^29.7.0", diff --git a/web/pnpm-lock.yaml b/web/pnpm-lock.yaml index cdb374f..0555b2d 100644 --- a/web/pnpm-lock.yaml +++ b/web/pnpm-lock.yaml @@ -114,6 +114,9 @@ importers: '@commitlint/config-conventional': specifier: ^19.4.1 version: 19.4.1 + '@types/fs-extra': + specifier: ^11.0.4 + version: 11.0.4 '@types/lodash': specifier: ^4.17.7 version: 4.17.7 @@ -141,6 +144,9 @@ importers: autoprefixer: specifier: ^10.4.20 version: 10.4.20(postcss@8.4.44) + chalk: + specifier: ^5.3.0 + version: 5.3.0 commitizen: specifier: ^4.3.0 version: 4.3.0(@types/node@22.5.2)(typescript@5.5.4) @@ -177,6 +183,9 @@ importers: esno: specifier: ^4.7.0 version: 4.7.0 + fs-extra: + specifier: ^11.2.0 + version: 11.2.0 gh-pages: specifier: ^6.1.1 version: 6.1.1 @@ -1264,6 +1273,9 @@ packages: '@types/estree@1.0.5': resolution: {integrity: sha512-/kYRxGDLWzHOB7q+wtSUQlFrtcdUccpfy+X+9iMBpHK8QLLhx2wIPYuS5DYtR9Wa/YlZAbIovy7qVdB1Aq6Lyw==} + '@types/fs-extra@11.0.4': + resolution: {integrity: sha512-yTbItCNreRooED33qjunPthRcSjERP1r4MqCZc7wv0u2sUkzTFp45tgUfS5+r7FrZPdmCCNflLhVSP/o+SemsQ==} + '@types/graceful-fs@4.1.9': resolution: {integrity: sha512-olP3sd1qOEe5dXTSaFvQG+02VdRXcdytWLAZsAq1PecU8uqQAhkrnbli7DagjtXKW/Bl7YJbUsa8MPcuc8LHEQ==} @@ -1279,6 +1291,9 @@ packages: '@types/json-schema@7.0.15': resolution: {integrity: sha512-5+fP8P8MFNC+AyZCDxrB2pkZFPGzqQWUzpSeuuVLvm8VMcorNYavBqoFcxK8bQz4Qsbn4oUEEem4wDLfcysGHA==} + '@types/jsonfile@6.1.4': + resolution: {integrity: sha512-D5qGUYwjvnNNextdU59/+fI+spnwtTFmyQP0h+PfIOSkNfpU6AOICUOkm4i0OnSk+NyjdPJrxCDro0sJsWlRpQ==} + '@types/katex@0.16.7': resolution: {integrity: sha512-HMwFiRujE5PjrgwHQ25+bsLJgowjGjm5Z8FVSf0N6PwgJrwxH0QxzHYDcKsTfV3wva0vzrpqMTJS2jXPr5BMEQ==} @@ -5643,6 +5658,11 @@ snapshots: '@types/estree@1.0.5': {} + '@types/fs-extra@11.0.4': + dependencies: + '@types/jsonfile': 6.1.4 + '@types/node': 22.5.2 + '@types/graceful-fs@4.1.9': dependencies: '@types/node': 22.5.2 @@ -5660,6 +5680,10 @@ snapshots: '@types/json-schema@7.0.15': optional: true + '@types/jsonfile@6.1.4': + dependencies: + '@types/node': 22.5.2 + '@types/katex@0.16.7': {} '@types/lodash-es@4.17.12': From 52c2538a6614a6400e0af02bf8f385580a0cbc51 Mon Sep 17 00:00:00 2001 From: SpiderMan <445001382@qq.com> Date: Sat, 28 Sep 2024 09:55:01 +0800 Subject: [PATCH 3/4] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8Deslint=E6=8A=A5?= =?UTF-8?q?=E9=94=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- web/.eslintignore | 16 --- web/.eslintrc.js | 77 ------------- web/eslint.config.js | 104 ++++++++++++++++++ web/package.json | 1 + web/pnpm-lock.yaml | 3 + ...prettier.config.js => prettier.config.cjs} | 0 6 files changed, 108 insertions(+), 93 deletions(-) delete mode 100644 web/.eslintignore delete mode 100644 web/.eslintrc.js create mode 100644 web/eslint.config.js rename web/{prettier.config.js => prettier.config.cjs} (100%) diff --git a/web/.eslintignore b/web/.eslintignore deleted file mode 100644 index 74aba32..0000000 --- a/web/.eslintignore +++ /dev/null @@ -1,16 +0,0 @@ -*.sh -node_modules -*.md -*.woff -*.ttf -.vscode -.idea -dist -/public -/docs -.husky -.local -/bin -Dockerfile -components.d.ts -components.d.ts diff --git a/web/.eslintrc.js b/web/.eslintrc.js deleted file mode 100644 index 87705e9..0000000 --- a/web/.eslintrc.js +++ /dev/null @@ -1,77 +0,0 @@ -// @ts-check -const { defineConfig } = require('eslint-define-config'); -module.exports = defineConfig({ - root: true, - env: { - browser: true, - node: true, - es6: true, - }, - parser: 'vue-eslint-parser', - parserOptions: { - parser: '@typescript-eslint/parser', - ecmaVersion: 2020, - sourceType: 'module', - jsxPragma: 'React', - ecmaFeatures: { - jsx: true, - }, - }, - extends: [ - 'plugin:vue/vue3-recommended', - 'plugin:@typescript-eslint/recommended', - 'prettier', - 'plugin:prettier/recommended', - ], - rules: { - 'vue/script-setup-uses-vars': 'error', - '@typescript-eslint/ban-ts-ignore': 'off', - '@typescript-eslint/explicit-function-return-type': 'off', - '@typescript-eslint/no-explicit-any': 'off', - '@typescript-eslint/no-var-requires': 'off', - '@typescript-eslint/no-empty-function': 'off', - 'vue/custom-event-name-casing': 'off', - 'no-use-before-define': 'off', - '@typescript-eslint/no-use-before-define': 'off', - '@typescript-eslint/ban-ts-comment': 'off', - '@typescript-eslint/ban-types': 'off', - '@typescript-eslint/no-non-null-assertion': 'off', - '@typescript-eslint/explicit-module-boundary-types': 'off', - '@typescript-eslint/no-unused-vars': ['error', { varsIgnorePattern: '.*', args: 'none' }], - 'no-unused-vars': [ - 'error', - // we are only using this rule to check for unused arguments since TS - // catches unused variables but not args. - { varsIgnorePattern: '.*', args: 'none' }, - ], - 'space-before-function-paren': 'off', - 'vue/multi-word-component-names': 'off', - 'vue/attributes-order': 'off', - 'vue/one-component-per-file': 'off', - 'vue/html-closing-bracket-newline': 'off', - 'vue/max-attributes-per-line': 'off', - 'vue/multiline-html-element-content-newline': 'off', - 'vue/singleline-html-element-content-newline': 'off', - 'vue/attribute-hyphenation': 'off', - 'vue/require-default-prop': 'off', - 'vue/html-self-closing': [ - 'error', - { - html: { - void: 'always', - normal: 'never', - component: 'always', - }, - svg: 'always', - math: 'always', - }, - ], - '@typescript-eslint/no-this-alias': [ - 'error', - { - allowDestructuring: false, // Disallow `const { props, state } = this`; true by default - allowedNames: ['that'], // Allow `const self = this`; `[]` by default - }, - ], - }, -}); diff --git a/web/eslint.config.js b/web/eslint.config.js new file mode 100644 index 0000000..a4eb964 --- /dev/null +++ b/web/eslint.config.js @@ -0,0 +1,104 @@ +import parser from 'vue-eslint-parser'; +import { FlatCompat } from '@eslint/eslintrc'; + +const compat = new FlatCompat(); + +export default [ + { + ignores: [ + '**/*.sh', + '**/node_modules', + '**/*.md', + '**/*.woff', + '**/*.ttf', + '**/.vscode', + '**/.idea', + '**/dist', + 'public', + 'docs', + '**/.husky', + '**/.local', + 'bin', + '**/Dockerfile', + '**/components.d.ts', + ], + }, + ...compat.extends( + 'plugin:vue/vue3-recommended', + 'plugin:@typescript-eslint/recommended', + 'prettier', + 'plugin:prettier/recommended' + ), + { + languageOptions: { + parser: parser, + ecmaVersion: 2020, + sourceType: 'module', + parserOptions: { + parser: '@typescript-eslint/parser', + jsxPragma: 'React', + ecmaFeatures: { + jsx: true, + }, + }, + }, + rules: { + 'vue/script-setup-uses-vars': 'error', + '@typescript-eslint/ban-ts-ignore': 'off', + '@typescript-eslint/explicit-function-return-type': 'off', + '@typescript-eslint/no-explicit-any': 'off', + '@typescript-eslint/no-var-requires': 'off', + '@typescript-eslint/no-empty-function': 'off', + 'vue/custom-event-name-casing': 'off', + 'no-use-before-define': 'off', + '@typescript-eslint/no-use-before-define': 'off', + '@typescript-eslint/ban-ts-comment': 'off', + '@typescript-eslint/ban-types': 'off', + '@typescript-eslint/no-non-null-assertion': 'off', + '@typescript-eslint/explicit-module-boundary-types': 'off', + '@typescript-eslint/no-unused-vars': [ + 'error', + { + varsIgnorePattern: '.*', + args: 'none', + }, + ], + 'no-unused-vars': [ + 'error', + { + varsIgnorePattern: '.*', + args: 'none', + }, + ], + 'space-before-function-paren': 'off', + 'vue/multi-word-component-names': 'off', + 'vue/attributes-order': 'off', + 'vue/one-component-per-file': 'off', + 'vue/html-closing-bracket-newline': 'off', + 'vue/max-attributes-per-line': 'off', + 'vue/multiline-html-element-content-newline': 'off', + 'vue/singleline-html-element-content-newline': 'off', + 'vue/attribute-hyphenation': 'off', + 'vue/require-default-prop': 'off', + 'vue/html-self-closing': [ + 'error', + { + html: { + void: 'always', + normal: 'never', + component: 'always', + }, + svg: 'always', + math: 'always', + }, + ], + '@typescript-eslint/no-this-alias': [ + 'error', + { + allowDestructuring: false, + allowedNames: ['that'], + }, + ], + }, + }, +]; diff --git a/web/package.json b/web/package.json index 1794042..84a8ad9 100644 --- a/web/package.json +++ b/web/package.json @@ -66,6 +66,7 @@ "devDependencies": { "@commitlint/cli": "^19.4.1", "@commitlint/config-conventional": "^19.4.1", + "@eslint/eslintrc": "^3.1.0", "@types/fs-extra": "^11.0.4", "@types/lodash": "^4.17.7", "@types/node": "^22.5.2", diff --git a/web/pnpm-lock.yaml b/web/pnpm-lock.yaml index 0555b2d..21bf9b1 100644 --- a/web/pnpm-lock.yaml +++ b/web/pnpm-lock.yaml @@ -114,6 +114,9 @@ importers: '@commitlint/config-conventional': specifier: ^19.4.1 version: 19.4.1 + '@eslint/eslintrc': + specifier: ^3.1.0 + version: 3.1.0 '@types/fs-extra': specifier: ^11.0.4 version: 11.0.4 diff --git a/web/prettier.config.js b/web/prettier.config.cjs similarity index 100% rename from web/prettier.config.js rename to web/prettier.config.cjs From abfd6a056f8934125c3461596c1f7e428310bb4d Mon Sep 17 00:00:00 2001 From: SpiderMan <445001382@qq.com> Date: Sat, 28 Sep 2024 17:38:46 +0800 Subject: [PATCH 4/4] =?UTF-8?q?feat:=20=E4=BF=AE=E5=A4=8Dlodash-es?= =?UTF-8?q?=E7=B1=BB=E5=9E=8B=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 项目里使用的是lodash-es,开发类型安装的为@types/lodash --- web/package.json | 2 +- web/pnpm-lock.yaml | 6 +++--- web/src/hooks/useDomWidth.ts | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/web/package.json b/web/package.json index 84a8ad9..257d1b9 100644 --- a/web/package.json +++ b/web/package.json @@ -68,7 +68,7 @@ "@commitlint/config-conventional": "^19.4.1", "@eslint/eslintrc": "^3.1.0", "@types/fs-extra": "^11.0.4", - "@types/lodash": "^4.17.7", + "@types/lodash-es": "^4.17.12", "@types/node": "^22.5.2", "@typescript-eslint/eslint-plugin": "^8.4.0", "@typescript-eslint/parser": "^8.4.0", diff --git a/web/pnpm-lock.yaml b/web/pnpm-lock.yaml index 21bf9b1..f006f24 100644 --- a/web/pnpm-lock.yaml +++ b/web/pnpm-lock.yaml @@ -120,9 +120,9 @@ importers: '@types/fs-extra': specifier: ^11.0.4 version: 11.0.4 - '@types/lodash': - specifier: ^4.17.7 - version: 4.17.7 + '@types/lodash-es': + specifier: ^4.17.12 + version: 4.17.12 '@types/node': specifier: ^22.5.2 version: 22.5.2 diff --git a/web/src/hooks/useDomWidth.ts b/web/src/hooks/useDomWidth.ts index eadd7de..1a0bc5a 100644 --- a/web/src/hooks/useDomWidth.ts +++ b/web/src/hooks/useDomWidth.ts @@ -1,5 +1,5 @@ import { ref, onMounted, onUnmounted } from 'vue'; -import { debounce } from 'lodash'; +import { debounce } from 'lodash-es'; /** * description: 获取页面宽度