You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
NewEduCoderBuild/p__MoopCases__index.async.js

247 lines
10 KiB

"use strict";
(self["webpackChunk"] = self["webpackChunk"] || []).push([[3212],{
/***/ 21333:
/*!***************************************!*\
!*** ./src/pages/MoopCases/label.css ***!
\***************************************/
/***/ (function() {
// extracted by mini-css-extract-plugin
/***/ }),
/***/ 19638:
/*!***************************************************!*\
!*** ./src/pages/MoopCases/index.tsx + 1 modules ***!
\***************************************************/
/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
// ESM COMPAT FLAG
__webpack_require__.r(__webpack_exports__);
// EXPORTS
__webpack_require__.d(__webpack_exports__, {
Types: function() { return /* binding */ Types; },
"default": function() { return /* binding */ pages_MoopCases; }
});
// EXTERNAL MODULE: ./node_modules/_react@17.0.2@react/index.js
var _react_17_0_2_react = __webpack_require__(59301);
// EXTERNAL MODULE: ./src/utils/fetch.ts
var fetch = __webpack_require__(87101);
;// CONCATENATED MODULE: ./src/pages/MoopCases/index.less
// extracted by mini-css-extract-plugin
// EXTERNAL MODULE: ./src/pages/MoopCases/label.css
var label = __webpack_require__(21333);
// EXTERNAL MODULE: ./node_modules/_antd@5.9.0@antd/es/input/index.js + 5 modules
var input = __webpack_require__(1056);
// EXTERNAL MODULE: ./node_modules/_antd@5.9.0@antd/es/spin/index.js + 1 modules
var spin = __webpack_require__(71418);
// EXTERNAL MODULE: ./node_modules/_antd@5.9.0@antd/es/pagination/index.js + 10 modules
var pagination = __webpack_require__(41867);
// EXTERNAL MODULE: ./src/.umi-production/exports.ts + 14 modules
var _umi_production_exports = __webpack_require__(87210);
// EXTERNAL MODULE: ./src/utils/env.ts + 1 modules
var env = __webpack_require__(64741);
// EXTERNAL MODULE: ./src/utils/authority.ts
var authority = __webpack_require__(55830);
;// CONCATENATED MODULE: ./src/pages/MoopCases/index.tsx
var __defProp = Object.defineProperty;
var __defProps = Object.defineProperties;
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __propIsEnum = Object.prototype.propertyIsEnumerable;
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
var __spreadValues = (a, b) => {
for (var prop in b || (b = {}))
if (__hasOwnProp.call(b, prop))
__defNormalProp(a, prop, b[prop]);
if (__getOwnPropSymbols)
for (var prop of __getOwnPropSymbols(b)) {
if (__propIsEnum.call(b, prop))
__defNormalProp(a, prop, b[prop]);
}
return a;
};
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
var __async = (__this, __arguments, generator) => {
return new Promise((resolve, reject) => {
var fulfilled = (value) => {
try {
step(generator.next(value));
} catch (e) {
reject(e);
}
};
var rejected = (value) => {
try {
step(generator.throw(value));
} catch (e) {
reject(e);
}
};
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
step((generator = generator.apply(__this, __arguments)).next());
});
};
const Search = input["default"].Search;
const initialState = {
loading: false,
type: "all",
page: 1,
count: 0,
list: [],
keyword: ""
};
var Types = /* @__PURE__ */ ((Types2) => {
Types2[Types2["GET_LIST"] = 0] = "GET_LIST";
Types2[Types2["CHANGE_KEYWORD"] = 1] = "CHANGE_KEYWORD";
Types2[Types2["CHANGE_PAGE"] = 2] = "CHANGE_PAGE";
Types2[Types2["CHANGE_TYPE"] = 3] = "CHANGE_TYPE";
Types2[Types2["SET_LOADING"] = 4] = "SET_LOADING";
return Types2;
})(Types || {});
function reducer(state, action) {
switch (action.type) {
case 0 /* GET_LIST */:
return __spreadValues(__spreadValues({}, state), action.payload);
case 2 /* CHANGE_PAGE */:
return __spreadProps(__spreadValues({}, state), { page: action.payload });
case 1 /* CHANGE_KEYWORD */:
return __spreadValues(__spreadValues({}, state), action.payload);
case 3 /* CHANGE_TYPE */:
return __spreadValues(__spreadValues({}, state), action.payload);
case 4 /* SET_LOADING */:
return __spreadProps(__spreadValues({}, state), { loading: action.payload });
default:
throw new Error();
}
}
const MoopCases = ({
user,
globalSetting,
dispatch
}) => {
var _a;
const [state, setState] = (0,_react_17_0_2_react.useReducer)(reducer, initialState);
const { loading, page, list, keyword, type, count } = state;
(0,_react_17_0_2_react.useEffect)(() => {
dispatch({
type: "globalSetting/onlyShowBackTopToggle",
payload: false
});
return () => {
dispatch({
type: "globalSetting/onlyShowBackTopToggle",
payload: true
});
};
}, []);
(0,_react_17_0_2_react.useEffect)(() => {
let didCancel = false;
function init() {
return __async(this, null, function* () {
setState({
type: 4 /* SET_LOADING */,
payload: true
});
const response = yield (0,fetch/* get */.U2)(`libraries.json`, {
keyword,
page,
type
});
const { libraries, count: count2 } = response;
if (!didCancel) {
setState({
type: 0 /* GET_LIST */,
payload: {
count: count2,
list: libraries,
loading: false
}
});
}
});
}
if (!didCancel) {
init();
}
return () => {
didCancel = true;
};
}, [page, keyword, type]);
function onSetKeyword(value) {
setState({
type: 1 /* CHANGE_KEYWORD */,
payload: {
keyword: value,
page: 1
}
});
}
function onChangeType(e) {
setState({ type: 3 /* CHANGE_TYPE */, payload: { type: e.target.id, page: 1 } });
}
function onPageChange(value) {
document.body.scrollIntoView();
setState({
type: 2 /* CHANGE_PAGE */,
payload: value
});
}
return /* @__PURE__ */ _react_17_0_2_react.createElement("div", { className: "moop-case" }, /* @__PURE__ */ _react_17_0_2_react.createElement("section", { className: "banner" }, /* @__PURE__ */ _react_17_0_2_react.createElement("img", { src: env/* default */.Z.IMG_SERVER + "/" + ((_a = globalSetting == null ? void 0 : globalSetting.setting) == null ? void 0 : _a.moop_cases_banner_url), alt: "bg" })), /* @__PURE__ */ _react_17_0_2_react.createElement("section", { className: "moop-main" }, /* @__PURE__ */ _react_17_0_2_react.createElement("div", { className: "moop-title" }, /* @__PURE__ */ _react_17_0_2_react.createElement("span", null, "\u6559\u5B66\u6848\u4F8B"), /* @__PURE__ */ _react_17_0_2_react.createElement(_umi_production_exports.Link, { to: "/moop_cases/new", className: "btn-ghost" }, "\u53D1\u5E03\u6848\u4F8B")), /* @__PURE__ */ _react_17_0_2_react.createElement("div", { className: "search-input-container" }, /* @__PURE__ */ _react_17_0_2_react.createElement("div", { className: "flex-container" }, /* @__PURE__ */ _react_17_0_2_react.createElement("a", { id: "all", onClick: onChangeType, className: type === "all" ? "active" : "" }, "\u5168\u90E8"), (0,authority/* isLogin */.bg)() ? /* @__PURE__ */ _react_17_0_2_react.createElement("a", { id: "mine", onClick: onChangeType, className: type === "mine" ? "active" : "" }, "\u6211\u7684") : null), /* @__PURE__ */ _react_17_0_2_react.createElement(
Search,
{
className: "moop-search",
defaultValue: keyword,
placeholder: "\u8F93\u5165\u6559\u5B66\u6848\u4F8B\u6807\u9898\u3001\u4F5C\u8005\u3001\u5355\u4F4D\u8FDB\u884C\u68C0\u7D22",
onSearch: onSetKeyword
}
))), /* @__PURE__ */ _react_17_0_2_react.createElement(spin/* default */.Z, { spinning: loading, delay: 500 }, /* @__PURE__ */ _react_17_0_2_react.createElement(CaseList, { data: list })), /* @__PURE__ */ _react_17_0_2_react.createElement("div", { className: "search-footer" }, count > 20 ? /* @__PURE__ */ _react_17_0_2_react.createElement(
pagination/* default */.Z,
{
showQuickJumper: true,
current: page,
onChange: onPageChange,
pageSize: 20,
showSizeChanger: false,
total: count
}
) : null));
};
function CaseList({ data }) {
return /* @__PURE__ */ _react_17_0_2_react.createElement("ul", { className: "case-list" }, data.map(
(item) => {
var _a;
return /* @__PURE__ */ _react_17_0_2_react.createElement("li", { key: item.id }, /* @__PURE__ */ _react_17_0_2_react.createElement("a", { href: `/moop_cases/${item.id}`, target: "_blank" }, /* @__PURE__ */ _react_17_0_2_react.createElement("img", { src: `${env/* default */.Z.IMG_SERVER}${item.cover_url}`, width: 120, alt: item.title }), /* @__PURE__ */ _react_17_0_2_react.createElement("div", { className: "info" }, /* @__PURE__ */ _react_17_0_2_react.createElement("h2", null, item.title, (_a = item.tags) == null ? void 0 : _a.map(
(tag, index) => /* @__PURE__ */ _react_17_0_2_react.createElement("span", { className: "label-" + index, key: tag.id }, tag.name)
)), /* @__PURE__ */ _react_17_0_2_react.createElement("div", { className: "detail" }, /* @__PURE__ */ _react_17_0_2_react.createElement("div", { className: "flex-container" }, /* @__PURE__ */ _react_17_0_2_react.createElement("span", null, `${item.author_name} ${item.author_school_name}`)), /* @__PURE__ */ _react_17_0_2_react.createElement("div", { className: "sum" }, /* @__PURE__ */ _react_17_0_2_react.createElement("span", null, " ", /* @__PURE__ */ _react_17_0_2_react.createElement("i", { className: "fa fa-eye" }), " ", item.visited_count, " \u6D4F\u89C8 "), /* @__PURE__ */ _react_17_0_2_react.createElement("span", null, " ", /* @__PURE__ */ _react_17_0_2_react.createElement("i", { className: "fa fa-thumbs-o-up" }), " ", item.praise_count, " \u8D5E "), /* @__PURE__ */ _react_17_0_2_react.createElement("span", null, " ", /* @__PURE__ */ _react_17_0_2_react.createElement("i", { className: "fa fa-download" }), " ", item.download_count, " \u4E0B\u8F7D "))))));
}
));
}
/* harmony default export */ var pages_MoopCases = ((0,_umi_production_exports.connect)(
({
user,
globalSetting
}) => ({
user,
globalSetting
})
)(MoopCases));
/***/ })
}]);