Skip to content

Commit 562413b

Browse files
支持 await/async
1 parent e1091fc commit 562413b

File tree

17 files changed

+172
-55
lines changed

17 files changed

+172
-55
lines changed

examples/event/.pages.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
routes:
2+
- path: "**"
3+
js:
4+
exec: "index.js"
5+
debug: true

examples/event/index.html

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<!doctype html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8">
5+
<meta name="viewport"
6+
content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
7+
<meta http-equiv="X-UA-Compatible" content="ie=edge">
8+
<title>JS 概念验证</title>
9+
</head>
10+
<body>
11+
</body>
12+
</html>

examples/event/index.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
function sleep(ms) {
2+
return new Promise(resolve => setTimeout(resolve, ms));
3+
}
4+
console.log('boot');
5+
(async () => {
6+
console.log(0);
7+
await sleep(1000);
8+
console.log(1000);
9+
await sleep(1000);
10+
console.log(2000);
11+
await sleep(1000);
12+
console.log(3000);
13+
await sleep(1000);
14+
console.log(4000);
15+
await sleep(1000);
16+
console.log(5000);
17+
})();
18+
console.log('boot end');
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

pkg/core/domain.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ func (p *PageDomain) returnMeta(ctx context.Context, owner, repo, branch string,
7272
result := &PageContent{}
7373
meta, err := p.GetMeta(ctx, owner, repo, branch)
7474
if err != nil {
75-
zap.L().Debug("查询错误", zap.Error(err))
75+
zap.L().Debug("repo does not exists", zap.Error(err), zap.Strings("meta", []string{owner, repo, branch}))
7676
if meta != nil {
7777
// 解析错误汇报
7878
return nil, errors.New(meta.ErrorMsg)
@@ -85,7 +85,7 @@ func (p *PageDomain) returnMeta(ctx context.Context, owner, repo, branch string,
8585
result.Path = strings.Join(path, "/")
8686

8787
if err = p.alias.Bind(ctx, meta.Alias, result.Owner, result.Repo, branch); err != nil {
88-
zap.L().Warn("别名绑定失败", zap.Error(err))
88+
zap.L().Warn("alias binding error.", zap.Error(err))
8989
return nil, err
9090
}
9191
return result, nil

pkg/filters/goja/debug.tmpl

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@
77
content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
88
<meta http-equiv="X-UA-Compatible" content="ie=edge">
99
<style>
10+
.clear{
11+
padding: 0;
12+
margin: 0;
13+
}
1014
body {
1115
font-family: Arial, sans-serif;
1216
margin: 0;
@@ -70,7 +74,7 @@
7074
<div class="section">
7175
<div class="section-header">控制台日志</div>
7276
<div class="section-content">
73-
<div class="log">{{- range .Logs }}<p>{{ .Time.Format "2006/01/02 15:04:05" }} - {{ .Level }} : {{ .Message }}</p>{{- end }}</div>
77+
<div class="log">{{- range .Logs }}<p class="clear">{{ .Time.Format "2006/01/02 15:04:05" }} - {{ .Level }} : {{ .Message }}</p>{{- end }}</div>
7478
</div>
7579
</div>
7680

0 commit comments

Comments
 (0)