Skip to content

Commit 5614472

Browse files
committed
Added module without TypeScript | Updated packages | Updated Readme
1 parent c262bb9 commit 5614472

File tree

25 files changed

+531
-188
lines changed

25 files changed

+531
-188
lines changed

README.md

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
# ASP.NET Core Vue.js with TypeScript template
1+
# ASP.NET Core 2.1 multi-page Vue.js with TypeScript template
22

3-
The repository contains template using Vue.js, Vuex, TypeScript and Bulma. It integrates Vue into AspNetCore MVC and showcases how to use Vue with .NET as a multipage (multiple mini SPA's) application. The template can also be used as a complete single page application but you should consider using [Vue cli](https://cli.vuejs.org/) for this as it is a more flexible and advanced solution.
3+
The repository contains template using Vue.js, Vuex, Vue router, TypeScript, Bulma, SASS and Jest. It integrates Vue into AspNetCore MVC and showcases how to use Vue with it's entire ecosystem in .NET as a multipage (multiple mini SPA's) application. The template can also be used as a complete single page application but you should consider using [Vue cli](https://cli.vuejs.org/) for this as it is a more flexible and advanced solution.
44

55
---
66

@@ -15,7 +15,11 @@ The repository contains template using Vue.js, Vuex, TypeScript and Bulma. It in
1515

1616
## Nuget
1717

18-
- [Nuget package](https://www.nuget.org/packages/AspNetCore.Vue.TypeScript.Template)
18+
- [AspNetCore.Vue.TypeScript.Template](https://www.nuget.org/packages/AspNetCore.Vue.TypeScript.Template)
19+
20+
| Version | Downloads |
21+
| :---: | :---: |
22+
| [![NuGet](https://img.shields.io/nuget/v/AspNetCore.Vue.TypeScript.Template.svg)](https://nuget.org/packages/AspNetCore.Vue.TypeScript.Template) | [![Nuget](https://img.shields.io/nuget/dt/AspNetCore.Vue.TypeScript.Template.svg)](https://nuget.org/packages/AspNetCore.Vue.TypeScript.Template) |
1923

2024
## Table of Contents
2125

@@ -35,6 +39,7 @@ The repository contains template using Vue.js, Vuex, TypeScript and Bulma. It in
3539
- **TypeScript**
3640
- **Bulma**
3741
- **Sass**
42+
- **Jest**
3843
- **Webpack 4**
3944

4045
## Prerequisites
@@ -46,9 +51,9 @@ The repository contains template using Vue.js, Vuex, TypeScript and Bulma. It in
4651

4752
In order to create a new project from this template, you must first install it.
4853

49-
- Install the template from nuget by running the following command:
54+
Install the template from NuGet by running the following command:
5055

51-
```console
56+
```
5257
dotnet new -i AspNetCore.Vue.TypeScript.Template
5358
```
5459

@@ -60,7 +65,7 @@ To create a new project run `dotnet new vuetypescript` command and provide the n
6065

6166
Example
6267

63-
```console
68+
```
6469
dotnet new vuetypescript --name TestProject.Web
6570
```
6671

aspnetcore-vue-typescript-template.nuspec

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22
<package xmlns="http://schemas.microsoft.com/packaging/2012/06/nuspec.xsd">
33
<metadata>
44
<id>AspNetCore.Vue.TypeScript.Template</id>
5-
<version>0.1.0</version>
5+
<version>0.2.0</version>
66
<description>
7-
Template integrating Vue.js with ASP.NET Core MVC application. Features Vue, Vuex, Vue router, Typescript, Bulma and Sass.
7+
Template integrating Vue.js with ASP.NET Core MVC application. Features Vue, Vuex, Vue router, TypeScript, Bulma, Sass, Jest and Webpack 4.
88
</description>
99
<tags>template;vue;vuejs;typescript;vuex;</tags>
1010
<authors>Danijel Hrček</authors>
@@ -14,7 +14,7 @@
1414
<packageType name="Template" />
1515
</packageTypes>
1616
<requireLicenseAcceptance>false</requireLicenseAcceptance>
17-
<releaseNotes>Initial release</releaseNotes>
17+
<releaseNotes>0.2.0 release.</releaseNotes>
1818
</metadata>
1919
<files>
2020
<file

content/AspNetCore.VueJs/AspNetCore.VueJs.csproj

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,4 +58,10 @@
5858
<Folder Include="VueApp\__tests__\" />
5959
</ItemGroup>
6060

61+
<ItemGroup>
62+
<Content Update="Views\IDontLikeTypeScript\Index.cshtml">
63+
<Pack>$(IncludeRazorContentInPack)</Pack>
64+
</Content>
65+
</ItemGroup>
66+
6167
</Project>
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
using Microsoft.AspNetCore.Mvc;
2+
3+
namespace AspNetCore.VueJs.Controllers
4+
{
5+
public class IDontNeedTypeScriptController : Controller
6+
{
7+
/// <summary>
8+
/// SPA entry point
9+
/// </summary>
10+
/// <returns></returns>
11+
public IActionResult Index()
12+
{
13+
return View();
14+
}
15+
}
16+
}

content/AspNetCore.VueJs/Startup.cs

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
using Microsoft.AspNetCore.Builder;
22
using Microsoft.AspNetCore.Hosting;
3+
using Microsoft.AspNetCore.Routing;
34
using Microsoft.Extensions.Configuration;
45
using Microsoft.Extensions.DependencyInjection;
56

@@ -17,7 +18,8 @@ public Startup(IConfiguration configuration)
1718
public void ConfigureServices(IServiceCollection services)
1819
{
1920
services.AddHttpClient();
20-
21+
22+
services.Configure<RouteOptions>(options => options.LowercaseUrls = true);
2123
services.AddMvc();
2224
}
2325

@@ -33,11 +35,12 @@ public void Configure(IApplicationBuilder app, IHostingEnvironment env)
3335
app.UseMvc(routes =>
3436
{
3537
routes.MapRoute(
36-
name: "default",
37-
template: "{controller=Template}/{action=Index}/{id?}");
38-
38+
name: "spa-route",
39+
template: "{controller}/{*anything=Index}",
40+
defaults: new { action = "Index" });
41+
3942
routes.MapRoute(
40-
name: "spa-fallback",
43+
name: "app-fallback",
4144
template: "{*anything}/",
4245
defaults: new { controller = "Template", action = "Index" });
4346
});
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
2+
@{
3+
ViewData["Title"] = "Index";
4+
}
5+
6+
@section scripts{
7+
8+
<environment names="Development,Production,Staging">
9+
<script src="~/dist/js/idontneedtypescript/bundle.js" asp-append-version="true"></script>
10+
</environment>
11+
12+
}
13+
14+
<div id="app">
15+
16+
</div>

content/AspNetCore.VueJs/Views/IceAndFire/Index.cshtml

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,9 @@
11
@{
2-
ViewData["Title"] = "Home Page";
2+
ViewData["Title"] = "Ice and fire";
33
}
44

55
@section styles{
66

7-
<environment names="Development,Production,Staging">
8-
@*<link rel="stylesheet" href="~/dist/css//main.css" asp-append-version="true" />*@
9-
</environment>
10-
117
}
128

139
@section scripts{

content/AspNetCore.VueJs/Views/Shared/_Navigation.cshtml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717
<div class="navbar-start">
1818
<a asp-controller="Template"
1919
asp-action="Index" class="navbar-item">Template</a>
20+
<a asp-controller="IDontNeedTypeScript"
21+
asp-action="Index" class="navbar-item">No TypeScript</a>
2022
<a asp-controller="IceAndFire"
2123
asp-action="Index" class="navbar-item">Api of Ice and fire</a>
2224
</div>

content/AspNetCore.VueJs/Views/Template/Index.cshtml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
@{
2-
ViewData["Title"] = "Home Page";
2+
ViewData["Title"] = "Template";
33
}
44

55
@section styles{

content/AspNetCore.VueJs/VueApp/iceandfire/router/router.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,16 @@ import VueRouter from 'vue-router'
33
// Pages
44
import Characters from '@/iceandfire/views/Characters.vue'
55

6+
const routePrefix = 'iceandfire'
7+
68
const routes = [
79
{
810
path: '*',
911
component: Characters
1012
},
1113
{
1214
name: 'characters',
13-
path: '/',
15+
path: `/${routePrefix}`,
1416
component: Characters
1517
}
1618
]
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
<template>
2+
<div>
3+
4+
<div class="container">
5+
<div class="columns">
6+
<div class="column is-3">
7+
<section class="section">
8+
<aside class="menu">
9+
<p class="menu-label">
10+
Examples
11+
</p>
12+
<ul class="menu-list">
13+
<li>
14+
<router-link :to="{ name: 'counter' }">Counter</router-link>
15+
</li>
16+
</ul>
17+
<p class="menu-label">
18+
About
19+
</p>
20+
<ul class="menu-list">
21+
<li>
22+
<router-link :to="{ name: 'moduleinfo' }">Module info</router-link>
23+
</li>
24+
</ul>
25+
</aside>
26+
</section>
27+
</div>
28+
<div class="column is-9">
29+
30+
<section class="section">
31+
<transition name="component-fade"
32+
mode="out-in">
33+
<router-view></router-view>
34+
</transition>
35+
</section>
36+
37+
</div>
38+
</div>
39+
</div>
40+
<notifications group="global" />
41+
42+
</div>
43+
44+
</template>
45+
46+
<script>
47+
import Vue from 'vue'
48+
import Notifications from 'vue-notification'
49+
50+
Vue.use(Notifications)
51+
52+
export default {
53+
name: 'App'
54+
}
55+
</script>
56+
57+
<style scoped>
58+
</style>
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import Vue from 'vue'
2+
import VueRouter from 'vue-router'
3+
4+
Vue.config.performance = true
5+
6+
Vue.use(VueRouter)
7+
8+
import store from './store/store'
9+
import { router } from './router/router'
10+
11+
import App from './App.vue'
12+
13+
new Vue({
14+
store,
15+
router,
16+
render: h => h(App)
17+
}).$mount('#app')
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import VueRouter from 'vue-router'
2+
3+
// Pages
4+
import Counter from '@/idontneedtypescript/views/Counter'
5+
import ModuleInfo from '@/idontneedtypescript/views/ModuleInfo'
6+
7+
const routePrefix = 'idontneedtypescript'
8+
9+
const routes = [
10+
{
11+
path: '*',
12+
redirect: { name: 'moduleinfo' }
13+
},
14+
{
15+
name: 'moduleinfo',
16+
path: `/${routePrefix}/info`,
17+
component: ModuleInfo
18+
},
19+
{
20+
name: 'counter',
21+
path: `/${routePrefix}/counter`,
22+
component: Counter
23+
}
24+
]
25+
26+
export const router = new VueRouter({
27+
mode: 'history',
28+
routes,
29+
linkActiveClass: 'is-active'
30+
})
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
const state = {
2+
count: 0
3+
}
4+
5+
const getters = {
6+
count(state) {
7+
return state.count
8+
}
9+
}
10+
11+
const mutations = {
12+
SET_COUNT(state, value) {
13+
state.count = value
14+
}
15+
}
16+
17+
const actions = {
18+
increaseCount({ commit, getters }) {
19+
commit('SET_COUNT', getters.count + 1)
20+
},
21+
22+
resetCount({ commit }) {
23+
commit('SET_COUNT', 0)
24+
}
25+
}
26+
27+
export default {
28+
namespaced: true,
29+
state,
30+
mutations,
31+
actions,
32+
getters
33+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import Vue from 'vue'
2+
import Vuex from 'vuex'
3+
4+
import counterModule from './modules/counter-module'
5+
6+
Vue.use(Vuex)
7+
8+
export default new Vuex.Store({
9+
state: {
10+
version: '1.0.0'
11+
},
12+
modules: {
13+
counterModule: counterModule
14+
}
15+
})

0 commit comments

Comments
 (0)