From a78b20e1fb354fd8a48eb8415bde5f1f2dde0c6f Mon Sep 17 00:00:00 2001 From: hejl Date: Sun, 7 Sep 2025 04:36:05 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=AD=E9=97=B4=E6=88=90=E6=9E=9C=E5=85=88?= =?UTF-8?q?=E4=BF=9D=E5=AD=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- gofaster/app/package-lock.json | 397 ++++++++ gofaster/app/package.json | 1 + gofaster/app/plugins/route-mapping-plugin.js | 942 +++++++++++------- .../role-management/services/roleService.js | 12 + .../role-management/views/RoleManagement.vue | 8 +- .../route-sync/direct-route-mappings.js | 261 ++--- .../user-management/services/userService.js | 17 + .../app/src/renderer/views/UserManagement.vue | 8 +- .../app/src/renderer/views/UserProfile.vue | 4 +- 9 files changed, 1125 insertions(+), 525 deletions(-) diff --git a/gofaster/app/package-lock.json b/gofaster/app/package-lock.json index 9a67155..da0100f 100644 --- a/gofaster/app/package-lock.json +++ b/gofaster/app/package-lock.json @@ -24,6 +24,7 @@ "@vue/compiler-sfc": "^3.5.21", "concurrently": "^9.2.0", "cross-env": "^7.0.3", + "dependency-cruiser": "^17.0.1", "electron-builder": "^26.0.12", "electron-reload": "^2.0.0-alpha.1", "global": "^4.4.0", @@ -2184,6 +2185,36 @@ "acorn": "^8.14.0" } }, + "node_modules/acorn-jsx": { + "version": "5.3.2", + "resolved": "https://registry.npmmirror.com/acorn-jsx/-/acorn-jsx-5.3.2.tgz", + "integrity": "sha512-rq9s+JNhf0IChjtDXxllJ7g41oZk5SlXtp0LHwyA5cejwn7vKmKp4pPri6YEePv2PU65sAsegbXtIinmDFDXgQ==", + "dev": true, + "license": "MIT", + "peerDependencies": { + "acorn": "^6.0.0 || ^7.0.0 || ^8.0.0" + } + }, + "node_modules/acorn-jsx-walk": { + "version": "2.0.0", + "resolved": "https://registry.npmmirror.com/acorn-jsx-walk/-/acorn-jsx-walk-2.0.0.tgz", + "integrity": "sha512-uuo6iJj4D4ygkdzd6jPtcxs8vZgDX9YFIkqczGImoypX2fQ4dVImmu3UzA4ynixCIMTrEOWW+95M2HuBaCEOVA==", + "dev": true, + "license": "MIT" + }, + "node_modules/acorn-loose": { + "version": "8.5.2", + "resolved": "https://registry.npmmirror.com/acorn-loose/-/acorn-loose-8.5.2.tgz", + "integrity": "sha512-PPvV6g8UGMGgjrMu+n/f9E/tCSkNQ2Y97eFvuVdJfG11+xdIeDcLyNdC8SHcrHbRqkfwLASdplyR6B6sKM1U4A==", + "dev": true, + "license": "MIT", + "dependencies": { + "acorn": "^8.15.0" + }, + "engines": { + "node": ">=0.4.0" + } + }, "node_modules/acorn-walk": { "version": "8.3.4", "resolved": "https://registry.npmjs.org/acorn-walk/-/acorn-walk-8.3.4.tgz", @@ -4576,6 +4607,129 @@ "node": ">= 0.8" } }, + "node_modules/dependency-cruiser": { + "version": "17.0.1", + "resolved": "https://registry.npmmirror.com/dependency-cruiser/-/dependency-cruiser-17.0.1.tgz", + "integrity": "sha512-4clZ8EPsOVoxGA8NMjaE95aJEO118Cd9D7gT5rysx5azij9cPiCSrnjYlZtV+90PFazlD2lZvjzBHkD1ZqGqlw==", + "dev": true, + "license": "MIT", + "dependencies": { + "acorn": "^8.15.0", + "acorn-jsx": "^5.3.2", + "acorn-jsx-walk": "^2.0.0", + "acorn-loose": "^8.5.2", + "acorn-walk": "^8.3.4", + "ajv": "^8.17.1", + "commander": "^14.0.0", + "enhanced-resolve": "^5.18.2", + "ignore": "^7.0.5", + "interpret": "^3.1.1", + "is-installed-globally": "^1.0.0", + "json5": "^2.2.3", + "memoize": "^10.1.0", + "picomatch": "^4.0.3", + "prompts": "^2.4.2", + "rechoir": "^0.8.0", + "safe-regex": "^2.1.1", + "semver": "^7.7.2", + "tsconfig-paths-webpack-plugin": "^4.2.0", + "watskeburt": "^4.2.3" + }, + "bin": { + "depcruise": "bin/dependency-cruise.mjs", + "depcruise-baseline": "bin/depcruise-baseline.mjs", + "depcruise-fmt": "bin/depcruise-fmt.mjs", + "depcruise-wrap-stream-in-html": "bin/wrap-stream-in-html.mjs", + "dependency-cruise": "bin/dependency-cruise.mjs", + "dependency-cruiser": "bin/dependency-cruise.mjs" + }, + "engines": { + "node": "^20.12||^22||>=24" + } + }, + "node_modules/dependency-cruiser/node_modules/ajv": { + "version": "8.17.1", + "resolved": "https://registry.npmmirror.com/ajv/-/ajv-8.17.1.tgz", + "integrity": "sha512-B/gBuNg5SiMTrPkC+A2+cW0RszwxYmn6VYxB/inlBStS5nx6xHIt/ehKRhIMhqusl7a8LjQoZnjCs5vhwxOQ1g==", + "dev": true, + "license": "MIT", + "dependencies": { + "fast-deep-equal": "^3.1.3", + "fast-uri": "^3.0.1", + "json-schema-traverse": "^1.0.0", + "require-from-string": "^2.0.2" + }, + "funding": { + "type": "github", + "url": "https://github.com/sponsors/epoberezkin" + } + }, + "node_modules/dependency-cruiser/node_modules/commander": { + "version": "14.0.0", + "resolved": "https://registry.npmmirror.com/commander/-/commander-14.0.0.tgz", + "integrity": "sha512-2uM9rYjPvyq39NwLRqaiLtWHyDC1FvryJDa2ATTVims5YAS4PupsEQsDvP14FqhFr0P49CYDugi59xaxJlTXRA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=20" + } + }, + "node_modules/dependency-cruiser/node_modules/ignore": { + "version": "7.0.5", + "resolved": "https://registry.npmmirror.com/ignore/-/ignore-7.0.5.tgz", + "integrity": "sha512-Hs59xBNfUIunMFgWAbGX5cq6893IbWg4KnrjbYwX3tx0ztorVgTDA6B2sxf8ejHJ4wz8BqGUMYlnzNBer5NvGg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">= 4" + } + }, + "node_modules/dependency-cruiser/node_modules/json-schema-traverse": { + "version": "1.0.0", + "resolved": "https://registry.npmmirror.com/json-schema-traverse/-/json-schema-traverse-1.0.0.tgz", + "integrity": "sha512-NM8/P9n3XjXhIZn1lLhkFaACTOURQXjWhV4BA/RnOv8xvgqtqpAX9IO4mRQxSx1Rlo4tqzeqb0sOlruaOy3dug==", + "dev": true, + "license": "MIT" + }, + "node_modules/dependency-cruiser/node_modules/json5": { + "version": "2.2.3", + "resolved": "https://registry.npmmirror.com/json5/-/json5-2.2.3.tgz", + "integrity": "sha512-XmOWe7eyHYH14cLdVPoyg+GOH3rYX++KpzrylJwSW98t3Nk+U8XOl8FWKOgwtzdb8lXGf6zYwDUzeHMWfxasyg==", + "dev": true, + "license": "MIT", + "bin": { + "json5": "lib/cli.js" + }, + "engines": { + "node": ">=6" + } + }, + "node_modules/dependency-cruiser/node_modules/picomatch": { + "version": "4.0.3", + "resolved": "https://registry.npmmirror.com/picomatch/-/picomatch-4.0.3.tgz", + "integrity": "sha512-5gTmgEY/sqK6gFXLIsQNH19lWb4ebPDLA4SdLP7dsWkIXHWlG66oPuVvXSGFPppYZz8ZDZq0dYYrbHfBCVUb1Q==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/sponsors/jonschlinkert" + } + }, + "node_modules/dependency-cruiser/node_modules/semver": { + "version": "7.7.2", + "resolved": "https://registry.npmmirror.com/semver/-/semver-7.7.2.tgz", + "integrity": "sha512-RF0Fw+rO5AMf9MAyaRXI4AV0Ulj5lMHqVxxdSgiVbixSCXoEmmX/jk0CuJw4+3SqroYO9VoUh+HcuJivvtJemA==", + "dev": true, + "license": "ISC", + "bin": { + "semver": "bin/semver.js" + }, + "engines": { + "node": ">=10" + } + }, "node_modules/destroy": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/destroy/-/destroy-1.2.0.tgz", @@ -6104,6 +6258,22 @@ "node": ">=10" } }, + "node_modules/global-directory": { + "version": "4.0.1", + "resolved": "https://registry.npmmirror.com/global-directory/-/global-directory-4.0.1.tgz", + "integrity": "sha512-wHTUcDUoZ1H5/0iVqEudYW4/kAlN5cZ3j/bXn0Dpbizl9iaUVeWSHqiOjsgk6OW2bkLclbBjzewBz6weQ1zA2Q==", + "dev": true, + "license": "MIT", + "dependencies": { + "ini": "4.1.1" + }, + "engines": { + "node": ">=18" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, "node_modules/globalthis": { "version": "1.0.4", "resolved": "https://registry.npmjs.org/globalthis/-/globalthis-1.0.4.tgz", @@ -6686,6 +6856,26 @@ "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==", "dev": true }, + "node_modules/ini": { + "version": "4.1.1", + "resolved": "https://registry.npmmirror.com/ini/-/ini-4.1.1.tgz", + "integrity": "sha512-QQnnxNyfvmHFIsj7gkPcYymR8Jdw/o7mp5ZFihxn6h8Ci6fh3Dx4E1gPjpQEpIuPo9XVNY/ZUwh4BPMjGyL01g==", + "dev": true, + "license": "ISC", + "engines": { + "node": "^14.17.0 || ^16.13.0 || >=18.0.0" + } + }, + "node_modules/interpret": { + "version": "3.1.1", + "resolved": "https://registry.npmmirror.com/interpret/-/interpret-3.1.1.tgz", + "integrity": "sha512-6xwYfHbajpoF0xLW+iwLkhwgvLoZDfjYfoFNu8ftMoXINzwuymNLd9u/KmwtdT2GbR+/Cz66otEGEVVUHX9QLQ==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=10.13.0" + } + }, "node_modules/ip-address": { "version": "9.0.5", "resolved": "https://registry.npmjs.org/ip-address/-/ip-address-9.0.5.tgz", @@ -6807,6 +6997,23 @@ "node": ">=0.10.0" } }, + "node_modules/is-installed-globally": { + "version": "1.0.0", + "resolved": "https://registry.npmmirror.com/is-installed-globally/-/is-installed-globally-1.0.0.tgz", + "integrity": "sha512-K55T22lfpQ63N4KEN57jZUAaAYqYHEe8veb/TycJRk9DdSCLLcovXz/mL6mOnhQaZsQGwPhuFopdQIlqGSEjiQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "global-directory": "^4.0.1", + "is-path-inside": "^4.0.0" + }, + "engines": { + "node": ">=18" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, "node_modules/is-interactive": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/is-interactive/-/is-interactive-1.0.0.tgz", @@ -6831,6 +7038,19 @@ "node": ">=0.12.0" } }, + "node_modules/is-path-inside": { + "version": "4.0.0", + "resolved": "https://registry.npmmirror.com/is-path-inside/-/is-path-inside-4.0.0.tgz", + "integrity": "sha512-lJJV/5dYS+RcL8uQdBDW9c9uWFLLBNRyFhnAKXw5tVqLlKZ4RMGZKv+YQ/IA3OhD+RpbJa1LLFM1FQPGyIXvOA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, "node_modules/is-plain-obj": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/is-plain-obj/-/is-plain-obj-3.0.0.tgz", @@ -7120,6 +7340,16 @@ "node": ">=0.10.0" } }, + "node_modules/kleur": { + "version": "3.0.3", + "resolved": "https://registry.npmmirror.com/kleur/-/kleur-3.0.3.tgz", + "integrity": "sha512-eTIzlVOSUR+JxdDFepEYcBMtZ9Qqdef+rnzWdRZuMbOywu5tO2w2N7rqjoANZ5k9vywhL6Br1VRjUIgTQx4E8w==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6" + } + }, "node_modules/klona": { "version": "2.0.6", "resolved": "https://registry.npmjs.org/klona/-/klona-2.0.6.tgz", @@ -7567,6 +7797,22 @@ "node": ">= 4.0.0" } }, + "node_modules/memoize": { + "version": "10.1.0", + "resolved": "https://registry.npmmirror.com/memoize/-/memoize-10.1.0.tgz", + "integrity": "sha512-MMbFhJzh4Jlg/poq1si90XRlTZRDHVqdlz2mPyGJ6kqMpyHUyVpDd5gpFAvVehW64+RA1eKE9Yt8aSLY7w2Kgg==", + "dev": true, + "license": "MIT", + "dependencies": { + "mimic-function": "^5.0.1" + }, + "engines": { + "node": ">=18" + }, + "funding": { + "url": "https://github.com/sindresorhus/memoize?sponsor=1" + } + }, "node_modules/merge-descriptors": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/merge-descriptors/-/merge-descriptors-1.0.3.tgz", @@ -7662,6 +7908,19 @@ "node": ">=6" } }, + "node_modules/mimic-function": { + "version": "5.0.1", + "resolved": "https://registry.npmmirror.com/mimic-function/-/mimic-function-5.0.1.tgz", + "integrity": "sha512-VP79XUPxV2CigYP3jWwAUFSku2aKqBH7uTAapFWCBqutsbmDo96KY5o8uh6U+/YSIn5OxJnXp73beVkpqMIGhA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=18" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, "node_modules/mimic-response": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/mimic-response/-/mimic-response-1.0.1.tgz", @@ -9398,6 +9657,20 @@ "node": ">= 4" } }, + "node_modules/prompts": { + "version": "2.4.2", + "resolved": "https://registry.npmmirror.com/prompts/-/prompts-2.4.2.tgz", + "integrity": "sha512-NxNv/kLguCA7p3jE8oL2aEBsrJWgAakBpgmgK6lpPWV+WuOmY6r2/zbAVnP+T8bQlA0nzHXSJSJW0Hq7ylaD2Q==", + "dev": true, + "license": "MIT", + "dependencies": { + "kleur": "^3.0.3", + "sisteransi": "^1.0.5" + }, + "engines": { + "node": ">= 6" + } + }, "node_modules/proxy-addr": { "version": "2.0.7", "resolved": "https://registry.npmjs.org/proxy-addr/-/proxy-addr-2.0.7.tgz", @@ -9609,6 +9882,29 @@ "node": ">=8.10.0" } }, + "node_modules/rechoir": { + "version": "0.8.0", + "resolved": "https://registry.npmmirror.com/rechoir/-/rechoir-0.8.0.tgz", + "integrity": "sha512-/vxpCXddiX8NGfGO/mTafwjq4aFa/71pvamip0++IQk3zG8cbCj0fifNPrjjF1XMXUne91jL9OoxmdykoEtifQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "resolve": "^1.20.0" + }, + "engines": { + "node": ">= 10.13.0" + } + }, + "node_modules/regexp-tree": { + "version": "0.1.27", + "resolved": "https://registry.npmmirror.com/regexp-tree/-/regexp-tree-0.1.27.tgz", + "integrity": "sha512-iETxpjK6YoRWJG5o6hXLwvjYAoW+FEZn9os0PD/b6AP6xQwsa/Y7lCVgIixBbUPMfhu+i2LtdeAqVTgGlQarfA==", + "dev": true, + "license": "MIT", + "bin": { + "regexp-tree": "bin/regexp-tree" + } + }, "node_modules/relateurl": { "version": "0.2.7", "resolved": "https://registry.npmjs.org/relateurl/-/relateurl-0.2.7.tgz", @@ -9838,6 +10134,16 @@ } ] }, + "node_modules/safe-regex": { + "version": "2.1.1", + "resolved": "https://registry.npmmirror.com/safe-regex/-/safe-regex-2.1.1.tgz", + "integrity": "sha512-rx+x8AMzKb5Q5lQ95Zoi6ZbJqwCLkqi3XuJXp5P3rT8OEc6sZCJG5AE5dU3lsgRr/F4Bs31jSlVN+j5KrsGu9A==", + "dev": true, + "license": "MIT", + "dependencies": { + "regexp-tree": "~0.1.1" + } + }, "node_modules/safer-buffer": { "version": "2.1.2", "resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz", @@ -10261,6 +10567,13 @@ "node": ">= 10" } }, + "node_modules/sisteransi": { + "version": "1.0.5", + "resolved": "https://registry.npmmirror.com/sisteransi/-/sisteransi-1.0.5.tgz", + "integrity": "sha512-bLGGlR1QxBcynn2d5YmDX4MGjlZvy2MRBDRNHLJ8VI6l6+9FUiyTFNJ0IveOSP0bcXgVDPRcfGqA0pjaqUpfVg==", + "dev": true, + "license": "MIT" + }, "node_modules/slash": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/slash/-/slash-3.0.0.tgz", @@ -10558,6 +10871,16 @@ "node": ">=8" } }, + "node_modules/strip-bom": { + "version": "3.0.0", + "resolved": "https://registry.npmmirror.com/strip-bom/-/strip-bom-3.0.0.tgz", + "integrity": "sha512-vavAMRXOgBVNF6nyEEmL3DBK19iRpDcoIwW+swQ+CbGiu7lju6t+JklA1MHweoWtadgt4ISVUsXLyDq34ddcwA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=4" + } + }, "node_modules/strip-eof": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/strip-eof/-/strip-eof-1.0.0.tgz", @@ -11042,6 +11365,67 @@ "utf8-byte-length": "^1.0.1" } }, + "node_modules/tsconfig-paths": { + "version": "4.2.0", + "resolved": "https://registry.npmmirror.com/tsconfig-paths/-/tsconfig-paths-4.2.0.tgz", + "integrity": "sha512-NoZ4roiN7LnbKn9QqE1amc9DJfzvZXxF4xDavcOWt1BPkdx+m+0gJuPM+S0vCe7zTJMYUP0R8pO2XMr+Y8oLIg==", + "dev": true, + "license": "MIT", + "dependencies": { + "json5": "^2.2.2", + "minimist": "^1.2.6", + "strip-bom": "^3.0.0" + }, + "engines": { + "node": ">=6" + } + }, + "node_modules/tsconfig-paths-webpack-plugin": { + "version": "4.2.0", + "resolved": "https://registry.npmmirror.com/tsconfig-paths-webpack-plugin/-/tsconfig-paths-webpack-plugin-4.2.0.tgz", + "integrity": "sha512-zbem3rfRS8BgeNK50Zz5SIQgXzLafiHjOwUAvk/38/o1jHn/V5QAgVUcz884or7WYcPaH3N2CIfUc2u0ul7UcA==", + "dev": true, + "license": "MIT", + "dependencies": { + "chalk": "^4.1.0", + "enhanced-resolve": "^5.7.0", + "tapable": "^2.2.1", + "tsconfig-paths": "^4.1.2" + }, + "engines": { + "node": ">=10.13.0" + } + }, + "node_modules/tsconfig-paths-webpack-plugin/node_modules/chalk": { + "version": "4.1.2", + "resolved": "https://registry.npmmirror.com/chalk/-/chalk-4.1.2.tgz", + "integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==", + "dev": true, + "license": "MIT", + "dependencies": { + "ansi-styles": "^4.1.0", + "supports-color": "^7.1.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/chalk/chalk?sponsor=1" + } + }, + "node_modules/tsconfig-paths/node_modules/json5": { + "version": "2.2.3", + "resolved": "https://registry.npmmirror.com/json5/-/json5-2.2.3.tgz", + "integrity": "sha512-XmOWe7eyHYH14cLdVPoyg+GOH3rYX++KpzrylJwSW98t3Nk+U8XOl8FWKOgwtzdb8lXGf6zYwDUzeHMWfxasyg==", + "dev": true, + "license": "MIT", + "bin": { + "json5": "lib/cli.js" + }, + "engines": { + "node": ">=6" + } + }, "node_modules/tslib": { "version": "2.8.1", "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.8.1.tgz", @@ -11406,6 +11790,19 @@ "node": ">=10.13.0" } }, + "node_modules/watskeburt": { + "version": "4.2.3", + "resolved": "https://registry.npmmirror.com/watskeburt/-/watskeburt-4.2.3.tgz", + "integrity": "sha512-uG9qtQYoHqAsnT711nG5iZc/8M5inSmkGCOp7pFaytKG2aTfIca7p//CjiVzAE4P7hzaYuCozMjNNaLgmhbK5g==", + "dev": true, + "license": "MIT", + "bin": { + "watskeburt": "dist/run-cli.js" + }, + "engines": { + "node": "^18||>=20" + } + }, "node_modules/wbuf": { "version": "1.7.3", "resolved": "https://registry.npmjs.org/wbuf/-/wbuf-1.7.3.tgz", diff --git a/gofaster/app/package.json b/gofaster/app/package.json index 9b38ab0..69f3c37 100644 --- a/gofaster/app/package.json +++ b/gofaster/app/package.json @@ -38,6 +38,7 @@ "@vue/compiler-sfc": "^3.5.21", "concurrently": "^9.2.0", "cross-env": "^7.0.3", + "dependency-cruiser": "^17.0.1", "electron-builder": "^26.0.12", "electron-reload": "^2.0.0-alpha.1", "global": "^4.4.0", diff --git a/gofaster/app/plugins/route-mapping-plugin.js b/gofaster/app/plugins/route-mapping-plugin.js index 6277e82..24b1e7c 100644 --- a/gofaster/app/plugins/route-mapping-plugin.js +++ b/gofaster/app/plugins/route-mapping-plugin.js @@ -209,17 +209,15 @@ function routeMappingPlugin() { // 2. 收集API信息(第一层) const apiMappings = this.collectApiMappings(routes) - // 3. 关联页面与API(第三层) + // 3. 关联页面与API(第三层) - 启用并调整逻辑 const enhancedApiMappings = this.associatePagesWithApi(routes, apiMappings) - // 4. 清理和优化API映射(第四层) + // 4. 清理和优化API映射(第四层) - 启用并调整逻辑 const optimizedApiMappings = this.optimizeApiMappings(routes, enhancedApiMappings) - // 5. 分析组件关联关系并完善路径信息(第五层) - const { componentRelationships, enhancedApiMappings: finalApiMappings } = this.analyzeComponentRelationships(routes, optimizedApiMappings) - // 6. 生成最终映射文件 - this.generateMappingFile(routes, finalApiMappings) + // 5. 生成最终映射文件 + this.generateMappingFile(routes, optimizedApiMappings) console.log('✅ 第一阶段直接映射关系收集完成') } else { @@ -476,24 +474,24 @@ function routeMappingPlugin() { associatePagesWithApi(routes, apiMappings) { console.log('🔍 开始关联页面与API,输入API映射数量:', apiMappings.length) - // 为每个API映射添加调用该API的页面信息 + // 为每个API映射添加调用该API的页面信息和触发器信息 const enhancedApiMappings = apiMappings.map(moduleMapping => { console.log(`🔍 处理模块 ${moduleMapping.module},API映射数量:`, moduleMapping.apiMappings.length) const enhancedApiMappings = moduleMapping.apiMappings.map(apiMapping => { - // 查找调用该API方法的组件,并收集button触发器信息 - const callingComponents = this.findComponentsCallingApiMethodWithTriggers( + // 查找调用该API方法的组件,并收集triggerSources信息 + const triggerSources = this.findTriggerSourcesForApiMethod( routes, moduleMapping.module, moduleMapping.serviceName, apiMapping.methodName ) - console.log(`🔍 API方法 ${apiMapping.methodName} 的调用组件数量:`, callingComponents.length) + console.log(`🔍 API方法 ${apiMapping.methodName} 的触发器数量:`, triggerSources.length) return { ...apiMapping, - callingComponents: callingComponents + triggerSources: triggerSources } }) @@ -507,69 +505,17 @@ function routeMappingPlugin() { return enhancedApiMappings }, - // 查找调用特定API方法的组件 - findComponentsCallingApiMethod(routes, moduleName, serviceName, methodName) { - const callingComponents = [] - - // 1. 遍历所有路由,查找调用该API方法的页面组件 - routes.forEach(route => { - if (route.module === moduleName) { - const componentAnalysis = this.analyzeComponentForServiceCalls( - route.component, - route.path, - moduleName - ) - - if (componentAnalysis && componentAnalysis.serviceCalls) { - // 检查是否有调用该服务方法的调用 - const hasServiceCall = componentAnalysis.serviceCalls.some(serviceCall => - serviceCall.type === 'service' && - serviceCall.service === serviceName && - serviceCall.method === methodName - ) - - if (hasServiceCall) { - callingComponents.push(route.component) - } - } - } - }) - - // 2. 搜索模块的components目录,查找调用该API方法的组件 - const componentsInModule = this.findComponentsInModule(moduleName) - componentsInModule.forEach(componentName => { - const componentAnalysis = this.analyzeComponentForServiceCalls( - componentName, - null, // components目录中的组件没有路由路径 - moduleName - ) - - if (componentAnalysis && componentAnalysis.serviceCalls) { - // 检查是否有调用该服务方法的调用 - const hasServiceCall = componentAnalysis.serviceCalls.some(serviceCall => - serviceCall.type === 'service' && - serviceCall.service === serviceName && - serviceCall.method === methodName - ) - - if (hasServiceCall) { - callingComponents.push(componentName) - } - } - }) + // 查找API方法的触发器源 - 使用简化的方法 + findTriggerSourcesForApiMethod(routes, moduleName, serviceName, methodName) { + const triggerSources = [] - // 去重 - return [...new Set(callingComponents)] - }, - - // 查找调用特定API方法的组件,并收集button触发器信息 - findComponentsCallingApiMethodWithTriggers(routes, moduleName, serviceName, methodName) { - const callingComponents = [] + console.log(`🔍 查找API方法 ${serviceName}.${methodName} 的触发器源,模块: ${moduleName}`) // 1. 遍历所有路由,查找调用该API方法的页面组件 routes.forEach(route => { if (route.module === moduleName) { - const componentAnalysis = this.analyzeComponentForServiceCallsWithTriggers( + console.log(`🔍 检查路由组件: ${route.component}`) + const triggerAnalysis = this.analyzeComponentForTriggerSourcesSimple( route.component, route.path, moduleName, @@ -577,20 +523,20 @@ function routeMappingPlugin() { methodName ) - if (componentAnalysis && componentAnalysis.hasServiceCall) { - callingComponents.push({ - component: route.component, - path: route.path, - trigger_source: componentAnalysis.triggerSources - }) + if (triggerAnalysis && triggerAnalysis.triggerSources.length > 0) { + triggerSources.push(...triggerAnalysis.triggerSources) + console.log(`✅ 在组件 ${route.component} 中找到 ${triggerAnalysis.triggerSources.length} 个触发器`) } } }) // 2. 搜索模块的components目录,查找调用该API方法的组件 const componentsInModule = this.findComponentsInModule(moduleName) + console.log(`🔍 模块 ${moduleName} 的组件:`, componentsInModule) + componentsInModule.forEach(componentName => { - const componentAnalysis = this.analyzeComponentForServiceCallsWithTriggers( + console.log(`🔍 检查模块组件: ${componentName}`) + const triggerAnalysis = this.analyzeComponentForTriggerSourcesSimple( componentName, null, // components目录中的组件没有路由路径 moduleName, @@ -598,338 +544,407 @@ function routeMappingPlugin() { methodName ) - if (componentAnalysis && componentAnalysis.hasServiceCall) { - callingComponents.push({ - component: componentName, - path: null, - trigger_source: componentAnalysis.triggerSources - }) + if (triggerAnalysis && triggerAnalysis.triggerSources.length > 0) { + triggerSources.push(...triggerAnalysis.triggerSources) + console.log(`✅ 在组件 ${componentName} 中找到 ${triggerAnalysis.triggerSources.length} 个触发器`) } }) - return callingComponents + // 去重 + const uniqueTriggerSources = [] + const seen = new Set() + + triggerSources.forEach(trigger => { + const key = `${trigger.component}#${trigger.triggerName || 'default'}` + if (!seen.has(key)) { + seen.add(key) + uniqueTriggerSources.push(trigger) + } + }) + + console.log(`🔍 API方法 ${serviceName}.${methodName} 最终触发器数量:`, uniqueTriggerSources.length) + return uniqueTriggerSources }, - - // 查找模块中的所有组件 - findComponentsInModule(moduleName) { - const components = [] - + // 简化的组件触发器源分析方法 + analyzeComponentForTriggerSourcesSimple(componentName, componentPath, moduleName, serviceName, methodName) { try { - // 查找views目录中的组件 - const viewsPath = resolve(__dirname, `../src/renderer/modules/${moduleName}/views`) - if (existsSync(viewsPath)) { - const viewFiles = readdirSync(viewsPath).filter(f => f.endsWith('.vue')) - viewFiles.forEach(file => { - components.push(file.replace('.vue', '')) - }) + let filePath = componentPath + + console.log(`🔍 简化分析组件 ${componentName},查找服务 ${serviceName}.${methodName}`) + + // 如果是组件名,需要找到对应的文件 + if (!filePath || !existsSync(filePath)) { + filePath = this.findComponentFile(componentName) } - // 查找components目录中的组件 - const componentsPath = resolve(__dirname, `../src/renderer/modules/${moduleName}/components`) - if (existsSync(componentsPath)) { - const componentFiles = readdirSync(componentsPath).filter(f => f.endsWith('.vue')) - componentFiles.forEach(file => { - components.push(file.replace('.vue', '')) - }) + if (!filePath || !existsSync(filePath)) { + console.warn(`⚠️ 组件文件未找到: ${componentName}`) + return { triggerSources: [] } } + + console.log(`🔍 找到组件文件: ${filePath}`) + const content = readFileSync(filePath, 'utf-8') + + // 使用简化的文本搜索方法 + return this.analyzeComponentWithTextSearch(content, componentName, serviceName, methodName) + } catch (error) { - console.warn(`⚠️ 查找模块组件失败: ${moduleName}`, error.message) + console.warn(`⚠️ 简化分析组件触发器源失败: ${componentName}`, error.message) + return { triggerSources: [] } } - - return components }, - // 第四步:清理和优化API映射 - optimizeApiMappings(routes, apiMappings) { - - const optimizedApiMappings = apiMappings.map(moduleMapping => { - // 暂时不过滤空的调用组件,保留所有API映射 - const filteredApiMappings = moduleMapping.apiMappings.filter(apiMapping => { - return true // 保留所有API映射 - }) - - // 为每个API映射的callingComponents添加路径信息 - const enhancedApiMappings = filteredApiMappings.map(apiMapping => { - const enhancedCallingComponents = apiMapping.callingComponents.map(componentName => { - // 在routes中查找匹配的组件 - const matchingRoute = routes.find(route => route.component === componentName) - - if (matchingRoute) { - return { - component: componentName, - path: matchingRoute.path - } - } else { - // 如果找不到匹配的路由,只返回组件名 - return { - component: componentName, - path: null - } - } - }) - - return { - ...apiMapping, - callingComponents: enhancedCallingComponents - } - }) - - return { - ...moduleMapping, - apiMappings: enhancedApiMappings + // 使用文本搜索分析组件 + analyzeComponentWithTextSearch(content, componentName, serviceName, methodName) { + const triggerSources = [] + + console.log(`🔍 文本搜索组件 ${componentName},查找 ${serviceName}.${methodName}`) + + // 1. 检查组件的authType属性,如果是public则跳过 + // 支持两种格式: