<template>
  <div class="command-view">
    <h2>发送指令</h2>
    <form
      class="command-form"
      @submit.prevent="sendCommand"
    >
      <div class="form-group">
        <label for="command">指令内容</label>
        <textarea
          id="command"
          v-model="command"
          rows="5"
          placeholder="请输入要发送的指令..."
          required
        />
      </div>
      <div class="form-actions">
        <button
          type="submit"
          class="btn btn-primary"
        >
          发送指令
        </button>
        <button
          type="button"
          class="btn btn-secondary"
          @click="clearCommand"
        >
          清空
        </button>
      </div>
    </form>
    <div
      v-if="response"
      class="response-section"
    >
      <h3>发送结果</h3>
      <div
        class="response-content"
        :class="{ 'success': response.success, 'error': !response.success }"
      >
        {{ response.message }}
      </div>
    </div>
  </div>
</template>

<script setup>
import { ref } from 'vue';

const command = ref('');
const response = ref(null);

const sendCommand = () => {
  // 这里将实现发送指令的逻辑
  response.value = {
    success: true,
    message: `指令已发送: ${command.value}`,
  };
  command.value = '';
};

const clearCommand = () => {
  command.value = '';
  response.value = null;
};
</script>

<style scoped>
.command-view {
  max-width: 800px;
  margin: 0 auto;
}

h2 {
  margin-bottom: 1rem;
  color: #333;
}

.command-form {
  background-color: white;
  border-radius: 8px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
  padding: 1.5rem;
  margin-bottom: 1.5rem;
}

.form-group {
  margin-bottom: 1.5rem;
}

label {
  display: block;
  margin-bottom: 0.5rem;
  font-weight: bold;
  color: #333;
}

textarea {
  width: 100%;
  padding: 0.75rem;
  border: 1px solid #ddd;
  border-radius: 4px;
  font-size: 1rem;
  resize: vertical;
  font-family: inherit;
}

textarea:focus {
  outline: none;
  border-color: #4285f4;
  box-shadow: 0 0 0 2px rgba(66, 133, 244, 0.2);
}

.form-actions {
  display: flex;
  gap: 1rem;
}

.btn {
  padding: 0.75rem 1.5rem;
  border: none;
  border-radius: 4px;
  font-size: 1rem;
  cursor: pointer;
  transition: background-color 0.2s;
}

.btn-primary {
  background-color: #4285f4;
  color: white;
}

.btn-primary:hover {
  background-color: #3367d6;
}

.btn-secondary {
  background-color: #f5f5f5;
  color: #333;
}

.btn-secondary:hover {
  background-color: #e0e0e0;
}

.response-section {
  background-color: white;
  border-radius: 8px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
  padding: 1.5rem;
}

h3 {
  margin-bottom: 1rem;
  color: #333;
}

.response-content {
  padding: 1rem;
  border-radius: 4px;
}

.response-content.success {
  background-color: #e8f5e8;
  color: #2e7d32;
}

.response-content.error {
  background-color: #ffebee;
  color: #c62828;
}
</style>