mirror of
https://github.com/d0zingcat/rime_wanxiang.git
synced 2026-05-13 15:10:03 +00:00
fix: 新增自动化apk打包
This commit is contained in:
249
.github/workflows/Wanxiang_Matrix.yml
vendored
249
.github/workflows/Wanxiang_Matrix.yml
vendored
@@ -36,84 +36,90 @@ jobs:
|
||||
fetch-depth: 0
|
||||
path: trime_src
|
||||
|
||||
# 1. 注入主题 (智能查找文件版)
|
||||
- name: Inject Theme (Jianchun)
|
||||
env:
|
||||
# 【自定义过滤】
|
||||
DELETE_LIST: ".git .github .idea .gitignore README.md *.png preview.jpg"
|
||||
- name: Download Shared Gram Model
|
||||
run: |
|
||||
echo ">>> [Debug] 列出仓库前3层文件 (帮助排查):"
|
||||
ls -R wanxiang_root/ | grep ":$" | head -n 20
|
||||
|
||||
echo ">>> [Theme] 清理 Trime shared 目录..."
|
||||
rm -rf trime_src/app/src/main/assets/shared/*
|
||||
|
||||
echo ">>> [Theme] 正在查找包含 '简纯' 的 YAML 文件..."
|
||||
TARGET_FILE=$(find wanxiang_root -type f -name "*简纯*.yaml" | head -n 1)
|
||||
|
||||
if [ -z "$TARGET_FILE" ]; then
|
||||
echo "::error::未找到文件名包含'简纯'的 yaml 文件!"
|
||||
exit 1
|
||||
else
|
||||
echo "✅ 找到目标文件: $TARGET_FILE"
|
||||
THEME_DIR=$(dirname "$TARGET_FILE")
|
||||
echo "✅ 定位主题源目录: $THEME_DIR"
|
||||
fi
|
||||
|
||||
echo ">>> [Theme] 正在准备文件..."
|
||||
mkdir -p temp_theme_clean
|
||||
cp -r "$THEME_DIR"/* temp_theme_clean/
|
||||
|
||||
# --- 执行清理函数 ---
|
||||
cd temp_theme_clean
|
||||
echo "正在删除无关文件: ${{ env.DELETE_LIST }}"
|
||||
for pattern in ${{ env.DELETE_LIST }}; do
|
||||
rm -rf $pattern || true
|
||||
done
|
||||
cd ..
|
||||
# -------------------
|
||||
|
||||
echo ">>> [Theme] 注入到 Trime..."
|
||||
cp -r temp_theme_clean/* trime_src/app/src/main/assets/shared/
|
||||
rm -rf temp_theme_clean
|
||||
|
||||
echo ">>> [Theme] 注入完成,检查结果:"
|
||||
ls -1 trime_src/app/src/main/assets/shared/ | head -n 5
|
||||
|
||||
# 2. 注入方案 (修复了 cp 找不到目录的问题)
|
||||
- name: Inject Scheme (${{ matrix.branch }})
|
||||
mkdir -p "$GITHUB_WORKSPACE/common_assets"
|
||||
curl -L "https://github.com/amzxyz/RIME-LMDG/releases/download/LTS/wanxiang-lts-zh-hans.gram" \
|
||||
-o "$GITHUB_WORKSPACE/common_assets/wanxiang-lts-zh-hans.gram"
|
||||
# 2. 注入方案 (核弹模式 + 智能分流)
|
||||
- name: Inject Scheme & Smart Sync
|
||||
env:
|
||||
# 【自定义过滤】
|
||||
DELETE_LIST: ".git .github .gitignore *.md version.txt wanxiang_t9.schema.yaml weasel.yaml LICENSE *.png *.jpg unused_folder update_log.txt"
|
||||
# 垃圾文件过滤
|
||||
DELETE_LIST: ".git .github .gitignore *.md plum weasel.yaml version.txt wanxiang_t9.schema.yaml LICENSE *.png *.jpg unused_folder update_log.txt"
|
||||
run: |
|
||||
echo ">>> [Scheme] 重置 Trime rime 目录..."
|
||||
rm -rf trime_src/app/src/main/assets/rime
|
||||
# 【关键修复】手动重建该目录
|
||||
mkdir -p trime_src/app/src/main/assets/rime/
|
||||
|
||||
# === 0. 安装编译工具 ===
|
||||
echo ">>> [System] 安装 OpenCC 工具..."
|
||||
sudo apt-get update
|
||||
sudo apt-get install -y opencc
|
||||
|
||||
echo ">>> [Scheme] 正在执行【核弹级】重置..."
|
||||
RIME_DEST="$GITHUB_WORKSPACE/trime_src/app/src/main/assets/rime"
|
||||
SHARED_DEST="$GITHUB_WORKSPACE/trime_src/app/src/main/assets/shared"
|
||||
SCRIPT_PATH="$GITHUB_WORKSPACE/wanxiang_root/.github/workflows/scripts/openccset.py"
|
||||
# === 1. 彻底删除官方 rime 目录 (纯净模式) ===
|
||||
rm -rf "$RIME_DEST"
|
||||
rm -rf "$SHARED_DEST"
|
||||
mkdir -p "$RIME_DEST"
|
||||
mkdir -p "$SHARED_DEST"
|
||||
# === 2. 拉取你的分支代码 ===
|
||||
echo ">>> [Scheme] 拉取分支: ${{ matrix.branch }} ..."
|
||||
git clone -b ${{ matrix.branch }} --single-branch --depth 1 https://github.com/${{ github.repository }}.git temp_scheme
|
||||
|
||||
# --- 执行清理函数 ---
|
||||
echo ">>> [Scheme] 执行自定义过滤..."
|
||||
# === 3. 执行 Python 转换脚本 ===
|
||||
if [ -d "temp_scheme/opencc" ]; then
|
||||
echo ">>> [OpenCC] 发现 opencc 目录,开始预编译..."
|
||||
python3 "$SCRIPT_PATH" "$GITHUB_WORKSPACE/temp_scheme/opencc"
|
||||
else
|
||||
echo ">>> [OpenCC] 未发现 opencc 目录,跳过。"
|
||||
fi
|
||||
# === 4. 清理垃圾 ===
|
||||
cd temp_scheme
|
||||
echo "正在删除: ${{ env.DELETE_LIST }}"
|
||||
for pattern in ${{ env.DELETE_LIST }}; do
|
||||
rm -rf $pattern || true
|
||||
done
|
||||
cd ..
|
||||
# -------------------
|
||||
|
||||
echo ">>> [Scheme] 注入 Trime..."
|
||||
cp -r temp_scheme/* trime_src/app/src/main/assets/rime/
|
||||
# === 5. 将所有文件注入 rime (Engine Base) ===
|
||||
echo ">>> [Scheme] 全量注入 rime 目录..."
|
||||
cp -rf temp_scheme/* "$SHARED_DEST"/
|
||||
rm -rf temp_scheme
|
||||
|
||||
echo ">>> [Scheme] 注入完成,文件列表:"
|
||||
ls -1 trime_src/app/src/main/assets/rime/ | head -n 5
|
||||
# === 注入 Gram 模型 ===
|
||||
echo ">>> [Gram] 注入公共模型到 Shared..."
|
||||
cp -f "$GITHUB_WORKSPACE/common_assets/wanxiang-lts-zh-hans.gram" "$SHARED_DEST/wanxiang-lts-zh-hans.gram"
|
||||
cd "$SHARED_DEST"
|
||||
THEME_FILE=$(find . -maxdepth 1 -name "*简纯*.yaml" | head -n 1)
|
||||
if [ -n "$THEME_FILE" ]; then
|
||||
echo "🎨 锁定默认主题: $THEME_FILE -> trime.yaml"
|
||||
mv -f "$THEME_FILE" "trime.yaml"
|
||||
fi
|
||||
# 修改源码 DataManager.kt
|
||||
echo ">>> [Source] 正在修改 DataManager.kt ..."
|
||||
if [ -f "$DM_PATH" ]; then
|
||||
# (1) 修改默认数据目录 (rime -> wanxiang)
|
||||
sed -i 's/File(Environment.getExternalStorageDirectory(), "rime")/File(Environment.getExternalStorageDirectory(), "wanxiang")/g' "$DM_PATH"
|
||||
|
||||
# ----------------------------------------------------------------
|
||||
# 编译环境准备 (终极修复版:物理删除 NDK 28)
|
||||
# ----------------------------------------------------------------
|
||||
# (2) 动态修改默认 Schema List
|
||||
# 判断当前编译的分支
|
||||
if [[ "${{ matrix.branch }}" == "wanxiang-base" ]]; then
|
||||
echo "📝 检测为 Base 包,注入 wanxiang 方案"
|
||||
NEW_SCHEMAS=" - schema: wanxiang"
|
||||
else
|
||||
echo "📝 检测为 Pro 包,注入 wanxiang_pro 方案"
|
||||
NEW_SCHEMAS=" - schema: wanxiang_pro"
|
||||
fi
|
||||
|
||||
# 使用 perl 进行多行精准替换,处理那个包含 luna_pinyin 的段落
|
||||
# 我们直接替换整个 schema_list 部分
|
||||
perl -i -0777 -pe 's/- schema: luna_pinyin\n\s+- schema: luna_pinyin_simp/'"$NEW_SCHEMAS"'/g' "$DM_PATH"
|
||||
|
||||
echo "✅ DataManager.kt 源码 Patch 完成"
|
||||
fi
|
||||
echo ">>> [Check] 最终状态检查:"
|
||||
echo "--- Shared (只有配置):"
|
||||
ls -1 "$SHARED_DEST"
|
||||
echo "--- Rime (完整数据):"
|
||||
ls -1 "$RIME_DEST" | head -n 10
|
||||
|
||||
# 编译环境准备 (删除 NDK 28)
|
||||
- name: Setup Java
|
||||
uses: actions/setup-java@v4
|
||||
with:
|
||||
@@ -130,7 +136,6 @@ jobs:
|
||||
yes | $ANDROID_HOME/cmdline-tools/latest/bin/sdkmanager --install "ndk;25.2.9519653" "cmake;3.22.1"
|
||||
|
||||
echo ">>> 2. 【核弹操作】物理删除系统预装的 NDK 28 ..."
|
||||
# 这一步是关键!删掉 NDK 28,让 Gradle 别无选择
|
||||
if [ -d "$ANDROID_HOME/ndk/28.0.13004108" ]; then
|
||||
sudo rm -rf $ANDROID_HOME/ndk/28.0.13004108
|
||||
echo "✅ 已删除 NDK 28"
|
||||
@@ -152,39 +157,35 @@ jobs:
|
||||
keyPassword=${{ secrets.KEY_PASSWORD }}
|
||||
EOF
|
||||
|
||||
# 7. 编译打包 (Release) - 【修复版本冲突版】
|
||||
# 7. 编译打包 (修改包名 + 锁定NDK + 注入版本)
|
||||
- name: Build Release APK
|
||||
working-directory: trime_src
|
||||
run: |
|
||||
echo ">>> 1. 准备 NDK 环境..."
|
||||
# 查找 NDK 25 路径
|
||||
|
||||
echo ">>> 2. 准备 NDK 环境..."
|
||||
NDK_PATH=$(find $ANDROID_HOME/ndk -maxdepth 1 -name "25*" | head -n 1)
|
||||
if [ -z "$NDK_PATH" ]; then
|
||||
echo "❌ 错误:未找到 NDK 25,尝试使用系统默认..."
|
||||
echo "❌ 错误:未找到 NDK 25"
|
||||
else
|
||||
echo "✅ 锁定 NDK 路径: $NDK_PATH"
|
||||
# 写入 local.properties 告诉 Gradle NDK 在哪
|
||||
echo "ndk.dir=$NDK_PATH" >> local.properties
|
||||
fi
|
||||
|
||||
echo ">>> 2. 【核心修复】修改 build.gradle.kts 强制使用 NDK 25..."
|
||||
echo ">>> 3. 修改 Gradle 脚本..."
|
||||
|
||||
# 步骤 A: 无论原来源码里写的版本是多少,先删掉那一行,防止冲突
|
||||
# --- 【核心修改】修改包名 (Application ID) ---
|
||||
echo ">>> 正在修改包名为 amzxyz.wanxiang.trime ..."
|
||||
sed -i 's/applicationId = "com.osfans.trime"/applicationId = "amzxyz.wanxiang.trime"/g' app/build.gradle.kts
|
||||
|
||||
# 锁定 NDK 版本
|
||||
sed -i '/ndkVersion/d' app/build.gradle.kts
|
||||
|
||||
# 步骤 B: 在 android { 块的开头插入我们要的版本
|
||||
sed -i 's/android {/android { \n ndkVersion = "25.2.9519653"/' app/build.gradle.kts
|
||||
|
||||
echo ">>> 3. 注入版本号信息..."
|
||||
# 提取官方版本号
|
||||
echo ">>> 4. 注入版本号信息..."
|
||||
TRIME_VERSION=$(grep -oE "[0-9]+\.[0-9]+\.[0-9]+" CHANGELOG.md | head -n 1)
|
||||
if [ -z "$TRIME_VERSION" ]; then TRIME_VERSION="3.3.x"; fi
|
||||
|
||||
# 获取 Commit ID
|
||||
COMMIT_ID=$(git rev-parse --short HEAD || echo "custom")
|
||||
echo "捕获版本: $TRIME_VERSION ($COMMIT_ID)"
|
||||
|
||||
# 替换动态变量 (防止 Git 报错)
|
||||
|
||||
# 替换 BuildConfig 变量
|
||||
sed -i 's/buildConfigField("String", "BUILDER", .*)/buildConfigField("String", "BUILDER", "\\"GitHub Actions\\"")/g' app/build.gradle.kts
|
||||
sed -i 's/buildConfigField("long", "BUILD_TIMESTAMP", .*)/buildConfigField("long", "BUILD_TIMESTAMP", "0L")/g' app/build.gradle.kts
|
||||
sed -i 's/buildConfigField("String", "BUILD_COMMIT_HASH", .*)/buildConfigField("String", "BUILD_COMMIT_HASH", "\\"'${COMMIT_ID}'\\"")/g' app/build.gradle.kts
|
||||
@@ -194,20 +195,16 @@ jobs:
|
||||
# 配置 Git 安全目录
|
||||
git config --global --add safe.directory "*"
|
||||
|
||||
echo ">>> 4. 开始编译..."
|
||||
echo ">>> 5. 开始编译..."
|
||||
chmod +x gradlew
|
||||
./gradlew :app:assembleRelease --stacktrace
|
||||
|
||||
# 8. 重命名逻辑
|
||||
- name: Rename APK
|
||||
working-directory: trime_src/app/build/outputs/apk/release/
|
||||
run: |
|
||||
# 1. 找到原始生成的 APK
|
||||
ORIGINAL_APK=$(ls *arm64-v8a*release*.apk | head -n 1)
|
||||
|
||||
# 2. 定义新名字
|
||||
NEW_NAME="trime-${{ matrix.branch }}-armv8.apk"
|
||||
|
||||
# 3. 执行重命名
|
||||
NEW_NAME="trime-${{ matrix.branch }}-armv8a.apk"
|
||||
echo ">>> 重命名操作: 将 $ORIGINAL_APK 改为 $NEW_NAME"
|
||||
mv "$ORIGINAL_APK" "$NEW_NAME"
|
||||
|
||||
@@ -216,36 +213,50 @@ jobs:
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: APK-${{ matrix.branch }}
|
||||
path: trime_src/app/build/outputs/apk/release/trime-${{ matrix.branch }}-armv8.apk
|
||||
path: trime_src/app/build/outputs/apk/release/trime-${{ matrix.branch }}-armv8a.apk
|
||||
|
||||
release_all:
|
||||
needs: build_apks
|
||||
runs-on: ubuntu-latest
|
||||
if: startsWith(github.ref, 'refs/tags/')
|
||||
permissions:
|
||||
contents: write
|
||||
steps:
|
||||
- name: Download All Artifacts
|
||||
uses: actions/download-artifact@v4
|
||||
with:
|
||||
path: all_apks
|
||||
merge-multiple: true
|
||||
needs: build_apks
|
||||
runs-on: ubuntu-latest
|
||||
if: startsWith(github.ref, 'refs/tags/') || github.event_name == 'workflow_dispatch'
|
||||
permissions:
|
||||
contents: write
|
||||
steps:
|
||||
- name: Get current date
|
||||
id: date
|
||||
run: echo "date=$(date +'%Y-%m-%d %H:%M')" >> $GITHUB_OUTPUT
|
||||
|
||||
- name: Create GitHub Release
|
||||
uses: softprops/action-gh-release@v2
|
||||
with:
|
||||
files: all_apks/*.apk
|
||||
name: Trime 万象版 ${{ github.ref_name }}
|
||||
body: |
|
||||
## 🎉 更新说明
|
||||
万象输入法自动构建版本。
|
||||
- name: Download All Artifacts
|
||||
uses: actions/download-artifact@v4
|
||||
with:
|
||||
path: all_apks
|
||||
merge-multiple: true
|
||||
|
||||
- name: Delete 'apk' tag and release
|
||||
uses: dev-drprasad/delete-tag-and-release@v1.1
|
||||
if: github.event_name == 'workflow_dispatch'
|
||||
with:
|
||||
delete_release: true
|
||||
tag_name: apk
|
||||
github_token: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
- name: Create GitHub Release
|
||||
uses: softprops/action-gh-release@v2
|
||||
with:
|
||||
files: all_apks/*.apk
|
||||
name: ${{ startsWith(github.ref, 'refs/tags/') && github.ref_name || '同文万象安卓版本APP下载' }}
|
||||
tag_name: ${{ startsWith(github.ref, 'refs/tags/') && github.ref_name || 'apk' }}
|
||||
body: |
|
||||
### 🛠️ 构建信息
|
||||
- **构建时间**: ${{ steps.date.outputs.date }}
|
||||
- **包名**: `amzxyz.wanxiang.trime`
|
||||
- **主题**: 默认集成简纯主题
|
||||
## 📢 版权与归属声明
|
||||
|
||||
### 包含分支:
|
||||
- 所有万象变体 (Hanxin, Wubi, Flypy, Moqi, Tiger, ZRM, Shouyou, Base)
|
||||
|
||||
### 特性:
|
||||
- 集成“简纯”主题
|
||||
- 跟随每夜同文
|
||||
- Release 签名 (Arm64-v8a)
|
||||
draft: false
|
||||
prerelease: false
|
||||
- **软件内核**:基于 [Trime (同文)](https://github.com/osfans/trime) 编译,归原作者所有。
|
||||
- **输入方案**:归 [万象项目组](https://github.com/${{ github.repository }}) 所有。
|
||||
- **作品性质**:再打包集成版。
|
||||
---
|
||||
*由 GitHub Actions 自动构建生成。*
|
||||
draft: false
|
||||
prerelease: true
|
||||
|
||||
@@ -63,12 +63,14 @@ CHANGES=$(
|
||||
echo ""
|
||||
echo "3. **语法模型需单独下载**,并放入输入法用户目录根目录(与方案文件放一起),**无需配置**。"
|
||||
echo ""
|
||||
echo "4. 💾 飞机盘下载地址(最快更新):[点击访问](https://share.feijipan.com/s/xiGvXdKz)"
|
||||
echo "4. **可采用万象提供的更新器完成更新操作[点击跳转下载](https://github.com/amzxyz/RIME-LMDG/releases/tag/tool)"
|
||||
echo ""
|
||||
echo "5. Arch Linux 用户 [启用 Arch Linux CN 仓库](https://www.archlinuxcn.org/archlinux-cn-repo-and-mirror/) 后安装。"
|
||||
echo "5. 💾 飞机盘下载地址(最快更新):[点击访问](https://share.feijipan.com/s/xiGvXdKz)"
|
||||
echo ""
|
||||
echo "6. Arch Linux 用户 [启用 Arch Linux CN 仓库](https://www.archlinuxcn.org/archlinux-cn-repo-and-mirror/) 后安装。"
|
||||
echo " - 基础版包名:\`rime-wanxiang-[拼写方案名]\`,如:自然码方案:\`rime-wanxiang-zrm\`"
|
||||
echo " - 双拼辅助码增强版包名:\`rime-wanxiang-pro-[拼写方案名]\`,如:自然码方案:\`rime-wanxiang-pro-zrm\`"
|
||||
echo "6. Deepin Linux v25 用户亦可以通过仓库进行安装。"
|
||||
echo "7. Deepin Linux v25 用户亦可以通过仓库进行安装。"
|
||||
echo "### 4. 周边推荐"
|
||||
echo " - [高度适配万象拼音的仓输入法皮肤](https://github.com/BlackCCCat/ResourceforHamster/tree/main/Skin_Keyboard/)"
|
||||
echo ""
|
||||
|
||||
55
.github/workflows/scripts/openccset.py
vendored
Normal file
55
.github/workflows/scripts/openccset.py
vendored
Normal file
@@ -0,0 +1,55 @@
|
||||
import os
|
||||
import json
|
||||
import subprocess
|
||||
import sys
|
||||
|
||||
def process_opencc():
|
||||
# 获取路径参数
|
||||
input_folder = sys.argv[1] if len(sys.argv) > 1 else "./opencc"
|
||||
if not os.path.exists(input_folder):
|
||||
print(f"跳过:路径 {input_folder} 不存在")
|
||||
return
|
||||
|
||||
for filename in os.listdir(input_folder):
|
||||
file_path = os.path.join(input_folder, filename)
|
||||
|
||||
# 1. 处理 TXT -> OCD2
|
||||
if filename.endswith(".txt"):
|
||||
ocd2_filename = filename.replace(".txt", ".ocd2")
|
||||
ocd2_path = os.path.join(input_folder, ocd2_filename)
|
||||
cmd = f'opencc_dict -i "{file_path}" -o "{ocd2_path}" -f text -t ocd2'
|
||||
try:
|
||||
subprocess.run(cmd, shell=True, check=True)
|
||||
print(f"✅ 转换完成: {ocd2_filename}")
|
||||
os.remove(file_path)
|
||||
except Exception as e:
|
||||
print(f"❌ 转换失败: {filename}, {e}")
|
||||
|
||||
# 2. 修改 JSON
|
||||
elif filename.endswith(".json"):
|
||||
with open(file_path, "r", encoding="utf-8") as f:
|
||||
try:
|
||||
data = json.load(f)
|
||||
except: continue
|
||||
|
||||
state = {"modified": False}
|
||||
def update_json(obj):
|
||||
if isinstance(obj, dict):
|
||||
if "type" in obj and obj["type"] == "text":
|
||||
obj["type"] = "ocd2"
|
||||
state["modified"] = True
|
||||
if "file" in obj and obj["file"].endswith(".txt"):
|
||||
obj["file"] = obj["file"].replace(".txt", ".ocd2")
|
||||
state["modified"] = True
|
||||
for key in obj: update_json(obj[key])
|
||||
elif isinstance(obj, list):
|
||||
for item in obj: update_json(item)
|
||||
|
||||
update_json(data)
|
||||
if state["modified"]:
|
||||
with open(file_path, "w", encoding="utf-8") as f:
|
||||
json.dump(data, f, ensure_ascii=False, indent=2)
|
||||
print(f"📝 已更新 JSON: {filename}")
|
||||
|
||||
if __name__ == "__main__":
|
||||
process_opencc()
|
||||
@@ -627,7 +627,7 @@ xxx/sync/ios
|
||||
|
||||
- [用于Linux Mac的词库刷拼音辅助码工具](https://github.com/amzxyz/RIME-LMDG/releases/download/tools/wanxiang-dicts-tools-linux-mac)
|
||||
|
||||
- [用于Windows的词库刷拼音辅助码工具](https://github.com/amzxyz/RIME-LMDG/releases/download/tools/wanxiang-dicts-tools.exe)
|
||||
- [用于Windows的词库刷拼音辅助码工具](https://github.com/amzxyz/RIME-LMDG/releases/download/tools/wanxiang-tools.exe)
|
||||
|
||||
|
||||
<img alt="pay" src="./custom/万象输入方案.png">
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -90,6 +90,7 @@ sort: by_weight
|
||||
阿里山山脉 ā lǐ shān shān mài 1
|
||||
阿利斯塔克 ā lì sī tǎ kè 1
|
||||
阿里乌主义 ā lǐ wū zhǔ yì 1
|
||||
阿里云百炼 ā lǐ yún bǎi liàn 1
|
||||
阿联酋组织 ā lián qiú zǔ zhī 1
|
||||
阿鲁巴条约 ā lǔ bā tiáo yuē 1
|
||||
阿仑膦酸钠 ā lún lìn suān nà 3
|
||||
@@ -410,8 +411,6 @@ sort: by_weight
|
||||
爱你的父亲 ài nǐ de fù qīn 1
|
||||
爱你的记号 ài nǐ de jì hào 1
|
||||
爱你的老公 ài nǐ de lǎo gōng 1
|
||||
左奇异向量 zuǒ qí yì xiàng liàng 1
|
||||
右奇异向量 yòu qí yì xiàng liàng 1
|
||||
爱你的妈妈 ài nǐ de mā ma 1
|
||||
爱你的男人 ài nǐ de nán rén 1
|
||||
爱你的男生 ài nǐ de nán shēng 1
|
||||
@@ -570,7 +569,6 @@ sort: by_weight
|
||||
爱情很美好 ài qíng hěn měi hǎo 1
|
||||
爱情回来了 ài qíng huí lái le 1
|
||||
爱情急整室 ài qíng jí zhěng shì 1
|
||||
阿里云百炼 ā lǐ yún bǎi liàn 1
|
||||
爱情急转弯 ài qíng jí zhuǎn wān 1
|
||||
爱情价更高 ài qíng jià gèng gāo 1
|
||||
爱情加油站 ài qíng jiā yóu zhàn 1
|
||||
@@ -63363,6 +63361,7 @@ sort: by_weight
|
||||
狗日的腾讯 gǒu rì de téng xùn 1
|
||||
狗日的下午 gǒu rì de xià wǔ 1
|
||||
狗肉滚三滚 gǒu ròu gǔn sān gǔn 1
|
||||
狗善被人欺 gǒu shàn bèi rén qī 1
|
||||
沟水东西流 gōu shuǐ dōng xi liú 1
|
||||
沟水坡水库 gōu shuǐ pō shuǐ kù 1
|
||||
沟通不到位 gōu tōng bú dào wèi 1
|
||||
@@ -92188,7 +92187,10 @@ sort: by_weight
|
||||
结构化处理 jié gòu huà chǔ lǐ 1
|
||||
结构化存储 jié gòu huà cún chǔ 1
|
||||
结构化方法 jié gòu huà fāng fǎ 1
|
||||
结构化分工 jié gòu huà fēn gōng 1
|
||||
结构化分类 jié gòu huà fēn lèi 1
|
||||
结构化分析 jié gòu huà fēn xī 1
|
||||
结构化分组 jié gòu huà fēn zǔ 1
|
||||
结构化行情 jié gòu huà háng qíng 1
|
||||
结构化决策 jié gòu huà jué cè 1
|
||||
结构化融资 jié gòu huà róng zī 1
|
||||
@@ -117009,6 +117011,7 @@ sort: by_weight
|
||||
马赛克拼图 mǎ sài kè pīn tú 1
|
||||
马赛克效应 mǎ sài kè xiào yìng 1
|
||||
玛莎拉蒂案 mǎ shā lā dì àn 1
|
||||
马善被人骑 mǎ shàn bèi rén qí 1
|
||||
马绍尔群岛 mǎ shào ěr qún dǎo 1
|
||||
麻生久美子 má shēng jiǔ měi zǐ 1
|
||||
麻生美代子 má shēng měi dài zǐ 1
|
||||
@@ -146252,11 +146255,6 @@ sort: by_weight
|
||||
忍辱波罗密 rěn rǔ bō luó mì 1
|
||||
人三次恋爱 rén sān cì liàn ài 1
|
||||
人善被人欺 rén shàn bèi rén qī 1
|
||||
狗善被人欺 gǒu shàn bèi rén qī 1
|
||||
马善被人骑 mǎ shàn bèi rén qí 1
|
||||
结构化分组 jié gòu huà fēn zǔ 1
|
||||
结构化分类 jié gòu huà fēn lèi 1
|
||||
结构化分工 jié gòu huà fēn gōng 1
|
||||
人山人海中 rén shān rén hǎi zhōng 1
|
||||
人上了年纪 rén shàng le nián jì 1
|
||||
人少的地方 rén shǎo de dì fāng 1
|
||||
@@ -221246,6 +221244,7 @@ sort: by_weight
|
||||
油漆稀释剂 yóu qī xī shì jì 1
|
||||
尤其要警惕 yóu qí yào jǐng tì 1
|
||||
尤其要小心 yóu qí yào xiǎo xīn 1
|
||||
右奇异向量 yòu qí yì xiàng liàng 1
|
||||
又气又好笑 yòu qì yòu hǎo xiào 1
|
||||
有钱才有脸 yǒu qián cái yǒu liǎn 1
|
||||
铀铅测年法 yóu qiān cè nián fǎ 1
|
||||
@@ -247810,6 +247809,7 @@ sort: by_weight
|
||||
做起了文章 zuò qǐ le wén zhāng 1
|
||||
做起事情来 zuò qǐ shì qíng lái 1
|
||||
做企业网站 zuò qǐ yè wǎng zhàn 1
|
||||
左奇异向量 zuǒ qí yì xiàng liàng 1
|
||||
左旗增廿八 zuǒ qí zēng niàn bā 1
|
||||
左旗增廿二 zuǒ qí zēng niàn èr 1
|
||||
左旗增廿九 zuǒ qí zēng niàn jiǔ 1
|
||||
|
||||
@@ -13542,6 +13542,7 @@ sort: by_weight
|
||||
白日黯已低 bái rì àn yǐ dī 1
|
||||
白日暗榆关 bái rì àn yú guān 1
|
||||
白日变幽晦 bái rì biàn yōu huì 1
|
||||
白日不到处 bái rì bú dào chù 1
|
||||
白日不照见 bái rì bú zhào jiàn 1
|
||||
白日长悬照 bái rì cháng xuán zhào 1
|
||||
白日沉光彩 bái rì chén guāng cǎi 1
|
||||
@@ -62542,8 +62543,6 @@ sort: by_weight
|
||||
还来荆山中 hái lái jīng shān zhōng 1
|
||||
还来旧城郭 hái lái jiù chéng guō 1
|
||||
还来旧窗下 hái lái jiù chuāng xià 1
|
||||
还来就菊花 huán lái jiù jú huā 1
|
||||
还来就日飞 huán lái jiù rì fēi 1
|
||||
还来礼惠聪 hái lái lǐ huì cōng 1
|
||||
还来绕井哭 hái lái rào jǐng kū 1
|
||||
还来绕暮天 hái lái rào mù tiān 1
|
||||
@@ -71518,6 +71517,8 @@ sort: by_weight
|
||||
唤觉来厌厌 huàn jué lái yàn yàn 1
|
||||
欢康谣国风 huān kāng yáo guó fēng 1
|
||||
唤客谷神应 huàn kè gǔ shén yīng 1
|
||||
还来就菊花 huán lái jiù jú huā 1
|
||||
还来就日飞 huán lái jiù rì fēi 1
|
||||
欢来苦昼短 huān lái kǔ zhòu duǎn 1
|
||||
焕烂声明发 huàn làn shēng míng fā 1
|
||||
欢乐曾倏忽 huān lè céng shū hū 1
|
||||
@@ -123544,6 +123545,7 @@ sort: by_weight
|
||||
青春明月夜 qīng chūn míng yuè yè 1
|
||||
青春岂不惜 qīng chūn qǐ bù xī 1
|
||||
青春期上皇 qīng chūn qī shàng huáng 1
|
||||
青春恰自来 qīng chūn qià zì lái 1
|
||||
青春三十馀 qīng chūn sān shí yú 1
|
||||
青春事汉主 qīng chūn shì hàn zhǔ 1
|
||||
青春事贺监 qīng chūn shì hè jiān 1
|
||||
@@ -138352,10 +138354,7 @@ sort: by_weight
|
||||
少别已经年 shǎo bié yǐ jīng nián 1
|
||||
少曾读仙史 shǎo céng dú xiān shǐ 1
|
||||
烧柴为温酒 shāo chái wéi wēn jiǔ 1
|
||||
少长皆孝慈 shào zhǎng jiē xiào cí 1
|
||||
少尝妄思索 shǎo cháng wàng sī suǒ 1
|
||||
少长游有群 shào zhǎng yóu yǒu qún 1
|
||||
少长与我齿 shào zhǎng yǔ wǒ chǐ 1
|
||||
绍成即我后 shào chéng jí wǒ hòu 1
|
||||
稍酬知己分 shāo chóu zhī jǐ fēn 1
|
||||
烧处愁云梦 shāo chù chóu yún mèng 1
|
||||
@@ -138787,6 +138786,9 @@ sort: by_weight
|
||||
少则洋洋焉 shǎo zé yáng yáng yān 1
|
||||
稍增裘褐气 shāo zēng qiú hè qì 1
|
||||
稍沾阶下苔 shāo zhān jiē xià tái 1
|
||||
少长皆孝慈 shào zhǎng jiē xiào cí 1
|
||||
少长游有群 shào zhǎng yóu yǒu qún 1
|
||||
少长与我齿 shào zhǎng yǔ wǒ chǐ 1
|
||||
少者从公学 shǎo zhě cóng gōng xué 1
|
||||
少知诚难得 shǎo zhī chéng nán dé 1
|
||||
稍知古人心 shāo zhī gǔ rén xīn 1
|
||||
@@ -148899,6 +148901,7 @@ sort: by_weight
|
||||
谁能持此词 shuí néng chí cǐ cí 1
|
||||
谁能持此冤 shuí néng chí cǐ yuān 1
|
||||
谁能弛其防 shuí néng chí qí fáng 1
|
||||
谁能重操杼 shuí néng chóng cāo zhù 1
|
||||
谁能愁此别 shuí néng chóu cǐ bié 1
|
||||
谁能雠校闲 shuí néng chóu xiào xián 1
|
||||
谁能春独愁 shuí néng chūn dú chóu 1
|
||||
@@ -149022,7 +149025,6 @@ sort: by_weight
|
||||
谁能正婚礼 shuí néng zhèng hūn lǐ 1
|
||||
谁能知此音 shuí néng zhī cǐ yīn 1
|
||||
谁能知许事 shuí néng zhī xǔ shì 1
|
||||
谁能重操杼 shuí néng chóng cāo zhù 1
|
||||
谁能中道要 shuí néng zhōng dào yào 1
|
||||
谁能坐自苦 shuí néng zuò zì kǔ 1
|
||||
谁念北楼上 shuí niàn běi lóu shàng 1
|
||||
@@ -154752,6 +154754,7 @@ sort: by_weight
|
||||
太华高标峻 tài huá gāo biāo jùn 1
|
||||
太华见重岩 tài huá jiàn zhòng yán 1
|
||||
苔花锦不如 tái huā jǐn bù rú 1
|
||||
苔花如米小 tái huā rú mǐ xiǎo 1
|
||||
太华三芙蓉 tài huá sān fú róng 1
|
||||
太华色莽苍 tài huá sè mǎng cāng 1
|
||||
太华生长松 tài huá shēng zhǎng sōng 1
|
||||
@@ -191604,6 +191607,7 @@ sort: by_weight
|
||||
夜雪巩梅春 yè xuě gǒng méi chūn 1
|
||||
夜雪卷书帷 yè xuě juǎn shū wéi 1
|
||||
野雪空斋掩 yě xuě kōng zhāi yǎn 1
|
||||
也学牡丹开 yě xué mǔ dān kāi 1
|
||||
夜雪入穿履 yè xuě rù chuān lǚ 1
|
||||
夜雪入秋浦 yè xuě rù qiū pǔ 1
|
||||
夜雪透窗多 yè xuě tòu chuāng duō 1
|
||||
@@ -195588,6 +195592,7 @@ sort: by_weight
|
||||
一学楚人为 yì xué chǔ rén wéi 1
|
||||
一学芙蓉叶 yì xué fú róng yè 1
|
||||
一吷何由喘 yī xuè hé yóu chuǎn 1
|
||||
亦学牡丹开 yì xué mǔ dān kāi 1
|
||||
蚁穴识阴雨 yǐ xué shí yīn yǔ 1
|
||||
一穴向西斜 yì xué xiàng xī xié 1
|
||||
一旬半雷雨 yì xún bàn léi yǔ 1
|
||||
@@ -247814,11 +247819,6 @@ sort: by_weight
|
||||
二十一人同入蜀 èr shí yī rén tóng rù shǔ 1
|
||||
二十一岁赐旗鼓 èr shí yī suì cì qí gǔ 1
|
||||
而世因贵言传书 ér shì yīn guì yán chuán shū 1
|
||||
白日不到处 bái rì bú dào chù 1
|
||||
青春恰自来 qīng chūn qià zì lái 1
|
||||
苔花如米小 tái huā rú mǐ xiǎo 1
|
||||
也学牡丹开 yě xué mǔ dān kāi 1
|
||||
亦学牡丹开 yì xué mǔ dān kāi 1
|
||||
二十有九即帝位 èr shí yǒu jiǔ jí dì wèi 1
|
||||
二室由来独擅名 èr shì yóu lái dú shàn míng 1
|
||||
二十有四功业成 èr shí yǒu sì gōng yè chéng 1
|
||||
@@ -287486,7 +287486,6 @@ sort: by_weight
|
||||
尚作四海毛虫祖 shàng zuò sì hǎi máo chóng zǔ 1
|
||||
少别华阳万里游 shǎo bié huá yáng wàn lǐ yóu 1
|
||||
烧残红烛暮云合 shāo cán hóng zhú mù yún hé 1
|
||||
少长登高一望乡 shào zhǎng dēng gāo yí wàng xiāng 1
|
||||
少处兼遭病折磨 shǎo chù jiān zāo bìng zhé mó 1
|
||||
少出游山多在城 shǎo chū yóu shān duō zài chéng 1
|
||||
少答胡王万匹罗 shǎo dá hú wáng wàn pǐ luó 1
|
||||
@@ -287713,6 +287712,7 @@ sort: by_weight
|
||||
少于我者半为土 shǎo yú wǒ zhě bàn wéi tǔ 1
|
||||
少在朝廷多在山 shǎo zài cháo tíng duō zài shān 1
|
||||
少在公门多在水 shǎo zài gōng mén duō zài shuǐ 1
|
||||
少长登高一望乡 shào zhǎng dēng gāo yí wàng xiāng 1
|
||||
稍知身作近南官 shāo zhī shēn zuò jìn nán guān 1
|
||||
少驻金羁大头马 shǎo zhù jīn jī dà tóu mǎ 1
|
||||
少住林间看夕曛 shǎo zhù lín jiān kàn xī xūn 1
|
||||
|
||||
@@ -21,7 +21,6 @@ sort: by_weight
|
||||
𠼞 ā 1
|
||||
𥥩 ā 1
|
||||
𨉚 ā 1
|
||||
嘬 chuài 23
|
||||
哎 āi 820
|
||||
唉 āi 816
|
||||
爱 ài 813
|
||||
@@ -57,6 +56,7 @@ sort: by_weight
|
||||
僾 ài 182
|
||||
嬡 ài 182
|
||||
敳 ái 181
|
||||
乂 aì 175
|
||||
藹 ǎi 171
|
||||
靄 ǎi 168
|
||||
壒 ài 166
|
||||
@@ -5002,6 +5002,7 @@ sort: by_weight
|
||||
膪 chuài 124
|
||||
膗 chuái 97
|
||||
揣 chuài 68
|
||||
嘬 chuài 23
|
||||
䦷 chuài 1
|
||||
欼 chuài 1
|
||||
㪓 chuái 1
|
||||
@@ -10225,8 +10226,8 @@ sort: by_weight
|
||||
𣬫 gà 1
|
||||
𪜃 gā 1
|
||||
戛 gā 1
|
||||
该 gāi 788
|
||||
改 gǎi 808
|
||||
该 gāi 788
|
||||
概 gài 729
|
||||
盖 gài 708
|
||||
钙 gài 608
|
||||
@@ -12991,6 +12992,7 @@ sort: by_weight
|
||||
姮 héng 301
|
||||
鑅 héng 209
|
||||
烆 héng 119
|
||||
行 héng 110
|
||||
鴴 héng 109
|
||||
啈 hēng 101
|
||||
鵆 héng 97
|
||||
@@ -13027,7 +13029,6 @@ sort: by_weight
|
||||
𪏓 héng 1
|
||||
𫰟 héng 1
|
||||
堼 hèng 1
|
||||
行 héng 110
|
||||
红 hóng 769
|
||||
洪 hóng 655
|
||||
宏 hóng 654
|
||||
@@ -20116,8 +20117,8 @@ sort: by_weight
|
||||
𫓳 lǎi 1
|
||||
𫝫 lái 1
|
||||
𪮶 lài 1
|
||||
兰 lán 705
|
||||
蓝 lán 744
|
||||
兰 lán 705
|
||||
览 lǎn 678
|
||||
篮 lán 660
|
||||
烂 làn 657
|
||||
@@ -43682,6 +43683,7 @@ sort: by_weight
|
||||
邑 yì 538
|
||||
沂 yí 531
|
||||
倚 yǐ 526
|
||||
羿 yì 524
|
||||
驿 yì 522
|
||||
翌 yì 517
|
||||
懿 yì 516
|
||||
@@ -43703,7 +43705,6 @@ sort: by_weight
|
||||
佚 yì 448
|
||||
議 yì 441
|
||||
醫 yī 439
|
||||
羿 yì 524
|
||||
旖 yǐ 429
|
||||
咿 yī 427
|
||||
苡 yǐ 424
|
||||
@@ -43721,7 +43722,6 @@ sort: by_weight
|
||||
刈 yì 394
|
||||
迤 yí 393
|
||||
乂 yì 391
|
||||
乂 aì 175
|
||||
铱 yī 388
|
||||
黟 yī 387
|
||||
诒 yí 377
|
||||
@@ -45586,13 +45586,13 @@ sort: by_weight
|
||||
语 yǔ 808
|
||||
预 yù 778
|
||||
雨 yǔ 776
|
||||
玉 yù 774
|
||||
育 yù 764
|
||||
域 yù 757
|
||||
鱼 yú 756
|
||||
遇 yù 730
|
||||
余 yú 720
|
||||
与 yù 700
|
||||
玉 yù 774
|
||||
娱 yú 687
|
||||
予 yǔ 683
|
||||
宇 yǔ 676
|
||||
@@ -50283,8 +50283,8 @@ sort: by_weight
|
||||
𩲃 zhuó 1
|
||||
𩷹 zhuó 1
|
||||
𪟣 zhuó 1
|
||||
自 zì 838
|
||||
字 zì 863
|
||||
自 zì 838
|
||||
子 zǐ 780
|
||||
资 zī 778
|
||||
咨 zī 676
|
||||
|
||||
@@ -1,6 +1,3 @@
|
||||
--https://github.com/amzxyz/rime_wanxiang
|
||||
--@amzxyz
|
||||
--一个快速初始化方案类型的工具,使用方法,方案文件放进用户目录后先部署,再执行相关指令后重新部署完成切换
|
||||
local wanxiang = require("wanxiang")
|
||||
|
||||
-- 文件复制函数
|
||||
@@ -21,7 +18,17 @@ local function copy_file(src, dest)
|
||||
return true
|
||||
end
|
||||
|
||||
-- 替换方案函数(根据文件名应用特定替换模式)
|
||||
-- 检查文件是否存在
|
||||
local function file_exists(path)
|
||||
local f = io.open(path, "r")
|
||||
if f then
|
||||
f:close()
|
||||
return true
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
-- 替换方案函数
|
||||
local function replace_schema(file_path, target_schema)
|
||||
local f = io.open(file_path, "r")
|
||||
if not f then
|
||||
@@ -32,39 +39,12 @@ local function replace_schema(file_path, target_schema)
|
||||
|
||||
-- 根据文件名决定替换模式
|
||||
if file_path:find("wanxiang_reverse") then
|
||||
-- 把 "__include: wanxiang_reverse.schema:/"(含可选后缀)改成 "__include: wanxiang_algebra:/mixed/"
|
||||
content = content:gsub("(%-?%s*__include:%s*)wanxiang_reverse%.schema:/[^%s\r\n]*", "%1wanxiang_algebra:/reverse/" .. target_schema)
|
||||
-- "__patch: wanxiang_reverse.schema:/hspzn" -> "__patch: wanxiang_algebra:/reverse/hspzn"
|
||||
content = content:gsub("(%-?%s*__patch:%s*)wanxiang_reverse%.schema:/([^%s\r\n]+)", "%1wanxiang_algebra:/reverse/%2")
|
||||
|
||||
content = content:gsub("([%s]*__include:%s*wanxiang_algebra:/reverse/)%S+", "%1" .. target_schema)
|
||||
|
||||
elseif file_path:find("wanxiang_mixedcode") then
|
||||
|
||||
-- "__include: wanxiang_mixedcode.schema:/全拼"
|
||||
-- -> "__include: wanxiang_algebra:/mixed/通用派生规则"
|
||||
-- "__patch: wanxiang_algebra:/mixed/全拼"
|
||||
content = content:gsub(
|
||||
"(%-?%s*)__include:%s*wanxiang_mixedcode%.schema:/全拼",
|
||||
function(lead)
|
||||
return lead .. "__include: wanxiang_algebra:/mixed/通用派生规则\n"
|
||||
.. lead .. "__patch: wanxiang_algebra:/mixed/全拼"
|
||||
end
|
||||
)
|
||||
content = content:gsub("([%s]*__patch:%s*wanxiang_algebra:/mixed/)%S+", "%1" .. target_schema)
|
||||
|
||||
elseif file_path:find("wanxiang%.custom") or file_path:find("wanxiang_pro%.custom") then
|
||||
-- 先把旧前缀整体替换为新前缀
|
||||
-- "- wanxiang.schema:/" -> "- wanxiang_algebra:/base/"
|
||||
-- "- wanxiang_pro.schema:/" -> "- wanxiang_algebra:/pro/"
|
||||
content = content:gsub("(%-+%s*)wanxiang%.schema:/", "%1wanxiang_algebra:/base/")
|
||||
content = content:gsub("(%-+%s*)wanxiang_pro%.schema:/", "%1wanxiang_algebra:/pro/")
|
||||
|
||||
-- 再将 base/pro 后面的 schema 名替换为 target_schema
|
||||
content = content:gsub("([%s%-]*wanxiang_algebra:/pro/)%S+", "%1" .. target_schema, 1)
|
||||
content = content:gsub("([%s%-]*wanxiang_algebra:/base/)%S+", "%1" .. target_schema, 1)
|
||||
|
||||
|
||||
end
|
||||
|
||||
f = io.open(file_path, "w")
|
||||
@@ -78,6 +58,7 @@ end
|
||||
|
||||
-- translator 主函数
|
||||
local function translator(input, seg, env)
|
||||
-- 处理直接辅助/间接辅助切换
|
||||
if input == "/zjf" or input == "/jjf" then
|
||||
local target_aux = (input == "/zjf") and "直接辅助" or "间接辅助"
|
||||
local user_dir = rime_api.get_user_data_dir()
|
||||
@@ -88,11 +69,11 @@ local function translator(input, seg, env)
|
||||
|
||||
local total_hits, touched = 0, 0
|
||||
for _, p in ipairs(paths) do
|
||||
local f = io.open(p, "r")
|
||||
if f then
|
||||
local content = f:read("*a"); f:close()
|
||||
if file_exists(p) then
|
||||
local f = io.open(p, "r")
|
||||
local content = f:read("*a")
|
||||
f:close()
|
||||
|
||||
-- 两次 gsub 都要接收“新文本 + 命中次数”
|
||||
local n1, n2 = 0, 0
|
||||
content, n1 = content:gsub("(%-+%s*wanxiang_algebra:/pro/)直接辅助(%s*#?.*)", "%1" .. target_aux .. "%2")
|
||||
content, n2 = content:gsub("(%-+%s*wanxiang_algebra:/pro/)间接辅助(%s*#?.*)", "%1" .. target_aux .. "%2")
|
||||
@@ -113,6 +94,8 @@ local function translator(input, seg, env)
|
||||
yield(Candidate("switch", seg.start, seg._end, msg, ""))
|
||||
return
|
||||
end
|
||||
|
||||
-- 方案映射表
|
||||
local schema_map = {
|
||||
["/flypy"] = "小鹤双拼",
|
||||
["/mspy"] = "微软双拼",
|
||||
@@ -131,19 +114,13 @@ local function translator(input, seg, env)
|
||||
local target_schema = schema_map[input]
|
||||
if target_schema then
|
||||
local user_dir = rime_api.get_user_data_dir()
|
||||
-- ★ 新增:获取系统共享目录(安装目录)
|
||||
local shared_dir = rime_api.get_shared_data_dir()
|
||||
|
||||
-- 检查根目录是否存在自定义文件
|
||||
local pro_file = user_dir .. "/wanxiang_pro.custom.yaml"
|
||||
local normal_file = user_dir .. "/wanxiang.custom.yaml"
|
||||
local pro_exists = io.open(pro_file, "r")
|
||||
local normal_exists = io.open(normal_file, "r")
|
||||
local custom_file_exists = false
|
||||
|
||||
if pro_exists or normal_exists then
|
||||
custom_file_exists = true
|
||||
if pro_exists then pro_exists:close() end
|
||||
if normal_exists then normal_exists:close() end
|
||||
end
|
||||
local custom_file_exists = file_exists(pro_file) or file_exists(normal_file)
|
||||
|
||||
local files = {
|
||||
"wanxiang_mixedcode.custom.yaml",
|
||||
@@ -156,17 +133,22 @@ local function translator(input, seg, env)
|
||||
table.insert(files, fourth_file)
|
||||
|
||||
for _, name in ipairs(files) do
|
||||
local src = user_dir .. "/custom/" .. name
|
||||
-- 1. 优先尝试从 系统目录/custom/ 下寻找
|
||||
local src = shared_dir .. "/custom/" .. name
|
||||
|
||||
-- 2. 如果系统目录没有,尝试从 用户目录/custom/ 下寻找(作为后备)
|
||||
if not file_exists(src) then
|
||||
src = user_dir .. "/custom/" .. name
|
||||
end
|
||||
|
||||
local dest = user_dir .. "/" .. name
|
||||
|
||||
if name == fourth_file and custom_file_exists then
|
||||
-- 根目录自定义文件已存在,不复制,但依然修改
|
||||
-- 根目录自定义文件已存在,不复制,但依然修改内容
|
||||
replace_schema(dest, target_schema)
|
||||
else
|
||||
-- 其他文件: 若 custom 目录存在文件,则复制到根目录并修改
|
||||
local src_file = io.open(src, "r")
|
||||
if src_file then
|
||||
src_file:close()
|
||||
-- 其他文件: 只有当源文件存在时才复制
|
||||
if file_exists(src) then
|
||||
if copy_file(src, dest) then
|
||||
replace_schema(dest, target_schema)
|
||||
end
|
||||
@@ -175,10 +157,11 @@ local function translator(input, seg, env)
|
||||
end
|
||||
|
||||
-- 返回提示候选
|
||||
local location_tip = "系统"
|
||||
if custom_file_exists then
|
||||
yield(Candidate("switch", seg.start, seg._end, "检测到已有自定义文件,已为您切换到〔" .. target_schema .. "〕,请手动重新部署", ""))
|
||||
yield(Candidate("switch", seg.start, seg._end, "检测到已有配置,已切换到〔" .. target_schema .. "〕,请手动重新部署", ""))
|
||||
else
|
||||
yield(Candidate("switch", seg.start, seg._end, "已帮您复制并切换到〔" .. target_schema .. "〕,请手动重新部署", ""))
|
||||
yield(Candidate("switch", seg.start, seg._end, "已从"..location_tip.."目录复制并切换到〔" .. target_schema .. "〕,请手动重新部署", ""))
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user