Browse Source

master

master
邓宏 3 years ago
parent
commit
0d28945a00
  1. 596
      package-lock.json
  2. 1
      package.json
  3. 27
      src/App.vue
  4. 3
      src/assets/index.less
  5. BIN
      src/assets/logo.png
  6. 1
      src/assets/svg/atm.svg
  7. 59
      src/components/HelloWorld.vue
  8. 43
      src/components/svgIcon.vue
  9. 11
      src/main.js
  10. 8
      src/views/Home.vue
  11. 63
      vue.config.js

596
package-lock.json

File diff suppressed because it is too large

1
package.json

@ -19,6 +19,7 @@
"@vue/cli-service": "~4.5.0",
"@vue/compiler-sfc": "^3.0.0",
"less": "^3.0.4",
"svg-sprite-loader": "^6.0.11",
"less-loader": "^5.0.0"
}
}

27
src/App.vue

@ -1,30 +1,3 @@
<template>
<div id="nav">
<router-link to="/">Home</router-link> |
<router-link to="/about">About</router-link>
</div>
<router-view/>
</template>
<style lang="less">
#app {
font-family: Avenir, Helvetica, Arial, sans-serif;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
text-align: center;
color: #2c3e50;
}
#nav {
padding: 30px;
a {
font-weight: bold;
color: #2c3e50;
&.router-link-exact-active {
color: #42b983;
}
}
}
</style>

3
src/assets/index.less

@ -0,0 +1,3 @@
#app {
font-family: Avenir, Helvetica, Arial, sans-serif;
}

BIN
src/assets/logo.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.7 KiB

1
src/assets/svg/atm.svg

@ -0,0 +1 @@
<?xml version="1.0" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"><svg t="1641785888735" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="2112" xmlns:xlink="http://www.w3.org/1999/xlink" width="200" height="200"><defs><style type="text/css"></style></defs><path d="M784.130082 627.2 784.130082 627.2C763.43961 627.2 746.666667 582.309084 746.666667 526.933333 746.666667 471.557583 763.43961 426.666667 784.130082 426.666667 804.820555 426.666667 821.593495 471.557583 821.593495 526.933333 821.593495 582.309084 804.820555 627.2 784.130082 627.2L784.130082 627.2Z" p-id="2113"></path><path d="M506.796749 666.133333 506.796749 666.133333C486.106276 666.133333 469.333333 626.853781 469.333333 578.4 469.333333 529.946219 486.106276 490.666667 506.796749 490.666667 527.487221 490.666667 544.260162 529.946219 544.260162 578.4 544.260162 626.853781 527.487221 666.133333 506.796749 666.133333L506.796749 666.133333Z" p-id="2114"></path><path d="M298.176058 170.679793C148.903723 243.807857 52.325153 380.784905 47.795479 533.899838 47.683821 537.67418 47.627907 541.454551 47.627907 545.240309 47.627907 558.392393 58.289777 569.054263 71.44186 569.054263 84.593944 569.054263 95.255814 558.392393 95.255814 545.240309 95.255814 541.924122 95.304783 538.613263 95.402558 535.308222 99.385529 400.673301 185.092659 279.115179 319.12951 213.450932 330.940433 207.664797 335.824491 193.399561 330.038353 181.588637 324.252218 169.777713 309.986982 164.893657 298.176058 170.679793L298.176058 170.679793ZM495.752687 972.469122C509.028354 973.415674 522.389387 973.891473 535.813954 973.891473 804.760642 973.891473 1024 782.759725 1024 545.240309 1024 307.720894 804.760642 116.589147 535.813954 116.589147 539.293886 116.589147 540.530596 117.143252 540.453681 117.087011 538.422812 115.602003 536.101914 113.576604 529.892474 107.917904 512.620427 92.177777 501.81277 83.341593 485.099902 72.691983 433.740934 39.965525 366.37498 21.333334 273.860465 21.333334 260.708382 21.333334 250.046511 31.995204 250.046511 45.147288 250.046511 58.299371 260.708382 68.961241 273.860465 68.961241 357.524284 68.961241 415.995189 85.133224 459.505449 112.858405 471.051998 120.215985 519.335509 164.217054 535.813954 164.217054 779.798515 164.217054 976.372094 335.588892 976.372094 545.240309 976.372094 754.891729 779.798515 926.263567 535.813954 926.263567 523.519644 926.263567 511.288412 925.828 499.139945 924.961818 486.021165 924.026453 474.628028 933.903061 473.692663 947.021843 472.757297 960.140623 482.633907 971.533758 495.752687 972.469122L495.752687 972.469122Z" p-id="2115"></path><path d="M238.139535 1021.519379C369.660369 1021.519379 476.27907 914.900678 476.27907 783.379844 476.27907 651.859012 369.660369 545.240309 238.139535 545.240309 106.618701 545.240309 0 651.859012 0 783.379844 0 914.900678 106.618701 1021.519379 238.139535 1021.519379L238.139535 1021.519379ZM238.139535 973.891473C132.922868 973.891473 47.627907 888.596512 47.627907 783.379844 47.627907 678.163179 132.922868 592.868218 238.139535 592.868218 343.356203 592.868218 428.651164 678.163179 428.651164 783.379844 428.651164 888.596512 343.356203 973.891473 238.139535 973.891473L238.139535 973.891473Z" p-id="2116"></path><path d="M214.325581 678.598449 214.325581 821.48217C214.325581 834.634255 224.987452 845.296124 238.139535 845.296124 251.291618 845.296124 261.953489 834.634255 261.953489 821.48217L261.953489 678.598449C261.953489 665.446366 251.291618 654.784497 238.139535 654.784497 224.987452 654.784497 214.325581 665.446366 214.325581 678.598449L214.325581 678.598449Z" p-id="2117"></path><path d="M303.689267 834.377316 237.010199 758.172666C228.349491 748.274714 213.304725 747.271729 203.406774 755.932437 193.508823 764.593146 192.505838 779.637909 201.166546 789.535861L267.845615 865.740512C276.506323 875.638464 291.551089 876.641449 301.449039 867.98074 311.346991 859.320034 312.349975 844.275268 303.689267 834.377316L303.689267 834.377316Z" p-id="2118"></path></svg>

After

Width:  |  Height:  |  Size: 4.0 KiB

59
src/components/HelloWorld.vue

@ -1,59 +0,0 @@
<template>
<div class="hello">
<h1>{{ msg }}</h1>
<p>
For a guide and recipes on how to configure / customize this project,<br>
check out the
<a href="https://cli.vuejs.org" target="_blank" rel="noopener">vue-cli documentation</a>.
</p>
<h3>Installed CLI Plugins</h3>
<ul>
<li><a href="https://github.com/vuejs/vue-cli/tree/dev/packages/%40vue/cli-plugin-babel" target="_blank" rel="noopener">babel</a></li>
<li><a href="https://github.com/vuejs/vue-cli/tree/dev/packages/%40vue/cli-plugin-router" target="_blank" rel="noopener">router</a></li>
<li><a href="https://github.com/vuejs/vue-cli/tree/dev/packages/%40vue/cli-plugin-vuex" target="_blank" rel="noopener">vuex</a></li>
</ul>
<h3>Essential Links</h3>
<ul>
<li><a href="https://vuejs.org" target="_blank" rel="noopener">Core Docs</a></li>
<li><a href="https://forum.vuejs.org" target="_blank" rel="noopener">Forum</a></li>
<li><a href="https://chat.vuejs.org" target="_blank" rel="noopener">Community Chat</a></li>
<li><a href="https://twitter.com/vuejs" target="_blank" rel="noopener">Twitter</a></li>
<li><a href="https://news.vuejs.org" target="_blank" rel="noopener">News</a></li>
</ul>
<h3>Ecosystem</h3>
<ul>
<li><a href="https://router.vuejs.org" target="_blank" rel="noopener">vue-router</a></li>
<li><a href="https://vuex.vuejs.org" target="_blank" rel="noopener">vuex</a></li>
<li><a href="https://github.com/vuejs/vue-devtools#vue-devtools" target="_blank" rel="noopener">vue-devtools</a></li>
<li><a href="https://vue-loader.vuejs.org" target="_blank" rel="noopener">vue-loader</a></li>
<li><a href="https://github.com/vuejs/awesome-vue" target="_blank" rel="noopener">awesome-vue</a></li>
</ul>
</div>
</template>
<script>
export default {
name: 'HelloWorld',
props: {
msg: String
}
}
</script>
<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped lang="less">
h3 {
margin: 40px 0 0;
}
ul {
list-style-type: none;
padding: 0;
}
li {
display: inline-block;
margin: 0 10px;
}
a {
color: #42b983;
}
</style>

43
src/components/svgIcon.vue

@ -0,0 +1,43 @@
<style lang="less" scoped>
.svg-icon{
width:1em;
height:1em;
vertical-align: -0.15em;
fill:currentColor;
overflow: hidden;
}
</style>
<template>
<svg class="svg-icon" aria-hidden="true" >
<use :xlink:href="iconName" :fill="color"/>
</svg>
</template>
<script>
import { computed, defineComponent } from 'vue'
const req=require.context('@/assets/svg',false, /\.svg$/)
const requireAll=requireContext => requireContext.keys().map(requireContext)
requireAll(req)
export default defineComponent({
name:"SvgIcon",
props:{
iconClass:{
type:String,
required:true,
},
color:{
type:String,
default:""
},
},
install(Vue,opt){
Vue.component(this.name,this)
},
setup(props,ctx) {
return{
iconName:computed(()=>`#icon-${props.iconClass}`),
}
},
})
</script>

11
src/main.js

@ -3,4 +3,13 @@ import App from './App.vue'
import router from './router'
import store from './store'
createApp(App).use(store).use(router).mount('#app')
import svgIcon from "@/components/svgIcon.vue"
//自定义样式
import "@/assets/index.less"
createApp(App)
.use(svgIcon)
.use(store)
.use(router)
.mount('#app')

8
src/views/Home.vue

@ -1,18 +1,12 @@
<template>
<div class="home">
<img alt="Vue logo" src="../assets/logo.png">
<HelloWorld msg="Welcome to Your Vue.js App"/>
<svg-icon iconClass="atm"/>
</div>
</template>
<script>
// @ is an alias to /src
import HelloWorld from '@/components/HelloWorld.vue'
export default {
name: 'Home',
components: {
HelloWorld
}
}
</script>

63
vue.config.js

@ -0,0 +1,63 @@
const path = require("path");
let resolve=dir=>path.join(__dirname,dir)
const isProduction = process.env.NODE_ENV === "production";
module.exports = {
publicPath:"./",
productionSourceMap:false,
lintOnSave: false,
filenameHashing: !isProduction,
// outputDir:"",
pages: {
index: {
entry: 'src/main.js',
template: 'public/index.html',
filename: 'index.html'
},
},
configureWebpack:{
devtool: "source-map"//isProduction ? false : "source-map",
},
devServer: {
port: process.env.PORT||8899, // 服务端口 默认8899
https: false, // 是否使用https
open: true, // 是否打开游览器
// proxy: { // 跨域代理
// '/api': {
// target: loadEnv(mode, process.cwd()).VITE_APP_API,
// changeOrigin: true,
// rewrite: (path) => path.replace(/^\/api/, '')
// }
// }
},
// 扩展 webpack 配置,使 packages 加入编译
chainWebpack: config => {
// config.module
// .rule('js')
// .include
// .add('/packages')
// .end()
// .use('babel')
// .loader('babel-loader')
// .tap(options => {
// return options
// })
//自定义图片
config.module.rule("images").use('url-loader').tap(options=>({
name:`./img/[hash]_[name].[ext]`,
quality:85,
limit: 0,
exModule:false,
}) )
//svg
config.module.rule("svg").exclude.add(resolve('src/assets/svg')).end()
config.module.rule('icons').test(/\.svg$/).include.add(resolve('src/assets/svg')).end().use('svg-sprite-loader').loader('svg-sprite-loader').options({symbolId:'icon-[name]'}).end()
config.optimization.splitChunks(false);
// config.optimization.minimize(false);//不压缩代码
config.resolve.alias
.set("@", path.join(__dirname, 'src'))
}
}
Loading…
Cancel
Save