efront 4.0.13 → 4.0.16

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.
@@ -1,6 +1,6 @@
1
1
  <thead @mounted="setFixedColumn.call(this.parentNode),setContextMenu(this)">
2
2
  <tr inline-block #adapter thead @mounted="resizeT(this)">
3
- <td draggable="false" fixed row-index>序号</td>
3
+ <td draggable="false" fixed row-index>${i18n`序号`}</td>
4
4
  <td fixed:="f.fixed" -repeat="f in fields track by f.id" :style="{width:f.width}" @dblclick="sort(f)"><i
5
5
  -if="f.icon" -class="f.icon"></i><span -if="f.name" -html="f.name"></span><template
6
6
  -else>&nbsp;</template>
@@ -26,13 +26,13 @@
26
26
  <tfoot>
27
27
  <tr .fade -if="!data||!data.length" style="padding-bottom: 20px;">
28
28
  <td style="text-align: center;">
29
- <template -if="data.is_loading">加载中</template>
30
- <template -else>无数据</template>
29
+ <template -if="data.is_loading">${i18n`加载中`}</template>
30
+ <template -else>${i18n`无数据`}</template>
31
31
  </td>
32
32
  </tr>
33
33
  <tr -elseif="hasFoot">
34
34
  <td>
35
- 共&nbsp;<span -bind="data.length"></span>&nbsp;个
35
+ ${i18n`共${"&nbsp;<span -bind=data.length></span>&nbsp;"}个`}
36
36
  </td>
37
37
  </tr>
38
38
  </tfoot>
@@ -0,0 +1,327 @@
1
+ # efront vs. angular/react/vue
2
+
3
+ * `efront` is a development environment, not a dependency library. Additionally, `efront` provides a browser mode component library called 'zimoli', which is provided in a discrete functionality manner and allows for but does not enforce the use of any item.
4
+
5
+ * Here we only present the facts and do not make any evaluations. The behavior of a certain official "belittling others and elevating oneself" is not criticized by efront.
6
+ * For the comparison of the web section in the following text, use the `zimoli` component library in the efront environment as a reference
7
+
8
+ ## 表面参数对比
9
+
10
+ | Comparison item\framework | efront/(zimoli) | angular | react | vue |
11
+ | -------------------- | --------------------------------------------------------------------------- | ---------------------------------- | -------------------------------- | ------------------------------ |
12
+ | Hello World object code | ≈1kb; | &gt;30kb | &gt;30kb | ≈30kb; |
13
+ | Development environment startup time | ≈0s; | &gt;2s | &gt;2s | >2s |
14
+ | development language | js/html/less | ts/html/less/sass/scss | jsx/css/js/ts/html | html/css/js |
15
+ | Export Component Dependencies | 无 | angular | react | vue |
16
+ | Official routing | zimoli,No need to register a path before use | angular-router, Path registration is required before use | react-router, Path registration is required before use | vue-router, Path registration is required before use |
17
+ | Cross domain implementation | Built in development environment | Configure browser or server | Configure browser or server | Configure browser or server |
18
+ | Code loading scheme | Dependency loading/Automatic preloading/Manual preloading`preapre('/page/path');` / Load on dynamic path access | One load/Or load on access | One load/Or load on access | One load/Or load on access |
19
+ | Jump to pass parameters | `go`(pagepath,&nbsp;params) | ignore | ignore | ignore |
20
+ | Asynchronous Object Parameter Transfer | `cast`(target,&nbsp;data) &#013;&#010; `care`(target,&nbsp;handle) | ignore | ignore | ignore |
21
+
22
+ ## Architecture Comparison
23
+
24
+ ### 1. efront/zimoli
25
+
26
+ In the efront environment, users directly operate or create dom elements in an isolated environment, and zimoli/render is responsible for assembly and binding between elements.
27
+
28
+ ### 2. angular 1~9
29
+
30
+ Angular1 isolates the view and logic, and JS can update the view by updating the data on the scope. The user's input on the view can be automatically synchronized to the scope through binding relationships. Angular2+abstracts the scope as an instance of a class in typescript, and its actual purpose remains unchanged. Angular's own logic maintains the binding relationship between data and views.
31
+
32
+ ### 3. react
33
+
34
+ React maintains synchronization with the view through the virtual dom. Before each rendering, the virtual dom is reconstructed through user logic, while React maintains synchronization between the virtual dom and the view.
35
+
36
+ ### 4. vue
37
+
38
+ Vue uses Object. defineProperty for data binding, which is different from the mechanism of event binding in regular, but it also isolates views from logic and maintains the binding relationship between data and views.
39
+
40
+ ## grammatical comparison
41
+
42
+ ### 1. conditional construct
43
+
44
+ ```xml
45
+ <!-- efront/(zimoli) with render(element,scope) -->
46
+ <component1 ng-if="expression"> </component1>
47
+ <!-- or -->
48
+ <component1 v-if="expression"> </component1>
49
+ <!-- Or any prefix -->
50
+ <component1 x-if="expression"> </component1>
51
+ <!-- In the following text, the prefix can be modified for the prefix that starts with 'ng-' -->
52
+ ```
53
+
54
+ ```xml
55
+ <!-- angular 1.x -->
56
+ <component1 ng-if="expression" ></component1>
57
+ <!-- angular 2+ -->
58
+ <component1 *ngIf="expression" ></component1>
59
+ ```
60
+
61
+ ```jsx
62
+ // react render() Using jsx syntax in
63
+ render(){
64
+ return expression ? <Component1></Component1> : null
65
+ }
66
+ ```
67
+
68
+ ```xml
69
+ <!-- vue Start with 'v-' -->
70
+ <component1 v-if="expression"></component1>
71
+ ```
72
+
73
+ ### 2. 循环结构
74
+
75
+ ```xml
76
+ <!-- efront/(zimoli) with render(element,scope) -->
77
+ <component1 ng-repeat="(item,index) in expression"></component1>
78
+ <component1 v-for="(item,index) in expression"></component1>
79
+ <component1 ng-repeat="item in expression"></component1>
80
+ <component1 v-for="item in expression"></component1>
81
+ ```
82
+
83
+ ```xml
84
+ <!-- angular 1.x -->
85
+ <component1 ng-repeat="(item,index) in expression" ></component1>
86
+ <!-- angular 1.x -->
87
+ <component1 ng-repeat="item in expression" ></component1>
88
+ <!-- angular 2+ structural grammar -->
89
+ <component1 *ngFor="let item of expression;let index=index" ></component1>
90
+ <!-- angular 2+ directive syntax -->
91
+ <component1 ngFor [ngForOf]="expression" let-item let-index></component1>
92
+ ```
93
+
94
+ ```jsx
95
+ // react render() Using map syntax in
96
+ render(){
97
+ return expression.map((item,index)=><Copoment1></Component1>)
98
+ }
99
+ ```
100
+
101
+ ```xml
102
+ <!-- vue Start with 'v-' -->
103
+ <component1 v-for="(item,index) in expression"></component1>
104
+ <!-- vue Start with 'v-' -->
105
+ <component1 v-for="item in expression"></component1>
106
+ ```
107
+
108
+ ### 3. Data binding
109
+
110
+ ```xml
111
+ <!-- efront/(zimoli) with render(element,scope) -->
112
+ <component1 ng-bind="expression"></component1>
113
+ <!-- efront/(zimoli) with render(element,scope) Set JS object properties element[key]=value -->
114
+ <image _src="expression" />
115
+ <image .src="expression" />
116
+ <image :src="expression" />
117
+ <!-- efront/(zimoli) with render(element,scope) Set Element Attributes element.setAttribute(key,value) -->
118
+ <image src_="expression" />
119
+ <image src.="expression" />
120
+ <image src:="expression" />
121
+ <image src@="expression" />
122
+ ```
123
+
124
+ ```xml
125
+ <!-- angular 1.x -->
126
+ <component1 ng-bind="expression" ></component1>
127
+ <image ng-src="expression" />
128
+ <!-- angular 2+ -->
129
+ <component1 [innerText]="expression" ></component1>
130
+ <image [src]="expression" />
131
+ <!-- angular 1+ -->
132
+ <component1 >{{expression}}</component1>
133
+ <image src="{{expression}}" />
134
+ ```
135
+
136
+ ```jsx
137
+ // react render() Using jsx syntax
138
+ render(){
139
+ return <Component1> { expression } </Component1>
140
+ }
141
+ ```
142
+
143
+ ```xml
144
+ <!-- vueStart with 'v-' -->
145
+ <component1 >{{expression}}</component1>
146
+ <image v-bind:src="expression" />
147
+ <image :src="expression" />
148
+ ```
149
+
150
+ ### 4. two-way/reverse/Event binding
151
+
152
+ ```xml
153
+ <!-- efront/(zimoli) with render(element,scope) -->
154
+ <component1 ng-model="expression"></component1>
155
+ <component1 ng-click="expression"></component1>
156
+ <component1 @click="expression"></component1>
157
+ <component1 v-on:click="expression"></component1>
158
+ ```
159
+
160
+
161
+ ```xml
162
+ <!-- angular 1.x -->
163
+ <input ng-model="expression" />
164
+ <button ng-click="expression" ></button>
165
+ <!-- angular 2+ -->
166
+ <component1 [(ngModel)]="expression" ></component1>
167
+ <component1 (click)="expression" ></component1>
168
+ ```
169
+
170
+ ```jsx
171
+ // react render() Using jsx syntax
172
+ render(){
173
+ return <Component1 onClick={expression}> </Component1>
174
+ }
175
+ ```
176
+
177
+ ```xml
178
+ <!-- vue Start with 'v-' -->
179
+ <component1 v-model="expression" ></component1>
180
+ <component1 v-on:click="expression" ></component1>
181
+ <component1 @click="expression" ></component1>
182
+ ```
183
+
184
+ ### 5. Define web components
185
+
186
+ ```javascript
187
+ // efront/(zimoli) with render(element,scope)
188
+
189
+ var htmlFileData={toString(){
190
+ // If there is an HTML file with the same name, similar code will be automatically generated
191
+ // The one-time binding before rendering can be done here
192
+ return `<btn>${i18n`Content`}</btn>`;
193
+ }};
194
+
195
+ function main(elem){
196
+ // Construction method
197
+ // You can use mounted or unmounted elements
198
+ // You can use the incoming element or create a new one;
199
+ elem = elem || document.createElement("div");
200
+ elem.innerHTML = htmlFileData;
201
+ onappend(elem,function(event){
202
+ // Triggered after mounting, can be bound if necessary
203
+ });
204
+ onremove(elem,function(event){
205
+ // Remove the previous trigger and bind it if necessary
206
+ });
207
+ watch(elem, {
208
+ // `propname` Refers to the propname in<element: propname=propvalue></element>
209
+ propname(current_value, previous_value){
210
+ // Tasks after parameter changes
211
+ }
212
+ });
213
+ var scope = {
214
+ // The content used in the HTML should appear here
215
+ btn: button, // Internal components can be renamed before rendering to simplify tagName in HTML and facilitate writing and reading in local contexts
216
+ };
217
+ render(elem,scope);// If not used, export native components
218
+ // If there is a less file with the same name, it will be automatically bound during compilation
219
+ return elem //If not transmitted, the original elements will not be replaced
220
+ }
221
+ ```
222
+
223
+ ```typescript
224
+ // angular 1.x
225
+ var app=angular.module("modulename");
226
+ app.directive("component-name",[
227
+ "$rootScope",//依赖项
228
+ function($rootScope){
229
+ return {
230
+ restrict: 'E',//Element
231
+ restrict: 'A',//Attribute
232
+ transclude: true,// Content
233
+ replace: true,
234
+ template:"<template-string></template-string>",
235
+ template:function(elem,attr){//Template construction method
236
+ },
237
+ templateUrl:"...",
238
+ scope:{//Private parameters
239
+ paramKey1:"=",//two way
240
+ paramKey1:"=?",//No reverse is possible
241
+ paramKey1:"@",//String parameter
242
+ },
243
+ compile(elem,attr,trans){
244
+ //Custom compiler
245
+ return function(scope,elem,attr,ctrl,transclude){};
246
+ },
247
+ link(scope,elem,attr,ctr,transclude){
248
+ // Compiler's lower level methods
249
+ },
250
+ };
251
+ }]);
252
+ // angular 2+
253
+ @Component({
254
+ template:'',
255
+ templateUrl:'',
256
+ stylesUrl:[],
257
+ styles:[],
258
+ })
259
+ class ComponentName implements OnChanges,AfterViewInit,OnInit,OnDestroy{
260
+ @Input() params1;
261
+ @Input() params2;
262
+ @Output() event1;
263
+ @Output() event2;
264
+ constructor(){
265
+ }
266
+ ngOnInit(){
267
+ // initialization
268
+ }
269
+ ngOnDestroy(){
270
+ // Destruction
271
+ }
272
+ ngOnChanges(){
273
+ // Triggered when parameter changes
274
+ }
275
+ ngAfterViewInit(){
276
+ // Trigger after rendering is completed
277
+ }
278
+ }
279
+ ```
280
+
281
+ ```jsx
282
+ // react render() Using jsx syntax
283
+ import React, { Component } from 'react';
284
+ import { render } from 'react-dom';
285
+
286
+ class ComponentName extends Component {
287
+ constructor(props){}
288
+ componentWillMount(){}
289
+ componentDidMount(){}
290
+ componentWillReceiveProps(){}
291
+ shouldComponentUpdate(){}
292
+ componentWillUpdate(){}
293
+ componentDidUpdate(){}
294
+ componentWillUnmount(){}
295
+ render() {
296
+ return <div>Hello {this.props.name}</div>;
297
+ }
298
+ }
299
+ ```
300
+
301
+ ```html
302
+ <!-- vue -->
303
+ <template>
304
+ <component></component>
305
+ </template>
306
+ <script>
307
+ var component = {
308
+ created(){},
309
+ mounted(){},
310
+ beforeDestroy(){},
311
+ destroyed(){},
312
+ render(){},
313
+ data(){
314
+ return {};
315
+ },
316
+ props:{},
317
+ watch:{},
318
+ methods:{},
319
+ components:{
320
+ component:compoment1
321
+ }
322
+ };
323
+ export default component;
324
+ </script>
325
+ <style></style>
326
+ ```
327
+
@@ -6,7 +6,7 @@
6
6
  var basepath = path.join(String(__efront), 'coms');
7
7
  if (req.id) {
8
8
  var compath = path.join(basepath, req.id);
9
- if (!comm_file_reg.test(req.id) || !/^\.\./.test(path.relative(compath, basepath))) return forbidden("禁止访问");
9
+ if (!comm_file_reg.test(req.id) || !/^\.\./.test(path.relative(compath, basepath))) return forbidden(i18n[req.headers["accept-language"]]`禁止访问`);
10
10
  return fs.readFile(compath);
11
11
  }
12
12
 
package/docs/main.xht CHANGED
@@ -77,27 +77,27 @@
77
77
  <script>
78
78
  var menus = [
79
79
  {
80
- name: "efront 简介",
80
+ name: i18n`efront简介`,
81
81
  children: [
82
- { name: "使用说明", md: "readme.md" },
83
- { name: "兼容性说明", md: "coms/basic_/readme.md" },
84
- { name: "版本说明", md: "docs/版本说明.md" },
85
- { name: "与前端框架对比", md: "docs/compare.md" },
86
- // { name: "notive", md: "docs/notive.md" },
82
+ { name: i18n`使用说明`, md: i18n`readme.md` },
83
+ { name: i18n`兼容性说明`, md: i18n`coms/basic_/readme.md` },
84
+ { name: i18n`版本说明`, md: i18n`docs/版本说明.md` },
85
+ { name: i18n`与前端框架对比`, md: i18n`docs/compare.md` },
86
+ // { name: i18n`notive`, md: "docs/notive.md" },
87
87
  ]
88
88
  },
89
89
  {
90
- name: "组件库",
90
+ name: i18n`组件库`,
91
91
  closed: true,
92
92
  children: []
93
93
  },
94
94
  {
95
- name: "小工具",
95
+ name: i18n`小工具`,
96
96
  closed: true,
97
97
  children: [
98
- "字符集检查",
99
- "国际化",
100
- ].map(a => ({ name: a, path: "/工具/" + a }))
98
+ { name: i18n`字符集检查`, path: "/工具/字符集检查" },
99
+ { name: i18n`国际化`, path: "/工具/国际化" }
100
+ ]
101
101
  }
102
102
  ];
103
103
  zimoli.register("/mark");
@@ -107,7 +107,7 @@
107
107
  if (!window.require) return;
108
108
  return menuList(null, [
109
109
  {
110
- "name": "开发者选项",
110
+ "name": i18n`开发者选项`,
111
111
  do() {
112
112
  window.require("electron").ipcRenderer.send("window", "open-dev-tools");
113
113
  window.resizeBy(400, 0);
@@ -123,14 +123,14 @@
123
123
  var initCommandsDocs = async function () {
124
124
  var helps = await init("docs$helps");
125
125
  var m = {
126
- name: "命令参考",
126
+ name: i18n`命令参考`,
127
127
  closed: true,
128
128
  children: [
129
- { name: "防御系", a: "f" },
130
- { name: "强攻系", a: "q" },
131
- { name: "辅助系", a: "z" },
132
- { name: "控制系", a: "k" },
133
- { name: "暗器系", a: "a" }
129
+ { name: i18n`防御系`, a: "f" },
130
+ { name: i18n`强攻系`, a: "q" },
131
+ { name: i18n`辅助系`, a: "z" },
132
+ { name: i18n`控制系`, a: "k" },
133
+ { name: i18n`暗器系`, a: "a" }
134
134
  ]
135
135
  };
136
136
  m.children.forEach(a => {
@@ -0,0 +1,11 @@
1
+ `efront` is a growing project with many incomplete features and areas for optimization. So far, there have been three major versions of updates and many minor revisions. Currently, `efront` does not provide detailed release instructions for each small version. You can refer to the code [submit logs](https://github.com/yunxu1019/efront/commits/develop) to view the updated content in.
2
+
3
+ # The update instructions for the major version are as follows:
4
+
5
+ 1.x `efront` is released in source code format, mainly relying on `esprima`, `esmangle`, `escodegen`, `pngjs`, `less node`, and `typescript` to provide compilation support
6
+
7
+ 2.x `efront` is published in a self compiled format
8
+
9
+ 3.x With a self built grammar parser, `efront` no longer relies on `esprima`, `esmangle`, and `escodegen`. The self compilation time has gradually decreased from the original 10 minute Github workflow to about 2 minutes.
10
+
11
+ 4.0 No longer relying on `typescript` (nearly 170000 lines of source code), the compilation speed has increased by four times, the memory usage has been reduced to 1/8 of the original, and the self compilation time on GitHub has also been reduced to about 15 seconds.
package/docs/welcome.jsp CHANGED
@@ -2,7 +2,7 @@
2
2
  __efront = String(__efront);
3
3
  var fullpath = path.join(__efront, req.id);
4
4
  if (!/^\.\./.test(path.relative(fullpath, __efront)) || !/\.md$/.test(req.id)) {
5
- return forbidden("禁止访问!");
5
+ return forbidden(i18n[req.headers["accept-language"]]`禁止访问!`);
6
6
  }
7
7
  return fs.promises.readFile(fullpath);
8
8
  </script>
@@ -34,9 +34,11 @@
34
34
  color: #fff;
35
35
  padding: 10px 16px;
36
36
  }
37
- [body]{
37
+
38
+ [body] {
38
39
  background: #222;
39
40
  }
41
+
40
42
  :scope {
41
43
  height: 100%;
42
44
  width: 100%;
@@ -55,7 +57,7 @@
55
57
  </style>
56
58
  <h2 head -bind="help?.info"></h2>
57
59
  <div body>
58
- <div>可以使用的命令有:</div>
60
+ <div>${i18n`可以使用的命令有:`}</div>
59
61
  <m -repeat="c in help?.cmds">
60
62
  <cmds></cmds>
61
63
  <topic></topic>
@@ -82,10 +84,14 @@
82
84
  });
83
85
  },
84
86
  topic(elem, s) {
85
- if (!s.topics.length) return;
86
- elem.innerHTML = "其中," + s.topics.filter(a => scope.dict[a]).map(a => {
87
- var [n, d] = scope.dict[a].split('|');
88
- return `${a}是${n},默认值是${d}`;
87
+ var topics = s.topics.filter(a => scope.dict[a]);
88
+ if (!topics.length) return;
89
+ elem.innerHTML = i18n`其中,` + topics.map(a => {
90
+ var d = scope.dict[a];
91
+ var t = i18n`${a}是${d[0]}`;
92
+ if (d.length > 1) t += i18n`,可取值有${d.slice(1).join('、')}`;
93
+ if (d.default) t += i18n`,默认值是${d.default}`;
94
+ return t;
89
95
  }).join(';');
90
96
  }
91
97
  }