/content Mounted at /content/drive env: PYTHONDONTWRITEBYTECODE=1 env: TF_CPP_MIN_LOG_LEVEL=1 41 packages can be upgraded. Run 'apt list --upgradable' to see them. W: Skipping acquire of configured file 'main/source/Sources' as repository 'https://r2u.stat.illinois.edu/ubuntu jammy InRelease' does not seem to provide it (sources.list entry misspelt?) --2025-07-10 10:55:32-- https://github.com/camenduru/gperftools/releases/download/v1.0/libtcmalloc_minimal.so.4 Resolving github.com (github.com)... 140.82.116.3 Connecting to github.com (github.com)|140.82.116.3|:443... connected. HTTP request sent, awaiting response... 302 Found Location: https://objects.githubusercontent.com/github-production-release-asset-2e65be/669786276/620e2e64-be9f-4599-904f-18ee3811e159?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=releaseassetproduction%2F20250710%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20250710T105532Z&X-Amz-Expires=1800&X-Amz-Signature=bb1f7de0303e274aac8be586bd68cbd25ac9e9ff9fed7f3202a91d76ba59a4a7&X-Amz-SignedHeaders=host&response-content-disposition=attachment%3B%20filename%3Dlibtcmalloc_minimal.so.4&response-content-type=application%2Foctet-stream [following] --2025-07-10 10:55:32-- https://objects.githubusercontent.com/github-production-release-asset-2e65be/669786276/620e2e64-be9f-4599-904f-18ee3811e159?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=releaseassetproduction%2F20250710%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20250710T105532Z&X-Amz-Expires=1800&X-Amz-Signature=bb1f7de0303e274aac8be586bd68cbd25ac9e9ff9fed7f3202a91d76ba59a4a7&X-Amz-SignedHeaders=host&response-content-disposition=attachment%3B%20filename%3Dlibtcmalloc_minimal.so.4&response-content-type=application%2Foctet-stream Resolving objects.githubusercontent.com (objects.githubusercontent.com)... 185.199.108.133, 185.199.109.133, 185.199.110.133, ... Connecting to objects.githubusercontent.com (objects.githubusercontent.com)|185.199.108.133|:443... connected. HTTP request sent, awaiting re

时间: 2025-07-22 18:50:05 AIGC 浏览: 39
<think>我们正在处理用户关于在Ubuntu环境中下载libtcmalloc_minimal.so.4失败及修复仓库配置错误的问题。 根据用户描述,可能涉及网络请求、GitHub资源获取或系统环境配置问题,同时用户可能遇到了软件包升级提示和仓库配置问题。 步骤: 1. 首先,尝试使用系统包管理器安装包含所需库的软件包。 2. 如果包管理器无法直接安装,则考虑手动下载并配置。 3. 修复仓库配置错误,确保包管理器正常工作。 具体步骤: 第一步:使用apt安装 在Ubuntu中,libtcmalloc_minimal.so.4通常由google-perftools或tcmalloc包提供。我们可以尝试安装: sudo apt update sudo apt install libgoogle-perftools4 但是,如果遇到仓库配置错误,我们需要先修复仓库配置。 修复仓库配置: 1. 检查/etc/apt/sources.list文件中的仓库地址是否正确。可以尝试使用官方的Ubuntu仓库镜像。 2. 运行`sudo apt update`查看错误信息,根据错误信息调整仓库配置。 3. 常见的错误包括:仓库地址不可达、仓库地址拼写错误、使用了不再支持的Ubuntu版本等。 如果第一步安装成功,则问题解决。如果包管理器找不到该软件包,则进入第二步。 第二步:手动下载 我们可以从可信的来源(如官方GitHub仓库或Ubuntu软件包仓库)手动下载该库文件。 例如,从Ubuntu软件包仓库下载: 1. 访问 https://packages.ubuntu.com/ ,搜索“libgoogle-perftools4”或“tcmalloc”。 2. 选择与你的Ubuntu版本匹配的包。 3. 下载对应的.deb文件(例如:libgoogle-perftools4_<version>_<arch>.deb)。 4. 安装:sudo dpkg -i /path/to/package.deb 如果下载.deb文件后安装时遇到依赖问题,可以运行: sudo apt-get install -f 第三步:从源代码构建(如果必要) 如果以上方法都不行,可以考虑从源代码构建。但通常不推荐,因为系统库的管理会变得复杂。 构建步骤: 1. 安装构建依赖:sudo apt install autoconf automake libtool 2. 从GitHub克隆gperftools仓库:git clone https://github.com/gperftools/gperftools.git 3. 进入目录,执行:./autogen.sh && ./configure && make 4. 然后,在生成的.so文件中找到libtcmalloc_minimal.so.4,将其复制到系统库目录(如/usr/local/lib)并运行ldconfig。 注意:手动构建和安装库文件可能会影响系统稳定性,建议优先使用包管理器。 关于仓库配置错误的修复,具体步骤可能包括: 1. 备份/etc/apt/sources.list文件。 2. 编辑sources.list,注释掉有问题的行,并添加正确的镜像源(例如,使用阿里云、清华镜像等)。 3. 运行sudo apt update检查是否成功。 例如,替换为阿里源(以Ubuntu 20.04为例): sudo sed -i 's/archive.ubuntu.com/mirrors.aliyun.com/g' /etc/apt/sources.list sudo sed -i 's/security.ubuntu.com/mirrors.aliyun.com/g' /etc/apt/sources.list 然后运行sudo apt update。 如果问题仍然存在,请检查网络设置、代理设置等。 最后,确保用户的环境变量(如LD_LIBRARY_PATH)包含该库的路径(如果手动安装到非标准路径)。 生成相关问题: 根据用户可能遇到的后续问题,我们生成以下问题: 1. 如何设置LD_LIBRARY_PATH环境变量? 2. 如何检查动态库是否被正确加载? 3. 如何卸载通过dpkg安装的软件包? 4. 如何添加第三方仓库并安装软件包? 5. 如何解决apt更新时的GPG错误? 6. 如何从源代码构建并安装gperftools?</think>### 解决 Ubuntu 中下载 libtcmalloc_minimal.so.4 失败及仓库配置错误 #### 步骤 1:修复仓库配置错误 当出现 `Repository '...' changed its ...` 错误时,需更新仓库证书: ```bash sudo apt update sudo apt install --reinstall ca-certificates sudo update-ca-certificates sudo apt clean sudo rm -rf /var/lib/apt/lists/* sudo apt update # 重新测试更新 ``` 若问题持续,检查 `/etc/apt/sources.list` 中的镜像源是否有效,建议替换为阿里云或清华镜像源[^1]。 #### 步骤 2:安装 libtcmalloc_minimal.so.4 该库包含在 `libgoogle-perftools4` 包中: ```bash sudo apt update sudo apt install libgoogle-perftools4 # 安装主包 ``` 验证安装: ```bash ls /usr/lib/x86_64-linux-gnu/libtcmalloc_minimal.so.4* # 确认库文件存在 ``` #### 步骤 3:手动下载(若 apt 失败) 从 Ubuntu 仓库直接下载: ```bash wget http://archive.ubuntu.com/ubuntu/pool/main/g/gperftools/libgoogle-perftools4_2.9.1-0.1_amd64.deb sudo dpkg -i libgoogle-perftools4_*.deb ``` 或从 GitHub 获取: ```bash wget https://github.com/gperftools/gperftools/releases/download/gperftools-2.10/libgoogle-perftools4_2.10-1_amd64.deb sudo dpkg -i libgoogle-perftools4_*.deb ``` #### 步骤 4:配置动态链接 确保系统识别库文件: ```bash sudo ldconfig # 更新库缓存 export LD_PRELOAD=/usr/lib/x86_64-linux-gnu/libtcmalloc_minimal.so.4 # 临时生效 ``` 永久生效:在 `/etc/environment` 添加: ```ini LD_PRELOAD="/usr/lib/x86_64-linux-gnu/libtcmalloc_minimal.so.4" ``` #### 常见问题排查 - **依赖错误**:运行 `sudo apt install -f` 修复依赖 - **证书失效**:更新系统时间 `sudo apt install ntpdate && sudo ntpdate pool.ntp.org` - **架构不匹配**:确认系统架构(`uname -m`),选择对应 .deb 包
阅读全文

相关推荐

/content Mounted at /content/drive env: PYTHONDONTWRITEBYTECODE=1 env: TF_CPP_MIN_LOG_LEVEL=1 41 packages can be upgraded. Run 'apt list --upgradable' to see them. W: Skipping acquire of configured file 'main/source/Sources' as repository 'https://r2u.stat.illinois.edu/ubuntu jammy InRelease' does not seem to provide it (sources.list entry misspelt?) --2025-07-10 10:19:00-- https://github.com/camenduru/gperftools/releases/download/v1.0/libtcmalloc_minimal.so.4 Resolving github.com (github.com)... 140.82.113.4 Connecting to github.com (github.com)|140.82.113.4|:443... connected. HTTP request sent, awaiting response... 302 Found Location: https://objects.githubusercontent.com/github-production-release-asset-2e65be/669786276/620e2e64-be9f-4599-904f-18ee3811e159?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=releaseassetproduction%2F20250710%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20250710T101901Z&X-Amz-Expires=1800&X-Amz-Signature=b5c26ca3d158bb5b88d2b09125b067e065003244102eeb42a1d86a5fc1b6c62e&X-Amz-SignedHeaders=host&response-content-disposition=attachment%3B%20filename%3Dlibtcmalloc_minimal.so.4&response-content-type=application%2Foctet-stream [following] --2025-07-10 10:19:01-- https://objects.githubusercontent.com/github-production-release-asset-2e65be/669786276/620e2e64-be9f-4599-904f-18ee3811e159?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=releaseassetproduction%2F20250710%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20250710T101901Z&X-Amz-Expires=1800&X-Amz-Signature=b5c26ca3d158bb5b88d2b09125b067e065003244102eeb42a1d86a5fc1b6c62e&X-Amz-SignedHeaders=host&response-content-disposition=attachment%3B%20filename%3Dlibtcmalloc_minimal.so.4&response-content-type=application%2Foctet-stream Resolving objects.githubusercontent.com (objects.githubusercontent.com)... 185.199.108.133, 185.199.109.133, 185.199.110.133, ... Connecting to objects.githubusercontent.com (objects.githubusercontent.com)|185.199.108.133|:443... connected. HTTP request sent, awaiting response... 200 OK Length: 373960 (365K) [application/octet-stream] Saving to: ‘/content/libtcmalloc_minimal.so.4’ /content/libtcmallo 100%[===================>] 365.20K --.-KB/s in 0.02s 2025-07-10 10:19:01 (15.2 MB/s) - ‘/content/libtcmalloc_minimal.so.4’ saved [373960/373960] env: LD_PRELOAD=/content/libtcmalloc_minimal.so.4 libcairo2-dev is already the newest version (1.16.0-5ubuntu2). python3-dev is already the newest version (3.10.6-1~22.04.1). python3-dev set to manually installed. The following packages were automatically installed and are no longer required: libbz2-dev libpkgconf3 libreadline-dev Use 'apt autoremove' to remove them. The following packages will be REMOVED: pkgconf r-base-dev The following NEW packages will be installed: aria2 libaria2-0 libc-ares2 pkg-config 0 upgraded, 4 newly installed, 2 to remove and 41 not upgraded. Need to get 1,561 kB of archives. After this operation, 5,430 kB of additional disk space will be used. (Reading database ... 126281 files and directories currently installed.) Removing r-base-dev (4.5.1-1.2204.0) ... dpkg: pkgconf: dependency problems, but removing anyway as you requested: libsndfile1-dev:amd64 depends on pkg-config; however: Package pkg-config is not installed. Package pkgconf which provides pkg-config is to be removed. libopencv-dev depends on pkg-config; however: Package pkg-config is not installed. Package pkgconf which provides pkg-config is to be removed. libmkl-dev:amd64 depends on pkg-config; however: Package pkg-config is not installed. Package pkgconf which provides pkg-config is to be removed. libjack-dev depends on pkg-config; however: Package pkg-config is not installed. Package pkgconf which provides pkg-config is to be removed. libgphoto2-dev:amd64 depends on pkg-config; however: Package pkg-config is not installed. Package pkgconf which provides pkg-config is to be removed. libglib2.0-dev:amd64 depends on pkg-config; however: Package pkg-config is not installed. Package pkgconf which provides pkg-config is to be removed. libfontconfig-dev:amd64 depends on pkg-config; however: Package pkg-config is not installed. Package pkgconf which provides pkg-config is to be removed. Removing pkgconf (1.8.0-1) ... Removing 'diversion of /usr/bin/pkg-config to /usr/bin/pkg-config.real by pkgconf' Removing 'diversion of /usr/share/aclocal/pkg.m4 to /usr/share/aclocal/pkg.real.m4 by pkgconf' Removing 'diversion of /usr/share/man/man1/pkg-config.1.gz to /usr/share/man/man1/pkg-config.real.1.gz by pkgconf' Removing 'diversion of /usr/share/pkg-config-crosswrapper to /usr/share/pkg-config-crosswrapper.real by pkgconf' Selecting previously unselected package pkg-config. (Reading database ... 126257 files and directories currently installed.) Preparing to unpack .../pkg-config_0.29.2-1ubuntu3_amd64.deb ... Unpacking pkg-config (0.29.2-1ubuntu3) ... Selecting previously unselected package libc-ares2:amd64. Preparing to unpack .../libc-ares2_1.18.1-1ubuntu0.22.04.3_amd64.deb ... Unpacking libc-ares2:amd64 (1.18.1-1ubuntu0.22.04.3) ... Selecting previously unselected package libaria2-0:amd64. Preparing to unpack .../libaria2-0_1.36.0-1_amd64.deb ... Unpacking libaria2-0:amd64 (1.36.0-1) ... Selecting previously unselected package aria2. Preparing to unpack .../aria2_1.36.0-1_amd64.deb ... Unpacking aria2 (1.36.0-1) ... Setting up libc-ares2:amd64 (1.18.1-1ubuntu0.22.04.3) ... Setting up pkg-config (0.29.2-1ubuntu3) ... Setting up libaria2-0:amd64 (1.36.0-1) ... Setting up aria2 (1.36.0-1) ... Processing triggers for man-db (2.10.2-1) ... Processing triggers for libc-bin (2.35-0ubuntu3.8) ... /sbin/ldconfig.real: /usr/local/lib/libtcm_debug.so.1 is not a symbolic link /sbin/ldconfig.real: /usr/local/lib/libtbbbind_2_0.so.3 is not a symbolic link /sbin/ldconfig.real: /usr/local/lib/libur_adapter_opencl.so.0 is not a symbolic link /sbin/ldconfig.real: /usr/local/lib/libtbbmalloc.so.2 is not a symbolic link /sbin/ldconfig.real: /usr/local/lib/libtbb.so.12 is not a symbolic link /sbin/ldconfig.real: /usr/local/lib/libtbbbind.so.3 is not a symbolic link /sbin/ldconfig.real: /usr/local/lib/libur_loader.so.0 is not a symbolic link /sbin/ldconfig.real: /usr/local/lib/libtbbbind_2_5.so.3 is not a symbolic link /sbin/ldconfig.real: /usr/local/lib/libhwloc.so.15 is not a symbolic link /sbin/ldconfig.real: /usr/local/lib/libur_adapter_level_zero.so.0 is not a symbolic link /sbin/ldconfig.real: /usr/local/lib/libumf.so.0 is not a symbolic link /sbin/ldconfig.real: /usr/local/lib/libtbbmalloc_proxy.so.2 is not a symbolic link /sbin/ldconfig.real: /usr/local/lib/libur_adapter_level_zero_v2.so.0 is not a symbolic link /sbin/ldconfig.real: /usr/local/lib/libtcm.so.1 is not a symbolic link The following packages were automatically installed and are no longer required: libbz2-dev libpkgconf3 libreadline-dev Use 'apt autoremove' to remove them. The following NEW packages will be installed: unionfs-fuse 0 upgraded, 1 newly installed, 0 to remove and 41 not upgraded. Need to get 48.7 kB of archives. After this operation, 146 kB of additional disk space will be used. Selecting previously unselected package unionfs-fuse. (Reading database ... 126346 files and directories currently installed.) Preparing to unpack .../unionfs-fuse_1.0-1ubuntu2_amd64.deb ... Unpacking unionfs-fuse (1.0-1ubuntu2) ... Setting up unionfs-fuse (1.0-1ubuntu2) ... Processing triggers for man-db (2.10.2-1) ... ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 2.3/2.3 GB 444.7 kB/s eta 0:00:00 ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 6.1/6.1 MB 89.3 MB/s eta 0:00:00 ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 4.4/4.4 MB 76.9 MB/s eta 0:00:00 ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 2.0/2.0 MB 16.6 MB/s eta 0:00:00 ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 4.6/4.6 MB 78.7 MB/s eta 0:00:00 ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 63.3/63.3 MB 11.3 MB/s eta 0:00:00 ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 96.4/96.4 kB 3.0 MB/s eta 0:00:00 ERROR: pip's dependency resolver does not currently take into account all the packages that are installed. This behaviour is the source of the following dependency conflicts. torchtune 0.6.1 requires torchdata==0.11.0, but you have torchdata 0.6.0 which is incompatible. ERROR: Could not find a version that satisfies the requirement xformers==0.0.19 (from versions: 0.0.1, 0.0.2, 0.0.3, 0.0.4, 0.0.5, 0.0.6, 0.0.7, 0.0.8, 0.0.9, 0.0.10, 0.0.11, 0.0.12, 0.0.13, 0.0.16rc424, 0.0.16rc425, 0.0.16, 0.0.20, 0.0.21, 0.0.22, 0.0.22.post7, 0.0.23, 0.0.23.post1, 0.0.24, 0.0.25, 0.0.25.post1, 0.0.26.post1, 0.0.27, 0.0.27.post1, 0.0.27.post2, 0.0.28, 0.0.28.post1, 0.0.28.post2, 0.0.28.post3, 0.0.29, 0.0.29.post1, 0.0.29.post2, 0.0.29.post3, 0.0.30, 0.0.31, 0.0.31.post1, 0.0.32.dev1062, 0.0.32.dev1064) ERROR: No matching distribution found for xformers==0.0.19 Failed to open /content/drive/MyDrive/stable-diffusion-webui-colab/stable-diffusion-webui/extensions/sd-webui-additional-networks/models/lora/: No such file or directory. Aborting! /content/drive/MyDrive/stable-diffusion-webui-colab/stable-diffusion-webui Updating files: 100% (203/203), done. HEAD is now at 22bcc7be attempted fix for infinite loading for settings that some people experience Updating files: 100% (135/135), done. HEAD is now at cf1d67a Update modelcard.md HEAD is now at c202932 GRADIO_TUNNEL online Already up to date. Download Results: gid |stat|avg speed |path/URI ======+====+===========+======================================================= 20d2be|OK | 0B/s|/content/drive/MyDrive/stable-diffusion-webui-colab/stable-diffusion-webui/models/CLIP/ViT-L-14.pt Status Legend: (OK):download completed. Python 3.11.13 (main, Jun 4 2025, 08:57:29) [GCC 11.4.0] Commit hash: 22bcc7be428c94e9408f589966c2040187245d81 Installing gfpgan Installing clip Installing open_clip Installing xformers Traceback (most recent call last): File "/content/drive/MyDrive/stable-diffusion-webui-colab/stable-diffusion-webui/launch.py", line 355, in <module> prepare_environment() File "/content/drive/MyDrive/stable-diffusion-webui-colab/stable-diffusion-webui/launch.py", line 281, in prepare_environment run_pip(f"install {xformers_package}", "xformers") File "/content/drive/MyDrive/stable-diffusion-webui-colab/stable-diffusion-webui/launch.py", line 129, in run_pip return run(f'"{python}" -m pip {args} --prefer-binary{index_url_line}', desc=f"Installing {desc}", errdesc=f"Couldn't install {desc}") ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/content/drive/MyDrive/stable-diffusion-webui-colab/stable-diffusion-webui/launch.py", line 97, in run raise RuntimeError(message) RuntimeError: Couldn't install xformers. Command: "/usr/bin/python3" -m pip install xformers==0.0.16rc425 --prefer-binary Error code: 1 stdout: Collecting xformers==0.0.16rc425 Downloading xformers-0.0.16rc425.tar.gz (7.3 MB) ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 7.3/7.3 MB 81.4 MB/s eta 0:00:00 Preparing metadata (setup.py): started Preparing metadata (setup.py): finished with status 'done' Requirement already satisfied: torch>=1.12 in /usr/local/lib/python3.11/dist-packages (from xformers==0.0.16rc425) (2.0.0+cu118) Requirement already satisfied: numpy in /usr/local/lib/python3.11/dist-packages (from xformers==0.0.16rc425) (2.0.2) Collecting pyre-extensions==0.0.23 (from xformers==0.0.16rc425) Downloading pyre_extensions-0.0.23-py3-none-any.whl.metadata (4.0 kB) Collecting typing-inspect (from pyre-extensions==0.0.23->xformers==0.0.16rc425) Downloading typing_inspect-0.9.0-py3-none-any.whl.metadata (1.5 kB) Requirement already satisfied: typing-extensions in /usr/local/lib/python3.11/dist-packages (from pyre-extensions==0.0.23->xformers==0.0.16rc425) (4.14.1) Requirement already satisfied: filelock in /usr/local/lib/python3.11/dist-packages (from torch>=1.12->xformers==0.0.16rc425) (3.18.0) Requirement already satisfied: sympy in /usr/local/lib/python3.11/dist-packages (from torch>=1.12->xformers==0.0.16rc425) (1.13.1) Requirement already satisfied: networkx in /usr/local/lib/python3.11/dist-packages (from torch>=1.12->xformers==0.0.16rc425) (3.5) Requirement already satisfied: jinja2 in /usr/local/lib/python3.11/dist-packages (from torch>=1.12->xformers==0.0.16rc425) (3.1.6) Requirement already satisfied: triton==2.0.0 in /usr/local/lib/python3.11/dist-packages (from torch>=1.12->xformers==0.0.16rc425) (2.0.0) Requirement already satisfied: cmake in /usr/local/lib/python3.11/dist-packages (from triton==2.0.0->torch>=1.12->xformers==0.0.16rc425) (3.31.6) Requirement already satisfied: lit in /usr/local/lib/python3.11/dist-packages (from triton==2.0.0->torch>=1.12->xformers==0.0.16rc425) (18.1.8) Requirement already satisfied: MarkupSafe>=2.0 in /usr/local/lib/python3.11/dist-packages (from jinja2->torch>=1.12->xformers==0.0.16rc425) (3.0.2) Requirement already satisfied: mpmath<1.4,>=1.1.0 in /usr/local/lib/python3.11/dist-packages (from sympy->torch>=1.12->xformers==0.0.16rc425) (1.3.0) Collecting mypy-extensions>=0.3.0 (from typing-inspect->pyre-extensions==0.0.23->xformers==0.0.16rc425) Downloading mypy_extensions-1.1.0-py3-none-any.whl.metadata (1.1 kB) Downloading pyre_extensions-0.0.23-py3-none-any.whl (11 kB) Downloading typing_inspect-0.9.0-py3-none-any.whl (8.8 kB) Downloading mypy_extensions-1.1.0-py3-none-any.whl (5.0 kB) Building wheels for collected packages: xformers Building wheel for xformers (setup.py): started Building wheel for xformers (setup.py): finished with status 'error' Running setup.py clean for xformers Failed to build xformers stderr: error: subprocess-exited-with-error × python setup.py bdist_wheel did not run successfully. │ exit code: 1 ╰─> See above for output. note: This error originates from a subprocess, and is likely not a problem with pip. ERROR: Failed building wheel for xformers ERROR: ERROR: Failed to build installable wheels for some pyproject.toml based projects (xformers)

<template> <el-dialog :visible.sync="dialogVisible" width="70%" :show-close="false" :close-on-click-modal="false" append-to-body @open="handleOpen" @close="handleClose" > <template slot="title"> {{ title }} </template> <el-form :model="detailForm" label-width="130px" v-loading="loading"> <el-row> <el-col :span="8"> <el-form-item label="日期:"> <el-input readonly v-model="detailForm.recordDate"></el-input> </el-form-item> </el-col> <el-col :span="8"> <el-form-item label="班别:"> <el-input readonly v-model="detailForm.workClass"></el-input> </el-form-item> </el-col> </el-row> <el-form-item label="异常机况:"> <el-table :data="eqpList" style="width: 100%" id="eqpTable"> <el-table-column prop="area" label="Area"></el-table-column> <el-table-column prop="eqpId" label="Eqp Id"></el-table-column> <el-table-column prop="eqpName" label="Eqp Name"></el-table-column> <el-table-column prop="eqpStatus" label="Eqp Status"></el-table-column> <el-table-column prop="eqpHour" label="Hour"></el-table-column> <el-table-column prop="eqpUser" label="User"></el-table-column> <el-table-column prop="comments" label="Comment"></el-table-column> </el-table> <el-input type="textarea" v-model="detailForm.abnormal" :autosize="{ minRows: 2 }" placeholder="请输入异常机况 或 选中粘贴图片" @paste="handlePaste($event, abnormalImageRef)" :readonly="!detailForm.editAuth" ></el-input> <el-upload ref="abnormalImageRef" v-model="detailForm.abnormalImageList" action="#" :http-request="handleHttpUpload" list-type="picture-card" :before-upload="beforeUpload" :on-success="() => uploadSuccess('abnormalImageList')" :on-error="uploadError" :on-remove="(file, fileList) => handleRemove('abnormalImageList', fileList)" :accept="fileType.join(',')" :on-preview="handlePreview" :disabled="!detailForm.editAuth" > </el-upload> </el-form-item> <el-form-item label="产片:"> <el-table :data="lotList" style="width: 100%" id="lotTable"> <el-table-column prop="eqp" label="机台"></el-table-column> <el-table-column prop="priority" label="Priority"></el-table-column> <el-table-column prop="lotId" label="Lot ID"></el-table-column> <el-table-column prop="maskTitle" label="Mask Title"></el-table-column> <el-table-column prop="dueDay" label="Due Day"></el-table-column> </el-table> <el-input type="textarea" v-model="detailForm.product" :autosize="{ minRows: 2 }" placeholder="请输入产片 或 选中粘贴图片" @paste="handlePaste($event, productImageRef)" :readonly="!detailForm.editAuth" ></el-input> <el-upload ref="productImageRef" v-model="detailForm.productImageList" action="#" :http-request="handleHttpUpload" list-type="picture-card" :before-upload="beforeUpload" :on-success="() => uploadSuccess('productImageList')" :on-error="uploadError" :on-remove="(file, fileList) => handleRemove('productImageList', fileList)" :accept="fileType.join(',')" :on-preview="handlePreview" :disabled="!detailForm.editAuth" > </el-upload> </el-form-item> <el-form-item label="工程师交接事项:"> <el-input type="textarea" v-model="detailForm.engHandover" :autosize="{ minRows: 2 }" placeholder="请输入工程师交接事项 或 选中粘贴图片" @paste="handlePaste($event, engHandoverImageRef)" :readonly="!detailForm.editAuth" ></el-input> <el-upload ref="engHandoverImageRef" v-model="detailForm.engHandoverImageList" action="#" :http-request="handleHttpUpload" list-type="picture-card" :before-upload="beforeUpload" :on-success="() => uploadSuccess('engHandoverImageList')" :on-error="uploadError" :accept="fileType.join(',')" :on-remove="(file, fileList) => handleRemove('engHandoverImageList', fileList)" :on-preview="handlePreview" :disabled="!detailForm.editAuth" > </el-upload> </el-form-item> <el-form-item label="课长:" v-if="detailForm.managerName !== null"> <el-input v-model="detailForm.managerName" readonly></el-input> </el-form-item> <el-form-item label="接班人:" v-if="detailForm.assigneeName !== null"> <el-input type="textarea" v-model="detailForm.assigneeName" readonly autosize></el-input> </el-form-item> </el-form> <template slot="footer"> <el-button type="primary" @click="save" v-if="detailForm.editAuth">保存</el-button> <el-button @click="closeDialog">取消</el-button> <el-button type="primary" @click="submit" v-if="detailForm.submitAuth">提交</el-button> <el-button type="primary" @click="audit" v-if="detailForm.auditAuth">审核</el-button> <el-button type="primary" @click="assign" v-if="detailForm.assignAuth">签核</el-button> </template> </el-dialog> <el-dialog :visible.sync="previewVisible" :show-close="false"> Preview Image </el-dialog> </template> <script> import { getJournalForEdit, saveJournal, submitJournal, auditJournal, assignJournal, clearEditUser } from '@/api/mfgLog/area'; import request from '@/utils/request'; import {Message, MessageBox } from "element-ui"; import dayjs from 'dayjs'; import { getToken } from '@/utils/auth' export default { data() { return { loading: false, dialogVisible: false, title: '光罩厂制造部站点交接记录簿', fileType: ['image/jpeg', 'image/png', 'image/gif'], abnormalImageRef: null, engHandoverImageRef: null, productImageRef: null, previewVisible: false, previewImageUrl: '', lotList: [], eqpList: [], detailForm: { recordDate: '', workClass: '', workArea: '', abnormal: '', lotList: [], eqpList: [], abnormalImage: '', abnormalImageList: [], product: '', productImage: '', productImageList: [], engHandover: '', engHandoverImage: '', engHandoverImageList: [], managerName: '', assigneeName: '', editAuth: false, submitAuth: false, auditAuth: false, assignAuth: false, id: '' }, timer: null }; }, mounted() { // 监听事件以重置计时器 window.addEventListener('keydown', this.resetTimer); window.addEventListener('mousemove', this.resetTimer); window.addEventListener('mouseenter', this.resetTimer); // 浏览器关闭事件 window.addEventListener('beforeunload', (e) => { this.userInactive(); }); }, beforeDestroy() { // 清除事件监听和计时器 window.removeEventListener('keydown', this.resetTimer); window.removeEventListener('mousemove', this.resetTimer); window.removeEventListener('mouseenter', this.resetTimer); clearTimeout(this.timer); }, methods: { handleOpen() { this.resetTimer(); }, handleClose() { clearTimeout(this.timer); }, resetTimer() { // 用户进行了操作,重置计时器 if (this.timer) { clearTimeout(this.timer); } this.startTimer(); }, startTimer() { // 设置5分钟后的无操作处理 this.timer = setTimeout(() => { // 用户5分钟内无操作,执行相关逻辑 if (this.dialogVisible) { this.userInactive(); } }, 5 * 60 * 1000); }, userInactive() { // 用户处于非活跃状态的逻辑处理 if (this.detailForm.editAuth) { this.save(); } this.closeDialog(); }, showDialog(row) { this.loading = true; getJournalForEdit(row).then(res => { Object.assign(this.detailForm, res.data); // 显示提示信息 if (!this.detailForm.editAuth && !this.detailForm.assignAuth && this.detailForm.editUser) { Message.warning({ message: "当前日志正在被 " + this.detailForm.editUserName + " 编辑", position: 'top', // 确保消息显示在页面顶部 duration: 5000 // 消息显示时间为 5 秒 }); return 0; } this.detailForm.abnormalImageList = []; if (this.detailForm.abnormalImage?.length > 0) { let abnormalList = this.detailForm.abnormalImage.split(","); for (let index in abnormalList) { this.detailForm.abnormalImageList.push({ url: abnormalList[index] }); } } this.detailForm.productImageList = []; if (this.detailForm.productImage?.length > 0) { let productList = this.detailForm.productImage.split(","); for (let index in productList) { this.detailForm.productImageList.push({ url: productList[index] }); } } this.detailForm.engHandoverImageList = []; if (this.detailForm.engHandoverImage?.length > 0) { let engHandoverList = this.detailForm.engHandoverImage?.split(","); for (let index in engHandoverList) { this.detailForm.engHandoverImageList.push({ url: engHandoverList[index] }); } } if (this.detailForm.lotList && Array.isArray(this.detailForm.lotList)) { this.lotList = this.detailForm.lotList; } else { this.lotList = []; // 否则初始化为空数组 } if (this.detailForm.eqpList && Array.isArray(this.detailForm.eqpList)) { this.eqpList = this.detailForm.eqpList; } else { this.eqpList = []; // 否则初始化为空数组 } this.title = "光罩厂制造部 " + this.detailForm.workArea + " 站点交接记录簿"; // 判断当前时间是否允许提交/审核日志 if (this.detailForm.submitAuth || this.detailForm.auditAuth) { // 白班18点30分之前不允许提交和审核 let authTime = this.detailForm.recordDate + " 18:30:00"; if ('N' == this.detailForm.workClass.substring(0, 1)) { // 晚班06点30分之前不允许提交和审核 authTime = dayjs(this.detailForm.recordDate).add(1, 'day').format("YYYY-MM-DD") + " 06:30:00"; } if (dayjs().isBefore(dayjs(authTime))) { this.detailForm.submitAuth = false; this.detailForm.auditAuth = false; } } // 父系统页面打开遮罩 window.parent.postMessage("open", '*'); this.dialogVisible = true; // 设置初始计时器 this.loading = false; }).catch(error => { console.log(error); this.loading = false; }); }, closeDialog() { clearEditUser({ id: this.detailForm.id }).catch(error => { Message.error(error.msg ? error.msg : error); }); this.$emit('close'); // 父系统页面关闭遮罩 window.parent.postMessage("close", '*'); this.dialogVisible = false; }, save() { this.detailForm.abnormalImage = this.detailForm.abnormalImageList.map(item => item.url).join(","); this.detailForm.productImage = this.detailForm.productImageList.map(item => item.url).join(","); this.detailForm.engHandoverImage = this.detailForm.engHandoverImageList.map(item => item.url).join(","); this.loading = true; saveJournal(this.detailForm).then(res => { this.loading = false; Message.success("保存成功"); this.closeDialog(); }).catch(error => { this.loading = false; }); }, submit() { MessageBox.confirm("确认要提交吗?", "提示", { confirmButtonText: '确认', cancelButtonText: '取消', type: 'warning', }).then(res => { this.detailForm.abnormalImage = this.detailForm.abnormalImageList.map(item => item.url).join(","); this.detailForm.productImage = this.detailForm.productImageList.map(item => item.url).join(","); this.detailForm.engHandoverImage = this.detailForm.engHandoverImageList.map(item => item.url).join(","); this.loading = true; submitJournal(this.detailForm).then(res => { this.loading = false; Message.success("提交成功"); this.closeDialog(); }).catch(error => { this.loading = false; Message.error(error.msg ? error.msg : error); }); }).catch(error => { console.log(error); }); }, audit() { MessageBox.confirm("确认要提交审核吗?", "提示", { confirmButtonText: '确认', cancelButtonText: '取消', type: 'warning', }).then(res => { this.detailForm.abnormalImage = this.detailForm.abnormalImageList.map(item => item.url).join(","); this.detailForm.productImage = this.detailForm.productImageList.map(item => item.url).join(","); this.detailForm.engHandoverImage = this.detailForm.engHandoverImageList.map(item => item.url).join(","); this.detailForm.lotList = this.detailForm.lotList this.detailForm.eqpList = this.detailForm.eqpList this.loading = true; auditJournal(this.detailForm).then(res => { this.loading = false; Message.success("审核成功"); this.closeDialog(); }).catch(error => { this.loading = false; Message.error(error.msg ? error.msg : error); }); }).catch(error => { console.log(error); }); }, assign() { MessageBox.confirm("确认要签核吗?", "提示", { confirmButtonText: '确认', cancelButtonText: '取消', type: 'warning', }).then(res => { this.loading = true; assignJournal({ id: this.detailForm.id }).then(res => { this.loading = false; Message.success("签核成功"); this.closeDialog(); }).catch(error => { this.loading = false; Message.error(error.msg ? error.msg : error); }); }).catch(error => { console.log(error); }); }, handleHttpUpload(options) { return process.env.VUE_APP_BASE_API + '/viewException/uploadImage' }, handleRemove(listName, fileList) { console.log(listName) console.log(fileList) console.log(this.detailForm[listName]) this.detailForm[listName] = fileList; }, headers(){ return { "Authorization": 'Bearer ' + getToken() } }, beforeUpload(rawFile) { const imgType = this.fileType.includes(rawFile.type); if (!imgType) { Message.warning({ title: '温馨提示', message: '上传图片不符合所需的格式!', }); } return imgType; }, uploadSuccess(imageListName) { Message.success({ title: '温馨提示', message: '图片上传成功!', }); this.detailForm[imageListName].forEach(item => { if (item.url.indexOf("/api/") < 0) item.url = item.response.url; }); }, uploadError() { Message.error({ title: '温馨提示', message: '图片上传失败,请您重新上传!', }); }, handlePaste(event, uploadRef) { const items = (event.clipboardData || window.clipboardData).items; let file = null; if (!items || items.length === 0) { Message.error("当前浏览器不支持粘贴板"); return; } // 搜索剪切板items for (let i = 0; i < items.length; i++) { if (items[i].type.indexOf("image") !== -1) { file = items[i].getAsFile(); break; } } if (!file) { return; } uploadRef.handleStart(file); // 将粘贴过来的图片加入预上传队列 uploadRef.submit(); // 提交图片上传队列 }, handlePreview(file) { this.previewImageUrl = file.url; this.previewVisible = true; } } }; </script> <style scoped> .layout-padding-custom { padding: 20px; } .border-vxe-table { margin-top: 20px; } </style> 报错vue.runtime.esm.js:619 [Vue warn]: Error in v-on handler: "TypeError: reqs[uid].abort is not a function" found in ---> <ElUploadList> at packages/upload/src/upload-list.vue <ElUpload> at packages/upload/src/index.vue <ElFormItem> at packages/form/src/form-item.vue <ElForm> at packages/form/src/form.vue <ElDialog> at packages/dialog/src/component.vue <Detail> at src/views/mfgLog/area/detail.vue <Index> at src/views/mfgLog/area/index.vue <AppMain> at src/layout/components/AppMain.vue <Layout> at src/layout/index.vue <App> at src/App.vue <Root> warn @ vue.runtime.esm.js:619 logError @ vue.runtime.esm.js:1893 globalHandleError @ vue.runtime.esm.js:1888 handleError @ vue.runtime.esm.js:1848 invokeWithErrorHandling @ vue.runtime.esm.js:1871 invoker @ vue.runtime.esm.js:2188 invokeWithErrorHandling @ vue.runtime.esm.js:1863 Vue.$emit @ vue.runtime.esm.js:3903 click @ element-ui.common.js:28831 invokeWithErrorHandling @ vue.runtime.esm.js:1863 invoker @ vue.runtime.esm.js:2188 original._wrapper @ vue.runtime.esm.js:6961 vue.runtime.esm.js:1897 TypeError: reqs[uid].abort is not a function at VueComponent.abort (element-ui.common.js:29351:1) at VueComponent.abort (element-ui.common.js:29717:1) at doRemove (element-ui.common.js:29688:1) at VueComponent.handleRemove (element-ui.common.js:29695:1) at invokeWithErrorHandling (vue.runtime.esm.js:1863:1) at Proxy.invoker (vue.runtime.esm.js:2188:1) at invokeWithErrorHandling (vue.runtime.esm.js:1863:1) at Vue.$emit (vue.runtime.esm.js:3903:1) at click (element-ui.common.js:28831:1) at invokeWithErrorHandling (vue.runtime.esm.js:1863:1)

package com.kotei.overseas.navi.update; import static com.kotei.overseas.navi.security.DecryptUtil.dataVerification; import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; import android.content.IntentFilter; import android.os.AsyncTask; import android.os.Handler; import android.os.Looper; import android.util.Log; import java.util.Map; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.CountDownLatch; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicLong; import androidx.annotation.NonNull; import com.here.sdk.core.engine.SDKNativeEngine; import com.here.sdk.maploader.MapDownloader; import com.here.sdk.maploader.MapDownloaderConstructionCallback; import com.kotei.overseas.navi.business.data.MapDataController; import com.kotei.overseas.navi.security.DecryptUtil; import com.kotei.overseas.navi.security.DfCert; import java.io.File; import java.io.IOException; import java.io.UncheckedIOException; import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; import java.util.concurrent.atomic.AtomicInteger; import java.util.regex.Pattern; import java.util.stream.Stream; /** * USB离线更新系统 */ public class USBOfflineUpdater { private static final String TAG = "USBOfflineUpdater"; // 状态码定义 /** * 操作成功 */ public static final int SUCCESS = 0; /** * 错误:未检测到USB设备 */ public static final int ERROR_NO_USB = 1; /** * 错误:未找到升级包文件 */ public static final int ERROR_NO_UPDATE_PACKAGE = 2; /** * 错误:电池电量不足(低于安全阈值) */ public static final int ERROR_BATTERY_LOW = 3; /** * 错误:存储空间不足 */ public static final int ERROR_STORAGE_INSUFFICIENT = 4; /** * 错误:系统正在执行其他升级任务 */ public static final int ERROR_UPDATE_IN_PROGRESS = 5; /** * 错误:文件复制失败(检查存储权限或磁盘状态) */ public static final int ERROR_COPY_FAILED = 6; /** * 错误:升级包解压失败(文件可能损坏) */ public static final int ERROR_EXTRACT_FAILED = 7; /** * 错误:用户手动取消操作 */ public static final int ERROR_USER_CANCELED = 8; /** * 错误:未预期的系统异常 */ public static final int ERROR_UNEXPECTED = 9; /** * 错误:升级过程中USB设备被移除 */ public static final int ERROR_USB_REMOVED = 10; /** * 错误:车辆档位未处于停车挡(P档) */ public static final int ERROR_VEHICLE_SHIFTED = 11; /** * 错误:电池电量极低(无法维持升级过程) */ public static final int ERROR_BATTERY_TOO_LOW = 12; /** * 错误:文件校验失败(MD5/SHA256校验不匹配) */ public static final int ERROR_FILE_VERIFY_FAILED = 13; /** * 错误:文件解密或验签失败 */ public static final int ERROR_DECRYPT_OR_SIGN_FAILED = 14; // 更新阶段定义 /** * 空闲状态(未开始升级) */ private static final int PHASE_IDLE = 0; /** * 设备检测阶段(检查USB/存储设备) */ private static final int PHASE_DETECTING = 1; /** * 升级包校验阶段(验证完整性/签名) */ private static final int PHASE_CHECKING = 2; /** * 系统备份阶段(备份当前系统数据) */ private static final int PHASE_BACKUP = 3; /** * 文件复制阶段(写入升级包到临时分区) */ private static final int PHASE_COPYING = 4; /** * 解压阶段(解压升级包内容) */ private static final int PHASE_EXTRACTING = 5; /** * 清理阶段(删除临时文件) */ private static final int PHASE_CLEANUP = 6; /** * 回滚阶段(升级失败时恢复备份) */ private static final int PHASE_ROLLBACK = 7; // 权重分配比例 private static final float BACKUP_WEIGHT = 0.1f; // 备份阶段权重10% private static final float PACKAGE_COPY_WEIGHT = 0.29f; // 升级包拷贝阶段权重29% private static final float PACKAGE_VERIFY_WEIGHT = 0.31f; // 升级包解密验签阶段权重31% private static final float PACKAGE_EXTRACT_WEIGHT = 0.29f; // 升级包解压阶段权重29% private static final float VERIFICATION_WEIGHT = 0.01f; // 校验阶段权重1% // 声明 mProgress 为实例变量(非静态) private float mProgress = 0; // 当前进度值(0~1) private static USBOfflineUpdater instance; private final Context context; private UpdateTask currentTask; private UpdateListener updateListener; private SDKNativeEngine sdkNativeEngine; private MapDataController mapDataController; // 目录配置 private File usbRoot; private File cacheDir; private File storageDir; // 更新控制 public boolean isPaused = false; public volatile boolean isCancelled = false; public final AtomicInteger currentPhase = new AtomicInteger(PHASE_IDLE); // 错误信息 private String lastErrorMessage = ""; // 电量阈值 private static final int MIN_BATTERY_LEVEL = 30; // 最低电量百分比 private static final int MIN_BATTERY_LEVEL_CRITICAL = 15; // 严重低电量 //升级包格式 private static final String FILE_NAME_PATTERN = "^KVM_Navi_EU_" + "(?<version>\\d{1,3})" // 版本号(1-3位数字) + "_" + "(?<serial>\\d{1,2})" // 1-2位数字编号 + "(\\.\\w+)?$"; // 可选的文件扩展名 // 进度计算相关变量(新增) private long totalUpdateSize = 0; // 所有升级包总大小 private long UpdateSize = 0; // 当前升级包大小 // private long currentCopiedBytes = 0; // 当前已拷贝字节数 // private long currentVerifiedBytes = 0; // 当前已验签字节数 // private long currentExtractedBytes = 0; // 当前已解压字节数 private final AtomicLong currentCopiedBytes = new AtomicLong(0); private final AtomicLong currentVerifiedBytes = new AtomicLong(0); private final AtomicLong currentExtractedBytes = new AtomicLong(0); // // private long backupSize = 0; // 备份数据大小 private int currentPackageIndex = 0; // 当前处理的升级包索引 private int totalPackageCount = 0; // 总升级包数量 // 用于跟踪回滚状态 public boolean isRollingBack = false; private long rollbackTotalSize = 0; private long rollbackProcessedSize = 0; //--------------------zwx----多线程--------------- // 多线程控制变量 private final Object packageLock = new Object(); private volatile boolean updateSuccess = true; private int nextPackageIndex = 0; private Handler mainHandler = new Handler(Looper.getMainLooper()); private volatile CountDownLatch allPackagesLatch; private volatile ExecutorService updateExecutor; private final AtomicLong totalPackageSize = new AtomicLong(0); // 每个包的最大进度(17.8%) private static final double MAX_PACKAGE_PROGRESS = 17.8; // 总进度中用于升级包处理的部分(89%) private static final double TOTAL_PACKAGE_PROGRESS = 89.0; // 存储每个包的当前进度(0.0 ~ 17.8) private final Map<String, Double> packageProgressMap = new ConcurrentHashMap<>(); // 存储每个包的总大小(用于计算进度比例) private final Map<String, Long> packageTotalSizeMap = new ConcurrentHashMap<>(); // 存储每个包的当前处理阶段(拷贝、验签、解压) private final Map<String, Integer> packageStageMap = new ConcurrentHashMap<>(); // 阶段标识 private static final int STAGE_COPY = 0; private static final int STAGE_VERIFY = 1; private static final int STAGE_EXTRACT = 2; //-----------------------------zwxend---------------- // USB监听器 private final BroadcastReceiver usbReceiver = new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { String action = intent.getAction(); if (Intent.ACTION_MEDIA_MOUNTED.equals(action)) { File usbPath = new File(intent.getData().getPath()); if (usbPath.exists() && usbPath.canRead()) { usbRoot = usbPath; Log.i(TAG, "USB mounted: " + usbRoot.getAbsolutePath()); } } else if (Intent.ACTION_MEDIA_EJECT.equals(action) || Intent.ACTION_MEDIA_UNMOUNTED.equals(action)) { if (currentTask != null && currentPhase.get() > PHASE_CHECKING) { cancelUpdate(ERROR_USB_REMOVED, "USB设备被移除"); } usbRoot = null; Log.e(TAG, "USB removed"); } } }; // // 车辆状态监听器(模拟) private final BroadcastReceiver vehicleReceiver = new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { if ("com.example.ACTION_SHIFT_CHANGE".equals(intent.getAction())) { String shift = intent.getStringExtra("shift"); if (!"P".equals(shift) && currentPhase.get() > PHASE_CHECKING) { // cancelUpdate(ERROR_VEHICLE_SHIFTED, "车辆已退出P挡"); } } } }; // 单例模式 public static synchronized USBOfflineUpdater getInstance(Context context) { if (instance == null) { instance = new USBOfflineUpdater(context); } return instance; } public static synchronized USBOfflineUpdater getInstance() { return instance; } private USBOfflineUpdater(Context context) { this.context = context.getApplicationContext(); // 初始化SDK sdkNativeEngine = SDKNativeEngine.getSharedInstance(); mapDataController = MapDataController.getInstance(); try { DfCert.getInstance().getService(); } catch (Exception e) { Log.e(TAG, "Exception:" + e.toString()); } // 初始化目录(默认值) cacheDir = this.context.getCacheDir(); storageDir = new File(sdkNativeEngine.getOptions().persistentMapStoragePath); // 注册USB监听器 IntentFilter usbFilter = new IntentFilter(); usbFilter.addAction(Intent.ACTION_MEDIA_MOUNTED); usbFilter.addAction(Intent.ACTION_MEDIA_EJECT); usbFilter.addAction(Intent.ACTION_MEDIA_UNMOUNTED); usbFilter.addDataScheme("file"); context.registerReceiver(usbReceiver, usbFilter); // 注册车辆状态监听器(模拟) IntentFilter vehicleFilter = new IntentFilter("com.example.ACTION_SHIFT_CHANGE"); context.registerReceiver(vehicleReceiver, vehicleFilter); //清除数据存储目录下的预留数据 removeLegacy(); } public void initialization(UpdateListener listener) { isRollingBack = true; this.updateListener = listener; Thread USBOfflineUpdaterInitialization = new Thread(new Runnable() { @Override public void run() { // 启动时检查恢复 checkRecoveryOnStartup(); } }); USBOfflineUpdaterInitialization.setName("USBOfflineUpdaterInitialization"); USBOfflineUpdaterInitialization.start(); } // 动态设置目录 public void setDirectories(File usbRoot, File cacheDir, File storageDir) { if (usbRoot != null) { this.usbRoot = usbRoot; } if (cacheDir != null) { this.cacheDir = cacheDir; } if (storageDir != null) { this.storageDir = storageDir; } } /** * 检测升级包 * * @return 状态码 (SUCCESS 或错误码) */ public int detectUpdatePackages() { // 1. 检测USB是否插入 if (usbRoot == null || !usbRoot.exists() || !usbRoot.isDirectory()) { return ERROR_NO_USB; } File[] tempPackages = usbRoot.listFiles(); // 2. 查找升级包 (命名格式: update_v{版本号}_{日期}.zip) File[] packages = usbRoot.listFiles(file -> file.isFile() && file.getName().matches(FILE_NAME_PATTERN) ); return (packages != null && packages.length > 0) ? SUCCESS : ERROR_NO_UPDATE_PACKAGE; } /** * 环境检测 * * @return 状态码 (SUCCESS 或错误码) */ public int checkEnvironment() { // 1. 检测电量 int batteryLevel = PowerUtils.getBatteryLevel(context); if (batteryLevel < MIN_BATTERY_LEVEL) { return batteryLevel < MIN_BATTERY_LEVEL_CRITICAL ? ERROR_BATTERY_TOO_LOW : ERROR_BATTERY_LOW; } // 2. 检测缓存空间 (需大于15GB) long requiredSpace = 15L * 1024 * 1024 * 1024; // 15GB long availableSpace = StorageUtils.getAvailableSpace(cacheDir); if (availableSpace < requiredSpace) { Log.e(TAG, "缓存空间剩余:【" + availableSpace + "】"); return ERROR_STORAGE_INSUFFICIENT; } return SUCCESS; } /** * 判读是否正在进行离线更新 */ public boolean isOfflineUpdate() { return currentTask != null && !currentTask.isCancelled(); } /** * 开始更新 */ public void startUpdate(UpdateListener listener) { int result = checkEnvironment(); if (result != SUCCESS) { notifyListener(result, "环境检测不合格"); return; } if (isOfflineUpdate()) { notifyListener(ERROR_UPDATE_IN_PROGRESS, "已有更新任务正在进行"); return; } if (isRollingBack) { notifyListener(ERROR_UPDATE_IN_PROGRESS, "正在进行数据回滚"); return; } Log.i(TAG, "检测到更新任务触发,开始进行地图更新"); notifyProgress("开始进行更新"); // 计算总工作量(新增) calculateTotalWorkload(); this.updateListener = listener; currentTask = new UpdateTask(); currentTask.execute(); } // 计算总工作量(新增) private void calculateTotalWorkload() { totalUpdateSize = 0; File[] packages = getUpdatePackages(); totalPackageCount = packages != null ? packages.length : 0; if (packages != null) { for (File pkg : packages) { totalUpdateSize += pkg.length(); } } backupSize = estimateBackupSize(); Log.i(TAG, "总工作量计算: 升级包数量=" + totalPackageCount + ", 升级包大小=" + formatSize(totalUpdateSize) + ", 备份大小=" + formatSize(backupSize)); } // 估算备份大小方法(避免返回0导致除0错误) private long estimateBackupSize() { long storageSize = FileUtilszwx.getDirectorySize(storageDir); long size = (long) (storageSize * 1.2); return size > 0 ? size : 1; // 确保不为0 } // 获取更新包(新增) private File[] getUpdatePackages() { if (usbRoot == null) return new File[0]; return usbRoot.listFiles(file -> file.isFile() && file.getName().matches(FILE_NAME_PATTERN) ); } // 格式化文件大小(新增) public static String formatSize(long size) { if (size < 1024) return size + "B"; else if (size < 1024 * 1024) return String.format("%.1fKB", size / 1024.0); else if (size < 1024 * 1024 * 1024) return String.format("%.1fMB", size / (1024.0 * 1024)); else return String.format("%.1fGB", size / (1024.0 * 1024 * 1024)); } /** * 暂停更新 */ public void pauseUpdate() { isPaused = true; notifyProgress("更新已暂停"); } /** * 恢复更新 */ public void resumeUpdate() { isPaused = false; notifyProgress("更新已恢复"); } /** * 取消更新 */ public void cancelUpdate() { cancelUpdate(ERROR_USER_CANCELED, "用户取消更新"); } private void cancelUpdate(int errorCode, String message) { isCancelled = true; lastErrorMessage = message; notifyListener(errorCode, message); } // 进度通知 private void notifyProgress(String message) { new Handler(Looper.getMainLooper()).post(() -> { if (updateListener != null) { // 计算当前总进度(修改) float progress = calculateOverallProgress(); updateListener.onProgress(currentPhase.get(), progress, message); } }); } private float calculateOverallProgress() { if (isRollingBack) { // 回滚阶段:直接计算回滚进度 if (rollbackTotalSize > 0) { mProgress = 99; return mProgress; } return 0; } if (totalPackageCount == 0 && currentPhase.get() != PHASE_ROLLBACK) return 0; // 每个包的总权重(拷贝+验签+解压) float packageTotalWeight = PACKAGE_COPY_WEIGHT + PACKAGE_VERIFY_WEIGHT + PACKAGE_EXTRACT_WEIGHT; //再次确认totalPackageCount是否等于0 if (totalPackageCount == 0) { throw new IllegalStateException("totalPackageCount should not be 0 here!"); } // 每个包的阶段权重 float packageCopyWeight = PACKAGE_COPY_WEIGHT / totalPackageCount; float packageVerifyWeight = PACKAGE_VERIFY_WEIGHT / totalPackageCount; float packageExtractWeight = PACKAGE_EXTRACT_WEIGHT / totalPackageCount; switch (currentPhase.get()) { case PHASE_BACKUP: if(backupSize > 0) { mProgress = BACKUP_WEIGHT * (currentCopiedBytes.get() / (float) backupSize); }else{ mProgress = BACKUP_WEIGHT; } if(mProgress > BACKUP_WEIGHT) { mProgress = BACKUP_WEIGHT; } break; case PHASE_COPYING: // 基础:备份 + 已完成包的完整进度 float copyBase = BACKUP_WEIGHT + (packageTotalWeight * currentPackageIndex) / totalPackageCount; // 增量:当前包拷贝进度 float copyProgress = currentCopiedBytes.get() / (float) UpdateSize; mProgress = copyBase + packageCopyWeight * copyProgress; break; case PHASE_CHECKING: // 基础:备份 + 已完成包的完整进度 + 当前包拷贝完成 float verifyBase = BACKUP_WEIGHT + (packageTotalWeight * currentPackageIndex) / totalPackageCount + packageCopyWeight; // 增量:当前包验签进度 float verifyProgress = currentVerifiedBytes.get() / (float) UpdateSize; mProgress = verifyBase + packageVerifyWeight * verifyProgress; break; case PHASE_EXTRACTING: // 修复:添加当前包验签完成 float extractBase = BACKUP_WEIGHT + (packageTotalWeight * currentPackageIndex) / totalPackageCount + packageCopyWeight + packageVerifyWeight; // 添加这行 // 增量:当前包解压进度 float extractProgress = currentExtractedBytes.get() / (float) UpdateSize; mProgress = extractBase + packageExtractWeight * extractProgress; break; case PHASE_DETECTING: mProgress = BACKUP_WEIGHT + packageTotalWeight + VERIFICATION_WEIGHT * (currentVerifiedBytes.get() / (float) totalUpdateSize); break; case PHASE_CLEANUP: case PHASE_ROLLBACK: mProgress = 0.99f; break; } return Math.min(Math.round(mProgress * 10000) / 100.00f, 100.00f); } // 结果通知 private void notifyListener(int resultCode, String message) { new Handler(Looper.getMainLooper()).post(() -> { if (updateListener != null) { updateListener.onResult(resultCode, message); } }); } // 获取当前进度百分比 private int getCurrentProgress() { // 此处可添加子任务进度计算 return (int) mProgress; } // =============================== 核心更新逻辑 =============================== private class UpdateTask extends AsyncTask<Void, Void, Integer> { private File backupFile; private File[] updatePackages; @Override protected void onPreExecute() { currentPhase.set(PHASE_DETECTING); isCancelled = false; isPaused = false; currentCopiedBytes.set(0); currentExtractedBytes.set(0); mProgress = 0; // 重置进度为0 } @Override protected Integer doInBackground(Void... voids) { try { // 阶段1: 备份数据 currentPhase.set(PHASE_BACKUP); notifyProgress("开始备份数据..."); backupFile = new File(cacheDir, "backup.zip"); if (backupFile.exists()) { if (!backupFile.delete()) { throw new IOException("删除旧备份文件失败: " + backupFile.getAbsolutePath()); } } // 计算备份大小 Log.i(TAG, "核对实际需要备份的数据大小"); backupSize = estimateBackupSize(); Log.i(TAG, "需要备份的数据大小: [" + formatSize(backupSize) + "]"); if (backupSize > 0) { Log.i(TAG, "开始进行数据备份"); boolean backupResult = FileUtilszwx.compressDirectoryWithProgress( storageDir, backupFile, (copied, total) -> { currentCopiedBytes.set(copied); notifyProgress("备份数据: " + formatSize(copied) + "/" + formatSize(total)); if (isCancelled()) { throw new InterruptedException("用户取消备份"); } } ); if (!backupResult) { lastErrorMessage = "备份创建失败"; return ERROR_UNEXPECTED; } } else { Log.i(TAG, "无数据需要备份,直接进行数据更新"); currentCopiedBytes.set(1); backupSize = 1; notifyProgress("无数据需要备份"); } if (isCancelled()) { return ERROR_USER_CANCELED; } // 阶段2: 获取升级包列表 updatePackages = getUpdatePackages(); int packageCount = updatePackages.length; if (packageCount == 0) { notifyProgress("无升级包"); return ERROR_USER_CANCELED; } Log.i(TAG, "开始并行处理升级包【拷贝、解密验签、解压】"); ExecutorService executor = Executors.newFixedThreadPool(Math.min(packageCount, 4)); // 限制线程数 allPackagesLatch = new CountDownLatch(packageCount); updateSuccess = true; Log.i(TAG, "zwx:开始并行处理升级包【拷贝、解密验签、解压】"); processUpdatePackagesInParallel(updatePackages); Log.i(TAG, "zwx:开始并行处理升级包【拷贝、解密验签、解压】"); // 等待所有任务完成或取消 while (!isCancelled() && allPackagesLatch.getCount() > 0) { Thread.sleep(200); // 避免 CPU 空转 } // 如果任务被取消,则中断所有任务 if (isCancelled()) { executor.shutdownNow(); return ERROR_USER_CANCELED; } // 关闭线程池 executor.shutdown(); // 检查是否全部成功 if (!updateSuccess) { lastErrorMessage = "升级包处理失败"; return ERROR_USER_CANCELED; } // 数据校验 if (!mapDataController.checkInstallationStatus()) { notifyProgress("校验失败"); return ERROR_FILE_VERIFY_FAILED; } else { notifyProgress("校验成功"); } // 异步构建 MapDownloader MapDownloader.fromEngineAsync(sdkNativeEngine, new MapDownloaderConstructionCallback() { @Override public void onMapDownloaderConstructedCompleted(@NonNull MapDownloader downloader) { Log.i(TAG, "数据同步成功"); } }); // 阶段3: 清理工作 currentPhase.set(PHASE_CLEANUP); notifyProgress("清理缓存..."); if (backupFile.exists() && !backupFile.delete()) { Log.w(TAG, "删除备份文件失败"); } notifyProgress("更新完成"); return SUCCESS; } catch (InterruptedException e) { if (backupFile != null && backupFile.exists()) { backupFile.delete(); } lastErrorMessage = "更新任务被中断"; return ERROR_USER_CANCELED; } catch (Exception e) { lastErrorMessage = "未知错误: " + e.getMessage(); Log.e(TAG, "更新失败", e); return ERROR_UNEXPECTED; } } @Override protected void onPostExecute(Integer resultCode) { if (resultCode == SUCCESS) { notifyListener(SUCCESS, "更新成功,请重启车机"); currentPhase.set(PHASE_IDLE); currentTask = null; } else { // 只有备份完成时才进行回滚(场景2) if (backupFile != null && backupFile.exists()) { // 场景2:进入回滚流程 isRollingBack = true; currentPhase.set(PHASE_ROLLBACK); // 先发送回滚进度通知(99%) notifyProgress("更新失败,正在回滚数据..."); // 保存错误消息,因为回滚完成后还需要使用 final String errorMessage = lastErrorMessage; // 启动回滚线程 new Thread(new Runnable() { @Override public void run() { try { // 执行回滚 performRollback(backupFile); } finally { // 回滚完成后删除备份 // backupFile.delete(); if (backupFile.exists() && !backupFile.delete()) { Log.w(TAG, "删除备份文件失败: " + backupFile.getAbsolutePath()); } if (!isCancelled) { // 回滚完成后发送最终结果 notifyListener(resultCode, getErrorMessage(resultCode)); } // 重置状态 currentPhase.set(PHASE_IDLE); currentTask = null; isRollingBack = false; } } }).start(); } else { // 场景1:没有备份文件,直接报告错误 notifyListener(resultCode, lastErrorMessage); currentPhase.set(PHASE_IDLE); currentTask = null; } } } } // ================== 启动时恢复检查 ================== private void checkRecoveryOnStartup() { File backupFile = findLatestBackupFile(); // 存在备份文件说明上次更新中断 if (backupFile != null && backupFile.exists()) { long fileSize = backupFile.length(); long expectedSize = estimateBackupSize(); // 场景3:备份未完成(文件大小小于预期大小的90%) if (fileSize < expectedSize * 0.9) { isRollingBack = true; Log.i(TAG, "检测到未完成的备份,删除: " + backupFile.getName()); // backupFile.delete(); if (backupFile.exists() && !backupFile.delete()) { Log.w(TAG, "删除备份文件失败: " + backupFile.getAbsolutePath()); } return; }else { // 场景4:备份已完成,启动回滚 Log.i(TAG, "检测到完整的备份,开始回滚: " + backupFile.getName()); currentPhase.set(PHASE_ROLLBACK); notifyProgress("检测到未完成更新,正在恢复数据..."); // 执行回滚 performRollback(backupFile); // 删除备份文件 // backupFile.delete(); if (backupFile.exists() && !backupFile.delete()) { Log.w(TAG, "删除备份文件失败: " + backupFile.getAbsolutePath()); } notifyProgress("数据恢复完成"); } } isRollingBack = false; this.updateListener = null; } private void checkStoragePerformance() { long writeSpeed = StorageUtils.measureWriteSpeed(storageDir); Log.d(TAG, "存储写入速度: " + formatSize(writeSpeed) + "/s"); if (writeSpeed < 50 * 1024 * 1024) { // 低于 50MB/s Log.w(TAG, "检测到低速存储设备,还原操作可能较慢"); } } // 新增回滚方法 private void performRollback(File backupFile) { try { // 1. 设置回滚进度为99% rollbackProcessedSize = backupFile.length() * 99 / 100; notifyProgress("开始恢复备份..."); // 2. 删除更新后的数据 FileUtilszwx.deleteRecursive(storageDir); if (!storageDir.mkdirs()) { Log.w(TAG, "创建存储目录失败"); } // 3. 恢复备份 rollbackTotalSize = backupFile.length(); rollbackProcessedSize = 0; boolean restoreSuccess = FileUtilszwx.extractZipWithProgress( backupFile, storageDir, (extracted, total) -> { rollbackProcessedSize = extracted; notifyProgress(String.format("恢复备份 %s: %s/%s", backupFile.getName(), formatSize(extracted), formatSize(total))); } ); if (!restoreSuccess) { Log.e(TAG, "备份恢复失败"); } } catch (Exception e) { Log.e(TAG, "回滚过程中发生错误", e); } } private File findLatestBackupFile() { File[] backups = cacheDir.listFiles(file -> file.isFile() && file.getName().startsWith("backup.zip") ); if (backups == null || backups.length == 0) { return null; } return backups[0]; } // 释放资源 public void release() { try { context.unregisterReceiver(usbReceiver); context.unregisterReceiver(vehicleReceiver); } catch (Exception e) { Log.w(TAG, "释放资源时出错", e); } } // ================== 接口定义 ================== public interface UpdateListener { void onProgress(int phase, float progress, String message); void onResult(int resultCode, String message); } public interface ProgressCallback { void onProgress(long progress, long total) throws InterruptedException; } public File getUsbRoot() { return usbRoot; } public File getCacheDir() { return cacheDir; } public File getStorageDir() { return storageDir; } public String getErrorMessage(int code) { return switch (code) { case ERROR_NO_USB -> "未检测到USB设备,请检查连接状态或更换接口"; case ERROR_NO_UPDATE_PACKAGE -> "升级包文件缺失,请确认存储路径"; case ERROR_BATTERY_LOW -> "电池电量不足(需≥20%)"; case ERROR_STORAGE_INSUFFICIENT -> "存储空间不足(需预留500MB以上)"; case ERROR_UPDATE_IN_PROGRESS -> "系统正在执行其他升级任务"; case ERROR_COPY_FAILED -> "文件复制失败,请检查存储权限"; case ERROR_EXTRACT_FAILED -> "升级包解压失败(可能文件损坏)"; case ERROR_USER_CANCELED -> "用户已取消升级操作"; case ERROR_UNEXPECTED -> "发生未预期的系统异常"; case ERROR_USB_REMOVED -> "升级过程中USB设备被移除"; case ERROR_VEHICLE_SHIFTED -> "请将车辆档位切换至P档"; case ERROR_BATTERY_TOO_LOW -> "电池电量极低(需≥10%)"; case ERROR_FILE_VERIFY_FAILED -> "文件校验失败(MD5/SHA256不匹配)"; case ERROR_DECRYPT_OR_SIGN_FAILED -> "文件解密/验签失败"; default -> "未知错误导致更新失败"; }; } void removeLegacy() { if (storageDir == null || !storageDir.exists() || !storageDir.isDirectory()) { return; } Pattern pattern = Pattern.compile(FILE_NAME_PATTERN); File[] files = storageDir.listFiles(); if (files == null) return; for (File file : files) { if (file.isFile() && pattern.matcher(file.getName()).matches()) { // 删除匹配的文件 try { Files.deleteIfExists(file.toPath()); } catch (IOException | SecurityException e) { // 处理异常(记录日志等) } } } // 删除sign文件夹(如果存在) Path signDir = Paths.get(storageDir.getAbsolutePath(), "sign"); if (Files.exists(signDir)) { try { // 递归删除整个目录 deleteDirectoryRecursively(signDir); } catch (IOException | SecurityException e) { // 处理异常 } } } private void deleteDirectoryRecursively(Path path) throws IOException { if (Files.isDirectory(path)) { // 使用 try-with-resources 确保 Stream 关闭 try (Stream children = Files.list(path)) { children.forEach(child -> { try { deleteDirectoryRecursively(child); } catch (IOException e) { // 处理子项删除异常 throw new UncheckedIOException(e); // 转换为 RuntimeException 以便在 Stream 中抛出 } }); } catch (UncheckedIOException e) { // 重新抛出原始 IOException throw e.getCause(); } } // 删除空目录或文件 Files.deleteIfExists(path); } //-----------------------------------多线程私有类------------------------ /** * 并行更新管道,用于并发处理多个升级包 */ /** * 并行更新管道,用于并发处理多个升级包 */ /** * 并行处理升级包 */ private void shutdownUpdateExecutor() { if (updateExecutor != null && !updateExecutor.isShutdown()) { updateExecutor.shutdownNow(); } } private void updateProgress(String format, String packageName, long processed, long total) { String message = String.format(format, packageName, formatSize(processed), formatSize(total)); mainHandler.post(() -> notifyProgress(message)); } private void processUpdatePackagesInParallel(File[] packages) { if (packages == null || packages.length == 0) { notifyListener(SUCCESS, "无升级包"); return; } // 初始化每个包的进度信息 for (File packageFile : packages) { packageTotalSizeMap.put(packageFile.getName(), packageFile.length()); packageProgressMap.put(packageFile.getName(), 0.0); packageStageMap.put(packageFile.getName(), STAGE_COPY); } allPackagesLatch = new CountDownLatch(packages.length); int maxThreads = Math.min(packages.length, 3); // 最大并发数为 3 ExecutorService parallelExecutor = Executors.newFixedThreadPool(maxThreads); ExecutorService serialCopyExecutor = Executors.newSingleThreadExecutor(); // 串行提交拷贝任务 for (File packageFile : packages) { if (isCancelled) break; serialCopyExecutor.submit(new SerialCopyTask(packageFile, parallelExecutor)); } // 关闭串行拷贝线程池(不再接受新任务) serialCopyExecutor.shutdown(); // 启动后台线程等待所有任务完成 new Thread(() -> { try { allPackagesLatch.await(); if (isCancelled) { notifyListener(ERROR_USER_CANCELED, "用户取消"); } else if (updateSuccess && mapDataController.checkInstallationStatus()) { notifyProgress("校验成功"); Log.d(TAG, "最终进度:" + packageProgressMap); notifyListener(SUCCESS, "更新成功,请重启车机"); } else { notifyProgress("校验失败"); notifyListener(ERROR_FILE_VERIFY_FAILED, "文件校验失败"); } } catch (InterruptedException e) { Thread.currentThread().interrupt(); notifyListener(ERROR_UNEXPECTED, "任务中断"); } finally { parallelExecutor.shutdown(); } }).start(); } private class PackageProcessingTask implements Runnable { private final File packageFile; public PackageProcessingTask(File packageFile) { this.packageFile = packageFile; } @Override public void run() { if (isCancelled) { allPackagesLatch.countDown(); return; } String packageName = packageFile.getName(); File destFile = new File(storageDir, packageName); // 阶段1: 拷贝 try { boolean copyResult = FileUtilszwx.copyFileWithProgress(packageFile, destFile, (copied, total) -> { packageStageMap.put(packageName, STAGE_COPY); updatePackageProgress(packageName, copied, total, STAGE_COPY); updateProgress("拷贝 %s: %s/%s", packageName, copied, total); }); if (!copyResult || isCancelled) { updateSuccess = false; allPackagesLatch.countDown(); return; } } catch (Exception e) { Log.e(TAG, "拷贝失败", e); updateSuccess = false; allPackagesLatch.countDown(); return; } // 阶段2: 解密验签 try { boolean verifyResult = dataVerification(destFile.getAbsolutePath(), new DecryptUtil.ProgressCallback() { @Override public void onProgress(long processed, long total) { packageStageMap.put(packageName, STAGE_VERIFY); updatePackageProgress(packageName, processed, total, STAGE_VERIFY); updateProgress("解密验签 %s: %s/%s", packageName, processed, total); } }); if (!verifyResult || isCancelled) { updateSuccess = false; allPackagesLatch.countDown(); return; } } catch (Exception e) { Log.e(TAG, "解密验签失败", e); updateSuccess = false; allPackagesLatch.countDown(); return; } // 阶段3: 解压 try { boolean extractResult = FileUtilszwx.extractZipWithProgress(destFile, storageDir, (extracted, total) -> { packageStageMap.put(packageName, STAGE_EXTRACT); updatePackageProgress(packageName, extracted, total, STAGE_EXTRACT); updateProgress("解压 %s: %s/%s", packageName, extracted, total); }); if (!extractResult || isCancelled) { updateSuccess = false; allPackagesLatch.countDown(); return; } } catch (Exception e) { Log.e(TAG, "解压失败", e); updateSuccess = false; allPackagesLatch.countDown(); return; } // 删除升级包 if (!destFile.delete()) { Log.w(TAG, "删除升级包失败: " + destFile.getName()); } // 最终进度设为最大值 packageProgressMap.put(packageName, MAX_PACKAGE_PROGRESS); allPackagesLatch.countDown(); // 任务完成 } } /** * 更新包的进度,并限制最大为 MAX_PACKAGE_PROGRESS */ private void updatePackageProgress(String packageName, long processed, long total, int stage) { double stageRatio = (double) processed / total; double progress = 0.0; switch (stage) { case STAGE_COPY: progress = MAX_PACKAGE_PROGRESS / 3 * stageRatio; break; case STAGE_VERIFY: progress = MAX_PACKAGE_PROGRESS / 3 + MAX_PACKAGE_PROGRESS / 3 * stageRatio; break; case STAGE_EXTRACT: progress = MAX_PACKAGE_PROGRESS / 3 * 2 + MAX_PACKAGE_PROGRESS / 3 * stageRatio; break; } packageProgressMap.put(packageName, Math.min(progress, MAX_PACKAGE_PROGRESS)); } /** * 串行拷贝任务 */ private class SerialCopyTask implements Runnable { private final File packageFile; private final ExecutorService parallelExecutor; public SerialCopyTask(File packageFile, ExecutorService parallelExecutor) { this.packageFile = packageFile; this.parallelExecutor = parallelExecutor; } @Override public void run() { if (isCancelled) { allPackagesLatch.countDown(); return; } String packageName = packageFile.getName(); File destFile = new File(storageDir, packageName); try { boolean copyResult = FileUtilszwx.copyFileWithProgress(packageFile, destFile, (copied, total) -> { packageStageMap.put(packageName, STAGE_COPY); updatePackageProgress(packageName, copied, total, STAGE_COPY); updateProgress("拷贝 %s: %s/%s", packageName, copied, total); }); if (!copyResult || isCancelled) { updateSuccess = false; allPackagesLatch.countDown(); return; } // 拷贝完成后,提交后续任务到线程池并行处理 parallelExecutor.submit(new PostCopyProcessingTask(packageFile, destFile)); } catch (Exception e) { Log.e(TAG, "拷贝失败", e); updateSuccess = false; allPackagesLatch.countDown(); } } } /** * 并行处理任务(解密验签、解压) */ private class PostCopyProcessingTask implements Runnable { private final File packageFile; private final File destFile; public PostCopyProcessingTask(File packageFile, File destFile) { this.packageFile = packageFile; this.destFile = destFile; } @Override public void run() { if (isCancelled) { allPackagesLatch.countDown(); return; } String packageName = packageFile.getName(); // 阶段2: 解密验签 try { boolean verifyResult = dataVerification(destFile.getAbsolutePath(), new DecryptUtil.ProgressCallback() { @Override public void onProgress(long processed, long total) { packageStageMap.put(packageName, STAGE_VERIFY); updatePackageProgress(packageName, processed, total, STAGE_VERIFY); updateProgress("解密验签 %s: %s/%s", packageName, processed, total); } }); if (!verifyResult || isCancelled) { updateSuccess = false; allPackagesLatch.countDown(); return; } } catch (Exception e) { Log.e(TAG, "解密验签失败", e); updateSuccess = false; allPackagesLatch.countDown(); return; } // 阶段3: 解压 try { boolean extractResult = FileUtilszwx.extractZipWithProgress(destFile, storageDir, (extracted, total) -> { packageStageMap.put(packageName, STAGE_EXTRACT); updatePackageProgress(packageName, extracted, total, STAGE_EXTRACT); updateProgress("解压 %s: %s/%s", packageName, extracted, total); }); if (!extractResult || isCancelled) { updateSuccess = false; allPackagesLatch.countDown(); return; } } catch (Exception e) { Log.e(TAG, "解压失败", e); updateSuccess = false; allPackagesLatch.countDown(); return; } // 删除升级包 if (!destFile.delete()) { Log.w(TAG, "删除升级包失败: " + destFile.getName()); } // 最终进度设为最大值 packageProgressMap.put(packageName, MAX_PACKAGE_PROGRESS); allPackagesLatch.countDown(); // 任务完成 } } } 总结函数表

<template> <el-dialog :visible.sync="dialogVisible" width="70%" :show-close="false" :close-on-click-modal="false" append-to-body @open="handleOpen" @close="handleClose" > <template slot="title"> {{ title }} </template> <el-form :model="detailForm" label-width="130px" v-loading="loading"> <el-row> <el-col :span="8"> <el-form-item label="日期:"> <el-input readonly v-model="detailForm.recordDate"></el-input> </el-form-item> </el-col> <el-col :span="8"> <el-form-item label="班别:"> <el-input readonly v-model="detailForm.workClass"></el-input> </el-form-item> </el-col> </el-row> <el-form-item label="异常机况:"> <el-table :data="eqpList" style="width: 100%" id="eqpTable"> <el-table-column prop="area" label="Area"></el-table-column> <el-table-column prop="eqpId" label="Eqp Id"></el-table-column> <el-table-column prop="eqpName" label="Eqp Name"></el-table-column> <el-table-column prop="eqpStatus" label="Eqp Status"></el-table-column> <el-table-column prop="eqpHour" label="Hour"></el-table-column> <el-table-column prop="eqpUser" label="User"></el-table-column> <el-table-column prop="comments" label="Comment"></el-table-column> </el-table> <el-input type="textarea" v-model="detailForm.abnormal" :autosize="{ minRows: 2 }" placeholder="请输入异常机况 或 选中粘贴图片" @paste="handlePaste($event, abnormalImageRef)" :readonly="!detailForm.editAuth" ></el-input> <el-upload ref="abnormalImageRef" v-model="detailForm.abnormalImageList" action="#" :http-request="handleHttpUpload" list-type="picture-card" :before-upload="beforeUpload" :on-success="() => uploadSuccess('abnormalImageList')" :on-error="uploadError" :accept="fileType.join(',')" :on-preview="handlePreview" :disabled="!detailForm.editAuth" > </el-upload> </el-form-item> <el-form-item label="产片:"> <el-table :data="lotList" style="width: 100%" id="lotTable"> <el-table-column prop="eqp" label="机台"></el-table-column> <el-table-column prop="priority" label="Priority"></el-table-column> <el-table-column prop="lotId" label="Lot ID"></el-table-column> <el-table-column prop="maskTitle" label="Mask Title"></el-table-column> <el-table-column prop="dueDay" label="Due Day"></el-table-column> </el-table> <el-input type="textarea" v-model="detailForm.product" :autosize="{ minRows: 2 }" placeholder="请输入产片 或 选中粘贴图片" @paste="handlePaste($event, productImageRef)" :readonly="!detailForm.editAuth" ></el-input> <el-upload ref="productImageRef" v-model="detailForm.productImageList" action="#" :http-request="handleHttpUpload" list-type="picture-card" :before-upload="beforeUpload" :on-success="() => uploadSuccess('productImageList')" :on-error="uploadError" :accept="fileType.join(',')" :on-preview="handlePreview" :disabled="!detailForm.editAuth" > </el-upload> </el-form-item> <el-form-item label="工程师交接事项:"> <el-input type="textarea" v-model="detailForm.engHandover" :autosize="{ minRows: 2 }" placeholder="请输入工程师交接事项 或 选中粘贴图片" @paste="handlePaste($event, engHandoverImageRef)" :readonly="!detailForm.editAuth" ></el-input> <el-upload ref="engHandoverImageRef" v-model="detailForm.engHandoverImageList" action="#" :http-request="handleHttpUpload" list-type="picture-card" :before-upload="beforeUpload" :on-success="() => uploadSuccess('engHandoverImageList')" :on-error="uploadError" :accept="fileType.join(',')" :on-preview="handlePreview" :disabled="!detailForm.editAuth" > </el-upload> </el-form-item> <el-form-item label="课长:" v-if="detailForm.managerName !== null"> <el-input v-model="detailForm.managerName" readonly></el-input> </el-form-item> <el-form-item label="接班人:" v-if="detailForm.assigneeName !== null"> <el-input type="textarea" v-model="detailForm.assigneeName" readonly autosize></el-input> </el-form-item> </el-form> <template slot="footer"> <el-button type="primary" @click="save" v-if="detailForm.editAuth">保存</el-button> <el-button @click="closeDialog">取消</el-button> <el-button type="primary" @click="submit" v-if="detailForm.submitAuth">提交</el-button> <el-button type="primary" @click="audit" v-if="detailForm.auditAuth">审核</el-button> <el-button type="primary" @click="assign" v-if="detailForm.assignAuth">签核</el-button> </template> </el-dialog> <el-dialog :visible.sync="previewVisible" :show-close="false"> Preview Image </el-dialog> </template> <script> import { getJournalForEdit, saveJournal, submitJournal, auditJournal, assignJournal, clearEditUser } from '@/api/mfgLog/area'; import request from '@/utils/request'; import {Message, MessageBox } from "element-ui"; import dayjs from 'dayjs'; import { getToken } from '@/utils/auth' export default { data() { return { loading: false, dialogVisible: false, title: '光罩厂制造部站点交接记录簿', fileType: ['image/jpeg', 'image/png', 'image/gif'], abnormalImageRef: null, engHandoverImageRef: null, productImageRef: null, previewVisible: false, previewImageUrl: '', detailForm: { recordDate: '', workClass: '', workArea: '', abnormal: '', lotList: [], eqpList: [], abnormalImage: '', abnormalImageList: [], product: '', productImage: '', productImageList: [], engHandover: '', engHandoverImage: '', engHandoverImageList: [], managerName: '', assigneeName: '', editAuth: false, submitAuth: false, auditAuth: false, assignAuth: false, id: '' }, timer: null }; }, mounted() { // 监听事件以重置计时器 window.addEventListener('keydown', this.resetTimer); window.addEventListener('mousemove', this.resetTimer); window.addEventListener('mouseenter', this.resetTimer); // 浏览器关闭事件 window.addEventListener('beforeunload', (e) => { this.userInactive(); }); }, beforeDestroy() { // 清除事件监听和计时器 window.removeEventListener('keydown', this.resetTimer); window.removeEventListener('mousemove', this.resetTimer); window.removeEventListener('mouseenter', this.resetTimer); clearTimeout(this.timer); }, methods: { handleOpen() { this.resetTimer(); }, handleClose() { clearTimeout(this.timer); }, resetTimer() { // 用户进行了操作,重置计时器 if (this.timer) { clearTimeout(this.timer); } this.startTimer(); }, startTimer() { // 设置5分钟后的无操作处理 this.timer = setTimeout(() => { // 用户5分钟内无操作,执行相关逻辑 if (this.dialogVisible) { this.userInactive(); } }, 5 * 60 * 1000); }, userInactive() { // 用户处于非活跃状态的逻辑处理 if (this.detailForm.editAuth) { this.save(); } this.closeDialog(); }, showDialog(row) { this.loading = true; getJournalForEdit(row).then(res => { Object.assign(this.detailForm, res.data); // 显示提示信息 if (!this.detailForm.editAuth && !this.detailForm.assignAuth && this.detailForm.editUser) { Message.warning({ message: "当前日志正在被 " + this.detailForm.editUserName + " 编辑", position: 'top', // 确保消息显示在页面顶部 duration: 5000 // 消息显示时间为 5 秒 }); return 0; } this.detailForm.abnormalImageList = []; if (this.detailForm.abnormalImage?.length > 0) { let abnormalList = this.detailForm.abnormalImage.split(","); for (let index in abnormalList) { this.detailForm.abnormalImageList.push({ url: abnormalList[index] }); } } this.detailForm.productImageList = []; if (this.detailForm.productImage?.length > 0) { let productList = this.detailForm.productImage.split(","); for (let index in productList) { this.detailForm.productImageList.push({ url: productList[index] }); } } this.detailForm.engHandoverImageList = []; if (this.detailForm.engHandoverImage?.length > 0) { let engHandoverList = this.detailForm.engHandoverImage?.split(","); for (let index in engHandoverList) { this.detailForm.engHandoverImageList.push({ url: engHandoverList[index] }); } } if (this.detailForm.lotList && Array.isArray(this.detailForm.lotList)) { this.lotList = this.detailForm.lotList; } else { this.lotList = []; // 否则初始化为空数组 } if (this.detailForm.eqpList && Array.isArray(this.detailForm.eqpList)) { this.eqpList = this.detailForm.eqpList; } else { this.eqpList = []; // 否则初始化为空数组 } this.title = "光罩厂制造部 " + this.detailForm.workArea + " 站点交接记录簿"; // 判断当前时间是否允许提交/审核日志 if (this.detailForm.submitAuth || this.detailForm.auditAuth) { // 白班18点30分之前不允许提交和审核 let authTime = this.detailForm.recordDate + " 18:30:00"; if ('N' == this.detailForm.workClass.substring(0, 1)) { // 晚班06点30分之前不允许提交和审核 authTime = dayjs(this.detailForm.recordDate).add(1, 'day').format("YYYY-MM-DD") + " 06:30:00"; } if (dayjs().isBefore(dayjs(authTime))) { this.detailForm.submitAuth = false; this.detailForm.auditAuth = false; } } // 父系统页面打开遮罩 window.parent.postMessage("open", '*'); this.dialogVisible = true; // 设置初始计时器 this.loading = false; }).catch(error => { console.log(error); this.loading = false; }); }, closeDialog() { clearEditUser({ id: this.detailForm.id }).catch(error => { Message.error(error.msg ? error.msg : error); }); this.$emit('close'); // 父系统页面关闭遮罩 window.parent.postMessage("close", '*'); this.dialogVisible = false; }, save() { this.detailForm.abnormalImage = this.detailForm.abnormalImageList.map(item => item.url).join(","); this.detailForm.productImage = this.detailForm.productImageList.map(item => item.url).join(","); this.detailForm.engHandoverImage = this.detailForm.engHandoverImageList.map(item => item.url).join(","); this.loading = true; saveJournal(this.detailForm).then(res => { this.loading = false; Message.success("保存成功"); this.closeDialog(); }).catch(error => { this.loading = false; }); }, submit() { MessageBox.confirm("确认要提交吗?", "提示", { confirmButtonText: '确认', cancelButtonText: '取消', type: 'warning', }).then(res => { this.detailForm.abnormalImage = this.detailForm.abnormalImageList.map(item => item.url).join(","); this.detailForm.productImage = this.detailForm.productImageList.map(item => item.url).join(","); this.detailForm.engHandoverImage = this.detailForm.engHandoverImageList.map(item => item.url).join(","); this.loading = true; submitJournal(this.detailForm).then(res => { this.loading = false; Message.success("提交成功"); this.closeDialog(); }).catch(error => { this.loading = false; Message.error(error.msg ? error.msg : error); }); }).catch(error => { console.log(error); }); }, audit() { MessageBox.confirm("确认要提交审核吗?", "提示", { confirmButtonText: '确认', cancelButtonText: '取消', type: 'warning', }).then(res => { this.detailForm.abnormalImage = this.detailForm.abnormalImageList.map(item => item.url).join(","); this.detailForm.productImage = this.detailForm.productImageList.map(item => item.url).join(","); this.detailForm.engHandoverImage = this.detailForm.engHandoverImageList.map(item => item.url).join(","); this.detailForm.lotList = this.detailForm.lotList this.detailForm.eqpList = this.detailForm.eqpList this.loading = true; auditJournal(this.detailForm).then(res => { this.loading = false; Message.success("审核成功"); this.closeDialog(); }).catch(error => { this.loading = false; Message.error(error.msg ? error.msg : error); }); }).catch(error => { console.log(error); }); }, assign() { MessageBox.confirm("确认要签核吗?", "提示", { confirmButtonText: '确认', cancelButtonText: '取消', type: 'warning', }).then(res => { this.loading = true; assignJournal({ id: this.detailForm.id }).then(res => { this.loading = false; Message.success("签核成功"); this.closeDialog(); }).catch(error => { this.loading = false; Message.error(error.msg ? error.msg : error); }); }).catch(error => { console.log(error); }); }, handleHttpUpload(options) { return process.env.VUE_APP_BASE_API + '/viewException/uploadImage' }, headers(){ return { "Authorization": 'Bearer ' + getToken() } }, beforeUpload(rawFile) { const imgType = this.fileType.includes(rawFile.type); if (!imgType) { Message.warning({ title: '温馨提示', message: '上传图片不符合所需的格式!', }); } return imgType; }, uploadSuccess(imageListName) { Message.success({ title: '温馨提示', message: '图片上传成功!', }); this.detailForm[imageListName].forEach(item => { if (item.url.indexOf("/api/") < 0) item.url = item.response.url; }); }, uploadError() { Message.error({ title: '温馨提示', message: '图片上传失败,请您重新上传!', }); }, handlePaste(event, uploadRef) { const items = (event.clipboardData || window.clipboardData).items; let file = null; if (!items || items.length === 0) { Message.error("当前浏览器不支持粘贴板"); return; } // 搜索剪切板items for (let i = 0; i < items.length; i++) { if (items[i].type.indexOf("image") !== -1) { file = items[i].getAsFile(); break; } } if (!file) { return; } uploadRef.handleStart(file); // 将粘贴过来的图片加入预上传队列 uploadRef.submit(); // 提交图片上传队列 }, handlePreview(file) { this.previewImageUrl = file.url; this.previewVisible = true; } } }; </script> <style scoped> .layout-padding-custom { padding: 20px; } .border-vxe-table { margin-top: 20px; } </style> 报错vue.runtime.esm.js:620 [Vue warn]: Error in v-on handler: "TypeError: reqs[uid].abort is not a function" found in ---> <ElUploadList> at packages/upload/src/upload-list.vue <ElUpload> at packages/upload/src/index.vue <ElFormItem> at packages/form/src/form-item.vue <ElForm> at packages/form/src/form.vue <ElDialog> at packages/dialog/src/component.vue <Detail> at src/views/mfgLog/area/detail.vue <Index> at src/views/mfgLog/area/index.vue <AppMain> at src/layout/components/AppMain.vue <Layout> at src/layout/index.vue <App> at src/App.vue <Root> warn @ vue.runtime.esm.js:620 logError @ vue.runtime.esm.js:1892 globalHandleError @ vue.runtime.esm.js:1887 handleError @ vue.runtime.esm.js:1847 invokeWithErrorHandling @ vue.runtime.esm.js:1870 invoker @ vue.runtime.esm.js:2187 invokeWithErrorHandling @ vue.runtime.esm.js:1862 Vue.$emit @ vue.runtime.esm.js:3897 click @ element-ui.common.js:28831 invokeWithErrorHandling @ vue.runtime.esm.js:1862 invoker @ vue.runtime.esm.js:2187 original._wrapper @ vue.runtime.esm.js:6951 vue.runtime.esm.js:1896 TypeError: reqs[uid].abort is not a function at VueComponent.abort (element-ui.common.js:29351:21) at VueComponent.abort (element-ui.common.js:29717:34) at doRemove (element-ui.common.js:29688:16) at VueComponent.handleRemove (element-ui.common.js:29695:9) at invokeWithErrorHandling (vue.runtime.esm.js:1862:26) at Proxy.invoker (vue.runtime.esm.js:2187:14) at invokeWithErrorHandling (vue.runtime.esm.js:1862:26) at Vue.$emit (vue.runtime.esm.js:3897:9) at click (element-ui.common.js:28831:37) at invokeWithErrorHandling (vue.runtime.esm.js:1862:26)

未启用CSS Modules的情况下在// 引入 path 模块 const path = require('path') // 判断当前环境是否是生产环境 const isProduction = process.env.NODE_ENV === 'production' // 样式单独分离到一个文件中 const MiniCssExtractPlugin = require('mini-css-extract-plugin') // 官方文档:Vue Loader v15 现在需要配合一个 webpack 插件才能正确使用 const VueLoaderPlugin = require("vue-loader/lib/plugin"); // 引入静态资源复制插件 const CopyWebpackPlugin = require('copy-webpack-plugin') // nodejs核心模块,直接使用 const os = require("os"); // cpu核数 const threads = os.cpus().length; // 引入入口文件 const { entry } = require('./setting.js') const webpack = require("webpack") module.exports = { // 打包入口地址 entry: entry, // 模块resolve的规则 resolve: { //自动的扩展后缀,比如一个js文件,则引用时书写可不要写.js extensions: ['.js', '.json', '.css', '.less', '.vue','.jsx'], // 路径别名 alias: { '@': path.resolve(__dirname, '../src'), 'vue$': 'vue/dist/vue.esm.js', "@ht-form-create/element-ui": path.resolve(__dirname, "../src/libs/form-create/packages/element-ui/src"), "@ht-form-create/utils": path.resolve(__dirname, "../src/libs/form-create/packages/utils"), "@ht-form-create/designer": path.resolve(__dirname, "../src/libs/form-designer/src") }, fallback: { process: require.resolve("process/browser") } }, // context 是 webpack entry 的上下文,是入口文件所处的目录的绝对路径,默认情况下是当前根目录。 // 由于我们 webpack 配置文件放于 build 目录下,所以需要重新设置下 context ,使其指向根目录。 context: path.resolve(__dirname, '../'), // 构建目标 target: ['web', 'es5'], // 不同类型模块的处理规则 module: { rules: [ { oneOf: [ // 处理 css、less 文件 { test: /\.css$/i, use: [ isProduction ? MiniCssExtractPlugin.loader : 'style-loader', { loader: 'css-loader', options: { // 是否使用source-map sourceMap: !isProduction, esModule: false } }, { loader: 'postcss-loader', options: { // 是否使用source-map sourceMap: !isProduction } } ] }, { test: /\.less$/i, use: [ isProduction ? MiniCssExtractPlugin.loader : 'style-loader', { loader: 'css-loader', options: { // 是否使用source-map sourceMap: !isProduction, esModule: false } }, { loader: 'postcss-loader', options: { // 是否使用source-map sourceMap: !isProduction } }, 'less-loader' ] }, // 处理sass资源 { test: /\.s[ca]ss$/, use: [ 'style-loader', 'css-loader', 'sass-loader', ] }, // 解析 html 中的 src 路径 // { // test: /\.html$/, // use: 'html-loader' // }, // 对图片资源文件进行处理,webpack5已经废弃了url-loader,改为type { test: /\.(png|jpe?g|gif|svg)(\?.*)?$/, type: 'asset', exclude: [path.resolve(__dirname, 'src/assets/imgs')], generator: { filename: 'imgs/[name].[contenthash][ext]' } }, // 对字体资源文件进行处理,webpack5已经废弃了url-loader,改为type { test: /\.(woff2?|eot|ttf|otf)(\?.*)?$/, type: 'asset', generator: { filename: 'fonts/[name].[contenthash][ext]' } }, // 对音频资源文件进行处理,webpack5已经废弃了url-loader,改为type { test: /\.(mp4|webm|ogg|mp3|wav|flac|aac)(\?.*)?$/, type: 'asset', exclude: [path.resolve(__dirname, 'src/assets/medias')], generator: { filename: 'medias/[name].[contenthash][ext]' } }, { test: /\.(m|j)s$/, exclude: /node_modules/, use: [ { loader: 'babel-loader', options: { cacheDirectory: true } }, { loader: "thread-loader", // 开启多进程 options: { workers: threads, // 数量 }, } ] }, { test: /\.(js|jsx)$/, include: [path.resolve(__dirname, "../src"), path.resolve(__dirname, "../src/libs/form-create"), path.resolve(__dirname, "../src/libs/form-designer")], use: [ { loader: "babel-loader", options: { cacheDirectory: true, // 确保包含处理JSX的预设 presets: ["@babel/preset-env", "@vue/babel-preset-jsx"] } }, { loader: "thread-loader", options: { workers: threads } } ] } ] }, // 处理.vue文件 { test: /\.vue$/, use: 'vue-loader' } ] }, watchOptions: { ignored: /node_modules/, }, // 插件 plugins: [ new VueLoaderPlugin(), // 把public的一些静态文件复制到指定位置,排除 html 文件 new CopyWebpackPlugin({ patterns: [ { from: path.resolve(__dirname, '../public'), globOptions: { dot: true, gitignore: true } } ] }), new webpack.DefinePlugin({ "process.env": { NODE_ENV: JSON.stringify(process.env.NODE_ENV || "development") // 可根据需要添加其他环境变量 // API_URL: JSON.stringify('https://api.example.com') } }) ] } 怎么添加

最新推荐

recommend-type

字体文件ttf裁剪工具

1、点开FontSubsetGUI.exe 2、Source Font选择为你自己所需的源字体库。 3、New Font为你自己想保存导出的字体库。 4、Char List为对照文件,需要txt格式,可将所用到的所有字符放入这个txt,然后选择这个txt文档。 5、Encoding为格式设置,一般UTF-8即可,若不知道,可不指定。 6、点击Proceed,即可导出。 注意,只能ttf文件
recommend-type

Coze/视频历史人物的一生工作流

文件编号:co0048 Coze工作流汇总 https://datayang.blog.csdn.net/article/details/124779452 工作流使用方法 https://datayang.blog.csdn.net/article/details/142167278 更多工具介绍 项目源码搭建介绍: 《我的AI工具箱Tauri+Django开源git项目介绍和使用》https://datayang.blog.csdn.net/article/details/146156817 图形桌面工具使用教程: 《我的AI工具箱Tauri+Django环境开发,支持局域网使用》https://datayang.blog.csdn.net/article/details/141897688
recommend-type

【scratch2.0少儿编程-游戏原型-动画-项目源码】3[猫和老鼠].zip

资源说明: 1:本资料仅用作交流学习参考,请切勿用于商业用途。 2:一套精品实用scratch2.0少儿编程游戏、动画源码资源,无论是入门练手还是项目复用都超实用,省去重复开发时间,让开发少走弯路! 更多精品资源请访问 https://blog.csdn.net/ashyyyy/article/details/146464041
recommend-type

现有svm识别模型,根据16000Hz,单声道音频判断是否为“到”

现有svm识别模型,根据16000Hz,单声道音频判断是否为“到”
recommend-type

基于C控制台开发的航空客运订票系统_数据结构课程设计作业_单链表存储航班数据_用户界面与管理员界面分离_查询航班_搜索航班_订票_退票_增加删除航班信息_浏览顾客信息_wind.zip

基于C控制台开发的航空客运订票系统_数据结构课程设计作业_单链表存储航班数据_用户界面与管理员界面分离_查询航班_搜索航班_订票_退票_增加删除航班信息_浏览顾客信息_wind.zip
recommend-type

Docker环境下的弹性APM服务器搭建指南

根据提供的文件信息,我们可以梳理出以下几个关键知识点: 1. Docker技术概念: Docker是一个开源的应用容器引擎,允许开发者打包他们的应用以及依赖包到一个可移植的容器中,然后发布到任何支持Docker的平台上。容器是完全使用沙箱机制,相互之间不会有任何接口(类似iOS的app)。 2. Docker的使用优势: 使用Docker部署应用可以带来多方面的优势,如提高开发效率、简化部署流程、易于迁移和扩展、强化安全性和隔离性等。容器化应用可以在不同的环境中保持一致的运行状态,减少了"在我的机器上可以运行"这类问题。 3. Compose工具: Docker Compose是一个用来定义和运行多容器Docker应用程序的工具。通过Compose,用户可以使用YAML文件来配置应用程序服务,并通过一个命令,完成容器的创建和启动。Docker Compose使得复杂配置的多容器应用的部署和管理工作变得简单。 4. APM(应用性能管理)服务器: APM服务器是用来监控和管理软件应用性能的工具。它通常包括实时性能监控、问题诊断、性能瓶颈定位、用户体验报告等功能。通过提供深入的应用性能洞察,APM能够帮助开发者和运维人员优化和提升应用性能。 5. 弹性APM服务器: 在标题中提到的“弹性”可能是指APM服务器能够根据应用的性能需求自动调整资源分配。这种弹性服务器可以动态地根据负载情况增加或减少资源,以保证应用性能的稳定,并在必要时节省资源。 6. Docker和Compose在APM服务器部署中的作用: Docker和Compose共同作用于APM服务器的部署,意味着开发者可能通过定义一个Docker Compose文件来指定APM服务器的所有依赖和服务。利用容器化的方式,可以保证APM服务器在开发、测试和生产环境中的部署和运行一致性。 7. “docker-apm-master”文件结构: 文件名称列表中提及的“docker-apm-master”很可能是包含Dockerfile、docker-compose.yml等文件的目录名称,这个目录用于管理和构建弹性APM服务器的Docker镜像和服务。在该目录下,可能包含了用于构建APM服务器镜像的脚本、配置文件,以及用于部署和管理APM服务器的Docker Compose配置。 8. 开发和运维实践: 一个“由Docker和Compose支持的弹性apm服务器”项目体现了现代软件开发和运维的实践,即使用容器化和自动化工具来提升开发效率、简化运维工作以及优化应用部署。在微服务架构和云计算日益普及的今天,这类实践变得越来越普遍。 综合以上知识点,我们可以理解“docker-apm:由Docker和Compose支持的弹性apm服务器”是一个运用现代开发运维技术实践,提供应用性能管理解决方案的项目。它结合了Docker容器化技术和Docker Compose自动化管理工具,以实现一个可扩展、弹性的APM服务器,帮助开发者和运维团队高效地监控和优化应用性能。
recommend-type

游戏开发与部署全流程指南

# 游戏开发与部署全流程指南 ## 1. 开发整体游戏结构 ### 1.1 场景添加与游戏启动 要确保场景能被加载,需将其添加到构建设置中。若不添加,Unity 就无法知晓可用的场景。在之前的测试中,若只是重新加载当前场景,无需进行此操作;但现在若要切换关卡,就必须添加。添加完成后,可从启动场景点击“播放”来启动游戏,此时游戏管理器对象会在两个场景中共享。 不过需注意,由于管理器是在启动场景中加载的,所以必须始终从该场景启动游戏。若觉得每次手动打开启动场景麻烦,可使用此编辑器脚本,它能在点击“播放”时自动切换到指定场景:[https://github.com/jhocking/from-u
recommend-type

初级运维面试题

<think> 首先,用户的问题是:“我想查找初级运维面试题”,这是在查询初级运维岗位的面试题。系统指令要求我参考提供的引用内容,这些引用来自之前的消息。 回顾引用内容: - 引用[1]:是关于运维面试题的文章,提到“2024年9月最新运维高频面试题汇总(1)”,但它是个标题,没有具体题目内容。它宣传了一个群组。 - 引用[2]:是“云计算运维工程师面试题(二)”,列出了11个具体问题,涉及云计算、弹性伸缩、高可用性、安全等。这些不是专门针对初级的,但可能涵盖。 - 引用[3]:是“初级运维工程师面试题”,描述了一个场景:查杀病毒的过程,提到了一个可疑进程。这不是直接的面试题列表,而是
recommend-type

构建Ikiwiki的Docker容器:简易部署与使用

### 知识点概述 #### 标题:“docker-ikiwiki:Ikiwiki的Docker容器” - Docker:一种开源的容器化平台,用于自动化部署、扩展和管理应用程序。 - Ikiwiki:一个使用git作为后端的wiki引擎,其特色在于使用Markdown或Textile等标记语言编辑页面。 - 容器化部署:利用Docker技术进行软件的打包、分发和运行,以容器形式提供一致的运行环境。 #### 描述:“Ikiwiki Docker容器” - Docker映像与使用:介绍了如何通过命令行工具拉取并运行一个Ikiwiki的Docker镜像。 - 拉取Docker镜像:使用命令`docker pull ankitrgadiya/ikiwiki`从Docker Hub中获取预配置好的Ikiwiki容器镜像。 - 使用方式:提供了两种使用该Docker镜像的示例,一种是与域名绑定进行SSL支持的配置,另一种是作为独立运行且不支持SSL的配置。 - 独立映像的局限性:明确指出独立映像不支持SSL,因此推荐与Nginx-Proxy结合使用以获得更好的网络服务。 #### 标签:“docker ikiwiki Shell” - 标签汇总:这些标签提示了该文档内容涉及的技术范畴,即Docker容器技术、Ikiwiki应用以及Shell命令行操作。 - Docker标签:强调了Docker在自动化部署Ikiwiki中的应用。 - Ikiwiki标签:指出了本文内容与Ikiwiki的使用和配置相关。 - Shell标签:表明操作过程涉及到Linux Shell命令的执行。 #### 压缩包子文件的文件名称列表:“docker-ikiwiki-master” - 压缩包内容:该列表暗示了压缩包内包含的文件是以"docker-ikiwiki-master"为名称的主目录或项目文件。 - 文件结构:可能包含了Dockerfile、配置脚本、说明文档等文件,用于构建和运行Ikiwiki Docker容器。 ### 详细知识点 #### Docker容器技术 - Docker基础:Docker是一个开源的应用容器引擎,允许开发者打包他们的应用以及应用的依赖包到一个可移植的容器中,然后发布到任何流行的Linux机器上,也可以实现虚拟化。容器是完全使用沙箱机制,相互之间不会有任何接口(类似 iPhone 的 app)。 - 镜像与容器:在Docker中,镜像(Image)是一个可执行包,包含了运行应用程序所需的所有内容,例如代码、运行时、库、环境变量和配置文件。容器(Container)是从镜像创建的应用运行实例,可以进行启动、停止、删除等操作。每个容器都是相互隔离的,保证应用安全运行。 #### Ikiwiki的配置与部署 - Ikiwiki简介:Ikiwiki是一个用git作为后端的wiki引擎,它允许通过文本文件来编辑网页,支持Markdown、Textile等标记语言,使得内容的编写更加直观和方便。 - 部署要求:部署Ikiwiki通常需要一个web服务器和一些配置来处理HTTP请求。而通过Docker,用户可以快速部署一个预配置好的Ikiwiki环境。 - 配置方式:Docker运行命令中涉及到了多个参数的使用,如`--name`用于给容器命名,`-v`用于指定挂载卷,`-e`用于设置环境变量,`-p`用于端口映射,`-d`用于让容器在后台运行。 #### Docker命令行操作 - docker pull:从Docker Hub或用户指定的仓库拉取指定的镜像。 - docker run:创建一个新的容器并运行一个命令。这里提供了两种运行Ikiwiki的方式,一种是用于生产环境的,与域名绑定并支持SSL;另一种是用于开发或测试环境的,直接在80端口运行。 #### 网络代理和SSL支持 - SSL支持:SSL(Secure Sockets Layer)是一种安全协议,用于保障Web服务器和浏览器之间的通信安全。当容器配置为不支持SSL时,通常意味着不直接处理HTTPS请求。 - Nginx-Proxy:一个Docker镜像,用于运行一个Nginx服务器,充当SSL终止层,将SSL终止在Nginx代理中,然后将非加密的HTTP请求转发到后端的容器。这样可以利用Nginx强大的网络功能来处理HTTPS、HTTP/2等,增强系统的安全性和效率。 ### 总结 在介绍如何部署Ikiwiki wiki引擎到Docker容器的过程中,涉及到了Docker的基本概念、容器的创建和配置、Ikiwiki的运行机制以及Shell命令行的实用操作。文档也提到了在使用不支持SSL的独立容器时,推荐配合Nginx-Proxy来增强安全性和扩展性。这些知识点对于管理和维护Docker容器化的应用具有很高的实用价值。
recommend-type

Unity开发实用指南:快捷键、外部工具与模型创建

### Unity开发实用指南:快捷键、外部工具与模型创建 #### 1. Unity场景导航与键盘快捷键 在使用Unity进行开发时,一个三键鼠标会带来更好的操作体验,虽然Unity也支持单键或双键鼠标,但三键鼠标能让操作更加便捷,在Mac系统上同样适用。 除了使用鼠标进行导航操作外,键盘也能实现一些视图控制功能。当按住鼠标右键时,可以使用键盘上的W、A、S、D键像在第一人称游戏中一样移动视角。在进行其他操作时按住Shift键可以加快移动速度。 而在选择对象后按下F键,场景视图会自动平移和缩放以聚焦该对象。如果在场景导航中迷失方向,可以在层级面板中选择一个对象,将鼠标移到场景视图上(此