Added the 'cd' command, and improved the view a bit.

このコミットが含まれているのは:
テクニカル諏訪子 2018-03-09 19:53:19 +09:00
コミット 73b2bf987c
2個のファイルの変更78行の追加53行の削除

2
.gitignore vendored
ファイルの表示

@ -2,7 +2,7 @@
/public/hot /public/hot
/public/js /public/js
/public/css /public/css
/public/storage/* /public/storage
/public/assets /public/assets
/storage/*.key /storage/*.key
/vendor /vendor

ファイルの表示

@ -1,13 +1,14 @@
<template> <template>
<div> <div>
<span v-for="(l, i) in line" :key="`l-${i}`"> <span class="regText">
<span class="regText"> <span v-for="(l, i) in line" :key="`l-${i}`">
<span class="regBold"> <span class="regBold">
{{ l.username }}@{{ l.hostname }}:<span class="pathText">{{ l.path }}</span> {{ l.username }}@{{ l.hostname }}:<span class="pathText">{{ l.path }}</span>
</span>$ </span>$
<span v-if="l.active"> <span v-if="l.active">
<input <input
:key="i" :key="i"
autofocus
spellcheck="false" spellcheck="false"
type="text" type="text"
class="inputField" class="inputField"
@ -26,57 +27,60 @@
@keyup.enter="exec(l.command, i)" @keyup.enter="exec(l.command, i)"
/> />
</span> </span>
<span v-for="(res, d) in result" :key="`res-${d}`"> <br />
<br /> </span>
{{ res.text }} <span v-for="(res, d) in result" :key="`res-${d}`">
<span v-if="res.field"> <br />
<span v-if="res.password"> {{ res.text }}
<span v-if="res.active"> <span v-if="res.field">
<input <span v-if="res.password">
:key="i" <span v-if="res.active">
password="password" <input
spellcheck="false" :key="d"
type="text" password="password"
class="inputField" autofocus
v-model="res.command" spellcheck="false"
@keyup.enter="execContinue(res.command, i)" type="text"
/> class="inputField"
</span> v-model="res.command"
<span v-else> @keyup.enter="execContinue(res.command, d)"
<input />
:key="i"
password="password"
disabled
spellcheck="false"
type="text"
class="inputField"
v-model="res.command"
@keyup.enter="execContinue(res.command, i)"
/>
</span>
</span> </span>
<span v-else> <span v-else>
<span v-if="res.active"> <input
<input :key="d"
:key="i" password="password"
spellcheck="false" disabled
type="text" spellcheck="false"
class="inputField" type="text"
v-model="res.command" class="inputField"
@keyup.enter="execContinue(res.command, i)" v-model="res.command"
/> @keyup.enter="execContinue(res.command, d)"
</span> />
<span v-else> </span>
<input </span>
:key="i" <span v-else>
disabled <span v-if="res.active">
spellcheck="false" <input
type="text" :key="d"
class="inputField" spellcheck="false"
v-model="res.command" autofocus
@keyup.enter="execContinue(res.command, i)" type="text"
/> class="inputField"
</span> v-model="res.command"
@keyup.enter="execContinue(res.command, d)"
/>
</span>
<span v-else>
<input
:key="d"
disabled
spellcheck="false"
type="text"
class="inputField"
v-model="res.command"
@keyup.enter="execContinue(res.command, d)"
/>
</span> </span>
</span> </span>
<br /> <br />
@ -136,13 +140,18 @@ export default {
var arg = text.split(' '); var arg = text.split(' ');
if (arg[0] === 'ls') this.ls(this.line[key].path); if (arg[0] === 'ls') this.ls(this.line[key].path);
else if (arg[0] === 'cd') this.cd(arg[1]);
else if (arg[0] === 'clear') this.clear();
else this.result.push({ else this.result.push({
active: true, active: true,
text: arg[0] + ': コマンドは見つかれません。', text: arg[0] + ': コマンドは見つかれません。',
field: false, field: false,
password: false, password: false,
command: '' command: ''
}) });
console.log('Line', this.line);
console.log('Res', this.result);
this.line.push({ this.line.push({
active: true, active: true,
@ -164,6 +173,22 @@ export default {
command: '' command: ''
}) })
}) })
},
cd(pwd) {
if (pwd === '/fuck' || pwd === 'fuck') this.result.push({
active: true,
text: 'bash: cd: ' + pwd + ': このファイルまたはフォルダがありません。',
field: false,
password: false,
command: ''
});
if (!pwd.startsWith('/')) pwd = '/' + pwd;
this.pwd = pwd;
},
clear() {
this.line = [];
this.result = [];
} }
} }
} }