通用评论 vedio

index.example.js 6.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176
  1. "use strict";
  2. var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
  3. var _react = require("react");
  4. var _react2 = _interopRequireDefault(_react);
  5. var _reactDom = require("react-dom");
  6. var _reactDom2 = _interopRequireDefault(_reactDom);
  7. var _App = require("./App");
  8. var _App2 = _interopRequireDefault(_App);
  9. var _registerServiceWorker = require("./registerServiceWorker");
  10. var _registerServiceWorker2 = _interopRequireDefault(_registerServiceWorker);
  11. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  12. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  13. function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
  14. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
  15. // e.g.
  16. // import { Button, Icon } from "antd";
  17. // import App, { Editor, RenderText } from "./App";
  18. var Index = function (_Component) {
  19. _inherits(Index, _Component);
  20. function Index(props) {
  21. _classCallCheck(this, Index);
  22. var _this = _possibleConstructorReturn(this, (Index.__proto__ || Object.getPrototypeOf(Index)).call(this, props));
  23. _this.state = {
  24. page: 1,
  25. value: ""
  26. };
  27. _this.onPageChange = _this.onPageChange.bind(_this);
  28. _this.handleChangeValue = _this.handleChangeValue.bind(_this);
  29. _this.handleChangeSubmit = _this.handleChangeSubmit.bind(_this);
  30. return _this;
  31. }
  32. _createClass(Index, [{
  33. key: "onPageChange",
  34. value: function onPageChange(page) {
  35. this.setState({
  36. page: page
  37. });
  38. }
  39. }, {
  40. key: "handleChangeValue",
  41. value: function handleChangeValue(value) {
  42. this.setState({ value: value });
  43. console.log("handleChangeValue value: ", value);
  44. }
  45. }, {
  46. key: "handleChangeSubmit",
  47. value: function handleChangeSubmit(_ref) {
  48. var _this2 = this;
  49. var text = _ref.text,
  50. files = _ref.files;
  51. this.setState({ loading: true }, function () {
  52. setTimeout(function () {
  53. _this2.setState({ loading: false });
  54. }, 2000);
  55. });
  56. console.log("submit text: ", text);
  57. console.log("submit files: ", files);
  58. }
  59. }, {
  60. key: "render",
  61. value: function render() {
  62. // 最简单的用法
  63. return _react2.default.createElement(
  64. _App2.default,
  65. {
  66. type: 1,
  67. businessId: "test",
  68. showAlertComment: true,
  69. showAlertReply: true,
  70. showAlertFavor: true,
  71. showError: false,
  72. userId: 71299,
  73. page: this.state.page,
  74. onPageChange: this.onPageChange,
  75. pageType: "more",
  76. onError: function onError(msg, _ref2) {
  77. var response = _ref2.response;
  78. if (response.status === 401) {
  79. console.log("unlogined");
  80. }
  81. console.log("-----------" + msg);
  82. }
  83. },
  84. _react2.default.createElement(_App.Editor, {
  85. maxUpload: 9,
  86. autoFocus: true,
  87. beforeSubmit: function beforeSubmit() {
  88. return new Promise(function (resolve) {
  89. resolve(true);
  90. });
  91. },
  92. onCommentSuccess: function onCommentSuccess() {
  93. console.log("succ");
  94. },
  95. showError: false,
  96. onError: function onError(msg, _ref3) {
  97. var response = _ref3.response;
  98. if (response.status === 401) {
  99. console.log("unlogined");
  100. }
  101. console.log("-----------" + msg);
  102. }
  103. })
  104. );
  105. // e.g.
  106. // 复杂的用户法
  107. // const props = {
  108. // type: 1,
  109. // businessId: "1",
  110. // API: "http://api.links123.net/comment/v1",
  111. // showList: true
  112. // };
  113. // const editorProps = {
  114. // showEmoji: true,
  115. // placeholder: "说点什么吧",
  116. // rows: 5,
  117. // btnLoading: this.state.loading,
  118. // btnDisable: this.state.loading,
  119. // btnSubmitText: "提交",
  120. // value: this.state.value,
  121. // onChange: v => this.handleChangeValue(v),
  122. // onSubmit: v => this.handleChangeSubmit(v),
  123. // button: (
  124. // <Button
  125. // type="primary"
  126. // ghost
  127. // // onClick={() => console.log('click btn: ', this.state.value)}
  128. // >
  129. // 自定义按钮
  130. // </Button>
  131. // ),
  132. // emojiToolIcon: <Icon type="smile" style={{ fontSize: 23 }} />,
  133. // imageToolIcon: (
  134. // <Icon type="cloud-upload-o" style={{ fontSize: 25, marginLeft: 10 }} />
  135. // )
  136. // };
  137. // return (
  138. // <App {...props}>
  139. // <Editor {...editorProps} />
  140. // </App>
  141. // );
  142. }
  143. }]);
  144. return Index;
  145. }(_react.Component);
  146. _reactDom2.default.render(_react2.default.createElement(Index, null), document.getElementById("root-comment"));
  147. (0, _registerServiceWorker2.default)();
  148. //# sourceMappingURL=index.example.js.map