You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Use Vue.js to develop a cross-platform full stack application of [Objc china](https://objccn.io/)
17
-
18
-
16
+
Use Vue.js to develop a cross-platform full stack application of [Objc china](https://objccn.io/).
17
+
19
18
-[x] ✅ Desktop applications, support Mac, Linux, Windows three platforms
20
19
-[x] ✅ Web applications, support for desktop browsers and mobile browsers
21
20
-[x] ✅ Mobile App, currently only supports the Cordova framework, support iOS、Android、Windows Phone、BlackBerry four platforms
22
21
-[ ] ❌ Mobile phone native App, intended to use Weex framework, the same support for both iOS and Android platform
23
22
24
-
25
23
<palign='center'>
26
24
<imgsrc='./image/Supported_Platforms_.png'>
27
25
</p>
28
26
29
27
> Note: This project is purely just for fun, please support [喵神(@onevcat)](https://github.com/onevcat),support [Objc china](https://objccn.io/)。
30
28
31
-
32
29
> [中文介绍 chinese introduction](./README_CN.md)
33
30
34
-
# Preface
35
-
36
-
## 一. About me
37
-
38
-
I am a full-time iOS developer, non-front-end developer. Due to contact with Weex development, thereby came into contact with the Vue.js.
31
+
## Preface
39
32
33
+
### 1. About me
40
34
41
-
## 二. Why write this project?
35
+
I am a full-time iOS developer, non-front-end developer. Due to contact with Weex development, thereby came into contact with the `Vue.js`.
42
36
37
+
### 2. Why write this project?
43
38
44
39
1. At the beginning of this idea is from a netizen, he asked me in my blog, the Internet has not a better Weex demo? I said that [@EVAN YOU](http://evanyou.me/)’s Hacker News is the best. Later netizen say, the bloggers can write one? I did not answer at the time. In fact, this thing I have always remember in my heart.
45
40
46
-
2. May 19 this year, GitHub use Electron rewrite the macOS and Windows client, coupled with the recent year development of cross-platform getting hotter, for some companies, the Web and app should be needed, app Also need iOS and Android two platforms, and even those who have to develop Weixin mini programs, desktop applications(despite a few), but with the same can be developed with the Electron. I also initiation of the idea of want to be eager.
41
+
2. May 19 this year, GitHub use Electron rewrite the macOS and Windows client, coupled with the recent year development of cross-platform getting hotter, for some companies, the Web and app should be needed, app Also need iOS and Android two platforms, and even those who have to develop Weixin mini programs, desktop applications(despite a few), but with the same can be developed with the Electron. I also initiation of the idea of want to be eager.
47
42
48
43
3. As a result of the contact to the Vue.js, of course, do not want to stay in the primary, would like to advanced, [@EVAN YOU](http://evanyou.me/) especially given the recommendations, is more practice, more practice. In order to speed up the pace of progress, I own private to find the project for practicing.
49
44
50
45
4. As for why to choose Objc China, the reason is actually very simple, because I am an iOS developer. In iOS developers, Objc is basically well known (do not know?), [喵神(@onevcat)](https://github.com/onevcat) is basically well known, I personally worship [喵神(@onevcat)](https://github.com/onevcat), so I chose Objc China to write.
51
46
52
47
5. Because of love ... ...
53
48
54
-
55
-
## 三. Why this development of cross-platform project without Weex?
56
-
49
+
### 3. Why this development of cross-platform project without Weex?
57
50
58
51
After I finished the project, found that Vue code directly converted to Weex project, can not be achieved, a lot of error. And not all of them can be repaired immediately. I believe that I use the wrong way, not Weex's problem. By the way, Weex has released a new version, and then there is time to put Weeks version of the open source again.
59
52
60
53
Well, into the topic, Let's introduce this project:
61
54
62
-
63
-
# Technology stack & main framework
55
+
## Technology stack & main framework
64
56
65
57
📦 All technology stack of Vue:vue2 + vuex + vue-router + webpack
66
58
📌 ES6
@@ -73,15 +65,14 @@ Well, into the topic, Let's introduce this project:
73
65
🔖 Form validation:vee-validate
74
66
🏆 Cross-platform framework:Electron
75
67
76
-
# 🔨 How to build
68
+
##🔨 How to build
77
69
78
70
Due to Objc china website is directly response html data, so I want to simulate the network request to return data, should build a server, write API return data.
79
71
80
72
I use Express framework to build a server, set up in the 8081 port, and write routing, the request will go to 8080, open the server will automatically open the background.
81
73
82
74
My current development environment is node v6.11.0 ,npm v3.10.10,Vue.js v2.8.2.
83
75
84
-
85
76
```bash
86
77
87
78
# install dependencies 安装依赖
@@ -122,38 +113,39 @@ npm run build:app
122
113
123
114
```
124
115
125
-
126
116
Here to talk about Cordova's packaging alone, it is slightly more than the desktop side of the special point.
127
117
128
-
First, make the src / main.js file on the three lines on the Coredova note open, Coredova library initialization needs to be included in the generation of Vue instance outside. After opening the comment, proceed to the next step.
118
+
First, make the `src/main.js` file on the three lines on the Coredova note open, Coredova library initialization needs to be included in the generation of Vue instance outside. After opening the comment, proceed to the next step.
129
119
130
120
I put a Makefile in the project, you can do this according to this.
131
121
132
-
133
122
1. First install the cordova command globally
123
+
134
124
> npm install -g cordova
135
125
136
126
2. And then enter the following command to generate the app project directory
127
+
137
128
> cordova create app com.vueobjccn vueobjccn
138
129
139
130
3. Into the app folder
131
+
140
132
> cd app
141
133
142
134
4. Add the corresponding platform
135
+
143
136
> cordova platform add ios
144
137
> cordova platform add android
145
138
146
139
5. Run the project
140
+
147
141
> cordova run ios
148
142
> cordova run android
149
143
150
-
151
144
Cordova only generated a shell of the app, inside the specific content still read the webpage, in the corresponding application which has a www inside the folder, this folder is to load the page inside. JavaScript package will generate the www folder, just replace the content which inside the Cordova corresponding platform’s www folder.
152
145
153
146
Add a few words, app development to the present so mature era, if you develop a large app, with Cordova framework to do, do not use Objective-C or Swift to develop, do not do any optimization, the user experience is really not as good as the native fast. I have a special package to experience the Cordova app, did not do any optimization, packaged out on the experience, if it is critical of the user, on the current major app close to the perfect experience compared to really do not feel a little sense of satisfaction. If you really want to use front-end technology development app, to give 2 recommendations, if it is Cordova framework, we must try to optimize it, otherwise, the performance of app is not as good as the native performance. If you want to have a close to the native experience, then you can consider using React Native or Weex.
154
147
155
-
156
-
# 🚀 Cross-platform development
148
+
## 🚀 Cross-platform development
157
149
158
150
JavaScript cross-platform development packaged into desktop applications, mainly use the Electron framework. Here you need to install the devdependencies inside "electron", "electron-builder", "electron-packager" these three framework. Make sure the other path configuration in the webpack have configured completed.
159
151
@@ -171,7 +163,6 @@ Next to show the performance of the cross-platform application on each platform:
171
163
172
164
First show the Web side:
173
165
174
-
175
166
<palign='center'>
176
167
<imgsrc='./image/Screenshots/Web/Web 1.png'>
177
168
</p>
@@ -197,28 +188,33 @@ And then show the effect in the mobile browser:
<imgsrc='./image/Screenshots/Web/iPhone 7 Plus Web.png'>
224
220
</p>
@@ -273,7 +269,7 @@ Finally look at Cordova's effect:
273
269
<imgsrc='./image/Screenshots/iPad/iPad 3.png'>
274
270
</p>
275
271
276
-
# 🌈 Function display
272
+
##🌈 Function display
277
273
278
274
Build a Web page with Vue.js quickly.
279
275
@@ -287,7 +283,6 @@ Vuex management status is very convenient. Login status saved in the state insid
287
283
<imgsrc='./image/Gifs/Web-login.gif'>
288
284
</p>
289
285
290
-
291
286
Once the user is not logged in, click on the purchase of e-books, to determine no user login will jump to the login page.
292
287
293
288
Another point is to say that because this is a SPA, so the routing inside are using Router-link to achieve, but did not use `<a>` tag jump, the effect is to jump and do not have to request data, jump quickly. This user experience is really cool.
@@ -306,7 +301,6 @@ When you are using the base option in HTML5 history mode, you don't need to incl
306
301
307
302
Log out of the page Similarly, once the user logs out, all show the user name will become a status to be logged in, the shopping cart on navigationBar also be disappeared. Manage status with Vuex, very Exciting.
308
303
309
-
310
304
<palign='center'>
311
305
<imgsrc='./image/Gifs/Web-email.gif'>
312
306
</p>
@@ -327,15 +321,12 @@ Then this is the iPhone's Safari performance, the speed is well.
327
321
328
322
In the cross-platform of these applications, the best experience, I think it is the application of Mac. Use satisfaction is very high.
329
323
330
-
331
324
<palign='center'>
332
325
<imgsrc='./image/Gifs/Web-Mac.gif'>
333
326
</p>
334
327
335
-
336
328
Finally Cordova framework build the mobile phone app, experience is unsatisfactory, in short, not optimized Cordova, for picky me, I was not satisfied. See this showcase below:
337
329
338
-
339
330
iPhone application
340
331
341
332
<palign='center'>
@@ -348,28 +339,25 @@ iPad application
348
339
<imgsrc='./image/Gifs/Web-iPad app.gif'>
349
340
</p>
350
341
351
-
# 🤔 After the completion of the project, I Fall into meditation
352
-
342
+
## 🤔 After the completion of the project, I Fall into meditation
353
343
354
344
First Amway [element-ui](https://github.com/ElemeFE/element) this project, use it to build the project, really very fast, a app can be efficient development. the development of Vue.js students must have heard of this library. Saving a lot of time can put more energy on business development.
355
345
356
346
Everyone is saying that now is a large front-end era, mobile development and front-end integration is inevitable. But the development of the two platforms is still a lot of different, I experienced a front-end development and iOS development, thinking a lot, front-end and iOS are a lot of places to learn from each other, both have their own advantages and disadvantages. Then I intend to write a series of articles on these aspects. The engineering, component, routing, MVVM of front-end, respectively, and iOS where the advantages and disadvantages of each other, what can learn each other. (Feeling to dig a big pit)
357
347
358
-
359
-
# 📜 Feature
348
+
## 📜 Feature
360
349
361
350
If I have free time, I want to support Weex, take Vue.js into a complete Weex application, become native app, the performance will not be bad. So cross-platform development should be the whole platform.
362
351
352
+
## ❗️ Errata
363
353
364
-
# ❗️ Errata
365
-
366
-
If found in the project what is puzzled or found a bug, welcome to submit PR or issue, thank you very much🙏🙏🙏
354
+
If found in the project what is puzzled or found a bug, welcome to submit PR or issue, thank you very much, 🙏🙏🙏
0 commit comments