component-shipinlv 0.1.1 → 0.1.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,2 @@
1
+ declare const fileSelect: (fileType: 'video' | 'video+image' | 'image' | 'sound' | '') => Promise<unknown>;
2
+ export default fileSelect;
@@ -0,0 +1,54 @@
1
+ import _regeneratorRuntime from "@babel/runtime/helpers/esm/regeneratorRuntime";
2
+ import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
3
+ import * as LocalFileController from "../service/local/FileController";
4
+ var fileSelect = /*#__PURE__*/function () {
5
+ var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(fileType) {
6
+ return _regeneratorRuntime().wrap(function _callee2$(_context2) {
7
+ while (1) switch (_context2.prev = _context2.next) {
8
+ case 0:
9
+ return _context2.abrupt("return", new Promise( /*#__PURE__*/function () {
10
+ var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(resolve, reject) {
11
+ var openResult;
12
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
13
+ while (1) switch (_context.prev = _context.next) {
14
+ case 0:
15
+ _context.next = 2;
16
+ return LocalFileController.fileSelect({
17
+ fileType: fileType
18
+ }, {
19
+ silent: true
20
+ }).catch(function (err) {
21
+ if ((err === null || err === void 0 ? void 0 : err.name) === "shipinlv-client-not-run") {
22
+ return reject(err);
23
+ }
24
+ console.log('open In Folder err:', err);
25
+ console.log('open In Folder err 2:', JSON.stringify(err));
26
+ err.message = "\u9009\u53D6\u6587\u4EF6\u5931\u8D25\uFF1A".concat(err === null || err === void 0 ? void 0 : err.message);
27
+ reject(err);
28
+ });
29
+ case 2:
30
+ openResult = _context.sent;
31
+ if (openResult) {
32
+ resolve(true);
33
+ }
34
+ case 4:
35
+ case "end":
36
+ return _context.stop();
37
+ }
38
+ }, _callee);
39
+ }));
40
+ return function (_x2, _x3) {
41
+ return _ref2.apply(this, arguments);
42
+ };
43
+ }()));
44
+ case 1:
45
+ case "end":
46
+ return _context2.stop();
47
+ }
48
+ }, _callee2);
49
+ }));
50
+ return function fileSelect(_x) {
51
+ return _ref.apply(this, arguments);
52
+ };
53
+ }();
54
+ export default fileSelect;
@@ -0,0 +1,2 @@
1
+ declare const folderOpen: (folderPath: string) => Promise<unknown>;
2
+ export default folderOpen;
@@ -0,0 +1,54 @@
1
+ import _regeneratorRuntime from "@babel/runtime/helpers/esm/regeneratorRuntime";
2
+ import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
3
+ import * as LocalFileController from "../service/local/FileController";
4
+ var folderOpen = /*#__PURE__*/function () {
5
+ var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(folderPath) {
6
+ return _regeneratorRuntime().wrap(function _callee2$(_context2) {
7
+ while (1) switch (_context2.prev = _context2.next) {
8
+ case 0:
9
+ return _context2.abrupt("return", new Promise( /*#__PURE__*/function () {
10
+ var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(resolve, reject) {
11
+ var openResult;
12
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
13
+ while (1) switch (_context.prev = _context.next) {
14
+ case 0:
15
+ _context.next = 2;
16
+ return LocalFileController.folderOpen({
17
+ folderPath: folderPath
18
+ }, {
19
+ silent: true
20
+ }).catch(function (err) {
21
+ if ((err === null || err === void 0 ? void 0 : err.name) === "shipinlv-client-not-run") {
22
+ return reject(err);
23
+ }
24
+ console.log('open In Folder err:', err);
25
+ console.log('open In Folder err 2:', JSON.stringify(err));
26
+ err.message = "\u9009\u53D6\u6587\u4EF6\u5939\u5931\u8D25\uFF1A".concat(err === null || err === void 0 ? void 0 : err.message, "\uFF01 \u6587\u4EF6\u5939\u5730\u5740\uFF1A ").concat(folderPath);
27
+ reject(err);
28
+ });
29
+ case 2:
30
+ openResult = _context.sent;
31
+ if (openResult) {
32
+ resolve(true);
33
+ }
34
+ case 4:
35
+ case "end":
36
+ return _context.stop();
37
+ }
38
+ }, _callee);
39
+ }));
40
+ return function (_x2, _x3) {
41
+ return _ref2.apply(this, arguments);
42
+ };
43
+ }()));
44
+ case 1:
45
+ case "end":
46
+ return _context2.stop();
47
+ }
48
+ }, _callee2);
49
+ }));
50
+ return function folderOpen(_x) {
51
+ return _ref.apply(this, arguments);
52
+ };
53
+ }();
54
+ export default folderOpen;
@@ -0,0 +1,2 @@
1
+ declare const folderSelect: (defaultPath: string) => Promise<unknown>;
2
+ export default folderSelect;
@@ -0,0 +1,54 @@
1
+ import _regeneratorRuntime from "@babel/runtime/helpers/esm/regeneratorRuntime";
2
+ import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
3
+ import * as LocalFileController from "../service/local/FileController";
4
+ var folderSelect = /*#__PURE__*/function () {
5
+ var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(defaultPath) {
6
+ return _regeneratorRuntime().wrap(function _callee2$(_context2) {
7
+ while (1) switch (_context2.prev = _context2.next) {
8
+ case 0:
9
+ return _context2.abrupt("return", new Promise( /*#__PURE__*/function () {
10
+ var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(resolve, reject) {
11
+ var openResult;
12
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
13
+ while (1) switch (_context.prev = _context.next) {
14
+ case 0:
15
+ _context.next = 2;
16
+ return LocalFileController.folderSelect({
17
+ defaultPath: defaultPath
18
+ }, {
19
+ silent: true
20
+ }).catch(function (err) {
21
+ if ((err === null || err === void 0 ? void 0 : err.name) === "shipinlv-client-not-run") {
22
+ return reject(err);
23
+ }
24
+ console.log('open In Folder err:', err);
25
+ console.log('open In Folder err 2:', JSON.stringify(err));
26
+ err.message = "\u9009\u53D6\u6587\u4EF6\u5939\u5931\u8D25\uFF1A".concat(err === null || err === void 0 ? void 0 : err.message);
27
+ reject(err);
28
+ });
29
+ case 2:
30
+ openResult = _context.sent;
31
+ if (openResult) {
32
+ resolve(true);
33
+ }
34
+ case 4:
35
+ case "end":
36
+ return _context.stop();
37
+ }
38
+ }, _callee);
39
+ }));
40
+ return function (_x2, _x3) {
41
+ return _ref2.apply(this, arguments);
42
+ };
43
+ }()));
44
+ case 1:
45
+ case "end":
46
+ return _context2.stop();
47
+ }
48
+ }, _callee2);
49
+ }));
50
+ return function folderSelect(_x) {
51
+ return _ref.apply(this, arguments);
52
+ };
53
+ }();
54
+ export default folderSelect;
@@ -0,0 +1,2 @@
1
+ declare const Base: () => import("react/jsx-runtime").JSX.Element;
2
+ export default Base;
@@ -0,0 +1,57 @@
1
+ import fileSelect from "./fileSelect";
2
+ import folderOpen from "./folderOpen";
3
+ import folderSelect from "./folderSelect";
4
+ import openInFolder from "./openInFolder";
5
+ import { Button, Space } from "antd";
6
+ import { jsx as _jsx } from "react/jsx-runtime";
7
+ import { jsxs as _jsxs } from "react/jsx-runtime";
8
+ var Base = function Base() {
9
+ var onFileSelect = function onFileSelect() {
10
+ fileSelect('').catch(function (err) {
11
+ console.log('onFileSelect:', err.name, err.message);
12
+ });
13
+ };
14
+ var onFolderOpen = function onFolderOpen() {
15
+ folderOpen('').catch(function (err) {
16
+ console.log('on folderOpen:', err.name, err.message);
17
+ });
18
+ };
19
+ var onFolderSelect = function onFolderSelect() {
20
+ folderSelect('').catch(function (err) {
21
+ console.log('on folderSelect:', err.name, err.message);
22
+ });
23
+ };
24
+ var onOpenInFolder = function onOpenInFolder() {
25
+ openInFolder('').catch(function (err) {
26
+ console.log('on openInFolder:', err.name, err.message);
27
+ });
28
+ };
29
+ return /*#__PURE__*/_jsxs(Space, {
30
+ children: [/*#__PURE__*/_jsx(Button, {
31
+ type: "primary",
32
+ onClick: function onClick() {
33
+ return onFileSelect();
34
+ },
35
+ children: "fileSelect"
36
+ }), /*#__PURE__*/_jsx(Button, {
37
+ type: "primary",
38
+ onClick: function onClick() {
39
+ return onFolderOpen();
40
+ },
41
+ children: "folderOpen"
42
+ }), /*#__PURE__*/_jsx(Button, {
43
+ type: "primary",
44
+ onClick: function onClick() {
45
+ return onFolderSelect();
46
+ },
47
+ children: "folderSelect"
48
+ }), /*#__PURE__*/_jsx(Button, {
49
+ type: "primary",
50
+ onClick: function onClick() {
51
+ return onOpenInFolder();
52
+ },
53
+ children: "openInFolder"
54
+ })]
55
+ });
56
+ };
57
+ export default Base;
@@ -0,0 +1,2 @@
1
+ declare const openInFolder: (filePath: string) => Promise<unknown>;
2
+ export default openInFolder;
@@ -0,0 +1,54 @@
1
+ import _regeneratorRuntime from "@babel/runtime/helpers/esm/regeneratorRuntime";
2
+ import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
3
+ import * as LocalFileController from "../service/local/FileController";
4
+ var openInFolder = /*#__PURE__*/function () {
5
+ var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(filePath) {
6
+ return _regeneratorRuntime().wrap(function _callee2$(_context2) {
7
+ while (1) switch (_context2.prev = _context2.next) {
8
+ case 0:
9
+ return _context2.abrupt("return", new Promise( /*#__PURE__*/function () {
10
+ var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(resolve, reject) {
11
+ var openResult;
12
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
13
+ while (1) switch (_context.prev = _context.next) {
14
+ case 0:
15
+ _context.next = 2;
16
+ return LocalFileController.openInFolder({
17
+ filePath: filePath
18
+ }, {
19
+ silent: true
20
+ }).catch(function (err) {
21
+ if ((err === null || err === void 0 ? void 0 : err.name) === "shipinlv-client-not-run") {
22
+ return reject(err);
23
+ }
24
+ console.log('open In Folder err:', err);
25
+ console.log('open In Folder err 2:', JSON.stringify(err));
26
+ err.message = "\u6253\u5F00\u6587\u4EF6\u5931\u8D25\uFF1A".concat(err === null || err === void 0 ? void 0 : err.message, "\uFF01 \u6587\u4EF6\u5730\u5740\uFF1A ").concat(filePath);
27
+ reject(err);
28
+ });
29
+ case 2:
30
+ openResult = _context.sent;
31
+ if (openResult) {
32
+ resolve(true);
33
+ }
34
+ case 4:
35
+ case "end":
36
+ return _context.stop();
37
+ }
38
+ }, _callee);
39
+ }));
40
+ return function (_x2, _x3) {
41
+ return _ref2.apply(this, arguments);
42
+ };
43
+ }()));
44
+ case 1:
45
+ case "end":
46
+ return _context2.stop();
47
+ }
48
+ }, _callee2);
49
+ }));
50
+ return function openInFolder(_x) {
51
+ return _ref.apply(this, arguments);
52
+ };
53
+ }();
54
+ export default openInFolder;
package/dist/index.d.ts CHANGED
@@ -4,3 +4,7 @@ export { default as Login } from './Login';
4
4
  export { default as AuthClient } from './AuthClient';
5
5
  export { default as Product } from './Product';
6
6
  export { default as JoinClient } from './join-client';
7
+ export { default as fileSelect } from './base/fileSelect';
8
+ export { default as folderOpen } from './base/folderOpen';
9
+ export { default as folderSelect } from './base/folderSelect';
10
+ export { default as openInFolder } from './base/openInFolder';
package/dist/index.js CHANGED
@@ -3,4 +3,8 @@ export { default as Buy } from "./Buy";
3
3
  export { default as Login } from "./Login";
4
4
  export { default as AuthClient } from "./AuthClient";
5
5
  export { default as Product } from "./Product";
6
- export { default as JoinClient } from "./join-client";
6
+ export { default as JoinClient } from "./join-client";
7
+ export { default as fileSelect } from "./base/fileSelect";
8
+ export { default as folderOpen } from "./base/folderOpen";
9
+ export { default as folderSelect } from "./base/folderSelect";
10
+ export { default as openInFolder } from "./base/openInFolder";
@@ -27,6 +27,8 @@ var JoinClient = function JoinClient(_ref) {
27
27
  var _useRequest = useRequest(function () {
28
28
  return SubClientController.start({
29
29
  productType: productType
30
+ }, {
31
+ silent: true
30
32
  });
31
33
  }, {
32
34
  // manual: true,
@@ -16,6 +16,11 @@ var getApiUrl = function getApiUrl() {
16
16
  return apiName;
17
17
  }
18
18
 
19
+ // 主客户端
20
+ if (/_main\//i.test(apiName)) {
21
+ return "http://127.0.0.1:61800/".concat(apiName.replace(/^_main\//i, ''));
22
+ }
23
+
19
24
  // 替换第一个 /
20
25
  apiName = apiName.replace(/^\//, '');
21
26
  var env = getApiEnv(apiEnv || envData());
@@ -61,8 +61,19 @@ var requestApi = function requestApi() {
61
61
  }
62
62
  }
63
63
  }).catch(function (err) {
64
+ var _err, _err2;
64
65
  console.log('ajax error:', err.name, err.message, err);
65
- if (['Failed to fetch', 'http error'].includes(err === null || err === void 0 ? void 0 : err.message)) {
66
+ if (!err) {
67
+ err = new Error();
68
+ }
69
+ console.log('request component shipinlv:', JSON.stringify(err), url);
70
+ if (!((_err = err) !== null && _err !== void 0 && _err.response) && url.indexOf('http://127.0.0.1:61800') === 0) {
71
+ err.name = "shipinlv-client-not-run";
72
+ err.message = "\u8BF7\u5148\u6253\u5F00\u7535\u8111\u4E0A\u5DF2\u5B89\u88C5\u7684\uFF1A\u3010\u89C6\u9891\u9A74\u5DE5\u5177\u7BB1\u3011\uFF0C\u518D\u64CD\u4F5C";
73
+ reject(err);
74
+ return;
75
+ }
76
+ if (['Failed to fetch', 'http error'].includes((_err2 = err) === null || _err2 === void 0 ? void 0 : _err2.message)) {
66
77
  err.message = '发生了一些问题,请稍后重试';
67
78
  }
68
79
  Tool.toastError(err.message);
@@ -12,7 +12,7 @@ function _start() {
12
12
  return _regeneratorRuntime().wrap(function _callee$(_context) {
13
13
  while (1) switch (_context.prev = _context.next) {
14
14
  case 0:
15
- return _context.abrupt("return", request("http://127.0.0.1:61800/sub-client/start", _objectSpread({
15
+ return _context.abrupt("return", request("_main/sub-client/start", _objectSpread({
16
16
  env: (options === null || options === void 0 ? void 0 : options.env) || '',
17
17
  method: 'GET',
18
18
  params: _objectSpread({}, body)
@@ -0,0 +1,22 @@
1
+ export declare function fileList(body: {
2
+ path: string[];
3
+ fileType: 'folder' | 'file' | '';
4
+ extTypes?: string[];
5
+ }, options?: ServicesApi.RequestOptions): Promise<string[][]>;
6
+ export declare function fileSelect(body: {
7
+ fileType: 'video' | 'video+image' | 'image' | 'sound' | '';
8
+ }, options?: ServicesApi.RequestOptions): Promise<LocalFile.FileSelect>;
9
+ export declare function folderSelect(body: {
10
+ defaultPath: string;
11
+ }, options?: ServicesApi.RequestOptions): Promise<LocalFile.FileSelect>;
12
+ export declare function openInFolder(body: {
13
+ filePath: string;
14
+ }, options?: ServicesApi.RequestOptions): Promise<LocalFile.FileSelect>;
15
+ export declare function folderOpen(body: {
16
+ folderPath: string;
17
+ }, options?: ServicesApi.RequestOptions): Promise<LocalFile.FileSelect>;
18
+ export declare function downUrl(body: {
19
+ url: string;
20
+ savePath?: string;
21
+ saveName?: string;
22
+ }, options?: ServicesApi.RequestOptions): Promise<LocalFile.DownUrlResult>;
@@ -0,0 +1,152 @@
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 fileList(_x, _x2) {
6
+ return _fileList.apply(this, arguments);
7
+ }
8
+ function _fileList() {
9
+ _fileList = _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("_local/file/localFileList", _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 _fileList.apply(this, arguments);
27
+ }
28
+ export function fileSelect(_x3, _x4) {
29
+ return _fileSelect.apply(this, arguments);
30
+ }
31
+ function _fileSelect() {
32
+ _fileSelect = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(body, options) {
33
+ return _regeneratorRuntime().wrap(function _callee2$(_context2) {
34
+ while (1) switch (_context2.prev = _context2.next) {
35
+ case 0:
36
+ return _context2.abrupt("return", request("_main/file/select", _objectSpread({
37
+ method: 'POST',
38
+ headers: {
39
+ 'Content-Type': 'application/json'
40
+ },
41
+ data: body
42
+ }, options || {})));
43
+ case 1:
44
+ case "end":
45
+ return _context2.stop();
46
+ }
47
+ }, _callee2);
48
+ }));
49
+ return _fileSelect.apply(this, arguments);
50
+ }
51
+ export function folderSelect(_x5, _x6) {
52
+ return _folderSelect.apply(this, arguments);
53
+ }
54
+ function _folderSelect() {
55
+ _folderSelect = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(body, options) {
56
+ return _regeneratorRuntime().wrap(function _callee3$(_context3) {
57
+ while (1) switch (_context3.prev = _context3.next) {
58
+ case 0:
59
+ return _context3.abrupt("return", request("_main/file/folderSelect", _objectSpread({
60
+ method: 'POST',
61
+ headers: {
62
+ 'Content-Type': 'application/json'
63
+ },
64
+ data: body
65
+ }, options || {})));
66
+ case 1:
67
+ case "end":
68
+ return _context3.stop();
69
+ }
70
+ }, _callee3);
71
+ }));
72
+ return _folderSelect.apply(this, arguments);
73
+ }
74
+ export function openInFolder(_x7, _x8) {
75
+ return _openInFolder.apply(this, arguments);
76
+ }
77
+ function _openInFolder() {
78
+ _openInFolder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(body, options) {
79
+ return _regeneratorRuntime().wrap(function _callee4$(_context4) {
80
+ while (1) switch (_context4.prev = _context4.next) {
81
+ case 0:
82
+ return _context4.abrupt("return", request("_main/file/openInFolder", _objectSpread({
83
+ method: 'POST',
84
+ headers: {
85
+ 'Content-Type': 'application/json'
86
+ },
87
+ data: body
88
+ }, options || {})));
89
+ case 1:
90
+ case "end":
91
+ return _context4.stop();
92
+ }
93
+ }, _callee4);
94
+ }));
95
+ return _openInFolder.apply(this, arguments);
96
+ }
97
+ export function folderOpen(_x9, _x10) {
98
+ return _folderOpen.apply(this, arguments);
99
+ }
100
+
101
+ // 相对粗糙,假设文件都不大;
102
+ function _folderOpen() {
103
+ _folderOpen = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(body, options) {
104
+ return _regeneratorRuntime().wrap(function _callee5$(_context5) {
105
+ while (1) switch (_context5.prev = _context5.next) {
106
+ case 0:
107
+ return _context5.abrupt("return", request("_main/file/folderOpen", _objectSpread({
108
+ method: 'POST',
109
+ headers: {
110
+ 'Content-Type': 'application/json'
111
+ },
112
+ data: body
113
+ }, options || {})));
114
+ case 1:
115
+ case "end":
116
+ return _context5.stop();
117
+ }
118
+ }, _callee5);
119
+ }));
120
+ return _folderOpen.apply(this, arguments);
121
+ }
122
+ export function downUrl(_x11, _x12) {
123
+ return _downUrl.apply(this, arguments);
124
+ }
125
+ function _downUrl() {
126
+ _downUrl = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6(body, options) {
127
+ return _regeneratorRuntime().wrap(function _callee6$(_context6) {
128
+ while (1) switch (_context6.prev = _context6.next) {
129
+ case 0:
130
+ if (body.savePath) {
131
+ if (!/\/$/.test(body.savePath)) {
132
+ body.savePath += '/';
133
+ }
134
+ }
135
+ return _context6.abrupt("return", request("_local/file/downUrl", _objectSpread({
136
+ method: 'POST',
137
+ headers: {
138
+ 'Content-Type': 'application/json'
139
+ },
140
+ data: body
141
+ }, _objectSpread(_objectSpread({}, options), {}, {
142
+ // 超时时间
143
+ timeout: 20 * 6e4
144
+ }))));
145
+ case 2:
146
+ case "end":
147
+ return _context6.stop();
148
+ }
149
+ }, _callee6);
150
+ }));
151
+ return _downUrl.apply(this, arguments);
152
+ }
@@ -0,0 +1,14 @@
1
+ declare namespace LocalFile {
2
+ interface List {
3
+ id: string;
4
+ progress: number;
5
+ videoUrl: string;
6
+ }
7
+ interface DownUrlResult {
8
+ filePath: string;
9
+ }
10
+ interface FileSelect {
11
+ canceled: boolean;
12
+ filePaths: string[];
13
+ }
14
+ }
File without changes
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "component-shipinlv",
3
- "version": "0.1.1",
3
+ "version": "0.1.3",
4
4
  "description": "",
5
5
  "module": "dist/index.js",
6
6
  "types": "dist/index.d.ts",