Skip to content

Commit

Permalink
初始化学习功能
Browse files Browse the repository at this point in the history
  • Loading branch information
gutrse3321 committed Jun 15, 2018
1 parent 6993ccb commit 4045076
Showing 1 changed file with 51 additions and 19 deletions.
70 changes: 51 additions & 19 deletions src/renderer/views/Home/chatroom.vue
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@ const YOU = 'You'
export default {
data () {
return {
talk_list: []
talk_list: [],
cmd_flag: 0
}
},
methods: {
Expand All @@ -64,32 +65,63 @@ export default {
content: _content
}
this.talk_list.push(_youTalk)
switch (this.cmd_flag) {
case 0: this._marisaThinking(_content)
break
case 1: this._teachMarisa(_content)
break
}
this.$refs.you.value = ''
// this._marisaRelpy()
}
},
_marisaThinking (_content) {
switch (_content) {
case 'teach': this._teachMode()
case 'teach':
this.talk_list.push({
name: MARISA,
content: '好哒,你要教我什么呢?格式:You的消息`白絲魔理沙的回复'
})
this.cmd_flag = 1
break
default: this._marisaRelpy()
default: this._marisaReply(_content)
}
},
_teachMode () {
let _marisaTalk = {
name: MARISA,
content: '好哒,你要教我什么呀?'
_marisaReply (_content) {
let memorise = this.$db.get('memorise').value()
let answer = ''
for (let i = 0; i < memorise.length; i++) {
memorise[i].keyword.forEach(item => {
if (item === _content) {
answer = memorise[i].answer
}
})
}
if (answer !== '') {
this.talk_list.push({
name: MARISA,
content: answer
})
} else {
this.talk_list.push({
name: MARISA,
content: '唔嗯...不懂你在说什么呢...'
})
}
setTimeout(() => {
this.talk_list.push(_marisaTalk)
}, 300)
},
_marisaRelpy () {
let _marisaTalk = {
name: MARISA,
content: '人类的本质就是复读机。'
_teachMarisa (_content) {
let str = _content.split('`')
let memorey = {
keyword: [
str[0]
],
answer: str[1]
}
setTimeout(() => {
this.talk_list.push(_marisaTalk)
}, 300)
this.$db.get('memorise').push(memorey).write()
this.talk_list.push({
name: MARISA,
content: `ok,当你说"${str[0]}"的时候,嗯...好!老子就说"${str[1]}"DA☆ZE`
})
this.cmd_flag = 0
},
_scrollBottom () {
this.$nextTick(() => {
Expand All @@ -104,7 +136,7 @@ export default {
created () {
let _startTalk = {
name: MARISA,
content: '白絲魔理沙 Type 0.001,还在继续升级da★ze'
content: '白絲魔理沙 Type 0.001,还在继续升级DA☆ZE'
}
this.talk_list.push(_startTalk)
}
Expand Down

0 comments on commit 4045076

Please sign in to comment.