Skip to content
This repository was archived by the owner on Mar 25, 2020. It is now read-only.

Commit b03b14d

Browse files
committedMar 19, 2017
テンプレートを編集
1 parent 58d81fe commit b03b14d

23 files changed

+69
-51
lines changed
 

‎package.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@
1818
"vue-class-component": "^5.0.0",
1919
"vue-property-decorator": "^4.0.0",
2020
"vue-router": "^2.3.0",
21-
"vuex": "^2.2.1"
21+
"vuex": "^2.2.1",
22+
"vuex-class": "^0.1.3"
2223
},
2324
"devDependencies": {
2425
"css-loader": "^0.27.3",
File renamed without changes.

‎src/Form/Form.ts

+8-7
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
import Vue from 'vue'
22
import Component from 'vue-class-component'
3-
import * as template from './Form.template.html'
3+
4+
import * as Template from './Form.html'
45
import Modal from '../modal/modal'
5-
import { mapActions } from 'vuex'
6+
import { Action } from 'vuex-class'
67

7-
@Component(template<Form>({
8+
@Template
9+
@Component<Form>({
810
components: {
911
Modal
1012
},
@@ -13,14 +15,13 @@ import { mapActions } from 'vuex'
1315
vm.title = ''
1416
vm.body = ''
1517
})
16-
},
17-
methods: mapActions(['storeMessage'])
18-
}))
18+
}
19+
})
1920
export default class Form extends Vue {
2021
title = ''
2122
body = ''
2223

23-
storeMessage: (message: any) => Promise<void>
24+
@Action readonly storeMessage: (message: any) => Promise<void>
2425

2526
save() {
2627
this.storeMessage({ title: this.title, body: this.body }).then(() => {
File renamed without changes.

‎src/Home/Home.ts

+7-6
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,22 @@
11
import Vue from 'vue'
22
import Component from 'vue-class-component'
3-
import * as template from './Home.template.html'
3+
import { Getter } from 'vuex-class'
4+
5+
import * as Template from './Home.html'
46
import Jumbotron from '../jumbotron/jumbotron'
5-
import { mapGetters } from 'vuex'
67
import { Message } from '../vuex/state'
78

8-
@Component(template<Home>({
9+
@Template
10+
@Component<Home>({
911
components: {
1012
Jumbotron
1113
},
12-
computed: mapGetters(['messages']),
1314
filters: {
1415
format(n: number) {
1516
return new Date(n).toLocaleString()
1617
}
1718
}
18-
}))
19+
})
1920
export default class Home extends Vue {
20-
messages: Message[]
21+
@Getter messages: Message[]
2122
}
File renamed without changes.

‎src/Links/Links.ts

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
import Vue from 'vue'
22
import Component from 'vue-class-component'
3-
import * as template from './Links.template.html'
3+
import * as Template from './Links.html'
44

5-
@Component(template({}))
5+
@Template
6+
@Component
67
export default class Links extends Vue {
78
links = [
89
{ title: 'vue.js', href: 'https://jp.vuejs.org' },
File renamed without changes.

‎src/Settings/Settings.ts

+8-7
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,19 @@
11
import Vue from 'vue'
22
import Component from 'vue-class-component'
3-
import * as template from './Settings.template.html'
4-
import { mapActions } from 'vuex'
3+
import { Action } from 'vuex-class'
4+
5+
import * as Template from './Settings.html'
56
import Alert from '../alert/alert'
67

7-
@Component(template({
8-
components: { Alert },
9-
methods: mapActions(['resetMessages'])
10-
}))
8+
@Template
9+
@Component({
10+
components: { Alert }
11+
})
1112
export default class Settings extends Vue {
1213
message = '削除しました'
1314
alert = false
1415

15-
resetMessages: () => Promise<void>
16+
@Action readonly resetMessages: () => Promise<void>
1617

1718
reset() {
1819
this.resetMessages().then(() => {
File renamed without changes.

‎src/alert/alert.ts

+7-7
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
import Vue from 'vue'
2-
import { Component, prop } from 'vue-property-decorator'
3-
import * as template from './alert.template.html'
2+
import Component from 'vue-class-component'
3+
import { Prop } from 'vue-property-decorator'
4+
import * as Template from './alert.html'
45

5-
@Component(template({}))
6+
@Template
7+
@Component
68
export default class Alert extends Vue {
7-
@prop({ type: null })
8-
type: string
9+
@Prop readonly type: string
910

10-
@prop({ type: null })
11-
message: string
11+
@Prop readonly message: string
1212

1313
get alertType() {
1414
return `alert-${this.type}`
File renamed without changes.

‎src/index.ts

+6-4
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
11
import Vue from 'vue'
22
import Component from 'vue-class-component'
3-
import * as template from './index.template.html'
4-
import router from './router'
53
import { mapActions } from 'vuex'
4+
5+
import * as Template from './index.html'
6+
import router from './router'
67
import store from './vuex/store'
78
import Navbar from './navbar/navbar'
89
import './style.scss'
910

10-
@Component(template<App>({
11+
@Template
12+
@Component<App>({
1113
components: {
1214
Navbar
1315
},
@@ -17,7 +19,7 @@ import './style.scss'
1719
mounted() {
1820
this.setMessages()
1921
}
20-
}))
22+
})
2123
class App extends Vue {
2224
setMessages: () => Promise<void>
2325
}
File renamed without changes.

‎src/jumbotron/jumbotron.ts

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import Vue from 'vue'
22
import Component from 'vue-class-component'
3-
import * as template from './jumbotron.template.html'
3+
4+
import * as Template from './jumbotron.html'
45
import { zero } from '../util'
56

67
function format(y: number, m: number, d: number) {
@@ -12,7 +13,8 @@ const year = today.getFullYear()
1213
const month = today.getMonth() + 1
1314
const date = today.getDate()
1415

15-
@Component(template<Jumbotron>({}))
16+
@Template
17+
@Component
1618
export default class Jumbotron extends Vue {
1719
today = format(year, month, date)
1820

File renamed without changes.

‎src/modal/modal.ts

+7-5
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
import Vue from 'vue'
2-
import { Component, prop } from 'vue-property-decorator'
3-
import * as template from './modal.template.html'
2+
import Component from 'vue-class-component'
3+
import { Prop } from 'vue-property-decorator'
44

5-
@Component(template({}))
5+
import * as Template from './modal.html'
6+
7+
@Template
8+
@Component
69
export default class Modal extends Vue {
7-
@prop({type: null})
8-
title: string
10+
@Prop readonly title: string
911

1012
close() {
1113
this.$emit('close')
File renamed without changes.

‎src/navbar/navbar.ts

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
import Vue from 'vue'
22
import Component from 'vue-class-component'
3-
import * as template from './navbar.template.html'
3+
import * as Template from './navbar.html'
44

5-
@Component(template({}))
5+
@Template
6+
@Component
67
export default class Navbar extends Vue {
78
links = [
89
{ title: 'ホーム', name: 'home' },

‎src/template.d.ts

+7-6
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
declare module '*.html' {
2-
import Vue from 'vue'
3-
import { ComponentOptions } from 'vue'
4-
5-
var template: <V extends Vue>(options: ComponentOptions<V>) => ComponentOptions<V>
6-
7-
export = template
2+
import Vue = require('vue')
3+
interface WithRender {
4+
<V extends Vue>(options: Vue.ComponentOptions<V>): Vue.ComponentOptions<V>
5+
<V extends typeof Vue>(component: V): V
6+
}
7+
const withRender: WithRender
8+
export = withRender
89
}

‎tsconfig.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
"noEmitHelpers": true,
1717
"experimentalDecorators": true,
1818
"importHelpers": true,
19-
"allowSyntheticDefaultImports": true
19+
"allowSyntheticDefaultImports": true,
20+
"emitDecoratorMetadata": true
2021
}
2122
}

‎webpack.config.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ module.exports = {
1111
loaders: [
1212
{ test: /\.tsx?$/, loader: 'ts-loader' },
1313
{ test: /\.scss$/, loader: ExtractTextPlugin.extract(['css-loader', 'sass-loader']) },
14-
{ test: /\.template\.html$/, loader: 'vue-template-loader' }
14+
{ test: /\.html$/, loader: 'vue-template-loader', include: /src/ }
1515
]
1616
},
1717
resolve: {

‎yarn.lock

+4
Original file line numberDiff line numberDiff line change
@@ -2851,6 +2851,10 @@ vue@^2.2.4:
28512851
version "2.2.4"
28522852
resolved "https://registry.yarnpkg.com/vue/-/vue-2.2.4.tgz#d0a3a050a80a12356d7950ae5a7b3131048209cc"
28532853

2854+
vuex-class@^0.1.3:
2855+
version "0.1.3"
2856+
resolved "https://registry.yarnpkg.com/vuex-class/-/vuex-class-0.1.3.tgz#b7550a697f592a0d033c9301621de2ebb035c760"
2857+
28542858
vuex@^2.2.1:
28552859
version "2.2.1"
28562860
resolved "https://registry.yarnpkg.com/vuex/-/vuex-2.2.1.tgz#a42d0ce18cb0e0359258f84bfd76835ed468c185"

0 commit comments

Comments
 (0)