@whyour/qinglong 0.20.4 → 0.21.0

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.
package/README-en.md CHANGED
@@ -48,7 +48,7 @@ docker pull whyour/qinglong:debian
48
48
 
49
49
  ### npm
50
50
 
51
- The npm version supports `debian/ubuntu/centos/alpine` systems and requires `node/python3` to be installed.
51
+ The npm version supports `debian/ubuntu/alpine` systems and requires `node/npm/python3/pip3/pnpm` to be installed.
52
52
 
53
53
  ```bash
54
54
  npm i @whyour/qinglong
@@ -105,15 +105,13 @@ podman run -dit \
105
105
  docker.io/whyour/qinglong:latest
106
106
  ```
107
107
 
108
- ### Local
108
+ ### Npm
109
109
 
110
- It is recommended to use a pure system installation to avoid losing the original system data, you need to install node/npm/python3/pip3 yourself
110
+ It is recommended to use a pure system installation to avoid losing the original system data, you need to install node/npm/python3/pip3/pnpm yourself
111
111
 
112
112
  ```bash
113
113
  # Debian/Ubuntu
114
114
  curl -sL https://deb.nodesource.com/setup_20.x | sudo -E bash -
115
- # Centos
116
- curl --silent --location https://rpm.nodesource.com/setup_20.x | sudo bash
117
115
  ```
118
116
 
119
117
  ```bash
package/README.md CHANGED
@@ -50,7 +50,7 @@ docker pull whyour/qinglong:debian
50
50
 
51
51
  ### npm
52
52
 
53
- npm 版本支持 `debian/ubuntu/centos/alpine` 系统,需要自行安装 `node/python3`
53
+ npm 版本支持 `debian/ubuntu/alpine` 系统,需要自行安装 `node/npm/python3/pip3/pnpm`
54
54
 
55
55
  ```bash
56
56
  npm i @whyour/qinglong
@@ -107,15 +107,13 @@ podman run -dit \
107
107
  docker.io/whyour/qinglong:latest
108
108
  ```
109
109
 
110
- ### 本机
110
+ ### npm
111
111
 
112
- 建议使用纯净系统安装,避免系统原有数据丢失,需要自己安装 node/npm/python3/pip3
112
+ 建议使用纯净系统安装,避免系统原有数据丢失,需要自己安装 node/npm/python3/pip3/pnpm
113
113
 
114
114
  ```bash
115
115
  # Debian/Ubuntu
116
116
  curl -sL https://deb.nodesource.com/setup_20.x | sudo -E bash -
117
- # Centos
118
- curl --silent --location https://rpm.nodesource.com/setup_20.x | sudo bash
119
117
  ```
120
118
 
121
119
  ```bash
@@ -6,8 +6,8 @@ COPY --from=nodebuilder /usr/local/bin/node /usr/local/bin/
6
6
  COPY --from=nodebuilder /usr/local/lib/node_modules/. /usr/local/lib/node_modules/
7
7
  RUN set -x && \
8
8
  ln -s /usr/local/lib/node_modules/npm/bin/npm-cli.js /usr/local/bin/npm && \
9
- apt update && \
10
- apt install --no-install-recommends -y libatomic1 && \
9
+ apt-get update && \
10
+ apt-get install --no-install-recommends -y libatomic1 && \
11
11
  npm i -g pnpm@8.3.1 && \
12
12
  cd /tmp/build && \
13
13
  pnpm install --prod
@@ -33,9 +33,9 @@ COPY --from=nodebuilder /usr/local/lib/node_modules/. /usr/local/lib/node_module
33
33
 
34
34
  RUN set -x && \
35
35
  ln -s /usr/local/lib/node_modules/npm/bin/npm-cli.js /usr/local/bin/npm && \
36
- apt update && \
37
- apt upgrade -y && \
38
- apt install --no-install-recommends -y git \
36
+ apt-get update && \
37
+ apt-get upgrade -y && \
38
+ apt-get install --no-install-recommends -y git \
39
39
  curl \
40
40
  wget \
41
41
  tzdata \
@@ -48,7 +48,7 @@ RUN set -x && \
48
48
  netcat \
49
49
  unzip \
50
50
  libatomic1 && \
51
- apt clean && \
51
+ apt-get clean && \
52
52
  ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime && \
53
53
  echo "Asia/Shanghai" >/etc/timezone && \
54
54
  git config --global user.email "qinglong@@users.noreply.github.com" && \
package/docker/Dockerfile CHANGED
@@ -6,8 +6,8 @@ COPY --from=nodebuilder /usr/local/bin/node /usr/local/bin/
6
6
  COPY --from=nodebuilder /usr/local/lib/node_modules/. /usr/local/lib/node_modules/
7
7
  RUN set -x && \
8
8
  ln -s /usr/local/lib/node_modules/npm/bin/npm-cli.js /usr/local/bin/npm && \
9
- apt update && \
10
- apt install --no-install-recommends -y libatomic1 && \
9
+ apt-get update && \
10
+ apt-get install --no-install-recommends -y libatomic1 && \
11
11
  npm i -g pnpm@8.3.1 && \
12
12
  cd /tmp/build && \
13
13
  pnpm install --prod
@@ -34,9 +34,9 @@ COPY --from=nodebuilder /usr/local/lib/node_modules/. /usr/local/lib/node_module
34
34
  RUN set -x && \
35
35
  ln -s /usr/local/lib/node_modules/npm/bin/npm-cli.js /usr/local/bin/npm && \
36
36
  ln -s /usr/local/lib/node_modules/npm/bin/npx-cli.js /usr/local/bin/npx && \
37
- apt update && \
38
- apt upgrade -y && \
39
- apt install --no-install-recommends -y git \
37
+ apt-get update && \
38
+ apt-get upgrade -y && \
39
+ apt-get install --no-install-recommends -y git \
40
40
  curl \
41
41
  wget \
42
42
  tzdata \
@@ -49,7 +49,7 @@ RUN set -x && \
49
49
  netcat \
50
50
  unzip \
51
51
  libatomic1 && \
52
- apt clean && \
52
+ apt-get clean && \
53
53
  ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime && \
54
54
  echo "Asia/Shanghai" >/etc/timezone && \
55
55
  git config --global user.email "qinglong@@users.noreply.github.com" && \
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@whyour/qinglong",
3
- "version": "0.20.4",
3
+ "version": "0.21.0",
4
4
  "description": "Timed task management platform supporting Python3, JavaScript, Shell, Typescript",
5
5
  "repository": {
6
6
  "type": "git",
package/shell/bot.sh CHANGED
@@ -9,7 +9,15 @@ else
9
9
  fi
10
10
 
11
11
  echo -e "\n1、安装bot依赖...\n"
12
- apt install -y gcc python3-dev musl-dev
12
+ os_name=$(source /etc/os-release && echo "$ID")
13
+ if [[ $os_name == 'alpine' ]]; then
14
+ apk --no-cache add -f zlib-dev gcc jpeg-dev python3-dev musl-dev freetype-dev
15
+ elif [[ $os_name == 'debian' ]] || [[ $os_name == 'ubuntu' ]]; then
16
+ apt-get install -y gcc python3-dev musl-dev
17
+ else
18
+ echo -e "暂不支持此系统 $os_name"
19
+ exit 1
20
+ fi
13
21
  echo -e "\nbot依赖安装成功...\n"
14
22
 
15
23
  echo -e "2、下载bot所需文件...\n"
package/shell/start.sh CHANGED
@@ -46,11 +46,8 @@ if [[ $os_name == 'alpine' ]]; then
46
46
  procps \
47
47
  netcat-openbsd
48
48
  elif [[ $os_name == 'debian' ]] || [[ $os_name == 'ubuntu' ]]; then
49
- apt update
50
- apt install -y git curl wget tzdata perl openssl jq nginx procps netcat-openbsd openssh-client
51
- elif [[ $os_name == 'centos' ]]; then
52
- yum update
53
- yum install -y epel-release git curl wget tzdata perl openssl jq nginx procps nc openssh-client
49
+ apt-get update
50
+ apt-get install -y git curl wget tzdata perl openssl jq nginx procps netcat-openbsd openssh-client
54
51
  else
55
52
  echo -e "暂不支持此系统部署 $os_name"
56
53
  exit 1
@@ -44,9 +44,13 @@ exports.default = (app) => {
44
44
  remarks: celebrate_1.Joi.string().optional().allow(''),
45
45
  })),
46
46
  }), async (req, res, next) => {
47
+ var _a;
47
48
  const logger = typedi_1.Container.get('logger');
48
49
  try {
49
50
  const envService = typedi_1.Container.get(env_1.default);
51
+ if (!((_a = req.body) === null || _a === void 0 ? void 0 : _a.length)) {
52
+ return res.send({ code: 400, message: '参数不正确' });
53
+ }
50
54
  const data = await envService.create(req.body);
51
55
  return res.send({ code: 200, data });
52
56
  }
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.SAMPLE_FILES = exports.QL_PREFIX = exports.TASK_PREFIX = exports.QL_COMMAND = exports.TASK_COMMAND = exports.LOG_END_SYMBOL = void 0;
3
+ exports.LINUX_DEPENDENCE_COMMAND = exports.SAMPLE_FILES = exports.QL_PREFIX = exports.TASK_PREFIX = exports.QL_COMMAND = exports.TASK_COMMAND = exports.LOG_END_SYMBOL = void 0;
4
4
  exports.LOG_END_SYMBOL = '     ';
5
5
  exports.TASK_COMMAND = 'task';
6
6
  exports.QL_COMMAND = 'ql';
@@ -23,4 +23,30 @@ exports.SAMPLE_FILES = [
23
23
  target: 'data/scripts/notify.py',
24
24
  },
25
25
  ];
26
+ exports.LINUX_DEPENDENCE_COMMAND = {
27
+ Debian: {
28
+ install: 'apt-get install -y',
29
+ uninstall: 'apt-get remove -y',
30
+ info: 'dpkg-query -s',
31
+ check(info) {
32
+ return info.includes('install ok installed');
33
+ },
34
+ },
35
+ Ubuntu: {
36
+ install: 'apt-get install -y',
37
+ uninstall: 'apt-get remove -y',
38
+ info: 'dpkg-query -s',
39
+ check(info) {
40
+ return info.includes('install ok installed');
41
+ },
42
+ },
43
+ Alpine: {
44
+ install: 'apk add --no-check-certificate',
45
+ uninstall: 'apk del',
46
+ info: 'apk info -es',
47
+ check(info) {
48
+ return info.includes('installed');
49
+ },
50
+ },
51
+ };
26
52
  //# sourceMappingURL=const.js.map
@@ -29,7 +29,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
29
29
  return (mod && mod.__esModule) ? mod : { "default": mod };
30
30
  };
31
31
  Object.defineProperty(exports, "__esModule", { value: true });
32
- exports.rmPath = exports.safeJSONParse = exports.getUniqPath = exports.parseContentVersion = exports.parseVersion = exports.getPid = exports.killTask = exports.psTree = exports.parseBody = exports.parseHeaders = exports.promiseExecSuccess = exports.promiseExec = exports.readDir = exports.readDirs = exports.dirSort = exports.concurrentRun = exports.handleLogPath = exports.createFile = exports.fileExist = exports.getPlatform = exports.getNetIp = exports.getToken = exports.getLastModifyFilePath = exports.getFileContentByName = void 0;
32
+ exports.updateLinuxMirrorFile = exports.detectOS = exports.rmPath = exports.safeJSONParse = exports.getUniqPath = exports.parseContentVersion = exports.parseVersion = exports.getPid = exports.killTask = exports.psTree = exports.parseBody = exports.parseHeaders = exports.promiseExecSuccess = exports.promiseExec = exports.readDir = exports.readDirs = exports.dirSort = exports.concurrentRun = exports.handleLogPath = exports.createFile = exports.fileExist = exports.getPlatform = exports.getNetIp = exports.getToken = exports.getLastModifyFilePath = exports.getFileContentByName = void 0;
33
33
  const fs = __importStar(require("fs/promises"));
34
34
  const path = __importStar(require("path"));
35
35
  const got_1 = __importDefault(require("got"));
@@ -42,7 +42,9 @@ const js_yaml_1 = require("js-yaml");
42
42
  const index_1 = __importDefault(require("./index"));
43
43
  const const_1 = require("./const");
44
44
  const logger_1 = __importDefault(require("../loaders/logger"));
45
+ const os_1 = __importDefault(require("os"));
45
46
  __exportStar(require("./share"), exports);
47
+ let osType;
46
48
  async function getFileContentByName(fileName) {
47
49
  const _exsit = await fileExist(fileName);
48
50
  if (_exsit) {
@@ -487,4 +489,114 @@ async function rmPath(path) {
487
489
  }
488
490
  }
489
491
  exports.rmPath = rmPath;
492
+ async function getOSReleaseInfo() {
493
+ const osRelease = await fs.readFile('/etc/os-release', 'utf8');
494
+ return osRelease;
495
+ }
496
+ function isDebian(osReleaseInfo) {
497
+ return osReleaseInfo.includes('Debian');
498
+ }
499
+ function isUbuntu(osReleaseInfo) {
500
+ return osReleaseInfo.includes('Ubuntu');
501
+ }
502
+ function isCentOS(osReleaseInfo) {
503
+ return osReleaseInfo.includes('CentOS') || osReleaseInfo.includes('Red Hat');
504
+ }
505
+ function isAlpine(osReleaseInfo) {
506
+ return osReleaseInfo.includes('Alpine');
507
+ }
508
+ async function detectOS() {
509
+ if (osType)
510
+ return osType;
511
+ const platform = os_1.default.platform();
512
+ if (platform === 'linux') {
513
+ const osReleaseInfo = await getOSReleaseInfo();
514
+ if (isDebian(osReleaseInfo)) {
515
+ osType = 'Debian';
516
+ }
517
+ else if (isUbuntu(osReleaseInfo)) {
518
+ osType = 'Ubuntu';
519
+ }
520
+ else if (isAlpine(osReleaseInfo)) {
521
+ osType = 'Alpine';
522
+ }
523
+ else {
524
+ logger_1.default.error(`Unknown Linux Distribution: ${osReleaseInfo}`);
525
+ console.error(`Unknown Linux Distribution: ${osReleaseInfo}`);
526
+ }
527
+ }
528
+ else {
529
+ logger_1.default.error(`Unsupported platform: ${platform}`);
530
+ console.error(`Unsupported platform: ${platform}`);
531
+ }
532
+ return osType;
533
+ }
534
+ exports.detectOS = detectOS;
535
+ async function getCurrentMirrorDomain(filePath) {
536
+ const fileContent = await fs.readFile(filePath, 'utf8');
537
+ const lines = fileContent.split('\n');
538
+ for (const line of lines) {
539
+ if (line.trim().startsWith('#')) {
540
+ continue;
541
+ }
542
+ const match = line.match(/https?:\/\/[^\/]+/);
543
+ if (match) {
544
+ return match[0];
545
+ }
546
+ }
547
+ return null;
548
+ }
549
+ async function replaceDomainInFile(filePath, oldDomainWithScheme, newDomainWithScheme) {
550
+ let fileContent = await fs.readFile(filePath, 'utf8');
551
+ let updatedContent = fileContent.replace(new RegExp(oldDomainWithScheme, 'g'), newDomainWithScheme);
552
+ if (!newDomainWithScheme.endsWith('/')) {
553
+ newDomainWithScheme += '/';
554
+ }
555
+ await fs.writeFile(filePath, updatedContent, 'utf8');
556
+ }
557
+ async function _updateLinuxMirror(osType, mirrorDomainWithScheme) {
558
+ let filePath, currentDomainWithScheme;
559
+ switch (osType) {
560
+ case 'Debian':
561
+ filePath = '/etc/apt/sources.list';
562
+ currentDomainWithScheme = await getCurrentMirrorDomain(filePath);
563
+ if (currentDomainWithScheme) {
564
+ await replaceDomainInFile(filePath, currentDomainWithScheme, mirrorDomainWithScheme || 'http://deb.debian.org');
565
+ return 'apt-get update';
566
+ }
567
+ else {
568
+ throw Error(`Current mirror domain not found.`);
569
+ }
570
+ case 'Ubuntu':
571
+ filePath = '/etc/apt/sources.list';
572
+ currentDomainWithScheme = await getCurrentMirrorDomain(filePath);
573
+ if (currentDomainWithScheme) {
574
+ await replaceDomainInFile(filePath, currentDomainWithScheme, mirrorDomainWithScheme || 'http://archive.ubuntu.com');
575
+ return 'apt-get update';
576
+ }
577
+ else {
578
+ throw Error(`Current mirror domain not found.`);
579
+ }
580
+ case 'Alpine':
581
+ filePath = '/etc/apk/repositories';
582
+ currentDomainWithScheme = await getCurrentMirrorDomain(filePath);
583
+ if (currentDomainWithScheme) {
584
+ await replaceDomainInFile(filePath, currentDomainWithScheme, mirrorDomainWithScheme || 'http://dl-cdn.alpinelinux.org');
585
+ return 'apk update';
586
+ }
587
+ else {
588
+ throw Error(`Current mirror domain not found.`);
589
+ }
590
+ default:
591
+ throw Error('Unsupported OS type for updating mirrors.');
592
+ }
593
+ }
594
+ async function updateLinuxMirrorFile(mirror) {
595
+ const detectedOS = await detectOS();
596
+ if (!detectedOS) {
597
+ throw Error(`Unknown Linux Distribution`);
598
+ }
599
+ return await _updateLinuxMirror(detectedOS, mirror);
600
+ }
601
+ exports.updateLinuxMirrorFile = updateLinuxMirrorFile;
490
602
  //# sourceMappingURL=util.js.map
@@ -39,13 +39,13 @@ var InstallDependenceCommandTypes;
39
39
  (function (InstallDependenceCommandTypes) {
40
40
  InstallDependenceCommandTypes[InstallDependenceCommandTypes["pnpm add -g"] = 0] = "pnpm add -g";
41
41
  InstallDependenceCommandTypes[InstallDependenceCommandTypes["pip3 install --disable-pip-version-check --root-user-action=ignore"] = 1] = "pip3 install --disable-pip-version-check --root-user-action=ignore";
42
- InstallDependenceCommandTypes[InstallDependenceCommandTypes["apt install -y"] = 2] = "apt install -y";
42
+ InstallDependenceCommandTypes[InstallDependenceCommandTypes["apt-get install -y"] = 2] = "apt-get install -y";
43
43
  })(InstallDependenceCommandTypes || (exports.InstallDependenceCommandTypes = InstallDependenceCommandTypes = {}));
44
44
  var GetDependenceCommandTypes;
45
45
  (function (GetDependenceCommandTypes) {
46
46
  GetDependenceCommandTypes[GetDependenceCommandTypes["pnpm ls -g "] = 0] = "pnpm ls -g ";
47
47
  GetDependenceCommandTypes[GetDependenceCommandTypes["pip3 show --disable-pip-version-check"] = 1] = "pip3 show --disable-pip-version-check";
48
- GetDependenceCommandTypes[GetDependenceCommandTypes["apt info"] = 2] = "apt info";
48
+ GetDependenceCommandTypes[GetDependenceCommandTypes["apt-get info"] = 2] = "apt-get info";
49
49
  })(GetDependenceCommandTypes || (exports.GetDependenceCommandTypes = GetDependenceCommandTypes = {}));
50
50
  var versionDependenceCommandTypes;
51
51
  (function (versionDependenceCommandTypes) {
@@ -57,7 +57,7 @@ var unInstallDependenceCommandTypes;
57
57
  (function (unInstallDependenceCommandTypes) {
58
58
  unInstallDependenceCommandTypes[unInstallDependenceCommandTypes["pnpm remove -g"] = 0] = "pnpm remove -g";
59
59
  unInstallDependenceCommandTypes[unInstallDependenceCommandTypes["pip3 uninstall --disable-pip-version-check --root-user-action=ignore -y"] = 1] = "pip3 uninstall --disable-pip-version-check --root-user-action=ignore -y";
60
- unInstallDependenceCommandTypes[unInstallDependenceCommandTypes["apt remove -y"] = 2] = "apt remove -y";
60
+ unInstallDependenceCommandTypes[unInstallDependenceCommandTypes["apt-get remove -y"] = 2] = "apt-get remove -y";
61
61
  })(unInstallDependenceCommandTypes || (exports.unInstallDependenceCommandTypes = unInstallDependenceCommandTypes = {}));
62
62
  exports.DependenceModel = _1.sequelize.define('Dependence', {
63
63
  name: sequelize_1.DataTypes.STRING,
@@ -92,7 +92,14 @@ let CronService = class CronService {
92
92
  options.last_running_time = last_running_time;
93
93
  }
94
94
  for (const id of ids) {
95
- const cron = await this.getDb({ id });
95
+ let cron;
96
+ try {
97
+ cron = await this.getDb({ id });
98
+ }
99
+ catch (err) { }
100
+ if (!cron) {
101
+ continue;
102
+ }
96
103
  if (status === cron_1.CrontabStatus.idle && log_path !== cron.log_path) {
97
104
  options = (0, omit_1.default)(options, ['status', 'log_path', 'pid']);
98
105
  }
@@ -36,6 +36,8 @@ const sequelize_1 = require("sequelize");
36
36
  const util_1 = require("../config/util");
37
37
  const dayjs_1 = __importDefault(require("dayjs"));
38
38
  const pLimit_1 = __importDefault(require("../shared/pLimit"));
39
+ const util_2 = require("../config/util");
40
+ const const_1 = require("../config/const");
39
41
  let DependenceService = class DependenceService {
40
42
  constructor(logger, sockService) {
41
43
  this.logger = logger;
@@ -118,8 +120,18 @@ let DependenceService = class DependenceService {
118
120
  const docs = await dependence_1.DependenceModel.findAll({ where: { id: ids } });
119
121
  for (const doc of docs) {
120
122
  pLimit_1.default.removeQueuedDependency(doc);
121
- const depInstallCommand = dependence_1.InstallDependenceCommandTypes[doc.type];
122
- const depUnInstallCommand = dependence_1.unInstallDependenceCommandTypes[doc.type];
123
+ let depInstallCommand = dependence_1.InstallDependenceCommandTypes[doc.type];
124
+ let depUnInstallCommand = dependence_1.unInstallDependenceCommandTypes[doc.type];
125
+ const isLinuxDependence = doc.type === dependence_1.DependenceTypes.linux;
126
+ if (isLinuxDependence) {
127
+ const osType = await (0, util_2.detectOS)();
128
+ if (!osType) {
129
+ continue;
130
+ }
131
+ const linuxCommand = const_1.LINUX_DEPENDENCE_COMMAND[osType];
132
+ depInstallCommand = linuxCommand.install;
133
+ depUnInstallCommand = linuxCommand.uninstall;
134
+ }
123
135
  const installCmd = `${depInstallCommand} ${doc.name.trim()}`;
124
136
  const unInstallCmd = `${depUnInstallCommand} ${doc.name.trim()}`;
125
137
  const pids = await Promise.all([
@@ -163,6 +175,17 @@ let DependenceService = class DependenceService {
163
175
  if (pLimit_1.default.firstDependencyId !== dependency.id) {
164
176
  return resolve(null);
165
177
  }
178
+ const isNodeDependence = dependency.type === dependence_1.DependenceTypes.nodejs;
179
+ const isLinuxDependence = dependency.type === dependence_1.DependenceTypes.linux;
180
+ const isPythonDependence = dependency.type === dependence_1.DependenceTypes.python3;
181
+ const osType = await (0, util_2.detectOS)();
182
+ let linuxCommand = {};
183
+ if (isLinuxDependence) {
184
+ if (!osType) {
185
+ return resolve(null);
186
+ }
187
+ linuxCommand = const_1.LINUX_DEPENDENCE_COMMAND[osType];
188
+ }
166
189
  pLimit_1.default.removeQueuedDependency(dependency);
167
190
  const depIds = [dependency.id];
168
191
  const status = isInstall
@@ -173,9 +196,14 @@ let DependenceService = class DependenceService {
173
196
  ? 'installDependence'
174
197
  : 'uninstallDependence';
175
198
  let depName = dependency.name.trim();
176
- const depRunCommand = (isInstall
199
+ let depRunCommand = (isInstall
177
200
  ? dependence_1.InstallDependenceCommandTypes
178
201
  : dependence_1.unInstallDependenceCommandTypes)[dependency.type];
202
+ if (isLinuxDependence) {
203
+ depRunCommand = isInstall
204
+ ? linuxCommand.install
205
+ : linuxCommand.uninstall;
206
+ }
179
207
  const actionText = isInstall ? '安装' : '删除';
180
208
  const startTime = (0, dayjs_1.default)();
181
209
  const message = `开始${actionText}依赖 ${depName},开始时间 ${startTime.format('YYYY-MM-DD HH:mm:ss')}\n\n`;
@@ -187,8 +215,11 @@ let DependenceService = class DependenceService {
187
215
  this.updateLog(depIds, message);
188
216
  // 判断是否已经安装过依赖
189
217
  if (isInstall && !force) {
190
- const getCommandPrefix = dependence_1.GetDependenceCommandTypes[dependency.type];
218
+ let getCommandPrefix = dependence_1.GetDependenceCommandTypes[dependency.type];
191
219
  const depVersionStr = dependence_1.versionDependenceCommandTypes[dependency.type];
220
+ if (isLinuxDependence) {
221
+ getCommandPrefix = linuxCommand.info;
222
+ }
192
223
  let depVersion = '';
193
224
  if (depName.includes(depVersionStr)) {
194
225
  const symbolRegx = new RegExp(`(.*)${depVersionStr}([0-9\\.\\-\\+a-zA-Z]*)`);
@@ -198,9 +229,6 @@ let DependenceService = class DependenceService {
198
229
  depVersion = _depVersion;
199
230
  }
200
231
  }
201
- const isNodeDependence = dependency.type === dependence_1.DependenceTypes.nodejs;
202
- const isLinuxDependence = dependency.type === dependence_1.DependenceTypes.linux;
203
- const isPythonDependence = dependency.type === dependence_1.DependenceTypes.python3;
204
232
  const depInfo = (await (0, util_1.promiseExecSuccess)(isNodeDependence
205
233
  ? `${getCommandPrefix} | grep "${depName}" | head -1`
206
234
  : `${getCommandPrefix} ${depName}`))
@@ -209,7 +237,7 @@ let DependenceService = class DependenceService {
209
237
  if (depInfo &&
210
238
  ((isNodeDependence && ((_a = depInfo.split(' ')) === null || _a === void 0 ? void 0 : _a[0]) === depName) ||
211
239
  (isLinuxDependence &&
212
- depInfo.toLocaleLowerCase().includes('apt-manual-installed')) ||
240
+ linuxCommand.check(depInfo.toLocaleLowerCase())) ||
213
241
  isPythonDependence) &&
214
242
  (!depVersion || depInfo.includes(depVersion))) {
215
243
  const endTime = (0, dayjs_1.default)();
@@ -31,6 +31,7 @@ const pLimit_1 = __importDefault(require("../shared/pLimit"));
31
31
  const notify_1 = __importDefault(require("./notify"));
32
32
  const schedule_1 = __importDefault(require("./schedule"));
33
33
  const sock_1 = __importDefault(require("./sock"));
34
+ const util_2 = require("../config/util");
34
35
  let SystemService = class SystemService {
35
36
  constructor(logger, scheduleService, sockService) {
36
37
  this.logger = logger;
@@ -155,20 +156,8 @@ let SystemService = class SystemService {
155
156
  }
156
157
  async updateLinuxMirror(info, res, onEnd) {
157
158
  const oDoc = await this.getSystemConfig();
158
- await this.updateAuthDb(Object.assign(Object.assign({}, oDoc), { info: Object.assign(Object.assign({}, oDoc.info), info) }));
159
- let defaultDomain = 'http://deb.debian.org';
160
- let targetDomain = 'http://deb.debian.org';
161
- const content = await fs_1.default.promises.readFile('/etc/apt/sources.list', {
162
- encoding: 'utf-8',
163
- });
164
- const domainMatch = content.match(/(http.*)\/debian /);
165
- if (domainMatch) {
166
- defaultDomain = domainMatch[1];
167
- }
168
- if (info.linuxMirror) {
169
- targetDomain = info.linuxMirror;
170
- }
171
- const command = `sed -i 's/${defaultDomain.replace(/\//g, '\\/')}/${targetDomain.replace(/\//g, '\\/')}/g' /etc/apt/sources.list && apt update`;
159
+ const command = await (0, util_2.updateLinuxMirrorFile)(info.linuxMirror || '');
160
+ let hasError = false;
172
161
  this.scheduleService.runTask(command, {
173
162
  onStart: async (cp) => {
174
163
  res === null || res === void 0 ? void 0 : res.setHeader('QL-Task-Pid', `${cp.pid}`);
@@ -180,8 +169,12 @@ let SystemService = class SystemService {
180
169
  message: 'update linux mirror end',
181
170
  });
182
171
  onEnd === null || onEnd === void 0 ? void 0 : onEnd();
172
+ if (!hasError) {
173
+ await this.updateAuthDb(Object.assign(Object.assign({}, oDoc), { info: Object.assign(Object.assign({}, oDoc.info), info) }));
174
+ }
183
175
  },
184
176
  onError: async (message) => {
177
+ hasError = true;
185
178
  this.sockService.sendMessage({ type: 'updateLinuxMirror', message });
186
179
  },
187
180
  onLog: async (message) => {
@@ -228,7 +228,7 @@ let UserService = class UserService {
228
228
  async getUserInfo() {
229
229
  const authFileExist = await (0, util_1.fileExist)(config_1.default.authConfigFile);
230
230
  if (!authFileExist) {
231
- await fs.writeFile(config_1.default.authConfigFile, JSON.stringify({
231
+ await (0, util_1.createFile)(config_1.default.authConfigFile, JSON.stringify({
232
232
  username: 'admin',
233
233
  password: 'admin',
234
234
  }));
@@ -10,6 +10,6 @@
10
10
  </head>
11
11
  <body>
12
12
  <div id="root"></div>
13
- <script src="./umi.e3c4ba8e.js"></script>
13
+ <script src="./umi.03b3fd83.js"></script>
14
14
 
15
15
  </body></html>
@@ -0,0 +1 @@
1
+ (self.webpackChunk_whyour_qinglong=self.webpackChunk_whyour_qinglong||[]).push([[6877],{27609:function(e,t,r){"use strict";r.r(t);var n=r(57213),o=r.n(n),i=r(54306),a=r.n(i),u=r(88265),s=r(63313),l=r(67393),c=r(9835),p=r(22159),h=r(24378),f=r(15207),d=r(57229),g=(r(10761),r(99120)),v=r.n(g),b=r(19334),y=r.n(b),m=r(21758),P=r(11527),x={"dependence-proxy":"dependenceProxy","node-mirror":"nodeMirror","python-mirror":"pythonMirror","linux-mirror":"linuxMirror"};t.default=function(){var e=(0,s.useState)(),t=a()(e,2),r=t[0],n=t[1],i=l.Z.useForm(),g=a()(i,1)[0],b=(0,s.useState)(""),Z=a()(b,2),k=Z[0],_=Z[1],w=(0,s.useState)(!1),q=a()(w,2),C=q[0],j=q[1],S=function(e){j(!0),_("in progress...\n"),d.W.put("".concat(f.Z.apiPrefix,"system/config/").concat(e),y()(r,x[e])).then((function(e){})).catch((function(){j(!1),_((function(e){return"".concat(e,"update mirror error")}))}))},B=function(e){j(!0),_(""),d.W.put("".concat(f.Z.apiPrefix,"system/config/").concat(e),y()(r,x[e])).then((function(e){var t=e.code;e.data;200===t&&c.ZP.success(u.ZP.get("更新成功"))})).catch((function(e){console.log(e)})).finally((function(){return j(!1)}))},M=function(e){var t=e.message;_((function(e){return"".concat(e).concat(t)})),(t.includes("update node mirror end")||t.includes("update linux mirror end"))&&j(!1)};return(0,s.useEffect)((function(){var e=m.Z.getInstance();return e.subscribe("updateNodeMirror",M),e.subscribe("updateLinuxMirror",M),function(){e.subscribe("updateNodeMirror",M),e.unsubscribe("updateLinuxMirror",M)}}),[]),(0,s.useEffect)((function(){d.W.get("".concat(f.Z.apiPrefix,"system/config")).then((function(e){var t=e.code,r=e.data;200===t&&r.info&&n(r.info)})).catch((function(e){console.log(e)}))}),[]),(0,P.jsxs)("div",{className:"dependence-config-wrapper",children:[(0,P.jsxs)(l.Z,{layout:"vertical",form:g,style:{flexShrink:0},children:[(0,P.jsx)(l.Z.Item,{label:u.ZP.get("代理"),name:"proxy",extra:u.ZP.get("代理与镜像源二选一即可"),tooltip:{title:u.ZP.get("代理地址, 支持HTTP(S)/SOCK5"),placement:"topLeft"},children:(0,P.jsxs)(p.Z.Group,{compact:!0,children:[(0,P.jsx)(p.Z,{placeholder:"http://1.1.1.1:8080",style:{width:250},value:null==r?void 0:r.dependenceProxy,onChange:function(e){n(o()(o()({},r),{},{dependenceProxy:e.target.value}))}}),(0,P.jsx)(h.Z,{type:"primary",loading:C,onClick:function(){B("dependence-proxy")},style:{width:100},children:u.ZP.get("确认")})]})}),(0,P.jsx)(l.Z.Item,{label:u.ZP.get("Node 软件包镜像源"),name:"node",tooltip:u.ZP.get("NPM 镜像源"),children:(0,P.jsxs)(p.Z.Group,{compact:!0,children:[(0,P.jsx)(p.Z,{style:{width:250},placeholder:"https://registry.npmmirror.com",value:null==r?void 0:r.nodeMirror,onChange:function(e){n(o()(o()({},r),{},{nodeMirror:e.target.value}))}}),(0,P.jsx)(h.Z,{type:"primary",loading:C,onClick:function(){S("node-mirror")},style:{width:100},children:u.ZP.get("确认")})]})}),(0,P.jsx)(l.Z.Item,{label:u.ZP.get("Python 软件包镜像源"),name:"python",tooltip:u.ZP.get("PyPI 镜像源"),children:(0,P.jsxs)(p.Z.Group,{compact:!0,children:[(0,P.jsx)(p.Z,{style:{width:250},placeholder:"https://pypi.doubanio.com/simple/",value:null==r?void 0:r.pythonMirror,onChange:function(e){n(o()(o()({},r),{},{pythonMirror:e.target.value}))}}),(0,P.jsx)(h.Z,{type:"primary",loading:C,onClick:function(){B("python-mirror")},style:{width:100},children:u.ZP.get("确认")})]})}),(0,P.jsx)(l.Z.Item,{label:u.ZP.get("Linux 软件包镜像源"),name:"linux",tooltip:u.ZP.get("debian linux 镜像源"),children:(0,P.jsxs)(p.Z.Group,{compact:!0,children:[(0,P.jsx)(p.Z,{style:{width:250},placeholder:"http://mirrors.aliyun.com",value:null==r?void 0:r.linuxMirror,onChange:function(e){n(o()(o()({},r),{},{linuxMirror:e.target.value}))}}),(0,P.jsx)(h.Z,{type:"primary",loading:C,onClick:function(){S("linux-mirror")},style:{width:100},children:u.ZP.get("确认")})]})})]}),(0,P.jsx)("pre",{style:{fontFamily:"Source Code Pro",zoom:.83,maxHeight:"100%",overflowY:"auto"},children:(0,P.jsx)(v(),{children:k})})]})}},15207:function(e,t,r){"use strict";var n=r(88265),o=window.__ENV__QlBaseUrl||"/";t.Z={siteName:n.ZP.get("青龙"),baseUrl:o,apiPrefix:"".concat(o,"api/"),authKey:"token",layouts:[{name:"primary",include:[/.*/],exclude:[/(\/(en|zh))*\/login/]}],i18n:{languages:[{key:"pt-br",title:"Português",flag:"/portugal.svg"},{key:"en",title:"English",flag:"/america.svg"},{key:"zh",title:n.ZP.get("中文"),flag:"/china.svg"}],defaultLanguage:"en"},scopes:[{name:n.ZP.get("定时任务"),value:"crons"},{name:n.ZP.get("环境变量"),value:"envs"},{name:n.ZP.get("订阅管理"),value:"subscriptions"},{name:n.ZP.get("配置文件"),value:"configs"},{name:n.ZP.get("脚本管理"),value:"scripts"},{name:n.ZP.get("日志管理"),value:"logs"},{name:n.ZP.get("依赖管理"),value:"dependencies"},{name:n.ZP.get("系统信息"),value:"system"}],scopesMap:{crons:n.ZP.get("定时任务"),envs:n.ZP.get("环境变量"),subscriptions:n.ZP.get("订阅管理"),configs:n.ZP.get("配置文件"),scripts:n.ZP.get("脚本管理"),logs:n.ZP.get("日志管理"),dependencies:n.ZP.get("依赖管理"),system:n.ZP.get("系统信息")},notificationModes:[{value:"gotify",label:"Gotify"},{value:"goCqHttpBot",label:"GoCqHttpBot"},{value:"serverChan",label:n.ZP.get("Server酱")},{value:"pushDeer",label:"PushDeer"},{value:"bark",label:"Bark"},{value:"telegramBot",label:n.ZP.get("Telegram机器人")},{value:"dingtalkBot",label:n.ZP.get("钉钉机器人")},{value:"weWorkBot",label:n.ZP.get("企业微信机器人")},{value:"weWorkApp",label:n.ZP.get("企业微信应用")},{value:"aibotk",label:n.ZP.get("智能微秘书")},{value:"iGot",label:"IGot"},{value:"pushPlus",label:"PushPlus"},{value:"wePlusBot",label:n.ZP.get("微加机器人")},{value:"chat",label:n.ZP.get("群晖chat")},{value:"email",label:n.ZP.get("邮箱")},{value:"lark",label:n.ZP.get("飞书机器人")},{value:"pushMe",label:"PushMe"},{value:"chronocat",label:"Chronocat"},{value:"webhook",label:n.ZP.get("自定义通知")},{value:"closed",label:n.ZP.get("已关闭")}],notificationModeMap:{gotify:[{label:"gotifyUrl",tip:n.ZP.get("gotify的url地址,例如 https://push.example.de:8080"),required:!0},{label:"gotifyToken",tip:n.ZP.get("gotify的消息应用token码"),required:!0},{label:"gotifyPriority",tip:n.ZP.get("推送消息的优先级")}],chat:[{label:"chatUrl",tip:n.ZP.get("chat的url地址"),required:!0},{label:"chatToken",tip:n.ZP.get("chat的token码"),required:!0}],goCqHttpBot:[{label:"goCqHttpBotUrl",tip:n.ZP.get("推送到个人QQ: http://127.0.0.1/send_private_msg,群:http://127.0.0.1/send_group_msg"),required:!0},{label:"goCqHttpBotToken",tip:n.ZP.get("访问密钥"),required:!0},{label:"goCqHttpBotQq",tip:n.ZP.get("如果GOBOT_URL设置 /send_private_msg 则需要填入 user_id=个人QQ 相反如果是 /send_group_msg 则需要填入 group_id=QQ群"),required:!0}],serverChan:[{label:"serverChanKey",tip:n.ZP.get("Server酱SENDKEY"),required:!0}],pushDeer:[{label:"pushDeerKey",tip:n.ZP.get("PushDeer的Key,https://github.com/easychen/pushdeer"),required:!0},{label:"pushDeerUrl",tip:n.ZP.get("PushDeer的自架API endpoint,默认是 https://api2.pushdeer.com/message/push")}],bark:[{label:"barkPush",tip:n.ZP.get("Bark的信息IP/设备码,例如:https://api.day.app/XXXXXXXX"),required:!0},{label:"barkIcon",tip:n.ZP.get("BARK推送图标,自定义推送图标 (需iOS15或以上才能显示)")},{label:"barkSound",tip:n.ZP.get("BARK推送铃声,铃声列表去APP查看复制填写")},{label:"barkGroup",tip:n.ZP.get("BARK推送消息的分组,默认为qinglong")},{label:"barkLevel",tip:n.ZP.get("BARK推送消息的时效性,默认为active")},{label:"barkUrl",tip:n.ZP.get("BARK推送消息的跳转URL")},{label:"barkArchive",tip:n.ZP.get("BARK是否保存推送消息")}],telegramBot:[{label:"telegramBotToken",tip:n.ZP.get("telegram机器人的token,例如:1077xxx4424:AAFjv0FcqxxxxxxgEMGfi22B4yh15R5uw"),required:!0},{label:"telegramBotUserId",tip:n.ZP.get("telegram用户的id,例如:129xxx206"),required:!0},{label:"telegramBotProxyHost",tip:n.ZP.get("代理IP")},{label:"telegramBotProxyPort",tip:n.ZP.get("代理端口")},{label:"telegramBotProxyAuth",tip:n.ZP.get("telegram代理配置认证参数,用户名与密码用英文冒号连接 user:password")},{label:"telegramBotApiHost",tip:n.ZP.get("telegram api自建的反向代理地址,默认tg官方api")}],dingtalkBot:[{label:"dingtalkBotToken",tip:n.ZP.get("钉钉机器人webhook token,例如:5a544165465465645d0f31dca676e7bd07415asdasd"),required:!0},{label:"dingtalkBotSecret",tip:n.ZP.get("密钥,机器人安全设置页面,加签一栏下面显示的SEC开头的字符串")}],weWorkBot:[{label:"weWorkBotKey",tip:n.ZP.get("企业微信机器人的webhook(详见文档 https://work.weixin.qq.com/api/doc/90000/90136/91770),例如:693a91f6-7xxx-4bc4-97a0-0ec2sifa5aaa"),required:!0},{label:"weWorkOrigin",tip:n.ZP.get("企业微信代理地址")}],weWorkApp:[{label:"weWorkAppKey",tip:n.ZP.get("corpid、corpsecret、touser(注:多个成员ID使用|隔开)、agentid、消息类型(选填,不填默认文本消息类型) 注意用,号隔开(英文输入法的逗号),例如:wwcfrs,B-76WERQ,qinglong,1000001,2COat"),required:!0},{label:"weWorkOrigin",tip:n.ZP.get("企业微信代理地址")}],aibotk:[{label:"aibotkKey",tip:n.ZP.get("密钥key,智能微秘书个人中心获取apikey,申请地址:https://wechat.aibotk.com/signup?from=ql"),required:!0},{label:"aibotkType",tip:n.ZP.get("发送的目标,群组或者好友"),required:!0,placeholder:n.ZP.get("请输入要发送的目标"),items:[{value:"room",label:n.ZP.get("群聊")},{value:"contact",label:n.ZP.get("好友")}]},{label:"aibotkName",tip:n.ZP.get("要发送的用户昵称或群名,如果目标是群,需要填群名,如果目标是好友,需要填好友昵称"),required:!0}],iGot:[{label:"iGotPushKey",tip:n.ZP.get("iGot的信息推送key,例如:https://push.hellyw.com/XXXXXXXX"),required:!0}],pushPlus:[{label:"pushPlusToken",tip:n.ZP.get("微信扫码登录后一对一推送或一对多推送下面的token(您的Token),不提供PUSH_PLUS_USER则默认为一对一推送,参考 https://www.pushplus.plus/"),required:!0},{label:"pushPlusUser",tip:n.ZP.get("一对多推送的“群组编码”(一对多推送下面->您的群组(如无则创建)->群组编码,如果您是创建群组人。也需点击“查看二维码”扫描绑定,否则不能接受群组消息推送)")}],wePlusBot:[{label:"wePlusBotToken",tip:n.ZP.get("用户令牌,扫描登录后 我的—>设置->令牌 中获取,参考 https://www.weplusbot.com/"),required:!0},{label:"wePlusBotReceiver",tip:n.ZP.get("消息接收人")},{label:"wePlusBotVersion",tip:n.ZP.get("调用版本;专业版填写pro,个人版填写personal,为空默认使用专业版")}],lark:[{label:"larkKey",tip:n.ZP.get("飞书群组机器人:https://www.feishu.cn/hc/zh-CN/articles/360024984973"),required:!0}],email:[{label:"emailService",tip:n.ZP.get("邮箱服务名称,比如126、163、Gmail、QQ等,支持列表https://github.com/nodemailer/nodemailer/blob/master/lib/well-known/services.json"),required:!0},{label:"emailUser",tip:n.ZP.get("邮箱地址"),required:!0},{label:"emailPass",tip:n.ZP.get("SMTP 登录密码,也可能为特殊口令,视具体邮件服务商说明而定"),required:!0}],pushMe:[{label:"pushMeKey",tip:n.ZP.get("PushMe的Key,https://push.i-i.me/"),required:!0},{label:"pushMeUrl",tip:n.ZP.get("自建的PushMeServer消息接口地址,例如:http://127.0.0.1:3010,不填则使用官方消息接口"),required:!1}],chronocat:[{label:"chronocatURL",tip:n.ZP.get("Chronocat Red 服务的连接地址 https://chronocat.vercel.app/install/docker/official/"),required:!0},{label:"chronocatQQ",tip:n.ZP.get("个人:user_id=个人QQ 群则填入group_id=QQ群 多个用英文;隔开同时支持个人和群 如:user_id=xxx;group_id=xxxx;group_id=xxxxx"),required:!0},{label:"chronocatToken",tip:n.ZP.get("docker安装在持久化config目录下的chronocat.yml文件可找到"),required:!0}],webhook:[{label:"webhookMethod",tip:n.ZP.get("请求方法"),required:!0,items:[{value:"GET"},{value:"POST"},{value:"PUT"}]},{label:"webhookContentType",tip:n.ZP.get("请求头Content-Type"),required:!0,items:[{value:"text/plain"},{value:"application/json"},{value:"multipart/form-data"},{value:"application/x-www-form-urlencoded"}]},{label:"webhookUrl",tip:n.ZP.get("请求链接以http或者https开头。url或者body中必须包含$title,$content可选,对应api内容的位置"),required:!0,placeholder:"https://xxx.cn/api?content=$title\n"},{label:"webhookHeaders",tip:n.ZP.get("请求头格式Custom-Header1: Header1,多个换行分割"),placeholder:"Custom-Header1: Header1\nCustom-Header2: Header2"},{label:"webhookBody",tip:n.ZP.get("请求体格式key1: value1,多个换行分割。url或者body中必须包含$title,$content可选,对应api内容的位置"),placeholder:"key1: $title\nkey2: $content"}]},documentTitleMap:{"/login":n.ZP.get("登录"),"/initialization":n.ZP.get("初始化"),"/crontab":n.ZP.get("定时任务"),"/env":n.ZP.get("环境变量"),"/subscription":n.ZP.get("订阅管理"),"/config":n.ZP.get("配置文件"),"/script":n.ZP.get("脚本管理"),"/diff":n.ZP.get("对比工具"),"/log":n.ZP.get("日志管理"),"/setting":n.ZP.get("系统设置"),"/error":n.ZP.get("错误日志"),"/dependence":n.ZP.get("依赖管理")},dependenceTypes:["nodejs","python3","linux"]}},57229:function(e,t,r){"use strict";r.d(t,{W:function(){return g}});var n=r(25359),o=r.n(n),i=r(49811),a=r.n(i),u=r(88265),s=r(9835),l=r(15207),c=r(14851),p=r(73669);s.ZP.config({duration:2});var h=Date.now(),f=p.Z.create({timeout:6e4,params:{t:h}}),d=["/api/user/login","/open/auth/token","/api/user/two-factor/login","/api/system","/api/user/init","/api/user/notification/init"];f.interceptors.request.use((function(e){var t=localStorage.getItem(l.Z.authKey);return t&&!d.includes(e.url)?(e.headers.Authorization="Bearer ".concat(t),e):e})),f.interceptors.response.use(function(){var e=a()(o()().mark((function e(t){var r,n,i;return o()().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r=t.status,![502,504].includes(r)){e.next=5;break}c.history.push("/error"),e.next=18;break;case 5:if(401!==r){e.next=9;break}"/login"!==c.history.location.pathname&&(localStorage.removeItem(l.Z.authKey),c.history.push("/login")),e.next=18;break;case 9:return e.prev=9,200!==(n=t.data).code&&(i=n.message||n.data)&&s.ZP.error({content:i,style:{maxWidth:500,margin:"0 auto"}}),e.abrupt("return",n);case 15:e.prev=15,e.t0=e.catch(9);case 17:case 18:return e.abrupt("return",t);case 19:case"end":return e.stop()}}),e,null,[[9,15]])})));return function(t){return e.apply(this,arguments)}}(),(function(e){if(e.response){var t=e.response.data?e.response.data.message||e.message||e.response.data:e.response.statusText,r=e.response.status;if([502,504].includes(r))c.history.push("/error");else if(401===r)"/login"!==c.history.location.pathname&&(s.ZP.error(u.ZP.get("登录已过期,请重新登录")),localStorage.removeItem(l.Z.authKey),c.history.push("/login"));else{var n,o;if("function"==typeof(null===(n=e.config)||void 0===n?void 0:n.onError))return null===(o=e.config)||void 0===o?void 0:o.onError(e.response);s.ZP.error({content:t,style:{maxWidth:500,margin:"0 auto"}})}}else console.log(e.message);return Promise.reject(e)}));var g=f},21758:function(e,t,r){"use strict";var n=r(93525),o=r.n(n),i=r(12342),a=r.n(i),u=r(25359),s=r.n(u),l=r(49811),c=r.n(l),p=r(21140),h=r.n(p),f=r(63466),d=r.n(f),g=r(52510),v=r.n(g),b=r(78078),y=r.n(b),m=["type"],P=function(){function e(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};h()(this,e),v()(this,"url",void 0),v()(this,"socket",null),v()(this,"subscriptions",new Map),v()(this,"options",void 0),v()(this,"reconnectAttempts",0),v()(this,"heartbeatTimeout",null),v()(this,"state","closed"),this.url=t,this.options={maxReconnectAttempts:r.maxReconnectAttempts||5,reconnectInterval:r.reconnectInterval||3e3,heartbeatInterval:r.heartbeatInterval||3e4},this.init()}var t,r;return d()(e,[{key:"init",value:(r=c()(s()().mark((function e(){var t=this;return s()().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:e.prev=0,this.state="connecting",this.emit("connecting");case 3:if(!(this.reconnectAttempts<this.options.maxReconnectAttempts)){e.next=16;break}return this.socket=new(y())(this.url),this.setupEventListeners(),this.startHeartbeat(),e.next=9,this.waitForClose();case 9:return this.stopHeartbeat(),this.socket=null,this.reconnectAttempts++,e.next=14,new Promise((function(e){return setTimeout(e,t.options.reconnectInterval)}));case 14:e.next=3;break;case 16:e.next=21;break;case 18:e.prev=18,e.t0=e.catch(0),this.handleError(e.t0);case 21:case"end":return e.stop()}}),e,this,[[0,18]])}))),function(){return r.apply(this,arguments)})},{key:"setupEventListeners",value:function(){var e=this;this.socket&&(this.socket.onopen=function(){e.state="open",e.emit("open")},this.socket.onmessage=function(t){var r=JSON.parse(t.data);e.dispatchMessage(r)},this.socket.onclose=function(){e.state="closed",e.emit("close")})}},{key:"waitForClose",value:(t=c()(s()().mark((function e(){var t;return s()().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if((null===(t=this.socket)||void 0===t?void 0:t.readyState)===y().CLOSED){e.next=5;break}return e.next=3,new Promise((function(e){return setTimeout(e,100)}));case 3:e.next=0;break;case 5:case"end":return e.stop()}}),e,this)}))),function(){return t.apply(this,arguments)})},{key:"subscribe",value:function(e,t){var r=this.subscriptions.get(e)||new Set;if(!r.has(t)){r.add(t),this.subscriptions.set(e,r);var n={action:"subscribe",topic:e};this.send(n)}}},{key:"unsubscribe",value:function(e,t){var r=this.subscriptions.get(e)||new Set;if(r.has(t)){r.delete(t);var n={action:"unsubscribe",topic:e};this.send(n)}}},{key:"send",value:function(e){var t;(null===(t=this.socket)||void 0===t?void 0:t.readyState)===y().OPEN&&this.socket.send(JSON.stringify(e))}},{key:"dispatchMessage",value:function(e){var t=e.type,r=a()(e,m),n=this.subscriptions.get(t)||new Set;o()(n).forEach((function(e){return e(r)}))}},{key:"startHeartbeat",value:function(){var e=this;this.heartbeatTimeout=setInterval((function(){var t;(null===(t=e.socket)||void 0===t?void 0:t.readyState)===y().OPEN&&e.socket.send(JSON.stringify({type:"heartbeat"}))}),this.options.heartbeatInterval)}},{key:"stopHeartbeat",value:function(){this.heartbeatTimeout&&clearInterval(this.heartbeatTimeout)}},{key:"close",value:function(){this.socket&&(this.state="closed",this.stopHeartbeat(),this.socket.close(),this.emit("close"))}},{key:"handleError",value:function(e){console.error("WebSocket错误:",e),this.emit("error",e)}},{key:"on",value:function(e,t){}},{key:"emit",value:function(e,t){}}],[{key:"getInstance",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",r=arguments.length>1?arguments[1]:void 0;return e.instance||(e.instance=new e(t,r)),e.instance}}]),e}();v()(P,"instance",null),t.Z=P},10761:function(){},68098:function(e,t,r){"use strict";r.d(t,{fk:function(){return a},jD:function(){return i}});var n,o=r(46594),i=function(){return(0,o.Z)()&&window.document.documentElement},a=function(){if(!i())return!1;if(void 0!==n)return n;var e=document.createElement("div");return e.style.display="flex",e.style.flexDirection="column",e.style.rowGap="1px",e.appendChild(document.createElement("div")),e.appendChild(document.createElement("div")),document.body.appendChild(e),n=1===e.scrollHeight,document.body.removeChild(e),n}},88987:function(e,t,r){var n=r(71519),o=r(82999),i=r(76111),a=r(50506),u=r(80845);function s(e){var t=-1,r=null==e?0:e.length;for(this.clear();++t<r;){var n=e[t];this.set(n[0],n[1])}}s.prototype.clear=n,s.prototype.delete=o,s.prototype.get=i,s.prototype.has=a,s.prototype.set=u,e.exports=s},175:function(e,t,r){var n=r(2173),o=r(33752),i=r(10548),a=r(63410),u=r(3564);function s(e){var t=-1,r=null==e?0:e.length;for(this.clear();++t<r;){var n=e[t];this.set(n[0],n[1])}}s.prototype.clear=n,s.prototype.delete=o,s.prototype.get=i,s.prototype.has=a,s.prototype.set=u,e.exports=s},35922:function(e,t,r){var n=r(47758)(r(29165),"Map");e.exports=n},9440:function(e,t,r){var n=r(7140),o=r(56504),i=r(88833),a=r(80953),u=r(70724);function s(e){var t=-1,r=null==e?0:e.length;for(this.clear();++t<r;){var n=e[t];this.set(n[0],n[1])}}s.prototype.clear=n,s.prototype.delete=o,s.prototype.get=i,s.prototype.has=a,s.prototype.set=u,e.exports=s},93501:function(e){e.exports=function(e,t,r){switch(r.length){case 0:return e.call(t);case 1:return e.call(t,r[0]);case 2:return e.call(t,r[0],r[1]);case 3:return e.call(t,r[0],r[1],r[2])}return e.apply(t,r)}},75697:function(e){e.exports=function(e,t){for(var r=-1,n=null==e?0:e.length,o=Array(n);++r<n;)o[r]=t(e[r],r,e);return o}},28486:function(e){e.exports=function(e,t){for(var r=-1,n=t.length,o=e.length;++r<n;)e[o+r]=t[r];return e}},93719:function(e,t,r){var n=r(30404),o=r(42448),i=Object.prototype.hasOwnProperty;e.exports=function(e,t,r){var a=e[t];i.call(e,t)&&o(a,r)&&(void 0!==r||t in e)||n(e,t,r)}},62718:function(e,t,r){var n=r(42448);e.exports=function(e,t){for(var r=e.length;r--;)if(n(e[r][0],t))return r;return-1}},30404:function(e,t,r){var n=r(34082);e.exports=function(e,t,r){"__proto__"==t&&n?n(e,t,{configurable:!0,enumerable:!0,value:r,writable:!0}):e[t]=r}},98768:function(e,t,r){var n=r(28486),o=r(89465);e.exports=function e(t,r,i,a,u){var s=-1,l=t.length;for(i||(i=o),u||(u=[]);++s<l;){var c=t[s];r>0&&i(c)?r>1?e(c,r-1,i,a,u):n(u,c):a||(u[u.length]=c)}return u}},97499:function(e,t,r){var n=r(60399),o=r(77817);e.exports=function(e,t){for(var r=0,i=(t=n(t,e)).length;null!=e&&r<i;)e=e[o(t[r++])];return r&&r==i?e:void 0}},71664:function(e){e.exports=function(e,t){return null!=e&&t in Object(e)}},84742:function(e,t,r){var n=r(80732),o=r(55073);e.exports=function(e){return o(e)&&"[object Arguments]"==n(e)}},58939:function(e,t,r){var n=r(92042),o=r(90654),i=r(36838),a=r(51059),u=/^\[object .+?Constructor\]$/,s=Function.prototype,l=Object.prototype,c=s.toString,p=l.hasOwnProperty,h=RegExp("^"+c.call(p).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");e.exports=function(e){return!(!i(e)||o(e))&&(n(e)?h:u).test(a(e))}},54822:function(e,t,r){var n=r(32648),o=r(28281);e.exports=function(e,t){return n(e,t,(function(t,r){return o(e,r)}))}},32648:function(e,t,r){var n=r(97499),o=r(85713),i=r(60399);e.exports=function(e,t,r){for(var a=-1,u=t.length,s={};++a<u;){var l=t[a],c=n(e,l);r(c,l)&&o(s,i(l,e),c)}return s}},85713:function(e,t,r){var n=r(93719),o=r(60399),i=r(91010),a=r(36838),u=r(77817);e.exports=function(e,t,r,s){if(!a(e))return e;for(var l=-1,c=(t=o(t,e)).length,p=c-1,h=e;null!=h&&++l<c;){var f=u(t[l]),d=r;if("__proto__"===f||"constructor"===f||"prototype"===f)return e;if(l!=p){var g=h[f];void 0===(d=s?s(g,f,h):void 0)&&(d=a(g)?g:i(t[l+1])?[]:{})}n(h,f,d),h=h[f]}return e}},56447:function(e,t,r){var n=r(64806),o=r(34082),i=r(48148),a=o?function(e,t){return o(e,"toString",{configurable:!0,enumerable:!1,value:n(t),writable:!0})}:i;e.exports=a},73150:function(e,t,r){var n=r(74396),o=r(75697),i=r(24669),a=r(16764),u=n?n.prototype:void 0,s=u?u.toString:void 0;e.exports=function e(t){if("string"==typeof t)return t;if(i(t))return o(t,e)+"";if(a(t))return s?s.call(t):"";var r=t+"";return"0"==r&&1/t==-Infinity?"-0":r}},60399:function(e,t,r){var n=r(24669),o=r(2610),i=r(77057),a=r(8389);e.exports=function(e,t){return n(e)?e:o(e,t)?[e]:i(a(e))}},36633:function(e,t,r){var n=r(29165)["__core-js_shared__"];e.exports=n},34082:function(e,t,r){var n=r(47758),o=function(){try{var e=n(Object,"defineProperty");return e({},"",{}),e}catch(e){}}();e.exports=o},54874:function(e,t,r){var n=r(22612),o=r(20323),i=r(71564);e.exports=function(e){return i(o(e,void 0,n),e+"")}},67707:function(e,t,r){var n=r(3880);e.exports=function(e,t){var r=e.__data__;return n(t)?r["string"==typeof t?"string":"hash"]:r.map}},47758:function(e,t,r){var n=r(58939),o=r(9149);e.exports=function(e,t){var r=o(e,t);return n(r)?r:void 0}},9149:function(e){e.exports=function(e,t){return null==e?void 0:e[t]}},18554:function(e,t,r){var n=r(60399),o=r(30353),i=r(24669),a=r(91010),u=r(17216),s=r(77817);e.exports=function(e,t,r){for(var l=-1,c=(t=n(t,e)).length,p=!1;++l<c;){var h=s(t[l]);if(!(p=null!=e&&r(e,h)))break;e=e[h]}return p||++l!=c?p:!!(c=null==e?0:e.length)&&u(c)&&a(h,c)&&(i(e)||o(e))}},71519:function(e,t,r){var n=r(37722);e.exports=function(){this.__data__=n?n(null):{},this.size=0}},82999:function(e){e.exports=function(e){var t=this.has(e)&&delete this.__data__[e];return this.size-=t?1:0,t}},76111:function(e,t,r){var n=r(37722),o=Object.prototype.hasOwnProperty;e.exports=function(e){var t=this.__data__;if(n){var r=t[e];return"__lodash_hash_undefined__"===r?void 0:r}return o.call(t,e)?t[e]:void 0}},50506:function(e,t,r){var n=r(37722),o=Object.prototype.hasOwnProperty;e.exports=function(e){var t=this.__data__;return n?void 0!==t[e]:o.call(t,e)}},80845:function(e,t,r){var n=r(37722);e.exports=function(e,t){var r=this.__data__;return this.size+=this.has(e)?0:1,r[e]=n&&void 0===t?"__lodash_hash_undefined__":t,this}},89465:function(e,t,r){var n=r(74396),o=r(30353),i=r(24669),a=n?n.isConcatSpreadable:void 0;e.exports=function(e){return i(e)||o(e)||!!(a&&e&&e[a])}},91010:function(e){var t=/^(?:0|[1-9]\d*)$/;e.exports=function(e,r){var n=typeof e;return!!(r=null==r?9007199254740991:r)&&("number"==n||"symbol"!=n&&t.test(e))&&e>-1&&e%1==0&&e<r}},2610:function(e,t,r){var n=r(24669),o=r(16764),i=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,a=/^\w*$/;e.exports=function(e,t){if(n(e))return!1;var r=typeof e;return!("number"!=r&&"symbol"!=r&&"boolean"!=r&&null!=e&&!o(e))||(a.test(e)||!i.test(e)||null!=t&&e in Object(t))}},3880:function(e){e.exports=function(e){var t=typeof e;return"string"==t||"number"==t||"symbol"==t||"boolean"==t?"__proto__"!==e:null===e}},90654:function(e,t,r){var n,o=r(36633),i=(n=/[^.]+$/.exec(o&&o.keys&&o.keys.IE_PROTO||""))?"Symbol(src)_1."+n:"";e.exports=function(e){return!!i&&i in e}},2173:function(e){e.exports=function(){this.__data__=[],this.size=0}},33752:function(e,t,r){var n=r(62718),o=Array.prototype.splice;e.exports=function(e){var t=this.__data__,r=n(t,e);return!(r<0)&&(r==t.length-1?t.pop():o.call(t,r,1),--this.size,!0)}},10548:function(e,t,r){var n=r(62718);e.exports=function(e){var t=this.__data__,r=n(t,e);return r<0?void 0:t[r][1]}},63410:function(e,t,r){var n=r(62718);e.exports=function(e){return n(this.__data__,e)>-1}},3564:function(e,t,r){var n=r(62718);e.exports=function(e,t){var r=this.__data__,o=n(r,e);return o<0?(++this.size,r.push([e,t])):r[o][1]=t,this}},7140:function(e,t,r){var n=r(88987),o=r(175),i=r(35922);e.exports=function(){this.size=0,this.__data__={hash:new n,map:new(i||o),string:new n}}},56504:function(e,t,r){var n=r(67707);e.exports=function(e){var t=n(this,e).delete(e);return this.size-=t?1:0,t}},88833:function(e,t,r){var n=r(67707);e.exports=function(e){return n(this,e).get(e)}},80953:function(e,t,r){var n=r(67707);e.exports=function(e){return n(this,e).has(e)}},70724:function(e,t,r){var n=r(67707);e.exports=function(e,t){var r=n(this,e),o=r.size;return r.set(e,t),this.size+=r.size==o?0:1,this}},45171:function(e,t,r){var n=r(34736);e.exports=function(e){var t=n(e,(function(e){return 500===r.size&&r.clear(),e})),r=t.cache;return t}},37722:function(e,t,r){var n=r(47758)(Object,"create");e.exports=n},20323:function(e,t,r){var n=r(93501),o=Math.max;e.exports=function(e,t,r){return t=o(void 0===t?e.length-1:t,0),function(){for(var i=arguments,a=-1,u=o(i.length-t,0),s=Array(u);++a<u;)s[a]=i[t+a];a=-1;for(var l=Array(t+1);++a<t;)l[a]=i[a];return l[t]=r(s),n(e,this,l)}}},71564:function(e,t,r){var n=r(56447),o=r(15509)(n);e.exports=o},15509:function(e){var t=Date.now;e.exports=function(e){var r=0,n=0;return function(){var o=t(),i=16-(o-n);if(n=o,i>0){if(++r>=800)return arguments[0]}else r=0;return e.apply(void 0,arguments)}}},77057:function(e,t,r){var n=r(45171),o=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,i=/\\(\\)?/g,a=n((function(e){var t=[];return 46===e.charCodeAt(0)&&t.push(""),e.replace(o,(function(e,r,n,o){t.push(n?o.replace(i,"$1"):r||e)})),t}));e.exports=a},77817:function(e,t,r){var n=r(16764);e.exports=function(e){if("string"==typeof e||n(e))return e;var t=e+"";return"0"==t&&1/e==-Infinity?"-0":t}},51059:function(e){var t=Function.prototype.toString;e.exports=function(e){if(null!=e){try{return t.call(e)}catch(e){}try{return e+""}catch(e){}}return""}},64806:function(e){e.exports=function(e){return function(){return e}}},42448:function(e){e.exports=function(e,t){return e===t||e!=e&&t!=t}},22612:function(e,t,r){var n=r(98768);e.exports=function(e){return(null==e?0:e.length)?n(e,1):[]}},28281:function(e,t,r){var n=r(71664),o=r(18554);e.exports=function(e,t){return null!=e&&o(e,t,n)}},48148:function(e){e.exports=function(e){return e}},30353:function(e,t,r){var n=r(84742),o=r(55073),i=Object.prototype,a=i.hasOwnProperty,u=i.propertyIsEnumerable,s=n(function(){return arguments}())?n:function(e){return o(e)&&a.call(e,"callee")&&!u.call(e,"callee")};e.exports=s},24669:function(e){var t=Array.isArray;e.exports=t},92042:function(e,t,r){var n=r(80732),o=r(36838);e.exports=function(e){if(!o(e))return!1;var t=n(e);return"[object Function]"==t||"[object GeneratorFunction]"==t||"[object AsyncFunction]"==t||"[object Proxy]"==t}},17216:function(e){e.exports=function(e){return"number"==typeof e&&e>-1&&e%1==0&&e<=9007199254740991}},34736:function(e,t,r){var n=r(9440);function o(e,t){if("function"!=typeof e||null!=t&&"function"!=typeof t)throw new TypeError("Expected a function");var r=function(){var n=arguments,o=t?t.apply(this,n):n[0],i=r.cache;if(i.has(o))return i.get(o);var a=e.apply(this,n);return r.cache=i.set(o,a)||i,a};return r.cache=new(o.Cache||n),r}o.Cache=n,e.exports=o},19334:function(e,t,r){var n=r(54822),o=r(54874)((function(e,t){return null==e?{}:n(e,t)}));e.exports=o},8389:function(e,t,r){var n=r(73150);e.exports=function(e){return null==e?"":n(e)}}}]);