简书链接:百度低代码温习笔记
文章字数:731,阅读全文大约需要2分钟
前几个月研究了低代码很快给公司完成了一个简单的管理后台,当然,后端接口自己写的。前端全部自动化,
https://aisuda.bce.baidu.com/amis/zh-CN/docs/index

学了很多 但是长时间没弄,还是会遗忘,现在已经忘得完全不知道是怎么回事了,

我学过的东西很少有坚持持续的去回顾的。
想到了著名的费曼学习法,或许我只知道学试试新鲜感,却没有反复的去用,是导致我只能刚刚入门这样子,我想,我还是需要做点笔记的,虽然不会很详细,但是或许可以让我联想起来我曾经学过的东西 再次捡起来。。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<title>数据孪生后台管理系统</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta
name="viewport"
content="width=device-width, initial-scale=1, maximum-scale=1"
/>
<meta http-equiv="Access-Control-Allow-Origin" content="*" />
<meta http-equiv="X-UA-Compatible" content="IE=Edge" />
<link
rel="stylesheet"
title="default"
href="./sdk/sdk.css"
/>
<!-- href="https://unpkg.com/amis@beta/sdk/sdk.css" -->
<link
rel="stylesheet"
href="./sdk/helper.css"
/>
<!-- href="https://unpkg.com/amis@beta/sdk/helper.css" -->
<script src="./sdk/sdk.js"></script>
<!-- <script src="https://unpkg.com/amis@beta/sdk/sdk.js"></script> -->
<script src="https://unpkg.com/vue@2"></script>
<script src="https://unpkg.com/[email protected]
/umd/history.js"></script>
<style>
html,
body,
.app-wrapper {
position: relative;
width: 100%;
height: 100%;
margin: 0;
padding: 0;
}
</style>
</head>
<body>
<div id="root" class="app-wrapper"></div>
<script>
(function () {
let amis = amisRequire('amis/embed');
const match = amisRequire('path-to-regexp').match;

// 如果想用 browserHistory 请切换下这处代码, 其他不用变
// const history = History.createBrowserHistory();
const history = History.createHashHistory();

const app = {
type: 'app',
brandName: '名字',
logo: '/public/logo.png',
header: {
type: 'tpl',
inline: false,
className: 'w-full',
tpl: '<div class="flex justify-between"><div>情迁触碰</div><div>必属精品</div></div>'
},
// footer: '<div class="p-2 text-center bg-light">底部区域</div>',
// asideBefore: '<div class="p-2 text-center">菜单前面区域</div>',
// asideAfter: '<div class="p-2 text-center">菜单后面区域</div>',
api: '/pages/site.json'
};

function normalizeLink(to, location = history.location) {
to = to || '';

if (to && to[0] === '#') {
to = location.pathname + location.search + to;
} else if (to && to[0] === '?') {
to = location.pathname + to;
}

const idx = to.indexOf('?');
const idx2 = to.indexOf('#');
let pathname = ~idx
? to.substring(0, idx)
: ~idx2
? to.substring(0, idx2)
: to;
let search = ~idx ? to.substring(idx, ~idx2 ? idx2 : undefined) : '';
let hash = ~idx2 ? to.substring(idx2) : location.hash;

if (!pathname) {
pathname = location.pathname;
} else if (pathname[0] != '/' && !/^https?\:\/\//.test(pathname)) {
let relativeBase = location.pathname;
const paths = relativeBase.split('/');
paths.pop();
let m;
while ((m = /^\.\.?\//.exec(pathname))) {
if (m[0] === '../') {
paths.pop();
}
pathname = pathname.substring(m[0].length);
}
pathname = paths.concat(pathname).join('/');
}

return pathname + search + hash;
}

function isCurrentUrl(to, ctx) {
if (!to) {
return false;
}
const pathname = history.location.pathname;
const link = normalizeLink(to, {
...location,
pathname,
hash: ''
});

if (!~link.indexOf('http') && ~link.indexOf(':')) {
let strict = ctx && ctx.strict;
return match(link, {
decode: decodeURIComponent,
strict: typeof strict !== 'undefined' ? strict : true
})(pathname);
}

return decodeURI(pathname) === link;
}

let amisInstance = amis.embed(
'#root',
app,
{
location: history.location
},
{
// watchRouteChange: fn => {
// return history.listen(fn);
// },
requestAdaptor(api){
api.headers["Authorization"]="Bearer "+localStorage.getItem("token")
console.log("全局请求适配器",api,"url:"+api.url);
if(api.url.indexOf("{domain}")!=-1){
api.url=api.url.replace("{domain}","http://192.168.1.124:5187")
}
return api;
},
updateLocation: (location, replace) => {
location = normalizeLink(location);
if (location === 'goBack') {
return history.goBack();
} else if (
(!/^https?\:\/\//.test(location) &&
location ===
history.location.pathname + history.location.search) ||
location === history.location.href
) {
// 目标地址和当前地址一样,不处理,免得重复刷新
return;
} else if (/^https?\:\/\//.test(location) || !history) {
return (window.location.href = location);
}

history[replace ? 'replace' : 'push'](location);
},
jumpTo: (to, action) => {
if (to === 'goBack') {
return history.goBack();
}

to = normalizeLink(to);

if (isCurrentUrl(to)) {
return;
}

if (action && action.actionType === 'url') {
action.blank === false
? (window.location.href = to)
: window.open(to, '_blank');
return;
} else if (action && action.blank) {
window.open(to, '_blank');
return;
}

if (/^https?:\/\//.test(to)) {
window.location.href = to;
} else if (
(!/^https?\:\/\//.test(to) &&
to === history.pathname + history.location.search) ||
to === history.location.href
) {
// do nothing
} else {
history.push(to);
}
},
isCurrentUrl: isCurrentUrl,
theme: 'cxd'
}
);

history.listen(state => {
amisInstance.updateProps({
location: state.location || state
});
});
})();
</script>
</body>
</html>


很多东西在文档里有,这里只记录一些技巧
开发项目采用vscode 结合 preview预览插件 可以实时预览更新提高效率

image.png

just html preview
Live Preview

上面的index.html是整个的入口,
里面 api: ‘/pages/site.json’ 涵盖了 整个界面的定义显示,

而这些文件则全是静态的,不是调用的接口。

image.png

而这是我曾经的笔记

https://www.jianshu.com/p/72e3a0165367
https://blog.csdn.net/u010042660/article/details/127387718

时间真的是一把杀猪刀。。才2个月我就忘了。。