Git Product home page Git Product logo

floodboad / light-vue3-starter Goto Github PK

View Code? Open in Web Editor NEW

This project forked from tommy44458/light-vue3-starter

0.0 0.0 0.0 719 KB

A LIGHT Vue3 Starter Admin Template by Vue3 + Vite + TypeScript + Pinia + WindiCSS + Mqtt + ESlint(Airbnb)

Home Page: https://light-vue3-starter-tommy44458.vercel.app/

License: MIT License

Shell 0.26% JavaScript 15.92% TypeScript 40.65% HTML 0.99% Vue 37.30% SCSS 4.87%

light-vue3-starter's Introduction

A LIGHT Vue3 Starter Admin Template.

This template should help get you started developing with Vue3, Pinia, WindiCSS, ElementPlus, Mqtt and TypeScript in Vite. The template uses Vue3 <script setup> SFCs. Also, this template also supports MQTT so that it can easily become a control system for IoT devices.

image

Check out the Online DEMO.

// login info
Account: tommy
Password: tommy

This starter template includes:

Collaboration-code specification

Many tech teams generally use Airbnb to constrain code specifications at present.

  • Through pre-commit to implement lint check,unit test,code formatting,etc.。
  • Combined with the VsCode(formatting automatically when saving:editor.formatOnSave: true)
  • Combined with the Git hooks(execute before commit:pre-commit => yarn lint)
  • IDE configuration(.editorconfig),ESLint configuration(.eslintrc.js.eslintignore),StyleLint configuration(.stylelintrc, .stylelintignore),for details, please refer to the corresponding configuration file。

Close code specification add .eslintignore and .stylelintignore to src/ directory respectively to ignore

Recommended IDE Setup

Support MQTT client

src/main.ts

import { createApp } from 'vue'
import App from './App.vue'

const app = createApp(App)

// protocol = 'wss', 'ws', 'mqtt', ...
// host = ip or domain
// port = 8083, 1883, ...
import mqttVueHook from 'mqtt-vue-hook'
// app.use(mqttVueHook, options)
app.use(mqttVueHook, `${protocol}://${host}:${port}`, {
  clean: false,
  keepalive: 60,
  clientId: `mqtt_client_${Math.random().toString(16).substring(2, 10)}`,
  connectTimeout: 4000,
})

views/console/ConsolePage1.vue

<script setup lang="ts">
import { useMQTT } from 'mqtt-vue-hook'

const mqttHook = useMQTT()

const form = reactive({
	// ...data
})

const mqttSubscribe = () => {
	mqttHook.subscribe(['+/vue3/starter/console/page1'], 1)

	// if receive mes from '+/vue3/starter/console/page1' before excute callback function.
	mqttHook.registerEvent(
		'+/vue3/starter/console/page1',
		// callback funtion
		(topic: string, message: string) => {
			const mesJson = JSON.parse(message.toString())
			ElNotification({
				title: `MQTT TOPIC: ${topic}`,
				message: mesJson,
				type: 'info',
			})
		},
		'key',
	)
}

const onPublish = () => {
	mqttHook.publish(
		'tommy44458/vue3/starter/console/page1',
		JSON.stringify({
			// ...form.data
		}),
	)
}

onMounted(() => {
	mqttSubscribe()
})

onUnmounted(() => {
	// remove Event by topic and key
	mqttHook.unRegisterEvent('+/vue3/starter/console/page1', 'key')
	mqttHook.unSubscribe('+/vue3/starter/console/page1')
})

Getting Started

Install

yarn install

Dev

yarn dev

Build

yarn build

Syntax check

// eslint
yarn lint
// stylelint
yarn lint:style

light-vue3-starter's People

Contributors

tommy44458 avatar

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.