Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
85 changes: 68 additions & 17 deletions .github/workflows/build-apk.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,13 @@ jobs:
- name: Install dependencies
run: flutter pub get

- name: Read app version
run: |
VERSION=$(sed -n 's/^version: *\([^+]*\)+.*/\1/p' pubspec.yaml)
test -n "$VERSION" || { echo 'Unable to read app version'; exit 1; }
echo "RELEASE_VERSION=$VERSION" >> "$GITHUB_ENV"
echo "RELEASE_TAG=v$VERSION" >> "$GITHUB_ENV"

- name: Configure release signing
env:
SECRETS_PK8_BASE64: ${{ secrets.SECRETS_PK8_BASE64 }}
Expand Down Expand Up @@ -95,13 +102,13 @@ jobs:
- name: Rename APK
run: |
mv build/app/outputs/flutter-apk/app-release.apk \
build/app/outputs/flutter-apk/AstrBot.apk
"build/app/outputs/flutter-apk/AstrBot-v${RELEASE_VERSION}.apk"

- name: Upload APK artifact
uses: actions/upload-artifact@v4
with:
name: AstrBot
path: build/app/outputs/flutter-apk/AstrBot.apk
name: AstrBot-v${{ env.RELEASE_VERSION }}
path: build/app/outputs/flutter-apk/AstrBot-v${{ env.RELEASE_VERSION }}.apk
compression-level: 0
if-no-files-found: error

Expand All @@ -110,20 +117,64 @@ jobs:
github.event_name == 'pull_request' &&
github.event.pull_request.merged == true
run: |
VERSION=$(sed -n 's/^version: *\([^+]*\)+.*/\1/p' pubspec.yaml)
TAG="v${VERSION}"
PREVIOUS_TAG=$(git describe --tags --abbrev=0 HEAD^ 2>/dev/null || true)
{
printf '更新内容\n\n'
if [ -n "$PREVIOUS_TAG" ]; then
git log --pretty=format:'- %s (%h)' "${PREVIOUS_TAG}..HEAD"
else
git log --pretty=format:'- %s (%h)' HEAD
if [ -n "$PREVIOUS_TAG" ]; then
LOG_RANGE="${PREVIOUS_TAG}..HEAD"
else
LOG_RANGE=HEAD
fi

NOTES_DIR=$(mktemp -d)
trap 'rm -rf "$NOTES_DIR"' EXIT
for CATEGORY in 新增 优化 修复 更新 修改 移除 其他; do
: > "$NOTES_DIR/$CATEGORY"
done

python3 - "$LOG_RANGE" "$NOTES_DIR" <<'PY'
import re
import subprocess
import sys

log_range, notes_dir = sys.argv[1:]
categories = ("新增", "优化", "修复", "更新", "修改", "移除", "其他")
separators = r",,、;;::|//\\\\\\s"
label_pattern = re.compile(
rf"(?:^|[{separators}])(?P<label>{'|'.join(categories)})"
rf"(?=[{separators}]|$)"
)
trim_pattern = re.compile(rf"^[{separators}]+|[{separators}]+$")

subjects = subprocess.check_output(
["git", "log", "--pretty=format:%s", log_range], text=True
).splitlines()
for subject in subjects:
if subject.startswith("Merge pull request"):
continue

matches = list(label_pattern.finditer(subject))
if not matches:
with open(f"{notes_dir}/其他", "a", encoding="utf-8") as output:
output.write(f"- {subject}\\n")
continue

for index, match in enumerate(matches):
category = match.group("label")
content_start = match.end()
content_end = matches[index + 1].start() if index + 1 < len(matches) else len(subject)
content = trim_pattern.sub("", subject[content_start:content_end]).strip()
if content:
with open(f"{notes_dir}/{category}", "a", encoding="utf-8") as output:
output.write(f"- {content}\\n")
PY

: > release-notes.md
for CATEGORY in 新增 优化 修复 更新 修改 移除 其他; do
if [ -s "$NOTES_DIR/$CATEGORY" ]; then
printf '%s\n' "$CATEGORY" >> release-notes.md
cat "$NOTES_DIR/$CATEGORY" >> release-notes.md
printf '\n' >> release-notes.md
fi
printf '\n'
} > release-notes.md
echo "RELEASE_TAG=$TAG" >> "$GITHUB_ENV"
echo "RELEASE_VERSION=$VERSION" >> "$GITHUB_ENV"
done

- name: Publish GitHub Release
if: >-
Expand All @@ -137,12 +188,12 @@ jobs:
--title "AstrBot $RELEASE_VERSION" \
--notes-file release-notes.md
gh release upload "$RELEASE_TAG" \
build/app/outputs/flutter-apk/AstrBot.apk \
"build/app/outputs/flutter-apk/AstrBot-v${RELEASE_VERSION}.apk" \
--clobber
else
gh release create "$RELEASE_TAG" \
--target "$GITHUB_SHA" \
--title "AstrBot $RELEASE_VERSION" \
--notes-file release-notes.md \
build/app/outputs/flutter-apk/AstrBot.apk
"build/app/outputs/flutter-apk/AstrBot-v${RELEASE_VERSION}.apk"
fi
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,11 @@
- 新增固定 NapCat 终端标签页,方便查看 NapCat 日志。
- 新增终端小键盘,提供`Ctrl`、`Alt`、`Shift` 修饰键及常用组合键, `Esc`、`Tab`、方向键、删除、翻页、行首行尾等常用按键,方便操作命令行。
- 长按方向键可快速移动光标、切换历史命令。
- 新增终端文本长按复制功能,长按选中文本后弹出复制弹窗
- 新增终端文本长按复制功能,长按选中文本后松手即可复制

### 修复与优化

- 使用原生 WebView ,访问 WebUI 无卡顿。
- 优化终端输入法弹出条件,仅在单击时才弹出输入法。
- 优化终端滚动输出,不会到达上限停止更新。
- 优化 后台进程处理,关闭终端页不会有残留进程。
- 优化网络下载,减少因为网络波动导致安装失败的概率。
Expand Down
26 changes: 14 additions & 12 deletions assets/astrbot-startup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -38,20 +38,22 @@ bump_progress() {
}

install_sudo_git_curl() {
apt-get update
apt --fix-broken install -y

# 检查必要命令
! command -v sudo && apt-get install -y sudo
for cmd in sudo git curl; do
if ! command -v $cmd >/dev/null 2>&1; then
progress_echo "缺少 $cmd,尝试安装 $cmd"
sudo apt-get install -y $cmd
if ! command -v $cmd >/dev/null 2>&1; then
echo "安装失败"
exit 1
if ! command -v sudo; then
apt-get update
apt --fix-broken install -y && apt-get install -y sudo
for cmd in sudo git curl; do
if ! command -v $cmd >/dev/null 2>&1; then
progress_echo "缺少 $cmd,尝试安装 $cmd"
sudo apt-get install -y $cmd
if ! command -v $cmd >/dev/null 2>&1; then
echo "安装失败"
exit 1
fi
fi
fi
done
done
fi
progress_echo "git & curl $L_INSTALLED"
}

Expand Down
Binary file not shown.
3 changes: 2 additions & 1 deletion git_repos/xterm.dart/lib/src/ui/terminal_text_style.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@ const _kDefaultFontSize = 13.0;

const _kDefaultHeight = 1.2;

const _kDefaultFontFamily = 'monospace';
const _kDefaultFontFamily = 'Cascadia Next SCNF';

const _kDefaultFontFamilyFallback = [
'monospace'
'Menlo',
'Monaco',
'Consolas',
Expand Down
3 changes: 2 additions & 1 deletion git_repos/xterm.dart/lib/src/utils/debugger_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,9 @@ class _CommandItem extends StatelessWidget {
style: TextStyle(
color: selected ? Colors.blue : Colors.black,
fontSize: 14,
fontFamily: 'monospace',
fontFamily: 'Cascadia Next SCNF',
fontFamilyFallback: [
'monospace'
'Menlo',
'Monaco',
'Consolas',
Expand Down
4 changes: 4 additions & 0 deletions git_repos/xterm.dart/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -59,3 +59,7 @@ flutter:
#
# For details regarding fonts in packages, see
# https://flutter.dev/custom-fonts/#from-packages
fonts:
- family: Cascadia Next SCNF
fonts:
- asset: fonts/CascadiaNextSCNF-Bold.ttf
37 changes: 27 additions & 10 deletions lib/ui/controllers/terminal_controller.dart
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ class HomeController extends GetxController {
final RxBool isLocalhostDetected = false.obs; // localhost:6185 检测标志
bool _isAppInForeground = true; // 应用是否在前台
bool _isAstrBotConfiguring = false; // AstrBot 配置中标志,用于控制终端输出过滤
bool _isNapCatLogin = false; // NapCat 登录标记
bool _isNapCatQuickLogin = false; // NapCat 快速登录标记
String _pendingOutput = ''; // 待处理的输出缓冲

File progressFile = File('${RuntimeEnvir.tmpPath}/progress');
Expand Down Expand Up @@ -240,6 +242,26 @@ class HomeController extends GetxController {
// 使用路由跳转
Get.toNamed(AppRoutes.webview);
webviewHasOpen = true; // 只有真正打开webview时才设置为true
if (!_isNapCatLogin && !_isNapCatQuickLogin) {
Get.snackbar(
'NapCat 未登录',
'请前往 NapCat 终端页或 WebUI 自行扫码登录',
snackPosition: SnackPosition.BOTTOM,
backgroundColor: Colors.red.withValues(alpha: 0.8),
colorText: Colors.white,
duration: const Duration(seconds: 5),
);
} else if (!_isNapCatLogin && _isNapCatQuickLogin) {
Get.snackbar(
'NapCat 未配置快速登录',
'请前往设置页配置快速登录QQ账号设置',
snackPosition: SnackPosition.BOTTOM,
backgroundColor: Colors.yellow.withValues(alpha: 0.8),
colorText: Colors.white,
duration: const Duration(seconds: 5),
);
_isNapCatLogin = true; // 视为已登录,防止重复触发
}
});
}
}
Expand Down Expand Up @@ -322,17 +344,12 @@ class HomeController extends GetxController {
}
}

if (event.contains('请扫描下面的二维码')) {
Get.snackbar(
'NapCat 未登录',
'请前往 NapCat 终端页或 WebUI 自行扫码登录',
snackPosition: SnackPosition.BOTTOM,
backgroundColor: Colors.red.withValues(alpha: 0.8),
colorText: Colors.white,
duration: const Duration(seconds: 5),
);
if (event.contains('可用于快速登录')) {
_isNapCatQuickLogin = true;
}

// 不取消订阅,继续监听以便终端日志持续更新
if (event.contains('正在快速登录')) {
_isNapCatLogin = true;
}

// 写入 NapCat 终端视图
Expand Down
7 changes: 6 additions & 1 deletion lib/ui/pages/terminal/terminal_tab_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -210,10 +210,15 @@ class _TerminalTabViewState extends State<TerminalTabView> {
if (text.isNotEmpty) {
_isCopyDialogOpen = true;
try {
String displayText = text;
if (text.length > 300) {
displayText = text.substring(0, 300) + '\n... (共 ${text.length} 个字符,已折叠)';
}

final shouldCopy = await Get.dialog<bool>(
AlertDialog(
title: const Text('复制终端文本'),
content: const Text('是否复制已选中的文本?'),
content: Text('$displayText\n\n是否复制已选中的文本?'),
actions: [
TextButton(
onPressed: () => Get.back(result: false),
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: astrbot_android
description: AstrBot Android App
publish_to: "none" # Remove this line if you wish to publish to pub.dev
version: 1.0.1+2
version: 1.0.2+3
environment:
sdk: ">=3.3.0 <4.0.0"

Expand Down
Loading