index.jsx 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. import { ElInput, ElInputNumber, ElSelect, ElOption } from 'element-plus'
  2. import { useDisabled, useProxy } from './use-proxy'
  3. import './index.less'
  4. export default {
  5. props: {
  6. protocol: { type: String, default: 'http:' },
  7. host: String,
  8. port: Number,
  9. path: String,
  10. size: { type: String, default: 'small' },
  11. portMin: { type: Number, default: 0 },
  12. portMax: { type: Number, default: 65535 },
  13. disabled: { type: Boolean, default: undefined },
  14. disabledConfig: { type: Object, default: () => ({}) } // { protocol, host, port, path}
  15. },
  16. setup (props, { emit }) {
  17. const [proxyProtocol, proxyHost, proxyPort, proxyPath] = useProxy(props, ['protocol', 'host', 'port', 'path'], emit)
  18. const [protocolDisabled, hostDisabled, portDisabled, pathDisabled] = useDisabled(props, ['protocol', 'host', 'port', 'path'])
  19. return () =>
  20. <div class={'cip-url-editor'}>
  21. <ElSelect
  22. class={'cip-url-editor__protocol'}
  23. size={props.size}
  24. v-model={proxyProtocol.value}
  25. disabled={protocolDisabled.value}
  26. >
  27. <ElOption value={'http:'} label={'http://'}></ElOption>
  28. <ElOption value={'https:'} label={'https://'}></ElOption>
  29. </ElSelect>
  30. <ElInput
  31. class={'cip-url-editor__host'}
  32. size={props.size}
  33. v-model={proxyHost.value}
  34. disabled={hostDisabled.value}
  35. placeholder={'请输入主机地址'}
  36. />
  37. <ElInputNumber
  38. class={'cip-url-editor__port'}
  39. controls={false}
  40. step={1}
  41. precision={0}
  42. size={props.size}
  43. v-model={proxyPort.value}
  44. min={props.portMin}
  45. max={props.portMax}
  46. disabled={portDisabled.value}
  47. placeholder={'请输入主机端口号'}
  48. />
  49. <ElInput
  50. class={'cip-url-editor__path'}
  51. size={props.size}
  52. v-model={proxyPath.value}
  53. disabled={pathDisabled.value}
  54. placeholder={'请输入路径'}
  55. />
  56. </div>
  57. }
  58. }