inbound_modal.html 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. {{define "inboundModal"}}
  2. <a-modal id="inbound-modal" v-model="inModal.visible" :title="inModal.title" @ok="inModal.ok"
  3. :confirm-loading="inModal.confirmLoading" :closable="true" :mask-closable="false"
  4. :ok-text="inModal.okText" cancel-text='{{ i18n "close" }}'>
  5. {{template "form/inbound"}}
  6. </a-modal>
  7. <script>
  8. const inModal = {
  9. title: '',
  10. visible: false,
  11. confirmLoading: false,
  12. okText: '确定',
  13. confirm: null,
  14. inbound: new Inbound(),
  15. dbInbound: new DBInbound(),
  16. ok() {
  17. ObjectUtil.execute(inModal.confirm, inModal.inbound, inModal.dbInbound);
  18. },
  19. show({ title='', okText='确定', inbound=null, dbInbound=null, confirm=(inbound, dbInbound)=>{} }) {
  20. this.title = title;
  21. this.okText = okText;
  22. if (inbound) {
  23. this.inbound = Inbound.fromJson(inbound.toJson());
  24. } else {
  25. this.inbound = new Inbound();
  26. }
  27. if (dbInbound) {
  28. this.dbInbound = new DBInbound(dbInbound);
  29. } else {
  30. this.dbInbound = new DBInbound();
  31. }
  32. this.confirm = confirm;
  33. this.visible = true;
  34. },
  35. close() {
  36. inModal.visible = false;
  37. inModal.loading(false);
  38. },
  39. loading(loading) {
  40. inModal.confirmLoading = loading;
  41. },
  42. };
  43. const protocols = {
  44. VMESS: Protocols.VMESS,
  45. VLESS: Protocols.VLESS,
  46. TROJAN: Protocols.TROJAN,
  47. SHADOWSOCKS: Protocols.SHADOWSOCKS,
  48. DOKODEMO: Protocols.DOKODEMO,
  49. SOCKS: Protocols.SOCKS,
  50. HTTP: Protocols.HTTP,
  51. };
  52. new Vue({
  53. delimiters: ['[[', ']]'],
  54. el: '#inbound-modal',
  55. data: {
  56. inModal: inModal,
  57. Protocols: protocols,
  58. SSMethods: SSMethods,
  59. get inbound() {
  60. return inModal.inbound;
  61. },
  62. get dbInbound() {
  63. return inModal.dbInbound;
  64. }
  65. },
  66. methods: {
  67. streamNetworkChange(oldValue) {
  68. if (oldValue === 'kcp') {
  69. this.inModal.inbound.tls = false;
  70. }
  71. }
  72. }
  73. });
  74. </script>
  75. {{end}}