Skip to content

Commit 567137e

Browse files
author
niuweili
committed
Merge branch 'feat/voice_template'
2 parents acfc5d7 + f9f5cb4 commit 567137e

3 files changed

Lines changed: 62 additions & 5 deletions

File tree

flashduty/en/1. On-call/4. Configure On-call/4.7 Templates.md

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -555,7 +555,8 @@ If you want to display only key label information, you can refer to the code seg
555555
```
556556
</div>
557557
558-
<div class="sms hide">
558+
<div class="feishu hide">
559+
559560
560561
## Feishu/Lark Bot
561562
---
@@ -825,6 +826,7 @@ Description:{{toHtml .Description}}{{end}}{{if gt (len .Responders) 0}}
825826
Responders:{{range .Responders}}@{{.PersonName}} {{end}}{{end}}
826827
<br>Details:{{.DetailUrl}}
827828
```
829+
828830
</div>
829831

830832
<div class="dingtalk hide">
@@ -1069,6 +1071,19 @@ You have a pending incident: {{toHtml .Title}}, Channel: {{.ChannelName}}, Sever
10691071
```
10701072
</div>
10711073

1074+
1075+
<div class="voice hide">
1076+
1077+
## Voice
1078+
---
1079+
If no custom content is set, the system default template will be used for notifications:
1080+
1081+
```go
1082+
You have a pending incident: {{toHtml .Title}}, Channel: {{.ChannelName}}, Severity: {{.IncidentSeverity}}{{if gt .AlertCnt 1}}, Grouped {{.AlertCnt}} alerts{{end}}
1083+
```
1084+
</div>
1085+
1086+
10721087
<div class="email hide">
10731088

10741089
## Email

flashduty/zh/1. On-call/3. 配置管理/4.7 配置通知模板.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1072,6 +1072,17 @@ msg_type 必填,值为 post
10721072
```
10731073
</div>
10741074
1075+
<div class="voice hide">
1076+
1077+
## 语音
1078+
---
1079+
如果不设置自定义内容,将采用系统默认模板渲染通知:
1080+
1081+
```
1082+
您有故障待处理:{{toHtml .Title}},协作空间:{{.ChannelName}},等级:{{.IncidentSeverity}}{{if gt .AlertCnt 1}},共聚合{{.AlertCnt}}条告警{{end}}
1083+
```
1084+
</div>
1085+
10751086
<div class="email hide">
10761087
10771088
## 邮件

vite.config.js

Lines changed: 35 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,37 @@
11
import { resolve } from "path";
2+
import { readFileSync } from "fs";
23
import { defineConfig, mergeConfig } from "vite";
34

5+
// function formatMd(content) {
6+
// let result = content;
7+
// result = result.replace(/^---\n(.*\n)*?---\n*/, "");
8+
// result = result.replace(
9+
// /^[ \t]*:{3,}[ \t]*\w[^\n]*\n([\s\S]*?)^[ \t]*:{3,}[ \t]*$/gm,
10+
// (_, inner) => {
11+
// return inner
12+
// .trimEnd()
13+
// .split("\n")
14+
// .map((line) => `> ${line}`)
15+
// .join("\n");
16+
// }
17+
// );
18+
// return result;
19+
// }
20+
21+
function formatMarkdownPlugin() {
22+
return {
23+
name: "format-markdown-raw",
24+
enforce: "pre",
25+
load(id) {
26+
if (/\.md\?raw$/.test(id)) {
27+
const filePath = id.replace(/\?raw$/, "");
28+
const content = readFileSync(filePath, "utf-8");
29+
return `export default ${JSON.stringify(content)}`;
30+
}
31+
},
32+
};
33+
}
34+
435
function transformCodePlugin(mode) {
536
return {
637
name: "transform-code-plugin",
@@ -60,10 +91,10 @@ const iifeConfig = {
6091

6192
// 根据命令行参数选择配置
6293
export default defineConfig(({ command, mode }) => {
94+
const plugins = [formatMarkdownPlugin()];
6395
if (mode === "iife") {
64-
return mergeConfig(iifeConfig, {
65-
plugins: [transformCodePlugin(mode)],
66-
});
96+
plugins.push(transformCodePlugin(mode));
97+
return mergeConfig(iifeConfig, { plugins });
6798
}
68-
return esmConfig;
99+
return mergeConfig(esmConfig, { plugins });
69100
});

0 commit comments

Comments
 (0)