Giter VIP home page Giter VIP logo

vue-objccn's Introduction

GitHub All Releases

Use Vue.js to develop a cross-platform full stack application of Objc china.

  • ✅ Desktop application available for three platforms, Mac, Linux and Windows
  • ✅ Web application supports desktop browsers and mobile browsers
  • ✅ Mobile App which uses the Cordova framework, supports iOS, Android, Windows Phone and BlackBerry platforms
  • ❌ Native Mobile App, which can use Weex framework to support both iOS and Android

Note: This project is just a bit of fun and purely for learning purpose, please support 喵神(@onevcat) and Objc china.

Chinese introduction

The download link for the runnable and complete packaged software is here.

Preface

1. About me

I'm a full-time iOS developer, not a front-end developer. Due to take part in Weex development, I get to know the Vue.js.

2. Why write this project?

  1. The motivation to write this project is from an e-pal, he left a message on my blog - was there a better Weex demo? I recommended @EVAN YOU’s Hacker News. Later he supposed me to make one. I refused but kept it in mind.

  2. On May 19 this year, GitHub used Electron rewrite the macOS and Windows client, coupled with the recent year development of cross-platform getting hotter, to some companies, Web and app are all needed, app also need support iOS and Android two platforms, and more they develop Weixin mini programs. Although desktop applications are a few, Electron can develop them all. I'm going to have a try.

  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 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.

  4. Why choose Objc China, the reason is typically simple - I am an iOS developer. To iOS developers, Objc is basically well known, 喵神(@onevcat) as the same. I admire him very much 喵神(@onevcat) and decide to write Objc china without hesitation.

  5. Because of love ... ...

3. Why not use Weex to build this cross-platform project?

When I completed the project and tried to convert it directly into Weex, I got a lot of errors and most of them cannot be fixed 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 Weex version of the open source again.

Well, into the topic, Let's introduce this project:

Technology stack & main framework

📦 All technology stack of Vue:vue2 + vuex + vue-router + webpack
📌 ES6
📡 Network request:axios
🎈 Response framework:bootstrap, element-ui
✏️ Backend:express
📝 Code highlighted:highlight.js
🗄 Database:lowdb
📖 Markdown Parser:vue-markdown
🔖 Form validation:vee-validate
🏆 Cross-platform framework:Electron

📱 Supported platforms

🔨 How to build

As the Objc china website is directly response html data, to simulate the network request to return data, I build a backend and write API to return data.

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.

My current development environment is node v6.11.0, npm v3.10.10, Vue.js v2.8.2.

# install dependencies 
npm install

# serve with hot reload at localhost:8080
npm run dev

# serve with hot reload at localhost:8080
npm run start

# build for production with minification
npm run build

# build for production and view the bundle analyzer report
npm run build --report

# run unit tests
npm run unit

# run e2e tests
npm run e2e

# run all tests
npm test

# build Mac application
npm run build:mac

# build Linxu application
npm run build:linux

# build Win application
npm run build:win

# build Cordova application
npm run build:app

Here to talk about Cordova's packaging alone, it is slightly more than the desktop side of the special point.

First, make the src/main.js file on the three lines on the Cordova note open, Cordova library initialization needs to be included in the generation of Vue instance outside. After opening the comment, proceed to the next step.

I put a Makefile in the project, you can do this according to this.

  1. First install the cordova command globally

npm install -g cordova

  1. And then enter the following command to generate the app project directory

cordova create app com.vueobjccn vueobjccn

  1. Into the app folder

cd app

  1. Add the corresponding platform

cordova platform add ios
cordova platform add android

  1. Run the project

cordova run ios
cordova run android

Cordova only generated a shell of the app, all the content are still read from the web page. There is a folder called WWW in the corresponding application and used to load the page. JavaScript package will generate the www folder, just replace the content under this folder.

In addition, if you develop a large app with Cordova framework and no any optimization, the user experience is really not as fast as the native. If you really want to use front-end technology to develop app, share you two recommendation: The one is trying to do optimization when use Cordova framework. The other is using React Native or Weex to get the experience close to native.

🚀 Cross-platform development

Package this project into desktop application by JavaScript cross-platform development, mainly used the Electron framework. Here you need to install these three dependencies "electron", "electron-builder" and "electron-packager" in devDependencies. Configure other paths in the webpack.

About Cordova installation, I make complaints a little network problems in China. If you are not over the wall in China, it is really painful. For example, not over the wall and in a very poor network environment, installation of Cordova globally, lots of error, even for the complete installation of cnpm after the addition of the iOS platform will later report a problem of 'co' file can not find, I suspect cnpm could not install the command complete. Later, I go back home, over the wall and network environment is very good, All of a sudden the npm installation is complete. But there is a small episode: If Cordova iOS 4.4.0 template throw a error, suggest installation of several times, the reason is still for the network over the wall in China, no catch to it.

There may be encountered the following error:

"Error: Cannot find module 'config-chain'" when running 'ionic start'

The solution of this error is trying again the original order with the sudo command. This error could be solved

The final package will be done in the dist folder.

Next to show the performance of the cross-platform application on each platform:

First show the Web side:

And then show the effect in the mobile browser:

Android platform

Nexus 5x Web

Nexus 6P Web

iOS platform

iPhone 5 Web

iPhone 7 Web

iPhone 7 Plus Web

iPad Web

Then look at the performance in Mac side:

Finally look at Cordova's effect:

🌈 Function display

Build a Web page with Vue.js quickly.

Vuex management status is very convenient. Login status saved in the state inside, the global object will be obtained it.

If there is no login in information and user click the purchase button to buy an e-book, it will jump to the login page.

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.

<router-link> is preferred over hard-coded <a href="..."> for the following reasons:

It works the same way in both HTML5 history mode and hash mode, so if you ever decide to switch mode, or when the router falls back to hash mode in IE9, nothing needs to be changed.

In HTML5 history mode, router-link will intercept the click event so that the browser doesn't try to reload the page.

When you are using the base option in HTML5 history mode, you don't need to include it in to prop's URLs.

Similarly, once the user logs out, all places showing 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.

This is the email form validation, not too much technical content.

Here is the shopping cart page and use the MVVM page binding ideas. There are four buttons on the page, clicking any one will immediately change the related total price. To iOSer, it's worthy to learn the implemention on the MVVM.

Then this is the iPhone's Safari performance, the speed is well.

In the cross-platform of these applications, the best experience, I think, is the application of Mac.

Finally is the mobile phone app build by Cordova framework, I'm a little picky and not satificated with the unoptimized Cordova. See this showcase below:

iPhone application

iPad application

🤔 Reflection

I strongly recommand you the element-ui (Vue.js developers must have heard of this library). It is a really fast way to build projects by using it, an app can be efficient developed. Save time and put more energy on business development.

Everyone says "Now is in the era of front-end, mobile development and front-end integration is inevitable". But there are many different aspectes of the development between front-end and iOS, I experience them all and think a lot. Font-end and iOS, they have lots to learn from each other in their own advantages and disadvantages, I intend to write an article series on those aspects - engineering, component, routing, MVVM. (Dig a big hole to jump)

📜 Feature

If I had more free time, I would like to support Weex. Taking Vue.js into a complete Weex application, to become a native app, the performance will not be bad. After then, it can cover the entire platform.

❗️ Errata

If you find a bug, welcome to sumbit your PR.
If you feel confused by something, welcome to submit your Issues.
I'm really appreciate it!🙏🙏🙏

♥️ Thanks

If you like this project, welcome Star!

Stargazers over time

🌏 LICENSE

Vue-ObjcCN is available under the GPLv3 license. See the LICENSE file for more info.

vue-objccn's People

Contributors

eyrefree avatar halfrost avatar jayzch avatar kant avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

vue-objccn's Issues

数据登录问题

项目运行起来没有问题,但是数据库不知道怎么使用。无法登陆也无法注册,希望大佬解惑。

win环境下更改main.js后打包cordova失败

ERROR in ./src/main.js

http://eslint.org/docs/rules/ Parsing error: Unexpected token

44 | cordova.initialize()
45 | // 打开此行代码的注释可以打 cordova 的包

46 |
| ^
G:\VueDemo\vue-objccn-master\src\main.js:46:1

^

✘ 1 problem (1 error, 0 warnings)

Errors:
1 http://eslint.org/docs/rules/null

ERROR in ./src/main.js
Module build failed: SyntaxError: G:/VueDemo/vue-objccn-master/src/main.js: Unex
pected token (46:0)

44 | cordova.initialize()
45 | // 打开此行代码的注释可以打 cordova 的包

46 |
| ^

打包成apk后在模拟器和手机上显示都是黑屏...

仓库体积过大

是否可以考虑减少仓库体积?比如图片使用图床。。%>_<% 我这里网不太好,,60M的代码有些吃不消。。

build:mac 和build:win 都报错。

CANNOT RUN WITH NODE 10.14.1
Electron Packager requires Node 4.0 or above.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] build:mac: `NODE_ELECTRON=true npm run build && electron-packager . vue-objccn --platform=darwin --out ./dist/$npm_package_version --overwrite --ignore=node_modules/* --ignore=.git --ignore=dist/$npm_package_version`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] build:mac script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/i/.npm/_logs/2019-01-24T03_44_21_631Z-debug.log

cordova打包时vue-router history模式空白

请问下,路由用history模式在用cordova打包成app的时候正常吗,我这里只要路由用history模式,打包出来的app就一片空白,config的assetsPublicPath设置的跟你的是一样的

安装项目依赖项出错

用yarn安装项目依赖项出现错误

运行的安装命令: yarn

错误详情:

.项目路径\node_modules\chromedriver: Command failed.
Exit code: 1
Command: node install.js
Arguments:
Directory: 项目路径\node_modules\chromedriver
Output:

项目流程

能从项目新建开始说一下大致流程吗?

提一个bug. npm run build:win 执行exe报错。

经过排查。webpack打包的路径错误。

// build/webpack.prod.conf.js 修改如下
output: {
    path: config.build.assetsRoot,
    // 下面这这句话一定要加,否则会影响 mac桌面端的路径问题,当然可以自己配置其他目录
    publicPath: isELECTRON ? path.join(__dirname, '../dist/') : './', (修改路径即可)
    filename: utils.assetsPath('js/[name].[chunkhash].js'),
    chunkFilename: utils.assetsPath('js/[id].[chunkhash].js')
  },

没试过其他环境,win下是如此。

please help me

hello ,it's honr for me to use your kuangjia..
but i face with a very big big big problem.it's so big that could make me spit blood,yeah,spit blood!
which is when i folded it to my phone,the stykes has be involved,

编译electron的文件存储位置有bug。会导致源程序不断重复编译。

Packaging app for platform win32 x64 using electron v1.6.11
ENAMETOOLONG: name too long, unlink '/var/folders/rf/f00pr8xn091_zvy7_vyx9p140000gn/T/electron-packager/win32-x64/vue-oms-win32-x64/resources/app/electron-packager/win32-x64/vue-oms-win32-x64/resources/app/electron-packager/win32-x64/vue-oms-win32-x64/resources/app/electron-packager/win32-x64/vue-oms-win32-x64/resources/app/electron-packager/win32-x64/vue-oms-win32-x64/resources/app/electron-packager/win32-x64/vue-oms-win32-x64/resources/app/electron-packager/win32-x64/vue-oms-win32-x64/resources/app/electron-packager/win32-x64/vue-oms-win32-x64/resources/app/electron-packager/win32-x64/vue-oms-win32-x64/resources/app/electron-packager/win32-x64/vue-oms-win32-x64/resources/app/electron-packager/win32-x64/vue-oms-win32-x64/resources/app/electron-packager/win32-x64/vue-oms-win32-x64/resources/app/electron-packager/win32-x64/vue-oms-win32-x64/resources/app/electron-packager/win32-x64/vue-oms-win32-x64/resources/app/electron-packager/win32-x64/vue-oms-win32-x64/resources/app/node_modules/babel-helper-builder-binary-assignment-operator-visitor/README.md'

图片太大

一张图片30M多,下载半天下不来。

cordova run ios异常

请问,我把vue build之后的代码放在www文件夹下 然后cordova run ios 不能正常预览,是白屏。cordova run browser正常,是ios需要其他的什么配置吗?烦请指点

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.