index.jsx 1.8 KB

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