Compare commits

..

21 Commits

Author SHA1 Message Date
手瓜一十雪
30a7797ba9 Reduce aria2c parallelism in auto-release workflow
Changed aria2c download options from 16 connections to 1 in the auto-release workflow. This may help avoid issues with rate limiting or unstable downloads from the Node.js distribution server.
2025-11-13 19:53:05 +08:00
手瓜一十雪
d09a82b1b8 Add Windows packaging workflow and NapCat entry files
Introduces a new GitHub Actions job to automate packaging NapCat for Windows, including downloading dependencies and assembling artifacts. Adds napcat.bat and index.js entry files for Windows distribution in packages/napcat-develop.
2025-11-13 19:48:15 +08:00
手瓜一十雪
85b5c881ba Add napcat-develop package and update scripts
Introduces the napcat-develop package with its own package.json and tsconfig.json. Updates build and dev scripts in the root package.json, modifies loadNapCat.cjs to adjust paths and output directories, and updates nodeTest.ps1 to use the correct script path.
2025-11-13 19:30:33 +08:00
手瓜一十雪
eebce222cf Update release note prompt formatting and examples
Changed the commit id placement in update items for clarity and added more example update entries to guide contributors in writing release notes.
2025-11-13 19:20:13 +08:00
手瓜一十雪
ec5ca5d89a Improve tag handling in auto-release workflow
Switches tag retrieval to use the GitHub API and sorts tags with jq for more reliable ordering. Adds explicit GITHUB_OWNER and GITHUB_REPO variables, improves previous tag selection logic, and ensures tags are fetched before generating release notes. Also adds more informative logging for debugging.
2025-11-13 19:16:12 +08:00
手瓜一十雪
31a7767ae4 Improve previous tag detection in auto-release workflow
Replaces 'git describe' with logic to find the previous tag by sorting all tags by creation date. This ensures accurate detection of the previous tag for release note generation and adds error handling if no previous tag is found.
2025-11-13 19:06:06 +08:00
手瓜一十雪
fec024334a Update release note prompt formatting instructions
Clarified that output must strictly follow the NapCat release note format and example. Updated constraints and replaced the example section with a real example for better guidance.
2025-11-13 19:03:28 +08:00
手瓜一十雪
2ad2af4d7c Trigger release workflow on tag push
Changed the workflow trigger from pushes to the main branch to pushes of any tag. This enables releases to be automatically created when a new tag is pushed.
2025-11-13 18:57:37 +08:00
手瓜一十雪
2a160d296f Remove tag trigger from auto-release workflow
The workflow will no longer be triggered by tag pushes, only by pushes to the main branch.
2025-11-13 18:57:20 +08:00
手瓜一十雪
e43f229e04 Update import paths to use direct module references
Changed import statements from alias-based paths (e.g., '@/napcat-common/store') to direct module references (e.g., 'napcat-common/src/store') in Proxy.ts, Status.ts, Data.ts, and SignToken.ts for improved compatibility and clarity.
2025-11-13 18:56:51 +08:00
手瓜一十雪
9158ebc136 Update workflow name to AI RELEASE NapCat
Renamed the GitHub Actions workflow from 'Build Action' to 'AI RELEASE NapCat' for improved clarity and identification.
2025-11-13 18:55:01 +08:00
手瓜一十雪
d758fe3a2b Improve release note generation in workflow
Enhances the release note generation step to compare commits between the previous and current tags, includes commit bodies and authors, and formats output for better readability. Also adds more robust extraction and output handling for the generated release notes.
2025-11-13 18:53:19 +08:00
手瓜一十雪
4abd0668a3 Refactor auto-release workflow for clarity and reliability
Renamed workflow, improved job and step naming, and streamlined artifact zipping and release note generation. Switched to using softprops/action-gh-release for release creation and asset upload, removed manual commit list preparation, and enhanced error handling for release note generation. Updated permissions and environment variables for consistency.
2025-11-13 18:46:48 +08:00
手瓜一十雪
0181700c3b feat: 自动化version打包 2025-11-13 18:31:55 +08:00
手瓜一十雪
6083e9cfcc feat: 以后仅维护napCatVersion 2025-11-13 16:14:31 +08:00
手瓜一十雪
5fec190c70 Remove package-lock.json
Deleted the package-lock.json file, possibly to reset dependency lock state or switch package managers. Ensure to regenerate lock file if needed for consistent dependency management.
2025-11-13 16:12:00 +08:00
手瓜一十雪
e1743ae5e4 Switch build and release workflows to npm install
Replaces pnpm install with npm install --omit=dev in both framework and shell build steps for build and release workflows. Removes package-lock.json after installation to avoid including it in artifacts.
2025-11-13 15:57:05 +08:00
手瓜一十雪
ded921c55e Update pnpm install flags in CI workflows
Replaces '--production' with '--prod --shamefully-hoist' in build and release GitHub Actions workflows to improve dependency installation compatibility.
2025-11-13 15:53:37 +08:00
手瓜一十雪
57e717e898 Update artifact paths in build and release workflows
Artifacts for NapCat.Framework and NapCat.Shell are now moved to 'framework-dist' and 'shell-dist' directories before upload. This change standardizes output locations and updates the upload paths accordingly in both build.yml and release.yml.
2025-11-13 15:49:11 +08:00
手瓜一十雪
55f21c6caa Install pnpm globally in build and release workflows
Added 'npm i -g pnpm' to both build and release GitHub Actions workflows to ensure pnpm is available before running installation and build commands.
2025-11-13 15:42:05 +08:00
手瓜一十雪
4360775eff refactor: 整体重构 (#1381)
* feat: pnpm new

* Refactor build and release workflows, update dependencies

Switch build scripts and workflows from npm to pnpm, update build and artifact paths, and simplify release workflow by removing version detection and changelog steps. Add new dependencies (silk-wasm, express, ws, node-pty-prebuilt-multiarch), update exports in package.json files, and add vite config for napcat-framework. Also, rename manifest.json for framework package and fix static asset copying in shell build config.
2025-11-13 15:39:42 +08:00
25 changed files with 668 additions and 1483 deletions

60
.github/prompt/release_note_prompt.txt vendored Normal file
View File

@@ -0,0 +1,60 @@
注意:输出必须严格使用 NapCat 的发布说明格式,严格保证示例格式,并用简体中文。
格式规则:
1. 第一行:# V{TAG}
2. 第二行:[使用文档](https://napneko.github.io/)
3. 空行后,按下面的节顺序输出(存在则输出,不存在则省略该节):
## Windows 一键包
- 简短一句话介绍一键包用途
- 列出可下载的文件名(只列文件名,不写下载链接)
## 警告
- 如果有需要特别提醒的兼容/运行库/版本要求,写成加粗警告句
## 如果WinX64缺少运行库或者xxx.dll
- 常见运行库建议
## 更新
按数字序列列出主要变更项,每条尽量一句话
- 前缀短 commit id例如1. 修复 get_essence_msg_list 崩溃 (a1b2c3d)
- 保持 4-18 条要点
## 开发者注意
- 列出迁移/接口断裂/配置变更;若无则省略
额外约束:
- 语言简体中文,面向最终用户
下面为真实示例,请完全参考
# V?.?.?
[使用文档](https://napneko.github.io/)
## Windows 一键包
我们为提供了的轻量化一键部署方案
相对于普通需要安装QQ的方案,下面已内置QQ和Napcat 阅读使用文档参考
你可以下载
NapCat.Shell.Windows.OneKey.zip (无头)
启动后可自动化部署一键包,教程参考使用文档安装部分
## 警告
**注意QQ版本推荐使用 40768+ 版本 最低可以使用40768版本**
**默认WebUi密钥为随机密码 控制台查看**
**[9.9.22-40990 X64 Win](https://dldir1v6.qq.com/qqfile/qq/QQNT/2c9d3f6c/QQ9.9.22.40990_x64.exe)**
[LinuxX64 DEB 40990 ](https://dldir1.qq.com/qqfile/qq/QQNT/ec800879/linuxqq_3.2.20-40990_amd64.deb)
[LinuxX64 RPM 40990 ](https://dldir1.qq.com/qqfile/qq/QQNT/ec800879/linuxqq_3.2.20-40990_x86_64.rpm)
[LinuxArm64 DEB 40990 ](https://dldir1.qq.com/qqfile/qq/QQNT/ec800879/linuxqq_3.2.20-40990_arm64.deb)
[LinuxArm64 RPM 40990 ](https://dldir1.qq.com/qqfile/qq/QQNT/ec800879/linuxqq_3.2.20-40990_aarch64.rpm)
[MAC DMG 40990 ](https://dldir1v6.qq.com/qqfile/qq/QQNT/c6cb0f5d/QQ_v6.9.82.40990.dmg)
## 如果WinX64缺少运行库或者xxx.dll
[安装运行库](https://aka.ms/vs/17/release/vc_redist.x64.exe)
## 更新
1. 修改了XXXXX
2. 新增了XXXX
3. 重构了XXXX

268
.github/workflows/auto-release.yml vendored Normal file
View File

@@ -0,0 +1,268 @@
name: AI RELEASE NapCat
on:
workflow_dispatch:
push:
tags:
- '*'
permissions: write-all
env:
OPENROUTER_API_URL: https://openrouter.ai/api/v1/chat/completions
OPENROUTER_MODEL: "openrouter/auto"
RELEASE_NAME: "NapCat"
jobs:
Build-LiteLoader:
runs-on: ubuntu-latest
steps:
- name: Clone Main Repository
uses: actions/checkout@v4
- name: Use Node.js 20.X
uses: actions/setup-node@v4
with:
node-version: 20.x
- name: Build NapCat.Framework
run: |
npm i -g pnpm
pnpm i
pnpm --filter napcat-webui-frontend run build || exit 1
pnpm run build:framework
mv packages/napcat-framework/dist framework-dist
cd framework-dist
npm install --omit=dev
rm ./package-lock.json || exit 0
- name: Upload Artifact
uses: actions/upload-artifact@v4
with:
name: NapCat.Framework
path: framework-dist
Build-Shell:
runs-on: ubuntu-latest
steps:
- name: Clone Main Repository
uses: actions/checkout@v4
- name: Use Node.js 20.X
uses: actions/setup-node@v4
with:
node-version: 20.x
- name: Build NapCat.Shell
run: |
npm i -g pnpm
pnpm i
pnpm --filter napcat-webui-frontend run build || exit 1
pnpm run build:shell
mv packages/napcat-shell/dist shell-dist
cd shell-dist
npm install --omit=dev
rm ./package-lock.json || exit 0
- name: Upload Artifact
uses: actions/upload-artifact@v4
with:
name: NapCat.Shell
path: shell-dist
Download-QNX64:
needs: Build-Shell
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Download Artifacts
uses: actions/download-artifact@v4
with:
path: ./artifacts
- name: Setup tools
run: |
sudo apt update
sudo apt install -y aria2 unzip zip p7zip-full curl jq
- name: Download QQ x64, Node.js and Assemble NapCat.Shell.Windows.Node.zip
run: |
set -euo pipefail
TMPDIR=$(mktemp -d)
cd "$TMPDIR"
# -----------------------------
# 1) 下载 QQ x64
# -----------------------------
JS_URL="https://cdn-go.cn/qq-web/im.qq.com_new/latest/rainbow/windowsConfig.js"
NT_URL=$(curl -fsSL "$JS_URL" | grep -oP '"ntDownloadX64Url"\s*:\s*"\K[^"]+')
QQ_ZIP="$(basename "$NT_URL")"
aria2c -x16 -s16 -k1M -o "$QQ_ZIP" "$NT_URL"
QQ_EXTRACT="$TMPDIR/qq_extracted"
mkdir -p "$QQ_EXTRACT"
7z x -y -o"$QQ_EXTRACT" "$QQ_ZIP" >/dev/null
# -----------------------------
# 2) 下载 Node.js Windows x64 zip 22.11.0
# -----------------------------
NODE_VER="22.11.0"
NODE_URL="https://nodejs.org/dist/v$NODE_VER/node-v$NODE_VER-win-x64.zip"
NODE_ZIP="node-v$NODE_VER-win-x64.zip"
aria2c -x1 -s1 -k1M -o "$NODE_ZIP" "$NODE_URL"
NODE_EXTRACT="$TMPDIR/node_extracted"
mkdir -p "$NODE_EXTRACT"
unzip -q "$NODE_ZIP" -d "$NODE_EXTRACT"
# -----------------------------
# 3) 创建输出目录
# -----------------------------
OUT_DIR="$GITHUB_WORKSPACE/napcat"
mkdir -p "$OUT_DIR/napcat"
# -----------------------------
# 4) 解压 NapCat.Shell.zip 到 napcat
# -----------------------------
unzip -q "$GITHUB_WORKSPACE/artifacts/NapCat.Shell.zip" -d "$OUT_DIR/napcat"
# -----------------------------
# 5) 拷贝 QQ 文件到 napcat
# -----------------------------
QQ_TARGETS=("avif_convert.dll" "broadcast_ipc.dll" "config.json" "libglib-2.0-0.dll" "libgobject-2.0-0.dll" "libvips-42.dll" "ncnn.dll" "opencv.dll" "package.json" "QBar.dll" "wrapper.node")
for name in "${QQ_TARGETS[@]}"; do
find "$QQ_EXTRACT" -iname "$name" -exec cp -a {} "$OUT_DIR/napcat" \; || true
done
# -----------------------------
# 6) 拷贝仓库文件 napcat.bat 和 index.js
# -----------------------------
cp -a "$GITHUB_WORKSPACE/packages/napcat-develop/napcat.bat" "$OUT_DIR/napcat/" || true
cp -a "$GITHUB_WORKSPACE/packages/napcat-develop/index.js" "$OUT_DIR/napcat/" || true
# -----------------------------
# 7) 拷贝 Node.exe 到 napcat
# -----------------------------
cp -a "$NODE_EXTRACT/node-v$NODE_VER-win-x64/node.exe" "$OUT_DIR/napcat/" || true
# -----------------------------
# 8) 生成 index.txt
# -----------------------------
echo "NapCat Files Collected on $(date)" > "$GITHUB_WORKSPACE/index.txt"
# -----------------------------
# 9) 打包 napcat命名为 NapCat.Shell.Windows.Node.zip
# -----------------------------
cd "$OUT_DIR"
zip -qr "$GITHUB_WORKSPACE/NapCat.Shell.Windows.Node.zip" napcat
- name: Upload Artifact
uses: actions/upload-artifact@v4
with:
name: NapCat.Shell.Windows.Node
path: NapCat.Shell.Windows.Node.zip
release-napcat:
needs: [Build-LiteLoader, Build-Shell]
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Download Artifacts
uses: actions/download-artifact@v4
with:
path: ./artifacts
- name: Zip Artifacts
run: |
cd artifacts
[ -d NapCat.Framework ] && zip -qr ../NapCat.Framework.zip -r NapCat.Framework
[ -d NapCat.Shell ] && zip -qr ../NapCat.Shell.zip -r NapCat.Shell
cd ..
- name: Generate release note via OpenRouter
env:
OPENROUTER_API_KEY: ${{ secrets.OPENROUTER_API_KEY }}
OPENROUTER_API_URL: ${{ env.OPENROUTER_API_URL }}
OPENROUTER_MODEL: ${{ env.OPENROUTER_MODEL }}
GITHUB_OWNER: "NapNeKo" # 替换成你的 repo owner
GITHUB_REPO: "NapCatQQ" # 替换成你的 repo 名
run: |
set -euo pipefail
# 当前 tag
CURRENT_TAG="${GITHUB_REF#refs/tags/}"
echo "Current tag: $CURRENT_TAG"
# 从 GitHub API 获取 tag 列表
TAGS_JSON=$(curl -s "https://api.github.com/repos/${GITHUB_OWNER}/${GITHUB_REPO}/tags?per_page=100")
TAGS=( $(echo "$TAGS_JSON" | jq -r '.[].name' | sort -V) )
# 找到上一个 tag
PREV_TAG=""
for i in "${!TAGS[@]}"; do
if [ "${TAGS[$i]}" = "$CURRENT_TAG" ]; then
if [ $i -gt 0 ]; then
PREV_TAG="${TAGS[$((i-1))]}"
fi
break
fi
done
if [ -z "$PREV_TAG" ]; then
echo "❌ Could not find previous tag for $CURRENT_TAG, aborting."
exit 1
fi
echo "Previous tag: $PREV_TAG"
# 强制拉取上一个 tag 和当前 tag
git fetch origin "refs/tags/$PREV_TAG:refs/tags/$PREV_TAG" --force
git fetch origin "refs/tags/$CURRENT_TAG:refs/tags/$CURRENT_TAG" --force
# 获取 commit title + body + 作者,保留换行
COMMITS=$(git log --pretty=format:'%h %B (%an)' "$PREV_TAG".."$CURRENT_TAG" | sed 's/$/\\n/')
echo "Commit list from $PREV_TAG to $CURRENT_TAG:"
echo -e "$COMMITS"
# 读取 prompt
PROMPT_FILE=".github/prompt/release_note_prompt.txt"
SYSTEM_PROMPT=$(<"$PROMPT_FILE")
# 构建用户内容
USER_CONTENT="TAG: $CURRENT_TAG\n提交列表:\n$COMMITS"
# 构建请求 JSON
BODY=$(jq -n \
--arg system "$SYSTEM_PROMPT" \
--arg user "$USER_CONTENT" \
'{model: env.OPENROUTER_MODEL, messages:[{role:"system", content:$system},{role:"user", content:$user}], temperature:0.2, max_tokens:800}')
# 调用 OpenRouter
RESPONSE=$(curl -s -X POST "$OPENROUTER_API_URL" \
-H "Authorization: Bearer $OPENROUTER_API_KEY" \
-H "Content-Type: application/json" \
-d "$BODY")
echo "=== OpenRouter raw response ==="
echo "$RESPONSE" | jq .
# 提取生成内容
RELEASE_BODY=$(echo "$RESPONSE" | jq -r '.choices[0].message.content // .choices[0].text // ""')
if [ -z "$RELEASE_BODY" ]; then
echo "❌ OpenRouter failed to generate release note, terminating workflow."
exit 1
fi
# 输出到 CHANGELOG.md
echo -e "$RELEASE_BODY" > CHANGELOG.md
echo "=== generated release note ==="
cat CHANGELOG.md
- name: Create Release Draft and Upload Artifacts
uses: softprops/action-gh-release@v1
with:
name: NapCat ${{ github.ref_name }}
token: ${{ secrets.GITHUB_TOKEN }}
body_path: CHANGELOG.md
files: |
NapCat.Framework.zip
NapCat.Shell.zip
draft: true

View File

@@ -19,16 +19,19 @@ jobs:
node-version: 20.x
- name: Build NapCat.Framework
run: |
npm i -g pnpm
pnpm i
pnpm --filter napcat-webui-frontend run build || exit 1
pnpm run build:framework
cd packages/napcat-framework/dist
pnpm install --production
mv packages/napcat-framework/dist framework-dist
cd framework-dist
npm install --omit=dev
rm ./package-lock.json || exit 0
- name: Upload Artifact
uses: actions/upload-artifact@v4
with:
name: NapCat.Framework
path: packages/napcat-framework/dist
path: framework-dist
Build-Shell:
runs-on: ubuntu-latest
steps:
@@ -40,13 +43,16 @@ jobs:
node-version: 20.x
- name: Build NapCat.Shell
run: |
npm i -g pnpm
pnpm i
pnpm --filter napcat-webui-frontend run build || exit 1
pnpm run build:shell
cd packages/napcat-shell/dist
pnpm install --production
mv packages/napcat-shell/dist shell-dist
cd shell-dist
npm install --omit=dev
rm ./package-lock.json || exit 0
- name: Upload Artifact
uses: actions/upload-artifact@v4
with:
name: NapCat.Shell
path: packages/napcat-shell/dist
path: shell-dist

View File

@@ -17,16 +17,19 @@ jobs:
node-version: 20.x
- name: Build NapCat.Framework
run: |
npm i -g pnpm
pnpm i
pnpm --filter napcat-webui-frontend run build || exit 1
pnpm run build:framework
cd packages/napcat-framework/dist
pnpm install --production
mv packages/napcat-framework/dist framework-dist
cd framework-dist
npm install --omit=dev
rm ./package-lock.json || exit 0
- name: Upload Artifact
uses: actions/upload-artifact@v4
with:
name: NapCat.Framework
path: packages/napcat-framework/dist
path: framework-dist
Build-Shell:
runs-on: ubuntu-latest
@@ -39,16 +42,19 @@ jobs:
node-version: 20.x
- name: Build NapCat.Shell
run: |
npm i -g pnpm
pnpm i
pnpm --filter napcat-webui-frontend run build || exit 1
pnpm run build:shell
cd packages/napcat-shell/dist
pnpm install --production
mv packages/napcat-shell/dist shell-dist
cd shell-dist
npm install --omit=dev
rm ./package-lock.json || exit 0
- name: Upload Artifact
uses: actions/upload-artifact@v4
with:
name: NapCat.Shell
path: packages/napcat-shell/dist
path: shell-dist
release-napcat:
needs: [Build-LiteLoader, Build-Shell]

2
.gitignore vendored
View File

@@ -16,4 +16,4 @@ checkVersion.sh
bun.lockb
tests/run/
guild1.db-wal
guild1.db-shm
guild1.db-shm

1457
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -2,11 +2,12 @@
"name": "napcat",
"private": true,
"type": "module",
"version": "4.9.42",
"version": "0.0.1",
"scripts": {
"build:shell": "pnpm --filter napcat-shell run build || exit 1",
"build:framework": "pnpm --filter napcat-framework run build || exit 1",
"build:webui": "pnpm --filter napcat-webui-frontend run build || exit 1"
"build:webui": "pnpm --filter napcat-webui-frontend run build || exit 1",
"dev:shell": "pnpm --filter napcat-develop run dev || exit 1"
},
"devDependencies": {
"@rollup/plugin-node-resolve": "^16.0.3",

9
packages/napcat-common/src/env.d.ts vendored Normal file
View File

@@ -0,0 +1,9 @@
/// <reference types="vite/client" />
declare global {
interface ImportMetaEnv {
readonly VITE_NAPCAT_VERSION: string;
}
}
export {};

View File

@@ -1 +1 @@
export const napCatVersion = '4.9.42';
export const napCatVersion = import.meta.env.VITE_NAPCAT_VERSION || 'alpha';

View File

@@ -0,0 +1,14 @@
const path = require('path');
const { pathToFileURL } = require('url');
// 公共目录变量
const BASE_DIR = __dirname;
const WRAPPER_NODE_PATH = path.join(BASE_DIR, 'wrapper.node');
const PACKAGE_JSON_PATH = path.join(BASE_DIR, 'package.json');
const CONFIG_JSON_PATH = path.join(BASE_DIR, 'config.json');
const NAPCAT_MJS_PATH = path.join(BASE_DIR, 'napcat', 'napcat.mjs');
process.env.NAPCAT_WRAPPER_PATH = WRAPPER_NODE_PATH;
process.env.NAPCAT_QQ_PACKAGE_INFO_PATH = PACKAGE_JSON_PATH;
process.env.NAPCAT_QQ_VERSION_CONFIG_PATH = CONFIG_JSON_PATH;
process.env.NAPCAT_DISABLE_PIPE = '1';
import(pathToFileURL(NAPCAT_MJS_PATH).href);

View File

@@ -18,9 +18,9 @@ if (versionFolders.length !== 1) {
}
const BASE_DIR = path.join(versionsDir, versionFolders[0], 'resources', 'app');
const TARGET_DIR = path.join(__dirname, 'run');
const TARGET_DIR = path.join(__dirname, 'dist');
const QQNT_FILE = path.join(__dirname, 'QQNT.dll');
const NAPCAT_MJS_PATH = path.join(__dirname, '..', 'dist', 'napcat.mjs');
const NAPCAT_MJS_PATH = path.join(__dirname, '..', 'napcat-shell','dist', 'napcat.mjs');
const itemsToCopy = [
'avif_convert.dll',
@@ -60,7 +60,7 @@ async function copyAll () {
process.env.NAPCAT_QQ_PACKAGE_INFO_PATH = path.join(TARGET_DIR, 'package.json');
process.env.NAPCAT_QQ_VERSION_CONFIG_PATH = path.join(TARGET_DIR, 'config.json');
process.env.NAPCAT_DISABLE_PIPE = '1';
process.env.NAPCAT_WORKDIR = path.join(__dirname, 'run');
process.env.NAPCAT_WORKDIR = TARGET_DIR;
console.log('Loading NapCat module...');
await import(pathToFileURL(NAPCAT_MJS_PATH).href);

View File

@@ -0,0 +1 @@
node.exe ./index.js

View File

@@ -5,4 +5,4 @@ $uninstall = $uninstall.Trim('"')
$qqPath = Split-Path $uninstall -Parent
Write-Host "QQPath: $qqPath"
node.exe "tests/loadNapCat.cjs" "$qqPath"
node.exe "./loadNapCat.cjs" "$qqPath"

View File

@@ -0,0 +1,27 @@
{
"name": "napcat-develop",
"version": "0.0.1",
"private": true,
"type": "module",
"main": "index.cjs",
"scripts": {
"dev": "powershell ./nodeTest.ps1"
},
"exports": {
".": {
"require": "./index.cjs"
},
"./*": {
"require": "./*"
}
},
"dependencies": {
"fs-extra": "^11.3.2"
},
"devDependencies": {
"@types/node": "^22.0.1"
},
"engines": {
"node": ">=18.0.0"
}
}

View File

@@ -0,0 +1,49 @@
{
"compilerOptions": {
"target": "ES2021",
"module": "ESNext",
"moduleResolution": "Node",
"lib": [
"ES2021"
],
"typeRoots": [
"./node_modules/@types"
],
"esModuleInterop": true,
"outDir": "dist",
"rootDir": "./",
"noEmit": false,
"sourceMap": true,
"strict": true,
"noImplicitAny": false,
"strictFunctionTypes": true,
"strictBindCallApply": true,
"alwaysStrict": true,
"noImplicitThis": true,
"noImplicitReturns": true,
"noPropertyAccessFromIndexSignature": true,
"noUncheckedIndexedAccess": true,
"exactOptionalPropertyTypes": false,
"forceConsistentCasingInFileNames": true,
"useUnknownInCatchVariables": true,
"noImplicitOverride": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"noFallthroughCasesInSwitch": true,
"useDefineForClassFields": true,
"experimentalDecorators": true,
"allowSyntheticDefaultImports": true,
"resolveJsonModule": true,
"baseUrl": "./",
"skipLibCheck": true,
"skipDefaultLibCheck": true,
"allowJs": true
},
"include": [
"**/*.cjs"
],
"exclude": [
"node_modules",
"dist"
]
}

View File

@@ -4,7 +4,7 @@
"name": "NapCatQQ",
"slug": "NapCat.Framework",
"description": "高性能的 OneBot 11 协议实现",
"version": "4.9.42",
"version": "0.0.1",
"icon": "./logo.png",
"authors": [
{

View File

@@ -23,7 +23,8 @@
"napcat-qrcode": "workspace:*"
},
"devDependencies": {
"@types/node": "^22.0.1"
"@types/node": "^22.0.1",
"napcat-vite": "workspace:*"
},
"engines": {
"node": ">=18.0.0"

View File

@@ -3,6 +3,8 @@ import { defineConfig, PluginOption, UserConfig } from 'vite';
import path, { resolve } from 'path';
import nodeResolve from '@rollup/plugin-node-resolve';
import { builtinModules } from 'module';
import napcatVersion from "napcat-vite/vite-plugin-version.js";
//依赖排除
const external = [
'silk-wasm',
@@ -21,6 +23,7 @@ const ShellBaseConfigPlugin: PluginOption[] = [
],
}),
nodeResolve(),
napcatVersion(),
];
const ShellBaseConfig = () =>
defineConfig({

View File

@@ -0,0 +1,31 @@
{
"name": "napcat-vite",
"version": "0.0.1",
"private": true,
"type": "module",
"main": "index.ts",
"scripts": {
"build": "vite build"
},
"exports": {
".": {
"import": "./index.ts"
},
"./*": {
"import": "./*"
}
},
"dependencies": {
"napcat-core": "workspace:*",
"napcat-common": "workspace:*",
"napcat-onebot": "workspace:*",
"napcat-webui-backend": "workspace:*",
"napcat-qrcode": "workspace:*"
},
"devDependencies": {
"@types/node": "^22.0.1"
},
"engines": {
"node": ">=18.0.0"
}
}

View File

@@ -0,0 +1,49 @@
{
"compilerOptions": {
"target": "ES2021",
"module": "ESNext",
"moduleResolution": "Node",
"lib": [
"ES2021"
],
"typeRoots": [
"./node_modules/@types"
],
"esModuleInterop": true,
"outDir": "dist",
"rootDir": "./",
"noEmit": false,
"sourceMap": true,
"strict": true,
"noImplicitAny": false,
"strictFunctionTypes": true,
"strictBindCallApply": true,
"alwaysStrict": true,
"noImplicitThis": true,
"noImplicitReturns": true,
"noPropertyAccessFromIndexSignature": true,
"noUncheckedIndexedAccess": true,
"exactOptionalPropertyTypes": false,
"forceConsistentCasingInFileNames": true,
"useUnknownInCatchVariables": true,
"noImplicitOverride": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"noFallthroughCasesInSwitch": true,
"useDefineForClassFields": true,
"experimentalDecorators": true,
"allowSyntheticDefaultImports": true,
"resolveJsonModule": true,
"baseUrl": "./",
"skipLibCheck": true,
"skipDefaultLibCheck": true,
"allowJs": true
},
"include": [
"vite-plugin-version.js"
],
"exclude": [
"node_modules",
"dist"
]
}

View File

@@ -0,0 +1,117 @@
import fs from "fs";
import path from "path";
import https from "https";
import { fileURLToPath } from "url";
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
/**
* NapCat Vite Plugin: fetches latest GitHub tag (not release) and injects into import.meta.env
*/
export default function vitePluginNapcatVersion() {
const pluginDir = path.resolve(__dirname, "dist");
const cacheFile = path.join(pluginDir, ".napcat-version.json");
const owner = "NapNeko";
const repo = "NapCatQQ";
const maxAgeMs = 24 * 60 * 60 * 1000; // cache 1 day
const githubToken = process.env.GITHUB_TOKEN;
fs.mkdirSync(pluginDir, { recursive: true });
function readCache() {
try {
const stat = fs.statSync(cacheFile);
if (Date.now() - stat.mtimeMs < maxAgeMs) {
const data = JSON.parse(fs.readFileSync(cacheFile, "utf8"));
if (data?.tag) return data.tag;
}
} catch {}
return null;
}
function writeCache(tag) {
try {
fs.writeFileSync(
cacheFile,
JSON.stringify({ tag, time: new Date().toISOString() }, null, 2)
);
} catch {}
}
async function fetchLatestTag() {
const url = `https://api.github.com/repos/${owner}/${repo}/tags`;
return new Promise((resolve, reject) => {
const req = https.get(
url,
{
headers: {
"User-Agent": "vite-plugin-napcat-version",
Accept: "application/vnd.github.v3+json",
...(githubToken ? { Authorization: `token ${githubToken}` } : {}),
},
},
(res) => {
let data = "";
res.on("data", (c) => (data += c));
res.on("end", () => {
try {
const json = JSON.parse(data);
if (Array.isArray(json) && json[0]?.name) {
resolve(json[0].name);
} else reject(new Error("Invalid GitHub tag response"));
} catch (e) {
reject(e);
}
});
}
);
req.on("error", reject);
});
}
async function getVersion() {
const cached = readCache();
if (cached) return cached;
try {
const tag = await fetchLatestTag();
writeCache(tag);
return tag;
} catch (e) {
console.warn("[vite-plugin-napcat-version] Failed to fetch tag:", e.message);
return cached ?? "v0.0.0";
}
}
let lastTag = null;
return {
name: "vite-plugin-napcat-version",
enforce: "pre",
async config(userConfig) {
const tag = await getVersion();
console.log(`[vite-plugin-napcat-version] Using version: ${tag}`);
lastTag = tag;
return {
define: {
...(userConfig.define || {}),
"import.meta.env.VITE_NAPCAT_VERSION": JSON.stringify(tag),
},
};
},
handleHotUpdate(ctx) {
if (path.resolve(ctx.file) === cacheFile) {
try {
const json = JSON.parse(fs.readFileSync(cacheFile, "utf8"));
const tag = json?.tag;
if (tag && tag !== lastTag) {
lastTag = tag;
ctx.server?.ws.send({ type: "full-reload" });
}
} catch {}
}
},
};
}

View File

@@ -1,5 +1,5 @@
import { RequestHandler } from 'express';
import { RequestUtil } from '@/napcat-common/request';
import { RequestUtil } from 'napcat-common/src/request';
import { sendError, sendSuccess } from '../utils/response';
export const GetProxyHandler: RequestHandler = async (req, res) => {

View File

@@ -1,5 +1,5 @@
import { RequestHandler } from 'express';
import { SystemStatus, statusHelperSubscription } from '@/napcat-core/helper/status';
import { SystemStatus, statusHelperSubscription } from 'napcat-core/helper/status';
export const StatusRealTimeHandler: RequestHandler = async (req, res) => {
res.setHeader('Content-Type', 'text/event-stream');

View File

@@ -1,6 +1,6 @@
import type { LoginRuntimeType } from '../types/data';
import packageJson from '../../../../package.json';
import store from '@/napcat-common/store';
import store from 'napcat-common/src/store';
const LoginRuntime: LoginRuntimeType = {
LoginCurrentTime: Date.now(),

View File

@@ -1,5 +1,5 @@
import crypto from 'crypto';
import store from '@/napcat-common/store';
import store from 'napcat-common/src/store';
export class AuthHelper {
private static readonly secretKey = Math.random().toString(36).slice(2);