mvframe 1.0.72 → 1.0.74
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/README.cn.md +80 -1
- package/README.md +67 -1
- package/dist/css/cpt.css +1 -1
- package/dist/index.js +11 -10
- package/dist/notify.js +80 -0
- package/dist/store-shared.js +3 -1
- package/dist/vendor.js +434 -425
- package/package.json +15 -3
- package/scripts/dev-with-notify.js +92 -0
- package/scripts/install-codex-agents.js +127 -0
- package/scripts/notify-server.js +405 -0
- package/scripts/scaffold-app.js +107 -1
package/scripts/scaffold-app.js
CHANGED
|
@@ -14,6 +14,7 @@
|
|
|
14
14
|
const fs = require("fs");
|
|
15
15
|
const path = require("path");
|
|
16
16
|
const { execFileSync } = require("child_process");
|
|
17
|
+
const { upsertCodexAgents } = require("./install-codex-agents.js");
|
|
17
18
|
|
|
18
19
|
const FORCE = process.argv.includes("--force");
|
|
19
20
|
const NO_PKG = process.argv.includes("--no-package-json");
|
|
@@ -35,6 +36,22 @@ function write(rel, content) {
|
|
|
35
36
|
console.log("[mvframe-init] 写入", rel);
|
|
36
37
|
}
|
|
37
38
|
|
|
39
|
+
function appendGitignoreLines(lines) {
|
|
40
|
+
const fp = path.join(target, ".gitignore");
|
|
41
|
+
const existing = fs.existsSync(fp) ? fs.readFileSync(fp, "utf8") : "";
|
|
42
|
+
const current = new Set(
|
|
43
|
+
existing
|
|
44
|
+
.split(/\r?\n/)
|
|
45
|
+
.map((line) => line.trim())
|
|
46
|
+
.filter(Boolean),
|
|
47
|
+
);
|
|
48
|
+
const missing = lines.filter((line) => !current.has(line));
|
|
49
|
+
if (missing.length === 0) return;
|
|
50
|
+
const prefix = existing && !existing.endsWith("\n") ? "\n" : "";
|
|
51
|
+
fs.writeFileSync(fp, `${existing}${prefix}${missing.join("\n")}\n`, "utf8");
|
|
52
|
+
console.log("[mvframe-init] 已更新 .gitignore");
|
|
53
|
+
}
|
|
54
|
+
|
|
38
55
|
/**
|
|
39
56
|
* 将本包 `.cursor/rules/*.mdc` 复制到目标工程,与 mvframe 仓库内 Cursor 规则保持一致。
|
|
40
57
|
* 发布包需在 `package.json` 的 `files` 中包含 `.cursor/rules`。
|
|
@@ -164,6 +181,8 @@ function main() {
|
|
|
164
181
|
}
|
|
165
182
|
|
|
166
183
|
copyCursorRulesFromPackage();
|
|
184
|
+
upsertCodexAgents(target);
|
|
185
|
+
appendGitignoreLines([".env.local", ".env.mvframe-notify"]);
|
|
167
186
|
|
|
168
187
|
write(
|
|
169
188
|
"src/main.js",
|
|
@@ -352,6 +371,12 @@ export default {
|
|
|
352
371
|
// url: "//at.alicdn.com/t/c/your_font.js",
|
|
353
372
|
// prefix: "ant",
|
|
354
373
|
},
|
|
374
|
+
notify: {
|
|
375
|
+
enabled: true,
|
|
376
|
+
endpoint: import.meta.env.VITE_MVFRAME_NOTIFY_ENDPOINT || "http://127.0.0.1:3300",
|
|
377
|
+
token: import.meta.env.VITE_MVFRAME_NOTIFY_TOKEN || "",
|
|
378
|
+
timeout: 5000,
|
|
379
|
+
},
|
|
355
380
|
table: {
|
|
356
381
|
summaryMetric: null,
|
|
357
382
|
},
|
|
@@ -730,6 +755,35 @@ export default defineConfig({
|
|
|
730
755
|
);
|
|
731
756
|
}
|
|
732
757
|
|
|
758
|
+
write(
|
|
759
|
+
".env.mvframe-notify.example",
|
|
760
|
+
`# Copy to .env.mvframe-notify and fill values for the local Node notify service.
|
|
761
|
+
# Do not put DingTalk webhook/secret in src/main.js or other browser-bundled files.
|
|
762
|
+
|
|
763
|
+
MVFRAME_NOTIFY_PORT=3300
|
|
764
|
+
MVFRAME_NOTIFY_HOST=127.0.0.1
|
|
765
|
+
MVFRAME_NOTIFY_TOKEN=
|
|
766
|
+
MVFRAME_NOTIFY_TIMEOUT_MS=5000
|
|
767
|
+
MVFRAME_NOTIFY_CORS_ORIGIN=*
|
|
768
|
+
|
|
769
|
+
DINGTALK_WEBHOOK="https://oapi.dingtalk.com/robot/send?access_token=xxxxxxxx"
|
|
770
|
+
DINGTALK_SECRET="SECxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
|
|
771
|
+
DINGTALK_AT_MOBILES=""
|
|
772
|
+
DINGTALK_AT_USER_IDS=""
|
|
773
|
+
DINGTALK_AT_ALL=""
|
|
774
|
+
`,
|
|
775
|
+
);
|
|
776
|
+
|
|
777
|
+
write(
|
|
778
|
+
".env.local.example",
|
|
779
|
+
`# Copy to .env.local when you need the browser app to call mvframe-notify.
|
|
780
|
+
# VITE_MVFRAME_NOTIFY_TOKEN should match MVFRAME_NOTIFY_TOKEN in .env.mvframe-notify.
|
|
781
|
+
|
|
782
|
+
VITE_MVFRAME_NOTIFY_ENDPOINT=http://127.0.0.1:3300
|
|
783
|
+
VITE_MVFRAME_NOTIFY_TOKEN=
|
|
784
|
+
`,
|
|
785
|
+
);
|
|
786
|
+
|
|
733
787
|
write(
|
|
734
788
|
"MVFRAME-SCAFFOLD.md",
|
|
735
789
|
`# MVFrame 雏形已生成
|
|
@@ -742,6 +796,12 @@ export default defineConfig({
|
|
|
742
796
|
yarn dev
|
|
743
797
|
\`\`\`
|
|
744
798
|
|
|
799
|
+
如需同时启动 Vite 与 MVFrame 钉钉通知服务,可显式执行框架命令(与 \`mvframe-b\` 类似由 MVFrame 包提供,不会自动覆盖宿主脚本):
|
|
800
|
+
|
|
801
|
+
\`\`\`bash
|
|
802
|
+
yarn exec mvframe-d
|
|
803
|
+
\`\`\`
|
|
804
|
+
|
|
745
805
|
若需跳过对 \`package.json\` 的修改:\`node scripts/scaffold-app.js --no-package-json\`。
|
|
746
806
|
|
|
747
807
|
自动生成的 \`vite.config.js\` 已包含 \`unplugin-auto-import\`;\`dts: true\` 时类型默认写在项目根 \`auto-imports.d.ts\`。
|
|
@@ -776,7 +836,43 @@ yarn dev
|
|
|
776
836
|
|
|
777
837
|
## 子路径(按需)
|
|
778
838
|
|
|
779
|
-
发布包 \`exports\` 还提供 \`mvframe/composition\`、\`mvframe/util\`、\`mvframe/store\` 等,业务侧可 \`import { ... } from "mvframe/composition"\` 等,参见包内 \`package.json\` 的 \`exports\`。
|
|
839
|
+
发布包 \`exports\` 还提供 \`mvframe/composition\`、\`mvframe/util\`、\`mvframe/store\`、\`mvframe/notify\` 等,业务侧可 \`import { ... } from "mvframe/composition"\` 等,参见包内 \`package.json\` 的 \`exports\`。
|
|
840
|
+
|
|
841
|
+
## 钉钉通知(mvframe-notify)
|
|
842
|
+
|
|
843
|
+
脚手架已初始化:
|
|
844
|
+
|
|
845
|
+
- \`src/config/index.js\` 的 \`notify\` 节点:浏览器端只保存本地服务地址和访问 token。
|
|
846
|
+
- \`.env.mvframe-notify.example\`:复制为 \`.env.mvframe-notify\`,填写 \`DINGTALK_WEBHOOK\` / \`DINGTALK_SECRET\`。
|
|
847
|
+
- \`.env.local.example\`:复制为 \`.env.local\`,填写 \`VITE_MVFRAME_NOTIFY_ENDPOINT\` / \`VITE_MVFRAME_NOTIFY_TOKEN\`。
|
|
848
|
+
|
|
849
|
+
启动通知服务:
|
|
850
|
+
|
|
851
|
+
\`\`\`bash
|
|
852
|
+
yarn exec mvframe-notify
|
|
853
|
+
\`\`\`
|
|
854
|
+
|
|
855
|
+
同时启动 Vite 和通知服务:
|
|
856
|
+
|
|
857
|
+
\`\`\`bash
|
|
858
|
+
yarn exec mvframe-d
|
|
859
|
+
\`\`\`
|
|
860
|
+
|
|
861
|
+
前端发送:
|
|
862
|
+
|
|
863
|
+
\`\`\`js
|
|
864
|
+
await globalThis.$notify.send("需要发送到钉钉的消息");
|
|
865
|
+
\`\`\`
|
|
866
|
+
|
|
867
|
+
或按需导入:
|
|
868
|
+
|
|
869
|
+
\`\`\`js
|
|
870
|
+
import { notify } from "mvframe/notify";
|
|
871
|
+
|
|
872
|
+
await notify("需要发送到钉钉的消息");
|
|
873
|
+
\`\`\`
|
|
874
|
+
|
|
875
|
+
注意:钉钉 webhook / secret 不应写进 \`main.js\`、\`src/config/index.js\` 或任何会被 Vite 打包到浏览器的文件。
|
|
780
876
|
|
|
781
877
|
## 目录约定
|
|
782
878
|
|
|
@@ -795,6 +891,16 @@ yarn dev
|
|
|
795
891
|
| \`src/maps/index.js\` | 与库内置 \`maps/chip\` 深度合并(模块内);\`useMap().$l()\` / \`mapLangPath\` / \`mapLang\` 可由 auto-import 从 \`mvframe/maps\` 引入 |
|
|
796
892
|
| \`src/composition\` | 可选,与 Vite 别名 \`@cps\` 对应 |
|
|
797
893
|
|
|
894
|
+
## Codex 规则(\`AGENTS.md\`)
|
|
895
|
+
|
|
896
|
+
初始化脚本会写入/更新项目根 **\`AGENTS.md\`** 的 MVFrame 区块,供 Codex 在宿主项目内优先使用 **MVFrame 全局组件、全局方法与全局样式工具类**。该区块带有 \`MVFRAME-CODEX-RULES\` 标记,重复执行脚手架会更新这段内容,不会覆盖你在 \`AGENTS.md\` 中的其它规则。
|
|
897
|
+
|
|
898
|
+
仅安装 Codex 规则:
|
|
899
|
+
|
|
900
|
+
\`\`\`bash
|
|
901
|
+
yarn exec mvframe-install-codex-rules
|
|
902
|
+
\`\`\`
|
|
903
|
+
|
|
798
904
|
## Cursor 规则(\`.cursor/rules\`)
|
|
799
905
|
|
|
800
906
|
初始化脚本会把 **mvframe 包内**与仓库一致的 **\`*.mdc\`** 写入目标项目 **\`/.cursor/rules/\`**(\`component-hierarchy\`、\`script-setup\`、\`style-system\`、\`views\`、\`router\`、\`global-components\`、\`data\`、\`util\`)。若目录或文件已存在且未加 \`--force\`,则跳过对应文件。
|