component-shipinlv 2.2.12 → 2.2.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,11 @@
1
+ import React from 'react';
2
+ import './index.less';
3
+ interface Props {
4
+ productType: string;
5
+ from: Ad.From;
6
+ position: string;
7
+ dealerId: number;
8
+ env?: Global.Env;
9
+ }
10
+ declare const Ad: React.FC<Props>;
11
+ export default Ad;
@@ -0,0 +1,141 @@
1
+ import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
2
+ import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
3
+ import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
4
+ import { useRequest } from "@umijs/hooks";
5
+ import * as AdController from "../service/api/AdController";
6
+ import React, { useRef, useState } from 'react';
7
+ import { LoadingOutlined, WarningOutlined } from "@ant-design/icons";
8
+ import "./index.less";
9
+ import { Image } from "antd";
10
+ import { jsx as _jsx } from "react/jsx-runtime";
11
+ import { jsxs as _jsxs } from "react/jsx-runtime";
12
+ var Ad = function Ad(_ref) {
13
+ var productType = _ref.productType,
14
+ from = _ref.from,
15
+ position = _ref.position,
16
+ dealerId = _ref.dealerId,
17
+ env = _ref.env;
18
+ var listDataRef = useRef([]);
19
+ var currentIndexRef = useRef(0);
20
+ var _useState = useState({
21
+ id: 0,
22
+ title: '',
23
+ url: '',
24
+ thumbUrl: '',
25
+ openTarget: 'url',
26
+ enabled: true,
27
+ orderIndex: 0,
28
+ disabledUrlQuery: [],
29
+ created: 0
30
+ }),
31
+ _useState2 = _slicedToArray(_useState, 2),
32
+ currentItem = _useState2[0],
33
+ setCurrentItem = _useState2[1];
34
+ var _useState3 = useState(false),
35
+ _useState4 = _slicedToArray(_useState3, 2),
36
+ imageVisible = _useState4[0],
37
+ setImageVisible = _useState4[1];
38
+ var _useState5 = useState(''),
39
+ _useState6 = _slicedToArray(_useState5, 2),
40
+ imageUrl = _useState6[0],
41
+ setImageUrl = _useState6[1];
42
+ var timerRef = useRef(setTimeout(function () {}, 0));
43
+ var _useRequest = useRequest(function () {
44
+ return AdController.list({
45
+ productType: productType,
46
+ from: from,
47
+ position: position,
48
+ dealerId: dealerId
49
+ }, {
50
+ env: env
51
+ });
52
+ }, {
53
+ onSuccess: function onSuccess(result) {
54
+ listDataRef.current = _toConsumableArray(result);
55
+ if (result.length > 0) {
56
+ setCurrentItem(_objectSpread({}, result[0]));
57
+ onLoop();
58
+ }
59
+ }
60
+ }),
61
+ loading = _useRequest.loading,
62
+ run = _useRequest.run,
63
+ error = _useRequest.error;
64
+ var onLoop = function onLoop() {
65
+ timerRef.current = setTimeout(function () {
66
+ onNext();
67
+ }, 5000);
68
+ };
69
+ var onNext = function onNext() {
70
+ var i = 0;
71
+ if (currentIndexRef.current + 1 >= listDataRef.current.length) {
72
+ currentIndexRef.current = 0;
73
+ } else {
74
+ currentIndexRef.current++;
75
+ }
76
+ console.log('onNext i:', currentIndexRef.current, listDataRef);
77
+ setCurrentItem(_objectSpread({}, listDataRef.current[currentIndexRef.current]));
78
+ onLoop();
79
+ };
80
+ var onOpen = function onOpen(currentItem) {
81
+ var _window$getBridge, _window$getBridge$ope;
82
+ switch (currentItem.openTarget) {
83
+ case "url":
84
+ if (from === 'web') {
85
+ return true;
86
+ }
87
+ (_window$getBridge = window.getBridge()) === null || _window$getBridge === void 0 || (_window$getBridge$ope = _window$getBridge.openLocalBrowser) === null || _window$getBridge$ope === void 0 || _window$getBridge$ope.call(_window$getBridge, currentItem.url);
88
+ break;
89
+ case "image":
90
+ setImageUrl(currentItem.url);
91
+ setImageVisible(true);
92
+ break;
93
+ }
94
+ return false;
95
+ };
96
+ return /*#__PURE__*/_jsxs("div", {
97
+ className: "ad",
98
+ children: [error ? /*#__PURE__*/_jsxs("a", {
99
+ onClick: function onClick() {
100
+ return run();
101
+ },
102
+ children: [/*#__PURE__*/_jsx(WarningOutlined, {
103
+ className: "reload"
104
+ }), " \u91CD\u8BD5"]
105
+ }) : loading ? /*#__PURE__*/_jsx(LoadingOutlined, {}) : /*#__PURE__*/_jsx("div", {
106
+ className: "adList",
107
+ onMouseEnter: function onMouseEnter() {
108
+ return clearTimeout(timerRef.current);
109
+ },
110
+ onMouseLeave: function onMouseLeave() {
111
+ return onLoop();
112
+ },
113
+ children: /*#__PURE__*/_jsx("a", {
114
+ href: currentItem.url,
115
+ target: "_blank",
116
+ onClick: function onClick(e) {
117
+ if (!onOpen(currentItem)) {
118
+ e.preventDefault();
119
+ e.stopPropagation();
120
+ return false;
121
+ }
122
+ },
123
+ children: currentItem.title
124
+ })
125
+ }), /*#__PURE__*/_jsx(Image, {
126
+ style: {
127
+ display: 'none'
128
+ },
129
+ src: "https://zos.alipayobjects.com/rmsportal/jkjgkEfvpUPVyRjUImniVslZfWPnJuuZ.png?x-oss-process=image/blur,r_50,s_50/quality,q_1/resize,m_mfit,h_200,w_200",
130
+ preview: {
131
+ visible: imageVisible,
132
+ src: imageUrl,
133
+ // 'https://zos.alipayobjects.com/rmsportal/jkjgkEfvpUPVyRjUImniVslZfWPnJuuZ.png',
134
+ onVisibleChange: function onVisibleChange(value) {
135
+ setImageVisible(value);
136
+ }
137
+ }
138
+ })]
139
+ });
140
+ };
141
+ export default Ad;
@@ -0,0 +1,8 @@
1
+ .ad{
2
+ overflow: hidden;
3
+ word-break: keep-all;
4
+ word-wrap: anywhere;
5
+ .reload{
6
+ color: #C00;
7
+ }
8
+ }
@@ -120,7 +120,7 @@ var VideoPublishLog = function VideoPublishLog(_ref) {
120
120
  setLastTaskApplyTime(Math.floor(Date.now() * 0.001));
121
121
  });
122
122
  event.on('ws-message.publish-video-log-publish-video', function (query) {
123
- console.log('ws-message publish-video -log-publish-video:', query);
123
+ // console.log('ws-message publish-video -log-publish-video:', query );
124
124
  if (query.dataType !== 'publish-video-log-publish-video') {
125
125
  return;
126
126
  }
package/dist/index.d.ts CHANGED
@@ -28,3 +28,4 @@ export { default as fileList } from './base/fileList';
28
28
  export { default as VideoStudy } from './video-study';
29
29
  export { default as HomePageAccountList } from './VideoPublish/account-manage/list';
30
30
  export { default as getWorkServerUploadToken } from './lib/getWorkServerUploadToken';
31
+ export { default as Ad } from './Ad';
package/dist/index.js CHANGED
@@ -31,4 +31,5 @@ export { default as fileListContent } from "./base/fileListContent";
31
31
  export { default as fileList } from "./base/fileList";
32
32
  export { default as VideoStudy } from "./video-study";
33
33
  export { default as HomePageAccountList } from "./VideoPublish/account-manage/list";
34
- export { default as getWorkServerUploadToken } from "./lib/getWorkServerUploadToken";
34
+ export { default as getWorkServerUploadToken } from "./lib/getWorkServerUploadToken";
35
+ export { default as Ad } from "./Ad";
@@ -0,0 +1,6 @@
1
+ export declare function list(body: {
2
+ productType: string;
3
+ from: 'web' | 'client';
4
+ position: string;
5
+ dealerId: number;
6
+ }, options?: Global.RequestOptions): Promise<Ad.List[]>;
@@ -0,0 +1,27 @@
1
+ import _regeneratorRuntime from "@babel/runtime/helpers/esm/regeneratorRuntime";
2
+ import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
3
+ import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
4
+ import request from "../../lib/request";
5
+ export function list(_x, _x2) {
6
+ return _list.apply(this, arguments);
7
+ }
8
+ function _list() {
9
+ _list = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(body, options) {
10
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
11
+ while (1) switch (_context.prev = _context.next) {
12
+ case 0:
13
+ return _context.abrupt("return", request("ad/list", _objectSpread({
14
+ method: 'POST',
15
+ headers: {
16
+ 'Content-Type': 'application/json'
17
+ },
18
+ data: body
19
+ }, options || {})));
20
+ case 1:
21
+ case "end":
22
+ return _context.stop();
23
+ }
24
+ }, _callee);
25
+ }));
26
+ return _list.apply(this, arguments);
27
+ }
@@ -0,0 +1,15 @@
1
+ declare namespace Ad {
2
+ type OpenTarget = 'url' | 'image';
3
+ type From = 'web' | 'client';
4
+ interface List {
5
+ id: number;
6
+ title: string;
7
+ url: string;
8
+ thumbUrl: string;
9
+ openTarget: OpenTarget;
10
+ enabled: true;
11
+ orderIndex: number;
12
+ disabledUrlQuery: string[];
13
+ created: number;
14
+ }
15
+ }
File without changes
package/dist/window.d.ts CHANGED
@@ -24,7 +24,7 @@ declare interface Window{
24
24
  fs: any;
25
25
  getIpc: any;
26
26
  openDir: ( dir: string ) => Promise<string>
27
-
27
+ openLocalBrowser: ( url: string, path: string = '' ) => {};
28
28
  openVideoAccountBrowser: ( platform: string, subPlatform: string, accountId: string, url: string , proxyInfo?: Global.ProxyInfo ) => void;
29
29
  };
30
30
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "component-shipinlv",
3
- "version": "2.2.12",
3
+ "version": "2.2.13",
4
4
  "description": "",
5
5
  "module": "dist/index.js",
6
6
  "types": "dist/index.d.ts",