Skip to content

Commit 4b8d6d4

Browse files
committed
feat: add source code to all templates
1 parent cf01dbc commit 4b8d6d4

File tree

20 files changed

+337
-9
lines changed

20 files changed

+337
-9
lines changed

template/source/default/src/App.vue

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<template>
2+
<img alt="Vue logo" src="./assets/logo.png" />
3+
<HelloWorld msg="Hello Vue 3 + Vite" />
4+
</template>
5+
6+
<script setup>
7+
import HelloWorld from './components/HelloWorld.vue'
8+
9+
// This starter template is using Vue 3 experimental <script setup> SFCs
10+
// Check out https://github.com/vuejs/rfcs/blob/master/active-rfcs/0040-script-setup.md
11+
</script>
12+
13+
<style>
14+
#app {
15+
font-family: Avenir, Helvetica, Arial, sans-serif;
16+
-webkit-font-smoothing: antialiased;
17+
-moz-osx-font-smoothing: grayscale;
18+
text-align: center;
19+
color: #2c3e50;
20+
margin-top: 60px;
21+
}
22+
</style>
6.69 KB
Loading
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
<template>
2+
<h1>{{ msg }}</h1>
3+
4+
<p>
5+
<a href="https://vitejs.dev/guide/features.html" target="_blank">
6+
Vite Documentation
7+
</a>
8+
|
9+
<a href="https://v3.vuejs.org/" target="_blank">Vue 3 Documentation</a>
10+
</p>
11+
12+
<button type="button" @click="state.count++">
13+
count is: {{ state.count }}
14+
</button>
15+
<p>
16+
Edit
17+
<code>components/HelloWorld.vue</code> to test hot module replacement.
18+
</p>
19+
</template>
20+
21+
<script setup>
22+
import { ref } from 'vue'
23+
24+
defineProps({
25+
msg: {
26+
type: String,
27+
required: true
28+
}
29+
})
30+
31+
const count = ref(0)
32+
</script>
33+
34+
<style scoped>
35+
a {
36+
color: #42b983;
37+
}
38+
</style>

template/source/default/src/main.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
import { createApp } from 'vue'
2+
import App from './App.vue'
3+
4+
createApp(App).mount('#app')

template/source/spa/src/App.vue

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
<template>
2+
<div id="nav">
3+
<router-link to="/">Home</router-link> |
4+
<router-link to="/about">About</router-link>
5+
</div>
6+
<router-view/>
7+
</template>
8+
9+
<style>
10+
#app {
11+
font-family: Avenir, Helvetica, Arial, sans-serif;
12+
-webkit-font-smoothing: antialiased;
13+
-moz-osx-font-smoothing: grayscale;
14+
text-align: center;
15+
color: #2c3e50;
16+
}
17+
18+
#nav {
19+
padding: 30px;
20+
}
21+
22+
#nav a {
23+
font-weight: bold;
24+
color: #2c3e50;
25+
}
26+
27+
#nav a.router-link-exact-active {
28+
color: #42b983;
29+
}
30+
</style>
6.69 KB
Loading
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
<template>
2+
<h1>{{ msg }}</h1>
3+
4+
<p>
5+
Recommended IDE setup:
6+
<a href="https://code.visualstudio.com/" target="_blank">VSCode</a>
7+
+
8+
<a href="https://github.com/johnsoncodehk/volar" target="_blank">Volar</a>
9+
</p>
10+
11+
<p>See <code>README.md</code> for more information.</p>
12+
13+
<p>
14+
<a href="https://vitejs.dev/guide/features.html" target="_blank">
15+
Vite Docs
16+
</a>
17+
|
18+
<a href="https://v3.vuejs.org/" target="_blank">Vue 3 Docs</a>
19+
</p>
20+
21+
<button type="button" @click="count++">count is: {{ count }}</button>
22+
<p>
23+
Edit
24+
<code>components/HelloWorld.vue</code> to test hot module replacement.
25+
</p>
26+
</template>
27+
28+
<script setup>
29+
import { ref } from 'vue'
30+
31+
defineProps({
32+
msg: {
33+
type: String,
34+
required: true
35+
}
36+
})
37+
38+
const count = ref(0)
39+
</script>
40+
41+
<style scoped>
42+
a {
43+
color: #42b983;
44+
}
45+
46+
label {
47+
margin: 0 0.5em;
48+
font-weight: bold;
49+
}
50+
51+
code {
52+
background-color: #eee;
53+
padding: 2px 4px;
54+
border-radius: 4px;
55+
color: #304455;
56+
}
57+
</style>
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import { mount } from '@cypress/vue'
2+
import HelloWorld from '../HelloWorld.vue'
3+
4+
describe('HelloWorld', () => {
5+
it('playground', () => {
6+
mount(HelloWorld, { props: { msg: 'Hello Cypress' } })
7+
})
8+
9+
it('renders properly', () => {
10+
mount(HelloWorld, { props: { msg: 'Hello Cypress' } })
11+
cy.get('h1').should('contain', 'Hello Cypress')
12+
})
13+
14+
it('adds 1 when clicking the plus button', () => {
15+
mount(HelloWorld, { props: { msg: 'Hello Cypress' } })
16+
17+
cy.get('button')
18+
.should('contain', '0')
19+
.click()
20+
.should('contain', '1')
21+
})
22+
})

template/source/spa/src/main.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import { createApp } from 'vue'
2+
import App from './App.vue'
3+
4+
import router from './router'
5+
import store from './store'
6+
7+
const app = createApp(App)
8+
9+
app.use(router)
10+
app.use(store)
11+
12+
app.mount('#app')
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import { createRouter, createWebHistory } from 'vue-router'
2+
import Home from '../views/Home.vue'
3+
4+
const routes = [
5+
{
6+
path: '/',
7+
name: 'Home',
8+
component: Home
9+
},
10+
{
11+
path: '/about',
12+
name: 'About',
13+
// route level code-splitting
14+
// this generates a separate chunk (About.[hash].js) for this route
15+
// which is lazy-loaded when the route is visited.
16+
component: () => import('../views/About.vue')
17+
}
18+
]
19+
20+
const router = createRouter({
21+
history: createWebHistory(import.meta.env.BASE_URL),
22+
routes
23+
})
24+
25+
export default router

0 commit comments

Comments
 (0)