Skip to content

Commit

Permalink
feat: 允许不指定解释器
Browse files Browse the repository at this point in the history
  • Loading branch information
rehiy committed Dec 26, 2023
1 parent 7f47a32 commit 63edf14
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 16 deletions.
9 changes: 1 addition & 8 deletions src/apps/script/create.vue
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,6 @@ export default class ScriptCreate extends Vue {
Api.msg.err('请检查表单');
return false;
}
if (this.formModel.CommandType == 'SHELL' && this.formModel.Content.indexOf('#!/') !== 0) {
Api.msg.err('请在首行声明解释器,如 #!/bin/sh');
return false;
}
await NaApi.script.create(this.formModel);
this.close();
}
Expand All @@ -48,9 +44,6 @@ export default class ScriptCreate extends Vue {
case 'SHELL':
this.formModel.Username = 'root';
this.formModel.WorkDirectory = '/root';
if (this.formModel.Content.indexOf('#!/') !== 0) {
this.formModel.Content = '#!/bin/sh\n' + this.formModel.Content;
}
break;
case 'POWERSHELL':
case 'BAT':
Expand Down Expand Up @@ -105,7 +98,7 @@ export default class ScriptCreate extends Vue {
<t-input v-model="formModel.WorkDirectory" />
</t-form-item>
<t-form-item name="Content" label="脚本内容">
<t-textarea v-model="formModel.Content" :autosize="{ minRows: 4, maxRows: 15 }" :placeholder="formModel.CommandType == 'SHELL' ? '请在首行声明解释器,如 #!/bin/sh' : ''" />
<t-textarea v-model="formModel.Content" :autosize="{ minRows: 4, maxRows: 15 }" :placeholder="formModel.CommandType == 'SHELL' ? '#!/bin/sh' : ''" />
</t-form-item>
<t-form-item name="Description" label="脚本描述">
<t-textarea v-model="formModel.Description" :autosize="{ minRows: 2, maxRows: 8 }" />
Expand Down
9 changes: 1 addition & 8 deletions src/apps/script/update.vue
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,6 @@ export default class ScriptUpdate extends Vue {
Api.msg.err('请检查表单');
return false;
}
if (this.formModel.CommandType == 'SHELL' && this.formModel.Content.indexOf('#!/') !== 0) {
Api.msg.err('请在首行声明解释器,如 #!/bin/sh');
return false;
}
await NaApi.script.update(this.formModel);
this.close();
}
Expand All @@ -48,9 +44,6 @@ export default class ScriptUpdate extends Vue {
case 'SHELL':
this.formModel.Username = 'root';
this.formModel.WorkDirectory = '/root';
if (this.formModel.Content.indexOf('#!/') !== 0) {
this.formModel.Content = '#!/bin/sh\n' + this.formModel.Content;
}
break;
case 'POWERSHELL':
case 'BAT':
Expand Down Expand Up @@ -97,7 +90,7 @@ export default class ScriptUpdate extends Vue {
<t-input v-model="formModel.WorkDirectory" />
</t-form-item>
<t-form-item name="Content" label="脚本内容">
<t-textarea v-model="formModel.Content" :autosize="{ minRows: 4, maxRows: 15 }" :placeholder="formModel.CommandType == 'SHELL' ? '请在首行声明解释器,如 #!/bin/sh' : ''" />
<t-textarea v-model="formModel.Content" :autosize="{ minRows: 4, maxRows: 15 }" :placeholder="formModel.CommandType == 'SHELL' ? '#!/bin/sh' : ''" />
</t-form-item>
<t-form-item name="Description" label="脚本描述">
<t-textarea v-model="formModel.Description" :autosize="{ minRows: 2, maxRows: 8 }" />
Expand Down

0 comments on commit 63edf14

Please sign in to comment.