mvframe 1.0.20 → 1.0.60
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.cursor/rules/component-hierarchy.mdc +63 -0
- package/.cursor/rules/data.mdc +70 -0
- package/.cursor/rules/global-components.mdc +49 -0
- package/.cursor/rules/router.mdc +17 -0
- package/.cursor/rules/script-setup.mdc +33 -0
- package/.cursor/rules/style-system.mdc +219 -0
- package/.cursor/rules/util.mdc +60 -0
- package/.cursor/rules/views.mdc +69 -0
- package/.cursor/skills/mvframe-app-init/SKILL.md +1 -1
- package/README.cn.md +1 -1
- package/README.md +1 -1
- package/dist/Config.js +77 -160
- package/dist/composition.js +414 -244
- package/dist/css/cpt.css +1 -1
- package/dist/css/style.css +1 -1
- package/dist/index.js +1 -1
- package/dist/lodash.js +1 -1
- package/dist/maps.js +6 -5
- package/dist/store-shared.js +72 -58
- package/dist/util.js +67 -65
- package/dist/vendor.js +6274 -2232
- package/package.json +11 -4
- package/scripts/build-host.js +108 -0
- package/scripts/install-cursor-skill.js +0 -0
- package/scripts/scaffold-app.js +29 -0
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mvframe",
|
|
3
3
|
"packageManager": "yarn@4.4.1",
|
|
4
|
-
"version": "1.0.
|
|
4
|
+
"version": "1.0.60",
|
|
5
5
|
"author": "matt avis",
|
|
6
6
|
"main": "./dist/index.js",
|
|
7
7
|
"module": "./dist/index.js",
|
|
@@ -39,17 +39,21 @@
|
|
|
39
39
|
"build": "node scripts/prebuild.js",
|
|
40
40
|
"install-cursor-skill": "node scripts/install-cursor-skill.js",
|
|
41
41
|
"scaffold-app": "node scripts/scaffold-app.js",
|
|
42
|
-
"gen-icon": "node scripts/gen-iconfont-ant-names.js"
|
|
42
|
+
"gen-icon": "node scripts/gen-iconfont-ant-names.js",
|
|
43
|
+
"b": "node scripts/build-host.js"
|
|
43
44
|
},
|
|
44
45
|
"bin": {
|
|
45
46
|
"mvframe-init-app": "scripts/scaffold-app.js",
|
|
46
|
-
"mvframe-install-cursor-skill": "scripts/install-cursor-skill.js"
|
|
47
|
+
"mvframe-install-cursor-skill": "scripts/install-cursor-skill.js",
|
|
48
|
+
"mvframe-b": "scripts/build-host.js"
|
|
47
49
|
},
|
|
48
50
|
"files": [
|
|
49
51
|
"dist/*",
|
|
52
|
+
"scripts/build-host.js",
|
|
50
53
|
"scripts/install-cursor-skill.js",
|
|
51
54
|
"scripts/scaffold-app.js",
|
|
52
|
-
".cursor/skills/mvframe-app-init"
|
|
55
|
+
".cursor/skills/mvframe-app-init",
|
|
56
|
+
".cursor/rules"
|
|
53
57
|
],
|
|
54
58
|
"peerDependencies": {
|
|
55
59
|
"element-plus": "^2.2.0"
|
|
@@ -57,7 +61,9 @@
|
|
|
57
61
|
"dependencies": {
|
|
58
62
|
"@visactor/vtable": "^1.26.0",
|
|
59
63
|
"@visactor/vtable-editors": "^1.26.0",
|
|
64
|
+
"axios": "^1.7.9",
|
|
60
65
|
"dayjs": "^1.11.20",
|
|
66
|
+
"flag-icons": "^7.2.3",
|
|
61
67
|
"pinia": "^3.0.0",
|
|
62
68
|
"vue": "^3.3.4",
|
|
63
69
|
"vue-router": "^4.6.3",
|
|
@@ -66,6 +72,7 @@
|
|
|
66
72
|
"devDependencies": {
|
|
67
73
|
"@vitejs/plugin-vue": "^5.2.1",
|
|
68
74
|
"@vue/shared": "^3.5.25",
|
|
75
|
+
"devrq": "file:../devrq",
|
|
69
76
|
"element-plus": "^2.13.6",
|
|
70
77
|
"rollup-plugin-terser": "^7.0.2",
|
|
71
78
|
"sass-embedded": "^1.97.3",
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* 宿主 Vite 工程:打包后写入与 mstar 一致的 `serve.json`(SPA 回写 index.html)。
|
|
4
|
+
*
|
|
5
|
+
* 在宿主 `package.json` 中增加:`"b": "mvframe-b"`
|
|
6
|
+
* 然后执行 `yarn b` 或 `yarn b [outDir] [-t|-p]`。
|
|
7
|
+
*
|
|
8
|
+
* - 默认:--mode development,输出目录 `dev`
|
|
9
|
+
* - `-t`:--mode test,输出 `test`
|
|
10
|
+
* - `-p`:--mode production,输出 `pre`(Vite 环境为 production,对应 .env.production*)
|
|
11
|
+
* - 一个位置参数:自定义输出目录(与 -t / -p 同用时,以 -t / -p 为准)
|
|
12
|
+
*/
|
|
13
|
+
const { spawnSync } = require("child_process");
|
|
14
|
+
const fs = require("fs");
|
|
15
|
+
const path = require("path");
|
|
16
|
+
const SERVE_JSON = `{
|
|
17
|
+
"rewrites": [{
|
|
18
|
+
"source": "**",
|
|
19
|
+
"destination": "/index.html"
|
|
20
|
+
}]
|
|
21
|
+
}`;
|
|
22
|
+
|
|
23
|
+
function parseArgs(argv) {
|
|
24
|
+
const args = argv.slice(2);
|
|
25
|
+
let mode = "development";
|
|
26
|
+
let outDir = "dev";
|
|
27
|
+
let preset = false;
|
|
28
|
+
const positional = [];
|
|
29
|
+
|
|
30
|
+
for (const a of args) {
|
|
31
|
+
if (a === "-t") {
|
|
32
|
+
mode = "test";
|
|
33
|
+
outDir = "test";
|
|
34
|
+
preset = true;
|
|
35
|
+
} else if (a === "-p") {
|
|
36
|
+
mode = "production";
|
|
37
|
+
outDir = "pre";
|
|
38
|
+
preset = true;
|
|
39
|
+
} else if (a.startsWith("-")) {
|
|
40
|
+
console.error(`[mvframe-b] 未知参数: ${a}`);
|
|
41
|
+
process.exit(1);
|
|
42
|
+
} else {
|
|
43
|
+
positional.push(a);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
if (positional.length > 1) {
|
|
48
|
+
console.error(
|
|
49
|
+
"[mvframe-b] 用法: yarn b [outDir] [-t|-p]\n 默认: outDir=dev, mode=development; -t: test/test; -p: pre/production",
|
|
50
|
+
);
|
|
51
|
+
process.exit(1);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
if (positional.length === 1) {
|
|
55
|
+
if (preset) {
|
|
56
|
+
console.warn(
|
|
57
|
+
`[mvframe-b] 已使用 -t/-p,忽略输出目录参数 "${positional[0]}",实际输出: ${outDir}`,
|
|
58
|
+
);
|
|
59
|
+
} else {
|
|
60
|
+
outDir = positional[0];
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
return { mode, outDir };
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* 使用磁盘路径定位 Vite CLI(Vite 7+ 的 `exports` 会阻止 `require.resolve("vite/bin/...")`)。
|
|
69
|
+
*/
|
|
70
|
+
function resolveViteCli(cwd) {
|
|
71
|
+
const vpkg = path.join(cwd, "node_modules", "vite", "package.json");
|
|
72
|
+
if (fs.existsSync(vpkg)) {
|
|
73
|
+
const p = require(vpkg);
|
|
74
|
+
const b = p.bin;
|
|
75
|
+
const bin = typeof b === "string" ? b : b && b.vite;
|
|
76
|
+
if (bin) {
|
|
77
|
+
const cli = path.join(path.dirname(vpkg), bin);
|
|
78
|
+
if (fs.existsSync(cli)) {
|
|
79
|
+
return cli;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
throw new Error(
|
|
84
|
+
"未在宿主项目找到可执行的 Vite(请在工程 devDependencies 中安装 `vite` 后再执行 `yarn b` 或 `mvframe-b`)",
|
|
85
|
+
);
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
function main() {
|
|
89
|
+
const cwd = process.cwd();
|
|
90
|
+
const { mode, outDir } = parseArgs(process.argv);
|
|
91
|
+
const viteEntry = resolveViteCli(cwd);
|
|
92
|
+
const env = { ...process.env, NODE_ENV: "production" };
|
|
93
|
+
const child = spawnSync(
|
|
94
|
+
process.execPath,
|
|
95
|
+
[viteEntry, "build", "--outDir", outDir, "--mode", mode],
|
|
96
|
+
{ stdio: "inherit", cwd, env, shell: false },
|
|
97
|
+
);
|
|
98
|
+
if (child.status !== 0) {
|
|
99
|
+
process.exit(child.status === null ? 1 : child.status);
|
|
100
|
+
}
|
|
101
|
+
const outAbs = path.resolve(cwd, outDir);
|
|
102
|
+
fs.mkdirSync(outAbs, { recursive: true });
|
|
103
|
+
const servePath = path.join(outAbs, "serve.json");
|
|
104
|
+
fs.writeFileSync(servePath, `${SERVE_JSON}\n`, "utf8");
|
|
105
|
+
console.log(`[mvframe-b] 已写入 ${path.relative(cwd, servePath)}`);
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
main();
|
|
File without changes
|
package/scripts/scaffold-app.js
CHANGED
|
@@ -34,6 +34,27 @@ function write(rel, content) {
|
|
|
34
34
|
console.log("[mvframe-init] 写入", rel);
|
|
35
35
|
}
|
|
36
36
|
|
|
37
|
+
/**
|
|
38
|
+
* 将本包 `.cursor/rules/*.mdc` 复制到目标工程,与 mvframe 仓库内 Cursor 规则保持一致。
|
|
39
|
+
* 发布包需在 `package.json` 的 `files` 中包含 `.cursor/rules`。
|
|
40
|
+
*/
|
|
41
|
+
function copyCursorRulesFromPackage() {
|
|
42
|
+
const rulesSrc = path.join(__dirname, "..", ".cursor", "rules");
|
|
43
|
+
if (!fs.existsSync(rulesSrc)) {
|
|
44
|
+
console.warn(
|
|
45
|
+
"[mvframe-init] 未找到包内 .cursor/rules(请使用含该目录的 mvframe 版本),跳过 Cursor 规则复制",
|
|
46
|
+
);
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
const entries = fs.readdirSync(rulesSrc, { withFileTypes: true });
|
|
50
|
+
for (const ent of entries) {
|
|
51
|
+
if (!ent.isFile() || !ent.name.endsWith(".mdc")) continue;
|
|
52
|
+
const content = fs.readFileSync(path.join(rulesSrc, ent.name), "utf8");
|
|
53
|
+
const rel = path.join(".cursor", "rules", ent.name);
|
|
54
|
+
write(rel.replace(/\\/g, "/"), content);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
37
58
|
/** 与 main.js / vite.config 模板一致;版本号与 mvframe 本仓库对齐思路,可随发布调整 */
|
|
38
59
|
// @vue/shared 为 Vue 3 内部包,传递依赖在部分包管理器下未提升时 Vite 解析失败,故写入直连依赖
|
|
39
60
|
const SCAFFOLD_DEPENDENCIES = {
|
|
@@ -124,6 +145,8 @@ function main() {
|
|
|
124
145
|
fs.mkdirSync(path.join(target, d), { recursive: true });
|
|
125
146
|
}
|
|
126
147
|
|
|
148
|
+
copyCursorRulesFromPackage();
|
|
149
|
+
|
|
127
150
|
write(
|
|
128
151
|
"src/main.js",
|
|
129
152
|
`import { createApp } from "vue";
|
|
@@ -754,6 +777,12 @@ yarn install
|
|
|
754
777
|
| \`src/maps/index.js\` | 与库内置 \`maps/chip\` 深度合并(模块内);\`useMap().$l()\` / \`mapLangPath\` / \`mapLang\` 可由 auto-import 从 \`mvframe/maps\` 引入 |
|
|
755
778
|
| \`src/composition\` | 可选,与 Vite 别名 \`@cps\` 对应 |
|
|
756
779
|
|
|
780
|
+
## Cursor 规则(\`.cursor/rules\`)
|
|
781
|
+
|
|
782
|
+
初始化脚本会把 **mvframe 包内**与仓库一致的 **\`*.mdc\`** 写入目标项目 **\`/.cursor/rules/\`**(\`component-hierarchy\`、\`script-setup\`、\`style-system\`、\`views\`、\`router\`、\`global-components\`、\`data\`、\`util\`)。若目录或文件已存在且未加 \`--force\`,则跳过对应文件。
|
|
783
|
+
|
|
784
|
+
npm 包需在 \`files\` 中包含 \`.cursor/rules\`;使用本地 \`file:\` / 源码链接时同样可用。
|
|
785
|
+
|
|
757
786
|
## Cursor Skill(可选)
|
|
758
787
|
|
|
759
788
|
\`\`\`bash
|