index.vue 868 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. <template>
  2. <div>
  3. <span class="mr-1">{{ username }}</span>
  4. <copy :message="username" />
  5. </div>
  6. </template>
  7. <script>
  8. import _ from 'lodash'
  9. const DEFAULT_ACCOUNT = 'root'
  10. export default {
  11. name: 'ServerAccount',
  12. props: {
  13. instance_capabilities: {
  14. type: Array,
  15. },
  16. hypervisor: {
  17. type: String,
  18. },
  19. osType: {
  20. type: String,
  21. default: 'linux',
  22. },
  23. },
  24. computed: {
  25. username () {
  26. if (this.hypervisor && this.instance_capabilities && this.instance_capabilities.length) {
  27. const item = this.instance_capabilities.find(val => {
  28. return val.hypervisor === this.hypervisor && val.default_account[this.osType]
  29. })
  30. if (item) {
  31. return _.get(item.default_account, `[${this.osType}].default_account`)
  32. }
  33. }
  34. return DEFAULT_ACCOUNT
  35. },
  36. },
  37. }
  38. </script>