Convert Figma logo to code with AI

lzxb logovue-cnode

基于vue2 + vue-router + vuet + ES6 + less + flex.css重写vue版cnode社区,使用webpack2打包

1,118
314
1,118
0

Top Related Projects

207,677

This is the repo for Vue 2. For Vue 3, go to https://github.com/vuejs/core

227,213

The library for web and native user interfaces.

95,657

Deliver web apps with confidence 🚀

78,194

Cybernetically enhanced web apps

36,546

⚛️ Fast 3kB React alternative with the same modern API. Components & Virtual DOM.

16,083

:fire: An extremely fast, React-like JavaScript library for building modern user interfaces

Quick Overview

Vue-cnode is a Vue.js-based implementation of the CNode community forum. It's a single-page application (SPA) that demonstrates how to build a full-featured web application using Vue.js, Vuex for state management, and Vue Router for navigation.

Pros

  • Provides a comprehensive example of building a complex application with Vue.js
  • Implements responsive design, making it mobile-friendly
  • Uses Vuex for efficient state management across components
  • Demonstrates integration with a real API (CNode)

Cons

  • The project hasn't been updated recently, potentially using outdated dependencies
  • Documentation is primarily in Chinese, which may be a barrier for non-Chinese speakers
  • Lacks comprehensive unit tests
  • May not follow the most recent Vue.js best practices due to its age

Code Examples

  1. Vuex store setup:
import Vue from 'vue'
import Vuex from 'vuex'
import user from './user'
import topics from './topics'

Vue.use(Vuex)

export default new Vuex.Store({
  modules: {
    user,
    topics
  }
})
  1. Vue Router configuration:
import Vue from 'vue'
import VueRouter from 'vue-router'
import Index from './component/index'
import Topic from './component/topic'
import User from './component/user'

Vue.use(VueRouter)

const router = new VueRouter({
  routes: [
    { path: '/', component: Index },
    { path: '/topic/:id', component: Topic },
    { path: '/user/:loginname', component: User }
  ]
})

export default router
  1. API call example:
import axios from 'axios'

export default {
  getTopics(params) {
    return axios.get('https://cnodejs.org/api/v1/topics', { params })
  },
  getTopic(id) {
    return axios.get(`https://cnodejs.org/api/v1/topic/${id}`)
  }
}

Getting Started

To get started with vue-cnode:

  1. Clone the repository:

    git clone https://github.com/lzxb/vue-cnode.git
    
  2. Install dependencies:

    cd vue-cnode
    npm install
    
  3. Run the development server:

    npm run dev
    
  4. Open your browser and navigate to http://localhost:8080 to see the application running.

Competitor Comparisons

207,677

This is the repo for Vue 2. For Vue 3, go to https://github.com/vuejs/core

Pros of Vue

  • Much larger and more active community with over 200k stars on GitHub
  • More comprehensive framework with official routing, state management, and tooling
  • Extensively documented with official guides, API references, and examples

Cons of Vue

  • Steeper learning curve due to more features and concepts to grasp
  • Potentially overkill for smaller projects or simple applications
  • Larger bundle size compared to minimal Vue implementations

Code Comparison

Vue (core template syntax):

<template>
  <div>{{ message }}</div>
</template>

<script>
export default {
  data() {
    return {
      message: 'Hello Vue!'
    }
  }
}
</script>

vue-cnode (example component):

<template>
  <div class="user">
    <user-info :user="user"></user-info>
    <user-topics :user="user"></user-topics>
  </div>
</template>

<script>
export default {
  name: 'user',
  computed: {
    user() {
      return this.$store.state.user.view
    }
  }
}
</script>

Summary

Vue is a more comprehensive framework with a larger ecosystem, while vue-cnode is a specific implementation for the CNode community. Vue offers more features and flexibility but may be more complex, whereas vue-cnode is tailored for a particular use case and potentially simpler to use within its intended context.

227,213

The library for web and native user interfaces.

Pros of React

  • Larger community and ecosystem, with more resources and third-party libraries
  • More flexible and can be used for both web and mobile development
  • Better performance for large-scale applications due to virtual DOM

Cons of React

  • Steeper learning curve, especially for beginners
  • Requires additional libraries for state management and routing
  • More boilerplate code compared to Vue.js

Code Comparison

React component:

import React from 'react';

const MyComponent = ({ name }) => {
  return <div>Hello, {name}!</div>;
};

export default MyComponent;

Vue-cnode component:

<template>
  <div>Hello, {{ name }}!</div>
</template>

<script>
export default {
  props: ['name']
}
</script>

Additional Notes

  • React is a more comprehensive library, while vue-cnode is a specific implementation of Vue.js for the CNode community
  • Vue-cnode is tailored for a specific use case, while React is more general-purpose
  • React has a larger job market and more widespread adoption in enterprise environments
  • Vue-cnode may be easier to set up and use for beginners or small projects
  • Both projects are open-source and actively maintained, but React has more frequent updates and contributions
95,657

Deliver web apps with confidence 🚀

Pros of Angular

  • More comprehensive framework with built-in features for large-scale applications
  • Strong typing with TypeScript integration
  • Extensive documentation and community support

Cons of Angular

  • Steeper learning curve for beginners
  • Heavier and more complex than Vue.js
  • Requires more boilerplate code

Code Comparison

Angular component:

@Component({
  selector: 'app-root',
  template: `<h1>{{ title }}</h1>`
})
export class AppComponent {
  title = 'Hello, Angular!';
}

vue-cnode component:

<template>
  <div>{{ message }}</div>
</template>

<script>
export default {
  data() {
    return {
      message: 'Hello, Vue!'
    }
  }
}
</script>

Summary

Angular is a more robust framework suitable for large-scale applications, offering strong typing and comprehensive features. However, it has a steeper learning curve and requires more boilerplate code. vue-cnode, being based on Vue.js, is lighter and easier to learn, making it more suitable for smaller projects or developers new to frontend frameworks. The code comparison shows that Angular uses TypeScript and decorators, while vue-cnode uses a more straightforward Vue.js component structure.

78,194

Cybernetically enhanced web apps

Pros of Svelte

  • Smaller bundle sizes and faster runtime performance
  • Simpler, more intuitive syntax with less boilerplate code
  • Built-in reactivity without the need for a virtual DOM

Cons of Svelte

  • Smaller ecosystem and community compared to Vue
  • Fewer third-party libraries and components available
  • Steeper learning curve for developers coming from traditional frameworks

Code Comparison

Svelte component:

<script>
  let count = 0;
  function increment() {
    count += 1;
  }
</script>

<button on:click={increment}>
  Clicks: {count}
</button>

Vue-CNode component:

<template>
  <button @click="increment">
    Clicks: {{ count }}
  </button>
</template>

<script>
export default {
  data() {
    return { count: 0 };
  },
  methods: {
    increment() {
      this.count += 1;
    }
  }
};
</script>

The Svelte code is more concise and requires less boilerplate. It uses a more straightforward approach to reactivity, while Vue-CNode follows Vue's traditional component structure with separate template and script sections.

36,546

⚛️ Fast 3kB React alternative with the same modern API. Components & Virtual DOM.

Pros of Preact

  • Smaller bundle size and faster performance due to its lightweight nature
  • Closer to vanilla JavaScript, making it easier for developers familiar with JS
  • Compatible with many React libraries and tools through aliases

Cons of Preact

  • Smaller ecosystem compared to Vue, which vue-cnode leverages
  • Less comprehensive documentation and community resources
  • May require additional configuration for some React-specific features

Code Comparison

vue-cnode (Vue.js):

<template>
  <div>{{ message }}</div>
</template>

<script>
export default {
  data() {
    return {
      message: 'Hello, Vue!'
    }
  }
}
</script>

Preact:

import { h, Component } from 'preact';

class App extends Component {
  render() {
    return <div>Hello, Preact!</div>;
  }
}

Summary

Preact offers a lightweight alternative to React with similar syntax and compatibility, making it suitable for performance-critical applications. vue-cnode, built with Vue.js, benefits from Vue's extensive ecosystem and easier learning curve. Preact's code is more concise and closer to vanilla JavaScript, while vue-cnode follows Vue's template-based approach. The choice between them depends on project requirements, team expertise, and performance considerations.

16,083

:fire: An extremely fast, React-like JavaScript library for building modern user interfaces

Pros of Inferno

  • Higher performance and smaller bundle size than Vue-based projects
  • More flexible and lightweight, allowing for greater customization
  • Better suited for complex, high-performance applications

Cons of Inferno

  • Smaller community and ecosystem compared to Vue
  • Steeper learning curve, especially for developers familiar with Vue
  • Less comprehensive documentation and fewer ready-made components

Code Comparison

Vue-cnode (Vue.js):

<template>
  <div>{{ message }}</div>
</template>

<script>
export default {
  data() {
    return {
      message: 'Hello, Vue!'
    }
  }
}
</script>

Inferno:

import { render } from 'inferno';

function MyComponent({ message }) {
  return <div>{message}</div>;
}

render(<MyComponent message="Hello, Inferno!" />, document.getElementById('app'));

The code comparison shows that Inferno uses a more React-like syntax with JSX, while Vue-cnode uses Vue's template and script structure. Inferno's approach is more JavaScript-centric, which can be advantageous for developers with strong JavaScript skills. However, Vue's template-based approach may be more intuitive for some developers, especially those new to frontend frameworks.

Inferno's performance benefits and smaller bundle size make it a strong choice for projects where these factors are crucial. However, Vue-cnode, being based on Vue.js, offers a gentler learning curve and a larger ecosystem, which can be beneficial for rapid development and community support.

Convert Figma logo designs to code with AI

Visual Copilot

Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.

Try Visual Copilot

README

此项目除了正常的bug修复,不再进行功能更新

如果对状态管理感兴趣,可以看下 Tms,文档更齐全

前言

项目灵感的最初来源是@shinygang来自的Vue-cnodejs, 感谢cnodejs社区提供的API。 github:https://github.com/lzxb/vue-cnode

感悟

在vue-cnode升级vue2的时候,在公司内部已经有两个正式项目使用vue2,
遇到的一个最难的问题,就是如何能在页面后退时还原数据和滚动条位置,
虽然vue2内置了keep-alive组件,vue-router也提供了scrollBehavior方法进行设置,
但是仍然无法满足需求,后来阅读vue-router的源码发现,
每个页面都会自动在history.state对象中存储一个对应的key值,
便利用这个特性实现了页面后退时,数据和滚动条还原,
不过目前只是实现了页面的顶级组件还原,
如果需要对顶级组件下的子组件实现数据还原,
可以利用$options._scopeId来实现。
哈哈,具体如何实现就要靠大家自己发挥想象力了

技术栈

基于vue2 + vue-router + vuet + ES6 + less + flex.css重写vue版cnode社区,使用webpack打包

使用项目

1.克隆项目:      git clone https://github.com/lzxb/vue-cnode.git
2.安装nodejs
3.安装依赖:      npm install
4.启动服务:      npm run dev
5.发布代码:      npm run build

功能

  • 首页列表,上拉加载
  • 主题详情,回复,点赞
  • 消息列表
  • 消息提醒
  • 消息标记为已读
  • 个人主页
  • 用户信息
  • 登录
  • 退出
  • 关于
  • 页面后退,数据还原
  • 页面后退,滚动位置还原
  • ajax请求拦截器
  • 页面跳转,不再执行此页面的ajax请求回调方法
  • 启动图

项目目录说明

.
|-- config                           // 项目开发环境配置
|   |-- index.js                     // 项目打包部署配置
|-- src                              // 源码目录
|   |-- components                   // 公共组件
|       |-- content.vue              // 页面内容公共组件
|       |-- data-null.vue            // 数据为空时公共组件
|       |-- footer.vue               // 底部导航栏公共组件
|       |-- header.vue               // 页面头部公共组件
|       |-- index.js                 // 加载各种公共组件
|       |-- loading.vue              // 页面数据加载公共组件
|   |-- config                       // 路由配置和程序的基本信息配置
|       |-- config.js                // 配置项目的基本信息
|       |-- routes.js                // 配置页面路由
|   |-- css                          // 各种css文件
|       |-- common.css               // 全局通用css文件
|   |-- iconfont                     // 各种字体图标
|   |-- images                       // 公共图片
|   |-- less                         // 各种less文件
|       |-- common.less              // 全局通用less文件
|       |-- config.less              // 全局通用less配置文件
|   |-- lib                          // 各种插件
|       |-- route-data               // 实现页面后退数据还原,滚动位置还原
|   |-- mixins                       // 各种全局mixins
|       |-- pull-list.js             // 上拉加载
|   |-- pages                        // 各种页面组件
|       |-- about                    // 关于
|       |-- index                    // 首页
|       |-- login                    // 登录
|       |-- my                       // 我的主页,和消息列表
|       |-- signout                  // 退出
|       |-- topic                    // 主题详情,主题新建
|       |-- user                     // 查看用户资料
|   |-- store                        // vuex的状态管理
|       |-- index.js                 // 加载各种store模块
|       |-- user.js                  // 用户store
|   |-- template                     // 各种html文件
|       |-- index.html               // 程序入口html文件
|   |-- utils                        // 公共的js方法
|   |-- app.vue                      // 页面入口文件
|   |-- main.js                      // 程序入口文件,加载各种公共组件
|-- .babelrc                         // ES6语法编译配置
|-- webpack.config.js                // 程序打包配置
|-- server.js                        // 开发时使用的服务器
|-- README.md                        // 项目说明
|-- package.json                     // 配置项目相关信息,通过执行 npm init 命令创建
.

扫一扫二维码查看效果

扫一扫二维码查看效果

NPM DownloadsLast 30 Days