mvframe 1.0.73 → 1.0.75
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 +64 -1
- package/README.md +51 -1
- package/dist/index.js +11 -10
- package/dist/notify.js +80 -0
- package/dist/vendor.js +434 -425
- package/package.json +13 -4
- package/scripts/dev-with-notify.js +92 -0
- package/scripts/notify-server.js +405 -0
- package/scripts/scaffold-app.js +121 -1
package/scripts/scaffold-app.js
CHANGED
|
@@ -36,6 +36,22 @@ function write(rel, content) {
|
|
|
36
36
|
console.log("[mvframe-init] 写入", rel);
|
|
37
37
|
}
|
|
38
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
|
+
|
|
39
55
|
/**
|
|
40
56
|
* 将本包 `.cursor/rules/*.mdc` 复制到目标工程,与 mvframe 仓库内 Cursor 规则保持一致。
|
|
41
57
|
* 发布包需在 `package.json` 的 `files` 中包含 `.cursor/rules`。
|
|
@@ -83,6 +99,11 @@ const SCAFFOLD_SCRIPTS = {
|
|
|
83
99
|
preview: "vite preview",
|
|
84
100
|
};
|
|
85
101
|
|
|
102
|
+
const TEST_DINGTALK_WEBHOOK =
|
|
103
|
+
"https://oapi.dingtalk.com/robot/send?access_token=142b6ddc73e8656b7906a3cb3982836a59f430a6fe5ef619a5689eed91d5f9f7";
|
|
104
|
+
const TEST_DINGTALK_SECRET =
|
|
105
|
+
"SEC7140677a84a5190046e22d508548923dd2c4f485e38896aa0c3555ae003f4ef5";
|
|
106
|
+
|
|
86
107
|
/**
|
|
87
108
|
* 合并 package.json:保留原有字段与其它依赖;仅补足脚手架所需包与启动脚本。
|
|
88
109
|
* 同名依赖以目标项目已有版本为准({ ...建议, ...已有 })。
|
|
@@ -166,6 +187,7 @@ function main() {
|
|
|
166
187
|
|
|
167
188
|
copyCursorRulesFromPackage();
|
|
168
189
|
upsertCodexAgents(target);
|
|
190
|
+
appendGitignoreLines([".env.local", ".env.mvframe-notify"]);
|
|
169
191
|
|
|
170
192
|
write(
|
|
171
193
|
"src/main.js",
|
|
@@ -354,6 +376,12 @@ export default {
|
|
|
354
376
|
// url: "//at.alicdn.com/t/c/your_font.js",
|
|
355
377
|
// prefix: "ant",
|
|
356
378
|
},
|
|
379
|
+
notify: {
|
|
380
|
+
enabled: true,
|
|
381
|
+
endpoint: import.meta.env.VITE_MVFRAME_NOTIFY_ENDPOINT || "http://127.0.0.1:3300",
|
|
382
|
+
token: import.meta.env.VITE_MVFRAME_NOTIFY_TOKEN || "",
|
|
383
|
+
timeout: 5000,
|
|
384
|
+
},
|
|
357
385
|
table: {
|
|
358
386
|
summaryMetric: null,
|
|
359
387
|
},
|
|
@@ -732,6 +760,56 @@ export default defineConfig({
|
|
|
732
760
|
);
|
|
733
761
|
}
|
|
734
762
|
|
|
763
|
+
write(
|
|
764
|
+
".env.mvframe-notify.example",
|
|
765
|
+
`# Copy to .env.mvframe-notify for the local Node notify service.
|
|
766
|
+
# Do not put DingTalk webhook/secret in src/main.js or other browser-bundled files.
|
|
767
|
+
# The DingTalk values below are MVFrame's test robot config. Replace them for production.
|
|
768
|
+
|
|
769
|
+
MVFRAME_NOTIFY_PORT=3300
|
|
770
|
+
MVFRAME_NOTIFY_HOST=127.0.0.1
|
|
771
|
+
MVFRAME_NOTIFY_TOKEN=
|
|
772
|
+
MVFRAME_NOTIFY_TIMEOUT_MS=5000
|
|
773
|
+
MVFRAME_NOTIFY_CORS_ORIGIN=*
|
|
774
|
+
|
|
775
|
+
DINGTALK_WEBHOOK="${TEST_DINGTALK_WEBHOOK}"
|
|
776
|
+
DINGTALK_SECRET="${TEST_DINGTALK_SECRET}"
|
|
777
|
+
DINGTALK_AT_MOBILES=""
|
|
778
|
+
DINGTALK_AT_USER_IDS=""
|
|
779
|
+
DINGTALK_AT_ALL=""
|
|
780
|
+
`,
|
|
781
|
+
);
|
|
782
|
+
|
|
783
|
+
write(
|
|
784
|
+
".env.mvframe-notify",
|
|
785
|
+
`# Local MVFrame DingTalk notify service config.
|
|
786
|
+
# This file is generated for test use and is ignored by git.
|
|
787
|
+
# Replace the DingTalk webhook/secret before production use.
|
|
788
|
+
|
|
789
|
+
MVFRAME_NOTIFY_PORT=3300
|
|
790
|
+
MVFRAME_NOTIFY_HOST=127.0.0.1
|
|
791
|
+
MVFRAME_NOTIFY_TOKEN=
|
|
792
|
+
MVFRAME_NOTIFY_TIMEOUT_MS=5000
|
|
793
|
+
MVFRAME_NOTIFY_CORS_ORIGIN=*
|
|
794
|
+
|
|
795
|
+
DINGTALK_WEBHOOK="${TEST_DINGTALK_WEBHOOK}"
|
|
796
|
+
DINGTALK_SECRET="${TEST_DINGTALK_SECRET}"
|
|
797
|
+
DINGTALK_AT_MOBILES=""
|
|
798
|
+
DINGTALK_AT_USER_IDS=""
|
|
799
|
+
DINGTALK_AT_ALL=""
|
|
800
|
+
`,
|
|
801
|
+
);
|
|
802
|
+
|
|
803
|
+
write(
|
|
804
|
+
".env.local.example",
|
|
805
|
+
`# Copy to .env.local when you need the browser app to call mvframe-notify.
|
|
806
|
+
# VITE_MVFRAME_NOTIFY_TOKEN should match MVFRAME_NOTIFY_TOKEN in .env.mvframe-notify.
|
|
807
|
+
|
|
808
|
+
VITE_MVFRAME_NOTIFY_ENDPOINT=http://127.0.0.1:3300
|
|
809
|
+
VITE_MVFRAME_NOTIFY_TOKEN=
|
|
810
|
+
`,
|
|
811
|
+
);
|
|
812
|
+
|
|
735
813
|
write(
|
|
736
814
|
"MVFRAME-SCAFFOLD.md",
|
|
737
815
|
`# MVFrame 雏形已生成
|
|
@@ -744,6 +822,12 @@ export default defineConfig({
|
|
|
744
822
|
yarn dev
|
|
745
823
|
\`\`\`
|
|
746
824
|
|
|
825
|
+
如需同时启动 Vite 与 MVFrame 钉钉通知服务,可显式执行框架命令(与 \`mvframe-b\` 类似由 MVFrame 包提供,不会自动覆盖宿主脚本):
|
|
826
|
+
|
|
827
|
+
\`\`\`bash
|
|
828
|
+
yarn exec mvframe-d
|
|
829
|
+
\`\`\`
|
|
830
|
+
|
|
747
831
|
若需跳过对 \`package.json\` 的修改:\`node scripts/scaffold-app.js --no-package-json\`。
|
|
748
832
|
|
|
749
833
|
自动生成的 \`vite.config.js\` 已包含 \`unplugin-auto-import\`;\`dts: true\` 时类型默认写在项目根 \`auto-imports.d.ts\`。
|
|
@@ -778,7 +862,43 @@ yarn dev
|
|
|
778
862
|
|
|
779
863
|
## 子路径(按需)
|
|
780
864
|
|
|
781
|
-
发布包 \`exports\` 还提供 \`mvframe/composition\`、\`mvframe/util\`、\`mvframe/store\` 等,业务侧可 \`import { ... } from "mvframe/composition"\` 等,参见包内 \`package.json\` 的 \`exports\`。
|
|
865
|
+
发布包 \`exports\` 还提供 \`mvframe/composition\`、\`mvframe/util\`、\`mvframe/store\`、\`mvframe/notify\` 等,业务侧可 \`import { ... } from "mvframe/composition"\` 等,参见包内 \`package.json\` 的 \`exports\`。
|
|
866
|
+
|
|
867
|
+
## 钉钉通知(mvframe-notify)
|
|
868
|
+
|
|
869
|
+
脚手架已初始化:
|
|
870
|
+
|
|
871
|
+
- \`src/config/index.js\` 的 \`notify\` 节点:浏览器端只保存本地服务地址和访问 token。
|
|
872
|
+
- \`.env.mvframe-notify\` 与 \`.env.mvframe-notify.example\`:已写入 MVFrame 测试钉钉机器人配置,生产环境请替换 \`DINGTALK_WEBHOOK\` / \`DINGTALK_SECRET\`。
|
|
873
|
+
- \`.env.local.example\`:复制为 \`.env.local\`,填写 \`VITE_MVFRAME_NOTIFY_ENDPOINT\` / \`VITE_MVFRAME_NOTIFY_TOKEN\`。
|
|
874
|
+
|
|
875
|
+
启动通知服务:
|
|
876
|
+
|
|
877
|
+
\`\`\`bash
|
|
878
|
+
yarn exec mvframe-notify
|
|
879
|
+
\`\`\`
|
|
880
|
+
|
|
881
|
+
同时启动 Vite 和通知服务:
|
|
882
|
+
|
|
883
|
+
\`\`\`bash
|
|
884
|
+
yarn exec mvframe-d
|
|
885
|
+
\`\`\`
|
|
886
|
+
|
|
887
|
+
前端发送:
|
|
888
|
+
|
|
889
|
+
\`\`\`js
|
|
890
|
+
await globalThis.$notify.send("需要发送到钉钉的消息");
|
|
891
|
+
\`\`\`
|
|
892
|
+
|
|
893
|
+
或按需导入:
|
|
894
|
+
|
|
895
|
+
\`\`\`js
|
|
896
|
+
import { notify } from "mvframe/notify";
|
|
897
|
+
|
|
898
|
+
await notify("需要发送到钉钉的消息");
|
|
899
|
+
\`\`\`
|
|
900
|
+
|
|
901
|
+
注意:钉钉 webhook / secret 不应写进 \`main.js\`、\`src/config/index.js\` 或任何会被 Vite 打包到浏览器的文件。
|
|
782
902
|
|
|
783
903
|
## 目录约定
|
|
784
904
|
|