This commit is contained in:
Lau-Laptop\Lau 2023-12-14 17:58:13 +08:00
commit 4cfc225227
25 changed files with 20287 additions and 0 deletions

3
.browserslistrc Normal file
View File

@ -0,0 +1,3 @@
> 1%
last 2 versions
not ie <= 9

3
.env.development Normal file
View File

@ -0,0 +1,3 @@
VUE_APP_TITLE = 'DEV标题'
VUE_APP_BASE_URL = '/'
VUE_APP_API_URL = '/api'

3
.env.production Normal file
View File

@ -0,0 +1,3 @@
VUE_APP_TITLE = '标题'
VUE_APP_BASE_URL = './'
VUE_APP_API_URL = '/api'

23
.eslintrc.js Normal file
View File

@ -0,0 +1,23 @@
module.exports = {
root: true,
env: {
node: true,
},
extends: [
'plugin:vue/essential',
'eslint:recommended',
'plugin:prettier/recommended',
],
parserOptions: {
parser: '@babel/eslint-parser',
},
rules: {
'no-console': process.env.NODE_ENV === 'production' ? 'warn' : 'off',
'no-debugger': process.env.NODE_ENV === 'production' ? 'warn' : 'off',
'no-alert': 0,
'no-var': 0,
semi: [0, 'always'],
quotes: [0, 'single'],
'prettier/prettier': ['error', { endOfLine: 'auto' }],
},
}

23
.gitignore vendored Normal file
View File

@ -0,0 +1,23 @@
.DS_Store
node_modules
/dist
# local env files
.env.local
.env.*.local
# Log files
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*
# Editor directories and files
.idea
.vscode
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw?

4
.prettierrc Normal file
View File

@ -0,0 +1,4 @@
{
"semi": false,
"singleQuote": true
}

27
README.md Normal file
View File

@ -0,0 +1,27 @@
# vue2-template
## Project setup
```
npm install
```
### Compiles and hot-reloads for development
```
npm run serve
```
or
```
npm run dev
```
### Compiles and minifies for production
```
npm run build
```
### Lints and fixes files
```
npm run lint
```
### Customize configuration
See [Configuration Reference](https://cli.vuejs.org/config/).

3
babel.config.js Normal file
View File

@ -0,0 +1,3 @@
module.exports = {
presets: ['@vue/cli-plugin-babel/preset'],
}

19
jsconfig.json Normal file
View File

@ -0,0 +1,19 @@
{
"compilerOptions": {
"target": "es5",
"module": "esnext",
"baseUrl": "./",
"moduleResolution": "node",
"paths": {
"@/*": [
"src/*"
]
},
"lib": [
"esnext",
"dom",
"dom.iterable",
"scripthost"
]
}
}

19883
package-lock.json generated Normal file

File diff suppressed because it is too large Load Diff

35
package.json Normal file
View File

@ -0,0 +1,35 @@
{
"name": "vue2-template",
"version": "0.1.0",
"private": true,
"scripts": {
"serve": "vue-cli-service serve",
"dev": "vue-cli-service serve",
"build": "vue-cli-service build",
"lint": "vue-cli-service lint"
},
"dependencies": {
"axios": "^1.6.2",
"core-js": "^3.8.3",
"vue": "^2.6.14",
"vue-router": "^3.5.1",
"vuex": "^3.6.2"
},
"devDependencies": {
"@babel/core": "^7.12.16",
"@babel/eslint-parser": "^7.12.16",
"@vue/cli-plugin-babel": "~5.0.0",
"@vue/cli-plugin-eslint": "~5.0.0",
"@vue/cli-plugin-router": "~5.0.0",
"@vue/cli-plugin-vuex": "~5.0.0",
"@vue/cli-service": "~5.0.0",
"eslint": "^7.32.0",
"eslint-config-prettier": "^8.3.0",
"eslint-plugin-prettier": "^4.0.0",
"eslint-plugin-vue": "^8.0.3",
"prettier": "^2.4.1",
"sass": "^1.32.7",
"sass-loader": "^12.0.0",
"vue-template-compiler": "^2.6.14"
}
}

BIN
public/favicon.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.2 KiB

17
public/index.html Normal file
View File

@ -0,0 +1,17 @@
<!DOCTYPE html>
<html lang="">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width,initial-scale=1.0">
<link rel="icon" href="<%= BASE_URL %>favicon.ico">
<title><%= htmlWebpackPlugin.options.title %></title>
</head>
<body>
<noscript>
<strong>We're sorry but <%= htmlWebpackPlugin.options.title %> doesn't work properly without JavaScript enabled. Please enable it to continue.</strong>
</noscript>
<div id="app"></div>
<!-- built files will be auto injected -->
</body>
</html>

7
src/App.vue Normal file
View File

@ -0,0 +1,7 @@
<template>
<div id="app">
<router-view />
</div>
</template>
<style lang="scss"></style>

BIN
src/assets/logo.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.7 KiB

View File

@ -0,0 +1,49 @@
<template>
<div class="base-btn" :style="{ minWidth: width }" @click="emitClick">
<span>
<slot>按钮</slot>
</span>
</div>
</template>
<script>
export default {
name: 'BaseBtn',
props: {
width: {
type: String,
default: '40px',
},
},
data() {
return {}
},
computed: {},
methods: {
emitClick() {
this.$emit('click')
},
},
}
</script>
<style lang="scss" scoped>
.base-btn {
display: inline-block;
padding: 6px 14px;
border: 1px solid rgba($color: #2784fd, $alpha: 0.3);
border-radius: 6px;
background-color: #2784fd;
color: #ffffff;
text-align: center;
font-size: 16px;
-webkit-touch-callout: none; /* iOS Safari */
-webkit-user-select: none; /* Chrome/Safari/Opera */
-moz-user-select: none; /* Firefox */
-ms-user-select: none; /* IE10+ */
user-select: none; /* Standard syntax */
&:hover {
background-color: #4998ff;
cursor: pointer;
}
}
</style>

13
src/main.js Normal file
View File

@ -0,0 +1,13 @@
import Vue from 'vue'
import App from './App.vue'
import router from './router'
import store from './store'
Vue.config.productionTip = false
Vue.prototype.$bus = new Vue() // 定义全局事件总线,便于组件之间通讯
new Vue({
router,
store,
render: (h) => h(App),
}).$mount('#app')

12
src/router/index.js Normal file
View File

@ -0,0 +1,12 @@
import Vue from 'vue'
import VueRouter from 'vue-router'
import routes from './routes'
Vue.use(VueRouter)
const router = new VueRouter({
mode: 'hash',
routes,
})
export default router

12
src/router/routes.js Normal file
View File

@ -0,0 +1,12 @@
import HomeView from '@/views/HomeView.vue'
const routes = [
{
path: '/',
name: 'home',
component: HomeView,
},
{ path: '*', component: () => import('@/views/404View.vue') },
]
export default routes

12
src/store/index.js Normal file
View File

@ -0,0 +1,12 @@
import Vue from 'vue'
import Vuex from 'vuex'
Vue.use(Vuex)
export default new Vuex.Store({
state: {},
getters: {},
mutations: {},
actions: {},
modules: {},
})

17
src/views/404View.vue Normal file
View File

@ -0,0 +1,17 @@
<template>
<div></div>
</template>
<script>
export default {
name: '404View',
components: {},
props: {},
data() {
return {}
},
computed: {},
methods: {},
}
</script>
<style lang="scss" scoped></style>

44
src/views/HomeView.vue Normal file
View File

@ -0,0 +1,44 @@
<template>
<div class="home">
<div>
<Btn @click="handleTestBtn">测试按钮自动</Btn>
</div>
<div>
{{ pro }}
<Test />
<Test2 />
</div>
</div>
</template>
<script>
import Btn from '@/components/BaseBtn.vue'
import Test from '@/views/testPro.vue'
import Test2 from '@/views/testPro2.vue'
export default {
name: 'HomeView',
components: { Btn, Test, Test2 },
props: {},
data() {
return {
pro: 123,
}
},
computed: {},
provide() {
return {
num: this.pro,
changeNum: this.changeNum,
}
},
methods: {
handleTestBtn() {
console.log(123)
},
changeNum() {
this.pro += 123
},
},
}
</script>
<style lang="scss" scoped></style>

36
src/views/testPro.vue Normal file
View File

@ -0,0 +1,36 @@
<template>
<div>
<div>{{ n }}</div>
<button @click="handleChange">change</button>
</div>
</template>
<script>
export default {
name: 'testPro',
components: {},
props: {},
inject: ['num', 'changeNum'],
data() {
return {
n: this.num,
}
},
computed: {},
methods: {
handleChange() {
this.n += 123
this.changeNum()
},
},
mounted() {
this.$bus.$on('test', (data) => {
console.log(data)
})
},
beforeDestroy() {
this.$bus.$off('test')
},
}
</script>
<style lang="scss" scoped></style>

33
src/views/testPro2.vue Normal file
View File

@ -0,0 +1,33 @@
<template>
<div>
<div>{{ n }}</div>
<button @click="handleChange">change</button>
<button @click="handleBrother">eventBus</button>
</div>
</template>
<script>
export default {
name: 'testPro2',
components: {},
props: {},
inject: ['num', 'changeNum'],
data() {
return {
n: this.num,
aa: 10,
}
},
computed: {},
methods: {
handleChange() {
this.n += 123
this.changeNum()
},
handleBrother() {
this.$bus.$emit('test', 'testEvent')
},
},
}
</script>
<style lang="scss" scoped></style>

9
vue.config.js Normal file
View File

@ -0,0 +1,9 @@
const { defineConfig } = require('@vue/cli-service')
module.exports = defineConfig({
transpileDependencies: true,
devServer: {
port: 3002,
proxy: {},
},
})