Merge upstream main and resolve conflicts
commit
78e36d4ade
|
|
@ -0,0 +1,54 @@
|
|||
# WeKnora Lite 配置模板
|
||||
# 复制此文件为 .env.lite 并按需修改
|
||||
# cp .env.lite.example .env.lite
|
||||
|
||||
GIN_MODE=debug
|
||||
|
||||
# 日志级别,可选值:debug, info, warn, error, fatal
|
||||
LOG_LEVEL=debug
|
||||
|
||||
# 可选:日志文件绝对路径;未配置时,macOS .app 默认写入
|
||||
# ~/Library/Logs/WeKnora Lite/WeKnora Lite.log
|
||||
# LOG_PATH=/absolute/path/to/weknora-lite.log
|
||||
|
||||
# === 数据库 ===
|
||||
# macOS .app 中相对路径会自动重定向到
|
||||
# ~/Library/Application Support/WeKnora Lite/data/
|
||||
DB_DRIVER=sqlite
|
||||
DB_PATH=./data/weknora.db
|
||||
|
||||
# === 检索引擎(FTS5 + sqlite-vec)===
|
||||
RETRIEVE_DRIVER=sqlite
|
||||
|
||||
# === 文件存储 ===
|
||||
STORAGE_TYPE=local
|
||||
LOCAL_STORAGE_BASE_DIR=./data/files
|
||||
|
||||
# === 流管理(内存,无 Redis)===
|
||||
STREAM_MANAGER_TYPE=memory
|
||||
|
||||
# === LLM 服务 ===
|
||||
# Ollama 本地服务(默认地址,按需修改)
|
||||
OLLAMA_BASE_URL=http://127.0.0.1:11434
|
||||
# 如使用其他 OpenAI 兼容服务,取消注释:
|
||||
# OPENAI_API_KEY=sk-xxx
|
||||
# OPENAI_BASE_URL=https://api.openai.com/v1
|
||||
|
||||
# === 安全配置(生产环境请务必修改!)===
|
||||
TENANT_AES_KEY=CHANGE-ME-32-char-secret-key!!!!
|
||||
JWT_SECRET=CHANGE-ME-jwt-secret
|
||||
|
||||
# === 功能开关 ===
|
||||
NEO4J_ENABLE=false
|
||||
WEKNORA_SANDBOX_MODE=disabled
|
||||
ENABLE_GRAPH_RAG=false
|
||||
DISABLE_REGISTRATION=false
|
||||
|
||||
# === 性能 ===
|
||||
CONCURRENCY_POOL_SIZE=3
|
||||
|
||||
# Docreader 地址
|
||||
DOCREADER_ADDR=127.0.0.1:50051
|
||||
|
||||
# Docreader 传输方式
|
||||
DOCREADER_TRANSPORT=grpc
|
||||
|
|
@ -0,0 +1,451 @@
|
|||
name: Release Lite Binaries
|
||||
|
||||
on:
|
||||
push:
|
||||
tags:
|
||||
- "v*"
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
tag:
|
||||
description: "Release tag (e.g. v0.2.0)"
|
||||
required: true
|
||||
|
||||
concurrency:
|
||||
group: release-lite-${{ github.ref }}
|
||||
cancel-in-progress: true
|
||||
|
||||
permissions:
|
||||
contents: write
|
||||
|
||||
env:
|
||||
GO_VERSION: "1.24"
|
||||
NODE_VERSION: "22"
|
||||
FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: "true"
|
||||
|
||||
jobs:
|
||||
# ── 1. Build frontend once, share as artifact (for Web CLI) ──
|
||||
build-frontend:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: ${{ env.NODE_VERSION }}
|
||||
cache: npm
|
||||
cache-dependency-path: frontend/package-lock.json
|
||||
|
||||
- name: Build frontend
|
||||
working-directory: frontend
|
||||
run: |
|
||||
npm ci
|
||||
npm run build
|
||||
|
||||
- uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: frontend-dist
|
||||
path: frontend/dist/
|
||||
retention-days: 1
|
||||
|
||||
# ── 2a. Build Web CLI binary per platform (native CGO) ──
|
||||
build-binary:
|
||||
needs: build-frontend
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
include:
|
||||
- os: ubuntu-latest
|
||||
goos: linux
|
||||
goarch: amd64
|
||||
- os: ubuntu-24.04-arm
|
||||
goos: linux
|
||||
goarch: arm64
|
||||
- os: macos-14
|
||||
goos: darwin
|
||||
goarch: amd64
|
||||
- os: macos-14
|
||||
goos: darwin
|
||||
goarch: arm64
|
||||
runs-on: ${{ matrix.os }}
|
||||
env:
|
||||
CGO_ENABLED: 1
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- uses: actions/setup-go@v5
|
||||
with:
|
||||
go-version: ${{ env.GO_VERSION }}
|
||||
cache: true
|
||||
|
||||
- uses: actions/download-artifact@v4
|
||||
with:
|
||||
name: frontend-dist
|
||||
path: web/
|
||||
|
||||
- name: Resolve version
|
||||
id: ver
|
||||
run: |
|
||||
if [ -n "${{ inputs.tag }}" ]; then
|
||||
VERSION="${{ inputs.tag }}"
|
||||
else
|
||||
VERSION="${GITHUB_REF#refs/tags/}"
|
||||
fi
|
||||
echo "version=${VERSION}" >> "$GITHUB_OUTPUT"
|
||||
echo "Building ${VERSION} for ${{ matrix.goos }}/${{ matrix.goarch }}"
|
||||
|
||||
- name: Build
|
||||
run: |
|
||||
export EDITION=lite
|
||||
eval "$(./scripts/get_version.sh env)"
|
||||
LDFLAGS="-w -s $(./scripts/get_version.sh ldflags)"
|
||||
export CGO_CFLAGS="-Wno-deprecated-declarations"
|
||||
if [ "${{ matrix.goos }}" = "darwin" ]; then
|
||||
export CGO_LDFLAGS="-Wl,-no_warn_duplicate_libraries"
|
||||
fi
|
||||
go build -tags "sqlite_fts5" -ldflags="${LDFLAGS}" \
|
||||
-o WeKnora-lite ./cmd/server
|
||||
|
||||
- name: Package tarball
|
||||
run: |
|
||||
ARCHIVE="WeKnora-lite_${{ steps.ver.outputs.version }}_${{ matrix.goos }}_${{ matrix.goarch }}"
|
||||
mkdir -p "${ARCHIVE}/web"
|
||||
cp WeKnora-lite "${ARCHIVE}/"
|
||||
cp -r web/* "${ARCHIVE}/web/"
|
||||
cp .env.lite.example "${ARCHIVE}/"
|
||||
cp docs/LITE.md "${ARCHIVE}/README.md"
|
||||
if [ -d config ]; then
|
||||
cp -r config "${ARCHIVE}/config"
|
||||
fi
|
||||
if [ -d migrations/sqlite ]; then
|
||||
mkdir -p "${ARCHIVE}/migrations/sqlite"
|
||||
cp -r migrations/sqlite/* "${ARCHIVE}/migrations/sqlite/"
|
||||
fi
|
||||
if [ -f deploy/weknora-lite.service ]; then
|
||||
cp deploy/weknora-lite.service "${ARCHIVE}/"
|
||||
fi
|
||||
tar czf "${ARCHIVE}.tar.gz" "${ARCHIVE}"
|
||||
shasum -a 256 "${ARCHIVE}.tar.gz" > "${ARCHIVE}.tar.gz.sha256"
|
||||
|
||||
- uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: release-${{ matrix.goos }}-${{ matrix.goarch }}
|
||||
path: |
|
||||
WeKnora-lite_*.tar.gz
|
||||
WeKnora-lite_*.tar.gz.sha256
|
||||
retention-days: 3
|
||||
|
||||
# ── 2b. Build Desktop APP per platform (Wails) ──
|
||||
build-desktop-app:
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
include:
|
||||
- os: macos-14
|
||||
platform: darwin/universal
|
||||
arch_label: macOS_universal
|
||||
artifact_name: desktop-macos-universal
|
||||
- os: macos-14
|
||||
platform: darwin/amd64
|
||||
arch_label: macOS_amd64
|
||||
artifact_name: desktop-macos-amd64
|
||||
- os: macos-14
|
||||
platform: darwin/arm64
|
||||
arch_label: macOS_arm64
|
||||
artifact_name: desktop-macos-arm64
|
||||
- os: ubuntu-latest
|
||||
platform: linux/amd64
|
||||
arch_label: linux_amd64
|
||||
artifact_name: desktop-linux-amd64
|
||||
- os: windows-latest
|
||||
platform: windows/amd64
|
||||
arch_label: windows_amd64
|
||||
artifact_name: desktop-windows-amd64
|
||||
runs-on: ${{ matrix.os }}
|
||||
env:
|
||||
CGO_ENABLED: 1
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- uses: actions/setup-go@v5
|
||||
with:
|
||||
go-version: ${{ env.GO_VERSION }}
|
||||
cache: true
|
||||
|
||||
- uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: ${{ env.NODE_VERSION }}
|
||||
cache: npm
|
||||
cache-dependency-path: frontend/package-lock.json
|
||||
|
||||
- name: Install Wails CLI
|
||||
run: go install github.com/wailsapp/wails/v2/cmd/wails@latest
|
||||
|
||||
- name: Install Linux dependencies
|
||||
if: runner.os == 'Linux'
|
||||
run: |
|
||||
sudo apt-get update
|
||||
sudo apt-get install -y libgtk-3-dev libwebkit2gtk-4.1-dev
|
||||
|
||||
- name: Install NSIS (Windows)
|
||||
if: runner.os == 'Windows'
|
||||
run: choco install nsis -y
|
||||
|
||||
- name: Resolve version
|
||||
id: ver
|
||||
shell: bash
|
||||
run: |
|
||||
if [ -n "${{ inputs.tag }}" ]; then
|
||||
VERSION="${{ inputs.tag }}"
|
||||
else
|
||||
VERSION="${GITHUB_REF#refs/tags/}"
|
||||
fi
|
||||
echo "version=${VERSION}" >> "$GITHUB_OUTPUT"
|
||||
|
||||
- name: Pre-compile Go packages (Windows)
|
||||
if: runner.os == 'Windows'
|
||||
shell: bash
|
||||
run: |
|
||||
export GOLANG_PROTOBUF_REGISTRATION_CONFLICT=warn
|
||||
export CGO_CFLAGS="-Wno-deprecated-declarations"
|
||||
cd cmd/desktop
|
||||
go build -p 1 -buildvcs=false -tags "desktop,sqlite_fts5,production" -o _prebuild_tmp.exe . || true
|
||||
rm -f _prebuild_tmp.exe
|
||||
|
||||
- name: Build desktop app
|
||||
shell: bash
|
||||
run: |
|
||||
export EDITION=lite
|
||||
export GOLANG_PROTOBUF_REGISTRATION_CONFLICT=warn
|
||||
eval "$(./scripts/get_version.sh env)"
|
||||
LDFLAGS="$(./scripts/get_version.sh ldflags) -X 'google.golang.org/protobuf/reflect/protoregistry.conflictPolicy=warn'"
|
||||
export CGO_CFLAGS="-Wno-deprecated-declarations"
|
||||
|
||||
BUILD_TAGS="sqlite_fts5"
|
||||
NSIS_FLAG=""
|
||||
|
||||
if [ "${{ runner.os }}" = "Linux" ]; then
|
||||
BUILD_TAGS="sqlite_fts5 webkit2_41"
|
||||
fi
|
||||
if [ "${{ runner.os }}" = "macOS" ]; then
|
||||
export CGO_LDFLAGS="-Wl,-no_warn_duplicate_libraries"
|
||||
fi
|
||||
if [ "${{ runner.os }}" = "Windows" ]; then
|
||||
NSIS_FLAG="-nsis"
|
||||
fi
|
||||
|
||||
cd cmd/desktop
|
||||
wails build -clean \
|
||||
-tags "${BUILD_TAGS}" \
|
||||
-platform "${{ matrix.platform }}" \
|
||||
${NSIS_FLAG} \
|
||||
-ldflags="${LDFLAGS}" \
|
||||
-o "WeKnora Lite"
|
||||
|
||||
# ── macOS: bundle .app with resources, then create DMG ──
|
||||
- name: Package macOS app
|
||||
if: runner.os == 'macOS'
|
||||
run: |
|
||||
APP_BUNDLE="WeKnora Lite.app"
|
||||
SRC="cmd/desktop/build/bin/${APP_BUNDLE}"
|
||||
RESOURCES="${SRC}/Contents/Resources"
|
||||
|
||||
mkdir -p "${RESOURCES}/config"
|
||||
mkdir -p "${RESOURCES}/migrations/sqlite"
|
||||
|
||||
if [ -f .env.lite.example ]; then
|
||||
cp .env.lite.example "${RESOURCES}/.env"
|
||||
fi
|
||||
if [ -d migrations/sqlite ]; then
|
||||
cp -r migrations/sqlite/* "${RESOURCES}/migrations/sqlite/"
|
||||
fi
|
||||
if [ -d config ]; then
|
||||
cp -r config/* "${RESOURCES}/config/"
|
||||
fi
|
||||
|
||||
DMG_NAME="WeKnora-Lite-App_${{ steps.ver.outputs.version }}_${{ matrix.arch_label }}"
|
||||
|
||||
DMG_SRC="dmg_staging"
|
||||
mkdir -p "${DMG_SRC}"
|
||||
cp -R "cmd/desktop/build/bin/${APP_BUNDLE}" "${DMG_SRC}/"
|
||||
ln -s /Applications "${DMG_SRC}/Applications"
|
||||
|
||||
hdiutil create -volname "WeKnora Lite" \
|
||||
-srcfolder "${DMG_SRC}" \
|
||||
-ov -format UDZO \
|
||||
"${DMG_NAME}.dmg"
|
||||
|
||||
shasum -a 256 "${DMG_NAME}.dmg" > "${DMG_NAME}.dmg.sha256"
|
||||
|
||||
# ── Linux: package tarball ──
|
||||
- name: Package Linux app
|
||||
if: runner.os == 'Linux'
|
||||
run: |
|
||||
ARCHIVE="WeKnora-Lite-App_${{ steps.ver.outputs.version }}_${{ matrix.arch_label }}"
|
||||
mkdir -p "${ARCHIVE}"
|
||||
cp "cmd/desktop/build/bin/WeKnora Lite" "${ARCHIVE}/"
|
||||
if [ -f .env.lite.example ]; then
|
||||
cp .env.lite.example "${ARCHIVE}/"
|
||||
fi
|
||||
cp docs/LITE.md "${ARCHIVE}/README.md"
|
||||
if [ -d config ]; then
|
||||
cp -r config "${ARCHIVE}/config"
|
||||
fi
|
||||
if [ -d migrations/sqlite ]; then
|
||||
mkdir -p "${ARCHIVE}/migrations/sqlite"
|
||||
cp -r migrations/sqlite/* "${ARCHIVE}/migrations/sqlite/"
|
||||
fi
|
||||
tar czf "${ARCHIVE}.tar.gz" "${ARCHIVE}"
|
||||
shasum -a 256 "${ARCHIVE}.tar.gz" > "${ARCHIVE}.tar.gz.sha256"
|
||||
|
||||
# ── Windows: package NSIS installer or plain exe ──
|
||||
- name: Package Windows app
|
||||
if: runner.os == 'Windows'
|
||||
shell: bash
|
||||
run: |
|
||||
ARCHIVE="WeKnora-Lite-App_${{ steps.ver.outputs.version }}_${{ matrix.arch_label }}"
|
||||
# Wails -nsis generates an installer named {app}-amd64-installer.exe
|
||||
INSTALLER="cmd/desktop/build/bin/WeKnora Lite-amd64-installer.exe"
|
||||
if [ -f "$INSTALLER" ]; then
|
||||
cp "$INSTALLER" "${ARCHIVE}_setup.exe"
|
||||
sha256sum "${ARCHIVE}_setup.exe" > "${ARCHIVE}_setup.exe.sha256"
|
||||
else
|
||||
cp "cmd/desktop/build/bin/WeKnora Lite.exe" "${ARCHIVE}.exe"
|
||||
sha256sum "${ARCHIVE}.exe" > "${ARCHIVE}.exe.sha256"
|
||||
fi
|
||||
|
||||
- uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: ${{ matrix.artifact_name }}
|
||||
path: |
|
||||
WeKnora-Lite-App_*
|
||||
retention-days: 3
|
||||
|
||||
# ── 3. Create GitHub Release ──
|
||||
release:
|
||||
needs: [build-binary, build-desktop-app]
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- uses: actions/download-artifact@v4
|
||||
with:
|
||||
pattern: release-*
|
||||
merge-multiple: true
|
||||
|
||||
- uses: actions/download-artifact@v4
|
||||
with:
|
||||
pattern: desktop-*
|
||||
merge-multiple: true
|
||||
|
||||
- name: Resolve version
|
||||
id: ver
|
||||
run: |
|
||||
if [ -n "${{ inputs.tag }}" ]; then
|
||||
VERSION="${{ inputs.tag }}"
|
||||
else
|
||||
VERSION="${GITHUB_REF#refs/tags/}"
|
||||
fi
|
||||
echo "version=${VERSION}" >> "$GITHUB_OUTPUT"
|
||||
|
||||
- name: Generate release notes
|
||||
id: notes
|
||||
run: |
|
||||
cat > notes.md << 'NOTES'
|
||||
## WeKnora Lite ${{ steps.ver.outputs.version }}
|
||||
|
||||
### Web CLI 版(命令行 / 服务器部署)
|
||||
|
||||
单二进制部署,零外部依赖(无需 Docker / PostgreSQL / Redis)。
|
||||
|
||||
```bash
|
||||
# 1. 解压
|
||||
tar xzf WeKnora-lite_${{ steps.ver.outputs.version }}_<os>_<arch>.tar.gz
|
||||
cd WeKnora-lite_${{ steps.ver.outputs.version }}_<os>_<arch>
|
||||
|
||||
# 2. 配置
|
||||
cp .env.lite.example .env.lite
|
||||
# 编辑 .env.lite,至少确认 OLLAMA_BASE_URL 正确
|
||||
|
||||
# 3. 启动 Ollama(如尚未运行)
|
||||
ollama serve &
|
||||
ollama pull qwen2.5:7b
|
||||
ollama pull nomic-embed-text
|
||||
|
||||
# 4. 运行
|
||||
set -a && source .env.lite && set +a
|
||||
./WeKnora-lite
|
||||
# 访问 http://localhost:8080
|
||||
```
|
||||
|
||||
| 文件 | 平台 |
|
||||
|------|------|
|
||||
| `WeKnora-lite_*_linux_amd64.tar.gz` | Linux x86_64 |
|
||||
| `WeKnora-lite_*_linux_arm64.tar.gz` | Linux ARM64 |
|
||||
| `WeKnora-lite_*_darwin_amd64.tar.gz` | macOS Intel |
|
||||
| `WeKnora-lite_*_darwin_arm64.tar.gz` | macOS Apple Silicon |
|
||||
|
||||
---
|
||||
|
||||
### 桌面 APP 版(开箱即用,无需命令行)
|
||||
|
||||
原生桌面应用,内置 Web 服务,双击即可运行。
|
||||
|
||||
| 文件 | 平台 |
|
||||
|------|------|
|
||||
| `WeKnora-Lite-App_*_macOS_universal.dmg` | macOS (Intel + Apple Silicon) |
|
||||
| `WeKnora-Lite-App_*_macOS_amd64.dmg` | macOS Intel |
|
||||
| `WeKnora-Lite-App_*_macOS_arm64.dmg` | macOS Apple Silicon |
|
||||
| `WeKnora-Lite-App_*_linux_amd64.tar.gz` | Linux x86_64 |
|
||||
| `WeKnora-Lite-App_*_windows_amd64_setup.exe` | Windows x86_64 (安装包) |
|
||||
|
||||
详细文档见 [LITE.md](docs/LITE.md)。
|
||||
NOTES
|
||||
|
||||
- name: Create release
|
||||
env:
|
||||
GH_TOKEN: ${{ github.token }}
|
||||
run: |
|
||||
gh release create "${{ steps.ver.outputs.version }}" \
|
||||
--title "WeKnora Lite ${{ steps.ver.outputs.version }}" \
|
||||
--notes-file notes.md \
|
||||
WeKnora-lite_*.tar.gz \
|
||||
WeKnora-lite_*.tar.gz.sha256 \
|
||||
WeKnora-Lite-App_* || true
|
||||
|
||||
# ── 4. Update Homebrew Formula ──
|
||||
update-homebrew:
|
||||
needs: release
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
ref: main
|
||||
token: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
- name: Resolve version
|
||||
id: ver
|
||||
run: |
|
||||
if [ -n "${{ inputs.tag }}" ]; then
|
||||
VERSION="${{ inputs.tag }}"
|
||||
else
|
||||
VERSION="${GITHUB_REF#refs/tags/}"
|
||||
fi
|
||||
echo "version=${VERSION}" >> "$GITHUB_OUTPUT"
|
||||
|
||||
- name: Wait for release assets to be available
|
||||
run: sleep 15
|
||||
|
||||
- name: Update Formula
|
||||
run: ./scripts/update-homebrew-formula.sh "${{ steps.ver.outputs.version }}"
|
||||
|
||||
- name: Commit and push
|
||||
run: |
|
||||
git config user.name "github-actions[bot]"
|
||||
git config user.email "github-actions[bot]@users.noreply.github.com"
|
||||
git add Formula/weknora-lite.rb
|
||||
if git diff --cached --quiet; then
|
||||
echo "No changes to Formula"
|
||||
else
|
||||
git commit -m "formula: update weknora-lite to ${{ steps.ver.outputs.version }}"
|
||||
git push origin main
|
||||
fi
|
||||
|
|
@ -1,8 +1,9 @@
|
|||
# 忽略所有隐藏文件和目录
|
||||
.*
|
||||
# 但不忽略示例文件
|
||||
# 但不忽略特定隐藏文件和目录
|
||||
!.env.example
|
||||
!.gitignore
|
||||
!.github/
|
||||
|
||||
# 敏感文件
|
||||
*.pem
|
||||
|
|
@ -29,6 +30,7 @@ logs/
|
|||
|
||||
WeKnora
|
||||
WeKnora-lite
|
||||
cmd/desktop/build/bin/
|
||||
/models/
|
||||
test/data/mswag.txt
|
||||
data/files/
|
||||
|
|
@ -40,7 +42,7 @@ web/
|
|||
|
||||
**/__pycache__
|
||||
/scripts/scale_dev_jobs.sh
|
||||
server
|
||||
/server
|
||||
frontend/.vite
|
||||
frontend/chrome-extension/
|
||||
WeKnora-Chrome-Extension
|
||||
|
|
@ -0,0 +1,118 @@
|
|||
class WeknoraLite < Formula
|
||||
desc "Knowledge base management system — single-binary Lite edition"
|
||||
homepage "https://github.com/Tencent/WeKnora"
|
||||
version "0.3.6-test"
|
||||
license "Apache-2.0"
|
||||
|
||||
on_macos do
|
||||
on_arm do
|
||||
url "https://github.com/Tencent/WeKnora/releases/download/v#{version}/WeKnora-lite_v#{version}_darwin_arm64.tar.gz"
|
||||
sha256 "1da2d4eef99e5cf8aa7a58501baa059e9e20482e1bd65a36a82321a89926c104"
|
||||
end
|
||||
on_intel do
|
||||
url "https://github.com/Tencent/WeKnora/releases/download/v#{version}/WeKnora-lite_v#{version}_darwin_amd64.tar.gz"
|
||||
sha256 "c187e16ac7671a615f012c82ebd89786e11fcf67cccc773eff175e4bdf7c9c06"
|
||||
end
|
||||
end
|
||||
|
||||
on_linux do
|
||||
on_arm do
|
||||
url "https://github.com/Tencent/WeKnora/releases/download/v#{version}/WeKnora-lite_v#{version}_linux_arm64.tar.gz"
|
||||
sha256 "bc4e184da005b60d1e8c037a61c58e643ebdc9bf14470fae6cd6227f52f02f1c"
|
||||
end
|
||||
on_intel do
|
||||
url "https://github.com/Tencent/WeKnora/releases/download/v#{version}/WeKnora-lite_v#{version}_linux_amd64.tar.gz"
|
||||
sha256 "cb34c50fb5b05555fca16084ffc7710524ff78badb3b1b82474eb89d21545d6e"
|
||||
end
|
||||
end
|
||||
|
||||
def install
|
||||
libexec.install "WeKnora-lite"
|
||||
pkgshare.install "web" if File.directory?("web")
|
||||
pkgshare.install "config" if File.directory?("config")
|
||||
pkgshare.install ".env.lite.example"
|
||||
doc.install "README.md"
|
||||
pkgshare.install "migrations" if File.directory?("migrations")
|
||||
|
||||
(bin/"weknora-lite").write <<~SH
|
||||
#!/bin/bash
|
||||
CONFIG_DIR="${WEKNORA_CONFIG_DIR:-${XDG_CONFIG_HOME:-$HOME/.config}/weknora}"
|
||||
DATA_DIR="${WEKNORA_DATA_DIR:-${XDG_DATA_HOME:-$HOME/.local/share}/weknora}"
|
||||
|
||||
mkdir -p "$DATA_DIR/files" "$CONFIG_DIR/config" 2>/dev/null
|
||||
|
||||
if [ ! -f "$CONFIG_DIR/config/config.yaml" ]; then
|
||||
cp -r "#{pkgshare}/config/" "$CONFIG_DIR/config/"
|
||||
fi
|
||||
|
||||
if [ ! -d "$CONFIG_DIR/migrations" ] && [ -d "#{pkgshare}/migrations" ]; then
|
||||
ln -sf "#{pkgshare}/migrations" "$CONFIG_DIR/migrations"
|
||||
fi
|
||||
|
||||
if [ ! -f "$CONFIG_DIR/.env.lite" ]; then
|
||||
cp "#{pkgshare}/.env.lite.example" "$CONFIG_DIR/.env.lite"
|
||||
sed -i '' "s|DB_PATH=.*|DB_PATH=$DATA_DIR/weknora.db|" "$CONFIG_DIR/.env.lite"
|
||||
sed -i '' "s|LOCAL_STORAGE_BASE_DIR=.*|LOCAL_STORAGE_BASE_DIR=$DATA_DIR/files|" "$CONFIG_DIR/.env.lite"
|
||||
rm -f "$CONFIG_DIR/.env.lite-e"
|
||||
echo ""
|
||||
echo "已创建配置文件: $CONFIG_DIR/.env.lite"
|
||||
echo "请根据需要编辑(如修改 LLM 地址、安全密钥等)。"
|
||||
echo ""
|
||||
fi
|
||||
|
||||
set -a
|
||||
source "$CONFIG_DIR/.env.lite"
|
||||
set +a
|
||||
|
||||
export DB_PATH="${DB_PATH:-$DATA_DIR/weknora.db}"
|
||||
export LOCAL_STORAGE_BASE_DIR="${LOCAL_STORAGE_BASE_DIR:-$DATA_DIR/files}"
|
||||
export WEKNORA_WEB_DIR="${WEKNORA_WEB_DIR:-#{pkgshare}/web}"
|
||||
|
||||
cd "$CONFIG_DIR"
|
||||
exec "#{libexec}/WeKnora-lite" "$@"
|
||||
SH
|
||||
end
|
||||
|
||||
def post_install
|
||||
(var/"weknora").mkpath
|
||||
(var/"log").mkpath
|
||||
end
|
||||
|
||||
service do
|
||||
run [bin/"weknora-lite"]
|
||||
keep_alive true
|
||||
working_dir var/"weknora"
|
||||
log_path var/"log/weknora-lite.log"
|
||||
error_log_path var/"log/weknora-lite.log"
|
||||
end
|
||||
|
||||
def caveats
|
||||
<<~EOS
|
||||
前台运行:
|
||||
weknora-lite
|
||||
|
||||
后台服务(推荐):
|
||||
brew services start weknora-lite # 启动并开机自启
|
||||
brew services stop weknora-lite # 停止
|
||||
brew services restart weknora-lite # 重启
|
||||
brew services info weknora-lite # 查看状态
|
||||
|
||||
日志:
|
||||
#{var}/log/weknora-lite.log
|
||||
|
||||
首次运行会自动创建配置文件:
|
||||
~/.config/weknora/.env.lite
|
||||
|
||||
数据存储在:
|
||||
~/.local/share/weknora/
|
||||
|
||||
如需修改配置(LLM 服务地址、安全密钥等):
|
||||
$EDITOR ~/.config/weknora/.env.lite
|
||||
brew services restart weknora-lite
|
||||
EOS
|
||||
end
|
||||
|
||||
test do
|
||||
assert_predicate bin/"weknora-lite", :executable?
|
||||
end
|
||||
end
|
||||
41
Makefile
41
Makefile
|
|
@ -1,4 +1,4 @@
|
|||
.PHONY: help build run test clean docker-build-app docker-build-docreader docker-build-frontend docker-build-all docker-run migrate-up migrate-down docker-restart docker-stop start-all stop-all start-ollama stop-ollama build-images build-images-app build-images-docreader build-images-frontend clean-images check-env list-containers pull-images show-platform dev-start dev-stop dev-restart dev-logs dev-status dev-app dev-frontend docs install-swagger
|
||||
.PHONY: help build run test clean docker-build-app docker-build-docreader docker-build-frontend docker-build-all docker-run migrate-up migrate-down docker-restart docker-stop start-all stop-all start-ollama stop-ollama build-images build-images-app build-images-docreader build-images-frontend clean-images check-env list-containers pull-images show-platform dev-start dev-stop dev-restart dev-logs dev-status dev-app dev-frontend docs install-swagger build-lite run-lite package-lite
|
||||
|
||||
# Show help
|
||||
help:
|
||||
|
|
@ -56,6 +56,12 @@ help:
|
|||
@echo " dev-status 查看开发环境状态"
|
||||
@echo " dev-app 启动后端应用(本地运行,需先运行 dev-start)"
|
||||
@echo " dev-frontend 启动前端(本地运行,需先运行 dev-start)"
|
||||
@echo ""
|
||||
@echo "Lite 模式(零外部依赖):"
|
||||
@echo " build-lite 构建 Lite 版本(先构建前端到 web/,再构建 Go;SKIP_FRONTEND=1 跳过前端)"
|
||||
@echo " run-lite 构建并启动 Lite 版本"
|
||||
@echo " package-lite 构建并打包 Lite 发行包(tarball)"
|
||||
@echo " package-mac-app 构建并打包 macOS 桌面应用 (.app)"
|
||||
|
||||
# Go related variables
|
||||
BINARY_NAME=WeKnora
|
||||
|
|
@ -231,6 +237,39 @@ build-prod:
|
|||
LDFLAGS="-X 'github.com/Tencent/WeKnora/internal/handler.Version=$$VERSION' -X 'github.com/Tencent/WeKnora/internal/handler.Edition=standard' -X 'github.com/Tencent/WeKnora/internal/handler.CommitID=$$COMMIT_ID' -X 'github.com/Tencent/WeKnora/internal/handler.BuildTime=$$BUILD_TIME' -X 'github.com/Tencent/WeKnora/internal/handler.GoVersion=$$GO_VERSION' -X 'google.golang.org/protobuf/reflect/protoregistry.conflictPolicy=warn'"; \
|
||||
go build -ldflags="-w -s $$LDFLAGS" -o $(BINARY_NAME) $(MAIN_PATH)
|
||||
|
||||
# Build Lite version (single binary, SQLite + in-memory queue)
|
||||
# 会先构建前端到 web/,再构建 Go 二进制;SKIP_FRONTEND=1 可跳过前端
|
||||
build-lite:
|
||||
@if [ -f frontend/package.json ] && [ "$${SKIP_FRONTEND:-}" != "1" ]; then \
|
||||
echo ">> Building frontend for Lite..."; \
|
||||
(cd frontend && npm ci --prefer-offline && npm run build) && \
|
||||
rm -rf web && cp -r frontend/dist web; \
|
||||
elif [ "$${SKIP_FRONTEND:-}" = "1" ]; then \
|
||||
echo ">> Skipping frontend (SKIP_FRONTEND=1)"; \
|
||||
else \
|
||||
echo ">> No frontend/package.json, skipping frontend"; \
|
||||
fi
|
||||
export EDITION=lite; \
|
||||
eval "$$(./scripts/get_version.sh env)"; \
|
||||
LDFLAGS="$$(./scripts/get_version.sh ldflags) -X 'google.golang.org/protobuf/reflect/protoregistry.conflictPolicy=warn'"; \
|
||||
CGO_ENABLED=1 \
|
||||
CGO_CFLAGS="-Wno-deprecated-declarations" \
|
||||
CGO_LDFLAGS="-Wl,-no_warn_duplicate_libraries" \
|
||||
go build -tags "sqlite_fts5" -ldflags="-w -s $$LDFLAGS" -o $(BINARY_NAME)-lite $(MAIN_PATH)
|
||||
|
||||
# Run Lite version with .env.lite defaults
|
||||
run-lite: build-lite
|
||||
@if [ ! -f .env.lite ]; then echo "Error: .env.lite not found"; exit 1; fi
|
||||
@set -a && . ./.env.lite && set +a && ./$(BINARY_NAME)-lite
|
||||
|
||||
# Package Lite version into distributable tarball
|
||||
package-lite:
|
||||
./scripts/package-lite.sh
|
||||
|
||||
# Package Mac App
|
||||
package-mac-app:
|
||||
./scripts/package-mac-app.sh
|
||||
|
||||
download_spatial:
|
||||
go run cmd/download/duckdb/duckdb.go
|
||||
|
||||
|
|
|
|||
|
|
@ -181,7 +181,7 @@ Fully modular pipeline from document parsing, vectorization, and retrieval to LL
|
|||
| LLMs | OpenAI / DeepSeek / Qwen (Alibaba Cloud) / Zhipu / Hunyuan / Doubao (Volcengine) / Gemini / MiniMax / NVIDIA / Novita AI / SiliconFlow / OpenRouter / Ollama |
|
||||
| Embeddings | Ollama / BGE / GTE / OpenAI-compatible APIs |
|
||||
| Vector DBs | PostgreSQL (pgvector) / Elasticsearch / Milvus / Weaviate / Qdrant |
|
||||
| Object Storage | Local / MinIO / AWS S3 / Volcengine TOS |
|
||||
| Object Storage | Local / MinIO / AWS S3 / Volcengine TOS / Alibaba Cloud OSS |
|
||||
| IM Channels | WeCom / Feishu / Slack / Telegram / DingTalk / Mattermost |
|
||||
| Web Search | DuckDuckGo / Bing / Google / Tavily |
|
||||
|
||||
|
|
|
|||
|
|
@ -180,7 +180,7 @@ WeKnora 提供**快速问答**与**智能推理**两种问答模式。快速问
|
|||
|------|------|
|
||||
| 模型厂商 | OpenAI / DeepSeek / Qwen(阿里云)/ 智谱 / 混元 / 豆包(火山引擎)/ Gemini / MiniMax / NVIDIA / Novita AI / SiliconFlow / OpenRouter / Ollama |
|
||||
| 向量数据库 | PostgreSQL (pgvector) / Elasticsearch / Milvus / Weaviate / Qdrant |
|
||||
| 对象存储 | 本地 / 腾讯云COS / 火山引擎 TOS / MinIO / AWS S3 |
|
||||
| 对象存储 | 本地 / 腾讯云COS / 火山引擎 TOS / MinIO / AWS S3 / 阿里云 OSS |
|
||||
| IM 集成 | 企业微信 / 飞书 / Slack / Telegram / 钉钉 / Mattermost |
|
||||
| 网络搜索 | DuckDuckGo / Bing / Google / Tavily |
|
||||
|
||||
|
|
|
|||
|
|
@ -182,7 +182,7 @@ Feishuなどの外部プラットフォームからのナレッジ自動同期
|
|||
| 大規模モデル | OpenAI / DeepSeek / Qwen (Alibaba Cloud) / Zhipu / Hunyuan / Doubao (Volcengine) / Gemini / MiniMax / NVIDIA / Novita AI / SiliconFlow / OpenRouter / Ollama |
|
||||
| Embedding | Ollama / BGE / GTE / OpenAI 互換 API |
|
||||
| ベクトル DB | PostgreSQL (pgvector) / Elasticsearch / Milvus / Weaviate / Qdrant |
|
||||
| オブジェクトストレージ | ローカル / MinIO / AWS S3 / 火山引擎 TOS |
|
||||
| オブジェクトストレージ | ローカル / MinIO / AWS S3 / 火山引擎 TOS / Alibaba Cloud OSS |
|
||||
| IM 統合 | WeChat Work / Feishu / Slack / Telegram / DingTalk / Mattermost |
|
||||
| Web 検索 | DuckDuckGo / Bing / Google / Tavily |
|
||||
|
||||
|
|
|
|||
|
|
@ -191,7 +191,7 @@ Feishu 등 외부 플랫폼에서 지식 자동 동기화를 지원하며(추가
|
|||
| LLM | OpenAI / DeepSeek / Qwen (Alibaba Cloud) / Zhipu / Hunyuan / Doubao (Volcengine) / Gemini / MiniMax / NVIDIA / Novita AI / SiliconFlow / OpenRouter / Ollama |
|
||||
| Embedding | Ollama / BGE / GTE / OpenAI 호환 API |
|
||||
| 벡터 DB | PostgreSQL (pgvector) / Elasticsearch / Milvus / Weaviate / Qdrant |
|
||||
| 오브젝트 스토리지 | 로컬 / MinIO / AWS S3 / Volcengine TOS |
|
||||
| 오브젝트 스토리지 | 로컬 / MinIO / AWS S3 / Volcengine TOS / Alibaba Cloud OSS |
|
||||
| IM 통합 | WeChat Work / Feishu / Slack / Telegram / DingTalk / Mattermost |
|
||||
| 웹 검색 | DuckDuckGo / Bing / Google / Tavily |
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,84 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
"strings"
|
||||
)
|
||||
|
||||
// App holds Wails-bound state for the desktop shell.
|
||||
type App struct {
|
||||
ctx context.Context
|
||||
backendURL string
|
||||
apiLanBaseURL string
|
||||
listenPublic bool
|
||||
shutdownCh chan struct{}
|
||||
}
|
||||
|
||||
// NewApp creates a new App application struct.
|
||||
func NewApp() *App {
|
||||
return &App{
|
||||
shutdownCh: make(chan struct{}, 1),
|
||||
}
|
||||
}
|
||||
|
||||
// startup is called when the application starts.
|
||||
func (a *App) startup(ctx context.Context) {
|
||||
a.ctx = ctx
|
||||
}
|
||||
|
||||
func (a *App) shutdown(ctx context.Context) {
|
||||
a.shutdownCh <- struct{}{}
|
||||
}
|
||||
|
||||
// GetAPIBaseURL returns the local HTTP base URL for REST API calls (e.g. http://127.0.0.1:PORT/api/v1).
|
||||
// The desktop shell proxies the webview to this address; window.location.origin is not the API host.
|
||||
func (a *App) GetAPIBaseURL() string {
|
||||
if a.backendURL == "" {
|
||||
return ""
|
||||
}
|
||||
return strings.TrimRight(a.backendURL, "/") + "/api/v1"
|
||||
}
|
||||
|
||||
// GetDesktopHTTPPortSetting returns the saved local API port (0 = random port each launch).
|
||||
func (a *App) GetDesktopHTTPPortSetting() int {
|
||||
return LoadDesktopPrefsHTTPPort()
|
||||
}
|
||||
|
||||
// SetDesktopHTTPPortSetting saves the preferred local API port to application support. Restart the app for it to take effect unless it matches the current listener.
|
||||
func (a *App) SetDesktopHTTPPortSetting(port int) error {
|
||||
return SaveDesktopHTTPPortPreference(port)
|
||||
}
|
||||
|
||||
// GetDesktopHTTPBindPublicSetting returns whether API listens on all interfaces (0.0.0.0).
|
||||
func (a *App) GetDesktopHTTPBindPublicSetting() bool {
|
||||
return LoadDesktopHTTPBindPublic()
|
||||
}
|
||||
|
||||
// SetDesktopHTTPBindPublicSetting saves LAN/public listen preference. Restart the app for it to take effect.
|
||||
func (a *App) SetDesktopHTTPBindPublicSetting(v bool) error {
|
||||
return SaveDesktopHTTPBindPublicPreference(v)
|
||||
}
|
||||
|
||||
// GetAPILanBaseURL returns a suggested base URL for other devices on the LAN (…/api/v1), or empty if not in bind-public mode or IP detection failed.
|
||||
func (a *App) GetAPILanBaseURL() string {
|
||||
return a.apiLanBaseURL
|
||||
}
|
||||
|
||||
// GetDesktopListenPublicActive is true when this session’s API server is listening on all interfaces (runtime), not the saved preference.
|
||||
func (a *App) GetDesktopListenPublicActive() bool {
|
||||
return a.listenPublic
|
||||
}
|
||||
|
||||
// CheckForUpdates manually triggers the update check from the frontend.
|
||||
func (a *App) CheckForUpdates() {
|
||||
if a.ctx != nil {
|
||||
checkUpdate(a.ctx, desktopAboutVersion(), true, false)
|
||||
}
|
||||
}
|
||||
|
||||
// AutoCheckForUpdates silently checks for updates and downloads them.
|
||||
func (a *App) AutoCheckForUpdates() {
|
||||
if a.ctx != nil {
|
||||
checkUpdate(a.ctx, desktopAboutVersion(), false, true)
|
||||
}
|
||||
}
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 130 KiB |
|
|
@ -0,0 +1,63 @@
|
|||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>CFBundlePackageType</key>
|
||||
<string>APPL</string>
|
||||
<key>CFBundleName</key>
|
||||
<string>{{.Info.ProductName}}</string>
|
||||
<key>CFBundleExecutable</key>
|
||||
<string>{{.OutputFilename}}</string>
|
||||
<key>CFBundleIdentifier</key>
|
||||
<string>com.wails.{{.Name}}</string>
|
||||
<key>CFBundleVersion</key>
|
||||
<string>{{.Info.ProductVersion}}</string>
|
||||
<key>CFBundleGetInfoString</key>
|
||||
<string>{{.Info.Comments}}</string>
|
||||
<key>CFBundleShortVersionString</key>
|
||||
<string>{{.Info.ProductVersion}}</string>
|
||||
<key>CFBundleIconFile</key>
|
||||
<string>iconfile</string>
|
||||
<key>LSMinimumSystemVersion</key>
|
||||
<string>10.13.0</string>
|
||||
<key>NSHighResolutionCapable</key>
|
||||
<string>true</string>
|
||||
<key>NSHumanReadableCopyright</key>
|
||||
<string>{{.Info.Copyright}}</string>
|
||||
{{if .Info.FileAssociations}}
|
||||
<key>CFBundleDocumentTypes</key>
|
||||
<array>
|
||||
{{range .Info.FileAssociations}}
|
||||
<dict>
|
||||
<key>CFBundleTypeExtensions</key>
|
||||
<array>
|
||||
<string>{{.Ext}}</string>
|
||||
</array>
|
||||
<key>CFBundleTypeName</key>
|
||||
<string>{{.Name}}</string>
|
||||
<key>CFBundleTypeRole</key>
|
||||
<string>{{.Role}}</string>
|
||||
<key>CFBundleTypeIconFile</key>
|
||||
<string>{{.IconName}}</string>
|
||||
</dict>
|
||||
{{end}}
|
||||
</array>
|
||||
{{end}}
|
||||
{{if .Info.Protocols}}
|
||||
<key>CFBundleURLTypes</key>
|
||||
<array>
|
||||
{{range .Info.Protocols}}
|
||||
<dict>
|
||||
<key>CFBundleURLName</key>
|
||||
<string>com.wails.{{.Scheme}}</string>
|
||||
<key>CFBundleURLSchemes</key>
|
||||
<array>
|
||||
<string>{{.Scheme}}</string>
|
||||
</array>
|
||||
<key>CFBundleTypeRole</key>
|
||||
<string>{{.Role}}</string>
|
||||
</dict>
|
||||
{{end}}
|
||||
</array>
|
||||
{{end}}
|
||||
</dict>
|
||||
</plist>
|
||||
|
|
@ -0,0 +1,517 @@
|
|||
//go:build !bindings
|
||||
|
||||
package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"net"
|
||||
"net/http"
|
||||
"net/http/httputil"
|
||||
"net/url"
|
||||
"os"
|
||||
"os/signal"
|
||||
"path/filepath"
|
||||
"strconv"
|
||||
"strings"
|
||||
"syscall"
|
||||
"time"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/wailsapp/wails/v2"
|
||||
"github.com/wailsapp/wails/v2/pkg/menu"
|
||||
"github.com/wailsapp/wails/v2/pkg/menu/keys"
|
||||
"github.com/wailsapp/wails/v2/pkg/options"
|
||||
"github.com/wailsapp/wails/v2/pkg/options/assetserver"
|
||||
"github.com/wailsapp/wails/v2/pkg/options/mac"
|
||||
|
||||
"github.com/Tencent/WeKnora/internal/config"
|
||||
"github.com/Tencent/WeKnora/internal/container"
|
||||
"github.com/Tencent/WeKnora/internal/logger"
|
||||
"github.com/Tencent/WeKnora/internal/runtime"
|
||||
"github.com/Tencent/WeKnora/internal/tracing"
|
||||
"github.com/Tencent/WeKnora/internal/types/interfaces"
|
||||
"github.com/joho/godotenv"
|
||||
wailsruntime "github.com/wailsapp/wails/v2/pkg/runtime"
|
||||
)
|
||||
|
||||
// dragHandlerJS is injected into the webview on DomReady.
|
||||
// It bypasses Wails' built-in CSS-variable-based drag detection (which uses
|
||||
// getComputedStyle and has timing/inheritance issues with dynamic SPA content)
|
||||
// and instead uses robust DOM-traversal via el.closest() plus a Y-position
|
||||
// fallback for the macOS title-bar region on layout containers. The "drag"
|
||||
// message is sent directly through the WKWebView script-message bridge,
|
||||
// which the native Objective-C handler in WailsContext.m converts to
|
||||
// [NSWindow performWindowDragWithEvent:].
|
||||
const dragHandlerJS = `(function(){
|
||||
if(window.__wkDragBound)return;
|
||||
window.__wkDragBound=true;
|
||||
document.documentElement.classList.add('wails-desktop');
|
||||
|
||||
// Disable rubber-band overscroll that reveals the dark window background
|
||||
document.documentElement.style.overscrollBehavior='none';
|
||||
document.body.style.overscrollBehavior='none';
|
||||
|
||||
if(window.wails&&window.wails.flags){
|
||||
window.wails.flags.cssDragProperty='__disabled__';
|
||||
window.wails.flags.cssDragValue='__never__';
|
||||
}
|
||||
|
||||
// Prevent native text/image drag-out to fix the "selected and dragged away" issue
|
||||
window.addEventListener('dragstart', function(e){
|
||||
e.preventDefault();
|
||||
}, true);
|
||||
|
||||
var TITLEBAR_H=38;
|
||||
|
||||
// We specifically look for Wails' inline style attributes injected by Vue,
|
||||
// and custom drag classes, avoiding generic headers like .section-header
|
||||
var dragSel='.logo_row,.menu_top,.drag-region,[data-wails-drag],' +
|
||||
'[style*="--wails-draggable: drag"],[style*="--wails-draggable:drag"]';
|
||||
|
||||
var noDragSel='button,a,input,select,textarea,[role="button"],' +
|
||||
'.t-button,.t-input,.t-select,.t-textarea,' +
|
||||
'.header-actions,.header-action-btn,.sidebar-toggle,.logo_box,' +
|
||||
'.close-btn,.menu_item,.submenu,.submenu_item,.menu_bottom,' +
|
||||
'.t-popup,.t-dropdown,.t-tooltip,.t-dialog,[data-no-drag],' +
|
||||
'[style*="--wails-draggable: no-drag"],[style*="--wails-draggable:no-drag"]';
|
||||
|
||||
var layoutClasses=['main','chat','dialogue-wrap','kb-list-container','kb-list-content',
|
||||
'agent-list-container','agent-list-content','org-list-container','org-list-content','aside_box',
|
||||
'ks-container','ks-content','settings-overlay','knowledge-layout',
|
||||
'faq-manager-wrapper','login-layout'];
|
||||
|
||||
function sendDrag(){
|
||||
try{window.webkit.messageHandlers.external.postMessage('drag')}
|
||||
catch(_){try{window.WailsInvoke('drag')}catch(e){}}
|
||||
}
|
||||
|
||||
function isLayoutEl(el){
|
||||
for(var i=0;i<layoutClasses.length;i++){
|
||||
if(el.classList.contains(layoutClasses[i]))return true;
|
||||
}
|
||||
var tag=el.tagName;
|
||||
return tag==='BODY'||tag==='HTML';
|
||||
}
|
||||
|
||||
function shouldDrag(el,y){
|
||||
if(!(el instanceof Element))return false;
|
||||
if(el.closest(noDragSel))return false;
|
||||
if(el.closest(dragSel))return true;
|
||||
if(y<=TITLEBAR_H&&isLayoutEl(el))return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
window.addEventListener('mousedown',function(e){
|
||||
var target=e.target;
|
||||
if(target&&target.nodeType===Node.TEXT_NODE){
|
||||
target=target.parentElement;
|
||||
}
|
||||
if(e.button!==0||e.detail!==1)return;
|
||||
if(!shouldDrag(target,e.clientY))return;
|
||||
e.preventDefault();
|
||||
sendDrag();
|
||||
},true);
|
||||
|
||||
// Intercept external link clicks and window.open so they open in the system browser
|
||||
document.addEventListener('click',function(e){
|
||||
var el=e.target;
|
||||
while(el&&el.tagName!=='A')el=el.parentElement;
|
||||
if(!el||!el.href)return;
|
||||
var href=el.href;
|
||||
if(href.indexOf('http://')===0||href.indexOf('https://')===0){
|
||||
if(window.runtime&&window.runtime.BrowserOpenURL){
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
window.runtime.BrowserOpenURL(href);
|
||||
}
|
||||
}
|
||||
},true);
|
||||
|
||||
var origOpen=window.open;
|
||||
window.open=function(url){
|
||||
if(url&&(typeof url==='string')&&(url.indexOf('http://')===0||url.indexOf('https://')===0)){
|
||||
if(window.runtime&&window.runtime.BrowserOpenURL){
|
||||
window.runtime.BrowserOpenURL(url);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
return origOpen.apply(window,arguments);
|
||||
};
|
||||
})();`
|
||||
|
||||
// wailsThemeSyncJS:与 index.html 首屏一致,在 DomReady 再跑一遍,覆盖 Ctrl+R 后 runtime 就绪时机
|
||||
const wailsThemeSyncJS = `(function(){try{var t=localStorage.getItem('WeKnora_theme')||'light';if(t==='system')t=window.matchMedia('(prefers-color-scheme: dark)').matches?'dark':'light';var bg=t==='dark'?'#181818':'#eee';document.documentElement.setAttribute('theme-mode',t);document.documentElement.style.background=bg;document.documentElement.style.minHeight='100%';document.documentElement.style.colorScheme=t==='dark'?'dark':'light';if(document.body){document.body.style.background=bg;document.body.style.minHeight='100%';}var w=window.runtime;if(!w)return;if(t==='dark'){if(w.WindowSetDarkTheme)w.WindowSetDarkTheme();if(w.WindowSetBackgroundColour)w.WindowSetBackgroundColour(24,24,24,255);}else{if(w.WindowSetLightTheme)w.WindowSetLightTheme();if(w.WindowSetBackgroundColour)w.WindowSetBackgroundColour(238,238,238,255);}}catch(e){}})()`
|
||||
|
||||
const weknoraGitHubRepoURL = "https://github.com/Tencent/WeKnora"
|
||||
|
||||
func main() {
|
||||
// For macOS .app bundle, the working directory is usually "/" or the MacOS folder.
|
||||
// We need to change the working directory to the Resources folder where our configs are.
|
||||
execPath, errPath := os.Executable()
|
||||
if errPath == nil && strings.Contains(execPath, ".app/Contents/MacOS") {
|
||||
resPath := filepath.Join(filepath.Dir(filepath.Dir(execPath)), "Resources")
|
||||
_ = os.Chdir(resPath)
|
||||
} else if _, err := os.Stat(filepath.Join("config", "config.yaml")); os.IsNotExist(err) {
|
||||
// wails build 生成绑定时 cwd 多为 cmd/desktop,LoadConfig 默认找 ./config/config.yaml;
|
||||
// 仓库实际配置在 <repo>/config/,向上两级即可。
|
||||
repoRoot := filepath.Clean(filepath.Join("..", ".."))
|
||||
if _, err := os.Stat(filepath.Join(repoRoot, "config", "config.yaml")); err == nil {
|
||||
_ = os.Chdir(repoRoot)
|
||||
}
|
||||
}
|
||||
|
||||
// Load .env explicitly for the desktop app so DB_DRIVER gets loaded
|
||||
_ = godotenv.Load()
|
||||
configureDesktopStorage(execPath)
|
||||
logger.ConfigureFromEnv()
|
||||
|
||||
// Set Gin mode
|
||||
if os.Getenv("GIN_MODE") == "release" {
|
||||
gin.SetMode(gin.ReleaseMode)
|
||||
} else {
|
||||
gin.SetMode(gin.DebugMode)
|
||||
}
|
||||
|
||||
// Build dependency injection container
|
||||
c := container.BuildContainer(runtime.GetContainer())
|
||||
|
||||
// Initialize the WeKnora App struct
|
||||
app := NewApp()
|
||||
|
||||
// Error channel to capture server startup errors
|
||||
serverErrCh := make(chan error, 1)
|
||||
|
||||
// Run backend in a separate goroutine
|
||||
go func() {
|
||||
err := c.Invoke(func(
|
||||
cfg *config.Config,
|
||||
router *gin.Engine,
|
||||
tracer *tracing.Tracer,
|
||||
resourceCleaner interfaces.ResourceCleaner,
|
||||
) error {
|
||||
server := &http.Server{Handler: router}
|
||||
|
||||
// 127.0.0.1 + saved port from settings (desktop-prefs.json), or :0 for random free port.
|
||||
addr := desktopBackendListenAddr()
|
||||
|
||||
listener, err := listenWithRetry(addr, 10, 300*time.Millisecond)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to start server: %v", err)
|
||||
}
|
||||
|
||||
tcpAddr := listener.Addr().(*net.TCPAddr)
|
||||
port := tcpAddr.Port
|
||||
app.listenPublic = LoadDesktopHTTPBindPublic()
|
||||
// Reverse proxy and webview API calls always use loopback; avoid 0.0.0.0 / [::] as dial target.
|
||||
app.backendURL = fmt.Sprintf("http://127.0.0.1:%d", port)
|
||||
app.apiLanBaseURL = ""
|
||||
if app.listenPublic {
|
||||
if ip := desktopPreferredLANIPv4(); ip != nil {
|
||||
app.apiLanBaseURL = fmt.Sprintf("http://%s:%d/api/v1", ip.String(), port)
|
||||
}
|
||||
}
|
||||
|
||||
// Handle graceful shutdown from Wails OnShutdown hook
|
||||
go func() {
|
||||
<-app.shutdownCh
|
||||
logger.Infof(context.Background(), "Wails shutting down, stopping Go backend...")
|
||||
|
||||
listener.Close()
|
||||
shutdownTimeout := cfg.Server.ShutdownTimeout
|
||||
if shutdownTimeout == 0 {
|
||||
shutdownTimeout = 30 * time.Second
|
||||
}
|
||||
shutdownCtx, cancel := context.WithTimeout(context.Background(), shutdownTimeout)
|
||||
defer cancel()
|
||||
|
||||
if err := server.Shutdown(shutdownCtx); err != nil {
|
||||
server.Close()
|
||||
}
|
||||
resourceCleaner.Cleanup(shutdownCtx)
|
||||
}()
|
||||
|
||||
// Also listen for OS signals just in case
|
||||
signals := make(chan os.Signal, 1)
|
||||
signal.Notify(signals, syscall.SIGINT, syscall.SIGTERM)
|
||||
go func() {
|
||||
<-signals
|
||||
app.shutdownCh <- struct{}{} // trigger shutdown
|
||||
}()
|
||||
|
||||
logger.Infof(context.Background(), "Server is running at %s (proxy -> %s)", tcpAddr.String(), app.backendURL)
|
||||
if err := server.Serve(listener); err != nil && err != http.ErrServerClosed {
|
||||
return fmt.Errorf("server error: %v", err)
|
||||
}
|
||||
return nil
|
||||
})
|
||||
|
||||
if err != nil {
|
||||
serverErrCh <- err
|
||||
logger.Fatalf(context.Background(), "Failed to run backend: %v", err)
|
||||
}
|
||||
}()
|
||||
|
||||
// Give the server a moment to start and determine its port
|
||||
time.Sleep(500 * time.Millisecond)
|
||||
|
||||
// Create application with options
|
||||
// macOS app menu
|
||||
AppMenu := menu.NewMenu()
|
||||
FileMenu := AppMenu.AddSubmenu("WeKnora Lite")
|
||||
FileMenu.AddText("About WeKnora", keys.CmdOrCtrl("i"), func(_ *menu.CallbackData) {
|
||||
if app.ctx == nil {
|
||||
return
|
||||
}
|
||||
choice, err := wailsruntime.MessageDialog(app.ctx, wailsruntime.MessageDialogOptions{
|
||||
Type: wailsruntime.InfoDialog,
|
||||
Title: "WeKnora Lite",
|
||||
Message: fmt.Sprintf("WeKnora Lite — Desktop Edition\n\nA RAG framework for document understanding and semantic Q&A over complex, heterogeneous content.\n\nVersion %s\n© 2026 Tencent\n\nGitHub:\n%s", desktopAboutVersion(), weknoraGitHubRepoURL),
|
||||
Buttons: []string{"Open GitHub", "OK"},
|
||||
DefaultButton: "OK",
|
||||
})
|
||||
if err != nil {
|
||||
logger.Warnf(context.Background(), "About dialog: %v", err)
|
||||
return
|
||||
}
|
||||
if choice == "Open GitHub" {
|
||||
wailsruntime.BrowserOpenURL(app.ctx, weknoraGitHubRepoURL)
|
||||
}
|
||||
})
|
||||
FileMenu.AddText("Check for Updates...", nil, func(_ *menu.CallbackData) {
|
||||
if app.ctx == nil {
|
||||
return
|
||||
}
|
||||
checkUpdate(app.ctx, desktopAboutVersion(), true, false)
|
||||
})
|
||||
FileMenu.AddSeparator()
|
||||
FileMenu.AddText("Quit", keys.CmdOrCtrl("q"), func(_ *menu.CallbackData) {
|
||||
app.shutdown(context.Background())
|
||||
os.Exit(0)
|
||||
})
|
||||
|
||||
AppMenu.Append(menu.EditMenu())
|
||||
|
||||
ViewMenu := AppMenu.AddSubmenu("View")
|
||||
ViewMenu.AddText("Reload", keys.CmdOrCtrl("r"), func(_ *menu.CallbackData) {
|
||||
if app.ctx != nil {
|
||||
wailsruntime.EventsEmit(app.ctx, "app:reload")
|
||||
}
|
||||
})
|
||||
|
||||
// Wait for the backend URL to be set
|
||||
targetURL, _ := url.Parse(app.backendURL)
|
||||
proxy := httputil.NewSingleHostReverseProxy(targetURL)
|
||||
|
||||
// Start Wails application
|
||||
// We use a Reverse Proxy to seamlessly proxy Wails' frontend to our Go backend
|
||||
err := wails.Run(&options.App{
|
||||
Title: "WeKnora Lite",
|
||||
Width: 1280,
|
||||
Height: 800,
|
||||
DisableResize: false,
|
||||
Menu: AppMenu,
|
||||
AssetServer: &assetserver.Options{
|
||||
Handler: proxy,
|
||||
},
|
||||
StartHidden: false, // Show window on startup
|
||||
OnStartup: app.startup,
|
||||
OnDomReady: func(ctx context.Context) {
|
||||
wailsruntime.WindowExecJS(ctx, wailsThemeSyncJS)
|
||||
wailsruntime.WindowExecJS(ctx, dragHandlerJS)
|
||||
// 注入真实 API 根路径(与 window.location.origin 不同);无 Go 绑定时仍可显示。
|
||||
if u := strings.TrimSpace(app.backendURL); u != "" {
|
||||
apiRoot := strings.TrimRight(u, "/") + "/api/v1"
|
||||
inject := fmt.Sprintf(`try{window.__WEKNORA_API_BASE__=%s}catch(e){}`, strconv.Quote(apiRoot))
|
||||
wailsruntime.WindowExecJS(ctx, inject)
|
||||
}
|
||||
if lan := strings.TrimSpace(app.apiLanBaseURL); lan != "" {
|
||||
injectLan := fmt.Sprintf(`try{window.__WEKNORA_API_LAN_BASE__=%s}catch(e){}`, strconv.Quote(lan))
|
||||
wailsruntime.WindowExecJS(ctx, injectLan)
|
||||
}
|
||||
},
|
||||
OnShutdown: app.shutdown,
|
||||
Bind: []interface{}{
|
||||
app,
|
||||
},
|
||||
BackgroundColour: &options.RGBA{R: 255, G: 255, B: 255, A: 255},
|
||||
Mac: &mac.Options{
|
||||
TitleBar: mac.TitleBarHiddenInset(),
|
||||
WebviewIsTransparent: false,
|
||||
WindowIsTranslucent: false,
|
||||
},
|
||||
})
|
||||
|
||||
if err != nil {
|
||||
println("Error:", err.Error())
|
||||
}
|
||||
}
|
||||
|
||||
func configureDesktopStorage(execPath string) {
|
||||
if execPath == "" || !strings.Contains(execPath, ".app/Contents/MacOS") {
|
||||
return
|
||||
}
|
||||
|
||||
appSupportDir, err := defaultMacAppSupportDir(execPath)
|
||||
if err != nil {
|
||||
logger.Warnf(context.Background(), "Failed to resolve app support dir: %v", err)
|
||||
return
|
||||
}
|
||||
|
||||
legacyResourcesDir := filepath.Join(filepath.Dir(filepath.Dir(execPath)), "Resources")
|
||||
targetDataDir := filepath.Join(appSupportDir, "data")
|
||||
migrateLegacyDesktopData(legacyResourcesDir, targetDataDir)
|
||||
|
||||
dbPath := resolveDesktopDataPath(os.Getenv("DB_PATH"), filepath.Join("data", "weknora.db"), appSupportDir)
|
||||
filesPath := resolveDesktopDataPath(os.Getenv("LOCAL_STORAGE_BASE_DIR"), filepath.Join("data", "files"), appSupportDir)
|
||||
|
||||
if err := os.MkdirAll(filepath.Dir(dbPath), 0o755); err != nil {
|
||||
logger.Warnf(context.Background(), "Failed to create desktop DB directory %s: %v", filepath.Dir(dbPath), err)
|
||||
}
|
||||
if err := os.MkdirAll(filesPath, 0o755); err != nil {
|
||||
logger.Warnf(context.Background(), "Failed to create desktop files directory %s: %v", filesPath, err)
|
||||
}
|
||||
|
||||
_ = os.Setenv("DB_PATH", dbPath)
|
||||
_ = os.Setenv("LOCAL_STORAGE_BASE_DIR", filesPath)
|
||||
}
|
||||
|
||||
func defaultMacAppSupportDir(execPath string) (string, error) {
|
||||
homeDir, err := os.UserHomeDir()
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
appName := "WeKnora Lite"
|
||||
if idx := strings.Index(execPath, ".app/Contents/MacOS"); idx >= 0 {
|
||||
bundleName := filepath.Base(execPath[:idx+4])
|
||||
if trimmed := strings.TrimSuffix(bundleName, ".app"); trimmed != "" {
|
||||
appName = trimmed
|
||||
}
|
||||
}
|
||||
|
||||
return filepath.Join(homeDir, "Library", "Application Support", appName), nil
|
||||
}
|
||||
|
||||
func resolveDesktopDataPath(rawPath, defaultRelativePath, appSupportDir string) string {
|
||||
trimmed := strings.TrimSpace(rawPath)
|
||||
if trimmed == "" {
|
||||
trimmed = defaultRelativePath
|
||||
}
|
||||
if filepath.IsAbs(trimmed) {
|
||||
return filepath.Clean(trimmed)
|
||||
}
|
||||
trimmed = strings.TrimPrefix(trimmed, "."+string(filepath.Separator))
|
||||
return filepath.Join(appSupportDir, filepath.Clean(trimmed))
|
||||
}
|
||||
|
||||
// desktopBackendListenAddr returns the TCP address for the embedded Gin server (Wails desktop).
|
||||
// Binds 127.0.0.1 by default, or 0.0.0.0 when http_bind_public is set in desktop-prefs.json.
|
||||
func desktopBackendListenAddr() string {
|
||||
host := "127.0.0.1"
|
||||
if LoadDesktopHTTPBindPublic() {
|
||||
host = "0.0.0.0"
|
||||
}
|
||||
pref := LoadDesktopPrefsHTTPPort()
|
||||
if pref >= 1 && pref <= 65535 {
|
||||
return net.JoinHostPort(host, strconv.Itoa(pref))
|
||||
}
|
||||
return net.JoinHostPort(host, "0")
|
||||
}
|
||||
|
||||
// desktopPreferredLANIPv4 picks a non-loopback IPv4 for “other devices on this network” URL hints.
|
||||
func desktopPreferredLANIPv4() net.IP {
|
||||
ifaces, err := net.Interfaces()
|
||||
if err == nil {
|
||||
for _, iface := range ifaces {
|
||||
if iface.Flags&net.FlagUp == 0 || iface.Flags&net.FlagLoopback != 0 {
|
||||
continue
|
||||
}
|
||||
addrs, aerr := iface.Addrs()
|
||||
if aerr != nil {
|
||||
continue
|
||||
}
|
||||
for _, a := range addrs {
|
||||
ipNet, ok := a.(*net.IPNet)
|
||||
if !ok || ipNet.IP == nil {
|
||||
continue
|
||||
}
|
||||
ip4 := ipNet.IP.To4()
|
||||
if ip4 == nil || ip4.IsLoopback() {
|
||||
continue
|
||||
}
|
||||
if ip4.IsPrivate() {
|
||||
return ip4
|
||||
}
|
||||
}
|
||||
}
|
||||
for _, iface := range ifaces {
|
||||
if iface.Flags&net.FlagUp == 0 || iface.Flags&net.FlagLoopback != 0 {
|
||||
continue
|
||||
}
|
||||
addrs, aerr := iface.Addrs()
|
||||
if aerr != nil {
|
||||
continue
|
||||
}
|
||||
for _, a := range addrs {
|
||||
ipNet, ok := a.(*net.IPNet)
|
||||
if !ok || ipNet.IP == nil {
|
||||
continue
|
||||
}
|
||||
ip4 := ipNet.IP.To4()
|
||||
if ip4 == nil || ip4.IsLoopback() || ip4.IsUnspecified() {
|
||||
continue
|
||||
}
|
||||
return ip4
|
||||
}
|
||||
}
|
||||
}
|
||||
conn, err := net.Dial("udp", "8.8.8.8:80")
|
||||
if err != nil {
|
||||
return nil
|
||||
}
|
||||
defer conn.Close()
|
||||
la, ok := conn.LocalAddr().(*net.UDPAddr)
|
||||
if !ok || la.IP == nil {
|
||||
return nil
|
||||
}
|
||||
return la.IP.To4()
|
||||
}
|
||||
|
||||
func migrateLegacyDesktopData(resourcesDir, targetDataDir string) {
|
||||
legacyDataDir := filepath.Join(resourcesDir, "data")
|
||||
if info, err := os.Stat(legacyDataDir); err != nil || !info.IsDir() {
|
||||
return
|
||||
}
|
||||
if _, err := os.Stat(targetDataDir); err == nil {
|
||||
return
|
||||
}
|
||||
if err := os.MkdirAll(filepath.Dir(targetDataDir), 0o755); err != nil {
|
||||
logger.Warnf(context.Background(), "Failed to create app support parent dir %s: %v", filepath.Dir(targetDataDir), err)
|
||||
return
|
||||
}
|
||||
if err := os.Rename(legacyDataDir, targetDataDir); err != nil {
|
||||
logger.Warnf(context.Background(), "Failed to migrate legacy desktop data from %s to %s: %v", legacyDataDir, targetDataDir, err)
|
||||
return
|
||||
}
|
||||
logger.Infof(context.Background(), "Migrated legacy desktop data to %s", targetDataDir)
|
||||
}
|
||||
|
||||
func listenWithRetry(addr string, maxRetries int, baseDelay time.Duration) (net.Listener, error) {
|
||||
var lastErr error
|
||||
for i := 0; i < maxRetries; i++ {
|
||||
listener, err := net.Listen("tcp", addr)
|
||||
if err == nil {
|
||||
return listener, nil
|
||||
}
|
||||
lastErr = err
|
||||
if i < maxRetries-1 {
|
||||
delay := baseDelay * time.Duration(1<<uint(i))
|
||||
if delay > 3*time.Second {
|
||||
delay = 3 * time.Second
|
||||
}
|
||||
time.Sleep(delay)
|
||||
}
|
||||
}
|
||||
return nil, lastErr
|
||||
}
|
||||
|
|
@ -0,0 +1,17 @@
|
|||
//go:build bindings
|
||||
|
||||
package main
|
||||
|
||||
import (
|
||||
"github.com/wailsapp/wails/v2"
|
||||
"github.com/wailsapp/wails/v2/pkg/options"
|
||||
)
|
||||
|
||||
// Wails「生成绑定」阶段使用 -tags bindings 单独编译本文件,不启动 Gin/数据库,避免依赖本机 Postgres。
|
||||
func main() {
|
||||
app := NewApp()
|
||||
_ = wails.Run(&options.App{
|
||||
Title: "WeKnora Lite",
|
||||
Bind: []interface{}{app},
|
||||
})
|
||||
}
|
||||
|
|
@ -0,0 +1,93 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"os"
|
||||
"path/filepath"
|
||||
)
|
||||
|
||||
const desktopPrefsFileName = "desktop-prefs.json"
|
||||
|
||||
type desktopPrefs struct {
|
||||
HTTPPort int `json:"http_port"`
|
||||
HTTPBindPublic bool `json:"http_bind_public"`
|
||||
}
|
||||
|
||||
func desktopPrefsDir() (string, error) {
|
||||
cfg, err := os.UserConfigDir()
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
dir := filepath.Join(cfg, "WeKnora Lite")
|
||||
if err := os.MkdirAll(dir, 0o755); err != nil {
|
||||
return "", err
|
||||
}
|
||||
return dir, nil
|
||||
}
|
||||
|
||||
func desktopPrefsFilePath() (string, error) {
|
||||
dir, err := desktopPrefsDir()
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
return filepath.Join(dir, desktopPrefsFileName), nil
|
||||
}
|
||||
|
||||
func loadDesktopPrefs() desktopPrefs {
|
||||
path, err := desktopPrefsFilePath()
|
||||
if err != nil {
|
||||
return desktopPrefs{}
|
||||
}
|
||||
data, err := os.ReadFile(path)
|
||||
if err != nil {
|
||||
return desktopPrefs{}
|
||||
}
|
||||
var p desktopPrefs
|
||||
if json.Unmarshal(data, &p) != nil {
|
||||
return desktopPrefs{}
|
||||
}
|
||||
if p.HTTPPort < 0 || p.HTTPPort > 65535 {
|
||||
p.HTTPPort = 0
|
||||
}
|
||||
return p
|
||||
}
|
||||
|
||||
func saveDesktopPrefs(p desktopPrefs) error {
|
||||
path, err := desktopPrefsFilePath()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
data, err := json.MarshalIndent(p, "", " ")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return os.WriteFile(path, data, 0o600)
|
||||
}
|
||||
|
||||
// LoadDesktopPrefsHTTPPort returns http_port from prefs file, or 0 if unset / invalid (ephemeral port on each launch).
|
||||
func LoadDesktopPrefsHTTPPort() int {
|
||||
return loadDesktopPrefs().HTTPPort
|
||||
}
|
||||
|
||||
// LoadDesktopHTTPBindPublic returns whether the embedded API server should listen on all interfaces (0.0.0.0).
|
||||
func LoadDesktopHTTPBindPublic() bool {
|
||||
return loadDesktopPrefs().HTTPBindPublic
|
||||
}
|
||||
|
||||
// SaveDesktopHTTPPortPreference persists listen port preference. port 0 means use a random free port on each launch.
|
||||
func SaveDesktopHTTPPortPreference(port int) error {
|
||||
if port < 0 || port > 65535 {
|
||||
return fmt.Errorf("invalid port")
|
||||
}
|
||||
cur := loadDesktopPrefs()
|
||||
cur.HTTPPort = port
|
||||
return saveDesktopPrefs(cur)
|
||||
}
|
||||
|
||||
// SaveDesktopHTTPBindPublicPreference persists whether to listen on 0.0.0.0 for LAN/public access.
|
||||
func SaveDesktopHTTPBindPublicPreference(v bool) error {
|
||||
cur := loadDesktopPrefs()
|
||||
cur.HTTPBindPublic = v
|
||||
return saveDesktopPrefs(cur)
|
||||
}
|
||||
|
|
@ -0,0 +1,413 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"io"
|
||||
"net/http"
|
||||
"os"
|
||||
"os/exec"
|
||||
"path/filepath"
|
||||
"runtime"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/Tencent/WeKnora/internal/handler"
|
||||
"github.com/Tencent/WeKnora/internal/logger"
|
||||
wailsruntime "github.com/wailsapp/wails/v2/pkg/runtime"
|
||||
"golang.org/x/mod/semver"
|
||||
)
|
||||
|
||||
type githubAsset struct {
|
||||
Name string `json:"name"`
|
||||
BrowserDownloadURL string `json:"browser_download_url"`
|
||||
}
|
||||
|
||||
type githubRelease struct {
|
||||
TagName string `json:"tag_name"`
|
||||
HTMLURL string `json:"html_url"`
|
||||
Assets []githubAsset `json:"assets"`
|
||||
}
|
||||
|
||||
func checkUpdate(ctx context.Context, currentVersion string, showUpToDate bool, autoDownload bool) {
|
||||
go func() {
|
||||
if currentVersion == "unknown" || currentVersion == "" {
|
||||
if showUpToDate {
|
||||
wailsruntime.MessageDialog(ctx, wailsruntime.MessageDialogOptions{
|
||||
Type: wailsruntime.InfoDialog,
|
||||
Title: "Check for Updates",
|
||||
Message: "Unable to determine the current version. Cannot check for updates.",
|
||||
Buttons: []string{"OK"},
|
||||
DefaultButton: "OK",
|
||||
})
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
if !strings.HasPrefix(currentVersion, "v") {
|
||||
currentVersion = "v" + currentVersion
|
||||
}
|
||||
|
||||
client := &http.Client{Timeout: 10 * time.Second}
|
||||
req, err := http.NewRequest("GET", "https://api.github.com/repos/Tencent/WeKnora/releases/latest", nil)
|
||||
if err != nil {
|
||||
logger.Warnf(context.Background(), "Check update failed: %v", err)
|
||||
return
|
||||
}
|
||||
|
||||
// Add User-Agent header which is required/recommended by GitHub API
|
||||
req.Header.Set("User-Agent", "WeKnora-Lite-Desktop-App")
|
||||
|
||||
// Add Authorization header if GITHUB_TOKEN is present to increase rate limit
|
||||
if token := os.Getenv("GITHUB_TOKEN"); token != "" {
|
||||
req.Header.Set("Authorization", "Bearer "+token)
|
||||
}
|
||||
|
||||
resp, err := client.Do(req)
|
||||
if err != nil {
|
||||
logger.Warnf(context.Background(), "Check update failed: %v", err)
|
||||
if showUpToDate {
|
||||
wailsruntime.MessageDialog(ctx, wailsruntime.MessageDialogOptions{
|
||||
Type: wailsruntime.ErrorDialog,
|
||||
Title: "Check Update Failed",
|
||||
Message: fmt.Sprintf("Failed to connect to GitHub to check for updates:\n%v", err),
|
||||
Buttons: []string{"OK"},
|
||||
DefaultButton: "OK",
|
||||
})
|
||||
}
|
||||
return
|
||||
}
|
||||
defer resp.Body.Close()
|
||||
|
||||
if resp.StatusCode != http.StatusOK {
|
||||
logger.Warnf(context.Background(), "GitHub API returned status code: %d", resp.StatusCode)
|
||||
if showUpToDate {
|
||||
msg := fmt.Sprintf("GitHub API returned an unexpected status code: %d", resp.StatusCode)
|
||||
if resp.StatusCode == 403 {
|
||||
msg = "GitHub API rate limit exceeded. Please try again later."
|
||||
}
|
||||
wailsruntime.MessageDialog(ctx, wailsruntime.MessageDialogOptions{
|
||||
Type: wailsruntime.ErrorDialog,
|
||||
Title: "Check Update Failed",
|
||||
Message: msg,
|
||||
Buttons: []string{"OK"},
|
||||
DefaultButton: "OK",
|
||||
})
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
var release githubRelease
|
||||
if err := json.NewDecoder(resp.Body).Decode(&release); err != nil {
|
||||
logger.Warnf(context.Background(), "Failed to parse release info: %v", err)
|
||||
return
|
||||
}
|
||||
|
||||
latestVersion := release.TagName
|
||||
if !strings.HasPrefix(latestVersion, "v") {
|
||||
latestVersion = "v" + latestVersion
|
||||
}
|
||||
|
||||
if semver.IsValid(latestVersion) && semver.IsValid(currentVersion) {
|
||||
if semver.Compare(latestVersion, currentVersion) > 0 {
|
||||
assetURL, assetName := findBestAsset(release.Assets, runtime.GOOS, runtime.GOARCH)
|
||||
|
||||
if autoDownload && assetURL != "" {
|
||||
// Silent download in background
|
||||
downloadAndInstall(ctx, assetURL, assetName, currentVersion, latestVersion, true)
|
||||
return
|
||||
}
|
||||
|
||||
msg := fmt.Sprintf("A new version of WeKnora Lite is available!\n\nCurrent version: %s\nLatest version: %s\n\nWould you like to download it now?", currentVersion, latestVersion)
|
||||
choice, _ := wailsruntime.MessageDialog(ctx, wailsruntime.MessageDialogOptions{
|
||||
Type: wailsruntime.InfoDialog,
|
||||
Title: "Update Available",
|
||||
Message: msg,
|
||||
Buttons: []string{"Download", "Cancel"},
|
||||
DefaultButton: "Download",
|
||||
})
|
||||
if choice == "Download" {
|
||||
if assetURL != "" {
|
||||
downloadAndInstall(ctx, assetURL, assetName, currentVersion, latestVersion, false)
|
||||
} else {
|
||||
// Fallback to opening the release page if no specific asset is found
|
||||
wailsruntime.BrowserOpenURL(ctx, release.HTMLURL)
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
if showUpToDate {
|
||||
wailsruntime.MessageDialog(ctx, wailsruntime.MessageDialogOptions{
|
||||
Type: wailsruntime.InfoDialog,
|
||||
Title: "Up to Date",
|
||||
Message: fmt.Sprintf("You are using the latest version of WeKnora Lite.\n\nCurrent version: %s", currentVersion),
|
||||
Buttons: []string{"OK"},
|
||||
DefaultButton: "OK",
|
||||
})
|
||||
}
|
||||
}()
|
||||
}
|
||||
|
||||
func findBestAsset(assets []githubAsset, goos, goarch string) (string, string) {
|
||||
osKeyword := ""
|
||||
switch goos {
|
||||
case "darwin":
|
||||
osKeyword = "mac"
|
||||
case "windows":
|
||||
osKeyword = "win"
|
||||
case "linux":
|
||||
osKeyword = "linux"
|
||||
}
|
||||
|
||||
archKeyword := ""
|
||||
switch goarch {
|
||||
case "amd64":
|
||||
archKeyword = "amd64"
|
||||
case "arm64":
|
||||
archKeyword = "arm64"
|
||||
}
|
||||
|
||||
// 1. Try to match both OS and Arch
|
||||
for _, asset := range assets {
|
||||
name := strings.ToLower(asset.Name)
|
||||
if strings.Contains(name, osKeyword) && (strings.Contains(name, archKeyword) || strings.Contains(name, "universal") || strings.Contains(name, "aarch64")) {
|
||||
return asset.BrowserDownloadURL, asset.Name
|
||||
}
|
||||
}
|
||||
|
||||
// 2. Try to match OS only (e.g. universal binaries without arch in name)
|
||||
for _, asset := range assets {
|
||||
name := strings.ToLower(asset.Name)
|
||||
if strings.Contains(name, osKeyword) {
|
||||
return asset.BrowserDownloadURL, asset.Name
|
||||
}
|
||||
}
|
||||
|
||||
// 3. MacOS specific fallback (e.g. .dmg)
|
||||
if goos == "darwin" {
|
||||
for _, asset := range assets {
|
||||
if strings.HasSuffix(strings.ToLower(asset.Name), ".dmg") {
|
||||
return asset.BrowserDownloadURL, asset.Name
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 4. Windows specific fallback (e.g. .exe)
|
||||
if goos == "windows" {
|
||||
for _, asset := range assets {
|
||||
if strings.HasSuffix(strings.ToLower(asset.Name), ".exe") {
|
||||
return asset.BrowserDownloadURL, asset.Name
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return "", ""
|
||||
}
|
||||
|
||||
func downloadAndInstall(ctx context.Context, url string, filename string, currentVersion string, latestVersion string, silent bool) {
|
||||
tempDir := os.TempDir()
|
||||
savePath := filepath.Join(tempDir, filename)
|
||||
|
||||
go func() {
|
||||
logger.Infof(context.Background(), "Starting download from %s to %s", url, savePath)
|
||||
resp, err := http.Get(url)
|
||||
if err != nil {
|
||||
logger.Warnf(context.Background(), "Download failed: %v", err)
|
||||
if !silent {
|
||||
wailsruntime.MessageDialog(ctx, wailsruntime.MessageDialogOptions{
|
||||
Type: wailsruntime.ErrorDialog,
|
||||
Title: "Download Failed",
|
||||
Message: fmt.Sprintf("Failed to download the update:\n%v", err),
|
||||
Buttons: []string{"OK"},
|
||||
DefaultButton: "OK",
|
||||
})
|
||||
}
|
||||
return
|
||||
}
|
||||
defer resp.Body.Close()
|
||||
|
||||
if resp.StatusCode != http.StatusOK {
|
||||
logger.Warnf(context.Background(), "Download failed, server returned status: %d", resp.StatusCode)
|
||||
if !silent {
|
||||
wailsruntime.MessageDialog(ctx, wailsruntime.MessageDialogOptions{
|
||||
Type: wailsruntime.ErrorDialog,
|
||||
Title: "Download Failed",
|
||||
Message: fmt.Sprintf("Server returned status: %d", resp.StatusCode),
|
||||
Buttons: []string{"OK"},
|
||||
DefaultButton: "OK",
|
||||
})
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
out, err := os.Create(savePath)
|
||||
if err != nil {
|
||||
logger.Warnf(context.Background(), "Failed to create file for download: %v", err)
|
||||
if !silent {
|
||||
wailsruntime.MessageDialog(ctx, wailsruntime.MessageDialogOptions{
|
||||
Type: wailsruntime.ErrorDialog,
|
||||
Title: "Save Failed",
|
||||
Message: fmt.Sprintf("Failed to save the update file:\n%v", err),
|
||||
Buttons: []string{"OK"},
|
||||
DefaultButton: "OK",
|
||||
})
|
||||
}
|
||||
return
|
||||
}
|
||||
defer out.Close()
|
||||
|
||||
_, err = io.Copy(out, resp.Body)
|
||||
if err != nil {
|
||||
logger.Warnf(context.Background(), "Error occurred during download copying: %v", err)
|
||||
if !silent {
|
||||
wailsruntime.MessageDialog(ctx, wailsruntime.MessageDialogOptions{
|
||||
Type: wailsruntime.ErrorDialog,
|
||||
Title: "Download Error",
|
||||
Message: fmt.Sprintf("An error occurred while downloading:\n%v", err),
|
||||
Buttons: []string{"OK"},
|
||||
DefaultButton: "OK",
|
||||
})
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
logger.Infof(context.Background(), "Download completed successfully: %s", savePath)
|
||||
|
||||
// Prompt user to restart
|
||||
choice, _ := wailsruntime.MessageDialog(ctx, wailsruntime.MessageDialogOptions{
|
||||
Type: wailsruntime.InfoDialog,
|
||||
Title: "Update Ready",
|
||||
Message: fmt.Sprintf("WeKnora Lite %s has been downloaded successfully.\n\nWould you like to restart and install the new version now?", latestVersion),
|
||||
Buttons: []string{"Restart Now", "Later"},
|
||||
DefaultButton: "Restart Now",
|
||||
})
|
||||
|
||||
if choice == "Restart Now" {
|
||||
applyUpdateAndRestart(ctx, savePath)
|
||||
}
|
||||
}()
|
||||
}
|
||||
|
||||
// desktopAboutVersion 优先使用构建脚本注入的 handler.Version,否则尝试读取仓库根目录 VERSION(本地 wails dev 等未带 ldflags 时)。
|
||||
func desktopAboutVersion() string {
|
||||
if v := strings.TrimSpace(handler.Version); v != "" && v != "unknown" {
|
||||
return v
|
||||
}
|
||||
for _, p := range []string{
|
||||
"VERSION",
|
||||
filepath.Join("..", "..", "VERSION"),
|
||||
filepath.Join("..", "..", "..", "VERSION"),
|
||||
} {
|
||||
b, err := os.ReadFile(p)
|
||||
if err != nil {
|
||||
continue
|
||||
}
|
||||
if v := strings.TrimSpace(string(b)); v != "" {
|
||||
return v
|
||||
}
|
||||
}
|
||||
return "unknown"
|
||||
}
|
||||
|
||||
// applyUpdateAndRestart applies the downloaded update and restarts the application
|
||||
func applyUpdateAndRestart(ctx context.Context, savePath string) {
|
||||
if runtime.GOOS == "windows" {
|
||||
scriptPath := filepath.Join(os.TempDir(), "weknora_update.bat")
|
||||
execPath, err := os.Executable()
|
||||
if err != nil {
|
||||
logger.Warnf(context.Background(), "Failed to get executable path: %v", err)
|
||||
return
|
||||
}
|
||||
scriptContent := fmt.Sprintf(`@echo off
|
||||
timeout /t 2 /nobreak
|
||||
start /wait "" "%s" /S
|
||||
start "" "%s"
|
||||
del "%%~f0"
|
||||
`, savePath, execPath)
|
||||
os.WriteFile(scriptPath, []byte(scriptContent), 0755)
|
||||
|
||||
cmd := exec.Command("cmd.exe", "/C", "start", "/b", scriptPath)
|
||||
cmd.Start()
|
||||
wailsruntime.Quit(ctx)
|
||||
|
||||
} else if runtime.GOOS == "darwin" {
|
||||
if strings.HasSuffix(strings.ToLower(savePath), ".dmg") {
|
||||
go func() {
|
||||
execPath, err := os.Executable()
|
||||
if err != nil {
|
||||
logger.Warnf(context.Background(), "Failed to get executable path: %v", err)
|
||||
exec.Command("open", savePath).Start()
|
||||
wailsruntime.Quit(ctx)
|
||||
return
|
||||
}
|
||||
|
||||
appBundlePath := filepath.Dir(filepath.Dir(filepath.Dir(execPath)))
|
||||
if !strings.HasSuffix(appBundlePath, ".app") {
|
||||
exec.Command("open", savePath).Start()
|
||||
wailsruntime.Quit(ctx)
|
||||
return
|
||||
}
|
||||
|
||||
mountPoint := filepath.Join(os.TempDir(), "WeKnoraUpdateMount")
|
||||
os.MkdirAll(mountPoint, 0755)
|
||||
|
||||
cmdMount := exec.Command("hdiutil", "attach", savePath, "-mountpoint", mountPoint, "-nobrowse", "-quiet")
|
||||
if err := cmdMount.Run(); err != nil {
|
||||
logger.Warnf(context.Background(), "Failed to mount dmg: %v", err)
|
||||
exec.Command("open", savePath).Start()
|
||||
wailsruntime.Quit(ctx)
|
||||
return
|
||||
}
|
||||
|
||||
entries, err := os.ReadDir(mountPoint)
|
||||
if err != nil {
|
||||
exec.Command("hdiutil", "detach", mountPoint, "-force").Run()
|
||||
exec.Command("open", savePath).Start()
|
||||
wailsruntime.Quit(ctx)
|
||||
return
|
||||
}
|
||||
|
||||
var newAppPath string
|
||||
for _, entry := range entries {
|
||||
if strings.HasSuffix(entry.Name(), ".app") {
|
||||
newAppPath = filepath.Join(mountPoint, entry.Name())
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
if newAppPath == "" {
|
||||
exec.Command("hdiutil", "detach", mountPoint, "-force").Run()
|
||||
exec.Command("open", savePath).Start()
|
||||
wailsruntime.Quit(ctx)
|
||||
return
|
||||
}
|
||||
|
||||
appDir := filepath.Dir(appBundlePath)
|
||||
scriptPath := filepath.Join(os.TempDir(), "weknora_update.sh")
|
||||
scriptContent := fmt.Sprintf(`#!/bin/bash
|
||||
sleep 2
|
||||
if ! (rm -rf "%s" && cp -a "%s" "%s"); then
|
||||
osascript -e "do shell script \"rm -rf \\\"%s\\\" && cp -a \\\"%s\\\" \\\"%s\\\"\" with administrator privileges"
|
||||
fi
|
||||
hdiutil detach "%s" -force
|
||||
open "%s"
|
||||
rm "$0"
|
||||
`, appBundlePath, newAppPath, appDir, appBundlePath, newAppPath, appDir, mountPoint, appBundlePath)
|
||||
|
||||
os.WriteFile(scriptPath, []byte(scriptContent), 0755)
|
||||
|
||||
exec.Command("bash", scriptPath).Start()
|
||||
wailsruntime.Quit(ctx)
|
||||
}()
|
||||
} else {
|
||||
exec.Command("open", savePath).Start()
|
||||
wailsruntime.Quit(ctx)
|
||||
}
|
||||
} else {
|
||||
exec.Command("xdg-open", savePath).Start()
|
||||
wailsruntime.Quit(ctx)
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,22 @@
|
|||
{
|
||||
"$schema": "https://wails.io/schemas/config.v2.json",
|
||||
"name": "WeKnora Lite",
|
||||
"outputfilename": "WeKnora Lite",
|
||||
"frontend:dir": "../../frontend",
|
||||
"wailsjsdir": "../../frontend/src",
|
||||
"author": {
|
||||
"name": "WeKnora Team",
|
||||
"email": ""
|
||||
},
|
||||
"info": {
|
||||
"companyName": "Tencent",
|
||||
"productName": "WeKnora Lite",
|
||||
"productVersion": "1.0.0",
|
||||
"copyright": "Copyright 2026 Tencent",
|
||||
"comments": "WeKnora Desktop Edition"
|
||||
},
|
||||
"mac": {
|
||||
"category": "public.app-category.productivity",
|
||||
"titlebar": "hiddenInset"
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,29 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net"
|
||||
"time"
|
||||
|
||||
"github.com/Tencent/WeKnora/internal/logger"
|
||||
)
|
||||
|
||||
func listenWithRetry(addr string, maxRetries int, baseDelay time.Duration) (net.Listener, error) {
|
||||
var lastErr error
|
||||
for i := 0; i < maxRetries; i++ {
|
||||
listener, err := net.Listen("tcp", addr)
|
||||
if err == nil {
|
||||
return listener, nil
|
||||
}
|
||||
lastErr = err
|
||||
if i < maxRetries-1 {
|
||||
delay := baseDelay * time.Duration(1<<uint(i))
|
||||
if delay > 3*time.Second {
|
||||
delay = 3 * time.Second
|
||||
}
|
||||
logger.Warnf(context.Background(), "Port %s in use, retrying in %v... (%d/%d)", addr, delay, i+1, maxRetries)
|
||||
time.Sleep(delay)
|
||||
}
|
||||
}
|
||||
return nil, lastErr
|
||||
}
|
||||
|
|
@ -25,11 +25,9 @@ package main
|
|||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"net"
|
||||
"net/http"
|
||||
"os"
|
||||
"os/signal"
|
||||
"syscall"
|
||||
"time"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
|
|
@ -40,8 +38,6 @@ import (
|
|||
"github.com/Tencent/WeKnora/internal/runtime"
|
||||
"github.com/Tencent/WeKnora/internal/tracing"
|
||||
"github.com/Tencent/WeKnora/internal/types/interfaces"
|
||||
|
||||
"golang.org/x/sys/unix"
|
||||
)
|
||||
|
||||
func main() {
|
||||
|
|
@ -76,7 +72,7 @@ func main() {
|
|||
ctx, done := context.WithCancel(context.Background())
|
||||
|
||||
signals := make(chan os.Signal, 1)
|
||||
signal.Notify(signals, syscall.SIGINT, syscall.SIGTERM, syscall.SIGHUP)
|
||||
signal.Notify(signals, shutdownSignals...)
|
||||
go func() {
|
||||
sig := <-signals
|
||||
logger.Infof(context.Background(), "Received signal: %v, starting server shutdown...", sig)
|
||||
|
|
@ -125,33 +121,3 @@ func main() {
|
|||
logger.Fatalf(context.Background(), "Failed to run application: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
// listenWithRetry retries listening with exponential backoff and SO_REUSEPORT,
|
||||
// useful during hot-reload when the previous process may not have released the port yet.
|
||||
func listenWithRetry(addr string, maxRetries int, baseDelay time.Duration) (net.Listener, error) {
|
||||
lc := net.ListenConfig{
|
||||
Control: func(network, address string, c syscall.RawConn) error {
|
||||
return c.Control(func(fd uintptr) {
|
||||
_ = syscall.SetsockoptInt(int(fd), syscall.SOL_SOCKET, unix.SO_REUSEPORT, 1)
|
||||
})
|
||||
},
|
||||
}
|
||||
|
||||
var lastErr error
|
||||
for i := 0; i < maxRetries; i++ {
|
||||
listener, err := lc.Listen(context.Background(), "tcp", addr)
|
||||
if err == nil {
|
||||
return listener, nil
|
||||
}
|
||||
lastErr = err
|
||||
if i < maxRetries-1 {
|
||||
delay := baseDelay * time.Duration(1<<uint(i))
|
||||
if delay > 3*time.Second {
|
||||
delay = 3 * time.Second
|
||||
}
|
||||
logger.Warnf(context.Background(), "Port %s in use, retrying in %v... (%d/%d)", addr, delay, i+1, maxRetries)
|
||||
time.Sleep(delay)
|
||||
}
|
||||
}
|
||||
return nil, lastErr
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,10 @@
|
|||
//go:build !windows
|
||||
|
||||
package main
|
||||
|
||||
import (
|
||||
"os"
|
||||
"syscall"
|
||||
)
|
||||
|
||||
var shutdownSignals = []os.Signal{syscall.SIGINT, syscall.SIGTERM, syscall.SIGHUP}
|
||||
|
|
@ -0,0 +1,10 @@
|
|||
//go:build windows
|
||||
|
||||
package main
|
||||
|
||||
import (
|
||||
"os"
|
||||
"syscall"
|
||||
)
|
||||
|
||||
var shutdownSignals = []os.Signal{syscall.SIGINT, syscall.SIGTERM}
|
||||
|
|
@ -0,0 +1,23 @@
|
|||
[Unit]
|
||||
Description=WeKnora Lite - Knowledge Base Management System
|
||||
After=network.target
|
||||
|
||||
[Service]
|
||||
Type=simple
|
||||
User=weknora
|
||||
Group=weknora
|
||||
WorkingDirectory=/opt/weknora
|
||||
EnvironmentFile=/opt/weknora/.env.lite
|
||||
ExecStart=/opt/weknora/WeKnora-lite
|
||||
Restart=on-failure
|
||||
RestartSec=5
|
||||
LimitNOFILE=65536
|
||||
|
||||
# Security hardening
|
||||
NoNewPrivileges=true
|
||||
ProtectSystem=strict
|
||||
ProtectHome=true
|
||||
ReadWritePaths=/opt/weknora/data
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
|
|
@ -116,6 +116,11 @@ services:
|
|||
- SSRF_WHITELIST=${SSRF_WHITELIST:-}
|
||||
- CONCURRENCY_POOL_SIZE=${CONCURRENCY_POOL_SIZE:-5}
|
||||
- JWT_SECRET=${JWT_SECRET:-}
|
||||
# Crypto: 主密钥和盐值,用于 AppSecret 等敏感字段的 AES-256 加密
|
||||
# 若不设置则自动生成并持久化到 data-files volume(/data/files/.crypto_state.json)
|
||||
# 重启时自动从文件恢复,保证已加密数据可继续解密
|
||||
- CRYPTO_MASTER_KEY=${CRYPTO_MASTER_KEY:-}
|
||||
- CRYPTO_SALT=${CRYPTO_SALT:-}
|
||||
# File size limit (in MB)
|
||||
- MAX_FILE_SIZE_MB=${MAX_FILE_SIZE_MB:-50}
|
||||
# Agent Skills Sandbox
|
||||
|
|
|
|||
|
|
@ -66,7 +66,8 @@ RUN if [ -n "$APK_MIRROR_ARG" ]; then \
|
|||
libsqlite3-0 \
|
||||
python3 python3-pip python3-dev libffi-dev libssl-dev \
|
||||
nodejs npm \
|
||||
gosu && \
|
||||
gosu \
|
||||
ffmpeg && \
|
||||
python3 -m pip install --break-system-packages --upgrade pip setuptools wheel && \
|
||||
mkdir -p /home/appuser/.local/bin && \
|
||||
curl -LsSf https://astral.sh/uv/install.sh | CARGO_HOME=/home/appuser/.cargo UV_INSTALL_DIR=/home/appuser/.local/bin sh && \
|
||||
|
|
|
|||
|
|
@ -126,6 +126,16 @@ DocReader 支持多种存储后端:
|
|||
- `COS_PATH_PREFIX`: 文件路径前缀
|
||||
- `COS_ENABLE_OLD_DOMAIN`: 是否使用旧域名(默认:true)
|
||||
|
||||
#### 阿里云 OSS 存储
|
||||
|
||||
- `STORAGE_TYPE`: 设置为 `oss`
|
||||
- `OSS_ACCESS_KEY_ID`: OSS 访问密钥 ID
|
||||
- `OSS_ACCESS_KEY_SECRET`: OSS 访问密钥
|
||||
- `OSS_ENDPOINT`: OSS 端点(如 `oss-cn-hangzhou.aliyuncs.com`)
|
||||
- `OSS_BUCKET_NAME`: OSS 存储桶名称
|
||||
- `OSS_REGION`: OSS 区域(如 `cn-hangzhou`)
|
||||
- `OSS_PATH_PREFIX`: 文件路径前缀
|
||||
|
||||
### 代理配置
|
||||
|
||||
如果需要通过代理访问外部服务:
|
||||
|
|
@ -178,6 +188,20 @@ docreader:
|
|||
- MAX_FILE_SIZE_MB=50
|
||||
```
|
||||
|
||||
### 使用阿里云 OSS
|
||||
|
||||
```yaml
|
||||
docreader:
|
||||
environment:
|
||||
- STORAGE_TYPE=oss
|
||||
- OSS_ACCESS_KEY_ID=your_access_key_id
|
||||
- OSS_ACCESS_KEY_SECRET=your_access_key_secret
|
||||
- OSS_ENDPOINT=oss-cn-hangzhou.aliyuncs.com
|
||||
- OSS_BUCKET_NAME=your-bucket
|
||||
- OSS_REGION=cn-hangzhou
|
||||
- MAX_FILE_SIZE_MB=50
|
||||
```
|
||||
|
||||
## 常见问题
|
||||
|
||||
### 1. DocReader 服务无法启动?
|
||||
|
|
|
|||
|
|
@ -10,6 +10,11 @@ from typing import Dict, Optional
|
|||
from minio import Minio
|
||||
from qcloud_cos import CosConfig, CosS3Client
|
||||
|
||||
try:
|
||||
import oss2
|
||||
except ImportError:
|
||||
oss2 = None # type: ignore[assignment]
|
||||
|
||||
from docreader.utils import endecode
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
|
@ -232,6 +237,99 @@ class MinioStorage(Storage):
|
|||
return ""
|
||||
|
||||
|
||||
class OssStorage(Storage):
|
||||
"""Alibaba Cloud OSS storage implementation"""
|
||||
|
||||
def __init__(self, storage_config: Optional[Dict] = None):
|
||||
self.storage_config = storage_config
|
||||
self.bucket, self.endpoint, self.prefix = self._init_oss_bucket()
|
||||
|
||||
def _init_oss_bucket(self):
|
||||
if oss2 is None:
|
||||
logger.error("oss2 package not installed. Install with: pip install oss2")
|
||||
return None, None, None
|
||||
try:
|
||||
sc = self.storage_config
|
||||
access_key = _cfg(sc, "access_key", "OSS_ACCESS_KEY")
|
||||
secret_key = _cfg(sc, "secret_key", "OSS_SECRET_KEY")
|
||||
endpoint_raw = _cfg(sc, "endpoint", "OSS_ENDPOINT")
|
||||
bucket_name = _cfg(sc, "bucket_name", "OSS_BUCKET_NAME")
|
||||
prefix_raw = _cfg(sc, "path_prefix", "OSS_PATH_PREFIX")
|
||||
|
||||
if not all([access_key, secret_key, endpoint_raw, bucket_name]):
|
||||
logger.error(
|
||||
"Incomplete OSS configuration: "
|
||||
"access_key=%s, endpoint=%s, bucket=%s",
|
||||
bool(access_key), endpoint_raw, bucket_name,
|
||||
)
|
||||
return None, None, None
|
||||
|
||||
# oss2 requires endpoint to include the scheme (http:// or https://)
|
||||
if not endpoint_raw.startswith(("http://", "https://")):
|
||||
endpoint_raw = f"https://{endpoint_raw}"
|
||||
|
||||
auth = oss2.Auth(access_key, secret_key)
|
||||
bucket = oss2.Bucket(auth, endpoint_raw, bucket_name)
|
||||
|
||||
# Verify bucket exists; do NOT auto-create to avoid unintended public-read buckets
|
||||
try:
|
||||
bucket.get_bucket_info()
|
||||
except oss2.exceptions.NoSuchBucket:
|
||||
logger.error(
|
||||
"OSS bucket %s does not exist. Please create it manually in the console.",
|
||||
bucket_name,
|
||||
)
|
||||
return None, None, None
|
||||
|
||||
prefix = prefix_raw.strip().strip("/") if prefix_raw else ""
|
||||
return bucket, endpoint_raw, prefix
|
||||
|
||||
except Exception as e:
|
||||
logger.error("Failed to initialize OSS client: %s", e)
|
||||
return None, None, None
|
||||
|
||||
def _get_download_url(self, object_key: str) -> str:
|
||||
# Use virtual-hosted style URL: https://{bucket}.{endpoint_without_scheme}/{key}
|
||||
endpoint_no_scheme = self.endpoint.removeprefix("https://").removeprefix("http://")
|
||||
return f"https://{self.bucket.bucket_name}.{endpoint_no_scheme}/{object_key}"
|
||||
|
||||
def upload_file(self, file_path: str) -> str:
|
||||
try:
|
||||
if not self.bucket:
|
||||
return ""
|
||||
file_ext = os.path.splitext(file_path)[1]
|
||||
object_key = (
|
||||
f"{self.prefix}/images/{uuid.uuid4().hex}{file_ext}"
|
||||
if self.prefix
|
||||
else f"images/{uuid.uuid4().hex}{file_ext}"
|
||||
)
|
||||
self.bucket.put_object_from_file(object_key, file_path)
|
||||
file_url = self._get_download_url(object_key)
|
||||
logger.info("OSS upload_file ok: %s", file_url)
|
||||
return file_url
|
||||
except Exception as e:
|
||||
logger.error("OSS upload_file failed: %s", e)
|
||||
return ""
|
||||
|
||||
def upload_bytes(self, content: bytes, file_ext: str = ".png") -> str:
|
||||
try:
|
||||
if not self.bucket:
|
||||
return ""
|
||||
object_key = (
|
||||
f"{self.prefix}/images/{uuid.uuid4().hex}{file_ext}"
|
||||
if self.prefix
|
||||
else f"images/{uuid.uuid4().hex}{file_ext}"
|
||||
)
|
||||
self.bucket.put_object(object_key, content)
|
||||
file_url = self._get_download_url(object_key)
|
||||
logger.info("OSS upload_bytes ok: %s", file_url)
|
||||
return file_url
|
||||
except Exception as e:
|
||||
logger.error("OSS upload_bytes failed: %s", e)
|
||||
traceback.print_exc()
|
||||
return ""
|
||||
|
||||
|
||||
class LocalStorage(Storage):
|
||||
"""Local file system storage implementation.
|
||||
|
||||
|
|
@ -297,7 +395,7 @@ def create_storage(storage_config: Optional[Dict[str, str]] = None) -> Storage:
|
|||
"""Create a storage instance based on storage_config dict.
|
||||
|
||||
The ``provider`` key in storage_config determines the backend:
|
||||
minio, cos, local, base64.
|
||||
minio, cos, oss, local, base64.
|
||||
Falls back to STORAGE_TYPE env var, then ``local``.
|
||||
"""
|
||||
storage_type = ""
|
||||
|
|
@ -315,6 +413,8 @@ def create_storage(storage_config: Optional[Dict[str, str]] = None) -> Storage:
|
|||
return MinioStorage(storage_config)
|
||||
elif storage_type == "cos":
|
||||
return CosStorage(storage_config)
|
||||
elif storage_type == "oss":
|
||||
return OssStorage(storage_config)
|
||||
elif storage_type == "local":
|
||||
return LocalStorage(storage_config)
|
||||
elif storage_type == "base64":
|
||||
|
|
|
|||
|
|
@ -21,6 +21,7 @@ dependencies = [
|
|||
"mistletoe>=1.5.0",
|
||||
"ollama>=0.6.0",
|
||||
"openai>=2.7.1",
|
||||
"oss2>=2.18.0",
|
||||
"paddleocr>=2.10.0,<3.0.0",
|
||||
"paddlepaddle>=3.0.0,<4.0.0",
|
||||
"pdfplumber>=0.11.7",
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
version = 1
|
||||
revision = 2
|
||||
revision = 3
|
||||
requires-python = ">=3.10.18"
|
||||
resolution-markers = [
|
||||
"python_full_version >= '3.14' and sys_platform == 'darwin'",
|
||||
|
|
@ -59,6 +59,28 @@ wheels = [
|
|||
{ url = "https://files.pythonhosted.org/packages/8e/64/013409c451a44b61310fb757af4527f3de57fc98a00f40448de28b864290/albumentations-2.0.8-py3-none-any.whl", hash = "sha256:c4c4259aaf04a7386ad85c7fdcb73c6c7146ca3057446b745cc035805acb1017", size = 369423, upload-time = "2025-05-27T21:23:15.609Z" },
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "aliyun-python-sdk-core"
|
||||
version = "2.16.0"
|
||||
source = { registry = "https://pypi.org/simple" }
|
||||
dependencies = [
|
||||
{ name = "cryptography" },
|
||||
{ name = "jmespath" },
|
||||
]
|
||||
sdist = { url = "https://files.pythonhosted.org/packages/3e/09/da9f58eb38b4fdb97ba6523274fbf445ef6a06be64b433693da8307b4bec/aliyun-python-sdk-core-2.16.0.tar.gz", hash = "sha256:651caad597eb39d4fad6cf85133dffe92837d53bdf62db9d8f37dab6508bb8f9", size = 449555, upload-time = "2024-10-09T06:01:01.762Z" }
|
||||
|
||||
[[package]]
|
||||
name = "aliyun-python-sdk-kms"
|
||||
version = "2.16.5"
|
||||
source = { registry = "https://pypi.org/simple" }
|
||||
dependencies = [
|
||||
{ name = "aliyun-python-sdk-core" },
|
||||
]
|
||||
sdist = { url = "https://files.pythonhosted.org/packages/a8/2c/9877d0e6b18ecf246df671ac65a5d1d9fecbf85bdcb5d43efbde0d4662eb/aliyun-python-sdk-kms-2.16.5.tar.gz", hash = "sha256:f328a8a19d83ecbb965ffce0ec1e9930755216d104638cd95ecd362753b813b3", size = 12018, upload-time = "2024-08-30T09:01:20.104Z" }
|
||||
wheels = [
|
||||
{ url = "https://files.pythonhosted.org/packages/11/5c/0132193d7da2c735669a1ed103b142fd63c9455984d48c5a88a1a516efaa/aliyun_python_sdk_kms-2.16.5-py2.py3-none-any.whl", hash = "sha256:24b6cdc4fd161d2942619479c8d050c63ea9cd22b044fe33b60bbb60153786f0", size = 99495, upload-time = "2024-08-30T09:01:18.462Z" },
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "annotated-types"
|
||||
version = "0.7.0"
|
||||
|
|
@ -690,6 +712,7 @@ dependencies = [
|
|||
{ name = "mistletoe" },
|
||||
{ name = "ollama" },
|
||||
{ name = "openai" },
|
||||
{ name = "oss2" },
|
||||
{ name = "paddleocr" },
|
||||
{ name = "paddlepaddle" },
|
||||
{ name = "pdfplumber" },
|
||||
|
|
@ -724,6 +747,7 @@ requires-dist = [
|
|||
{ name = "mistletoe", specifier = ">=1.5.0" },
|
||||
{ name = "ollama", specifier = ">=0.6.0" },
|
||||
{ name = "openai", specifier = ">=2.7.1" },
|
||||
{ name = "oss2", specifier = ">=2.18.0" },
|
||||
{ name = "paddleocr", specifier = ">=2.10.0,<3.0.0" },
|
||||
{ name = "paddlepaddle", specifier = ">=3.0.0,<4.0.0" },
|
||||
{ name = "pdfplumber", specifier = ">=0.11.7" },
|
||||
|
|
@ -1322,6 +1346,15 @@ wheels = [
|
|||
{ url = "https://files.pythonhosted.org/packages/d9/71/71408b02c6133153336d29fa3ba53000f1e1a3f78bb2fc2d1a1865d2e743/jiter-0.11.1-graalpy312-graalpy250_312_native-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:18c77aaa9117510d5bdc6a946baf21b1f0cfa58ef04d31c8d016f206f2118960", size = 343697, upload-time = "2025-10-17T11:31:13.773Z" },
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "jmespath"
|
||||
version = "0.10.0"
|
||||
source = { registry = "https://pypi.org/simple" }
|
||||
sdist = { url = "https://files.pythonhosted.org/packages/3c/56/3f325b1eef9791759784aa5046a8f6a1aff8f7c898a2e34506771d3b99d8/jmespath-0.10.0.tar.gz", hash = "sha256:b85d0567b8666149a93172712e68920734333c0ce7e89b78b3e987f71e5ed4f9", size = 21607, upload-time = "2020-05-12T22:03:47.267Z" }
|
||||
wheels = [
|
||||
{ url = "https://files.pythonhosted.org/packages/07/cb/5f001272b6faeb23c1c9e0acc04d48eaaf5c862c17709d20e3469c6e0139/jmespath-0.10.0-py2.py3-none-any.whl", hash = "sha256:cdf6525904cc597730141d61b36f2e4b8ecc257c420fa2f4549bac2c2d0cb72f", size = 24489, upload-time = "2020-05-12T22:03:45.643Z" },
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "joblib"
|
||||
version = "1.5.2"
|
||||
|
|
@ -1984,21 +2017,16 @@ wheels = [
|
|||
{ url = "https://files.pythonhosted.org/packages/35/d6/311b1afea060015b56c742f3531168c1644650767f27ef40062569960587/onnxruntime-1.23.2-cp310-cp310-macosx_13_0_arm64.whl", hash = "sha256:a7730122afe186a784660f6ec5807138bf9d792fa1df76556b27307ea9ebcbe3", size = 17195934, upload-time = "2025-10-27T23:06:14.143Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/db/db/81bf3d7cecfbfed9092b6b4052e857a769d62ed90561b410014e0aae18db/onnxruntime-1.23.2-cp310-cp310-macosx_13_0_x86_64.whl", hash = "sha256:b28740f4ecef1738ea8f807461dd541b8287d5650b5be33bca7b474e3cbd1f36", size = 19153079, upload-time = "2025-10-27T23:05:57.686Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/2e/4d/a382452b17cf70a2313153c520ea4c96ab670c996cb3a95cc5d5ac7bfdac/onnxruntime-1.23.2-cp310-cp310-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:8f7d1fe034090a1e371b7f3ca9d3ccae2fabae8c1d8844fb7371d1ea38e8e8d2", size = 15219883, upload-time = "2025-10-22T03:46:21.66Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/fb/56/179bf90679984c85b417664c26aae4f427cba7514bd2d65c43b181b7b08b/onnxruntime-1.23.2-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:4ca88747e708e5c67337b0f65eed4b7d0dd70d22ac332038c9fc4635760018f7", size = 17370357, upload-time = "2025-10-22T03:46:57.968Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/44/be/467b00f09061572f022ffd17e49e49e5a7a789056bad95b54dfd3bee73ff/onnxruntime-1.23.2-cp311-cp311-macosx_13_0_arm64.whl", hash = "sha256:6f91d2c9b0965e86827a5ba01531d5b669770b01775b23199565d6c1f136616c", size = 17196113, upload-time = "2025-10-22T03:47:33.526Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/9f/a8/3c23a8f75f93122d2b3410bfb74d06d0f8da4ac663185f91866b03f7da1b/onnxruntime-1.23.2-cp311-cp311-macosx_13_0_x86_64.whl", hash = "sha256:87d8b6eaf0fbeb6835a60a4265fde7a3b60157cf1b2764773ac47237b4d48612", size = 19153857, upload-time = "2025-10-22T03:46:37.578Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/3f/d8/506eed9af03d86f8db4880a4c47cd0dffee973ef7e4f4cff9f1d4bcf7d22/onnxruntime-1.23.2-cp311-cp311-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:bbfd2fca76c855317568c1b36a885ddea2272c13cb0e395002c402f2360429a6", size = 15220095, upload-time = "2025-10-22T03:46:24.769Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/e9/80/113381ba832d5e777accedc6cb41d10f9eca82321ae31ebb6bcede530cea/onnxruntime-1.23.2-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:da44b99206e77734c5819aa2142c69e64f3b46edc3bd314f6a45a932defc0b3e", size = 17372080, upload-time = "2025-10-22T03:47:00.265Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/1b/9e/f748cd64161213adeef83d0cb16cb8ace1e62fa501033acdd9f9341fff57/onnxruntime-1.23.2-cp312-cp312-macosx_13_0_arm64.whl", hash = "sha256:b8f029a6b98d3cf5be564d52802bb50a8489ab73409fa9db0bf583eabb7c2321", size = 17195929, upload-time = "2025-10-22T03:47:36.24Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/91/9d/a81aafd899b900101988ead7fb14974c8a58695338ab6a0f3d6b0100f30b/onnxruntime-1.23.2-cp312-cp312-macosx_13_0_x86_64.whl", hash = "sha256:218295a8acae83905f6f1aed8cacb8e3eb3bd7513a13fe4ba3b2664a19fc4a6b", size = 19157705, upload-time = "2025-10-22T03:46:40.415Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/3c/35/4e40f2fba272a6698d62be2cd21ddc3675edfc1a4b9ddefcc4648f115315/onnxruntime-1.23.2-cp312-cp312-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:76ff670550dc23e58ea9bc53b5149b99a44e63b34b524f7b8547469aaa0dcb8c", size = 15226915, upload-time = "2025-10-22T03:46:27.773Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/ef/88/9cc25d2bafe6bc0d4d3c1db3ade98196d5b355c0b273e6a5dc09c5d5d0d5/onnxruntime-1.23.2-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:0f9b4ae77f8e3c9bee50c27bc1beede83f786fe1d52e99ac85aa8d65a01e9b77", size = 17382649, upload-time = "2025-10-22T03:47:02.782Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/3d/41/fba0cabccecefe4a1b5fc8020c44febb334637f133acefc7ec492029dd2c/onnxruntime-1.23.2-cp313-cp313-macosx_13_0_arm64.whl", hash = "sha256:2ff531ad8496281b4297f32b83b01cdd719617e2351ffe0dba5684fb283afa1f", size = 17196337, upload-time = "2025-10-22T03:46:35.168Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/fe/f9/2d49ca491c6a986acce9f1d1d5fc2099108958cc1710c28e89a032c9cfe9/onnxruntime-1.23.2-cp313-cp313-macosx_13_0_x86_64.whl", hash = "sha256:162f4ca894ec3de1a6fd53589e511e06ecdc3ff646849b62a9da7489dee9ce95", size = 19157691, upload-time = "2025-10-22T03:46:43.518Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/1c/a1/428ee29c6eaf09a6f6be56f836213f104618fb35ac6cc586ff0f477263eb/onnxruntime-1.23.2-cp313-cp313-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:45d127d6e1e9b99d1ebeae9bcd8f98617a812f53f46699eafeb976275744826b", size = 15226898, upload-time = "2025-10-22T03:46:30.039Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/f2/2b/b57c8a2466a3126dbe0a792f56ad7290949b02f47b86216cd47d857e4b77/onnxruntime-1.23.2-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:8bace4e0d46480fbeeb7bbe1ffe1f080e6663a42d1086ff95c1551f2d39e7872", size = 17382518, upload-time = "2025-10-22T03:47:05.407Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/7c/3d/6830fa61c69ca8e905f237001dbfc01689a4e4ab06147020a4518318881f/onnxruntime-1.23.2-cp313-cp313t-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:9d2385e774f46ac38f02b3a91a91e30263d41b2f1f4f26ae34805b2a9ddef466", size = 15229610, upload-time = "2025-10-22T03:46:32.239Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/b6/ca/862b1e7a639460f0ca25fd5b6135fb42cf9deea86d398a92e44dfda2279d/onnxruntime-1.23.2-cp313-cp313t-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:e2b9233c4947907fd1818d0e581c049c41ccc39b2856cc942ff6d26317cee145", size = 17394184, upload-time = "2025-10-22T03:47:08.127Z" },
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
|
@ -2099,6 +2127,20 @@ wheels = [
|
|||
{ url = "https://files.pythonhosted.org/packages/bc/19/404708a7e54ad2798907210462fd950c3442ea51acc8790f3da48d2bee8b/opt_einsum-3.3.0-py3-none-any.whl", hash = "sha256:2455e59e3947d3c275477df7f5205b30635e266fe6dc300e3d9f9646bfcea147", size = 65486, upload-time = "2020-07-19T22:40:30.301Z" },
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "oss2"
|
||||
version = "2.19.1"
|
||||
source = { registry = "https://pypi.org/simple" }
|
||||
dependencies = [
|
||||
{ name = "aliyun-python-sdk-core" },
|
||||
{ name = "aliyun-python-sdk-kms" },
|
||||
{ name = "crcmod" },
|
||||
{ name = "pycryptodome" },
|
||||
{ name = "requests" },
|
||||
{ name = "six" },
|
||||
]
|
||||
sdist = { url = "https://files.pythonhosted.org/packages/df/b5/f2cb1950dda46ac2284d6c950489fdacd0e743c2d79a347924d3cc44b86f/oss2-2.19.1.tar.gz", hash = "sha256:a8ab9ee7eb99e88a7e1382edc6ea641d219d585a7e074e3776e9dec9473e59c1", size = 298845, upload-time = "2024-10-25T11:37:46.638Z" }
|
||||
|
||||
[[package]]
|
||||
name = "packaging"
|
||||
version = "25.0"
|
||||
|
|
|
|||
|
|
@ -0,0 +1,16 @@
|
|||
# WeKnora Lite 与标准版区别
|
||||
|
||||
Lite 面向希望快速在本地使用、部署尽量简单的场景;标准版面向多租户协作与完整企业能力。主要差异如下。
|
||||
|
||||
|
||||
| 维度 | Lite | 标准版 |
|
||||
| --------- | ----------------------------------------------- | --------------------------------- |
|
||||
| **共享空间** | 不提供共享空间(成员邀请、跨成员共享知识库与智能体等) | 提供共享空间及租户隔离检索等协作能力 |
|
||||
| **租户与账号** | 单租户;开箱即用,**无需注册** | 多租户;通常需要注册、登录与组织管理 |
|
||||
| **文档解析** | 内置仅 **Simple** 类型解析引擎;可通过 **Cloud** 等方式接入其他解析能力 | 可配置多种解析引擎(含高精度等),与完整文档处理链路集成 |
|
||||
| **部署形态** | **单应用、零依赖**(不依赖独立的数据库、消息队列等外部服务栈) | 典型为 Docker Compose 等多服务部署,依赖与组件更多 |
|
||||
| **数据归属** | 数据**完全在本地**存储与处理 | 私有化部署时数据也可在本地;具体取决于你的部署方式 |
|
||||
| **网络暴露** | **默认仅本机访问**;可按需配置,**选择是否放行到公网** | 按部署与安全策略自行绑定地址与网关 |
|
||||
|
||||
|
||||
若你不需要多团队协作、复杂解析流水线与多服务架构,Lite 更适合个人或小团队在本机零依赖试用;需要共享空间、多租户与完整解析引擎矩阵时,请使用标准版。
|
||||
18
docs/QA.md
18
docs/QA.md
|
|
@ -160,6 +160,24 @@ docker compose restart app
|
|||
|
||||
如果重启后短时间恢复正常,但再次访问又出现相同现象,仍应优先检查浏览器代理、缓存和多环境串连问题,而不是直接判断为后端配置丢失。
|
||||
|
||||
## 8. SSRF 校验白名单(`SSRF_WHITELIST`)
|
||||
|
||||
可选配置。在 `.env` 中设置 `SSRF_WHITELIST`,用于在 URL 校验等环节将指定目标加入白名单,从而绕过常规 SSRF 限制。值为逗号分隔的多条规则,每条可以是:
|
||||
|
||||
- **精确域名**:如 `api.internal`
|
||||
- **通配域名**:如 `*.example.com`
|
||||
- **IPv4**:如 `203.0.113.5`
|
||||
- **IPv6**:如 `2001:db8::1`(不要带方括号)
|
||||
- **CIDR**:如 `10.0.0.0/8`、`2001:db8::/32`
|
||||
|
||||
列入白名单的地址会在 URL 校验等处绕过常规 SSRF 规则,**生产环境请谨慎配置**,仅加入确实需要且可信的目标。
|
||||
|
||||
示例(与 `.env.example` 一致,可按需取消注释并修改):
|
||||
|
||||
```bash
|
||||
# SSRF_WHITELIST=internal.service,*.corp.example,172.16.0.0/12,2001:db8::1,fd00::/8
|
||||
```
|
||||
|
||||
|
||||
## P.S.
|
||||
如果以上方式未解决问题,请在issue中描述您的问题,并提供必要的日志信息辅助我们进行问题排查
|
||||
|
|
|
|||
330
docs/WeKnora.md
330
docs/WeKnora.md
|
|
@ -1,330 +0,0 @@
|
|||
## 介绍
|
||||
WeKora 是一个可立即在生产环境投入的企业级RAG框架,实现智能文档理解和检索功能。该系统采用模块化设计,将文档理解、向量存储、推理文件等功能分离。
|
||||
|
||||

|
||||
|
||||
---
|
||||
|
||||
## PipeLine
|
||||
WeKnora 处理文档需要多个步骤:插入-》知识提取-》索引-》检索-》生成,整个流程支持多种检索方法,
|
||||
|
||||

|
||||
|
||||
|
||||
以用户上传的一张住宿流水单pdf文件为例,详细介绍下其数据流:
|
||||
|
||||
### 1. 接收请求与初始化
|
||||
+ **请求识别**: 系统收到一个请求,并为其分配了唯一的 `request_id=Lkq0OGLYu2fV`,用于追踪整个处理流程。
|
||||
+ **租户与会话验证**:
|
||||
- 系统首先验证了租户信息(ID: 1, Name: Default Tenant)。
|
||||
- 接着开始处理一个知识库问答(Knowledge QA)请求,该请求属于会话 `1f241340-ae75-40a5-8731-9a3a82e34fdd`。
|
||||
+ **用户问题**: 用户的原始问题是:“**入住的房型是什么**”。
|
||||
+ **消息创建**: 系统为用户的提问和即将生成的回答分别创建了消息记录,ID 分别为 `703ddf09-...` 和 `6f057649-...`。
|
||||
|
||||
### 2. 知识库问答流程启动
|
||||
系统正式调用知识库问答服务,并定义了将要按顺序执行的完整处理管道(Pipeline),包含以下9个事件:
|
||||
`[rewrite_query, preprocess_query, chunk_search, chunk_rerank, chunk_merge, filter_top_k, into_chat_message, chat_completion_stream, stream_filter]`
|
||||
|
||||
---
|
||||
|
||||
### 3. 事件执行详情
|
||||
#### 事件 1: `rewrite_query` - 问题改写
|
||||
+ **目的**: 为了让检索更精确,系统需要结合上下文来理解用户的真实意图。
|
||||
+ **操作**:
|
||||
1. 系统检索了当前会话最近的20条历史消息(实际检索到8条)作为上下文。
|
||||
2. 调用了一个名为 `deepseek-r1:7b` 的本地大语言模型。
|
||||
3. 模型根据聊天历史分析出提问者是“Liwx”,并将原问题“入住的房型是什么”改写得更具体。
|
||||
+ **结果**: 问题被成功改写为:“**Liwx本次入住的房型是什么**”。
|
||||
|
||||
#### 事件 2: `preprocess_query` - 问题预处理
|
||||
+ **目的**: 将改写后的问题进行分词,转换为适合搜索引擎处理的关键词序列。
|
||||
+ **操作**: 对改写后的问题进行了分词处理。
|
||||
+ **结果**: 生成了一串关键词:“`需要 改写 用户 问题 入住 房型 根据 提供 信息 入住 人 Liwx 选择 房型 双床 房 因此 改写 后 完整 问题 为 Liwx 本次 入住 房型`”。
|
||||
|
||||
#### 事件 3: `chunk_search` - 知识区块检索
|
||||
这是最核心的**检索(Retrieval)**步骤,系统执行了两次混合搜索(Hybrid Search)。
|
||||
|
||||
+ **第一次搜索 (使用改写后的完整问句)**:
|
||||
- **向量检索**:
|
||||
1. 加载嵌入模型 `bge-m3:latest` 将问句转换为一个1024维的向量。
|
||||
2. 在PostgreSQL数据库中进行向量相似度搜索,找到了2个相关的知识区块(chunk),ID 分别为 `e3bf6599-...` 和 `3989c6ce-...`。
|
||||
- **关键词检索**:
|
||||
1. 同时,系统也进行了关键词搜索。
|
||||
2. 同样找到了上述2个知识区块。
|
||||
- **结果合并**: 两种方法找到的4个结果(实际是2个重复的)被去重,最终得到2个唯一的知识区块。
|
||||
+ **第二次搜索 (使用预处理后的关键词序列)**:
|
||||
- 系统使用分词后的关键词重复了上述的**向量检索**和**关键词检索**过程。
|
||||
- 最终也得到了相同的2个知识区块。
|
||||
+ **最终结果**: 经过两次搜索和结果合并,系统锁定了2个最相关的知识区块,并将它们的内容提取出来,准备用于生成答案。
|
||||
|
||||
#### 事件 4: `chunk_rerank` - 结果重排序
|
||||
+ **目的**: 使用一个更强大的模型对初步检索出的结果进行更精细的排序,以提高最终答案的质量。
|
||||
+ **操作**: 日志显示 `Rerank model ID is empty, skipping reranking`。这意味着系统配置了重排序步骤,但没有指定具体的重排序模型,因此**跳过了此步骤**。
|
||||
|
||||
#### 事件 5: `chunk_merge` - 区块合并
|
||||
+ **目的**: 将内容上相邻或相关的知识区块进行合并,形成更完整的上下文。
|
||||
+ **操作**: 系统分析了检索到的2个区块,并尝试进行合并。根据日志,最终处理后仍然是2个独立的区块,但已按相关性分数排好序。
|
||||
|
||||
#### 事件 6: `filter_top_k` - Top-K 过滤
|
||||
+ **目的**: 仅保留最相关的K个结果,防止过多无关信息干扰语言模型。
|
||||
+ **操作**: 系统配置保留前5个(Top-K = 5)最相关的区块。由于当前只有2个区块,它们全部通过了此过滤器。
|
||||
|
||||
#### 事件 7 & 8: `into_chat_message` & `chat_completion_stream` - 生成回答
|
||||
这是**生成(Generation)**步骤。
|
||||
|
||||
+ **目的**: 基于检索到的信息,生成自然流畅的回答。
|
||||
+ **操作**:
|
||||
1. 系统将检索到的2个知识区块的内容、用户的原始问题以及聊天历史整合在一起,形成一个完整的提示(Prompt)。
|
||||
2. 再次调用 `deepseek-r1:7b` 大语言模型,并以**流式(Stream)**的方式请求生成答案。流式输出可以实现打字机效果,提升用户体验。
|
||||
|
||||
#### 事件 9: `stream_filter` - 流式输出过滤
|
||||
+ **目的**: 对模型生成的实时文本流进行后处理,过滤掉不需要的特殊标记或内容。
|
||||
+ **操作**:
|
||||
- 系统设置了一个过滤器,用于移除模型在思考过程中可能产生的内部标记,如 `<think>` 和 `</think>`。
|
||||
- 日志显示,模型输出的第一个词块是 `<think> 根据`,过滤器成功拦截并移除了 `<think>` 标记,只将“根据”及之后的内容传递下去。
|
||||
|
||||
### 4. 完成与响应
|
||||
+ **发送引用**: 在生成答案的同时,系统将作为依据的2个知识区块作为“参考内容”发送给前端,以便用户查证来源。
|
||||
+ **更新消息**: 当模型生成完所有内容后,系统将完整的回答更新到之前创建的消息记录(ID: `6f057649-...`)中。
|
||||
+ **请求结束**: 服务器返回 `200` 成功状态码,标志着本次从提问到回答的完整流程结束。
|
||||
|
||||
### 总结
|
||||
这个日志完整地记录了一次典型的RAG流程:系统通过**问题改写**和**预处理**来精确理解用户意图,接着利用**向量与关键词混合检索**从知识库中找到相关信息,虽然跳过了**重排序**,但依然执行了**合并**与**过滤**,最后将检索到的知识作为上下文,交由大语言模型**生成**流畅、准确的回答,并通过**流式过滤**保证了输出的纯净性。
|
||||
|
||||
## 文档解析切分
|
||||
代码实现了一个独立的、通过gRPC通信的微服务,专门负责文档内容的深度解析、分块和多模态信息提取。它正是“异步处理”阶段的核心执行者。
|
||||
|
||||
### **整体架构**
|
||||
这是一个基于Python的gRPC服务,其核心职责是接收文件(或URL),并将其解析成结构化的、可供后续处理(如向量化)的文本块(Chunks)。
|
||||
|
||||
+ `server.py`: 服务的入口和网络层。它负责启动一个多进程、多线程的gRPC服务器,接收来自Go后端的请求,并将解析结果返回。
|
||||
+ `parser.py`: 设计模式中的**外观(Facade)模式**。它提供了一个统一的`Parser`类,屏蔽了内部多种具体解析器(如PDF、DOCX、Markdown等)的复杂性。外部调用者(`server.py`)只需与这个`Parser`类交互。
|
||||
+ `base_parser.py`: 解析器的基类,定义了所有具体解析器共享的核心逻辑和抽象方法。这是整个解析流程的“大脑”,包含了最复杂的文本分块、图片处理、OCR和图像描述生成等功能。
|
||||
|
||||
---
|
||||
|
||||
### **详细工作流程**
|
||||
当Go后端启动异步任务时,它会携带文件内容和配置信息,向这个Python服务发起一次gRPC调用。以下是完整的处理流程:
|
||||
|
||||
#### **第一步:请求接收与分发 (**`server.py`** & **`parser.py`**)
|
||||
1. **gRPC服务入口 (**`server.py: serve`**)**:
|
||||
- 服务通过`serve()`函数启动。它会根据环境变量(`GRPC_WORKER_PROCESSES`, `GRPC_MAX_WORKERS`)启动一个**多进程、多线程**的服务器,以充分利用CPU资源,提高并发处理能力。
|
||||
- 每个工作进程都监听在指定的端口(如50051),准备接收请求。
|
||||
2. **请求处理 (**`server.py: ReadFromFile`**)**:
|
||||
- 当Go后端发起`ReadFromFile`请求时,其中一个工作进程会接收到该请求。
|
||||
- 该方法首先会解析请求中的参数,包括:
|
||||
* `file_name`, `file_type`, `file_content`:文件的基本信息和二进制内容。
|
||||
* `read_config`: 一个包含所有解析配置的复杂对象,如`chunk_size`(分块大小)、`chunk_overlap`(重叠大小)、`enable_multimodal`(是否启用多模态处理)、`storage_config`(对象存储配置)、`vlm_config`(视觉语言模型配置)等。
|
||||
- 它将这些配置整合成一个`ChunkingConfig`数据对象。
|
||||
- 最关键的一步是调用 `self.parser.parse_file(...)`,将解析任务交给`Parser`外观类处理。
|
||||
3. **解析器选择 (**`parser.py: Parser.parse_file`**)**:
|
||||
- `Parser`类接收到任务后,首先调用`get_parser(file_type)`方法。
|
||||
- 该方法会根据文件类型(例如 `'pdf'`)在一个字典 `self.parsers` 中查找对应的具体解析器类(例如 `PDFParser`)。
|
||||
- 找到后,它会**实例化**这个`PDFParser`类,并将`ChunkingConfig`等所有配置信息传递给构造函数。
|
||||
|
||||
#### **第二步:核心解析与分块 (**`base_parser.py`**)**
|
||||
它触及了整个流程的核心:**如何保证信息的上下文完整性和原始顺序**。
|
||||
|
||||
根据 `base_parser.py` 代码,**最终切分出的 Chunk 中的文本、表格和图像是按照它们在原始文档中的出现顺序来保存的**。
|
||||
|
||||
这个顺序得以保证,主要归功于 `BaseParser` 中几个设计精巧的方法相互协作。我们来详细追踪一下这个流程。
|
||||
|
||||
整个顺序的保证可以分为三个阶段:
|
||||
|
||||
1. **阶段一:统一的文本流创建 (**`pdf_parser.py`**)**:
|
||||
- 在 `parse_into_text` 方法中,您的代码会**逐页**处理PDF。
|
||||
- 在每一页内部,它会按照一定的逻辑(先提取非表格文本,再附加表格,最后附加图像占位符)将所有内容**拼接成一个长字符串** (`page_content_parts`)。
|
||||
- **关键点**: 虽然在这个阶段,文本、表格和图像占位符的拼接顺序可能不是100%精确到字符级别,但它保证了**同一页的内容会在一起**,并且大致遵循了从上到下的阅读顺序。
|
||||
- 最后,所有页面的内容被 `"\n\n--- Page Break ---\n\n"` 连接起来,形成一个**包含了所有信息(文本、Markdown表格、图像占位符)的、单一的、有序的文本流 (**`final_text`**)**。
|
||||
2. **阶段二:原子化与保护 (**`_split_into_units`**)**:
|
||||
- 这个单一的 `final_text` 被传递给 `_split_into_units` 方法。
|
||||
- 这个方法是**保证结构完整性的关键**。它使用正则表达式,将**整个Markdown表格**和**整个Markdown图像占位符**识别为**不可分割的原子单元 (atomic units)**。
|
||||
- 它会将这些原子单元(表格、图片)和它们之间的普通文本块,按照它们在 `final_text` 中出现的**原始顺序**,切分成一个列表 (`units`)。
|
||||
- **结果**: 我们现在有了一个列表,例如 `['一些文本', '', '另一些文本', '|...|...|\n|---|---|\n...', '更多文本']`。这个列表中的元素顺序**完全等同于它们在原始文档中的顺序**。
|
||||
3. **阶段三:顺序分块 (**`chunk_text`**)**:
|
||||
- `chunk_text` 方法接收到这个**有序的 **`units`** 列表**。
|
||||
- 它的工作机制非常简单直接:它会**按顺序**遍历这个列表中的每一个单元(`unit`)。
|
||||
- 它将这些单元**依次添加**到一个临时的 `current_chunk` 列表中,直到这个块的长度接近 `chunk_size` 的上限。
|
||||
- 当一个块满了之后,它就被保存下来,然后开始一个新的块(可能会带有上一个块的重叠部分)。
|
||||
- **关键点**: 因为 `chunk_text` **严格按照 **`units`** 列表的顺序进行处理**,所以它永远不会打乱表格、文本和图像之间的相对顺序。一个在文档中先出现的表格,也必然会出现在一个序号更靠前的 Chunk 中。
|
||||
4. **阶段四:图像信息附加 (**`process_chunks_images`**)**:
|
||||
- 在文本块被切分好之后,`process_chunks_images` 方法会被调用。
|
||||
- 它会处理**每一个**已经生成好的 Chunk。
|
||||
- 在每个 Chunk 内部,它会找到图像占位符,然后进行AI处理。
|
||||
- 最后,它会将处理好的图像信息(包含永久URL、OCR文本、图像描述等)附加到**该 Chunk 自己**的 `.images` 属性中。
|
||||
- **关键点**: 这个过程**不会改变 Chunk 的顺序或其 **`.content`** 的内容**。它只是为已经存在的、顺序正确的 Chunk 附加额外的信息。
|
||||
|
||||
#### **第三步:多模态处理(如果启用) (**`base_parser.py`**)**
|
||||
如果 `enable_multimodal` 为 `True`,在文本分块完成后,会进入最复杂的多模态处理阶段。
|
||||
|
||||
1. **并发任务启动 (**`BaseParser.process_chunks_images`**)**:
|
||||
- 该方法使用`asyncio`(Python的异步I/O框架)来**并发处理所有文本块中的图片**,以极大地提升效率。
|
||||
- 它为每个`Chunk`创建一个异步任务`process_chunk_images_async`。
|
||||
2. **处理单个块中的图片 (**`BaseParser.process_chunk_images_async`**)**:
|
||||
- **提取图片引用**: 首先,使用正则表达式 `extract_images_from_chunk` 从当前块的文本中找到所有的图片引用(例如,``)。
|
||||
- **图片持久化**: 对于找到的每个图片,并发地调用 `download_and_upload_image`。这个函数负责:
|
||||
* 从其原始位置(可能是PDF内部、本地路径或远程URL)获取图片数据。
|
||||
* 将图片**上传到配置好的对象存储(COS/MinIO)**。这一步至关重要,它将临时的、不稳定的图片引用转换成一个持久化、可通过URL公开访问的地址。
|
||||
* 返回持久化的URL和图片对象(PIL Image)。
|
||||
- **并发AI处理**: 将所有成功上传的图片收集起来,调用`process_multiple_images`。
|
||||
* 该方法内部使用`asyncio.Semaphore`来限制并发数量(例如最多同时处理5张图片),防止瞬间消耗过多内存或触发模型API的速率限制。
|
||||
* 对于每张图片,它会调用`process_image_async`。
|
||||
3. **处理单张图片 (**`BaseParser.process_image_async`**)**:
|
||||
- **OCR**: 调用`perform_ocr`,它会使用一个OCR引擎(如`PaddleOCR`)来识别图片中的所有文字。
|
||||
- **图像描述 (Caption)**: 调用`get_image_caption`,它会将图片数据(转为Base64)发送给配置的视觉语言模型(VLM),生成对图片内容的自然语言描述。
|
||||
- 该方法返回 `(ocr_text, caption, 持久化URL)`。
|
||||
4. **结果聚合**:
|
||||
- 所有图片处理完成后,包含持久化URL、OCR文本和图像描述的结构化信息,会被附加到对应`Chunk`对象的 `.images` 字段上。
|
||||
|
||||
#### **第四步:返回结果 (**`server.py`**)**
|
||||
1. **数据转换 (**`server.py: _convert_chunk_to_proto`**)**:
|
||||
- 当`parser.parse_file`执行完毕后,它返回一个包含所有处理过的`Chunk`对象的列表(`ParseResult`)。
|
||||
- `ReadFromFile`方法接收到这个结果,并调用`_convert_chunk_to_proto`,将Python的`Chunk`对象(包括其内部的图片信息)转换成gRPC定义的Protobuf消息格式。
|
||||
2. **响应返回**:
|
||||
- 最后,gRPC服务器将这个包含所有分块和多模态信息的`ReadResponse`消息发送回给调用方——Go后端服务。
|
||||
|
||||
至此,Go后端就拿到了结构化、信息丰富的文档数据,可以进行下一步的向量化和索引存储了。
|
||||
|
||||
|
||||
## 部署
|
||||
支持Docker 镜像本地部署,并通过API端口提供接口服务
|
||||
|
||||
## 性能和监控
|
||||
Weknora包含丰富的监控和测试组件:
|
||||
|
||||
+ 分布式跟踪:集成Jaeger用于跟踪请求在服务架构中的完整执行路。本质上,Jaeger是一种帮助用户“看见”请求在分布式系统中完整生命周期的技术。
|
||||
+ 健康监控:监控服务处在健康状态
|
||||
+ 可扩展性:通过容器化部署,可通过多个服务满足大规模并发请求
|
||||
|
||||
## QA
|
||||
### 问题1: 在检索过程的执行了两次混合搜索的目的是什么?以及第一次和第二次搜索有什么不同?
|
||||
这是一个非常好的观察。系统执行两次混合搜索是为了**最大化检索的准确性和召回率**,本质上是一种**查询扩展(Query Expansion)和多策略检索**的组合方法。
|
||||
|
||||
#### 目的
|
||||
通过两种不同形式的查询(原始改写句 vs. 分词后的关键词序列)去搜索,系统可以结合两种查询方式的优点:
|
||||
|
||||
+ **语义检索的深度**: 使用完整的句子进行搜索,能更好地利用向量模型(如`bge-m3`)对句子整体含义的理解能力,找到语义上最接近的知识区块。
|
||||
+ **关键词检索的广度**: 使用分词后的关键词进行搜索,能确保即使知识区块的表述方式与原问题不同,但只要包含了核心关键词,就有机会被命中。这对于传统的关键词匹配算法(如BM25)尤其有效。
|
||||
|
||||
简单来说,就是**用两种不同的“问法”去问同一个问题**,然后将两边的结果汇总起来,确保最相关的知识不会被遗漏。
|
||||
|
||||
#### 两次搜索的不同点
|
||||
它们最核心的不同在于**输入的查询文本(Query Text)**:
|
||||
|
||||
1. **第一次混合搜索**
|
||||
- **输入**: 使用的是经过`rewrite_query`事件后生成的、**语法完整的自然语言问句**。
|
||||
- **日志证据**:
|
||||
|
||||
```plain
|
||||
INFO [2025-08-29 09:46:36.896] [request_id=Lkq0OGLYu2fV] knowledgebase.go:266[HybridSearch] | Hybrid search parameters, knowledge base ID: kb-00000001, query text: 需要改写的用户问题是:“入住的房型是什么”。根据提供的信息,入住人Liwx选择的房型是双床房。因此,改写后的完整问题为: “Liwx本次入住的房型是什么”
|
||||
```
|
||||
|
||||
2. **第二次混合搜索**
|
||||
- **输入**: 使用的是经过`preprocess_query`事件处理后生成的、**由空格隔开的关键词序列**。
|
||||
- **日志证据**:
|
||||
|
||||
```plain
|
||||
INFO [2025-08-29 09:46:37.257] [request_id=Lkq0OGLYu2fV] knowledgebase.go:266[HybridSearch] | Hybrid search parameters, knowledge base ID: kb-00000001, query text: 需要 改写 用户 问题 入住 房型 根据 提供 信息 入住 人 Liwx 选择 房型 双床 房 因此 改写 后 完整 问题 为 Liwx 本次 入住 房型
|
||||
```
|
||||
|
||||
最终,系统将这两次搜索的结果进行去重和合并(日志中显示每次都找到2个结果,去重后总共还是2个),从而得到一个更可靠的知识集合,用于后续的答案生成。
|
||||
|
||||
|
||||
|
||||
### 问题2:重排序模型分析
|
||||
Reranker(重排器)是目前RAG领域中非常先进的技术,它们在工作原理和适用场景上有着显著的区别。
|
||||
|
||||
简单来说,它们代表了从“**专门的判别模型**”到“**利用大语言模型(LLM)进行判别**”再到“**深度挖掘LLM内部信息进行判别**”的演进。
|
||||
|
||||
以下是它们的详细区别:
|
||||
|
||||
|
||||
|
||||
#### 1. Normal Reranker (常规重排器 / 交叉编码器)
|
||||
这是最经典也是最主流的重排方法。
|
||||
|
||||
+ **模型类型**: **序列分类模型 (Sequence Classification Model)**。本质上是一个**交叉编码器 (Cross-Encoder)**,通常基于BERT、RoBERTa等双向编码器架构。`BAAI/bge-reranker-base/large/v2-m3` 都属于这一类。
|
||||
+ **工作原理**:
|
||||
1. 它将**查询(Query)**和**待排序的文档(Passage)**拼接成一个单一的输入序列,例如:`[CLS] what is panda? [SEP] The giant panda is a bear species endemic to China. [SEP]`。
|
||||
2. 这个拼接后的序列被完整地送入模型中。模型内部的自注意力机制(Self-Attention)可以同时分析查询和文档中的每一个词,并计算它们之间**细粒度的交互关系**。
|
||||
3. 模型最终输出一个**单一的分数(Logit)**,这个分数直接代表了查询和文档的相关性。分数越高,相关性越强。
|
||||
+ **关键特性**:
|
||||
- **优点**: 由于查询和文档在模型内部进行了充分的、深度的交互,其**准确度通常非常高**,是衡量Reranker性能的黄金标准。
|
||||
- **缺点**: **速度较慢**。因为它必须为**每一个“查询-文档”对**都独立执行一次完整的、代价高昂的计算。如果初步检索返回了100个文档,它就需要运行100次。
|
||||
|
||||
|
||||
|
||||
#### 2. LLM-based Reranker (基于LLM的重排器)
|
||||
这种方法创造性地利用了通用大语言模型(LLM)的能力来进行重排。
|
||||
|
||||
+ **模型类型**: **因果语言模型 (Causal Language Model)**,即我们常说的GPT、Llama、Gemma这类用于生成文本的LLM。`BAAI/bge-reranker-v2-gemma` 就是一个典型的例子。
|
||||
+ **工作原理**:
|
||||
1. 它**不是直接输出一个分数**,而是将重排任务**转化为一个问答或文本生成任务**。
|
||||
2. 它通过一个精心设计的**提示(Prompt)**来组织输入,例如:`"Given a query A and a passage B, determine whether the passage contains an answer to the query by providing a prediction of either 'Yes' or 'No'. A: {query} B: {passage}"`。
|
||||
3. 它将这个完整的Prompt喂给LLM,然后**观察LLM在最后生成“Yes”这个词的概率**。
|
||||
4. 这个**生成“Yes”的概率(或其Logit值)就被当作是相关性分数**。如果模型非常确信答案是“Yes”,说明它认为文档B包含了查询A的答案,即相关性高。
|
||||
+ **关键特性**:
|
||||
- **优点**: 能够利用LLM强大的**语义理解、推理和世界知识**,对于需要深度理解和推理才能判断相关性的复杂查询,效果可能更好。
|
||||
- **缺点**: 计算开销可能非常大(取决于LLM的大小),并且性能**高度依赖于Prompt的设计**。
|
||||
|
||||
|
||||
|
||||
#### 3. LLM-based Layerwise Reranker (基于LLM分层信息的重排器)
|
||||
这是第二种方法的“威力加强版”,是一种更前沿、更复杂的探究性技术。
|
||||
|
||||
+ **模型类型**: 同样是**因果语言模型 (Causal Language Model)**,例如`BAAI/bge-reranker-v2-minicpm-layerwise`。
|
||||
+ **工作原理**:
|
||||
1. 输入部分与第二种方法完全相同,也是使用“Yes/No”的Prompt。
|
||||
2. 核心区别在于**分数的提取方式**。它不再仅仅依赖LLM**最后一层**的输出(即最终的预测结果)。
|
||||
3. 它认为LLM在逐层处理信息的过程中,不同深度的网络层(Layer)可能捕获了不同层次的语义相关性信息。因此,它会从**模型的多个中间层**提取出关于“Yes”这个词的预测Logit。
|
||||
4. 代码中的 `cutoff_layers=[28]` 参数就是告诉模型:“请把第28层的输出给我”。最终,你会得到一个或多个来自不同网络层的分数,这些分数可以被平均或以其他方式组合,形成一个更鲁棒的最终相关性判断。
|
||||
+ **关键特性**:
|
||||
- **优点**: 理论上可以获得**更丰富、更全面的相关性信号**,可能达到比只看最后一层更高的精度,是目前探索性能极限的一种方法。
|
||||
- **缺点**: **复杂度最高**,需要对模型进行特定的修改才能提取中间层信息(代码中的`trust_remote_code=True`就是一个信号),计算开销也很大。
|
||||
|
||||
#### 总结对比
|
||||
| 特性 | 1. Normal Reranker (常规) | 2. LLM-based Reranker (基于LLM) | 3. LLM-based Layerwise Reranker (基于LLM分层) |
|
||||
| :--- | :--- | :--- | :--- |
|
||||
| **底层模型** | 交叉编码器 (如BERT) | 因果语言模型 (如Gemma) | 因果语言模型 (如MiniCPM) |
|
||||
| **工作原理** | 计算Query和Passage的深度交互,直接输出相关分 | 将排序任务转为"Yes/No"预测,用"Yes"的概率作为分数 | 与2类似,但从LLM的多个中间层提取"Yes"的概率 |
|
||||
| **输出** | 单一的相关性分数 | 单一的相关性分数(来自最后一层) | 多个相关性分数(来自不同层) |
|
||||
| **优点** | **速度与精度的最佳平衡点**,成熟稳定 | 利用LLM的推理能力,处理复杂问题 | 理论上精度最高,信号更丰富 |
|
||||
| **缺点** | 相比向量检索慢 | 计算开销大,依赖Prompt设计 | **复杂度最高**,计算开销最大 |
|
||||
| **推荐场景** | **大多数生产环境的首选**,效果好,易于部署 | 对答案质量有极致要求,且计算资源充足的场景 | 学术研究或追求SOTA(State-of-the-art)性能的场景 |
|
||||
|
||||
|
||||
#### 使用建议
|
||||
1. **开始阶段**: 强烈建议您**从 **`Normal Reranker`** 开始**,例如 `BAAI/bge-reranker-v2-m3`。它是目前综合表现最好的模型之一,能显著提升您的RAG系统性能,并且相对容易集成和部署。
|
||||
2. **进阶探索**: 如果您发现常规Reranker在处理某些非常微妙或需要复杂推理的查询时表现不佳,并且您拥有充足的GPU资源,可以尝试 `LLM-based Reranker`。
|
||||
3. **前沿研究**: `Layerwise Reranker` 更适合研究人员或希望在特定任务上压榨出最后一点性能的专家。
|
||||
|
||||
|
||||
### 问题3:粗过滤或细过滤后的知识(带重排)如何组装发送给大模型的?
|
||||
这一块主要是设计提示词,典型的指令细节,其核心任务是根据上下文回答用户问题。组装上下文时需要指定
|
||||
关键约束:必须严格按照所提供文档回答,禁止使用你自己的知识回答
|
||||
未知情况处理: 如果文档中没有足够的信息来回答问题,请告知“根据所掌握的资料,无法回答这个问题”
|
||||
引用要求:在回答时,如果引用了某个文档内容,请在句子末尾加上文档编号
|
||||
|
||||
---
|
||||
|
||||
## 手工知识在线编辑
|
||||
|
||||
平台的知识库页面新增“上传文档 / 在线编辑”双入口,支持直接在浏览器中撰写并维护 Markdown 知识:
|
||||
|
||||
- 草稿模式用于暂存内容,草稿不会参与检索。
|
||||
- 发布操作会自动触发向量化与索引构建。
|
||||
- 已发布的 Markdown 知识可再次打开编辑并重新发布。
|
||||
- 在对话页面的助手回答末尾提供“添加到知识库”工具,可一键带入当前问答到编辑器中确认后保存。
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
BIN
docs/WeKnora.pdf
BIN
docs/WeKnora.pdf
Binary file not shown.
|
|
@ -458,7 +458,7 @@ curl --location 'http://localhost:8080/api/v1/agents/placeholders' \
|
|||
|------|------|--------|------|
|
||||
| `image_upload_enabled` | bool | false | 是否允许上传图片 |
|
||||
| `vlm_model_id` | string | - | 图片分析所用的 VLM 模型 ID |
|
||||
| `image_storage_provider` | string | - | 图片存储提供者:`local`/`minio`/`cos`/`tos`,为空使用全局默认 |
|
||||
| `image_storage_provider` | string | - | 图片存储提供者:`local`/`minio`/`cos`/`tos`/`oss`,为空使用全局默认 |
|
||||
|
||||
### FAQ 策略设置
|
||||
|
||||
|
|
|
|||
|
|
@ -155,6 +155,11 @@ curl --location 'http://localhost:8080/api/v1/system/storage-engine-status' \
|
|||
"name": "s3",
|
||||
"available": false,
|
||||
"description": "AWS S3 对象存储"
|
||||
},
|
||||
{
|
||||
"name": "oss",
|
||||
"available": false,
|
||||
"description": "阿里云 OSS 对象存储"
|
||||
}
|
||||
],
|
||||
"minio_env_available": true
|
||||
|
|
|
|||
|
|
@ -429,7 +429,7 @@ definitions:
|
|||
type: integer
|
||||
image_storage_provider:
|
||||
description: |-
|
||||
Storage provider for image uploads: "local", "minio", "cos", "tos"
|
||||
Storage provider for image uploads: "local", "minio", "cos", "tos", "s3", "oss"
|
||||
Empty means use the global/tenant default provider.
|
||||
type: string
|
||||
image_upload_enabled:
|
||||
|
|
@ -2067,12 +2067,14 @@ definitions:
|
|||
cos:
|
||||
$ref: '#/definitions/github_com_Tencent_WeKnora_internal_types.COSEngineConfig'
|
||||
default_provider:
|
||||
description: '"local", "minio", "cos", "tos", "s3"'
|
||||
description: '"local", "minio", "cos", "tos", "s3", "oss"'
|
||||
type: string
|
||||
local:
|
||||
$ref: '#/definitions/github_com_Tencent_WeKnora_internal_types.LocalEngineConfig'
|
||||
minio:
|
||||
$ref: '#/definitions/github_com_Tencent_WeKnora_internal_types.MinIOEngineConfig'
|
||||
oss:
|
||||
$ref: '#/definitions/github_com_Tencent_WeKnora_internal_types.OSSEngineConfig'
|
||||
s3:
|
||||
$ref: '#/definitions/github_com_Tencent_WeKnora_internal_types.S3EngineConfig'
|
||||
tos:
|
||||
|
|
@ -2081,7 +2083,7 @@ definitions:
|
|||
github_com_Tencent_WeKnora_internal_types.StorageProviderConfig:
|
||||
properties:
|
||||
provider:
|
||||
description: '"local", "minio", "cos", "tos"'
|
||||
description: '"local", "minio", "cos", "tos", "s3", "oss"'
|
||||
type: string
|
||||
type: object
|
||||
github_com_Tencent_WeKnora_internal_types.SubmitJoinRequestRequest:
|
||||
|
|
@ -2169,6 +2171,27 @@ definitions:
|
|||
secret_key:
|
||||
type: string
|
||||
type: object
|
||||
github_com_Tencent_WeKnora_internal_types.OSSEngineConfig:
|
||||
properties:
|
||||
access_key:
|
||||
type: string
|
||||
bucket_name:
|
||||
type: string
|
||||
endpoint:
|
||||
type: string
|
||||
path_prefix:
|
||||
type: string
|
||||
region:
|
||||
type: string
|
||||
secret_key:
|
||||
type: string
|
||||
temp_bucket_name:
|
||||
type: string
|
||||
temp_region:
|
||||
type: string
|
||||
use_temp_bucket:
|
||||
type: boolean
|
||||
type: object
|
||||
github_com_Tencent_WeKnora_internal_types.Tenant:
|
||||
properties:
|
||||
agent_config:
|
||||
|
|
@ -2671,8 +2694,10 @@ definitions:
|
|||
minio:
|
||||
$ref: '#/definitions/github_com_Tencent_WeKnora_internal_types.MinIOEngineConfig'
|
||||
provider:
|
||||
description: '"minio", "cos", "tos", or "s3"'
|
||||
description: '"minio", "cos", "tos", "s3", or "oss"'
|
||||
type: string
|
||||
oss:
|
||||
$ref: '#/definitions/github_com_Tencent_WeKnora_internal_types.OSSEngineConfig'
|
||||
s3:
|
||||
$ref: '#/definitions/github_com_Tencent_WeKnora_internal_types.S3EngineConfig'
|
||||
tos:
|
||||
|
|
@ -2696,7 +2721,7 @@ definitions:
|
|||
description: short description for UI
|
||||
type: string
|
||||
name:
|
||||
description: '"local", "minio", "cos", "tos"'
|
||||
description: '"local", "minio", "cos", "tos", "s3", "oss"'
|
||||
type: string
|
||||
type: object
|
||||
internal_handler.TextRelationExtractionRequest:
|
||||
|
|
|
|||
|
|
@ -15,8 +15,58 @@
|
|||
<link rel="apple-touch-icon" sizes="120x120" type="image/png" href="./public/favicon.ico"/>
|
||||
</head>
|
||||
<body>
|
||||
<script>
|
||||
(function(){
|
||||
var t=localStorage.getItem('WeKnora_theme')||'light';
|
||||
if(t==='system')t=window.matchMedia('(prefers-color-scheme:dark)').matches?'dark':'light';
|
||||
document.documentElement.setAttribute('theme-mode',t);
|
||||
/* 与 theme.css 中 --td-bg-color-page 一致,避免样式加载后整页背景从 #fff 跳到 #eee 触发重绘闪动 */
|
||||
var bg=t==='dark'?'#181818':'#eee';
|
||||
document.documentElement.style.background=bg;
|
||||
document.documentElement.style.minHeight='100%';
|
||||
document.documentElement.style.colorScheme=t==='dark'?'dark':'light';
|
||||
document.body.style.background=bg;
|
||||
document.body.style.minHeight='100%';
|
||||
try{
|
||||
var w=window.runtime;
|
||||
if(w){
|
||||
if(t==='dark'){
|
||||
if(w.WindowSetDarkTheme)w.WindowSetDarkTheme();
|
||||
if(w.WindowSetBackgroundColour)w.WindowSetBackgroundColour(24,24,24,255);
|
||||
}else{
|
||||
if(w.WindowSetLightTheme)w.WindowSetLightTheme();
|
||||
if(w.WindowSetBackgroundColour)w.WindowSetBackgroundColour(238,238,238,255);
|
||||
}
|
||||
}
|
||||
}catch(_){}
|
||||
})();
|
||||
</script>
|
||||
<script>
|
||||
(function(){
|
||||
try {
|
||||
if (localStorage.getItem('weknora_lite_mode') !== 'true') return;
|
||||
var saved = sessionStorage.getItem('weknora_lite_last_path');
|
||||
if (!saved || saved.indexOf('/platform/') !== 0 || saved.indexOf('/platform/organizations') === 0) return;
|
||||
var path = window.location.pathname;
|
||||
if (path !== '/' && path !== '/platform' && path !== '/platform/knowledge-bases') return;
|
||||
var target = saved.indexOf('#') >= 0 ? saved.slice(0, saved.indexOf('#')) : saved;
|
||||
if (!target) return;
|
||||
var current = window.location.pathname + window.location.search;
|
||||
if (target !== current) window.history.replaceState(window.history.state, '', target);
|
||||
} catch (e) {}
|
||||
})();
|
||||
</script>
|
||||
<script src="/config.js"></script>
|
||||
<div id="app"></div>
|
||||
<script>
|
||||
(function(){
|
||||
var t=localStorage.getItem('WeKnora_theme')||'light';
|
||||
if(t==='system')t=window.matchMedia('(prefers-color-scheme:dark)').matches?'dark':'light';
|
||||
var bg=t==='dark'?'#181818':'#eee';
|
||||
var el=document.getElementById('app');
|
||||
if(el){ el.style.background=bg; el.style.minHeight='100%'; }
|
||||
})();
|
||||
</script>
|
||||
<script type="module" src="/src/main.ts"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
|||
|
|
@ -1,12 +1,12 @@
|
|||
{
|
||||
"name": "knowledage-base",
|
||||
"version": "0.3.4",
|
||||
"version": "0.3.6",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "knowledage-base",
|
||||
"version": "0.3.4",
|
||||
"version": "0.3.6",
|
||||
"dependencies": {
|
||||
"@microsoft/fetch-event-source": "^2.0.1",
|
||||
"@types/dompurify": "^3.0.5",
|
||||
|
|
@ -463,42 +463,40 @@
|
|||
"license": "MIT"
|
||||
},
|
||||
"node_modules/@chevrotain/cst-dts-gen": {
|
||||
"version": "11.1.2",
|
||||
"resolved": "https://mirrors.tencent.com/npm/@chevrotain/cst-dts-gen/-/cst-dts-gen-11.1.2.tgz",
|
||||
"integrity": "sha512-XTsjvDVB5nDZBQB8o0o/0ozNelQtn2KrUVteIHSlPd2VAV2utEb6JzyCJaJ8tGxACR4RiBNWy5uYUHX2eji88Q==",
|
||||
"version": "12.0.0",
|
||||
"resolved": "https://registry.npmjs.org/@chevrotain/cst-dts-gen/-/cst-dts-gen-12.0.0.tgz",
|
||||
"integrity": "sha512-fSL4KXjTl7cDgf0B5Rip9Q05BOrYvkJV/RrBTE/bKDN096E4hN/ySpcBK5B24T76dlQ2i32Zc3PAE27jFnFrKg==",
|
||||
"license": "Apache-2.0",
|
||||
"dependencies": {
|
||||
"@chevrotain/gast": "11.1.2",
|
||||
"@chevrotain/types": "11.1.2",
|
||||
"lodash-es": "4.17.23"
|
||||
"@chevrotain/gast": "12.0.0",
|
||||
"@chevrotain/types": "12.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@chevrotain/gast": {
|
||||
"version": "11.1.2",
|
||||
"resolved": "https://mirrors.tencent.com/npm/@chevrotain/gast/-/gast-11.1.2.tgz",
|
||||
"integrity": "sha512-Z9zfXR5jNZb1Hlsd/p+4XWeUFugrHirq36bKzPWDSIacV+GPSVXdk+ahVWZTwjhNwofAWg/sZg58fyucKSQx5g==",
|
||||
"version": "12.0.0",
|
||||
"resolved": "https://registry.npmjs.org/@chevrotain/gast/-/gast-12.0.0.tgz",
|
||||
"integrity": "sha512-1ne/m3XsIT8aEdrvT33so0GUC+wkctpUPK6zU9IlOyJLUbR0rg4G7ZiApiJbggpgPir9ERy3FRjT6T7lpgetnQ==",
|
||||
"license": "Apache-2.0",
|
||||
"dependencies": {
|
||||
"@chevrotain/types": "11.1.2",
|
||||
"lodash-es": "4.17.23"
|
||||
"@chevrotain/types": "12.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@chevrotain/regexp-to-ast": {
|
||||
"version": "11.1.2",
|
||||
"resolved": "https://mirrors.tencent.com/npm/@chevrotain/regexp-to-ast/-/regexp-to-ast-11.1.2.tgz",
|
||||
"integrity": "sha512-nMU3Uj8naWer7xpZTYJdxbAs6RIv/dxYzkYU8GSwgUtcAAlzjcPfX1w+RKRcYG8POlzMeayOQ/znfwxEGo5ulw==",
|
||||
"version": "12.0.0",
|
||||
"resolved": "https://registry.npmjs.org/@chevrotain/regexp-to-ast/-/regexp-to-ast-12.0.0.tgz",
|
||||
"integrity": "sha512-p+EW9MaJwgaHguhoqwOtx/FwuGr+DnNn857sXWOi/mClXIkPGl3rn7hGNWvo31HA3vyeQxjqe+H36yZJwYU8cA==",
|
||||
"license": "Apache-2.0"
|
||||
},
|
||||
"node_modules/@chevrotain/types": {
|
||||
"version": "11.1.2",
|
||||
"resolved": "https://mirrors.tencent.com/npm/@chevrotain/types/-/types-11.1.2.tgz",
|
||||
"integrity": "sha512-U+HFai5+zmJCkK86QsaJtoITlboZHBqrVketcO2ROv865xfCMSFpELQoz1GkX5GzME8pTa+3kbKrZHQtI0gdbw==",
|
||||
"version": "12.0.0",
|
||||
"resolved": "https://registry.npmjs.org/@chevrotain/types/-/types-12.0.0.tgz",
|
||||
"integrity": "sha512-S+04vjFQKeuYw0/eW3U52LkAHQsB1ASxsPGsLPUyQgrZ2iNNibQrsidruDzjEX2JYfespXMG0eZmXlhA6z7nWA==",
|
||||
"license": "Apache-2.0"
|
||||
},
|
||||
"node_modules/@chevrotain/utils": {
|
||||
"version": "11.1.2",
|
||||
"resolved": "https://mirrors.tencent.com/npm/@chevrotain/utils/-/utils-11.1.2.tgz",
|
||||
"integrity": "sha512-4mudFAQ6H+MqBTfqLmU7G1ZwRzCLfJEooL/fsF6rCX5eePMbGhoy5n4g+G4vlh2muDcsCTJtL+uKbOzWxs5LHA==",
|
||||
"version": "12.0.0",
|
||||
"resolved": "https://registry.npmjs.org/@chevrotain/utils/-/utils-12.0.0.tgz",
|
||||
"integrity": "sha512-lB59uJoaGIfOOL9knQqQRfhl9g7x8/wqFkp13zTdkRu1huG9kg6IJs1O8hqj9rs6h7orGxHJUKb+mX3rPbWGhA==",
|
||||
"license": "Apache-2.0"
|
||||
},
|
||||
"node_modules/@esbuild/aix-ppc64": {
|
||||
|
|
@ -2391,13 +2389,14 @@
|
|||
"license": "MIT"
|
||||
},
|
||||
"node_modules/axios": {
|
||||
"version": "1.13.5",
|
||||
"resolved": "https://mirrors.tencent.com/npm/axios/-/axios-1.13.5.tgz",
|
||||
"integrity": "sha512-cz4ur7Vb0xS4/KUN0tPWe44eqxrIu31me+fbang3ijiNscE129POzipJJA6zniq2C/Z6sJCjMimjS8Lc/GAs8Q==",
|
||||
"version": "1.15.0",
|
||||
"resolved": "https://registry.npmjs.org/axios/-/axios-1.15.0.tgz",
|
||||
"integrity": "sha512-wWyJDlAatxk30ZJer+GeCWS209sA42X+N5jU2jy6oHTp7ufw8uzUTVFBX9+wTfAlhiJXGS0Bq7X6efruWjuK9Q==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"follow-redirects": "^1.15.11",
|
||||
"form-data": "^4.0.5",
|
||||
"proxy-from-env": "^1.1.0"
|
||||
"proxy-from-env": "^2.1.0"
|
||||
}
|
||||
},
|
||||
"node_modules/baseline-browser-mapping": {
|
||||
|
|
@ -2492,28 +2491,31 @@
|
|||
]
|
||||
},
|
||||
"node_modules/chevrotain": {
|
||||
"version": "11.1.2",
|
||||
"resolved": "https://mirrors.tencent.com/npm/chevrotain/-/chevrotain-11.1.2.tgz",
|
||||
"integrity": "sha512-opLQzEVriiH1uUQ4Kctsd49bRoFDXGGSC4GUqj7pGyxM3RehRhvTlZJc1FL/Flew2p5uwxa1tUDWKzI4wNM8pg==",
|
||||
"version": "12.0.0",
|
||||
"resolved": "https://registry.npmjs.org/chevrotain/-/chevrotain-12.0.0.tgz",
|
||||
"integrity": "sha512-csJvb+6kEiQaqo1woTdSAuOWdN0WTLIydkKrBnS+V5gZz0oqBrp4kQ35519QgK6TpBThiG3V1vNSHlIkv4AglQ==",
|
||||
"license": "Apache-2.0",
|
||||
"dependencies": {
|
||||
"@chevrotain/cst-dts-gen": "11.1.2",
|
||||
"@chevrotain/gast": "11.1.2",
|
||||
"@chevrotain/regexp-to-ast": "11.1.2",
|
||||
"@chevrotain/types": "11.1.2",
|
||||
"@chevrotain/utils": "11.1.2",
|
||||
"lodash-es": "4.17.23"
|
||||
"@chevrotain/cst-dts-gen": "12.0.0",
|
||||
"@chevrotain/gast": "12.0.0",
|
||||
"@chevrotain/regexp-to-ast": "12.0.0",
|
||||
"@chevrotain/types": "12.0.0",
|
||||
"@chevrotain/utils": "12.0.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=22.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/chevrotain-allstar": {
|
||||
"version": "0.3.1",
|
||||
"resolved": "https://mirrors.tencent.com/npm/chevrotain-allstar/-/chevrotain-allstar-0.3.1.tgz",
|
||||
"integrity": "sha512-b7g+y9A0v4mxCW1qUhf3BSVPg+/NvGErk/dOkrDaHA0nQIQGAtrOjlX//9OQtRlSCy+x9rfB5N8yC71lH1nvMw==",
|
||||
"version": "0.4.1",
|
||||
"resolved": "https://registry.npmjs.org/chevrotain-allstar/-/chevrotain-allstar-0.4.1.tgz",
|
||||
"integrity": "sha512-PvVJm3oGqrveUVW2Vt/eZGeiAIsJszYweUcYwcskg9e+IubNYKKD+rHHem7A6XVO22eDAL+inxNIGAzZ/VIWlA==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"lodash-es": "^4.17.21"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"chevrotain": "^11.0.0"
|
||||
"chevrotain": "^12.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/chrome-trace-event": {
|
||||
|
|
@ -3802,13 +3804,14 @@
|
|||
"integrity": "sha512-Ls993zuzfayK269Svk9hzpeGUKob/sIgZzyHYdjQoAdQetRKpOLj+k/QQQ/6Qi0Yz65mlROrfd+Ev+1+7dz9Kw=="
|
||||
},
|
||||
"node_modules/langium": {
|
||||
"version": "4.2.1",
|
||||
"resolved": "https://mirrors.tencent.com/npm/langium/-/langium-4.2.1.tgz",
|
||||
"integrity": "sha512-zu9QWmjpzJcomzdJQAHgDVhLGq5bLosVak1KVa40NzQHXfqr4eAHupvnPOVXEoLkg6Ocefvf/93d//SB7du4YQ==",
|
||||
"version": "4.2.2",
|
||||
"resolved": "https://registry.npmjs.org/langium/-/langium-4.2.2.tgz",
|
||||
"integrity": "sha512-JUshTRAfHI4/MF9dH2WupvjSXyn8JBuUEWazB8ZVJUtXutT0doDlAv1XKbZ1Pb5sMexa8FF4CFBc0iiul7gbUQ==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"chevrotain": "~11.1.1",
|
||||
"chevrotain-allstar": "~0.3.1",
|
||||
"@chevrotain/regexp-to-ast": "~12.0.0",
|
||||
"chevrotain": "~12.0.0",
|
||||
"chevrotain-allstar": "~0.4.1",
|
||||
"vscode-languageserver": "~9.0.1",
|
||||
"vscode-languageserver-textdocument": "~1.0.11",
|
||||
"vscode-uri": "~3.1.0"
|
||||
|
|
@ -3899,9 +3902,10 @@
|
|||
}
|
||||
},
|
||||
"node_modules/lodash-es": {
|
||||
"version": "4.17.23",
|
||||
"resolved": "https://mirrors.tencent.com/npm/lodash-es/-/lodash-es-4.17.23.tgz",
|
||||
"integrity": "sha512-kVI48u3PZr38HdYz98UmfPnXl2DXrpdctLrFLCd3kOx1xUkOmpFPx7gCWWM5MPkL/fD8zb+Ph0QzjGFs4+hHWg=="
|
||||
"version": "4.18.1",
|
||||
"resolved": "https://registry.npmjs.org/lodash-es/-/lodash-es-4.18.1.tgz",
|
||||
"integrity": "sha512-J8xewKD/Gk22OZbhpOVSwcs60zhd95ESDwezOFuA3/099925PdHJ7OFHNTGtajL3AlZkykD32HykiMo+BIBI8A==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/lru-cache": {
|
||||
"version": "5.1.1",
|
||||
|
|
@ -4367,9 +4371,13 @@
|
|||
"license": "MIT"
|
||||
},
|
||||
"node_modules/proxy-from-env": {
|
||||
"version": "1.1.0",
|
||||
"resolved": "https://mirrors.tencent.com/npm/proxy-from-env/-/proxy-from-env-1.1.0.tgz",
|
||||
"integrity": "sha512-D+zkORCbA9f1tdWRK0RaCR3GPv50cMxcrz4X8k5LTSUD1Dkw47mKJEZQNunItRTkWwgtaUSo1RVFRIG9ZXiFYg=="
|
||||
"version": "2.1.0",
|
||||
"resolved": "https://registry.npmjs.org/proxy-from-env/-/proxy-from-env-2.1.0.tgz",
|
||||
"integrity": "sha512-cJ+oHTW1VAEa8cJslgmUZrc+sjRKgAKl3Zyse6+PV38hZe/V6Z14TbCuXcan9F9ghlz4QrFr2c92TNF82UkYHA==",
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">=10"
|
||||
}
|
||||
},
|
||||
"node_modules/prr": {
|
||||
"version": "1.0.1",
|
||||
|
|
@ -4538,14 +4546,6 @@
|
|||
"semver": "bin/semver.js"
|
||||
}
|
||||
},
|
||||
"node_modules/serialize-javascript": {
|
||||
"version": "7.0.3",
|
||||
"resolved": "https://mirrors.tencent.com/npm/serialize-javascript/-/serialize-javascript-7.0.3.tgz",
|
||||
"integrity": "sha512-h+cZ/XXarqDgCjo+YSyQU/ulDEESGGf8AMK9pPNmhNSl/FzPl6L8pMp1leca5z6NuG6tvV/auC8/43tmovowww==",
|
||||
"engines": {
|
||||
"node": ">=20.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/setimmediate": {
|
||||
"version": "1.0.5",
|
||||
"resolved": "https://mirrors.tencent.com/npm/setimmediate/-/setimmediate-1.0.5.tgz",
|
||||
|
|
@ -4789,14 +4789,14 @@
|
|||
}
|
||||
},
|
||||
"node_modules/terser-webpack-plugin": {
|
||||
"version": "5.3.16",
|
||||
"resolved": "https://mirrors.tencent.com/npm/terser-webpack-plugin/-/terser-webpack-plugin-5.3.16.tgz",
|
||||
"integrity": "sha512-h9oBFCWrq78NyWWVcSwZarJkZ01c2AyGrzs1crmHZO3QUg9D61Wu4NPjBy69n7JqylFF5y+CsUZYmYEIZ3mR+Q==",
|
||||
"version": "5.4.0",
|
||||
"resolved": "https://registry.npmjs.org/terser-webpack-plugin/-/terser-webpack-plugin-5.4.0.tgz",
|
||||
"integrity": "sha512-Bn5vxm48flOIfkdl5CaD2+1CiUVbonWQ3KQPyP7/EuIl9Gbzq/gQFOzaMFUEgVjB1396tcK0SG8XcNJ/2kDH8g==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@jridgewell/trace-mapping": "^0.3.25",
|
||||
"jest-worker": "^27.4.5",
|
||||
"schema-utils": "^4.3.0",
|
||||
"serialize-javascript": "^6.0.2",
|
||||
"terser": "^5.31.1"
|
||||
},
|
||||
"engines": {
|
||||
|
|
@ -4952,13 +4952,13 @@
|
|||
}
|
||||
},
|
||||
"node_modules/vite": {
|
||||
"version": "7.2.2",
|
||||
"resolved": "https://mirrors.tencent.com/npm/vite/-/vite-7.2.2.tgz",
|
||||
"integrity": "sha512-BxAKBWmIbrDgrokdGZH1IgkIk/5mMHDreLDmCJ0qpyJaAteP8NvMhkwr/ZCQNqNH97bw/dANTE9PDzqwJghfMQ==",
|
||||
"version": "7.3.2",
|
||||
"resolved": "https://registry.npmjs.org/vite/-/vite-7.3.2.tgz",
|
||||
"integrity": "sha512-Bby3NOsna2jsjfLVOHKes8sGwgl4TT0E6vvpYgnAYDIF/tie7MRaFthmKuHx1NSXjiTueXH3do80FMQgvEktRg==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"esbuild": "^0.25.0",
|
||||
"esbuild": "^0.27.0",
|
||||
"fdir": "^6.5.0",
|
||||
"picomatch": "^4.0.3",
|
||||
"postcss": "^8.5.6",
|
||||
|
|
|
|||
|
|
@ -0,0 +1 @@
|
|||
a8c281c741c2499a02564295ccfb3f91
|
||||
|
|
@ -1,10 +1,11 @@
|
|||
<script setup lang="ts">
|
||||
import { computed, nextTick, onMounted } from 'vue'
|
||||
import { computed, nextTick, onMounted, onUnmounted } from 'vue'
|
||||
import { useRouter } from 'vue-router'
|
||||
import { useI18n } from 'vue-i18n'
|
||||
import { MessagePlugin } from 'tdesign-vue-next'
|
||||
import ManualKnowledgeEditor from '@/components/manual-knowledge-editor.vue'
|
||||
import { useAuthStore } from '@/stores/auth'
|
||||
import { useSettingsStore } from '@/stores/settings'
|
||||
import { getCurrentUser } from '@/api/auth'
|
||||
|
||||
// TDesign locale configs
|
||||
|
|
@ -16,6 +17,7 @@ import ruRUConfig from 'tdesign-vue-next/esm/locale/ru_RU'
|
|||
const { locale } = useI18n()
|
||||
const router = useRouter()
|
||||
const authStore = useAuthStore()
|
||||
const settingsStore = useSettingsStore()
|
||||
|
||||
const tdLocaleMap: Record<string, object> = {
|
||||
'en-US': enUSConfig,
|
||||
|
|
@ -132,9 +134,40 @@ const handleGlobalOIDCCallback = async () => {
|
|||
}
|
||||
}
|
||||
|
||||
let updateCheckTimer: ReturnType<typeof setInterval> | null = null
|
||||
|
||||
onMounted(() => {
|
||||
handleGlobalOIDCCallback()
|
||||
|
||||
// Auto check for updates on startup
|
||||
setTimeout(() => {
|
||||
if (settingsStore.isAutoCheckUpdateEnabled) {
|
||||
// @ts-ignore
|
||||
if (window.go && window.go.main && window.go.main.App && window.go.main.App.AutoCheckForUpdates) {
|
||||
// @ts-ignore
|
||||
window.go.main.App.AutoCheckForUpdates()
|
||||
}
|
||||
}
|
||||
}, 2000)
|
||||
|
||||
// Periodically check for updates (every 4 hours)
|
||||
updateCheckTimer = setInterval(() => {
|
||||
if (settingsStore.isAutoCheckUpdateEnabled) {
|
||||
// @ts-ignore
|
||||
if (window.go && window.go.main && window.go.main.App && window.go.main.App.AutoCheckForUpdates) {
|
||||
// @ts-ignore
|
||||
window.go.main.App.AutoCheckForUpdates()
|
||||
}
|
||||
}
|
||||
}, 4 * 60 * 60 * 1000)
|
||||
})
|
||||
|
||||
onUnmounted(() => {
|
||||
if (updateCheckTimer) {
|
||||
clearInterval(updateCheckTimer)
|
||||
}
|
||||
})
|
||||
|
||||
</script>
|
||||
<template>
|
||||
<t-config-provider :globalConfig="tdGlobalConfig">
|
||||
|
|
@ -145,6 +178,11 @@ onMounted(() => {
|
|||
</t-config-provider>
|
||||
</template>
|
||||
<style>
|
||||
html {
|
||||
/* 提示 UA 使用对应配色绘制滚动条等,减少主题切换时的额外重绘 */
|
||||
color-scheme: light dark;
|
||||
}
|
||||
|
||||
body,
|
||||
html,
|
||||
#app {
|
||||
|
|
@ -160,4 +198,11 @@ html,
|
|||
background: var(--td-bg-color-page);
|
||||
color: var(--td-text-color-primary);
|
||||
}
|
||||
|
||||
#app {
|
||||
/* 独立合成层,减轻 WebKit 全量重绘时整窗与内容的撕裂感(桌面 WebView 尤其明显) */
|
||||
isolation: isolate;
|
||||
transform: translateZ(0);
|
||||
backface-visibility: hidden;
|
||||
}
|
||||
</style>
|
||||
|
|
|
|||
|
|
@ -49,6 +49,7 @@ export interface CustomAgentConfig {
|
|||
|
||||
// ===== 网络搜索设置 =====
|
||||
web_search_enabled?: boolean;
|
||||
web_search_provider_id?: string;
|
||||
web_search_max_results?: number;
|
||||
|
||||
// ===== 多轮对话设置 =====
|
||||
|
|
@ -184,10 +185,10 @@ export interface IMChannel {
|
|||
id: string;
|
||||
tenant_id?: number;
|
||||
agent_id: string;
|
||||
platform: 'wecom' | 'feishu' | 'slack' | 'telegram' | 'dingtalk' | 'mattermost';
|
||||
platform: 'wecom' | 'feishu' | 'slack' | 'telegram' | 'dingtalk' | 'mattermost' | 'wechat';
|
||||
name: string;
|
||||
enabled: boolean;
|
||||
mode: 'webhook' | 'websocket';
|
||||
mode: 'webhook' | 'websocket' | 'longpoll';
|
||||
output_mode: 'stream' | 'full';
|
||||
session_mode?: 'user' | 'thread';
|
||||
knowledge_base_id?: string;
|
||||
|
|
@ -238,3 +239,27 @@ export function getSuggestedQuestions(
|
|||
const qs = query.toString();
|
||||
return get<{ data: { questions: SuggestedQuestion[] } }>(`/api/v1/agents/${agentId}/suggested-questions${qs ? '?' + qs : ''}`);
|
||||
}
|
||||
// ===== WeChat QR Code Login =====
|
||||
|
||||
export interface WeChatQRCodeResult {
|
||||
qrcode_url: string;
|
||||
qrcode: string;
|
||||
}
|
||||
|
||||
export interface WeChatQRCodeStatus {
|
||||
status: 'wait' | 'scaned' | 'confirmed' | 'expired';
|
||||
credentials?: {
|
||||
bot_token: string;
|
||||
ilink_bot_id: string;
|
||||
ilink_user_id: string;
|
||||
};
|
||||
baseurl?: string;
|
||||
}
|
||||
|
||||
export function getWeChatQRCode() {
|
||||
return post<{ data: WeChatQRCodeResult }>('/api/v1/wechat/qrcode');
|
||||
}
|
||||
|
||||
export function pollWeChatQRCodeStatus(qrcode: string) {
|
||||
return post<{ data: WeChatQRCodeStatus }>('/api/v1/wechat/qrcode/status', { qrcode });
|
||||
}
|
||||
|
|
|
|||
|
|
@ -190,6 +190,21 @@ export async function register(data: RegisterRequest): Promise<RegisterResponse>
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Lite 版自动初始化(创建默认用户/租户 + 签发令牌)
|
||||
*/
|
||||
export async function autoSetup(): Promise<LoginResponse> {
|
||||
try {
|
||||
const response = await post('/api/v1/auth/auto-setup', {})
|
||||
return response as unknown as LoginResponse
|
||||
} catch (error: any) {
|
||||
return {
|
||||
success: false,
|
||||
message: error.message || 'Auto-setup unavailable'
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取当前用户信息
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -1,7 +1,8 @@
|
|||
import { fetchEventSource } from '@microsoft/fetch-event-source'
|
||||
import { ref, type Ref, onUnmounted, nextTick } from 'vue'
|
||||
import { fetchEventSource } from '@microsoft/fetch-event-source';
|
||||
import { ref, onUnmounted } from 'vue';
|
||||
import { generateRandomString } from '@/utils/index';
|
||||
import i18n from '@/i18n';
|
||||
import { getApiBaseUrl } from '@/utils/api-base';
|
||||
|
||||
|
||||
|
||||
|
|
@ -37,7 +38,7 @@ export function useStream() {
|
|||
isLoading.value = true;
|
||||
|
||||
// 获取API配置
|
||||
const apiUrl = import.meta.env.VITE_IS_DOCKER ? "" : "http://localhost:8080";
|
||||
const apiUrl = getApiBaseUrl();
|
||||
|
||||
// 获取JWT Token
|
||||
const token = localStorage.getItem('weknora_token');
|
||||
|
|
|
|||
|
|
@ -255,6 +255,7 @@ export function checkRemoteModel(modelConfig: {
|
|||
modelName: string;
|
||||
baseUrl: string;
|
||||
apiKey?: string;
|
||||
provider?: string;
|
||||
}): Promise<{
|
||||
available: boolean;
|
||||
message?: string;
|
||||
|
|
|
|||
|
|
@ -126,3 +126,45 @@ export function deleteModel(id: string): Promise<void> {
|
|||
});
|
||||
}
|
||||
|
||||
export interface InitializeWeKnoraCloudRequest {
|
||||
app_id: string
|
||||
app_secret: string
|
||||
}
|
||||
|
||||
export interface InitializeWeKnoraCloudResult {
|
||||
models: Array<{
|
||||
name: string
|
||||
type: string
|
||||
action: 'created' | 'updated'
|
||||
}>
|
||||
}
|
||||
|
||||
export function initializeWeKnoraCloud(data: InitializeWeKnoraCloudRequest): Promise<InitializeWeKnoraCloudResult> {
|
||||
return post('/api/v1/models/weknoracloud/initialize', data) as Promise<InitializeWeKnoraCloudResult>
|
||||
}
|
||||
|
||||
export interface WeKnoraCloudStatusResult {
|
||||
has_models: boolean
|
||||
needs_reinit: boolean
|
||||
reason?: string
|
||||
}
|
||||
|
||||
export function getWeKnoraCloudStatus(): Promise<WeKnoraCloudStatusResult> {
|
||||
return new Promise((resolve, reject) => {
|
||||
get('/api/v1/models/weknoracloud/status')
|
||||
.then((response: any) => {
|
||||
// status 接口直接返回对象,不包在 success/data 中
|
||||
if (response && typeof response.has_models === 'boolean') {
|
||||
resolve(response)
|
||||
} else if (response?.success && response?.data) {
|
||||
resolve(response.data)
|
||||
} else {
|
||||
resolve({ has_models: false, needs_reinit: false })
|
||||
}
|
||||
})
|
||||
.catch(() => {
|
||||
resolve({ has_models: false, needs_reinit: false })
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -183,7 +183,7 @@ export function reconnectDocReader(addr: string): Promise<ParserEnginesResponse
|
|||
// ---- 存储引擎配置(租户级,供文档/图片存储与 docreader 使用) ----
|
||||
|
||||
export interface StorageEngineConfig {
|
||||
default_provider: string // "local" | "minio" | "cos" | "tos" | "s3"
|
||||
default_provider: string // "local" | "minio" | "cos" | "tos" | "s3" | "oss"
|
||||
local?: { path_prefix: string }
|
||||
minio?: { mode: string; endpoint: string; access_key_id: string; secret_access_key: string; bucket_name: string; use_ssl: boolean; path_prefix: string }
|
||||
cos?: {
|
||||
|
|
@ -210,6 +210,17 @@ export interface StorageEngineConfig {
|
|||
bucket_name: string
|
||||
path_prefix: string
|
||||
}
|
||||
oss?: {
|
||||
endpoint: string
|
||||
region: string
|
||||
access_key: string
|
||||
secret_key: string
|
||||
bucket_name: string
|
||||
path_prefix: string
|
||||
use_temp_bucket: boolean
|
||||
temp_bucket_name: string
|
||||
temp_region: string
|
||||
}
|
||||
}
|
||||
|
||||
export interface StorageEngineStatusItem {
|
||||
|
|
@ -236,11 +247,12 @@ export function getStorageEngineStatus(): Promise<{ data: GetStorageEngineStatus
|
|||
}
|
||||
|
||||
export interface StorageCheckRequest {
|
||||
provider: string // "minio" | "cos" | "tos" | "s3"
|
||||
provider: string // "minio" | "cos" | "tos" | "s3" | "oss"
|
||||
minio?: StorageEngineConfig['minio']
|
||||
cos?: StorageEngineConfig['cos']
|
||||
tos?: StorageEngineConfig['tos']
|
||||
s3?: StorageEngineConfig['s3']
|
||||
oss?: StorageEngineConfig['oss']
|
||||
}
|
||||
|
||||
export interface StorageCheckResponse {
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ export interface WebSearchProviderEntity {
|
|||
id?: string
|
||||
tenant_id?: number
|
||||
name: string
|
||||
provider: 'bing' | 'google' | 'duckduckgo' | 'tavily'
|
||||
provider: 'bing' | 'google' | 'duckduckgo' | 'tavily' | 'ollama' | 'baidu'
|
||||
description?: string
|
||||
parameters: {
|
||||
api_key?: string
|
||||
|
|
|
|||
|
|
@ -89,13 +89,14 @@
|
|||
<!-- Platform -->
|
||||
<div class="form-item">
|
||||
<label class="form-label">{{ $t('agentEditor.im.platform') }}</label>
|
||||
<t-radio-group v-model="formData.platform" :disabled="!!editingChannel">
|
||||
<t-radio-group v-model="formData.platform" :disabled="!!editingChannel" @change="onPlatformChange">
|
||||
<t-radio-button value="wecom">{{ $t('agentEditor.im.wecom') }}</t-radio-button>
|
||||
<t-radio-button value="feishu">{{ $t('agentEditor.im.feishu') }}</t-radio-button>
|
||||
<t-radio-button value="slack">{{ $t('agentEditor.im.slack') }}</t-radio-button>
|
||||
<t-radio-button value="telegram">{{ $t('agentEditor.im.telegram') }}</t-radio-button>
|
||||
<t-radio-button value="dingtalk">{{ $t('agentEditor.im.dingtalk') }}</t-radio-button>
|
||||
<t-radio-button value="mattermost">{{ $t('agentEditor.im.mattermost') }}</t-radio-button>
|
||||
<t-radio-button value="wechat">{{ $t('agentEditor.im.wechat') }}</t-radio-button>
|
||||
</t-radio-group>
|
||||
</div>
|
||||
|
||||
|
|
@ -105,8 +106,8 @@
|
|||
<t-input v-model="formData.name" :placeholder="$t('agentEditor.im.channelNamePlaceholder')" />
|
||||
</div>
|
||||
|
||||
<!-- Mode -->
|
||||
<div class="form-item">
|
||||
<!-- Mode (hidden for WeChat) -->
|
||||
<div v-if="formData.platform !== 'wechat'" class="form-item">
|
||||
<label class="form-label">{{ $t('agentEditor.im.mode') }}</label>
|
||||
<t-radio-group v-model="formData.mode">
|
||||
<t-radio-button value="websocket" :disabled="formData.platform === 'mattermost'">WebSocket</t-radio-button>
|
||||
|
|
@ -116,8 +117,8 @@
|
|||
<p v-else class="form-hint">{{ $t('agentEditor.im.modeHint') }}</p>
|
||||
</div>
|
||||
|
||||
<!-- Output mode -->
|
||||
<div class="form-item">
|
||||
<!-- Output mode (hidden for WeChat) -->
|
||||
<div v-if="formData.platform !== 'wechat'" class="form-item">
|
||||
<label class="form-label">{{ $t('agentEditor.im.outputMode') }}</label>
|
||||
<t-radio-group v-model="formData.output_mode">
|
||||
<t-radio-button value="stream">{{ $t('agentEditor.im.outputStream') }}</t-radio-button>
|
||||
|
|
@ -173,6 +174,11 @@
|
|||
<label class="form-label">Bot Secret</label>
|
||||
<t-input v-model="formData.credentials.bot_secret" type="password" placeholder="Bot Secret" />
|
||||
</div>
|
||||
<div class="form-item">
|
||||
<label class="form-label">WebSocket Endpoint</label>
|
||||
<t-input v-model="formData.credentials.ws_endpoint" placeholder="wss://openws.work.weixin.qq.com" />
|
||||
<p class="form-hint">{{ $t('agentEditor.im.wecomWSEndpointHint') }}</p>
|
||||
</div>
|
||||
</template>
|
||||
<template v-else>
|
||||
<div class="form-item">
|
||||
|
|
@ -195,6 +201,11 @@
|
|||
<label class="form-label">Corp Agent ID</label>
|
||||
<t-input-number v-model="formData.credentials.corp_agent_id" placeholder="Corp Agent ID" style="width: 100%;" />
|
||||
</div>
|
||||
<div class="form-item">
|
||||
<label class="form-label">API Base URL</label>
|
||||
<t-input v-model="formData.credentials.api_base_url" placeholder="https://qyapi.weixin.qq.com" />
|
||||
<p class="form-hint">{{ $t('agentEditor.im.wecomAPIBaseURLHint') }}</p>
|
||||
</div>
|
||||
</template>
|
||||
</template>
|
||||
|
||||
|
|
@ -339,16 +350,62 @@
|
|||
<p class="form-hint">{{ $t('agentEditor.im.mattermostPostToMainHint') }}</p>
|
||||
</div>
|
||||
</template>
|
||||
<!-- WeChat credentials (QR code binding) -->
|
||||
<template v-if="formData.platform === 'wechat'">
|
||||
<p class="form-hint">{{ $t('agentEditor.im.wechatHint') }}</p>
|
||||
|
||||
<!-- Already bound state -->
|
||||
<div v-if="wechatBound" class="wechat-bound-status">
|
||||
<t-icon name="check-circle-filled" class="bound-icon" />
|
||||
<span>{{ $t('agentEditor.im.wechatBindSuccess') }}</span>
|
||||
<t-button size="small" variant="outline" theme="default" @click="startWeChatBinding">
|
||||
{{ $t('agentEditor.im.wechatRebind') }}
|
||||
</t-button>
|
||||
</div>
|
||||
|
||||
<!-- QR code binding flow -->
|
||||
<div v-else class="wechat-qr-section">
|
||||
<!-- Initial state: show bind button -->
|
||||
<div v-if="!wechatQRImgUrl" class="wechat-bind-action">
|
||||
<t-button theme="default" variant="outline" :loading="wechatLoading" @click="startWeChatBinding">
|
||||
<template #icon><t-icon name="scan" /></template>
|
||||
{{ $t('agentEditor.im.wechatScanBind') }}
|
||||
</t-button>
|
||||
</div>
|
||||
|
||||
<!-- QR code displayed -->
|
||||
<div v-else class="wechat-qr-display">
|
||||
<div class="qr-container">
|
||||
<img :src="wechatQRImgUrl" alt="WeChat QR Code" class="qr-image" />
|
||||
<div v-if="wechatQRStatus === 'expired'" class="qr-expired-overlay" @click="startWeChatBinding">
|
||||
<t-icon name="refresh" class="refresh-icon" />
|
||||
<span>{{ $t('agentEditor.im.wechatQRExpired') }}</span>
|
||||
</div>
|
||||
</div>
|
||||
<p class="qr-hint">
|
||||
<template v-if="wechatQRStatus === 'scaned'">
|
||||
{{ $t('agentEditor.im.wechatBinding') }}
|
||||
</template>
|
||||
<template v-else>
|
||||
{{ $t('agentEditor.im.wechatScanning') }}
|
||||
</template>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
</div>
|
||||
</t-dialog>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { ref, onMounted, watch } from 'vue';
|
||||
import { ref, onMounted, watch, onUnmounted, computed } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { MessagePlugin } from 'tdesign-vue-next';
|
||||
import { listIMChannels, createIMChannel, updateIMChannel, deleteIMChannel, toggleIMChannel } from '@/api/agent';
|
||||
import {
|
||||
listIMChannels, createIMChannel, updateIMChannel, deleteIMChannel, toggleIMChannel,
|
||||
getWeChatQRCode, pollWeChatQRCodeStatus,
|
||||
} from '@/api/agent';
|
||||
import { listKnowledgeBases } from '@/api/knowledge-base';
|
||||
import type { IMChannel } from '@/api/agent';
|
||||
|
||||
|
|
@ -366,12 +423,21 @@ const editingChannel = ref<IMChannel | null>(null);
|
|||
// Knowledge base options for file-to-KB feature
|
||||
const knowledgeBases = ref<{ id: string; name: string }[]>([]);
|
||||
|
||||
// WeChat QR code binding state
|
||||
const wechatQRContent = ref(''); // raw text to encode as QR code
|
||||
const wechatQRImgUrl = ref(''); // generated QR image URL
|
||||
const wechatQRCode = ref(''); // opaque token for polling status
|
||||
const wechatQRStatus = ref<string>('');
|
||||
const wechatLoading = ref(false);
|
||||
let wechatPollActive = false;
|
||||
let wechatPollTimer: ReturnType<typeof setTimeout> | null = null;
|
||||
|
||||
const defaultCredentials = (): Record<string, any> => ({});
|
||||
|
||||
const formData = ref({
|
||||
platform: 'wecom' as 'wecom' | 'feishu' | 'slack' | 'telegram' | 'dingtalk' | 'mattermost',
|
||||
platform: 'wecom' as 'wecom' | 'feishu' | 'slack' | 'telegram' | 'dingtalk' | 'mattermost' | 'wechat',
|
||||
name: '',
|
||||
mode: 'websocket' as 'webhook' | 'websocket',
|
||||
mode: 'websocket' as 'webhook' | 'websocket' | 'longpoll',
|
||||
output_mode: 'stream' as 'stream' | 'full',
|
||||
session_mode: 'user' as 'user' | 'thread',
|
||||
knowledge_base_id: '',
|
||||
|
|
@ -401,6 +467,101 @@ watch(
|
|||
}
|
||||
},
|
||||
);
|
||||
// Whether WeChat credentials are already bound
|
||||
const wechatBound = computed(() => {
|
||||
return formData.value.platform === 'wechat' &&
|
||||
formData.value.credentials.bot_token &&
|
||||
formData.value.credentials.ilink_bot_id;
|
||||
});
|
||||
|
||||
|
||||
function onPlatformChange(val: string | number | boolean) {
|
||||
formData.value.credentials = defaultCredentials();
|
||||
stopWeChatPolling();
|
||||
wechatQRContent.value = '';
|
||||
wechatQRImgUrl.value = '';
|
||||
wechatQRCode.value = '';
|
||||
wechatQRStatus.value = '';
|
||||
// WeChat uses fixed mode/output
|
||||
if (val === 'wechat') {
|
||||
formData.value.mode = 'longpoll';
|
||||
formData.value.output_mode = 'full';
|
||||
} else {
|
||||
formData.value.mode = 'websocket';
|
||||
formData.value.output_mode = 'stream';
|
||||
}
|
||||
}
|
||||
|
||||
async function startWeChatBinding() {
|
||||
stopWeChatPolling();
|
||||
wechatLoading.value = true;
|
||||
wechatQRContent.value = '';
|
||||
wechatQRImgUrl.value = '';
|
||||
wechatQRStatus.value = '';
|
||||
|
||||
try {
|
||||
const res = await getWeChatQRCode();
|
||||
// qrcode_url is the text content to encode as QR code (e.g. a weixin:// URL)
|
||||
wechatQRContent.value = res.data.qrcode_url;
|
||||
wechatQRCode.value = res.data.qrcode;
|
||||
wechatQRStatus.value = 'wait';
|
||||
|
||||
// Generate QR code image via public API (no extra npm dependency needed)
|
||||
wechatQRImgUrl.value = `https://api.qrserver.com/v1/create-qr-code/?size=200x200&data=${encodeURIComponent(res.data.qrcode_url)}`;
|
||||
|
||||
// Start long-polling for scan status
|
||||
startStatusPolling();
|
||||
} catch (e: any) {
|
||||
MessagePlugin.error(e?.message || 'Failed to generate QR code');
|
||||
} finally {
|
||||
wechatLoading.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
function startStatusPolling() {
|
||||
wechatPollActive = true;
|
||||
pollOnce();
|
||||
}
|
||||
|
||||
async function pollOnce() {
|
||||
if (!wechatPollActive) return;
|
||||
try {
|
||||
const statusRes = await pollWeChatQRCodeStatus(wechatQRCode.value);
|
||||
if (!wechatPollActive) return;
|
||||
wechatQRStatus.value = statusRes.data.status;
|
||||
|
||||
if (statusRes.data.status === 'confirmed' && statusRes.data.credentials) {
|
||||
formData.value.credentials = {
|
||||
bot_token: statusRes.data.credentials.bot_token,
|
||||
ilink_bot_id: statusRes.data.credentials.ilink_bot_id,
|
||||
ilink_user_id: statusRes.data.credentials.ilink_user_id,
|
||||
};
|
||||
stopWeChatPolling();
|
||||
wechatQRContent.value = '';
|
||||
wechatQRImgUrl.value = '';
|
||||
MessagePlugin.success(t('agentEditor.im.wechatBindSuccess'));
|
||||
return;
|
||||
}
|
||||
if (statusRes.data.status === 'expired') {
|
||||
stopWeChatPolling();
|
||||
return;
|
||||
}
|
||||
} catch {
|
||||
// transient error
|
||||
}
|
||||
// Schedule next poll with a short delay (the backend already long-polled ~35s)
|
||||
if (wechatPollActive) {
|
||||
wechatPollTimer = setTimeout(pollOnce, 500);
|
||||
}
|
||||
}
|
||||
|
||||
function stopWeChatPolling() {
|
||||
wechatPollActive = false;
|
||||
if (wechatPollTimer) {
|
||||
clearTimeout(wechatPollTimer);
|
||||
wechatPollTimer = null;
|
||||
}
|
||||
}
|
||||
|
||||
async function loadChannels() {
|
||||
loading.value = true;
|
||||
|
|
@ -419,7 +580,7 @@ async function loadChannels() {
|
|||
}
|
||||
|
||||
function getCallbackUrl(channel: IMChannel): string {
|
||||
const base = import.meta.env.VITE_IS_DOCKER ? window.location.origin : 'http://127.0.0.1:8080';
|
||||
const base = window.location.origin;
|
||||
return `${base}/api/v1/im/callback/${channel.id}`;
|
||||
}
|
||||
|
||||
|
|
@ -461,6 +622,11 @@ function editChannel(channel: IMChannel) {
|
|||
|
||||
function resetForm() {
|
||||
editingChannel.value = null;
|
||||
stopWeChatPolling();
|
||||
wechatQRContent.value = '';
|
||||
wechatQRImgUrl.value = '';
|
||||
wechatQRCode.value = '';
|
||||
wechatQRStatus.value = '';
|
||||
formData.value = {
|
||||
platform: 'wecom',
|
||||
name: '',
|
||||
|
|
@ -474,6 +640,12 @@ function resetForm() {
|
|||
|
||||
async function handleSave() {
|
||||
try {
|
||||
// For WeChat, validate that credentials are bound
|
||||
if (formData.value.platform === 'wechat' && !formData.value.credentials.bot_token) {
|
||||
MessagePlugin.warning(t('agentEditor.im.wechatScanBind'));
|
||||
return;
|
||||
}
|
||||
|
||||
if (editingChannel.value) {
|
||||
await updateIMChannel(editingChannel.value.id, {
|
||||
name: formData.value.name,
|
||||
|
|
@ -527,6 +699,10 @@ async function handleDelete(id: string) {
|
|||
onMounted(() => {
|
||||
loadChannels();
|
||||
});
|
||||
|
||||
onUnmounted(() => {
|
||||
stopWeChatPolling();
|
||||
});
|
||||
</script>
|
||||
|
||||
<style scoped lang="less">
|
||||
|
|
@ -670,6 +846,11 @@ onMounted(() => {
|
|||
background: rgba(25, 42, 77, 0.08);
|
||||
color: #192a4d;
|
||||
}
|
||||
|
||||
&.wechat {
|
||||
background: rgba(7, 193, 96, 0.08);
|
||||
color: #07c160;
|
||||
}
|
||||
}
|
||||
|
||||
.channel-name {
|
||||
|
|
@ -815,4 +996,86 @@ onMounted(() => {
|
|||
color: var(--td-text-color-placeholder);
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
||||
// --- WeChat QR code binding ---
|
||||
.wechat-bound-status {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
padding: 12px 16px;
|
||||
background: rgba(7, 193, 96, 0.06);
|
||||
border: 1px solid rgba(7, 193, 96, 0.2);
|
||||
border-radius: 8px;
|
||||
font-size: 14px;
|
||||
color: var(--td-text-color-primary);
|
||||
|
||||
.bound-icon {
|
||||
font-size: 18px;
|
||||
color: #07c160;
|
||||
}
|
||||
}
|
||||
|
||||
.wechat-qr-section {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
gap: 12px;
|
||||
}
|
||||
|
||||
.wechat-bind-action {
|
||||
padding: 24px 0;
|
||||
}
|
||||
|
||||
.wechat-qr-display {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
gap: 12px;
|
||||
padding: 16px 0;
|
||||
}
|
||||
|
||||
.qr-container {
|
||||
position: relative;
|
||||
width: 200px;
|
||||
height: 200px;
|
||||
border: 1px solid var(--td-component-stroke);
|
||||
border-radius: 8px;
|
||||
overflow: hidden;
|
||||
// QR code images are always black-on-white; force white background
|
||||
// so the code remains scannable in dark mode.
|
||||
background: #fff;
|
||||
|
||||
.qr-image {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
object-fit: contain;
|
||||
}
|
||||
}
|
||||
|
||||
.qr-expired-overlay {
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 0;
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
gap: 8px;
|
||||
background: rgba(0, 0, 0, 0.6);
|
||||
color: #fff;
|
||||
cursor: pointer;
|
||||
font-size: 12px;
|
||||
|
||||
.refresh-icon {
|
||||
font-size: 24px;
|
||||
}
|
||||
}
|
||||
|
||||
.qr-hint {
|
||||
font-size: 13px;
|
||||
color: var(--td-text-color-secondary);
|
||||
text-align: center;
|
||||
}
|
||||
</style>
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ import AgentSelector from './AgentSelector.vue';
|
|||
import { getCaretCoordinates } from '@/utils/caret';
|
||||
import { listModels, type ModelConfig } from '@/api/model';
|
||||
import { listAgents, type CustomAgent, BUILTIN_QUICK_ANSWER_ID, BUILTIN_SMART_REASONING_ID } from '@/api/agent';
|
||||
import { getTenantWebSearchConfig } from '@/api/web-search';
|
||||
import { listWebSearchProviders, type WebSearchProviderEntity } from '@/api/web-search-provider';
|
||||
import { getConversationConfig, updateConversationConfig, type ConversationConfig } from '@/api/system';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import AttachmentUpload, { type AttachmentFile } from './AttachmentUpload.vue';
|
||||
|
|
@ -197,6 +197,11 @@ const agentWebSearchEnabled = computed(() => {
|
|||
return currentAgentConfig.value?.web_search_enabled ?? true;
|
||||
});
|
||||
|
||||
const agentWebSearchProviderId = computed(() => {
|
||||
if (!hasAgentConfig.value) return '';
|
||||
return currentAgentConfig.value?.web_search_provider_id || '';
|
||||
});
|
||||
|
||||
// 网络搜索是否被智能体禁用(只读状态)- 只有明确设置为 false 时才禁用
|
||||
const isWebSearchDisabledByAgent = computed(() => {
|
||||
return hasAgentConfig.value && agentWebSearchEnabled.value === false;
|
||||
|
|
@ -287,7 +292,6 @@ const isAgentEnabled = computed(() => settingsStore.isAgentEnabled);
|
|||
const isWebSearchEnabled = computed(() => settingsStore.isWebSearchEnabled);
|
||||
const selectedKbIds = computed(() => settingsStore.settings.selectedKnowledgeBases || []);
|
||||
const selectedFileIds = computed(() => settingsStore.settings.selectedFiles || []);
|
||||
const isWebSearchConfigured = ref(false);
|
||||
|
||||
// 获取已选择的知识库信息
|
||||
const knowledgeBases = ref<Array<{ id: string; name: string; type?: 'document' | 'faq'; knowledge_count?: number; chunk_count?: number }>>([]);
|
||||
|
|
@ -526,19 +530,29 @@ watch(selectedFileIds, () => {
|
|||
loadFiles();
|
||||
}, { immediate: true });
|
||||
|
||||
const webSearchProviders = ref<WebSearchProviderEntity[]>([]);
|
||||
|
||||
const isWebSearchConfigured = computed(() => {
|
||||
const agentProviderId = agentWebSearchProviderId.value;
|
||||
if (agentProviderId) {
|
||||
return webSearchProviders.value.some(p => p.id === agentProviderId);
|
||||
}
|
||||
|
||||
return webSearchProviders.value.some(p => p.is_default);
|
||||
});
|
||||
|
||||
const loadWebSearchConfig = async () => {
|
||||
try {
|
||||
const response: any = await getTenantWebSearchConfig();
|
||||
const config = response?.data;
|
||||
const configured = !!(config && config.provider);
|
||||
isWebSearchConfigured.value = configured;
|
||||
const response = await listWebSearchProviders();
|
||||
const providers = (response as any)?.data;
|
||||
webSearchProviders.value = Array.isArray(providers) ? providers : [];
|
||||
|
||||
if (!configured && settingsStore.isWebSearchEnabled) {
|
||||
if (!isWebSearchConfigured.value && settingsStore.isWebSearchEnabled) {
|
||||
settingsStore.toggleWebSearch(false);
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('Failed to load web search config:', error);
|
||||
isWebSearchConfigured.value = false;
|
||||
webSearchProviders.value = [];
|
||||
if (settingsStore.isWebSearchEnabled) {
|
||||
settingsStore.toggleWebSearch(false);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -317,6 +317,18 @@ const fallbackProviderOptions = computed(() => [
|
|||
description: t('model.editor.providers.openai.description'),
|
||||
modelTypes: ['chat', 'embedding', 'vllm', 'asr']
|
||||
},
|
||||
{
|
||||
value: 'azure_openai',
|
||||
label: t('model.editor.providers.azure_openai.label'),
|
||||
defaultUrls: {
|
||||
chat: 'https://{resource}.openai.azure.com',
|
||||
embedding: 'https://{resource}.openai.azure.com',
|
||||
vllm: 'https://{resource}.openai.azure.com',
|
||||
asr: 'https://{resource}.openai.azure.com'
|
||||
},
|
||||
description: t('model.editor.providers.azure_openai.description'),
|
||||
modelTypes: ['chat', 'embedding', 'vllm', 'asr']
|
||||
},
|
||||
{
|
||||
value: 'aliyun',
|
||||
label: t('model.editor.providers.aliyun.label'),
|
||||
|
|
@ -810,7 +822,8 @@ const checkRemoteAPI = async () => {
|
|||
result = await checkRemoteModel({
|
||||
modelName: formData.value.modelName,
|
||||
baseUrl: formData.value.baseUrl,
|
||||
apiKey: formData.value.apiKey || ''
|
||||
apiKey: formData.value.apiKey || '',
|
||||
provider: formData.value.provider
|
||||
})
|
||||
break
|
||||
|
||||
|
|
@ -846,7 +859,8 @@ const checkRemoteAPI = async () => {
|
|||
result = await checkRemoteModel({
|
||||
modelName: formData.value.modelName,
|
||||
baseUrl: formData.value.baseUrl,
|
||||
apiKey: formData.value.apiKey || ''
|
||||
apiKey: formData.value.apiKey || '',
|
||||
provider: formData.value.provider
|
||||
})
|
||||
break
|
||||
|
||||
|
|
|
|||
|
|
@ -22,10 +22,6 @@
|
|||
<t-icon name="control-platform" class="menu-icon" />
|
||||
<span>{{ $t('settings.modelManagement') }}</span>
|
||||
</div>
|
||||
<div class="menu-item" @click="handleQuickNav('ollama')">
|
||||
<t-icon name="server" class="menu-icon" />
|
||||
<span>Ollama</span>
|
||||
</div>
|
||||
<div class="menu-item" @click="handleQuickNav('websearch')">
|
||||
<svg
|
||||
width="16"
|
||||
|
|
@ -47,16 +43,21 @@
|
|||
<t-icon name="tools" class="menu-icon" />
|
||||
<span>{{ $t('settings.mcpService') }}</span>
|
||||
</div>
|
||||
<div class="menu-item" @click="handleQuickNav('api')">
|
||||
<t-icon name="secured" class="menu-icon" />
|
||||
<span>{{ $t('settings.apiInfo') }}</span>
|
||||
</div>
|
||||
<div class="menu-divider"></div>
|
||||
<div class="menu-item" @click="handleSettings">
|
||||
<t-icon name="setting" class="menu-icon" />
|
||||
<span>{{ $t('general.allSettings') }}</span>
|
||||
</div>
|
||||
<div class="menu-divider"></div>
|
||||
<div class="menu-item" @click="openApiDoc">
|
||||
<t-icon name="book" class="menu-icon" />
|
||||
<div class="menu-item" @click="openClawhubSkill">
|
||||
<span class="menu-icon menu-icon--emoji" role="img" :aria-label="$t('common.clawhubSkill')">🦞</span>
|
||||
<span class="menu-text-with-icon">
|
||||
<span>{{ $t('tenant.apiDocument') }}</span>
|
||||
<span>{{ $t('common.clawhubSkill') }}</span>
|
||||
<span class="menu-new-badge">{{ $t('common.newBadge') }}</span>
|
||||
<svg class="menu-external-icon" viewBox="0 0 16 16" aria-hidden="true">
|
||||
<path
|
||||
fill="currentColor"
|
||||
|
|
@ -65,10 +66,11 @@
|
|||
</svg>
|
||||
</span>
|
||||
</div>
|
||||
<div class="menu-item" @click="openWebsite">
|
||||
<t-icon name="home" class="menu-icon" />
|
||||
<div class="menu-item" @click="openChromeExtension">
|
||||
<t-icon name="extension" class="menu-icon" />
|
||||
<span class="menu-text-with-icon">
|
||||
<span>{{ $t('common.website') }}</span>
|
||||
<span>{{ $t('common.chromeExtension') }}</span>
|
||||
<span class="menu-new-badge">{{ $t('common.newBadge') }}</span>
|
||||
<svg class="menu-external-icon" viewBox="0 0 16 16" aria-hidden="true">
|
||||
<path
|
||||
fill="currentColor"
|
||||
|
|
@ -77,10 +79,15 @@
|
|||
</svg>
|
||||
</span>
|
||||
</div>
|
||||
<div class="menu-item" @click="openGithub">
|
||||
<div
|
||||
class="menu-item"
|
||||
:title="$t('common.githubStarTip')"
|
||||
@click="openGithub"
|
||||
>
|
||||
<t-icon name="logo-github" class="menu-icon" />
|
||||
<span class="menu-text-with-icon">
|
||||
<span>GitHub</span>
|
||||
<span>{{ $t('common.github') }}</span>
|
||||
<t-icon name="star-filled" class="menu-github-star-icon" size="14px" aria-hidden="true" />
|
||||
<svg class="menu-external-icon" viewBox="0 0 16 16" aria-hidden="true">
|
||||
<path
|
||||
fill="currentColor"
|
||||
|
|
@ -89,11 +96,13 @@
|
|||
</svg>
|
||||
</span>
|
||||
</div>
|
||||
<div class="menu-divider"></div>
|
||||
<div class="menu-item danger" @click="handleLogout">
|
||||
<t-icon name="logout" class="menu-icon" />
|
||||
<span>{{ $t('auth.logout') }}</span>
|
||||
</div>
|
||||
<template v-if="!authStore.isLiteMode">
|
||||
<div class="menu-divider"></div>
|
||||
<div class="menu-item danger" @click="handleLogout">
|
||||
<t-icon name="logout" class="menu-icon" />
|
||||
<span>{{ $t('auth.logout') }}</span>
|
||||
</div>
|
||||
</template>
|
||||
</div>
|
||||
</Transition>
|
||||
</div>
|
||||
|
|
@ -159,16 +168,20 @@ const handleSettings = () => {
|
|||
router.push('/platform/settings')
|
||||
}
|
||||
|
||||
// 打开 API 文档
|
||||
const openApiDoc = () => {
|
||||
const CHROME_EXTENSION_URL =
|
||||
'https://chromewebstore.google.com/detail/jpemjbopikggjlmikmclgbmkhhopjdgd?utm_source=item-share-cb'
|
||||
|
||||
const CLAWHUB_SKILL_URL = 'https://clawhub.ai/lyingbug/weknora'
|
||||
|
||||
// 打开 WeKnora Chrome 插件(Chrome应用商店)
|
||||
const openChromeExtension = () => {
|
||||
menuVisible.value = false
|
||||
window.open('https://github.com/Tencent/WeKnora/blob/main/docs/api/README.md', '_blank')
|
||||
window.open(CHROME_EXTENSION_URL, '_blank')
|
||||
}
|
||||
|
||||
// 打开官网
|
||||
const openWebsite = () => {
|
||||
const openClawhubSkill = () => {
|
||||
menuVisible.value = false
|
||||
window.open('https://weknora.weixin.qq.com/', '_blank')
|
||||
window.open(CLAWHUB_SKILL_URL, '_blank')
|
||||
}
|
||||
|
||||
// 打开 GitHub
|
||||
|
|
@ -407,6 +420,18 @@ onUnmounted(() => {
|
|||
height: 16px;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
&--emoji {
|
||||
width: 16px;
|
||||
height: 16px;
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
font-size: 15px;
|
||||
line-height: 1;
|
||||
flex-shrink: 0;
|
||||
color: inherit;
|
||||
}
|
||||
}
|
||||
|
||||
.menu-text-with-icon {
|
||||
|
|
@ -417,13 +442,33 @@ onUnmounted(() => {
|
|||
color: inherit;
|
||||
min-width: 0;
|
||||
|
||||
span {
|
||||
> span:first-of-type {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
min-width: 0;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
}
|
||||
|
||||
.menu-new-badge {
|
||||
flex-shrink: 0;
|
||||
font-size: 10px;
|
||||
font-weight: 600;
|
||||
line-height: 1.2;
|
||||
padding: 2px 5px;
|
||||
border-radius: 4px;
|
||||
background: var(--td-brand-color-light);
|
||||
color: var(--td-brand-color);
|
||||
letter-spacing: 0.02em;
|
||||
}
|
||||
|
||||
.menu-github-star-icon {
|
||||
flex-shrink: 0;
|
||||
color: var(--td-warning-color);
|
||||
}
|
||||
|
||||
.menu-external-icon {
|
||||
width: 14px;
|
||||
height: 14px;
|
||||
|
|
|
|||
|
|
@ -690,6 +690,24 @@ const getParentContent = (item: any) => {
|
|||
return parentContextCache.value.get(item.parent_chunk_id) || '';
|
||||
};
|
||||
|
||||
const summaryExpanded = ref(false);
|
||||
const summaryRef = ref<HTMLElement>();
|
||||
const summaryOverflow = ref(false);
|
||||
|
||||
const checkSummaryOverflow = () => {
|
||||
nextTick(() => {
|
||||
const el = summaryRef.value;
|
||||
if (!el) { summaryOverflow.value = false; return; }
|
||||
summaryOverflow.value = el.scrollHeight > el.clientHeight + 1;
|
||||
});
|
||||
};
|
||||
|
||||
watch(() => props.details?.description, () => {
|
||||
summaryExpanded.value = false;
|
||||
checkSummaryOverflow();
|
||||
});
|
||||
watch(summaryRef, () => checkSummaryOverflow());
|
||||
|
||||
const downloadFile = () => {
|
||||
downKnowledgeDetails(props.details.id)
|
||||
.then((result) => {
|
||||
|
|
@ -734,7 +752,7 @@ const handleDetailsScroll = () => {
|
|||
</script>
|
||||
<template>
|
||||
<div class="doc_content" ref="mdContentWrap">
|
||||
<t-drawer :visible="visible" :zIndex="2000" :closeBtn="true" @close="handleClose">
|
||||
<t-drawer :visible="visible" :zIndex="2000" :closeBtn="true" :footer="false" @close="handleClose">
|
||||
<template #header>
|
||||
<div class="drawer-header">
|
||||
<span class="header-title">{{ getDisplayTitle() }}</span>
|
||||
|
|
@ -784,7 +802,12 @@ const handleDetailsScroll = () => {
|
|||
<!-- 文档摘要 -->
|
||||
<div v-if="details.description" class="summary_box">
|
||||
<span class="label">{{ $t('knowledgeBase.documentSummary') }}</span>
|
||||
<div class="summary_content">{{ details.description }}</div>
|
||||
<div class="summary_wrapper" :class="{ 'summary_clickable': summaryOverflow || summaryExpanded }" @click="(summaryOverflow || summaryExpanded) && (summaryExpanded = !summaryExpanded)">
|
||||
<div ref="summaryRef" :class="['summary_content', { 'summary_collapsed': !summaryExpanded }]">{{ details.description }}</div>
|
||||
<div v-if="(summaryOverflow && !summaryExpanded) || summaryExpanded" class="summary_fade" :class="{ 'summary_fade_expanded': summaryExpanded }">
|
||||
<t-icon :name="summaryExpanded ? 'chevron-up' : 'chevron-down'" size="14px" class="summary_fade_icon" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div v-else-if="details.summary_status === 'pending' || details.summary_status === 'processing'" class="summary_box">
|
||||
<span class="label">{{ $t('knowledgeBase.documentSummary') }}</span>
|
||||
|
|
@ -948,10 +971,6 @@ const handleDetailsScroll = () => {
|
|||
/>
|
||||
</div>
|
||||
|
||||
<template #footer>
|
||||
<t-button @click="handleClose">{{ $t('common.confirm') }}</t-button>
|
||||
<t-button theme="default" @click="handleClose">{{ $t('common.cancel') }}</t-button>
|
||||
</template>
|
||||
</t-drawer>
|
||||
</div>
|
||||
</template>
|
||||
|
|
@ -1056,15 +1075,50 @@ const handleDetailsScroll = () => {
|
|||
font-size: 14px;
|
||||
}
|
||||
|
||||
.summary_content {
|
||||
padding: 12px;
|
||||
.summary_wrapper {
|
||||
position: relative;
|
||||
background: var(--td-bg-color-container-hover);
|
||||
border-radius: 4px;
|
||||
|
||||
&.summary_clickable {
|
||||
cursor: pointer;
|
||||
}
|
||||
}
|
||||
|
||||
.summary_content {
|
||||
padding: 12px;
|
||||
color: var(--td-text-color-primary);
|
||||
font-size: 13px;
|
||||
line-height: 1.5;
|
||||
word-break: break-word;
|
||||
white-space: pre-wrap;
|
||||
|
||||
&.summary_collapsed {
|
||||
max-height: 4.5em;
|
||||
overflow: hidden;
|
||||
}
|
||||
}
|
||||
|
||||
.summary_fade {
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
padding-bottom: 4px;
|
||||
pointer-events: none;
|
||||
|
||||
&:not(.summary_fade_expanded) {
|
||||
position: absolute;
|
||||
bottom: 0;
|
||||
left: 0;
|
||||
right: 0;
|
||||
height: 28px;
|
||||
background: linear-gradient(transparent, var(--td-bg-color-container-hover) 80%);
|
||||
border-radius: 0 0 4px 4px;
|
||||
align-items: flex-end;
|
||||
}
|
||||
}
|
||||
|
||||
.summary_fade_icon {
|
||||
color: var(--td-text-color-placeholder);
|
||||
}
|
||||
|
||||
.summary_loading {
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@
|
|||
<div class="logo_row" v-if="!uiStore.sidebarCollapsed">
|
||||
<div class="logo_box" @click="router.push('/platform/knowledge-bases')" style="cursor: pointer;">
|
||||
<img class="logo" src="@/assets/img/weknora.png" alt="">
|
||||
<sup v-if="isLiteEdition" class="lite-badge">Lite</sup>
|
||||
</div>
|
||||
<div class="sidebar-toggle"
|
||||
@click="uiStore.toggleSidebar"
|
||||
|
|
@ -60,6 +61,14 @@
|
|||
</div>
|
||||
</t-tooltip>
|
||||
<div ref="submenuscrollContainer" @scroll="handleScroll" class="submenu" v-if="item.children && !uiStore.sidebarCollapsed">
|
||||
<!-- 骨架屏占位 -->
|
||||
<template v-if="loading && groupedSessions.length === 0">
|
||||
<div v-for="n in 5" :key="'skel-'+n" class="submenu_item_p">
|
||||
<div class="submenu_item">
|
||||
<t-skeleton animation="gradient" style="margin-left:18px;width:80%" :row-col="[{ width: '100%', height: '16px' }]" />
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
<template v-for="(group, groupIndex) in groupedSessions" :key="groupIndex">
|
||||
<div class="timeline_header">{{ group.label }}</div>
|
||||
<div class="submenu_item_p" v-for="(subitem, subindex) in group.items" :key="subitem.id">
|
||||
|
|
@ -137,6 +146,7 @@ import { MessagePlugin, DialogPlugin, Icon as TIcon } from "tdesign-vue-next";
|
|||
import UserMenu from '@/components/UserMenu.vue';
|
||||
import TenantSelector from '@/components/TenantSelector.vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { getSystemInfo } from '@/api/system';
|
||||
|
||||
const { t } = useI18n();
|
||||
const usemenuStore = useMenuStore();
|
||||
|
|
@ -155,8 +165,9 @@ const submenuscrollContainer = ref(null);
|
|||
const totalPages = computed(() => Math.ceil(total.value / page_size.value));
|
||||
const hasMore = computed(() => currentPage.value < totalPages.value);
|
||||
type MenuItem = { title: string; icon: string; path: string; childrenPath?: string; children?: any[] };
|
||||
const { menuArr } = storeToRefs(usemenuStore);
|
||||
const { menuArr, visibleMenuArr } = storeToRefs(usemenuStore);
|
||||
let activeSubmenu = ref<string>('');
|
||||
const isLiteEdition = ref(false);
|
||||
|
||||
// 批量管理状态
|
||||
const batchMode = ref(false)
|
||||
|
|
@ -250,15 +261,15 @@ const getIconActiveState = (itemPath: string) => {
|
|||
};
|
||||
};
|
||||
|
||||
// 分离上下两部分菜单
|
||||
// 分离上下两部分菜单(使用 visibleMenuArr 以便 lite 模式过滤 logout)
|
||||
const topMenuItems = computed<MenuItem[]>(() => {
|
||||
return (menuArr.value as unknown as MenuItem[]).filter((item: MenuItem) =>
|
||||
return (visibleMenuArr.value as unknown as MenuItem[]).filter((item: MenuItem) =>
|
||||
item.path === 'knowledge-bases' || item.path === 'knowledge-search' || item.path === 'agents' || item.path === 'organizations' || item.path === 'creatChat'
|
||||
);
|
||||
});
|
||||
|
||||
const bottomMenuItems = computed<MenuItem[]>(() => {
|
||||
return (menuArr.value as unknown as MenuItem[]).filter((item: MenuItem) => {
|
||||
return (visibleMenuArr.value as unknown as MenuItem[]).filter((item: MenuItem) => {
|
||||
if (item.path === 'knowledge-bases' || item.path === 'knowledge-search' || item.path === 'agents' || item.path === 'organizations' || item.path === 'creatChat') {
|
||||
return false;
|
||||
}
|
||||
|
|
@ -539,6 +550,14 @@ onMounted(async () => {
|
|||
currentSecondpath.value = `chat/${route.params.chatid}`;
|
||||
}
|
||||
|
||||
isLiteEdition.value = authStore.isLiteMode
|
||||
getSystemInfo().then(res => {
|
||||
if (res.data?.edition === 'lite') {
|
||||
isLiteEdition.value = true
|
||||
authStore.setLiteMode(true)
|
||||
}
|
||||
}).catch(() => {})
|
||||
|
||||
// 初始化知识库信息
|
||||
const kbId = (route.params as any)?.kbId as string
|
||||
if (kbId && isInKnowledgeBase.value) {
|
||||
|
|
@ -761,6 +780,11 @@ const onDragHandleMouseDown = (e: MouseEvent) => {
|
|||
transition: width 0.25s ease, min-width 0.25s ease;
|
||||
position: relative;
|
||||
|
||||
// macOS Wails 桌面:红绿灯位于 HiddenInset 标题栏区域,需让出顶部空间
|
||||
html.wails-desktop & {
|
||||
padding-top: 30px;
|
||||
}
|
||||
|
||||
&--collapsed {
|
||||
min-width: 60px;
|
||||
width: 60px;
|
||||
|
|
@ -832,10 +856,21 @@ const onDragHandleMouseDown = (e: MouseEvent) => {
|
|||
flex: 1;
|
||||
min-width: 0;
|
||||
overflow: hidden;
|
||||
|
||||
.logo{
|
||||
width: 134px;
|
||||
height: auto;
|
||||
}
|
||||
.lite-badge {
|
||||
margin-left: 2px;
|
||||
align-self: flex-start;
|
||||
margin-top: 2px;
|
||||
font-size: 9px;
|
||||
font-weight: 600;
|
||||
color: var(--td-text-color-placeholder);
|
||||
user-select: none;
|
||||
white-space: nowrap;
|
||||
}
|
||||
}
|
||||
|
||||
.logo_img {
|
||||
|
|
@ -998,6 +1033,11 @@ const onDragHandleMouseDown = (e: MouseEvent) => {
|
|||
margin-left: 4px;
|
||||
}
|
||||
|
||||
@keyframes menuItemFadeIn {
|
||||
from { opacity: 0; transform: translateX(-4px); }
|
||||
to { opacity: 1; transform: translateX(0); }
|
||||
}
|
||||
|
||||
.timeline_header {
|
||||
font-family: "PingFang SC";
|
||||
font-size: 12px;
|
||||
|
|
@ -1007,6 +1047,7 @@ const onDragHandleMouseDown = (e: MouseEvent) => {
|
|||
margin-top: 8px;
|
||||
line-height: 20px;
|
||||
user-select: none;
|
||||
animation: menuItemFadeIn 0.25s ease-out;
|
||||
|
||||
&:first-child {
|
||||
margin-top: 4px;
|
||||
|
|
@ -1017,6 +1058,7 @@ const onDragHandleMouseDown = (e: MouseEvent) => {
|
|||
height: 44px;
|
||||
padding: 4px 0px 4px 0px;
|
||||
box-sizing: border-box;
|
||||
animation: menuItemFadeIn 0.25s ease-out;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -13,9 +13,46 @@ function getSystemTheme(): 'light' | 'dark' {
|
|||
return window.matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light'
|
||||
}
|
||||
|
||||
/** Wails:与原生窗口底色 / 系统深浅色一致,减轻 Ctrl+R 整窗白闪(浅色与 --td-bg-color-page #eee 对齐) */
|
||||
function syncWailsNativeChrome(effective: 'light' | 'dark') {
|
||||
const bg = effective === 'dark' ? '#181818' : '#eeeeee'
|
||||
document.documentElement.style.background = bg
|
||||
document.documentElement.style.minHeight = '100%'
|
||||
document.documentElement.style.colorScheme = effective === 'dark' ? 'dark' : 'light'
|
||||
if (document.body) {
|
||||
document.body.style.background = bg
|
||||
document.body.style.minHeight = '100%'
|
||||
}
|
||||
const appEl = document.getElementById('app')
|
||||
if (appEl) {
|
||||
appEl.style.background = bg
|
||||
appEl.style.minHeight = '100%'
|
||||
}
|
||||
const w = (window as unknown as {
|
||||
runtime?: {
|
||||
WindowSetDarkTheme?: () => void
|
||||
WindowSetLightTheme?: () => void
|
||||
WindowSetBackgroundColour?: (r: number, g: number, b: number, a: number) => void
|
||||
}
|
||||
}).runtime
|
||||
if (!w?.WindowSetBackgroundColour) return
|
||||
try {
|
||||
if (effective === 'dark') {
|
||||
w.WindowSetDarkTheme?.()
|
||||
w.WindowSetBackgroundColour(24, 24, 24, 255)
|
||||
} else {
|
||||
w.WindowSetLightTheme?.()
|
||||
w.WindowSetBackgroundColour(238, 238, 238, 255)
|
||||
}
|
||||
} catch {
|
||||
/* 非桌面壳或未注入 runtime */
|
||||
}
|
||||
}
|
||||
|
||||
function applyTheme(mode: ThemeMode) {
|
||||
const effective = mode === 'system' ? getSystemTheme() : mode
|
||||
document.documentElement.setAttribute('theme-mode', effective)
|
||||
syncWailsNativeChrome(effective)
|
||||
}
|
||||
|
||||
export function useTheme() {
|
||||
|
|
|
|||
|
|
@ -103,15 +103,17 @@ export default {
|
|||
noValidFilesSelected: 'All selected files are unsupported',
|
||||
hiddenFilesFiltered: 'Filtered {count} hidden files',
|
||||
imagesFilteredNoVLM: 'Filtered {count} image files (VLM not enabled)',
|
||||
videosFilteredNoVLM: 'Filtered {count} video files (VLM not enabled)',
|
||||
audiosFilteredNoASR: 'Filtered {count} audio files (ASR not enabled)',
|
||||
invalidFilesFiltered: 'Filtered {count} unsupported files',
|
||||
unsupportedFileType: 'Unsupported file type',
|
||||
unsupportedTypesHint: 'Some document types ({types}) have no available parser engine and cannot be processed',
|
||||
goToParserSettings: 'Configure',
|
||||
failedFilesList: 'Failed files:',
|
||||
failedFilesList: 'Failed files:',
|
||||
andMoreFiles: '...and {count} more files',
|
||||
duplicateFilesSkipped: '{count} duplicate files skipped',
|
||||
uploadFile: 'Upload File',
|
||||
uploadFileDesc: 'Supports PDF, Word, TXT, etc.',
|
||||
uploadFileDesc: 'Supports PDF, Word, TXT, images, videos, audio, etc.',
|
||||
importURL: 'Import from URL',
|
||||
addDocument: 'Add Document',
|
||||
importURLDesc: 'Import via URL link',
|
||||
|
|
@ -567,6 +569,8 @@ export default {
|
|||
webSearchConfig: 'Web Search',
|
||||
enableMemory: 'Enable Memory',
|
||||
enableMemoryDesc: 'When enabled, the system will record your conversation history and automatically recall relevant content in future conversations to provide more personalized answers.',
|
||||
autoCheckUpdate: 'Auto Download Updates',
|
||||
autoCheckUpdateDesc: 'When enabled, automatically check and download the latest version in the background.',
|
||||
memoryRequiresNeo4j: 'Memory feature requires Neo4j graph database. Please configure and enable Neo4j (set NEO4J_ENABLE=true) before enabling this feature.',
|
||||
memoryHowToEnable: 'View Neo4j Configuration Guide',
|
||||
parserEngine: 'Parser Engine',
|
||||
|
|
@ -655,6 +659,7 @@ export default {
|
|||
engineLocal: 'Local',
|
||||
engineCos: 'Tencent Cloud COS',
|
||||
engineTos: 'Volcengine TOS',
|
||||
engineOss: 'Alibaba Cloud OSS',
|
||||
engineS3: 'AWS S3',
|
||||
localTitle: 'Local Storage',
|
||||
localDesc: 'Store files on the server local filesystem, suitable for single-node deployment only.',
|
||||
|
|
@ -688,6 +693,10 @@ export default {
|
|||
s3Desc: 'AWS S3 and S3-compatible object storage services, suitable for public cloud deployment.',
|
||||
s3AccessKeyPlaceholder: 'AWS Access Key',
|
||||
s3SecretKeyPlaceholder: 'AWS Secret Key',
|
||||
ossTitle: 'Alibaba Cloud OSS',
|
||||
ossDesc: 'Alibaba Cloud Object Storage Service (OSS), suitable for public cloud deployment.',
|
||||
ossAccessKeyPlaceholder: 'Alibaba Cloud Access Key',
|
||||
ossSecretKeyPlaceholder: 'Alibaba Cloud Secret Key',
|
||||
console: 'Console',
|
||||
docs: 'Docs',
|
||||
testConnection: 'Test Connection',
|
||||
|
|
@ -699,6 +708,7 @@ export default {
|
|||
requestFailed: 'Request failed',
|
||||
cos: 'Tencent Cloud COS',
|
||||
tos: 'Volcengine TOS',
|
||||
oss: 'Alibaba Cloud OSS',
|
||||
},
|
||||
},
|
||||
webSearchSettings: {
|
||||
|
|
@ -1159,7 +1169,11 @@ export default {
|
|||
reset: 'Reset',
|
||||
clear: 'Clear',
|
||||
website: 'Official Website',
|
||||
chromeExtension: 'Chrome extension',
|
||||
clawhubSkill: 'Claw Skill',
|
||||
newBadge: 'New',
|
||||
github: 'GitHub',
|
||||
githubStarTip: 'Open the repo on GitHub — star it if you find it useful',
|
||||
on: 'On',
|
||||
off: 'Off',
|
||||
resetToDefault: 'Reset to default',
|
||||
|
|
@ -1175,6 +1189,8 @@ export default {
|
|||
defaultUser: 'User',
|
||||
copyFailed: 'Copy failed',
|
||||
retry: 'Retry',
|
||||
expand: 'Expand',
|
||||
collapse: 'Collapse',
|
||||
},
|
||||
mentionDetail: {
|
||||
readOnlyFromAgent: 'Read-only in this conversation; not shown in Knowledge Base list',
|
||||
|
|
@ -1958,6 +1974,10 @@ export default {
|
|||
description: 'View and manage your API key',
|
||||
keyLabel: 'API Key',
|
||||
keyDescription: 'Secret used for API requests. Keep it safe.',
|
||||
urlLabel: 'API URL',
|
||||
urlDescription: 'Base path for REST API requests; append the specific endpoint when calling.',
|
||||
copyUrlTitle: 'Copy API URL',
|
||||
urlCopySuccess: 'API URL copied to clipboard',
|
||||
copyTitle: 'Copy API Key',
|
||||
docLabel: 'API Documentation',
|
||||
docDescription: 'View complete API documentation and examples,',
|
||||
|
|
@ -1973,7 +1993,26 @@ export default {
|
|||
createdAtDescription: 'Time when the account was created',
|
||||
noKey: 'No API Key available',
|
||||
copySuccess: 'API Key copied to clipboard',
|
||||
copyFailed: 'Copy failed, please copy manually'
|
||||
copyFailed: 'Copy failed, please copy manually',
|
||||
desktopPortLabel: 'Local API port (desktop)',
|
||||
desktopPortDescription:
|
||||
'Use a fixed port (e.g. 37841) so tools like the Chrome extension can keep the same API URL. 0 means a random port each launch. Restart the app after saving.',
|
||||
desktopPortSave: 'Save',
|
||||
desktopPortSaved: 'Saved. Restart the app for it to take effect.',
|
||||
desktopPortSaveFailed: 'Save failed',
|
||||
desktopPortInvalid: 'Enter a port between 0 and 65535',
|
||||
desktopBindPublicLabel: 'Allow LAN access to the API',
|
||||
desktopBindPublicDescription:
|
||||
'When enabled, the embedded server listens on 0.0.0.0 so other devices on your LAN can reach the API via the address below. This increases exposure—use host firewalls and routing rules as needed. Restart the app after changing this.',
|
||||
desktopBindPublicSaved: 'Saved. Restart the app for it to take effect.',
|
||||
desktopBindPublicSaveFailed: 'Save failed',
|
||||
lanUrlLabel: 'LAN API base URL',
|
||||
lanUrlDescription:
|
||||
'Shown after “Allow LAN access” is on and the app has restarted. If the IP is wrong, replace the host with your machine’s IPv4 from system network settings.',
|
||||
lanUrlCopyTitle: 'Copy LAN API URL',
|
||||
lanUrlCopySuccess: 'LAN API URL copied',
|
||||
lanUrlUnavailable:
|
||||
'The API is listening on all interfaces, but no LAN IPv4 could be detected automatically. Find your IPv4 in network settings and build http://YOUR_IP:PORT/api/v1 manually.',
|
||||
}
|
||||
},
|
||||
system: {
|
||||
|
|
@ -2153,6 +2192,10 @@ export default {
|
|||
label: 'OpenAI',
|
||||
description: 'gpt-5.2, gpt-5-mini, etc.',
|
||||
},
|
||||
azure_openai: {
|
||||
label: 'Azure OpenAI',
|
||||
description: 'OpenAI service hosted on Microsoft Azure',
|
||||
},
|
||||
aliyun: {
|
||||
label: 'Aliyun DashScope',
|
||||
description: 'qwen-plus, tongyi-embedding-vision-plus, qwen3-rerank, etc.',
|
||||
|
|
@ -3085,6 +3128,8 @@ export default {
|
|||
engineTosDesc: 'Volcengine object storage, for public cloud deployment',
|
||||
engineS3: 'AWS S3',
|
||||
engineS3Desc: 'AWS S3 and compatible storage, for public cloud deployment',
|
||||
engineOss: 'Alibaba Cloud OSS',
|
||||
engineOssDesc: 'Alibaba Cloud Object Storage Service, for public cloud deployment',
|
||||
},
|
||||
parser: {
|
||||
title: 'Parser Engine',
|
||||
|
|
@ -3282,12 +3327,14 @@ export default {
|
|||
},
|
||||
im: {
|
||||
title: 'IM Integration',
|
||||
description: 'Connect agent to instant messaging platforms like WeCom, Feishu, Slack, Telegram, DingTalk, and Mattermost',
|
||||
description: 'Connect agent to instant messaging platforms like WeCom, Feishu, Slack, Telegram, DingTalk, Mattermost and WeChat',
|
||||
feishu: 'Feishu',
|
||||
slack: 'Slack',
|
||||
telegram: 'Telegram',
|
||||
dingtalk: 'DingTalk',
|
||||
mattermost: 'Mattermost',
|
||||
wecom: 'WeCom',
|
||||
wechat: 'WeChat',
|
||||
addChannel: 'Add Channel',
|
||||
editChannel: 'Edit Channel',
|
||||
deleteConfirm: 'Are you sure you want to delete this channel? This action cannot be undone.',
|
||||
|
|
@ -3315,6 +3362,8 @@ export default {
|
|||
'When on, bot replies are new top-level posts in the channel. When off (default), they stay in the thread and the main view only shows “N replies”.',
|
||||
modeHint: 'WebSocket is recommended for easier setup',
|
||||
consoleTip: 'to get credentials',
|
||||
wecomWSEndpointHint: 'Optional. For private WeCom deployments, enter a custom WebSocket address. Leave empty to use the default public cloud endpoint. For internal network addresses, add the hostname to the SSRF_WHITELIST env var.',
|
||||
wecomAPIBaseURLHint: 'Optional. For private WeCom deployments, enter a custom API base URL. Leave empty to use the default public cloud endpoint. For internal network addresses, add the hostname to the SSRF_WHITELIST env var.',
|
||||
fileKnowledgeBase: 'File Storage Knowledge Base',
|
||||
fileKnowledgeBasePlaceholder: 'Select a knowledge base (optional)',
|
||||
fileKnowledgeBaseHint: 'When configured, files sent by users will be automatically saved to this knowledge base',
|
||||
|
|
@ -3322,6 +3371,13 @@ export default {
|
|||
sessionModeUser: 'Per User (default)',
|
||||
sessionModeThread: 'Per Thread',
|
||||
sessionModeHint: 'User mode: each person has their own conversation. Use /clear to start fresh. Thread mode: each message thread is a separate conversation. Multiple people can collaborate in the same thread.',
|
||||
wechatScanBind: 'Scan to bind WeChat',
|
||||
wechatScanning: 'Scan the QR code with WeChat',
|
||||
wechatBindSuccess: 'WeChat bound successfully',
|
||||
wechatRebind: 'Rebind',
|
||||
wechatHint: 'Requires iOS WeChat 8.0.70+, direct messages only',
|
||||
wechatQRExpired: 'QR code expired, please try again',
|
||||
wechatBinding: 'Binding...',
|
||||
},
|
||||
mcp: {
|
||||
label: 'MCP Services',
|
||||
|
|
@ -3464,11 +3520,15 @@ export default {
|
|||
untitled: 'Untitled',
|
||||
resourceLoadFailed: 'Failed to load resources',
|
||||
noResources: 'No wiki spaces found',
|
||||
noResourcesDesc: 'The app needs wiki access via a group chat to fetch content',
|
||||
noResourcesDesc: 'The app needs wiki access via a group chat to fetch content',
|
||||
noResourcesDesc_notion: 'The app needs Notion page access permissions to fetch content',
|
||||
retryLoadResources: 'Retry',
|
||||
guideStep1: 'Create a group chat in Feishu, then add your app as a bot in the group settings',
|
||||
guideStep2: 'Open wiki "Settings" > "Member Settings" > "Add Member", search for the group chat and add it',
|
||||
guideStep3: 'Ensure the group chat role is at least "Can Read", then come back and click Retry',
|
||||
guideStep1_notion: 'Open the page or database you want to sync in Notion',
|
||||
guideStep2_notion: 'Click the "···" menu at the top right, select "Connect to" or "Add connections"',
|
||||
guideStep3_notion: 'Search and select your Integration app, then come back and click Retry',
|
||||
permissionDocLink: 'View Feishu wiki permission docs',
|
||||
syncScheduleLabel: 'Sync schedule',
|
||||
conflictLabel: 'Conflict strategy',
|
||||
|
|
|
|||
|
|
@ -102,6 +102,8 @@ export default {
|
|||
noValidFilesSelected: "선택한 파일 모두 지원되지 않음",
|
||||
hiddenFilesFiltered: "{count}개 숨김 파일 필터링됨",
|
||||
imagesFilteredNoVLM: "{count}개 이미지 파일 필터링됨(VLM 미활성화)",
|
||||
videosFilteredNoVLM: "{count}개 동영상 파일 필터링됨(VLM 미활성화)",
|
||||
audiosFilteredNoASR: "{count}개 오디오 파일 필터링됨(ASR 미활성화)",
|
||||
invalidFilesFiltered: "{count}개 지원되지 않는 파일 필터링됨",
|
||||
unsupportedFileType: "지원되지 않는 파일 형식",
|
||||
unsupportedTypesHint: "일부 문서 유형({types})에 사용 가능한 파서 엔진이 없어 처리할 수 없습니다",
|
||||
|
|
@ -110,7 +112,7 @@ export default {
|
|||
andMoreFiles: "...외 {count}개 파일",
|
||||
duplicateFilesSkipped: "{count}개 중복 파일 무시됨",
|
||||
uploadFile: "파일 업로드",
|
||||
uploadFileDesc: "PDF, Word, TXT 등 지원",
|
||||
uploadFileDesc: "PDF, Word, TXT, 이미지, 동영상, 오디오 등 지원",
|
||||
importURL: "웹페이지 가져오기",
|
||||
addDocument: "문서 추가",
|
||||
importURLDesc: "URL 링크로 가져오기",
|
||||
|
|
@ -429,6 +431,8 @@ export default {
|
|||
webSearchConfig: "웹 검색",
|
||||
enableMemory: "기억 기능 활성화",
|
||||
enableMemoryDesc: "활성화하면 시스템이 대화 기록을 저장하고 향후 대화에서 관련 내용을 자동으로 회상하여 더 개인화된 답변을 제공합니다.",
|
||||
autoCheckUpdate: '업데이트 자동 다운로드',
|
||||
autoCheckUpdateDesc: '활성화하면 시작 시 최신 버전을 자동으로 확인하고 백그라운드에서 다운로드합니다.',
|
||||
memoryRequiresNeo4j: "기억 기능은 Neo4j 그래프 데이터베이스가 필요합니다. 이 기능을 활성화하기 전에 Neo4j를 구성하고 활성화해 주세요 (NEO4J_ENABLE=true 설정).",
|
||||
memoryHowToEnable: "Neo4j 구성 가이드 보기",
|
||||
parserEngine: "파싱 엔진",
|
||||
|
|
@ -517,6 +521,7 @@ export default {
|
|||
engineLocal: 'Local(로컬)',
|
||||
engineCos: 'Tencent Cloud COS',
|
||||
engineTos: 'Volcengine TOS',
|
||||
engineOss: 'Alibaba Cloud OSS',
|
||||
engineS3: 'AWS S3',
|
||||
localTitle: 'Local(로컬 스토리지)',
|
||||
localDesc: '서버 로컬 파일시스템에 파일을 저장합니다. 단일 노드 배포에만 적합합니다.',
|
||||
|
|
@ -550,6 +555,10 @@ export default {
|
|||
s3Desc: 'AWS S3 및 호환 오브젝트 스토리지 서비스, 퍼블릭 클라우드 배포에 적합합니다.',
|
||||
s3AccessKeyPlaceholder: 'AWS Access Key',
|
||||
s3SecretKeyPlaceholder: 'AWS Secret Key',
|
||||
ossTitle: 'Alibaba Cloud OSS',
|
||||
ossDesc: 'Alibaba Cloud 오브젝트 스토리지 서비스(OSS), 퍼블릭 클라우드 배포에 적합합니다.',
|
||||
ossAccessKeyPlaceholder: 'Alibaba Cloud Access Key',
|
||||
ossSecretKeyPlaceholder: 'Alibaba Cloud Secret Key',
|
||||
console: '콘솔',
|
||||
docs: '문서',
|
||||
testConnection: '연결 테스트',
|
||||
|
|
@ -561,6 +570,7 @@ export default {
|
|||
requestFailed: '요청 실패',
|
||||
cos: 'Tencent Cloud COS',
|
||||
tos: 'Volcengine TOS',
|
||||
oss: 'Alibaba Cloud OSS',
|
||||
},
|
||||
},
|
||||
webSearchSettings: {
|
||||
|
|
@ -1007,7 +1017,11 @@ export default {
|
|||
reset: "초기화",
|
||||
clear: "지우기",
|
||||
website: "공식 웹사이트",
|
||||
chromeExtension: 'Chrome 확장 프로그램',
|
||||
clawhubSkill: 'Claw Skill',
|
||||
newBadge: 'New',
|
||||
github: 'GitHub',
|
||||
githubStarTip: 'GitHub에서 저장소로 이동합니다. 유용하다면 Star를 부탁드립니다',
|
||||
on: "켜기",
|
||||
off: "끄기",
|
||||
resetToDefault: "기본값 복원",
|
||||
|
|
@ -1023,6 +1037,8 @@ export default {
|
|||
defaultUser: "사용자",
|
||||
copyFailed: "복사 실패",
|
||||
retry: "재시도",
|
||||
expand: "펼치기",
|
||||
collapse: "접기",
|
||||
},
|
||||
mentionDetail: {
|
||||
faqCount: "Q&A {count}개",
|
||||
|
|
@ -1406,6 +1422,10 @@ export default {
|
|||
description: "API 키 보기 및 관리",
|
||||
keyLabel: "API 키",
|
||||
keyDescription: "API 호출에 사용되는 키, 안전하게 보관하세요",
|
||||
urlLabel: "API URL",
|
||||
urlDescription: "REST API 기본 경로입니다. 호출 시 구체적인 엔드포인트 경로를 이어서 사용하세요.",
|
||||
copyUrlTitle: "API URL 복사",
|
||||
urlCopySuccess: "API URL이 클립보드에 복사되었습니다",
|
||||
copyTitle: "API 키 복사",
|
||||
docLabel: "API 문서",
|
||||
docDescription: "전체 API 호출 문서 및 예시 보기, ",
|
||||
|
|
@ -1422,8 +1442,28 @@ export default {
|
|||
noKey: "API 키 없음",
|
||||
copySuccess: "API 키가 클립보드에 복사되었습니다",
|
||||
copyFailed: "복사 실패, 수동으로 복사해주세요",
|
||||
desktopPortLabel: "로컬 API 포트 (데스크톱)",
|
||||
desktopPortDescription:
|
||||
"Chrome 확장 프로그램 등에서 동일한 API 주소를 쓰려면 고정 포트(예: 37841)를 지정하세요. 0이면 매번 다른 포트입니다. 저장 후 앱을 다시 시작하세요.",
|
||||
desktopPortSave: "저장",
|
||||
desktopPortSaved: "저장되었습니다. 적용하려면 앱을 다시 시작하세요.",
|
||||
desktopPortSaveFailed: "저장 실패",
|
||||
desktopPortInvalid: "0~65535 사이의 포트를 입력하세요",
|
||||
desktopBindPublicLabel: "Allow LAN access to the API",
|
||||
desktopBindPublicDescription:
|
||||
"When enabled, the embedded server listens on 0.0.0.0 so other devices on your LAN can reach the API via the address below. This increases exposure—use host firewalls and routing rules as needed. Restart the app after changing this.",
|
||||
desktopBindPublicSaved: "Saved. Restart the app for it to take effect.",
|
||||
desktopBindPublicSaveFailed: "Save failed",
|
||||
lanUrlLabel: "LAN API base URL",
|
||||
lanUrlDescription:
|
||||
"Shown after \"Allow LAN access\" is on and the app has restarted. If the IP is wrong, replace the host with your machine IPv4 from system network settings.",
|
||||
lanUrlCopyTitle: "Copy LAN API URL",
|
||||
lanUrlCopySuccess: "LAN API URL copied",
|
||||
lanUrlUnavailable:
|
||||
"The API is listening on all interfaces, but no LAN IPv4 could be detected automatically. Find your IPv4 in network settings and build http://YOUR_IP:PORT/api/v1 manually.",
|
||||
},
|
||||
},
|
||||
|
||||
system: {
|
||||
title: "시스템 정보",
|
||||
sectionDescription: "시스템 버전 정보 및 사용자 계정 설정 보기",
|
||||
|
|
@ -1603,6 +1643,10 @@ export default {
|
|||
label: "OpenAI",
|
||||
description: "gpt-5.2, gpt-5-mini 등",
|
||||
},
|
||||
azure_openai: {
|
||||
label: 'Azure OpenAI',
|
||||
description: 'Microsoft Azure에서 호스팅되는 OpenAI 서비스',
|
||||
},
|
||||
aliyun: {
|
||||
label: "Aliyun DashScope",
|
||||
description: "qwen-plus, tongyi-embedding-vision-plus, qwen3-rerank 등",
|
||||
|
|
@ -3139,6 +3183,8 @@ export default {
|
|||
engineTosDesc: 'Volcengine 오브젝트 스토리지, 퍼블릭 클라우드 배포에 적합',
|
||||
engineS3: 'AWS S3',
|
||||
engineS3Desc: 'AWS S3 및 호환 스토리지, 퍼블릭 클라우드 배포에 적합',
|
||||
engineOss: 'Alibaba Cloud OSS',
|
||||
engineOssDesc: 'Alibaba Cloud 오브젝트 스토리지, 퍼블릭 클라우드 배포에 적합',
|
||||
},
|
||||
parser: {
|
||||
title: '파서 엔진',
|
||||
|
|
@ -3343,6 +3389,8 @@ export default {
|
|||
"켜면 봇 답변이 채널의 새 최상위 게시물로 올라갑니다. 끄면(기본) 스레드 답변이며 메인 화면에는 「N개 답변」만 보입니다.",
|
||||
modeHint: "WebSocket 방식이 설정이 더 간편하여 권장됩니다",
|
||||
consoleTip: "자격 증명 정보를 가져오세요",
|
||||
wecomWSEndpointHint: "선택 사항. 프라이빗 WeCom 배포 시 사용자 정의 WebSocket 주소를 입력하세요. 비워두면 기본 퍼블릭 클라우드 주소를 사용합니다. 내부 네트워크 주소의 경우 SSRF_WHITELIST 환경 변수에 호스트명을 추가하세요.",
|
||||
wecomAPIBaseURLHint: "선택 사항. 프라이빗 WeCom 배포 시 사용자 정의 API 기본 URL을 입력하세요. 비워두면 기본 퍼블릭 클라우드 주소를 사용합니다. 내부 네트워크 주소의 경우 SSRF_WHITELIST 환경 변수에 호스트명을 추가하세요.",
|
||||
fileKnowledgeBase: "파일 저장 지식 베이스",
|
||||
fileKnowledgeBasePlaceholder: "지식 베이스 선택 (선택 사항)",
|
||||
fileKnowledgeBaseHint: "설정 시 사용자가 보낸 파일이 자동으로 해당 지식 베이스에 저장됩니다",
|
||||
|
|
@ -3516,11 +3564,15 @@ export default {
|
|||
untitled: "제목 없음",
|
||||
resourceLoadFailed: "리소스 목록 로드 실패",
|
||||
noResources: "동기화 가능한 위키 공간을 찾을 수 없습니다",
|
||||
noResourcesHint: "먼저 데이터 소스를 저장하고 권한 설정을 확인하세요",
|
||||
permissionHint: "앱이 위키 공간의 멤버로 추가되어야 콘텐츠에 접근할 수 있습니다:",
|
||||
permissionStep1: "페이슈를 열고 동기화할 위키 공간으로 이동",
|
||||
permissionStep2: "오른쪽 상단 '...' > '설정' > '멤버 관리' 클릭",
|
||||
permissionStep3: "페이슈 앱을 검색하여 위키 공간 멤버로 추가",
|
||||
noResourcesDesc: "앱이 콘텐츠를 가져오려면 그룹 채팅을 통해 위키 접근 권한을 얻어야 합니다",
|
||||
noResourcesDesc_notion: "앱이 콘텐츠를 가져오려면 Notion 페이지 접근 권한이 필요합니다",
|
||||
retryLoadResources: "다시 시도",
|
||||
guideStep1: "Feishu에서 그룹 채팅을 만들고 그룹 설정의 '그룹 봇'에 앱을 추가하세요",
|
||||
guideStep2: "위키 '설정' > '멤버 설정' > '멤버 추가'를 열고 해당 그룹 채팅을 검색하여 추가하세요",
|
||||
guideStep3: "그룹 채팅 역할이 최소 '읽기 가능'인지 확인한 후, 돌아와서 다시 시도를 클릭하세요",
|
||||
guideStep1_notion: "Notion에서 동기화하려는 페이지나 데이터베이스를 엽니다",
|
||||
guideStep2_notion: "오른쪽 상단의 '···' 메뉴를 클릭하고 'Connect to' 또는 'Add connections'를 선택합니다",
|
||||
guideStep3_notion: "Integration 앱을 검색하여 선택한 후, 돌아와서 다시 시도를 클릭하세요",
|
||||
permissionDocLink: "페이슈 위키 권한 설정 문서 보기",
|
||||
syncScheduleLabel: "동기화 주기",
|
||||
conflictLabel: "충돌 전략",
|
||||
|
|
|
|||
|
|
@ -85,6 +85,8 @@ export default {
|
|||
noValidFilesSelected: 'Все выбранные файлы не поддерживаются',
|
||||
hiddenFilesFiltered: 'Отфильтровано {count} скрытых файлов',
|
||||
imagesFilteredNoVLM: 'Отфильтровано {count} изображений (VLM не включен)',
|
||||
videosFilteredNoVLM: 'Отфильтровано {count} видеофайлов (VLM не включен)',
|
||||
audiosFilteredNoASR: 'Отфильтровано {count} аудиофайлов (ASR не включен)',
|
||||
invalidFilesFiltered: 'Отфильтровано {count} неподдерживаемых файлов',
|
||||
unsupportedFileType: 'Неподдерживаемый тип файла',
|
||||
unsupportedTypesHint: 'Некоторые типы документов ({types}) не имеют доступного парсера и не могут быть обработаны',
|
||||
|
|
@ -93,7 +95,7 @@ export default {
|
|||
andMoreFiles: '...и ещё {count} файлов',
|
||||
duplicateFilesSkipped: 'Пропущено {count} повторяющихся файлов',
|
||||
uploadFile: 'Загрузить файл',
|
||||
uploadFileDesc: 'Поддерживает PDF, Word, TXT и т.д.',
|
||||
uploadFileDesc: 'Поддерживает PDF, Word, TXT, изображения, видео, аудио и т.д.',
|
||||
importURL: 'Импорт из URL',
|
||||
importURLDesc: 'Импорт по ссылке URL',
|
||||
importURLTitle: 'Импорт из URL',
|
||||
|
|
@ -546,6 +548,8 @@ export default {
|
|||
webSearchConfig: 'Сетевой поиск',
|
||||
enableMemory: 'Включить память',
|
||||
enableMemoryDesc: 'При включении система будет записывать историю ваших разговоров и автоматически вспоминать соответствующий контент в будущих беседах для более персонализированных ответов.',
|
||||
autoCheckUpdate: 'Автоматическая загрузка обновлений',
|
||||
autoCheckUpdateDesc: 'При включении автоматически проверять и скачивать последнюю версию в фоновом режиме при запуске.',
|
||||
memoryRequiresNeo4j: 'Функция памяти требует графовую базу данных Neo4j. Пожалуйста, настройте и включите Neo4j (установите NEO4J_ENABLE=true) перед активацией этой функции.',
|
||||
memoryHowToEnable: 'Руководство по настройке Neo4j',
|
||||
parserEngine: 'Движок парсинга',
|
||||
|
|
@ -636,6 +640,7 @@ export default {
|
|||
engineLocal: 'Локальное',
|
||||
engineCos: 'Tencent Cloud COS',
|
||||
engineTos: 'Volcengine TOS',
|
||||
engineOss: 'Alibaba Cloud OSS',
|
||||
engineS3: 'AWS S3',
|
||||
localTitle: 'Локальное хранилище',
|
||||
localDesc: 'Хранение файлов в локальной файловой системе сервера. Подходит только для однонодового развёртывания.',
|
||||
|
|
@ -669,6 +674,10 @@ export default {
|
|||
s3Desc: 'AWS S3 и совместимые сервисы объектного хранилища для публичного облака.',
|
||||
s3AccessKeyPlaceholder: 'AWS Access Key',
|
||||
s3SecretKeyPlaceholder: 'AWS Secret Key',
|
||||
ossTitle: 'Alibaba Cloud OSS',
|
||||
ossDesc: 'Объектное хранилище Alibaba Cloud (OSS), подходит для публичного облака.',
|
||||
ossAccessKeyPlaceholder: 'Alibaba Cloud Access Key',
|
||||
ossSecretKeyPlaceholder: 'Alibaba Cloud Secret Key',
|
||||
console: 'Консоль',
|
||||
docs: 'Документация',
|
||||
testConnection: 'Тест подключения',
|
||||
|
|
@ -679,7 +688,8 @@ export default {
|
|||
unknownError: 'Неизвестная ошибка',
|
||||
requestFailed: 'Ошибка запроса',
|
||||
cos: 'Tencent Cloud COS',
|
||||
tos: 'Volcengine TOS'
|
||||
tos: 'Volcengine TOS',
|
||||
oss: 'Alibaba Cloud OSS',
|
||||
}
|
||||
},
|
||||
webSearchSettings: {
|
||||
|
|
@ -1121,7 +1131,11 @@ export default {
|
|||
reset: 'Сбросить',
|
||||
clear: 'Очистить',
|
||||
website: 'Официальный сайт',
|
||||
chromeExtension: 'Расширение Chrome',
|
||||
clawhubSkill: 'Claw Skill',
|
||||
newBadge: 'New',
|
||||
github: 'GitHub',
|
||||
githubStarTip: 'Открыть репозиторий на GitHub — поставьте Star, если проект полезен',
|
||||
on: 'Вкл',
|
||||
off: 'Выкл',
|
||||
resetToDefault: 'Сбросить по умолчанию',
|
||||
|
|
@ -1137,6 +1151,8 @@ export default {
|
|||
defaultUser: 'Пользователь',
|
||||
copyFailed: 'Ошибка копирования',
|
||||
retry: 'Повторить',
|
||||
expand: 'Развернуть',
|
||||
collapse: 'Свернуть',
|
||||
me: 'Я',
|
||||
copy: 'Копировать',
|
||||
copied: 'Скопировано'
|
||||
|
|
@ -1248,6 +1264,10 @@ export default {
|
|||
description: 'Просматривайте и управляйте своим API-ключом',
|
||||
keyLabel: 'API Key',
|
||||
keyDescription: 'Ключ для API-запросов. Храните его в безопасности.',
|
||||
urlLabel: 'URL API',
|
||||
urlDescription: 'Базовый путь REST API; при вызове добавляйте конкретный путь эндпоинта.',
|
||||
copyUrlTitle: 'Скопировать URL API',
|
||||
urlCopySuccess: 'URL API скопирован в буфер обмена',
|
||||
copyTitle: 'Скопировать API Key',
|
||||
docLabel: 'Документация API',
|
||||
docDescription: 'Ознакомьтесь с полной документацией и примерами API,',
|
||||
|
|
@ -1263,7 +1283,26 @@ export default {
|
|||
createdAtDescription: 'Время создания учётной записи',
|
||||
noKey: 'API Key отсутствует',
|
||||
copySuccess: 'API Key скопирован в буфер обмена',
|
||||
copyFailed: 'Не удалось скопировать, пожалуйста, сделайте это вручную'
|
||||
copyFailed: 'Не удалось скопировать, пожалуйста, сделайте это вручную',
|
||||
desktopPortLabel: 'Локальный порт API (desktop)',
|
||||
desktopPortDescription:
|
||||
'Укажите фиксированный порт (например, 37841), чтобы расширение Chrome и другие инструменты всегда использовали один URL API. 0 — случайный порт при каждом запуске. После сохранения перезапустите приложение.',
|
||||
desktopPortSave: 'Сохранить',
|
||||
desktopPortSaved: 'Сохранено. Перезапустите приложение, чтобы применить.',
|
||||
desktopPortSaveFailed: 'Не удалось сохранить',
|
||||
desktopPortInvalid: 'Введите порт от 0 до 65535',
|
||||
desktopBindPublicLabel: 'Разрешить доступ к API в LAN',
|
||||
desktopBindPublicDescription:
|
||||
'Встроенный сервер слушает 0.0.0.0 — другие устройства в локальной сети смогут обращаться к API по адресу ниже. Риски доступа выше; настройте брандмауэр и маршрутизацию. После изменения перезапустите приложение.',
|
||||
desktopBindPublicSaved: 'Сохранено. Перезапустите приложение, чтобы применить.',
|
||||
desktopBindPublicSaveFailed: 'Не удалось сохранить',
|
||||
lanUrlLabel: 'Базовый URL API для LAN',
|
||||
lanUrlDescription:
|
||||
'Отображается после включения доступа в LAN и перезапуска. Если IP неверный, подставьте IPv4 из сетевых настроек системы.',
|
||||
lanUrlCopyTitle: 'Копировать LAN URL API',
|
||||
lanUrlCopySuccess: 'LAN URL API скопирован',
|
||||
lanUrlUnavailable:
|
||||
'API слушает все интерфейсы, но LAN IPv4 не удалось определить автоматически. Узнайте IPv4 в настройках сети и соберите http://ВАШ_IP:ПОРТ/api/v1 вручную.',
|
||||
}
|
||||
},
|
||||
system: {
|
||||
|
|
@ -1442,6 +1481,10 @@ export default {
|
|||
label: 'OpenAI',
|
||||
description: 'gpt-5.2, gpt-5-mini, etc.'
|
||||
},
|
||||
azure_openai: {
|
||||
label: 'Azure OpenAI',
|
||||
description: 'Сервис OpenAI на платформе Microsoft Azure',
|
||||
},
|
||||
aliyun: {
|
||||
label: 'Aliyun DashScope',
|
||||
description: 'qwen-plus, tongyi-embedding-vision-plus, qwen3-rerank, etc.'
|
||||
|
|
@ -2755,6 +2798,8 @@ export default {
|
|||
engineTosDesc: 'Объектное хранилище Volcengine, для публичного облака',
|
||||
engineS3: 'AWS S3',
|
||||
engineS3Desc: 'AWS S3 и совместимые хранилища, для публичного облака',
|
||||
engineOss: 'Alibaba Cloud OSS',
|
||||
engineOssDesc: 'Объектное хранилище Alibaba Cloud, для публичного облака',
|
||||
},
|
||||
parser: {
|
||||
title: 'Парсер',
|
||||
|
|
@ -2982,6 +3027,8 @@ export default {
|
|||
'Включено — ответы бота как новые сообщения в канале. Выключено (по умолчанию) — ответы в ветке, в основном окне только «N ответов».',
|
||||
modeHint: 'Рекомендуется WebSocket — проще настроить',
|
||||
consoleTip: 'для получения учётных данных',
|
||||
wecomWSEndpointHint: 'Необязательно. Для приватного развёртывания WeCom укажите пользовательский адрес WebSocket. Оставьте пустым для публичного облака. Для адресов внутренней сети добавьте имя хоста в переменную SSRF_WHITELIST.',
|
||||
wecomAPIBaseURLHint: 'Необязательно. Для приватного развёртывания WeCom укажите пользовательский базовый URL API. Оставьте пустым для публичного облака. Для адресов внутренней сети добавьте имя хоста в переменную SSRF_WHITELIST.',
|
||||
fileKnowledgeBase: 'База знаний для файлов',
|
||||
fileKnowledgeBasePlaceholder: 'Выберите базу знаний (необязательно)',
|
||||
fileKnowledgeBaseHint: 'При настройке файлы, отправленные пользователями, автоматически сохраняются в эту базу знаний',
|
||||
|
|
@ -3423,11 +3470,15 @@ export default {
|
|||
untitled: 'Без названия',
|
||||
resourceLoadFailed: 'Не удалось загрузить список ресурсов',
|
||||
noResources: 'Пространства вики не найдены',
|
||||
noResourcesHint: 'Сначала сохраните источник данных и проверьте права доступа',
|
||||
permissionHint: 'Приложение должно быть добавлено как участник пространства вики для доступа к контенту:',
|
||||
permissionStep1: 'Откройте Feishu и перейдите в пространство вики для синхронизации',
|
||||
permissionStep2: 'Нажмите "..." > "Настройки" > "Управление участниками"',
|
||||
permissionStep3: 'Найдите и добавьте приложение Feishu как участника пространства',
|
||||
noResourcesDesc: 'Приложению требуется доступ к вики через групповой чат для получения контента',
|
||||
noResourcesDesc_notion: 'Приложению требуются права доступа к странице Notion для получения контента',
|
||||
retryLoadResources: 'Повторить',
|
||||
guideStep1: 'Создайте групповой чат в Feishu, затем добавьте ваше приложение как бота в настройках группы',
|
||||
guideStep2: 'Откройте вики "Настройки" > "Управление участниками" > "Добавить участника", найдите групповой чат и добавьте его',
|
||||
guideStep3: 'Убедитесь, что роль группового чата как минимум "Может читать", затем вернитесь и нажмите Повторить',
|
||||
guideStep1_notion: 'Откройте страницу или базу данных, которую хотите синхронизировать в Notion',
|
||||
guideStep2_notion: 'Нажмите меню «···» в правом верхнем углу, выберите «Connect to» или «Add connections»',
|
||||
guideStep3_notion: 'Найдите и выберите ваше интеграционное приложение, затем вернитесь и нажмите Повторить',
|
||||
permissionDocLink: 'Документация по настройке прав доступа',
|
||||
syncScheduleLabel: 'Расписание синхронизации',
|
||||
conflictLabel: 'Стратегия конфликтов',
|
||||
|
|
|
|||
|
|
@ -102,6 +102,8 @@ export default {
|
|||
noValidFilesSelected: "选中的文件均不支持",
|
||||
hiddenFilesFiltered: "已过滤 {count} 个隐藏文件",
|
||||
imagesFilteredNoVLM: "已过滤 {count} 个图片文件(未启用VLM)",
|
||||
videosFilteredNoVLM: "已过滤 {count} 个视频文件(未启用VLM)",
|
||||
audiosFilteredNoASR: "已过滤 {count} 个音频文件(未启用ASR)",
|
||||
invalidFilesFiltered: "已过滤 {count} 个不支持的文件",
|
||||
unsupportedFileType: "不支持的文件格式",
|
||||
unsupportedTypesHint: "部分文档类型({types})暂无可用解析引擎,上传后将无法解析",
|
||||
|
|
@ -110,7 +112,7 @@ export default {
|
|||
andMoreFiles: "...及其他 {count} 个文件",
|
||||
duplicateFilesSkipped: "已忽略 {count} 个重复文件",
|
||||
uploadFile: "上传文件",
|
||||
uploadFileDesc: "支持 PDF、Word、TXT 等",
|
||||
uploadFileDesc: "支持 PDF、Word、TXT、图片、视频、音频等",
|
||||
importURL: "导入网页",
|
||||
addDocument: "添加文档",
|
||||
importURLDesc: "通过URL链接导入",
|
||||
|
|
@ -426,6 +428,8 @@ export default {
|
|||
webSearchConfig: "网络搜索",
|
||||
enableMemory: "开启记忆功能",
|
||||
enableMemoryDesc: "开启后,系统将记录您的对话历史,并在后续对话中自动回忆相关内容,提供更个性化的回答。",
|
||||
autoCheckUpdate: '自动下载更新',
|
||||
autoCheckUpdateDesc: '开启后自动检查并在后台下载最新版本安装包。',
|
||||
memoryRequiresNeo4j: "记忆功能依赖 Neo4j 图数据库,请先配置并启用 Neo4j(设置环境变量 NEO4J_ENABLE=true)后再开启此功能。",
|
||||
memoryHowToEnable: "查看 Neo4j 配置指南",
|
||||
parserEngine: "解析引擎",
|
||||
|
|
@ -514,6 +518,7 @@ export default {
|
|||
engineLocal: "Local(本地)",
|
||||
engineCos: "腾讯云 COS",
|
||||
engineTos: "火山引擎 TOS",
|
||||
engineOss: "阿里云 OSS",
|
||||
engineS3: "AWS S3",
|
||||
localTitle: "Local(本地存储)",
|
||||
localDesc: "使用服务器本地文件系统存储文件,仅适合单机部署。",
|
||||
|
|
@ -547,6 +552,10 @@ export default {
|
|||
s3Desc: "AWS S3 及兼容的对象存储服务,适合公有云部署。",
|
||||
s3AccessKeyPlaceholder: "AWS Access Key",
|
||||
s3SecretKeyPlaceholder: "AWS Secret Key",
|
||||
ossTitle: "阿里云 OSS",
|
||||
ossDesc: "阿里云对象存储服务(OSS),适合公有云部署。",
|
||||
ossAccessKeyPlaceholder: "阿里云 Access Key",
|
||||
ossSecretKeyPlaceholder: "阿里云 Secret Key",
|
||||
console: "控制台",
|
||||
docs: "文档",
|
||||
testConnection: "测试连接",
|
||||
|
|
@ -558,6 +567,7 @@ export default {
|
|||
requestFailed: "请求失败",
|
||||
cos: "腾讯云 COS",
|
||||
tos: "火山引擎 TOS",
|
||||
oss: "阿里云 OSS",
|
||||
},
|
||||
},
|
||||
webSearchSettings: {
|
||||
|
|
@ -1011,7 +1021,11 @@ export default {
|
|||
reset: "重置",
|
||||
clear: "清空",
|
||||
website: "官方网站",
|
||||
chromeExtension: "Chrome 插件",
|
||||
clawhubSkill: "Claw Skill",
|
||||
newBadge: "New",
|
||||
github: 'GitHub',
|
||||
githubStarTip: '在 GitHub 打开仓库,若觉得有用欢迎点个 Star',
|
||||
on: "开启",
|
||||
off: "关闭",
|
||||
resetToDefault: "恢复默认",
|
||||
|
|
@ -1027,6 +1041,8 @@ export default {
|
|||
defaultUser: "用户",
|
||||
copyFailed: "复制失败",
|
||||
retry: "重试",
|
||||
expand: "展开",
|
||||
collapse: "收起",
|
||||
},
|
||||
mentionDetail: {
|
||||
faqCount: "共 {count} 条问答",
|
||||
|
|
@ -1400,6 +1416,10 @@ export default {
|
|||
description: "查看和管理您的 API 密钥",
|
||||
keyLabel: "API Key",
|
||||
keyDescription: "用于 API 调用的密钥,请妥善保管",
|
||||
urlLabel: "API 地址",
|
||||
urlDescription: "REST API 的基础路径,请求时在末尾拼接具体接口路径",
|
||||
copyUrlTitle: "复制 API 地址",
|
||||
urlCopySuccess: "API 地址已复制到剪贴板",
|
||||
copyTitle: "复制 API Key",
|
||||
docLabel: "API 文档",
|
||||
docDescription: "查看完整的 API 调用文档和示例,",
|
||||
|
|
@ -1416,6 +1436,25 @@ export default {
|
|||
noKey: "暂无 API Key",
|
||||
copySuccess: "API Key 已复制到剪贴板",
|
||||
copyFailed: "复制失败,请手动复制",
|
||||
desktopPortLabel: "本地 API 端口(桌面版)",
|
||||
desktopPortDescription:
|
||||
"填写固定端口(如 37841)后,Chrome 扩展等工具可长期使用同一 API 地址;0 表示每次启动随机端口。保存后请重启应用生效。",
|
||||
desktopPortSave: "保存",
|
||||
desktopPortSaved: "已保存,请重启应用后生效",
|
||||
desktopPortSaveFailed: "保存失败",
|
||||
desktopPortInvalid: "请输入 0–65535 之间的端口",
|
||||
desktopBindPublicLabel: "允许局域网访问 API",
|
||||
desktopBindPublicDescription:
|
||||
"开启后内嵌服务监听 0.0.0.0,同一局域网内其他设备可通过下方地址调用 API。存在数据暴露风险,请在防火墙与路由侧自行做好访问控制;修改后需重启应用。",
|
||||
desktopBindPublicSaved: "已保存,请重启应用后生效",
|
||||
desktopBindPublicSaveFailed: "保存失败",
|
||||
lanUrlLabel: "局域网 API 地址",
|
||||
lanUrlDescription:
|
||||
"在已开启「允许局域网访问」且应用已重启后显示;若 IP 不准确,请在本机网络设置中查看实际 IPv4 后替换主机部分。",
|
||||
lanUrlCopyTitle: "复制局域网 API 地址",
|
||||
lanUrlCopySuccess: "局域网 API 地址已复制",
|
||||
lanUrlUnavailable:
|
||||
"当前已监听所有网卡,但未能自动识别本机 IPv4。请在本机网络设置中查看局域网地址,并手动拼接为 http://你的IP:端口/api/v1。",
|
||||
},
|
||||
},
|
||||
system: {
|
||||
|
|
@ -1595,6 +1634,10 @@ export default {
|
|||
label: "OpenAI",
|
||||
description: "gpt-5.2, gpt-5-mini, etc.",
|
||||
},
|
||||
azure_openai: {
|
||||
label: 'Azure OpenAI',
|
||||
description: 'Microsoft Azure 上的 OpenAI 服务',
|
||||
},
|
||||
aliyun: {
|
||||
label: "阿里云 DashScope",
|
||||
description: "qwen-plus, tongyi-embedding-vision-plus, qwen3-rerank, etc.",
|
||||
|
|
@ -3083,6 +3126,8 @@ export default {
|
|||
engineTosDesc: "火山引擎对象存储,适合公有云部署",
|
||||
engineS3: "AWS S3",
|
||||
engineS3Desc: "AWS S3 及兼容存储,适合公有云部署",
|
||||
engineOss: "阿里云 OSS",
|
||||
engineOssDesc: "阿里云对象存储,适合公有云部署",
|
||||
},
|
||||
parser: {
|
||||
title: "解析引擎",
|
||||
|
|
@ -3257,13 +3302,14 @@ export default {
|
|||
},
|
||||
im: {
|
||||
title: "IM 集成",
|
||||
description: "将智能体接入即时通讯平台,支持企业微信、飞书、Slack、Telegram、钉钉和 Mattermost",
|
||||
description: "将智能体接入即时通讯平台,支持企业微信、飞书、Slack、Telegram、钉钉、Mattermost和微信",
|
||||
wecom: "企业微信",
|
||||
feishu: "飞书",
|
||||
slack: "Slack",
|
||||
telegram: "Telegram",
|
||||
dingtalk: "钉钉",
|
||||
mattermost: "Mattermost",
|
||||
wechat: "微信",
|
||||
addChannel: "添加渠道",
|
||||
editChannel: "编辑渠道",
|
||||
deleteConfirm: "确定删除该渠道?删除后无法恢复。",
|
||||
|
|
@ -3291,6 +3337,8 @@ export default {
|
|||
"开启后 Bot 回复作为频道内新帖子;关闭(默认)则作为原消息的线程回复,主窗口仅显示「N 条回复」。",
|
||||
modeHint: "推荐使用 WebSocket 方式接入,配置更简单",
|
||||
consoleTip: "前往获取凭证信息",
|
||||
wecomWSEndpointHint: "可选,私有化部署时填写自定义 WebSocket 地址,留空则使用默认公有云地址。内网地址需将域名加入 SSRF_WHITELIST 环境变量",
|
||||
wecomAPIBaseURLHint: "可选,私有化部署时填写自定义 API 地址,留空则使用默认公有云地址。内网地址需将域名加入 SSRF_WHITELIST 环境变量",
|
||||
fileKnowledgeBase: "文件保存知识库",
|
||||
fileKnowledgeBasePlaceholder: "选择知识库(可选)",
|
||||
fileKnowledgeBaseHint: "配置后,用户发送的文件将自动保存到该知识库中",
|
||||
|
|
@ -3298,6 +3346,13 @@ export default {
|
|||
sessionModeUser: "按用户(默认)",
|
||||
sessionModeThread: "按话题",
|
||||
sessionModeHint: "用户模式:每个用户独立对话,使用 /clear 开始新对话。话题模式:每个消息话题独立对话,同一话题中多人可协作。",
|
||||
wechatScanBind: "扫码绑定微信",
|
||||
wechatScanning: "请使用微信扫描二维码",
|
||||
wechatBindSuccess: "微信绑定成功",
|
||||
wechatRebind: "重新绑定",
|
||||
wechatHint: "需要 iOS 微信 8.0.70+ 版本,仅支持单聊消息",
|
||||
wechatQRExpired: "二维码已过期,请重新获取",
|
||||
wechatBinding: "绑定中...",
|
||||
},
|
||||
tools: {
|
||||
thinking: "思考",
|
||||
|
|
@ -3463,11 +3518,15 @@ export default {
|
|||
untitled: "无标题",
|
||||
resourceLoadFailed: "加载资源列表失败",
|
||||
noResources: "未找到可同步的知识库空间",
|
||||
noResourcesDesc: "应用需要通过群聊获得知识库访问权限才能拉取内容",
|
||||
noResourcesDesc: "应用需要通过群聊获得知识库访问权限才能拉取内容",
|
||||
noResourcesDesc_notion: "应用需要获得 Notion 页面的访问权限才能拉取内容",
|
||||
retryLoadResources: "重新加载",
|
||||
guideStep1: "在飞书中创建一个群聊,在群设置「群机器人」中添加你的应用",
|
||||
guideStep2: "打开知识库「设置」→「成员设置」→ 添加成员,搜索该群聊名称并添加",
|
||||
guideStep3: "确保群聊角色至少为「可阅读」,然后回到这里点重新加载",
|
||||
guideStep1_notion: "在 Notion 中打开你想要同步的页面或数据库",
|
||||
guideStep2_notion: "点击右上角的「···」菜单,选择「Connect to」或「Add connections」",
|
||||
guideStep3_notion: "搜索并选择你的集成应用(Integration),然后回到这里点重新加载",
|
||||
permissionDocLink: "查看飞书知识库权限配置文档",
|
||||
syncScheduleLabel: "同步频率",
|
||||
conflictLabel: "冲突策略",
|
||||
|
|
|
|||
|
|
@ -20,4 +20,7 @@ app.use(createPinia());
|
|||
app.use(router);
|
||||
app.use(i18n);
|
||||
|
||||
app.mount("#app");
|
||||
// 等首屏路由(含导航守卫、Lite 自动登录)完成后再挂载,避免先闪默认页再跳转
|
||||
router.isReady().finally(() => {
|
||||
app.mount("#app");
|
||||
});
|
||||
|
|
|
|||
|
|
@ -1,7 +1,27 @@
|
|||
import { createRouter, createWebHistory } from 'vue-router'
|
||||
import { listKnowledgeBases } from '@/api/knowledge-base'
|
||||
import type { RouteLocationNormalized } from 'vue-router'
|
||||
import { useAuthStore } from '@/stores/auth'
|
||||
import { validateToken } from '@/api/auth'
|
||||
import { autoSetup } from '@/api/auth'
|
||||
|
||||
/** Lite /桌面 WebView 硬刷新时可能只打开 `/`,用 session 记住上次页面以便恢复 */
|
||||
const LITE_LAST_PATH_KEY = 'weknora_lite_last_path'
|
||||
|
||||
function isLiteEdition(authStore: ReturnType<typeof useAuthStore>) {
|
||||
return authStore.isLiteMode || localStorage.getItem('weknora_lite_mode') === 'true'
|
||||
}
|
||||
|
||||
function isLiteSpaDefaultEntry(to: RouteLocationNormalized) {
|
||||
return (
|
||||
to.path === '/' ||
|
||||
to.path === '/platform' ||
|
||||
to.path === '/platform/knowledge-bases' ||
|
||||
to.name === 'knowledgeBaseList'
|
||||
)
|
||||
}
|
||||
|
||||
function isSafeLiteRestoreTarget(path: string) {
|
||||
return path.startsWith('/platform/') && !path.startsWith('/platform/organizations')
|
||||
}
|
||||
|
||||
const router = createRouter({
|
||||
history: createWebHistory(import.meta.env.BASE_URL),
|
||||
|
|
@ -105,10 +125,55 @@ const router = createRouter({
|
|||
],
|
||||
});
|
||||
|
||||
// 持久化 auto-setup / login 返回的认证信息到 store
|
||||
function persistLoginResponse(authStore: ReturnType<typeof useAuthStore>, response: any) {
|
||||
if (response.user && response.tenant && response.token) {
|
||||
authStore.setUser({
|
||||
id: response.user.id || '',
|
||||
username: response.user.username || '',
|
||||
email: response.user.email || '',
|
||||
avatar: response.user.avatar,
|
||||
tenant_id: String(response.tenant.id) || '',
|
||||
can_access_all_tenants: response.user.can_access_all_tenants || false,
|
||||
created_at: response.user.created_at || new Date().toISOString(),
|
||||
updated_at: response.user.updated_at || new Date().toISOString()
|
||||
})
|
||||
authStore.setToken(response.token)
|
||||
if (response.refresh_token) {
|
||||
authStore.setRefreshToken(response.refresh_token)
|
||||
}
|
||||
authStore.setTenant({
|
||||
id: String(response.tenant.id) || '',
|
||||
name: response.tenant.name || '',
|
||||
api_key: response.tenant.api_key || '',
|
||||
owner_id: response.user.id || '',
|
||||
created_at: response.tenant.created_at || new Date().toISOString(),
|
||||
updated_at: response.tenant.updated_at || new Date().toISOString()
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
let autoSetupAttempted = false
|
||||
let liteDeepLinkRestoreDone = false
|
||||
|
||||
// 路由守卫:检查认证状态和系统初始化状态
|
||||
router.beforeEach(async (to, from, next) => {
|
||||
const authStore = useAuthStore()
|
||||
|
||||
|
||||
// Lite:硬刷新后若落在默认首页,恢复本次会话中最后访问的 /platform 子路径
|
||||
if (!liteDeepLinkRestoreDone) {
|
||||
liteDeepLinkRestoreDone = true
|
||||
if (isLiteEdition(authStore)) {
|
||||
const saved = sessionStorage.getItem(LITE_LAST_PATH_KEY)
|
||||
if (saved && isSafeLiteRestoreTarget(saved) && isLiteSpaDefaultEntry(to)) {
|
||||
if (saved !== to.fullPath) {
|
||||
next(saved)
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 如果访问的是登录页面或初始化页面,直接放行
|
||||
if (to.meta.requiresAuth === false || to.meta.requiresInit === false) {
|
||||
// 如果已登录用户访问登录页面,重定向到知识库列表页面
|
||||
|
|
@ -123,29 +188,34 @@ router.beforeEach(async (to, from, next) => {
|
|||
// 检查用户认证状态
|
||||
if (to.meta.requiresAuth !== false) {
|
||||
if (!authStore.isLoggedIn) {
|
||||
// 未登录,跳转到登录页面
|
||||
// Lite 版:尝试自动初始化(仅一次),成功则跳过登录页
|
||||
if (!autoSetupAttempted) {
|
||||
autoSetupAttempted = true
|
||||
try {
|
||||
const response = await autoSetup()
|
||||
if (response.success) {
|
||||
persistLoginResponse(authStore, response)
|
||||
authStore.setLiteMode(true)
|
||||
next(to.fullPath)
|
||||
return
|
||||
}
|
||||
} catch {
|
||||
// auto-setup 不可用(非 lite 版本),走正常登录流程
|
||||
}
|
||||
}
|
||||
next('/login')
|
||||
return
|
||||
}
|
||||
|
||||
// 验证Token有效性
|
||||
// try {
|
||||
// const { valid } = await validateToken()
|
||||
// if (!valid) {
|
||||
// // Token无效,清空认证信息并跳转到登录页面
|
||||
// authStore.logout()
|
||||
// next('/login')
|
||||
// return
|
||||
// }
|
||||
// } catch (error) {
|
||||
// console.error('Token验证失败:', error)
|
||||
// authStore.logout()
|
||||
// next('/login')
|
||||
// return
|
||||
// }
|
||||
}
|
||||
|
||||
next()
|
||||
});
|
||||
})
|
||||
|
||||
router.afterEach((to) => {
|
||||
if (!isLiteEdition(useAuthStore())) return
|
||||
if (to.path === '/login') return
|
||||
if (!to.path.startsWith('/platform')) return
|
||||
sessionStorage.setItem(LITE_LAST_PATH_KEY, to.fullPath)
|
||||
})
|
||||
|
||||
export default router
|
||||
|
|
|
|||
|
|
@ -15,6 +15,7 @@ export const useAuthStore = defineStore('auth', () => {
|
|||
const selectedTenantId = ref<number | null>(null)
|
||||
const selectedTenantName = ref<string | null>(null)
|
||||
const allTenants = ref<TenantInfoFromAPI[]>([])
|
||||
const isLiteMode = ref(false)
|
||||
|
||||
// 计算属性
|
||||
const isLoggedIn = computed(() => {
|
||||
|
|
@ -102,6 +103,14 @@ export const useAuthStore = defineStore('auth', () => {
|
|||
return selectedTenantId.value
|
||||
}
|
||||
|
||||
const setLiteMode = (value: boolean) => {
|
||||
isLiteMode.value = value
|
||||
if (value) {
|
||||
localStorage.setItem('weknora_lite_mode', 'true')
|
||||
} else {
|
||||
localStorage.removeItem('weknora_lite_mode')
|
||||
}
|
||||
}
|
||||
|
||||
const logout = () => {
|
||||
// 清空状态
|
||||
|
|
@ -124,7 +133,13 @@ export const useAuthStore = defineStore('auth', () => {
|
|||
localStorage.removeItem('weknora_current_kb')
|
||||
localStorage.removeItem('weknora_selected_tenant_id')
|
||||
localStorage.removeItem('weknora_selected_tenant_name')
|
||||
|
||||
localStorage.removeItem('weknora_lite_mode')
|
||||
isLiteMode.value = false
|
||||
try {
|
||||
sessionStorage.removeItem('weknora_lite_last_path')
|
||||
} catch {
|
||||
/* ignore */
|
||||
}
|
||||
}
|
||||
|
||||
const initFromStorage = () => {
|
||||
|
|
@ -192,6 +207,8 @@ export const useAuthStore = defineStore('auth', () => {
|
|||
selectedTenantName.value = null
|
||||
}
|
||||
}
|
||||
|
||||
isLiteMode.value = localStorage.getItem('weknora_lite_mode') === 'true'
|
||||
}
|
||||
|
||||
// 初始化时从localStorage恢复状态
|
||||
|
|
@ -216,6 +233,7 @@ export const useAuthStore = defineStore('auth', () => {
|
|||
currentUserId,
|
||||
canAccessAllTenants,
|
||||
effectiveTenantId,
|
||||
isLiteMode,
|
||||
|
||||
// 方法
|
||||
setUser,
|
||||
|
|
@ -227,6 +245,7 @@ export const useAuthStore = defineStore('auth', () => {
|
|||
setSelectedTenant,
|
||||
setAllTenants,
|
||||
getSelectedTenant,
|
||||
setLiteMode,
|
||||
logout,
|
||||
initFromStorage
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
import { reactive, ref, watch } from 'vue'
|
||||
import { reactive, ref, computed, watch } from 'vue'
|
||||
import { defineStore } from 'pinia'
|
||||
import i18n from '@/i18n'
|
||||
import { useAuthStore } from '@/stores/auth'
|
||||
|
||||
type MenuChild = Record<string, any>
|
||||
|
||||
|
|
@ -58,6 +59,16 @@ export const useMenuStore = defineStore('menuStore', () => {
|
|||
}
|
||||
)
|
||||
|
||||
const liteHiddenPaths = new Set(['logout', 'organizations'])
|
||||
|
||||
const visibleMenuArr = computed(() => {
|
||||
const authStore = useAuthStore()
|
||||
if (authStore.isLiteMode) {
|
||||
return menuArr.filter(item => !liteHiddenPaths.has(item.path))
|
||||
}
|
||||
return menuArr
|
||||
})
|
||||
|
||||
const chatMenuIndex = menuArr.findIndex(item => item.path === 'creatChat')
|
||||
|
||||
const clearMenuArr = () => {
|
||||
|
|
@ -120,6 +131,7 @@ export const useMenuStore = defineStore('menuStore', () => {
|
|||
|
||||
return {
|
||||
menuArr,
|
||||
visibleMenuArr,
|
||||
isFirstSession,
|
||||
firstQuery,
|
||||
firstMentionedItems,
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
import { defineStore } from "pinia";
|
||||
import { BUILTIN_QUICK_ANSWER_ID, BUILTIN_SMART_REASONING_ID } from "@/api/agent";
|
||||
import { getApiBaseUrl } from "@/utils/api-base";
|
||||
|
||||
// 定义设置接口
|
||||
interface Settings {
|
||||
|
|
@ -18,6 +19,7 @@ interface Settings {
|
|||
conversationModels: ConversationModels;
|
||||
selectedAgentId: string; // 当前选中的智能体ID
|
||||
selectedAgentSourceTenantId: string | null; // 当使用共享智能体时,来源租户 ID(用于后端 model/KB/MCP 解析)
|
||||
autoCheckUpdate?: boolean; // 是否自动检查并下载更新
|
||||
}
|
||||
|
||||
// Agent 配置接口
|
||||
|
|
@ -63,7 +65,7 @@ interface OllamaConfig {
|
|||
|
||||
// 默认设置
|
||||
const defaultSettings: Settings = {
|
||||
endpoint: import.meta.env.VITE_IS_DOCKER ? "" : "http://localhost:8080",
|
||||
endpoint: getApiBaseUrl(),
|
||||
apiKey: "",
|
||||
knowledgeBaseId: "",
|
||||
isAgentEnabled: false,
|
||||
|
|
@ -95,6 +97,7 @@ const defaultSettings: Settings = {
|
|||
},
|
||||
selectedAgentId: BUILTIN_QUICK_ANSWER_ID, // 默认选中快速问答模式
|
||||
selectedAgentSourceTenantId: null as string | null, // 共享智能体来源租户 ID
|
||||
autoCheckUpdate: true,
|
||||
};
|
||||
|
||||
export const useSettingsStore = defineStore("settings", {
|
||||
|
|
@ -143,6 +146,9 @@ export const useSettingsStore = defineStore("settings", {
|
|||
// 记忆功能是否启用
|
||||
isMemoryEnabled: (state) => state.settings.enableMemory || false,
|
||||
|
||||
// 是否自动检查并下载更新
|
||||
isAutoCheckUpdateEnabled: (state) => state.settings.autoCheckUpdate ?? true,
|
||||
|
||||
// 当前选中的智能体ID
|
||||
selectedAgentId: (state) => state.settings.selectedAgentId || BUILTIN_QUICK_ANSWER_ID,
|
||||
// 共享智能体来源租户 ID(可选)
|
||||
|
|
@ -307,6 +313,12 @@ export const useSettingsStore = defineStore("settings", {
|
|||
localStorage.setItem("WeKnora_settings", JSON.stringify(this.settings));
|
||||
},
|
||||
|
||||
// 启用/禁用自动检查更新
|
||||
toggleAutoCheckUpdate(enabled: boolean) {
|
||||
this.settings.autoCheckUpdate = enabled;
|
||||
localStorage.setItem("WeKnora_settings", JSON.stringify(this.settings));
|
||||
},
|
||||
|
||||
// File selection actions
|
||||
addFile(fileId: string) {
|
||||
if (!this.settings.selectedFiles) this.settings.selectedFiles = [];
|
||||
|
|
|
|||
|
|
@ -0,0 +1,5 @@
|
|||
export function getApiBaseUrl(): string {
|
||||
// Use same-origin requests by default.
|
||||
// In local Vite dev, `vite.config.ts` proxies `/api` to the Go backend.
|
||||
return '';
|
||||
}
|
||||
|
|
@ -40,7 +40,7 @@ export function formatStringDate(date: any) {
|
|||
year + "-" + month + "-" + day + " " + hour + ":" + minute + ":" + second
|
||||
);
|
||||
}
|
||||
const DEFAULT_VALID_TYPES = new Set(["pdf", "txt", "md", "docx", "doc", "pptx", "ppt", "jpg", "jpeg", "png", "csv", "xlsx", "xls"]);
|
||||
const DEFAULT_VALID_TYPES = new Set(["pdf", "txt", "md", "docx", "doc", "pptx", "ppt", "jpg", "jpeg", "png", "csv", "xlsx", "xls", "mp4", "mov", "avi", "mkv", "webm", "wmv", "flv", "mp3", "wav", "m4a", "flac", "ogg"]);
|
||||
|
||||
/**
|
||||
* Returns true when the file should be **rejected**.
|
||||
|
|
|
|||
|
|
@ -2,11 +2,12 @@
|
|||
import axios from "axios";
|
||||
import { generateRandomString } from "./index";
|
||||
import i18n from '@/i18n'
|
||||
import { getApiBaseUrl } from './api-base';
|
||||
|
||||
const t = (key: string) => i18n.global.t(key)
|
||||
|
||||
// API基础URL
|
||||
const BASE_URL = import.meta.env.VITE_IS_DOCKER ? "" : "http://localhost:8080";
|
||||
const BASE_URL = getApiBaseUrl();
|
||||
|
||||
|
||||
// 创建Axios实例
|
||||
|
|
|
|||
|
|
@ -41,7 +41,7 @@ const DOMPurifyConfig = {
|
|||
'display', 'pointer-events', 'cursor', 'data-emit', 'direction'
|
||||
],
|
||||
// 允许的协议
|
||||
ALLOWED_URI_REGEXP: /^(?:(?:(?:f|ht)tps?|mailto|tel|callto|cid|xmpp):|(?:local|minio|cos|tos|s3):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i,
|
||||
ALLOWED_URI_REGEXP: /^(?:(?:(?:f|ht)tps?|mailto|tel|callto|cid|xmpp):|(?:local|minio|cos|tos|s3|oss):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i,
|
||||
// 禁止的标签和属性
|
||||
FORBID_TAGS: ['script', 'object', 'embed', 'form', 'input', 'button'],
|
||||
FORBID_ATTR: ['onerror', 'onload', 'onclick', 'onmouseover', 'onfocus', 'onblur'],
|
||||
|
|
@ -119,7 +119,7 @@ function protectProviderImageSrcInHTML(html: string): string {
|
|||
.replace(/&/g, '&')
|
||||
.replace(/"/g, '"');
|
||||
return html.replace(
|
||||
/<img\b([^>]*?)\ssrc=(["'])(local|minio|cos|tos|s3):(?:\/\/|//|//)([^"']+)\2([^>]*)>/gi,
|
||||
/<img\b([^>]*?)\ssrc=(["'])(local|minio|cos|tos|s3|oss):(?:\/\/|//|//)([^"']+)\2([^>]*)>/gi,
|
||||
(_m, before, quote, provider, restPathRaw, after) => {
|
||||
const restPath = decodeProviderURL(restPathRaw);
|
||||
const protectedSrc = `${provider}://${restPath}`;
|
||||
|
|
@ -173,7 +173,7 @@ export function isValidURL(url: string): boolean {
|
|||
}
|
||||
|
||||
// 允许 provider:// 形式,由前端后续鉴权拉取并替换为 blob URL
|
||||
if (/^(local|minio|cos|tos|s3):\/\/\S+$/i.test(trimmed)) {
|
||||
if (/^(local|minio|cos|tos|s3|oss):\/\/\S+$/i.test(trimmed)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
@ -299,7 +299,7 @@ export async function hydrateProtectedFileImages(root: ParentNode | null | undef
|
|||
}
|
||||
|
||||
const images = root.querySelectorAll<HTMLImageElement>(
|
||||
'img[data-protected-src], img[src^="local://"], img[src^="minio://"], img[src^="cos://"], img[src^="tos://"], img[src^="s3://"]',
|
||||
'img[data-protected-src], img[src^="local://"], img[src^="minio://"], img[src^="cos://"], img[src^="tos://"], img[src^="s3://"], img[src^="oss://"]',
|
||||
);
|
||||
if (!images.length) {
|
||||
return;
|
||||
|
|
@ -319,7 +319,7 @@ export async function hydrateProtectedFileImages(root: ParentNode | null | undef
|
|||
}
|
||||
img.dataset.authHydrated = '1';
|
||||
|
||||
const isProviderScheme = /^(local|minio|cos|tos|s3):\/\//.test(sourceURL);
|
||||
const isProviderScheme = /^(local|minio|cos|tos|s3|oss):\/\//.test(sourceURL);
|
||||
const requestURL = isProviderScheme
|
||||
? `/files?${new URLSearchParams({ file_path: sourceURL }).toString()}`
|
||||
: sourceURL;
|
||||
|
|
|
|||
|
|
@ -1247,6 +1247,7 @@ import { listSkills, type SkillInfo } from '@/api/skill';
|
|||
import { listWebSearchProviders, type WebSearchProviderEntity } from '@/api/web-search-provider';
|
||||
import { getAgentConfig, getConversationConfig, getStorageEngineStatus, type StorageEngineStatusItem, type PromptTemplate } from '@/api/system';
|
||||
import { useUIStore } from '@/stores/ui';
|
||||
import { useAuthStore } from '@/stores/auth';
|
||||
import { useOrganizationStore } from '@/stores/organization';
|
||||
import AgentAvatar from '@/components/AgentAvatar.vue';
|
||||
import PromptTemplateSelector from '@/components/PromptTemplateSelector.vue';
|
||||
|
|
@ -1255,6 +1256,7 @@ import AgentShareSettings from '@/components/AgentShareSettings.vue';
|
|||
import IMChannelPanel from '@/components/IMChannelPanel.vue';
|
||||
|
||||
const uiStore = useUIStore();
|
||||
const authStore = useAuthStore();
|
||||
const orgStore = useOrganizationStore();
|
||||
|
||||
const { t } = useI18n();
|
||||
|
|
@ -1293,6 +1295,7 @@ const imageStorageOptions = computed(() => {
|
|||
{ value: 'cos', label: t('settings.storage.engineCos'), disabled: statusMap.cos === false },
|
||||
{ value: 'tos', label: t('settings.storage.engineTos'), disabled: statusMap.tos === false },
|
||||
{ value: 's3', label: 'Amazon S3', disabled: statusMap.s3 === false },
|
||||
{ value: 'oss', label: t('settings.storage.engineOss'), disabled: statusMap.oss === false },
|
||||
];
|
||||
});
|
||||
|
||||
|
|
@ -1482,8 +1485,8 @@ const navItems = computed(() => {
|
|||
if (!isAgentMode.value) {
|
||||
items.push({ key: 'conversation', icon: 'chat', label: t('agent.editor.conversationSettings') });
|
||||
}
|
||||
// 共享管理(仅编辑模式且非内置智能体)
|
||||
if (props.mode === 'edit' && props.agent?.id && !props.agent?.is_builtin) {
|
||||
// 共享管理(仅编辑模式且非内置智能体,Lite 模式下隐藏)
|
||||
if (props.mode === 'edit' && props.agent?.id && !props.agent?.is_builtin && !authStore.isLiteMode) {
|
||||
items.push({ key: 'share', icon: 'share', label: t('knowledgeEditor.sidebar.share') });
|
||||
}
|
||||
// IM集成(仅编辑模式,创建时Agent还没有ID)
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
<template>
|
||||
<div class="agent-list-container">
|
||||
<ListSpaceSidebar
|
||||
v-if="!authStore.isLiteMode"
|
||||
v-model="spaceSelection"
|
||||
:count-all="allAgentsCount"
|
||||
:count-mine="agents.length"
|
||||
|
|
@ -9,16 +10,17 @@
|
|||
hide-shared
|
||||
/>
|
||||
<div class="agent-list-content">
|
||||
<div class="header">
|
||||
<div class="header-title">
|
||||
<div class="title-row">
|
||||
<h2>{{ $t('agent.title') }}</h2>
|
||||
<div class="header" style="--wails-draggable: drag">
|
||||
<div class="header-title" style="--wails-draggable: drag">
|
||||
<div class="title-row" style="--wails-draggable: drag">
|
||||
<h2 style="--wails-draggable: drag">{{ $t('agent.title') }}</h2>
|
||||
<t-tooltip :content="$t('agent.createAgent')" placement="bottom">
|
||||
<t-button
|
||||
variant="text"
|
||||
theme="default"
|
||||
size="small"
|
||||
class="header-action-btn"
|
||||
style="--wails-draggable: no-drag"
|
||||
@click="handleCreateAgent"
|
||||
>
|
||||
<template #icon>
|
||||
|
|
@ -33,10 +35,27 @@
|
|||
</t-button>
|
||||
</t-tooltip>
|
||||
</div>
|
||||
<p class="header-subtitle">{{ $t('agent.subtitle') }}</p>
|
||||
<p class="header-subtitle" style="--wails-draggable: drag">{{ $t('agent.subtitle') }}</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="agent-list-main">
|
||||
<!-- 骨架屏占位 -->
|
||||
<div v-if="loading && agents.length === 0" class="agent-card-wrap">
|
||||
<div v-for="n in 6" :key="'skel-'+n" class="agent-card agent-card-skeleton">
|
||||
<div class="card-header">
|
||||
<div class="card-header-left">
|
||||
<t-skeleton animation="gradient" :row-col="[[{ width: '32px', height: '32px', type: 'circle' }, { width: '40%', height: '18px' }]]" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="card-content">
|
||||
<t-skeleton animation="gradient" :row-col="[{ width: '100%', height: '14px' }, { width: '70%', height: '14px' }]" />
|
||||
</div>
|
||||
<div class="card-bottom">
|
||||
<t-skeleton animation="gradient" :row-col="[[{ width: '60px', height: '22px', type: 'rect' }, { width: '60px', height: '22px', type: 'rect' }]]" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 全部:我的 + 共享 -->
|
||||
<div v-if="spaceSelection === 'all' && filteredAgents.length > 0" class="agent-card-wrap">
|
||||
<div
|
||||
|
|
@ -544,10 +563,12 @@ import type { SharedAgentInfo, OrganizationSharedAgentItem } from '@/api/organiz
|
|||
import AgentEditorModal from './AgentEditorModal.vue'
|
||||
import AgentAvatar from '@/components/AgentAvatar.vue'
|
||||
import ListSpaceSidebar from '@/components/ListSpaceSidebar.vue'
|
||||
import { useAuthStore } from '@/stores/auth'
|
||||
|
||||
const { t } = useI18n()
|
||||
const route = useRoute()
|
||||
const router = useRouter()
|
||||
const authStore = useAuthStore()
|
||||
const orgStore = useOrganizationStore()
|
||||
|
||||
interface AgentWithUI extends CustomAgent {
|
||||
|
|
@ -1180,10 +1201,23 @@ defineExpose({
|
|||
}
|
||||
|
||||
|
||||
@keyframes contentFadeIn {
|
||||
from { opacity: 0; transform: translateY(6px); }
|
||||
to { opacity: 1; transform: translateY(0); }
|
||||
}
|
||||
|
||||
.agent-card-wrap {
|
||||
display: grid;
|
||||
gap: 20px;
|
||||
grid-template-columns: 1fr;
|
||||
animation: contentFadeIn 0.32s ease-out;
|
||||
}
|
||||
|
||||
.agent-card-skeleton {
|
||||
cursor: default;
|
||||
.card-header { margin-bottom: 16px; }
|
||||
.card-content { flex: 1; }
|
||||
.card-bottom { margin-top: auto; }
|
||||
}
|
||||
|
||||
/* 与知识库列表卡片统一尺寸:160px 高、18px 20px 内边距、12px 圆角 */
|
||||
|
|
|
|||
|
|
@ -377,7 +377,7 @@ import { Autoplay, EffectFade, Pagination } from 'swiper/modules'
|
|||
import 'swiper/css'
|
||||
import 'swiper/css/effect-fade'
|
||||
import 'swiper/css/pagination'
|
||||
import { login, register, getOIDCAuthorizationURL, getOIDCConfig } from '@/api/auth'
|
||||
import { login, register, getOIDCAuthorizationURL, getOIDCConfig, autoSetup } from '@/api/auth'
|
||||
import { useAuthStore } from '@/stores/auth'
|
||||
import { useI18n } from 'vue-i18n'
|
||||
|
||||
|
|
@ -668,13 +668,24 @@ const handleRegister = async () => {
|
|||
}
|
||||
}
|
||||
|
||||
// Check if already logged in
|
||||
onMounted(() => {
|
||||
// Check if already logged in; for lite edition, attempt transparent auto-setup
|
||||
onMounted(async () => {
|
||||
if (authStore.isLoggedIn) {
|
||||
router.replace('/platform/knowledge-bases')
|
||||
return
|
||||
}
|
||||
|
||||
try {
|
||||
const response = await autoSetup()
|
||||
if (response.success) {
|
||||
authStore.setLiteMode(true)
|
||||
await persistLoginResponse(response)
|
||||
return
|
||||
}
|
||||
} catch {
|
||||
// auto-setup not available (standard edition) — show normal login form
|
||||
}
|
||||
|
||||
loadOIDCConfig()
|
||||
})
|
||||
</script>
|
||||
|
|
|
|||
|
|
@ -1000,9 +1000,15 @@ const handleCitationActivate = (el: HTMLElement) => {
|
|||
const url = el.getAttribute('data-url');
|
||||
if (!url) return;
|
||||
try {
|
||||
const newWindow = window.open(url, '_blank', 'noopener,noreferrer');
|
||||
if (!newWindow) {
|
||||
window.location.assign(url);
|
||||
// @ts-ignore: Wails runtime check
|
||||
if (window.runtime && window.runtime.BrowserOpenURL) {
|
||||
// @ts-ignore
|
||||
window.runtime.BrowserOpenURL(url);
|
||||
} else {
|
||||
const newWindow = window.open(url, '_blank', 'noopener,noreferrer');
|
||||
if (!newWindow) {
|
||||
window.location.assign(url);
|
||||
}
|
||||
}
|
||||
} catch {
|
||||
window.location.assign(url);
|
||||
|
|
@ -1200,10 +1206,8 @@ const onRootClick = (e: Event) => {
|
|||
// Handle web citation clicks
|
||||
const webEl = target.closest?.('.citation-web') as HTMLElement | null;
|
||||
if (webEl && webEl.getAttribute('data-url')) {
|
||||
if (!(webEl instanceof HTMLAnchorElement)) {
|
||||
e.preventDefault();
|
||||
handleCitationActivate(webEl);
|
||||
}
|
||||
e.preventDefault();
|
||||
handleCitationActivate(webEl);
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -1223,6 +1227,18 @@ const onRootClick = (e: Event) => {
|
|||
}
|
||||
return;
|
||||
}
|
||||
|
||||
// Handle generic a clicks (especially in Wails desktop)
|
||||
const aEl = target.closest?.('a') as HTMLAnchorElement | null;
|
||||
// @ts-ignore
|
||||
if (aEl && aEl.href && window.runtime && window.runtime.BrowserOpenURL) {
|
||||
if (aEl.href.startsWith('http://') || aEl.href.startsWith('https://')) {
|
||||
e.preventDefault();
|
||||
// @ts-ignore
|
||||
window.runtime.BrowserOpenURL(aEl.href);
|
||||
return;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
const onRootKeydown = (e: KeyboardEvent) => {
|
||||
|
|
@ -1233,15 +1249,8 @@ const onRootKeydown = (e: KeyboardEvent) => {
|
|||
const webEl = target.closest?.('.citation-web') as HTMLElement | null;
|
||||
if (webEl) {
|
||||
if (e.key === 'Enter' || e.key === ' ') {
|
||||
if (webEl instanceof HTMLAnchorElement && e.key === 'Enter') {
|
||||
return;
|
||||
}
|
||||
e.preventDefault();
|
||||
if (webEl instanceof HTMLAnchorElement) {
|
||||
webEl.click();
|
||||
} else {
|
||||
handleCitationActivate(webEl);
|
||||
}
|
||||
handleCitationActivate(webEl);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -259,19 +259,17 @@ const getWebSearchDisplayText = (item) => {
|
|||
line-height: 20px;
|
||||
padding: 2px 0;
|
||||
transition: all 0.2s ease;
|
||||
border-bottom: 1px solid transparent;
|
||||
border-bottom: 1px dashed var(--td-brand-color);
|
||||
|
||||
&:hover {
|
||||
border-bottom-color: var(--td-brand-color);
|
||||
background-color: rgba(7, 192, 95, 0.08);
|
||||
border-radius: 3px;
|
||||
padding-right: 4px;
|
||||
}
|
||||
|
||||
&.doc-web {
|
||||
white-space: normal;
|
||||
word-break: break-all;
|
||||
|
||||
&:hover {
|
||||
text-decoration: underline;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -2,9 +2,33 @@
|
|||
<div class="chat">
|
||||
<div ref="scrollContainer" class="chat_scroll_box" @scroll="handleScroll">
|
||||
<div class="msg_list">
|
||||
<!-- 消息列表骨架屏 -->
|
||||
<div v-if="historyLoading && messagesList.length === 0" class="msg-skeleton-list">
|
||||
<div class="msg-skeleton msg-skeleton-user">
|
||||
<t-skeleton animation="gradient" :row-col="[{ width: '45%', height: '36px', type: 'rect' }]" />
|
||||
</div>
|
||||
<div class="msg-skeleton msg-skeleton-bot">
|
||||
<t-skeleton animation="gradient" :row-col="[{ width: '80%', height: '16px' }, { width: '100%', height: '16px' }, { width: '60%', height: '16px' }]" />
|
||||
</div>
|
||||
<div class="msg-skeleton msg-skeleton-user">
|
||||
<t-skeleton animation="gradient" :row-col="[{ width: '35%', height: '36px', type: 'rect' }]" />
|
||||
</div>
|
||||
<div class="msg-skeleton msg-skeleton-bot">
|
||||
<t-skeleton animation="gradient" :row-col="[{ width: '70%', height: '16px' }, { width: '90%', height: '16px' }]" />
|
||||
</div>
|
||||
</div>
|
||||
<!-- 推荐问题卡片 - 仅在新会话(无消息)时展示 -->
|
||||
<div v-if="messagesList.length === 0 && !loading" class="suggested-questions-container" :class="{ 'has-questions': suggestedQuestions.length > 0 }">
|
||||
<transition name="sq-fade">
|
||||
<div v-if="messagesList.length === 0 && !loading" class="suggested-questions-container" :class="{ 'has-questions': suggestedQuestions.length > 0 || suggestedQuestionsLoading }">
|
||||
<!-- 骨架屏占位 -->
|
||||
<div v-if="suggestedQuestionsLoading && suggestedQuestions.length === 0" class="suggested-questions-inner">
|
||||
<div class="suggested-questions-title"><t-skeleton animation="gradient" :row-col="[{ width: '120px', height: '18px' }]" /></div>
|
||||
<div class="suggested-questions-grid">
|
||||
<div v-for="n in 6" :key="'sq-skel-'+n" class="suggested-question-card sq-card-skeleton">
|
||||
<t-skeleton animation="gradient" :row-col="[{ width: '90%', height: '14px' }, { width: '60%', height: '14px' }]" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<transition v-else appear name="sq-fade">
|
||||
<div v-if="suggestedQuestions.length > 0" class="suggested-questions-inner">
|
||||
<div class="suggested-questions-title">{{ t('chat.suggestedQuestions') }}</div>
|
||||
<div class="suggested-questions-grid">
|
||||
|
|
@ -40,6 +64,11 @@
|
|||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<transition name="scroll-btn-fade">
|
||||
<div v-show="userHasScrolledUp" class="scroll-to-bottom-btn" @click="onClickScrollToBottom">
|
||||
<t-icon name="chevron-down" size="20px" />
|
||||
</div>
|
||||
</transition>
|
||||
<div style="min-height: 115px; margin: 16px auto 4px;width: 100%;max-width: 800px;">
|
||||
<InputField
|
||||
ref="inputFieldRef"
|
||||
|
|
@ -98,9 +127,19 @@ const scrollLock = ref(false);
|
|||
const isNeedTitle = ref(false);
|
||||
const isFirstEnter = ref(true);
|
||||
const loading = ref(false);
|
||||
const historyLoading = ref(true);
|
||||
let fullContent = ref('')
|
||||
let userquery = ref('')
|
||||
const scrollContainer = ref(null)
|
||||
const userHasScrolledUp = ref(false)
|
||||
const SCROLL_BOTTOM_THRESHOLD = 80
|
||||
|
||||
const isNearBottom = () => {
|
||||
if (!scrollContainer.value) return true;
|
||||
const { scrollTop, scrollHeight, clientHeight } = scrollContainer.value;
|
||||
return scrollHeight - scrollTop - clientHeight < SCROLL_BOTTOM_THRESHOLD;
|
||||
}
|
||||
|
||||
const handleKBEditorSuccess = (kbId) => {
|
||||
navigateToKnowledgeBaseList(kbId)
|
||||
}
|
||||
|
|
@ -198,10 +237,12 @@ watch([() => route.params], (newvalue) => {
|
|||
messagesList.splice(0);
|
||||
session_id.value = newvalue[0].chatid;
|
||||
|
||||
// 切换会话时,重置状态(加载历史消息不应显示loading)
|
||||
// 切换会话时,重置状态
|
||||
historyLoading.value = true;
|
||||
loading.value = false;
|
||||
isReplying.value = false;
|
||||
currentAssistantMessageId.value = '';
|
||||
userHasScrolledUp.value = false;
|
||||
|
||||
checkmenuTitle(session_id.value)
|
||||
let data = {
|
||||
|
|
@ -212,13 +253,18 @@ watch([() => route.params], (newvalue) => {
|
|||
getmsgList(data);
|
||||
}
|
||||
});
|
||||
const scrollToBottom = () => {
|
||||
const scrollToBottom = (force = false) => {
|
||||
if (!force && userHasScrolledUp.value) return;
|
||||
nextTick(() => {
|
||||
if (scrollContainer.value) {
|
||||
scrollContainer.value.scrollTop = scrollContainer.value.scrollHeight;
|
||||
}
|
||||
})
|
||||
}
|
||||
const onClickScrollToBottom = () => {
|
||||
userHasScrolledUp.value = false;
|
||||
scrollToBottom(true);
|
||||
}
|
||||
const debounce = (fn, delay) => {
|
||||
let timer
|
||||
return (...args) => {
|
||||
|
|
@ -239,7 +285,11 @@ const onChatScrollTop = () => {
|
|||
getmsgList(data, true, scrollHeight);
|
||||
}
|
||||
}
|
||||
const handleScroll = debounce(onChatScrollTop, 500);
|
||||
const debouncedScrollTop = debounce(onChatScrollTop, 500);
|
||||
const handleScroll = () => {
|
||||
userHasScrolledUp.value = !isNearBottom();
|
||||
debouncedScrollTop();
|
||||
};
|
||||
|
||||
const getmsgList = (data, isScrollType = false, scrollHeight) => {
|
||||
getMessageList(data).then(res => {
|
||||
|
|
@ -247,6 +297,8 @@ const getmsgList = (data, isScrollType = false, scrollHeight) => {
|
|||
created_at.value = res.data[0].created_at;
|
||||
handleMsgList(res.data, isScrollType, scrollHeight);
|
||||
}
|
||||
}).finally(() => {
|
||||
historyLoading.value = false;
|
||||
})
|
||||
}
|
||||
|
||||
|
|
@ -381,7 +433,7 @@ const handleMsgList = async (data, isScrollType = false, newScrollHeight) => {
|
|||
}
|
||||
messagesList.unshift(item);
|
||||
if (isFirstEnter.value) {
|
||||
scrollToBottom();
|
||||
scrollToBottom(true);
|
||||
} else if (isScrollType) {
|
||||
nextTick(() => {
|
||||
const { scrollHeight } = scrollContainer.value;
|
||||
|
|
@ -473,8 +525,9 @@ const sendMsg = async (value, modelId = '', mentionedItems = [], imageFiles = []
|
|||
}
|
||||
|
||||
// 将@提及的知识库和文件信息存入用户消息
|
||||
messagesList.push({ content: value, role: 'user', mentioned_items: mentionedItems, images: userImages, attachments: attachmentFiles.map(a => ({ file_name: a.name, file_size: a.size, file_type: '.' + a.name.split('.').pop()?.toLowerCase() })), channel: 'web' });
|
||||
scrollToBottom();
|
||||
messagesList.push({ content: value, role: 'user', mentioned_items: mentionedItems, images: userImages, attachments: attachmentFiles.map(a => ({ file_name: a.name, file_size: a.size, file_type: '.' + a.name.split('.').pop()?.toLowerCase() })), channel: 'web' });
|
||||
userHasScrolledUp.value = false;
|
||||
scrollToBottom(true);
|
||||
|
||||
// Get agent mode status from settings store
|
||||
const agentEnabled = useSettingsStoreInstance.isAgentEnabled;
|
||||
|
|
@ -637,7 +690,7 @@ onChunk((data) => {
|
|||
};
|
||||
messagesList.push(existingMessage);
|
||||
loading.value = false; // 消息已创建,关闭 loading
|
||||
scrollToBottom();
|
||||
scrollToBottom(true);
|
||||
}
|
||||
|
||||
existingMessage.knowledge_references = data.knowledge_references || data.data?.references || [];
|
||||
|
|
@ -739,7 +792,7 @@ const handleAgentChunk = (data) => {
|
|||
};
|
||||
messagesList.push(newMsg);
|
||||
loading.value = false; // 消息已创建,关闭 loading
|
||||
scrollToBottom();
|
||||
scrollToBottom(true);
|
||||
// Don't return - continue to process the current event data
|
||||
message = newMsg;
|
||||
}
|
||||
|
|
@ -1110,7 +1163,8 @@ onMounted(async () => {
|
|||
checkmenuTitle(session_id.value)
|
||||
if (firstQuery.value) {
|
||||
scrollLock.value = true;
|
||||
sendMsg(firstQuery.value, firstModelId.value || '', firstMentionedItems.value || [], firstImageFiles.value || [], firstAttachmentFiles.value || []);
|
||||
historyLoading.value = false;
|
||||
sendMsg(firstQuery.value, firstModelId.value || '', firstMentionedItems.value || [], firstImageFiles.value || [], firstAttachmentFiles.value || []);
|
||||
usemenuStore.changeFirstQuery('', [], '', [], []);
|
||||
} else {
|
||||
scrollLock.value = false;
|
||||
|
|
@ -1179,6 +1233,45 @@ onBeforeRouteUpdate((to, from, next) => {
|
|||
}
|
||||
}
|
||||
|
||||
.scroll-to-bottom-btn {
|
||||
position: absolute;
|
||||
left: 50%;
|
||||
transform: translateX(-50%);
|
||||
bottom: 140px;
|
||||
z-index: 10;
|
||||
width: 36px;
|
||||
height: 36px;
|
||||
border-radius: 50%;
|
||||
background: var(--td-bg-color-container);
|
||||
border: 1px solid var(--td-component-stroke);
|
||||
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
cursor: pointer;
|
||||
color: var(--td-text-color-secondary);
|
||||
transition: all 0.2s ease;
|
||||
|
||||
&:hover {
|
||||
background: var(--td-bg-color-container-hover);
|
||||
color: var(--td-text-color-primary);
|
||||
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
|
||||
}
|
||||
|
||||
&:active {
|
||||
transform: translateX(-50%) scale(0.92);
|
||||
}
|
||||
}
|
||||
|
||||
.scroll-btn-fade-enter-active,
|
||||
.scroll-btn-fade-leave-active {
|
||||
transition: opacity 0.2s ease, transform 0.2s ease;
|
||||
}
|
||||
.scroll-btn-fade-enter-from,
|
||||
.scroll-btn-fade-leave-to {
|
||||
opacity: 0;
|
||||
transform: translateX(-50%) translateY(8px);
|
||||
}
|
||||
|
||||
.agent-mode-indicator {
|
||||
display: flex;
|
||||
|
|
@ -1204,6 +1297,30 @@ onBeforeRouteUpdate((to, from, next) => {
|
|||
}
|
||||
}
|
||||
|
||||
@keyframes contentFadeIn {
|
||||
from { opacity: 0; transform: translateY(6px); }
|
||||
to { opacity: 1; transform: translateY(0); }
|
||||
}
|
||||
|
||||
.msg-skeleton-list {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 20px;
|
||||
max-width: 800px;
|
||||
padding: 16px 0;
|
||||
animation: contentFadeIn 0.3s ease-out;
|
||||
}
|
||||
.msg-skeleton-user {
|
||||
display: flex;
|
||||
justify-content: flex-end;
|
||||
}
|
||||
.msg-skeleton-bot {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 8px;
|
||||
padding-left: 4px;
|
||||
}
|
||||
|
||||
.msg_list {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
|
|
@ -1276,6 +1393,7 @@ onBeforeRouteUpdate((to, from, next) => {
|
|||
flex-direction: column;
|
||||
align-items: center;
|
||||
width: 100%;
|
||||
animation: contentFadeIn 0.3s ease-out;
|
||||
}
|
||||
|
||||
.sq-fade-enter-active,
|
||||
|
|
|
|||
|
|
@ -1,12 +1,21 @@
|
|||
<template>
|
||||
<div class="dialogue-wrap">
|
||||
<div class="dialogue-answers">
|
||||
<div class="dialogue-title">
|
||||
<span>{{ $t('createChat.title') }}</span>
|
||||
<div class="dialogue-title" style="--wails-draggable: drag">
|
||||
<span style="--wails-draggable: drag">{{ $t('createChat.title') }}</span>
|
||||
</div>
|
||||
<!-- 推荐问题 -->
|
||||
<div ref="sqContainerRef" class="suggested-questions-container">
|
||||
<transition name="sq-slide-fade" mode="out-in"
|
||||
<!-- 骨架屏占位 -->
|
||||
<div v-if="sqLoading && suggestedQuestions.length === 0" class="suggested-questions-inner">
|
||||
<div class="suggested-questions-title"><t-skeleton animation="gradient" :row-col="[{ width: '120px', height: '18px' }]" /></div>
|
||||
<div class="suggested-questions-grid">
|
||||
<div v-for="n in 6" :key="'sq-skel-'+n" class="suggested-question-card sq-card-skeleton">
|
||||
<t-skeleton animation="gradient" :row-col="[{ width: '90%', height: '14px' }, { width: '60%', height: '14px' }]" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<transition v-else appear name="sq-slide-fade" mode="out-in"
|
||||
@before-leave="onBeforeLeave"
|
||||
@after-leave="onAfterLeave"
|
||||
@enter="onEnter"
|
||||
|
|
@ -69,6 +78,7 @@ const { navigateToKnowledgeBaseList } = useKnowledgeBaseCreationNavigation();
|
|||
|
||||
// ===== 推荐问题 =====
|
||||
const suggestedQuestions = ref<SuggestedQuestion[]>([]);
|
||||
const sqLoading = ref(true);
|
||||
const sqCardsRevealed = ref(false);
|
||||
const sqRenderKey = ref(0);
|
||||
const sqContainerRef = ref<HTMLElement | null>(null);
|
||||
|
|
@ -119,7 +129,7 @@ const onQuestionsEntered = () => {
|
|||
|
||||
const fetchSuggestedQuestions = async () => {
|
||||
const fetchId = ++suggestedQuestionsFetchId;
|
||||
// 加载期间保留旧数据,不清空,避免布局抖动
|
||||
if (suggestedQuestions.value.length === 0) sqLoading.value = true;
|
||||
try {
|
||||
const agentId = settingsStore.selectedAgentId;
|
||||
if (!agentId) return;
|
||||
|
|
@ -140,6 +150,10 @@ const fetchSuggestedQuestions = async () => {
|
|||
if (fetchId === suggestedQuestionsFetchId) {
|
||||
suggestedQuestions.value = [];
|
||||
}
|
||||
} finally {
|
||||
if (fetchId === suggestedQuestionsFetchId) {
|
||||
sqLoading.value = false;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
|
@ -277,11 +291,17 @@ const handleKBEditorSuccess = (kbId: string) => {
|
|||
transition: height 0.35s cubic-bezier(0.4, 0, 0.2, 1);
|
||||
}
|
||||
|
||||
@keyframes skeletonFadeIn {
|
||||
from { opacity: 0; }
|
||||
to { opacity: 1; }
|
||||
}
|
||||
|
||||
.suggested-questions-inner {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
width: 100%;
|
||||
animation: skeletonFadeIn 0.3s ease-out;
|
||||
}
|
||||
|
||||
// 容器整体过渡:淡入 + 轻微上滑
|
||||
|
|
@ -335,6 +355,12 @@ const handleKBEditorSuccess = (kbId: string) => {
|
|||
background 0.2s ease,
|
||||
box-shadow 0.2s ease;
|
||||
|
||||
&.sq-card-skeleton {
|
||||
opacity: 1;
|
||||
transform: none;
|
||||
cursor: default;
|
||||
}
|
||||
|
||||
&.sq-card-visible {
|
||||
opacity: 1;
|
||||
transform: translateY(0) scale(1);
|
||||
|
|
|
|||
|
|
@ -42,6 +42,7 @@ const uploadInputRef = ref<HTMLInputElement | null>(null);
|
|||
const folderUploadInputRef = ref<HTMLInputElement | null>(null);
|
||||
const uploading = ref(false);
|
||||
const kbLoading = ref(false);
|
||||
const docListLoading = ref(true);
|
||||
const isFAQ = computed(() => (kbInfo.value?.type || '') === 'faq');
|
||||
const missingStorageEngine = computed(() => {
|
||||
if (!kbInfo.value || isFAQ.value) return false
|
||||
|
|
@ -210,6 +211,18 @@ const fileTypeOptions = computed(() => [
|
|||
{ content: 'MD', value: 'md' },
|
||||
{ content: 'URL', value: 'url' },
|
||||
{ content: t('knowledgeBase.typeManual'), value: 'manual' },
|
||||
{ content: 'MP4', value: 'mp4' },
|
||||
{ content: 'MOV', value: 'mov' },
|
||||
{ content: 'AVI', value: 'avi' },
|
||||
{ content: 'MKV', value: 'mkv' },
|
||||
{ content: 'WEBM', value: 'webm' },
|
||||
{ content: 'WMV', value: 'wmv' },
|
||||
{ content: 'FLV', value: 'flv' },
|
||||
{ content: 'MP3', value: 'mp3' },
|
||||
{ content: 'WAV', value: 'wav' },
|
||||
{ content: 'M4A', value: 'm4a' },
|
||||
{ content: 'FLAC', value: 'flac' },
|
||||
{ content: 'OGG', value: 'ogg' },
|
||||
]);
|
||||
type TagInputInstance = ComponentPublicInstance<{ focus: () => void; select: () => void }>;
|
||||
const tagDropdownOptions = computed(() =>
|
||||
|
|
@ -554,6 +567,7 @@ const loadKnowledgeBaseInfo = async (targetKbId: string) => {
|
|||
// 重置store中的标签选择状态,避免上传文档时自动带上之前选择的标签
|
||||
uiStore.setSelectedTagId('');
|
||||
if (!isFAQ.value) {
|
||||
docListLoading.value = true;
|
||||
loadKnowledgeFiles(targetKbId);
|
||||
} else {
|
||||
cardList.value = [];
|
||||
|
|
@ -711,6 +725,7 @@ onUnmounted(() => {
|
|||
});
|
||||
watch(() => cardList.value, (newValue) => {
|
||||
if (isFAQ.value) return;
|
||||
docListLoading.value = false;
|
||||
|
||||
// Auto-open document if navigated with ?knowledge_id=xxx
|
||||
if (pendingKnowledgeId.value && newValue?.length) {
|
||||
|
|
@ -1115,11 +1130,14 @@ const handleFolderUpload = async (event: Event) => {
|
|||
}
|
||||
|
||||
const vlmEnabled = kbInfo.value?.vlm_config?.enabled || false;
|
||||
const asrEnabled = kbInfo.value?.asr_config?.enabled || false;
|
||||
const dynamicTypes = supportedFileTypes.value.size > 0 ? supportedFileTypes.value : undefined
|
||||
|
||||
const validFiles: File[] = [];
|
||||
let hiddenFileCount = 0;
|
||||
let imageFilteredCount = 0;
|
||||
let videoFilteredCount = 0;
|
||||
let audioFilteredCount = 0;
|
||||
|
||||
for (let i = 0; i < files.length; i++) {
|
||||
const file = files[i];
|
||||
|
|
@ -1132,13 +1150,25 @@ const handleFolderUpload = async (event: Event) => {
|
|||
continue;
|
||||
}
|
||||
|
||||
const fileExt = file.name.substring(file.name.lastIndexOf('.') + 1).toLowerCase();
|
||||
const imageTypes = ['jpg', 'jpeg', 'png', 'gif', 'bmp', 'webp'];
|
||||
const videoTypes = ['mp4', 'mov', 'avi', 'mkv', 'webm', 'wmv', 'flv'];
|
||||
const audioTypes = ['mp3', 'wav', 'm4a', 'flac', 'ogg'];
|
||||
|
||||
if (!vlmEnabled) {
|
||||
const fileExt = file.name.substring(file.name.lastIndexOf('.') + 1).toLowerCase();
|
||||
const imageTypes = ['jpg', 'jpeg', 'png', 'gif', 'bmp', 'webp'];
|
||||
if (imageTypes.includes(fileExt)) {
|
||||
imageFilteredCount++;
|
||||
continue;
|
||||
}
|
||||
if (videoTypes.includes(fileExt)) {
|
||||
videoFilteredCount++;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
if (!asrEnabled && audioTypes.includes(fileExt)) {
|
||||
audioFilteredCount++;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!kbFileTypeVerification(file, true, dynamicTypes)) {
|
||||
|
|
@ -1151,7 +1181,6 @@ const handleFolderUpload = async (event: Event) => {
|
|||
if (input) input.value = '';
|
||||
return;
|
||||
}
|
||||
|
||||
MessagePlugin.info(t('knowledgeBase.uploadingFolder', { total: validFiles.length }));
|
||||
|
||||
// 批量上传
|
||||
|
|
@ -1444,8 +1473,13 @@ async function createNewSession(value: string): Promise<void> {
|
|||
:disabled="!kbId"
|
||||
@click.stop="handleNavigateToCurrentKB"
|
||||
>
|
||||
<span>{{ kbInfo?.name || '--' }}</span>
|
||||
<t-icon name="chevron-down" />
|
||||
<template v-if="!kbInfo">
|
||||
<t-skeleton animation="gradient" :row-col="[{ width: '120px', height: '20px' }]" />
|
||||
</template>
|
||||
<template v-else>
|
||||
<span>{{ kbInfo.name }}</span>
|
||||
<t-icon name="chevron-down" />
|
||||
</template>
|
||||
</button>
|
||||
</t-dropdown>
|
||||
<button
|
||||
|
|
@ -1455,13 +1489,18 @@ async function createNewSession(value: string): Promise<void> {
|
|||
:disabled="!kbId"
|
||||
@click="handleNavigateToCurrentKB"
|
||||
>
|
||||
{{ kbInfo?.name || '--' }}
|
||||
<template v-if="!kbInfo">
|
||||
<t-skeleton animation="gradient" :row-col="[{ width: '120px', height: '20px' }]" />
|
||||
</template>
|
||||
<template v-else>
|
||||
{{ kbInfo.name }}
|
||||
</template>
|
||||
</button>
|
||||
<t-icon name="chevron-right" class="breadcrumb-separator" />
|
||||
<span class="breadcrumb-current">{{ $t('knowledgeEditor.document.title') }}</span>
|
||||
</h2>
|
||||
<!-- 身份与最后更新:紧凑单行,置于标题行右侧,悬停显示权限说明 -->
|
||||
<div v-if="kbInfo" class="kb-access-meta">
|
||||
<div v-if="kbInfo && !authStore.isLiteMode" class="kb-access-meta">
|
||||
<t-tooltip :content="accessPermissionSummary" placement="top">
|
||||
<span class="kb-access-meta-inner">
|
||||
<t-tag size="small" :theme="isOwner ? 'success' : (effectiveKBPermission === 'admin' ? 'primary' : effectiveKBPermission === 'editor' ? 'warning' : 'default')" class="kb-access-role-tag">
|
||||
|
|
@ -1514,7 +1553,7 @@ async function createNewSession(value: string): Promise<void> {
|
|||
ref="uploadInputRef"
|
||||
type="file"
|
||||
class="document-upload-input"
|
||||
:accept="acceptFileTypes || '.pdf,.docx,.doc,.txt,.md,.json,.jpg,.jpeg,.png,.csv,.xlsx,.xls,.pptx,.ppt,.mp3,.wav,.m4a,.flac,.ogg'"
|
||||
:accept="acceptFileTypes || '.pdf,.docx,.doc,.txt,.md,.json,.jpg,.jpeg,.png,.csv,.xlsx,.xls,.pptx,.ppt,.mp3,.wav,.m4a,.flac,.ogg,.mp4,.mov,.avi,.mkv,.webm,.wmv,.flv'"
|
||||
multiple
|
||||
@change="handleDocumentUpload"
|
||||
/>
|
||||
|
|
@ -1541,7 +1580,7 @@ async function createNewSession(value: string): Promise<void> {
|
|||
:title="$t('knowledgeBase.tagCreateAction')"
|
||||
@click="startCreateTag"
|
||||
>
|
||||
<span class="create-tag-plus" aria-hidden="true">+</span>
|
||||
<t-icon name="add" />
|
||||
</t-button>
|
||||
</div>
|
||||
</div>
|
||||
|
|
@ -1557,11 +1596,18 @@ async function createNewSession(value: string): Promise<void> {
|
|||
</template>
|
||||
</t-input>
|
||||
</div>
|
||||
<t-loading :loading="tagLoading" size="small">
|
||||
<div class="tag-list">
|
||||
<div class="tag-list">
|
||||
<template v-if="tagLoading && !filteredTags.length">
|
||||
<div v-for="n in 8" :key="'skel-tag-'+n" class="tag-list-item" style="cursor: default; pointer-events: none;">
|
||||
<div class="tag-list-left" style="gap: 12px; width: 100%;">
|
||||
<t-skeleton animation="gradient" :row-col="[{ width: '80%', height: '18px' }]" />
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
<template v-else>
|
||||
<div v-if="creatingTag" class="tag-list-item tag-editing" @click.stop>
|
||||
<div class="tag-list-left">
|
||||
<t-icon name="folder" size="18px" />
|
||||
<span class="tag-hash-icon">#</span>
|
||||
<div class="tag-edit-input">
|
||||
<t-input
|
||||
ref="newTagInputRef"
|
||||
|
|
@ -1606,7 +1652,7 @@ async function createNewSession(value: string): Promise<void> {
|
|||
@click="handleTagRowClick(tag.id)"
|
||||
>
|
||||
<div class="tag-list-left">
|
||||
<t-icon name="folder" size="18px" />
|
||||
<span class="tag-hash-icon">#</span>
|
||||
<template v-if="editingTagId === tag.id">
|
||||
<div class="tag-edit-input" @click.stop>
|
||||
<t-input
|
||||
|
|
@ -1685,8 +1731,8 @@ async function createNewSession(value: string): Promise<void> {
|
|||
{{ $t('tenant.loadMore') }}
|
||||
</t-button>
|
||||
</div>
|
||||
</div>
|
||||
</t-loading>
|
||||
</template>
|
||||
</div>
|
||||
</aside>
|
||||
<div class="tag-content">
|
||||
<div class="doc-card-area">
|
||||
|
|
@ -1732,8 +1778,22 @@ async function createNewSession(value: string): Promise<void> {
|
|||
ref="knowledgeScroll"
|
||||
@scroll="handleScroll"
|
||||
>
|
||||
<template v-if="cardList.length">
|
||||
<div class="doc-card-list">
|
||||
<!-- 文档骨架屏 -->
|
||||
<div v-if="docListLoading && cardList.length === 0" class="doc-card-list doc-card-list-animated">
|
||||
<div v-for="n in 8" :key="'doc-skel-'+n" class="knowledge-card knowledge-card-skeleton">
|
||||
<div class="card-content">
|
||||
<div class="card-content-nav">
|
||||
<t-skeleton animation="gradient" :row-col="[{ width: '70%', height: '18px' }]" />
|
||||
</div>
|
||||
<t-skeleton animation="gradient" :row-col="[{ width: '100%', height: '14px' }, { width: '60%', height: '14px' }]" />
|
||||
</div>
|
||||
<div class="card-bottom">
|
||||
<t-skeleton animation="gradient" :row-col="[[{ width: '80px', height: '14px' }, { width: '40px', height: '18px', type: 'rect' }]]" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<template v-else-if="cardList.length">
|
||||
<div class="doc-card-list doc-card-list-animated">
|
||||
<!-- 现有文档卡片 -->
|
||||
<div
|
||||
class="knowledge-card"
|
||||
|
|
@ -1952,7 +2012,7 @@ async function createNewSession(value: string): Promise<void> {
|
|||
</div>
|
||||
</Teleport>
|
||||
</template>
|
||||
<template v-else>
|
||||
<template v-else-if="!docListLoading">
|
||||
<div class="doc-empty-state">
|
||||
<EmptyKnowledge />
|
||||
</div>
|
||||
|
|
@ -2078,19 +2138,18 @@ async function createNewSession(value: string): Promise<void> {
|
|||
display: flex;
|
||||
flex: 1;
|
||||
min-height: 0;
|
||||
background: var(--td-bg-color-container);
|
||||
border: 1px solid var(--td-component-stroke);
|
||||
border-radius: 10px;
|
||||
overflow: hidden;
|
||||
background: transparent;
|
||||
border: none;
|
||||
}
|
||||
|
||||
// 与列表页筛选区一致:白底卡片感、细分界
|
||||
// 贴近整体系统设计语言的极简侧栏(对齐 menu 与右侧主窗口质感)
|
||||
.tag-sidebar {
|
||||
width: 200px;
|
||||
background: var(--td-bg-color-container);
|
||||
width: 180px;
|
||||
background: transparent;
|
||||
border: none;
|
||||
border-right: 1px solid var(--td-component-stroke);
|
||||
box-shadow: 2px 0 8px rgba(0, 0, 0, 0.04);
|
||||
padding: 16px;
|
||||
box-shadow: 1px 0 0 rgba(0, 0, 0, 0.02);
|
||||
padding: 0 16px 0 0;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
flex-shrink: 0;
|
||||
|
|
@ -2101,62 +2160,71 @@ async function createNewSession(value: string): Promise<void> {
|
|||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
margin-bottom: 10px;
|
||||
margin-bottom: 12px;
|
||||
padding: 0 4px;
|
||||
color: var(--td-text-color-primary);
|
||||
|
||||
.sidebar-title {
|
||||
display: flex;
|
||||
align-items: baseline;
|
||||
gap: 4px;
|
||||
font-size: 13px;
|
||||
gap: 6px;
|
||||
font-size: 14px;
|
||||
font-weight: 600;
|
||||
letter-spacing: 0.5px;
|
||||
|
||||
.sidebar-count {
|
||||
font-size: 12px;
|
||||
color: var(--td-text-color-secondary);
|
||||
color: var(--td-text-color-placeholder);
|
||||
font-weight: 400;
|
||||
}
|
||||
}
|
||||
|
||||
.sidebar-actions {
|
||||
display: flex;
|
||||
gap: 6px;
|
||||
color: var(--td-text-color-placeholder);
|
||||
align-items: center;
|
||||
|
||||
.create-tag-btn {
|
||||
width: 24px;
|
||||
height: 24px;
|
||||
padding: 0;
|
||||
border-radius: 6px;
|
||||
border-radius: 4px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
font-size: 16px;
|
||||
font-weight: 600;
|
||||
color: var(--td-success-color);
|
||||
line-height: 1;
|
||||
transition: background 0.2s ease, color 0.2s ease;
|
||||
color: var(--td-text-color-secondary);
|
||||
transition: all 0.2s ease;
|
||||
|
||||
.t-icon {
|
||||
font-size: 16px;
|
||||
}
|
||||
|
||||
&:hover {
|
||||
background: var(--td-bg-color-secondarycontainer);
|
||||
color: var(--td-brand-color-active);
|
||||
color: var(--td-brand-color);
|
||||
}
|
||||
}
|
||||
|
||||
.create-tag-plus {
|
||||
line-height: 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.tag-search-bar {
|
||||
margin-bottom: 10px;
|
||||
margin-bottom: 12px;
|
||||
padding: 0 4px;
|
||||
|
||||
:deep(.t-input) {
|
||||
font-size: 13px;
|
||||
background-color: var(--td-bg-color-container);
|
||||
border-color: var(--td-component-stroke);
|
||||
background-color: var(--td-bg-color-secondarycontainer);
|
||||
border-color: transparent;
|
||||
border-radius: 6px;
|
||||
box-shadow: none !important;
|
||||
|
||||
&:hover,
|
||||
&:focus,
|
||||
&.t-is-focused {
|
||||
border-color: var(--td-brand-color);
|
||||
background-color: var(--td-bg-color-container);
|
||||
box-shadow: none !important;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -2190,13 +2258,13 @@ async function createNewSession(value: string): Promise<void> {
|
|||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
padding: 9px 12px;
|
||||
padding: 8px 8px;
|
||||
border-radius: 6px;
|
||||
color: var(--td-text-color-primary);
|
||||
cursor: pointer;
|
||||
transition: all 0.2s ease;
|
||||
font-family: "PingFang SC", -apple-system, BlinkMacSystemFont, sans-serif;
|
||||
font-size: 14px;
|
||||
font-size: 13px;
|
||||
-webkit-font-smoothing: antialiased;
|
||||
|
||||
.tag-list-left {
|
||||
|
|
@ -2206,12 +2274,25 @@ async function createNewSession(value: string): Promise<void> {
|
|||
min-width: 0;
|
||||
flex: 1;
|
||||
|
||||
.t-icon {
|
||||
.t-icon,
|
||||
.tag-hash-icon {
|
||||
flex-shrink: 0;
|
||||
color: var(--td-text-color-secondary);
|
||||
font-size: 14px;
|
||||
transition: color 0.2s ease;
|
||||
}
|
||||
|
||||
.t-icon {
|
||||
font-size: 16px;
|
||||
}
|
||||
|
||||
.tag-hash-icon {
|
||||
font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
|
||||
font-size: 16px;
|
||||
font-weight: 500;
|
||||
width: 16px;
|
||||
text-align: center;
|
||||
display: inline-block;
|
||||
}
|
||||
}
|
||||
|
||||
.tag-name {
|
||||
|
|
@ -2221,10 +2302,9 @@ async function createNewSession(value: string): Promise<void> {
|
|||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
font-family: "PingFang SC", -apple-system, BlinkMacSystemFont, sans-serif;
|
||||
font-size: 14px;
|
||||
font-weight: 450;
|
||||
font-size: 13px;
|
||||
font-weight: 400;
|
||||
line-height: 1.4;
|
||||
letter-spacing: 0.01em;
|
||||
}
|
||||
|
||||
.tag-list-right {
|
||||
|
|
@ -2237,37 +2317,34 @@ async function createNewSession(value: string): Promise<void> {
|
|||
|
||||
.tag-count {
|
||||
font-size: 12px;
|
||||
color: var(--td-text-color-secondary);
|
||||
font-weight: 500;
|
||||
min-width: 28px;
|
||||
padding: 3px 7px;
|
||||
border-radius: 8px;
|
||||
background: var(--td-bg-color-secondarycontainer);
|
||||
color: var(--td-text-color-placeholder);
|
||||
font-weight: 400;
|
||||
transition: all 0.2s ease;
|
||||
text-align: center;
|
||||
box-sizing: border-box;
|
||||
text-align: right;
|
||||
padding-left: 8px;
|
||||
background: transparent;
|
||||
}
|
||||
|
||||
&:hover {
|
||||
background: var(--td-bg-color-secondarycontainer);
|
||||
color: var(--td-text-color-primary);
|
||||
|
||||
.tag-list-left .t-icon {
|
||||
color: var(--td-text-color-primary);
|
||||
.tag-list-left .t-icon,
|
||||
.tag-list-left .tag-hash-icon {
|
||||
color: var(--td-text-color-secondary);
|
||||
}
|
||||
|
||||
.tag-count {
|
||||
background: var(--td-bg-color-secondarycontainer);
|
||||
color: var(--td-text-color-primary);
|
||||
color: var(--td-text-color-secondary);
|
||||
}
|
||||
}
|
||||
|
||||
&.active {
|
||||
background: var(--td-success-color-light);
|
||||
background: var(--td-brand-color-light);
|
||||
color: var(--td-brand-color);
|
||||
font-weight: 500;
|
||||
|
||||
.tag-list-left .t-icon {
|
||||
.tag-list-left .t-icon,
|
||||
.tag-list-left .tag-hash-icon {
|
||||
color: var(--td-brand-color);
|
||||
}
|
||||
|
||||
|
|
@ -2276,9 +2353,7 @@ async function createNewSession(value: string): Promise<void> {
|
|||
}
|
||||
|
||||
.tag-count {
|
||||
background: var(--td-success-color-light);
|
||||
color: var(--td-brand-color);
|
||||
font-weight: 600;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -2322,22 +2397,22 @@ async function createNewSession(value: string): Promise<void> {
|
|||
}
|
||||
|
||||
:deep(.tag-action-btn.confirm) {
|
||||
background: var(--td-success-color-light);
|
||||
color: var(--td-brand-color-active);
|
||||
|
||||
&:hover {
|
||||
background: var(--td-success-color-light);
|
||||
color: var(--td-success-color);
|
||||
}
|
||||
}
|
||||
|
||||
:deep(.tag-action-btn.cancel) {
|
||||
background: var(--td-bg-color-secondarycontainer);
|
||||
background: transparent;
|
||||
color: var(--td-text-color-secondary);
|
||||
|
||||
&:hover {
|
||||
background: var(--td-bg-color-secondarycontainer);
|
||||
color: var(--td-text-color-secondary);
|
||||
color: var(--td-brand-color);
|
||||
}
|
||||
}
|
||||
|
||||
:deep(.tag-action-btn.cancel) {
|
||||
background: transparent;
|
||||
color: var(--td-text-color-secondary);
|
||||
|
||||
&:hover {
|
||||
background: var(--td-bg-color-secondarycontainer);
|
||||
color: var(--td-error-color);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -2348,48 +2423,38 @@ async function createNewSession(value: string): Promise<void> {
|
|||
max-width: 100%;
|
||||
|
||||
:deep(.t-input) {
|
||||
font-size: 12px;
|
||||
font-size: 13px;
|
||||
background-color: transparent;
|
||||
border: none;
|
||||
border-bottom: 1px solid var(--td-component-stroke);
|
||||
border-radius: 0;
|
||||
box-shadow: none;
|
||||
padding-left: 0;
|
||||
padding-right: 0;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
:deep(.t-input__wrap) {
|
||||
background-color: transparent;
|
||||
border: none;
|
||||
border-bottom: 1px solid var(--td-component-stroke);
|
||||
border-radius: 0;
|
||||
box-shadow: none;
|
||||
}
|
||||
|
||||
:deep(.t-input__inner) {
|
||||
padding-left: 0;
|
||||
padding-right: 0;
|
||||
padding: 0;
|
||||
color: var(--td-text-color-primary);
|
||||
caret-color: var(--td-text-color-primary);
|
||||
caret-color: var(--td-brand-color);
|
||||
}
|
||||
|
||||
:deep(.t-input:hover),
|
||||
:deep(.t-input.t-is-focused),
|
||||
:deep(.t-input__wrap:hover),
|
||||
:deep(.t-input__wrap.t-is-focused) {
|
||||
border-bottom-color: var(--td-success-color);
|
||||
border-color: transparent;
|
||||
}
|
||||
}
|
||||
|
||||
.tag-more {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
opacity: 0;
|
||||
transition: opacity 0.2s ease;
|
||||
}
|
||||
|
||||
&:hover .tag-more {
|
||||
opacity: 1;
|
||||
}
|
||||
|
||||
.tag-more-btn {
|
||||
|
|
@ -2399,7 +2464,7 @@ async function createNewSession(value: string): Promise<void> {
|
|||
align-items: center;
|
||||
justify-content: center;
|
||||
border-radius: 4px;
|
||||
color: var(--td-text-color-secondary);
|
||||
color: var(--td-text-color-placeholder);
|
||||
transition: all 0.2s ease;
|
||||
|
||||
&:hover {
|
||||
|
|
@ -2413,7 +2478,7 @@ async function createNewSession(value: string): Promise<void> {
|
|||
text-align: center;
|
||||
padding: 10px 6px;
|
||||
color: var(--td-text-color-placeholder);
|
||||
font-size: 11px;
|
||||
font-size: 12px;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -2464,9 +2529,10 @@ async function createNewSession(value: string): Promise<void> {
|
|||
display: flex;
|
||||
flex-direction: column;
|
||||
min-height: 0;
|
||||
padding: 12px;
|
||||
padding: 0 0 0 16px;
|
||||
border: none;
|
||||
overflow: hidden;
|
||||
background: var(--td-bg-color-container);
|
||||
background: transparent;
|
||||
}
|
||||
|
||||
.doc-card-area {
|
||||
|
|
@ -2508,29 +2574,33 @@ async function createNewSession(value: string): Promise<void> {
|
|||
|
||||
:deep(.t-input) {
|
||||
font-size: 13px;
|
||||
background-color: var(--td-bg-color-container);
|
||||
border-color: var(--td-component-stroke);
|
||||
background-color: var(--td-bg-color-secondarycontainer);
|
||||
border-color: transparent;
|
||||
border-radius: 6px;
|
||||
box-shadow: none !important;
|
||||
|
||||
&:hover,
|
||||
&:focus,
|
||||
&.t-is-focused {
|
||||
border-color: var(--td-brand-color);
|
||||
background-color: var(--td-bg-color-container);
|
||||
box-shadow: none !important;
|
||||
}
|
||||
}
|
||||
|
||||
:deep(.t-select) {
|
||||
.t-input {
|
||||
font-size: 13px;
|
||||
background-color: var(--td-bg-color-container);
|
||||
border-color: var(--td-component-stroke);
|
||||
background-color: var(--td-bg-color-secondarycontainer);
|
||||
border-color: transparent;
|
||||
border-radius: 6px;
|
||||
box-shadow: none !important;
|
||||
|
||||
&:hover,
|
||||
&.t-is-focused {
|
||||
border-color: var(--td-brand-color);
|
||||
background-color: var(--td-bg-color-container);
|
||||
box-shadow: none !important;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -2872,6 +2942,11 @@ async function createNewSession(value: string): Promise<void> {
|
|||
}
|
||||
}
|
||||
|
||||
@keyframes contentFadeIn {
|
||||
from { opacity: 0; transform: translateY(6px); }
|
||||
to { opacity: 1; transform: translateY(0); }
|
||||
}
|
||||
|
||||
.doc-card-list {
|
||||
box-sizing: border-box;
|
||||
display: grid;
|
||||
|
|
@ -2879,6 +2954,29 @@ async function createNewSession(value: string): Promise<void> {
|
|||
gap: 14px;
|
||||
align-content: flex-start;
|
||||
width: 100%;
|
||||
|
||||
&.doc-card-list-animated {
|
||||
animation: contentFadeIn 0.32s ease-out;
|
||||
}
|
||||
}
|
||||
|
||||
.knowledge-card-skeleton {
|
||||
cursor: default;
|
||||
.card-content { padding: 15px 17px 13px; }
|
||||
.card-content-nav { margin-bottom: 14px; }
|
||||
.card-bottom {
|
||||
position: absolute;
|
||||
bottom: 0;
|
||||
left: 0;
|
||||
width: 100%;
|
||||
padding: 0 17px;
|
||||
box-sizing: border-box;
|
||||
height: 34px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
border-top: 1px solid var(--td-component-stroke);
|
||||
}
|
||||
}
|
||||
|
||||
.doc-empty-state {
|
||||
|
|
|
|||
|
|
@ -292,6 +292,7 @@ import { createKnowledgeBase, getKnowledgeBaseById, listKnowledgeFiles, updateKn
|
|||
import { updateKBConfig, type KBModelConfigRequest } from '@/api/initialization'
|
||||
import { listModels } from '@/api/model'
|
||||
import { useUIStore } from '@/stores/ui'
|
||||
import { useAuthStore } from '@/stores/auth'
|
||||
import KBModelConfig from './settings/KBModelConfig.vue'
|
||||
import KBParserSettings from './settings/KBParserSettings.vue'
|
||||
import KBStorageSettings from './settings/KBStorageSettings.vue'
|
||||
|
|
@ -304,6 +305,7 @@ import DataSourceSettings from './settings/DataSourceSettings.vue'
|
|||
import { useI18n } from 'vue-i18n'
|
||||
|
||||
const uiStore = useUIStore()
|
||||
const authStore = useAuthStore()
|
||||
const { t } = useI18n()
|
||||
|
||||
// Props
|
||||
|
|
@ -349,7 +351,7 @@ const navItems = computed(() => {
|
|||
items.push({ key: 'datasource', icon: 'cloud-download', label: t('knowledgeEditor.sidebar.datasource'), badge: dsCount.value || undefined })
|
||||
}
|
||||
}
|
||||
if (props.mode === 'edit' && props.kbId) {
|
||||
if (props.mode === 'edit' && props.kbId && !authStore.isLiteMode) {
|
||||
items.push({ key: 'share', icon: 'share', label: t('knowledgeEditor.sidebar.share') })
|
||||
}
|
||||
return items
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
<template>
|
||||
<div class="kb-list-container">
|
||||
<ListSpaceSidebar
|
||||
v-if="!authStore.isLiteMode"
|
||||
v-model="spaceSelection"
|
||||
:count-all="allKnowledgeBases"
|
||||
:count-mine="kbs.length"
|
||||
|
|
@ -8,23 +9,24 @@
|
|||
:count-by-org="effectiveSharedCountByOrg"
|
||||
/>
|
||||
<div class="kb-list-content">
|
||||
<div class="header">
|
||||
<div class="header-title">
|
||||
<div class="title-row">
|
||||
<h2>{{ $t('knowledgeBase.title') }}</h2>
|
||||
<div class="header" style="--wails-draggable: drag">
|
||||
<div class="header-title" style="--wails-draggable: drag">
|
||||
<div class="title-row" style="--wails-draggable: drag">
|
||||
<h2 style="--wails-draggable: drag">{{ $t('knowledgeBase.title') }}</h2>
|
||||
<t-tooltip :content="$t('knowledgeList.create')" placement="bottom">
|
||||
<t-button
|
||||
variant="text"
|
||||
theme="default"
|
||||
size="small"
|
||||
class="header-action-btn"
|
||||
style="--wails-draggable: no-drag"
|
||||
@click="handleCreateKnowledgeBase"
|
||||
>
|
||||
<template #icon><t-icon name="folder-add" size="16px" /></template>
|
||||
</t-button>
|
||||
</t-tooltip>
|
||||
</div>
|
||||
<p class="header-subtitle">{{ $t('knowledgeList.subtitle') }}</p>
|
||||
<p class="header-subtitle" style="--wails-draggable: drag">{{ $t('knowledgeList.subtitle') }}</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="kb-list-main">
|
||||
|
|
@ -76,6 +78,21 @@
|
|||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 骨架屏占位 -->
|
||||
<div v-if="loading && kbs.length === 0" class="kb-card-wrap">
|
||||
<div v-for="n in 6" :key="'skel-'+n" class="kb-card kb-card-skeleton">
|
||||
<div class="card-header">
|
||||
<t-skeleton animation="gradient" :row-col="[{ width: '60%', height: '20px' }]" />
|
||||
</div>
|
||||
<div class="card-content">
|
||||
<t-skeleton animation="gradient" :row-col="[{ width: '100%', height: '14px' }, { width: '80%', height: '14px' }]" />
|
||||
</div>
|
||||
<div class="card-bottom">
|
||||
<t-skeleton animation="gradient" :row-col="[[{ width: '28px', height: '28px', type: 'rect' }, { width: '28px', height: '28px', type: 'rect' }]]" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 卡片网格:全部 -->
|
||||
<div v-if="spaceSelection === 'all' && filteredKnowledgeBases.length > 0" class="kb-card-wrap">
|
||||
<!-- 全部:我的知识库 + 共享给我的知识库 -->
|
||||
|
|
@ -168,7 +185,7 @@
|
|||
</t-tooltip>
|
||||
</div>
|
||||
</div>
|
||||
<div class="bottom-right">
|
||||
<div v-if="!authStore.isLiteMode" class="bottom-right">
|
||||
<div class="personal-source">
|
||||
<t-icon name="user" size="14px" />
|
||||
<span>{{ $t('knowledgeList.myLabel') }}</span>
|
||||
|
|
@ -342,7 +359,7 @@
|
|||
</t-tooltip>
|
||||
</div>
|
||||
</div>
|
||||
<div class="bottom-right">
|
||||
<div v-if="!authStore.isLiteMode" class="bottom-right">
|
||||
<div class="personal-source">
|
||||
<t-icon name="user" size="14px" />
|
||||
<span>{{ $t('knowledgeList.myLabel') }}</span>
|
||||
|
|
@ -605,6 +622,7 @@ import { MessagePlugin, Icon as TIcon } from 'tdesign-vue-next'
|
|||
import { listKnowledgeBases, deleteKnowledgeBase, togglePinKnowledgeBase } from '@/api/knowledge-base'
|
||||
import { formatStringDate } from '@/utils/index'
|
||||
import { useUIStore } from '@/stores/ui'
|
||||
import { useAuthStore } from '@/stores/auth'
|
||||
import { useOrganizationStore } from '@/stores/organization'
|
||||
import { listOrganizationSharedKnowledgeBases, type SharedKnowledgeBase, type OrganizationSharedKnowledgeBaseItem, type SourceFromAgentInfo } from '@/api/organization'
|
||||
import KnowledgeBaseEditorModal from './KnowledgeBaseEditorModal.vue'
|
||||
|
|
@ -615,6 +633,7 @@ import { useI18n } from 'vue-i18n'
|
|||
const router = useRouter()
|
||||
const route = useRoute()
|
||||
const uiStore = useUIStore()
|
||||
const authStore = useAuthStore()
|
||||
const orgStore = useOrganizationStore()
|
||||
const { t } = useI18n()
|
||||
|
||||
|
|
@ -1579,10 +1598,16 @@ const handleUploadFinishedEvent = (event: Event) => {
|
|||
transition: width 0.2s ease;
|
||||
}
|
||||
|
||||
@keyframes contentFadeIn {
|
||||
from { opacity: 0; transform: translateY(6px); }
|
||||
to { opacity: 1; transform: translateY(0); }
|
||||
}
|
||||
|
||||
.kb-card-wrap {
|
||||
display: grid;
|
||||
gap: 20px;
|
||||
grid-template-columns: 1fr;
|
||||
animation: contentFadeIn 0.32s ease-out;
|
||||
}
|
||||
|
||||
.kb-card {
|
||||
|
|
@ -1601,6 +1626,13 @@ const handleUploadFinishedEvent = (event: Event) => {
|
|||
height: 160px;
|
||||
min-height: 160px;
|
||||
|
||||
&.kb-card-skeleton {
|
||||
cursor: default;
|
||||
.card-header { margin-bottom: 16px; }
|
||||
.card-content { flex: 1; }
|
||||
.card-bottom { margin-top: auto; }
|
||||
}
|
||||
|
||||
&:hover {
|
||||
border-color: var(--td-brand-color);
|
||||
box-shadow: 0 4px 12px rgba(7, 192, 95, 0.12);
|
||||
|
|
|
|||
|
|
@ -1,13 +1,13 @@
|
|||
<template>
|
||||
<div class="ks-container">
|
||||
<div class="ks-content">
|
||||
<div class="header">
|
||||
<div class="header-title">
|
||||
<h2>{{ $t('knowledgeSearch.title') }}</h2>
|
||||
<p class="header-subtitle">{{ $t('knowledgeSearch.subtitle') }}</p>
|
||||
<div class="header" style="--wails-draggable: drag">
|
||||
<div class="header-title" style="--wails-draggable: drag">
|
||||
<h2 style="--wails-draggable: drag">{{ $t('knowledgeSearch.title') }}</h2>
|
||||
<p class="header-subtitle" style="--wails-draggable: drag">{{ $t('knowledgeSearch.subtitle') }}</p>
|
||||
</div>
|
||||
<div class="header-actions">
|
||||
<t-button variant="text" shape="square" :class="{ active: showSettings }" @click="showSettings = !showSettings">
|
||||
<div class="header-actions" style="--wails-draggable: no-drag">
|
||||
<t-button variant="text" shape="square" :class="{ active: showSettings }" style="--wails-draggable: no-drag" @click="showSettings = !showSettings">
|
||||
<template #icon><t-icon name="setting" /></template>
|
||||
</t-button>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -23,8 +23,13 @@
|
|||
:disabled="!props.kbId"
|
||||
@click.stop="handleNavigateToCurrentKB"
|
||||
>
|
||||
<span>{{ kbInfo?.name || '--' }}</span>
|
||||
<t-icon name="chevron-down" />
|
||||
<template v-if="!kbInfo">
|
||||
<t-skeleton animation="gradient" :row-col="[{ width: '120px', height: '20px' }]" />
|
||||
</template>
|
||||
<template v-else>
|
||||
<span>{{ kbInfo.name }}</span>
|
||||
<t-icon name="chevron-down" />
|
||||
</template>
|
||||
</button>
|
||||
</t-dropdown>
|
||||
<button
|
||||
|
|
@ -34,13 +39,18 @@
|
|||
:disabled="!props.kbId"
|
||||
@click="handleNavigateToCurrentKB"
|
||||
>
|
||||
{{ kbInfo?.name || '--' }}
|
||||
<template v-if="!kbInfo">
|
||||
<t-skeleton animation="gradient" :row-col="[{ width: '120px', height: '20px' }]" />
|
||||
</template>
|
||||
<template v-else>
|
||||
{{ kbInfo.name }}
|
||||
</template>
|
||||
</button>
|
||||
<t-icon name="chevron-right" class="breadcrumb-separator" />
|
||||
<span class="breadcrumb-current">{{ $t('knowledgeEditor.faq.title') }}</span>
|
||||
</h2>
|
||||
<!-- 身份与最后更新:紧凑单行,置于标题行右侧,悬停显示权限说明 -->
|
||||
<div v-if="kbInfo" class="faq-access-meta">
|
||||
<div v-if="kbInfo && !authStore.isLiteMode" class="faq-access-meta">
|
||||
<t-tooltip :content="accessPermissionSummary" placement="top">
|
||||
<span class="faq-access-meta-inner">
|
||||
<t-tag size="small" :theme="isOwner ? 'success' : (effectiveKBPermission === 'admin' ? 'primary' : effectiveKBPermission === 'editor' ? 'warning' : 'default')" class="faq-access-role-tag">
|
||||
|
|
@ -206,7 +216,7 @@
|
|||
:title="$t('knowledgeBase.tagCreateAction')"
|
||||
@click="startCreateTag"
|
||||
>
|
||||
<span class="create-tag-plus" aria-hidden="true">+</span>
|
||||
<t-icon name="add" />
|
||||
</t-button>
|
||||
</div>
|
||||
</div>
|
||||
|
|
@ -222,13 +232,20 @@
|
|||
</template>
|
||||
</t-input>
|
||||
</div>
|
||||
<t-loading :loading="tagLoading" size="small">
|
||||
<div ref="tagListRef" class="faq-tag-list" @scroll="handleTagListScroll">
|
||||
<div ref="tagListRef" class="faq-tag-list" @scroll="handleTagListScroll">
|
||||
<template v-if="tagLoading && !filteredTags.length">
|
||||
<div v-for="n in 8" :key="'skel-tag-'+n" class="faq-tag-item" style="cursor: default; pointer-events: none;">
|
||||
<div class="faq-tag-left" style="gap: 12px; width: 100%;">
|
||||
<t-skeleton animation="gradient" :row-col="[{ width: '80%', height: '18px' }]" />
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
<template v-else>
|
||||
<div v-if="creatingTag" class="faq-tag-item tag-editing" @click.stop>
|
||||
<div class="faq-tag-left">
|
||||
<t-icon name="folder" size="18px" />
|
||||
<div class="tag-edit-input">
|
||||
<t-input
|
||||
<div class="faq-tag-left">
|
||||
<span class="tag-hash-icon">#</span>
|
||||
<div class="tag-edit-input">
|
||||
<t-input
|
||||
ref="newTagInputRef"
|
||||
v-model="newTagName"
|
||||
size="small"
|
||||
|
|
@ -270,9 +287,9 @@
|
|||
:class="{ active: selectedTagId === tag.seq_id, editing: editingTagId === tag.id }"
|
||||
@click="handleTagRowClick(tag.seq_id)"
|
||||
>
|
||||
<div class="faq-tag-left">
|
||||
<t-icon name="folder" size="18px" />
|
||||
<template v-if="editingTagId === tag.id">
|
||||
<div class="faq-tag-left">
|
||||
<span class="tag-hash-icon">#</span>
|
||||
<template v-if="editingTagId === tag.id">
|
||||
<div class="tag-edit-input" @click.stop>
|
||||
<t-input
|
||||
:ref="setEditingTagInputRefByTag(tag.id)"
|
||||
|
|
@ -343,8 +360,8 @@
|
|||
<div v-if="tagLoadingMore" class="tag-loading-more">
|
||||
<t-loading size="small" />
|
||||
</div>
|
||||
</div>
|
||||
</t-loading>
|
||||
</template>
|
||||
</div>
|
||||
</aside>
|
||||
|
||||
<div class="faq-card-area">
|
||||
|
|
@ -394,9 +411,22 @@
|
|||
</div>
|
||||
<!-- Card List Container with Scroll -->
|
||||
<div ref="scrollContainer" class="faq-scroll-container" @scroll="handleScroll">
|
||||
<t-loading :loading="loading && entries.length === 0" size="medium">
|
||||
<!-- FAQ 骨架屏 -->
|
||||
<div v-if="loading && entries.length === 0" class="faq-skeleton-grid">
|
||||
<div v-for="n in 6" :key="'faq-skel-'+n" class="faq-card faq-card-skeleton">
|
||||
<div class="faq-card-header">
|
||||
<t-skeleton animation="gradient" :row-col="[{ width: '80%', height: '16px' }]" />
|
||||
</div>
|
||||
<div class="faq-card-body">
|
||||
<t-skeleton animation="gradient" :row-col="[{ width: '100%', height: '13px' }, { width: '90%', height: '13px' }, { width: '60%', height: '13px' }]" />
|
||||
</div>
|
||||
<div class="faq-skel-footer">
|
||||
<t-skeleton animation="gradient" :row-col="[[{ width: '50px', height: '18px', type: 'rect' }, { width: '60px', height: '18px', type: 'rect' }]]" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- Card List -->
|
||||
<template v-if="entries.length > 0">
|
||||
<template v-else-if="entries.length > 0">
|
||||
<div ref="cardListRef" class="faq-card-list">
|
||||
<div
|
||||
v-for="entry in entries"
|
||||
|
|
@ -614,8 +644,8 @@
|
|||
</div>
|
||||
</div>
|
||||
</template>
|
||||
<template v-else>
|
||||
<div v-if="!loading" class="faq-empty-state">
|
||||
<template v-else-if="!loading">
|
||||
<div class="faq-empty-state">
|
||||
<div class="empty-content">
|
||||
<t-icon name="file-add" size="48px" class="empty-icon" />
|
||||
<div class="empty-text">{{ $t('knowledgeEditor.faq.emptyTitle') }}</div>
|
||||
|
|
@ -623,7 +653,6 @@
|
|||
</div>
|
||||
</div>
|
||||
</template>
|
||||
</t-loading>
|
||||
<div v-if="loadingMore" class="faq-load-more">
|
||||
<t-loading size="small" :text="$t('common.loading')" />
|
||||
</div>
|
||||
|
|
@ -1363,7 +1392,7 @@ const handleFaqAction = (data: { value: string }) => {
|
|||
}
|
||||
}
|
||||
|
||||
const loading = ref(false)
|
||||
const loading = ref(true)
|
||||
const loadingMore = ref(false)
|
||||
const entries = ref<FAQEntry[]>([])
|
||||
const entryStatusLoading = reactive<Record<number, boolean>>({})
|
||||
|
|
@ -3274,22 +3303,21 @@ watch(() => entries.value.map(e => ({
|
|||
display: flex;
|
||||
flex: 1;
|
||||
min-height: 0;
|
||||
background: var(--td-bg-color-container);
|
||||
border: 1px solid var(--td-component-stroke);
|
||||
border-radius: 10px;
|
||||
overflow: hidden;
|
||||
background: transparent;
|
||||
border: none;
|
||||
}
|
||||
|
||||
// 与列表页筛选区、文档型知识库标签栏一致:白底卡片感
|
||||
// 贴近整体系统设计语言的极简侧栏
|
||||
.faq-tag-panel {
|
||||
width: 200px;
|
||||
background: var(--td-bg-color-container);
|
||||
width: 180px;
|
||||
background: transparent;
|
||||
border: none;
|
||||
border-right: 1px solid var(--td-component-stroke);
|
||||
box-shadow: 2px 0 8px rgba(0, 0, 0, 0.04);
|
||||
padding: 16px;
|
||||
flex-shrink: 0;
|
||||
box-shadow: 1px 0 0 rgba(0, 0, 0, 0.02);
|
||||
padding: 0 16px 0 0;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
flex-shrink: 0;
|
||||
max-height: 100%;
|
||||
min-height: 0;
|
||||
overflow: hidden;
|
||||
|
|
@ -3308,77 +3336,88 @@ watch(() => entries.value.map(e => ({
|
|||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
margin-bottom: 10px;
|
||||
margin-bottom: 12px;
|
||||
padding: 0 4px;
|
||||
color: var(--td-text-color-primary);
|
||||
|
||||
.sidebar-title {
|
||||
display: flex;
|
||||
align-items: baseline;
|
||||
gap: 4px;
|
||||
font-size: 13px;
|
||||
gap: 6px;
|
||||
font-size: 14px;
|
||||
font-weight: 600;
|
||||
letter-spacing: 0.5px;
|
||||
|
||||
.sidebar-count {
|
||||
font-size: 12px;
|
||||
color: var(--td-text-color-secondary);
|
||||
color: var(--td-text-color-placeholder);
|
||||
font-weight: 400;
|
||||
}
|
||||
}
|
||||
|
||||
.sidebar-actions {
|
||||
display: flex;
|
||||
gap: 6px;
|
||||
color: var(--td-text-color-placeholder);
|
||||
align-items: center;
|
||||
|
||||
.create-tag-btn {
|
||||
width: 24px;
|
||||
height: 24px;
|
||||
padding: 0;
|
||||
border-radius: 6px;
|
||||
border-radius: 4px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
font-size: 16px;
|
||||
font-weight: 600;
|
||||
color: var(--td-success-color);
|
||||
line-height: 1;
|
||||
transition: background 0.2s ease, color 0.2s ease;
|
||||
color: var(--td-text-color-secondary);
|
||||
transition: all 0.2s ease;
|
||||
|
||||
.t-icon {
|
||||
font-size: 16px;
|
||||
}
|
||||
|
||||
&:hover {
|
||||
background: var(--td-bg-color-secondarycontainer);
|
||||
color: var(--td-brand-color-active);
|
||||
color: var(--td-brand-color);
|
||||
}
|
||||
}
|
||||
|
||||
.create-tag-plus {
|
||||
line-height: 1;
|
||||
}
|
||||
|
||||
.sidebar-action-icon {
|
||||
width: 24px;
|
||||
height: 24px;
|
||||
border-radius: 6px;
|
||||
border-radius: 4px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
color: var(--td-text-color-secondary);
|
||||
cursor: pointer;
|
||||
transition: background 0.2s ease, color 0.2s ease;
|
||||
transition: all 0.2s ease;
|
||||
|
||||
&:hover {
|
||||
background: var(--td-bg-color-secondarycontainer);
|
||||
color: var(--td-success-color);
|
||||
color: var(--td-brand-color);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.tag-search-bar {
|
||||
margin-bottom: 10px;
|
||||
margin-bottom: 12px;
|
||||
padding: 0 4px;
|
||||
|
||||
:deep(.t-input) {
|
||||
font-size: 12px;
|
||||
background-color: var(--td-bg-color-container);
|
||||
border-color: var(--td-component-stroke);
|
||||
font-size: 13px;
|
||||
background-color: var(--td-bg-color-secondarycontainer);
|
||||
border-color: transparent;
|
||||
border-radius: 6px;
|
||||
box-shadow: none !important;
|
||||
|
||||
&:hover,
|
||||
&:focus,
|
||||
&.t-is-focused {
|
||||
border-color: var(--td-brand-color);
|
||||
background-color: var(--td-bg-color-container);
|
||||
box-shadow: none !important;
|
||||
}
|
||||
}
|
||||
|
||||
:deep(.t-input__inner) {
|
||||
|
|
@ -3415,13 +3454,13 @@ watch(() => entries.value.map(e => ({
|
|||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
padding: 9px 12px;
|
||||
padding: 8px 8px;
|
||||
border-radius: 6px;
|
||||
color: var(--td-text-color-primary);
|
||||
cursor: pointer;
|
||||
transition: all 0.2s ease;
|
||||
font-family: "PingFang SC", -apple-system, BlinkMacSystemFont, sans-serif;
|
||||
font-size: 14px;
|
||||
font-size: 13px;
|
||||
-webkit-font-smoothing: antialiased;
|
||||
|
||||
.faq-tag-left {
|
||||
|
|
@ -3431,12 +3470,25 @@ watch(() => entries.value.map(e => ({
|
|||
min-width: 0;
|
||||
flex: 1;
|
||||
|
||||
.t-icon {
|
||||
.t-icon,
|
||||
.tag-hash-icon {
|
||||
flex-shrink: 0;
|
||||
color: var(--td-text-color-secondary);
|
||||
font-size: 14px;
|
||||
transition: color 0.2s ease;
|
||||
}
|
||||
|
||||
.t-icon {
|
||||
font-size: 16px;
|
||||
}
|
||||
|
||||
.tag-hash-icon {
|
||||
font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
|
||||
font-size: 16px;
|
||||
font-weight: 500;
|
||||
width: 16px;
|
||||
text-align: center;
|
||||
display: inline-block;
|
||||
}
|
||||
}
|
||||
|
||||
.tag-name {
|
||||
|
|
@ -3446,10 +3498,9 @@ watch(() => entries.value.map(e => ({
|
|||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
font-family: "PingFang SC", -apple-system, BlinkMacSystemFont, sans-serif;
|
||||
font-size: 14px;
|
||||
font-weight: 450;
|
||||
font-size: 13px;
|
||||
font-weight: 400;
|
||||
line-height: 1.4;
|
||||
letter-spacing: 0.01em;
|
||||
}
|
||||
|
||||
.faq-tag-right {
|
||||
|
|
@ -3462,37 +3513,34 @@ watch(() => entries.value.map(e => ({
|
|||
|
||||
.faq-tag-count {
|
||||
font-size: 12px;
|
||||
color: var(--td-text-color-secondary);
|
||||
font-weight: 500;
|
||||
min-width: 28px;
|
||||
padding: 3px 7px;
|
||||
border-radius: 8px;
|
||||
background: var(--td-bg-color-secondarycontainer);
|
||||
color: var(--td-text-color-placeholder);
|
||||
font-weight: 400;
|
||||
transition: all 0.2s ease;
|
||||
text-align: center;
|
||||
box-sizing: border-box;
|
||||
text-align: right;
|
||||
padding-left: 8px;
|
||||
background: transparent;
|
||||
}
|
||||
|
||||
&:hover {
|
||||
background: var(--td-bg-color-secondarycontainer);
|
||||
color: var(--td-text-color-primary);
|
||||
|
||||
.faq-tag-left .t-icon {
|
||||
color: var(--td-text-color-primary);
|
||||
.faq-tag-left .t-icon,
|
||||
.faq-tag-left .tag-hash-icon {
|
||||
color: var(--td-text-color-secondary);
|
||||
}
|
||||
|
||||
.faq-tag-count {
|
||||
background: var(--td-bg-color-secondarycontainer);
|
||||
color: var(--td-text-color-primary);
|
||||
color: var(--td-text-color-secondary);
|
||||
}
|
||||
}
|
||||
|
||||
&.active {
|
||||
background: var(--td-success-color-light);
|
||||
background: var(--td-brand-color-light);
|
||||
color: var(--td-brand-color);
|
||||
font-weight: 500;
|
||||
|
||||
.faq-tag-left .t-icon {
|
||||
.faq-tag-left .t-icon,
|
||||
.faq-tag-left .tag-hash-icon {
|
||||
color: var(--td-brand-color);
|
||||
}
|
||||
|
||||
|
|
@ -3501,13 +3549,7 @@ watch(() => entries.value.map(e => ({
|
|||
}
|
||||
|
||||
.faq-tag-count {
|
||||
background: var(--td-success-color-light);
|
||||
color: var(--td-brand-color);
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
&:hover {
|
||||
background: var(--td-success-color-light);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -3551,22 +3593,22 @@ watch(() => entries.value.map(e => ({
|
|||
}
|
||||
|
||||
:deep(.tag-action-btn.confirm) {
|
||||
background: var(--td-success-color-light);
|
||||
color: var(--td-brand-color-active);
|
||||
|
||||
&:hover {
|
||||
background: var(--td-success-color-light);
|
||||
color: var(--td-success-color);
|
||||
}
|
||||
}
|
||||
|
||||
:deep(.tag-action-btn.cancel) {
|
||||
background: var(--td-bg-color-secondarycontainer);
|
||||
background: transparent;
|
||||
color: var(--td-text-color-secondary);
|
||||
|
||||
&:hover {
|
||||
background: var(--td-bg-color-secondarycontainer);
|
||||
color: var(--td-text-color-secondary);
|
||||
color: var(--td-brand-color);
|
||||
}
|
||||
}
|
||||
|
||||
:deep(.tag-action-btn.cancel) {
|
||||
background: transparent;
|
||||
color: var(--td-text-color-secondary);
|
||||
|
||||
&:hover {
|
||||
background: var(--td-bg-color-secondarycontainer);
|
||||
color: var(--td-error-color);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -3577,39 +3619,40 @@ watch(() => entries.value.map(e => ({
|
|||
max-width: 100%;
|
||||
|
||||
:deep(.t-input) {
|
||||
font-size: 12px;
|
||||
font-size: 13px;
|
||||
background-color: transparent;
|
||||
border: none;
|
||||
border-bottom: 1px solid var(--td-component-stroke);
|
||||
border-radius: 0;
|
||||
box-shadow: none;
|
||||
padding-left: 0;
|
||||
padding-right: 0;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
:deep(.t-input__wrap) {
|
||||
background-color: transparent;
|
||||
border: none;
|
||||
border-bottom: 1px solid var(--td-component-stroke);
|
||||
border-radius: 0;
|
||||
box-shadow: none;
|
||||
}
|
||||
|
||||
:deep(.t-input__inner) {
|
||||
padding-left: 0;
|
||||
padding-right: 0;
|
||||
padding: 0;
|
||||
color: var(--td-text-color-primary);
|
||||
caret-color: var(--td-text-color-primary);
|
||||
caret-color: var(--td-brand-color);
|
||||
}
|
||||
|
||||
:deep(.t-input:hover),
|
||||
:deep(.t-input.t-is-focused),
|
||||
:deep(.t-input__wrap:hover),
|
||||
:deep(.t-input__wrap.t-is-focused) {
|
||||
border-bottom-color: var(--td-success-color);
|
||||
border-color: transparent;
|
||||
}
|
||||
}
|
||||
|
||||
.tag-more {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.tag-more-btn {
|
||||
width: 22px;
|
||||
height: 22px;
|
||||
|
|
@ -3617,23 +3660,15 @@ watch(() => entries.value.map(e => ({
|
|||
align-items: center;
|
||||
justify-content: center;
|
||||
border-radius: 4px;
|
||||
color: var(--td-text-color-secondary);
|
||||
color: var(--td-text-color-placeholder);
|
||||
transition: all 0.2s ease;
|
||||
opacity: 0.6;
|
||||
|
||||
&:hover {
|
||||
background: var(--td-bg-color-secondarycontainer);
|
||||
color: var(--td-text-color-secondary);
|
||||
opacity: 1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
.tag-more {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.tag-more-placeholder {
|
||||
width: 22px;
|
||||
height: 22px;
|
||||
|
|
@ -3653,12 +3688,13 @@ watch(() => entries.value.map(e => ({
|
|||
.faq-card-area {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
min-height: 0;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
padding: 12px;
|
||||
min-height: 0;
|
||||
padding: 0 0 0 16px;
|
||||
border: none;
|
||||
overflow: hidden;
|
||||
background: var(--td-bg-color-container);
|
||||
background: transparent;
|
||||
}
|
||||
|
||||
.faq-search-bar {
|
||||
|
|
@ -3683,7 +3719,7 @@ watch(() => entries.value.map(e => ({
|
|||
background: transparent;
|
||||
border: none;
|
||||
&:hover {
|
||||
color: var(--td-text-color-secondary);
|
||||
color: var(--td-brand-color);
|
||||
background: var(--td-bg-color-secondarycontainer);
|
||||
}
|
||||
}
|
||||
|
|
@ -3691,15 +3727,17 @@ watch(() => entries.value.map(e => ({
|
|||
|
||||
:deep(.t-input) {
|
||||
font-size: 13px;
|
||||
background-color: var(--td-bg-color-container);
|
||||
border-color: var(--td-component-stroke);
|
||||
background-color: var(--td-bg-color-secondarycontainer);
|
||||
border-color: transparent;
|
||||
border-radius: 6px;
|
||||
box-shadow: none !important;
|
||||
|
||||
&:hover,
|
||||
&:focus,
|
||||
&.t-is-focused {
|
||||
border-color: var(--td-brand-color);
|
||||
background-color: var(--td-bg-color-container);
|
||||
border-color: var(--td-success-color);
|
||||
box-shadow: none !important;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -4171,10 +4209,40 @@ watch(() => entries.value.map(e => ({
|
|||
padding-right: 4px;
|
||||
}
|
||||
|
||||
@keyframes contentFadeIn {
|
||||
from { opacity: 0; transform: translateY(6px); }
|
||||
to { opacity: 1; transform: translateY(0); }
|
||||
}
|
||||
|
||||
.faq-skeleton-grid {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
|
||||
gap: 12px;
|
||||
width: 100%;
|
||||
animation: contentFadeIn 0.32s ease-out;
|
||||
}
|
||||
|
||||
.faq-card-skeleton {
|
||||
cursor: default;
|
||||
height: auto;
|
||||
.faq-card-header {
|
||||
padding-bottom: 10px;
|
||||
border-bottom: 1px solid var(--td-component-stroke);
|
||||
}
|
||||
.faq-card-body {
|
||||
padding: 8px 0;
|
||||
}
|
||||
.faq-skel-footer {
|
||||
padding-top: 8px;
|
||||
border-top: 1px solid var(--td-component-stroke);
|
||||
}
|
||||
}
|
||||
|
||||
// 卡片列表样式 - 使用绝对定位实现瀑布流,下一行补齐上一行空缺
|
||||
.faq-card-list {
|
||||
position: relative;
|
||||
width: 100%;
|
||||
animation: contentFadeIn 0.32s ease-out;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -114,6 +114,13 @@ const engineOptions = computed(() => {
|
|||
available: statusMap.s3,
|
||||
disabled: statusMap.s3 === false,
|
||||
},
|
||||
{
|
||||
value: 'oss',
|
||||
label: t('kbSettings.storage.engineOss'),
|
||||
desc: t('kbSettings.storage.engineOssDesc'),
|
||||
available: statusMap.oss,
|
||||
disabled: statusMap.oss === false,
|
||||
},
|
||||
]
|
||||
})
|
||||
|
||||
|
|
|
|||
|
|
@ -8,17 +8,18 @@
|
|||
:count-joined="joinedCount"
|
||||
/>
|
||||
<div class="org-list-content">
|
||||
<div class="header">
|
||||
<div class="header-title">
|
||||
<div class="title-row">
|
||||
<h2>{{ $t('organization.title') }}</h2>
|
||||
<div class="header-actions">
|
||||
<div class="header" style="--wails-draggable: drag">
|
||||
<div class="header-title" style="--wails-draggable: drag">
|
||||
<div class="title-row" style="--wails-draggable: drag">
|
||||
<h2 style="--wails-draggable: drag">{{ $t('organization.title') }}</h2>
|
||||
<div class="header-actions" style="--wails-draggable: no-drag">
|
||||
<t-tooltip :content="$t('organization.joinOrg')" placement="bottom">
|
||||
<t-button
|
||||
variant="text"
|
||||
theme="default"
|
||||
size="small"
|
||||
class="header-action-btn"
|
||||
style="--wails-draggable: no-drag"
|
||||
@click="handleJoinOrganization"
|
||||
>
|
||||
<template #icon><t-icon name="enter" size="16px" /></template>
|
||||
|
|
@ -30,6 +31,7 @@
|
|||
theme="default"
|
||||
size="small"
|
||||
class="header-action-btn"
|
||||
style="--wails-draggable: no-drag"
|
||||
@click="handleCreateOrganization"
|
||||
>
|
||||
<template #icon><img src="@/assets/img/organization-green.svg" class="org-create-icon" alt="" aria-hidden="true" /></template>
|
||||
|
|
@ -37,10 +39,25 @@
|
|||
</t-tooltip>
|
||||
</div>
|
||||
</div>
|
||||
<p class="header-subtitle">{{ $t('organization.subtitle') }}</p>
|
||||
<p class="header-subtitle" style="--wails-draggable: drag">{{ $t('organization.subtitle') }}</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="org-list-main">
|
||||
<!-- 骨架屏占位 -->
|
||||
<div v-if="loading && filteredOrganizations.length === 0" class="org-card-wrap">
|
||||
<div v-for="n in 4" :key="'skel-'+n" class="org-card org-card-skeleton">
|
||||
<div class="card-header">
|
||||
<t-skeleton animation="gradient" :row-col="[[{ width: '36px', height: '36px', type: 'circle' }, { width: '50%', height: '20px' }]]" />
|
||||
</div>
|
||||
<div style="flex:1;margin-top:12px">
|
||||
<t-skeleton animation="gradient" :row-col="[{ width: '100%', height: '14px' }, { width: '70%', height: '14px' }]" />
|
||||
</div>
|
||||
<div style="margin-top:auto">
|
||||
<t-skeleton animation="gradient" :row-col="[[{ width: '60px', height: '22px', type: 'rect' }, { width: '60px', height: '22px', type: 'rect' }]]" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 卡片网格 -->
|
||||
<div v-if="filteredOrganizations.length > 0" class="org-card-wrap">
|
||||
<div
|
||||
|
|
@ -1404,10 +1421,24 @@ onUnmounted(() => {
|
|||
}
|
||||
}
|
||||
|
||||
@keyframes contentFadeIn {
|
||||
from { opacity: 0; transform: translateY(6px); }
|
||||
to { opacity: 1; transform: translateY(0); }
|
||||
}
|
||||
|
||||
.org-card-wrap {
|
||||
display: grid;
|
||||
gap: 20px;
|
||||
grid-template-columns: 1fr;
|
||||
animation: contentFadeIn 0.32s ease-out;
|
||||
}
|
||||
|
||||
.org-card-skeleton {
|
||||
cursor: default;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
height: 160px;
|
||||
min-height: 160px;
|
||||
}
|
||||
|
||||
/* 与知识库列表卡片统一尺寸:160px 高、18px 20px 内边距、12px 圆角 */
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
<template>
|
||||
<div class="main" ref="dropzone">
|
||||
<Menu></Menu>
|
||||
<RouterView />
|
||||
<RouterView v-if="isRouterAlive" />
|
||||
<div class="upload-mask" v-show="ismask">
|
||||
<input type="file" style="display: none" ref="uploadInput" accept=".pdf,.docx,.doc,.pptx,.ppt,.txt,.md,.jpg,.jpeg,.png,.csv,.xls,.xlsx" />
|
||||
<UploadMask></UploadMask>
|
||||
|
|
@ -12,7 +12,7 @@
|
|||
</template>
|
||||
<script setup lang="ts">
|
||||
import Menu from '@/components/menu.vue'
|
||||
import { ref, onMounted, onUnmounted } from 'vue';
|
||||
import { ref, onMounted, onUnmounted, nextTick, provide } from 'vue';
|
||||
import { useRoute } from 'vue-router'
|
||||
import useKnowledgeBase from '@/hooks/useKnowledgeBase'
|
||||
import UploadMask from '@/components/upload-mask.vue'
|
||||
|
|
@ -27,6 +27,22 @@ let ismask = ref(false)
|
|||
let uploadInput = ref();
|
||||
const { t } = useI18n();
|
||||
|
||||
const isRouterAlive = ref(true)
|
||||
const reloadApp = () => {
|
||||
isRouterAlive.value = false
|
||||
nextTick(() => {
|
||||
isRouterAlive.value = true
|
||||
})
|
||||
}
|
||||
provide('app:reload', reloadApp)
|
||||
|
||||
const handleGlobalKeyDown = (e: KeyboardEvent) => {
|
||||
if ((e.ctrlKey || e.metaKey) && e.key.toLowerCase() === 'r') {
|
||||
e.preventDefault()
|
||||
reloadApp()
|
||||
}
|
||||
}
|
||||
|
||||
// 用于跟踪拖拽进入/离开的计数器,解决子元素触发 dragleave 的问题
|
||||
let dragCounter = 0;
|
||||
|
||||
|
|
@ -118,6 +134,14 @@ onMounted(() => {
|
|||
document.addEventListener('dragover', handleGlobalDragOver, true);
|
||||
document.addEventListener('dragleave', handleGlobalDragLeave, true);
|
||||
document.addEventListener('drop', handleGlobalDrop, true);
|
||||
window.addEventListener('keydown', handleGlobalKeyDown);
|
||||
// @ts-ignore
|
||||
if (window.runtime?.EventsOn) {
|
||||
// @ts-ignore
|
||||
window.runtime.EventsOn('app:reload', () => {
|
||||
reloadApp()
|
||||
})
|
||||
}
|
||||
});
|
||||
|
||||
// 组件卸载时移除全局事件监听器
|
||||
|
|
@ -126,6 +150,12 @@ onUnmounted(() => {
|
|||
document.removeEventListener('dragover', handleGlobalDragOver, true);
|
||||
document.removeEventListener('dragleave', handleGlobalDragLeave, true);
|
||||
document.removeEventListener('drop', handleGlobalDrop, true);
|
||||
window.removeEventListener('keydown', handleGlobalKeyDown);
|
||||
// @ts-ignore
|
||||
if (window.runtime?.EventsOff) {
|
||||
// @ts-ignore
|
||||
window.runtime.EventsOff('app:reload')
|
||||
}
|
||||
dragCounter = 0;
|
||||
});
|
||||
</script>
|
||||
|
|
|
|||
|
|
@ -55,6 +55,96 @@
|
|||
</div>
|
||||
</div>
|
||||
|
||||
<!-- API base URL -->
|
||||
<div class="setting-row">
|
||||
<div class="setting-info">
|
||||
<label>{{ $t('tenant.api.urlLabel') }}</label>
|
||||
<p class="desc">{{ $t('tenant.api.urlDescription') }}</p>
|
||||
</div>
|
||||
<div class="setting-control">
|
||||
<div class="api-key-control">
|
||||
<t-input
|
||||
:model-value="apiBaseUrlDisplay"
|
||||
readonly
|
||||
type="text"
|
||||
style="width: 100%; font-family: monospace; font-size: 12px;"
|
||||
/>
|
||||
<t-button
|
||||
size="small"
|
||||
variant="text"
|
||||
@click="copyApiUrl"
|
||||
:title="$t('tenant.api.copyUrlTitle')"
|
||||
>
|
||||
<t-icon name="file-copy" />
|
||||
</t-button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Desktop (Wails): fixed local API port + optional LAN/public listen -->
|
||||
<template v-if="showDesktopPortSetting || showDesktopBindPublicSetting">
|
||||
<div v-if="showDesktopPortSetting" class="setting-row">
|
||||
<div class="setting-info">
|
||||
<label>{{ $t('tenant.api.desktopPortLabel') }}</label>
|
||||
<p class="desc">{{ $t('tenant.api.desktopPortDescription') }}</p>
|
||||
</div>
|
||||
<div class="setting-control">
|
||||
<div class="api-key-control">
|
||||
<div class="desktop-port-input-wrap">
|
||||
<t-input-number
|
||||
v-model="desktopPortInput"
|
||||
:min="0"
|
||||
:max="65535"
|
||||
theme="normal"
|
||||
/>
|
||||
</div>
|
||||
<t-button size="small" variant="text" @click="saveDesktopPort">
|
||||
{{ $t('tenant.api.desktopPortSave') }}
|
||||
</t-button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div v-if="showDesktopBindPublicSetting" class="setting-row">
|
||||
<div class="setting-info">
|
||||
<label>{{ $t('tenant.api.desktopBindPublicLabel') }}</label>
|
||||
<p class="desc">{{ $t('tenant.api.desktopBindPublicDescription') }}</p>
|
||||
</div>
|
||||
<div class="setting-control desktop-bind-public-control">
|
||||
<t-switch v-model="desktopBindPublicInput" @change="onDesktopBindPublicChange" />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div v-if="wailsApiLanBaseURL" class="setting-row">
|
||||
<div class="setting-info">
|
||||
<label>{{ $t('tenant.api.lanUrlLabel') }}</label>
|
||||
<p class="desc">{{ $t('tenant.api.lanUrlDescription') }}</p>
|
||||
</div>
|
||||
<div class="setting-control">
|
||||
<div class="api-key-control">
|
||||
<t-input
|
||||
:model-value="wailsApiLanBaseURL"
|
||||
readonly
|
||||
type="text"
|
||||
style="width: 100%; font-family: monospace; font-size: 12px;"
|
||||
/>
|
||||
<t-button
|
||||
size="small"
|
||||
variant="text"
|
||||
@click="copyLanApiUrl"
|
||||
:title="$t('tenant.api.lanUrlCopyTitle')"
|
||||
>
|
||||
<t-icon name="file-copy" />
|
||||
</t-button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div v-if="showLanUrlUnavailableHint" class="setting-row lan-url-hint-row">
|
||||
<t-alert theme="warning" :message="$t('tenant.api.lanUrlUnavailable')" />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<!-- API docs -->
|
||||
<div class="setting-row">
|
||||
<div class="setting-info">
|
||||
|
|
@ -123,6 +213,7 @@
|
|||
<script setup lang="ts">
|
||||
import { ref, computed, onMounted } from 'vue'
|
||||
import { getCurrentUser, type TenantInfo, type UserInfo } from '@/api/auth'
|
||||
import { getApiBaseUrl } from '@/utils/api-base'
|
||||
import { MessagePlugin } from 'tdesign-vue-next'
|
||||
import { useI18n } from 'vue-i18n'
|
||||
|
||||
|
|
@ -134,6 +225,14 @@ const userInfo = ref<UserInfo | null>(null)
|
|||
const loading = ref(true)
|
||||
const error = ref('')
|
||||
const showApiKey = ref(false)
|
||||
/** WeKnora Lite (Wails): real API origin is loopback + dynamic port, not window.location.origin */
|
||||
const wailsApiBaseURL = ref<string | null>(null)
|
||||
const showDesktopPortSetting = ref(false)
|
||||
const showDesktopBindPublicSetting = ref(false)
|
||||
const desktopPortInput = ref<number | undefined>(0)
|
||||
const desktopBindPublicInput = ref(false)
|
||||
const wailsApiLanBaseURL = ref<string | null>(null)
|
||||
const desktopListenPublicActive = ref(false)
|
||||
|
||||
// Computed
|
||||
const displayApiKey = computed(() => {
|
||||
|
|
@ -148,6 +247,164 @@ const displayApiKey = computed(() => {
|
|||
return masked
|
||||
})
|
||||
|
||||
const showLanUrlUnavailableHint = computed(
|
||||
() =>
|
||||
showDesktopBindPublicSetting.value &&
|
||||
desktopListenPublicActive.value &&
|
||||
!wailsApiLanBaseURL.value
|
||||
)
|
||||
|
||||
const apiBaseUrlDisplay = computed(() => {
|
||||
if (wailsApiBaseURL.value) {
|
||||
return wailsApiBaseURL.value
|
||||
}
|
||||
const configured = getApiBaseUrl().trim().replace(/\/$/, '')
|
||||
let origin = typeof window !== 'undefined' ? window.location.origin : ''
|
||||
if (!origin || origin === 'null') {
|
||||
origin = ''
|
||||
}
|
||||
const base = configured || origin
|
||||
return `${base}/api/v1`
|
||||
})
|
||||
|
||||
type WeKnoraDesktopWindow = Window & {
|
||||
__WEKNORA_API_BASE__?: string
|
||||
__WEKNORA_API_LAN_BASE__?: string
|
||||
go?: {
|
||||
main?: {
|
||||
App?: {
|
||||
GetAPIBaseURL?: () => Promise<string> | string
|
||||
GetAPILanBaseURL?: () => Promise<string> | string
|
||||
GetDesktopHTTPPortSetting?: () => Promise<number> | number
|
||||
GetDesktopHTTPBindPublicSetting?: () => Promise<boolean> | boolean
|
||||
GetDesktopListenPublicActive?: () => Promise<boolean> | boolean
|
||||
SetDesktopHTTPPortSetting?: (port: number) => Promise<void> | void
|
||||
SetDesktopHTTPBindPublicSetting?: (v: boolean) => Promise<void> | void
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
async function tryLoadWailsApiBaseURL() {
|
||||
const win = window as WeKnoraDesktopWindow
|
||||
for (let i = 0; i < 40; i++) {
|
||||
const injected = win.__WEKNORA_API_BASE__
|
||||
if (typeof injected === 'string' && injected.trim()) {
|
||||
wailsApiBaseURL.value = injected.trim().replace(/\/$/, '')
|
||||
await tryLoadWailsLanHints(win)
|
||||
return
|
||||
}
|
||||
const fn = win.go?.main?.App?.GetAPIBaseURL
|
||||
if (typeof fn === 'function') {
|
||||
try {
|
||||
const raw = await Promise.resolve(fn())
|
||||
if (typeof raw === 'string' && raw.trim()) {
|
||||
wailsApiBaseURL.value = raw.trim().replace(/\/$/, '')
|
||||
}
|
||||
} catch {
|
||||
/* binding error */
|
||||
}
|
||||
await tryLoadWailsLanHints(win)
|
||||
return
|
||||
}
|
||||
await new Promise((r) => setTimeout(r, 50))
|
||||
}
|
||||
await tryLoadWailsLanHints(win)
|
||||
}
|
||||
|
||||
async function tryLoadWailsLanHints(win: WeKnoraDesktopWindow) {
|
||||
const injectedLan = win.__WEKNORA_API_LAN_BASE__
|
||||
if (typeof injectedLan === 'string' && injectedLan.trim()) {
|
||||
wailsApiLanBaseURL.value = injectedLan.trim().replace(/\/$/, '')
|
||||
}
|
||||
const fnLan = win.go?.main?.App?.GetAPILanBaseURL
|
||||
if (typeof fnLan === 'function' && !wailsApiLanBaseURL.value) {
|
||||
try {
|
||||
const raw = await Promise.resolve(fnLan())
|
||||
if (typeof raw === 'string' && raw.trim()) {
|
||||
wailsApiLanBaseURL.value = raw.trim().replace(/\/$/, '')
|
||||
}
|
||||
} catch {
|
||||
/* binding error */
|
||||
}
|
||||
}
|
||||
const fnAct = win.go?.main?.App?.GetDesktopListenPublicActive
|
||||
if (typeof fnAct === 'function') {
|
||||
try {
|
||||
desktopListenPublicActive.value = !!(await Promise.resolve(fnAct()))
|
||||
} catch {
|
||||
desktopListenPublicActive.value = false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function desktopPortBindingsAvailable(win: WeKnoraDesktopWindow) {
|
||||
const app = win.go?.main?.App
|
||||
return typeof app?.GetDesktopHTTPPortSetting === 'function' && typeof app?.SetDesktopHTTPPortSetting === 'function'
|
||||
}
|
||||
|
||||
function desktopBindPublicBindingsAvailable(win: WeKnoraDesktopWindow) {
|
||||
const app = win.go?.main?.App
|
||||
return (
|
||||
typeof app?.GetDesktopHTTPBindPublicSetting === 'function' &&
|
||||
typeof app?.SetDesktopHTTPBindPublicSetting === 'function'
|
||||
)
|
||||
}
|
||||
|
||||
async function loadDesktopApiPrefs() {
|
||||
const win = window as WeKnoraDesktopWindow
|
||||
if (desktopPortBindingsAvailable(win)) {
|
||||
showDesktopPortSetting.value = true
|
||||
try {
|
||||
const p = await Promise.resolve(win.go!.main!.App!.GetDesktopHTTPPortSetting!())
|
||||
desktopPortInput.value = typeof p === 'number' ? p : 0
|
||||
} catch {
|
||||
desktopPortInput.value = 0
|
||||
}
|
||||
}
|
||||
if (desktopBindPublicBindingsAvailable(win)) {
|
||||
showDesktopBindPublicSetting.value = true
|
||||
try {
|
||||
const b = await Promise.resolve(win.go!.main!.App!.GetDesktopHTTPBindPublicSetting!())
|
||||
desktopBindPublicInput.value = !!b
|
||||
} catch {
|
||||
desktopBindPublicInput.value = false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const onDesktopBindPublicChange = async (value: boolean) => {
|
||||
const v = value === true
|
||||
const win = window as WeKnoraDesktopWindow
|
||||
const fn = win.go?.main?.App?.SetDesktopHTTPBindPublicSetting
|
||||
if (typeof fn !== 'function') return
|
||||
try {
|
||||
await Promise.resolve(fn(v))
|
||||
MessagePlugin.success(t('tenant.api.desktopBindPublicSaved'))
|
||||
} catch (err: unknown) {
|
||||
MessagePlugin.error(err instanceof Error ? err.message : t('tenant.api.desktopBindPublicSaveFailed'))
|
||||
desktopBindPublicInput.value = !v
|
||||
}
|
||||
}
|
||||
|
||||
const saveDesktopPort = async () => {
|
||||
const v = desktopPortInput.value
|
||||
const port = typeof v === 'number' && !Number.isNaN(v) ? Math.floor(v) : 0
|
||||
if (port < 0 || port > 65535) {
|
||||
MessagePlugin.warning(t('tenant.api.desktopPortInvalid'))
|
||||
return
|
||||
}
|
||||
const win = window as WeKnoraDesktopWindow
|
||||
const fn = win.go?.main?.App?.SetDesktopHTTPPortSetting
|
||||
if (typeof fn !== 'function') return
|
||||
try {
|
||||
await Promise.resolve(fn(port))
|
||||
MessagePlugin.success(t('tenant.api.desktopPortSaved'))
|
||||
} catch (err: unknown) {
|
||||
MessagePlugin.error(err instanceof Error ? err.message : t('tenant.api.desktopPortSaveFailed'))
|
||||
}
|
||||
}
|
||||
|
||||
// Methods
|
||||
const loadInfo = async () => {
|
||||
try {
|
||||
|
|
@ -203,6 +460,37 @@ const copyApiKey = async () => {
|
|||
}
|
||||
}
|
||||
|
||||
const copyLanApiUrl = async () => {
|
||||
const text = wailsApiLanBaseURL.value
|
||||
if (!text) return
|
||||
try {
|
||||
if (navigator.clipboard && navigator.clipboard.writeText) {
|
||||
await navigator.clipboard.writeText(text)
|
||||
} else {
|
||||
fallbackCopyText(text)
|
||||
}
|
||||
MessagePlugin.success(t('tenant.api.lanUrlCopySuccess'))
|
||||
} catch {
|
||||
fallbackCopyText(text)
|
||||
MessagePlugin.success(t('tenant.api.lanUrlCopySuccess'))
|
||||
}
|
||||
}
|
||||
|
||||
const copyApiUrl = async () => {
|
||||
const text = apiBaseUrlDisplay.value
|
||||
try {
|
||||
if (navigator.clipboard && navigator.clipboard.writeText) {
|
||||
await navigator.clipboard.writeText(text)
|
||||
} else {
|
||||
fallbackCopyText(text)
|
||||
}
|
||||
MessagePlugin.success(t('tenant.api.urlCopySuccess'))
|
||||
} catch {
|
||||
fallbackCopyText(text)
|
||||
MessagePlugin.success(t('tenant.api.urlCopySuccess'))
|
||||
}
|
||||
}
|
||||
|
||||
const formatDate = (dateStr: string | undefined) => {
|
||||
if (!dateStr) return t('tenant.unknown')
|
||||
|
||||
|
|
@ -222,7 +510,9 @@ const formatDate = (dateStr: string | undefined) => {
|
|||
}
|
||||
|
||||
// Lifecycle
|
||||
onMounted(() => {
|
||||
onMounted(async () => {
|
||||
await tryLoadWailsApiBaseURL()
|
||||
await loadDesktopApiPrefs()
|
||||
loadInfo()
|
||||
})
|
||||
</script>
|
||||
|
|
@ -328,7 +618,7 @@ onMounted(() => {
|
|||
min-width: 280px;
|
||||
display: flex;
|
||||
justify-content: flex-end;
|
||||
align-items: center;
|
||||
align-items: flex-start;
|
||||
|
||||
.info-value {
|
||||
font-size: 14px;
|
||||
|
|
@ -356,5 +646,37 @@ onMounted(() => {
|
|||
margin-top: 0;
|
||||
}
|
||||
}
|
||||
|
||||
/* 与 API Key / API 地址 行一致:输入区占满 flex 剩余宽度,文案按钮贴右 */
|
||||
.desktop-port-input-wrap {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
|
||||
:deep(.t-input-number) {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
:deep(.t-input__wrap) {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
:deep(input) {
|
||||
font-family: monospace;
|
||||
font-size: 12px;
|
||||
}
|
||||
}
|
||||
|
||||
.desktop-bind-public-control {
|
||||
padding-top: 4px;
|
||||
}
|
||||
|
||||
.lan-url-hint-row {
|
||||
padding-top: 0;
|
||||
border-bottom: 1px solid var(--td-component-stroke);
|
||||
|
||||
:deep(.t-alert) {
|
||||
width: 100%;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
||||
|
|
|
|||
|
|
@ -73,6 +73,19 @@
|
|||
</t-link>
|
||||
</template>
|
||||
</t-alert>
|
||||
|
||||
<!-- 自动下载更新开关 (Lite edition only) -->
|
||||
<div class="setting-row" v-if="authStore.isLiteMode">
|
||||
<div class="setting-info">
|
||||
<label>{{ $t('settings.autoCheckUpdate') }}</label>
|
||||
<p class="desc">{{ $t('settings.autoCheckUpdateDesc') }}</p>
|
||||
</div>
|
||||
<div class="setting-control">
|
||||
<t-switch
|
||||
v-model="isAutoCheckUpdateEnabled"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
|
@ -82,11 +95,13 @@ import { ref, onMounted, computed } from 'vue'
|
|||
import { MessagePlugin } from 'tdesign-vue-next'
|
||||
import { useI18n } from 'vue-i18n'
|
||||
import { useSettingsStore } from '@/stores/settings'
|
||||
import { useAuthStore } from '@/stores/auth'
|
||||
import { getSystemInfo } from '@/api/system'
|
||||
import { useTheme, type ThemeMode } from '@/composables/useTheme'
|
||||
|
||||
const { t, locale } = useI18n()
|
||||
const settingsStore = useSettingsStore()
|
||||
const authStore = useAuthStore()
|
||||
const { currentTheme, setTheme } = useTheme()
|
||||
|
||||
// 本地状态
|
||||
|
|
@ -106,6 +121,21 @@ const isMemoryEnabled = computed({
|
|||
set: (val) => settingsStore.toggleMemory(val)
|
||||
})
|
||||
|
||||
// 自动检查更新状态
|
||||
const isAutoCheckUpdateEnabled = computed({
|
||||
get: () => settingsStore.isAutoCheckUpdateEnabled,
|
||||
set: (val) => {
|
||||
settingsStore.toggleAutoCheckUpdate(val)
|
||||
if (val) {
|
||||
// @ts-ignore
|
||||
if (window.go && window.go.main && window.go.main.App && window.go.main.App.AutoCheckForUpdates) {
|
||||
// @ts-ignore
|
||||
window.go.main.App.AutoCheckForUpdates()
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
// 初始化加载
|
||||
onMounted(async () => {
|
||||
// 从 localStorage 加载语言设置
|
||||
|
|
|
|||
|
|
@ -3,37 +3,71 @@
|
|||
<div class="section-header">
|
||||
<h2>{{ $t('modelSettings.title') }}</h2>
|
||||
<p class="section-description">{{ $t('modelSettings.description') }}</p>
|
||||
|
||||
<!-- 内置模型说明 -->
|
||||
<div class="builtin-models-info">
|
||||
<div class="info-box">
|
||||
<div class="info-header">
|
||||
<t-icon name="info-circle" class="info-icon" />
|
||||
<span class="info-title">{{ $t('modelSettings.builtinModels.title') }}</span>
|
||||
</div>
|
||||
<div class="info-content">
|
||||
<p>{{ $t('modelSettings.builtinModels.description') }}</p>
|
||||
<p class="doc-link">
|
||||
<t-icon name="link" class="link-icon" />
|
||||
<a href="https://github.com/Tencent/WeKnora/blob/main/docs/BUILTIN_MODELS.md" target="_blank" rel="noopener noreferrer">
|
||||
{{ $t('modelSettings.builtinModels.viewGuide') }}
|
||||
</a>
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div class="builtin-models-hint" role="note">
|
||||
<p class="builtin-hint-label">{{ $t('modelSettings.builtinModels.title') }}</p>
|
||||
<p class="builtin-hint-text">{{ $t('modelSettings.builtinModels.description') }}</p>
|
||||
<a
|
||||
class="builtin-hint-link"
|
||||
href="https://github.com/Tencent/WeKnora/blob/main/docs/BUILTIN_MODELS.md"
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
>
|
||||
{{ $t('modelSettings.builtinModels.viewGuide') }}
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- WeKnoraCloud 厂商配置 -->
|
||||
<div class="weknoracloud-config-section" style="margin-bottom: 24px;">
|
||||
<div class="category-header" style="margin-bottom: 12px;">
|
||||
<h3 style="margin: 0; font-size: 16px; font-weight: 600;">WeKnoraCloud 厂商配置</h3>
|
||||
</div>
|
||||
<!-- 凭证失效警告 -->
|
||||
<div v-if="weKnoraCloudNeedsReinit" style="margin-bottom: 12px; background: #fff7ed; border: 1px solid #fed7aa; border-left: 3px solid #f97316; border-radius: 6px; padding: 12px 16px; display: flex; align-items: flex-start; gap: 10px;">
|
||||
<t-icon name="error-circle" style="font-size: 16px; color: #f97316; flex-shrink: 0; margin-top: 1px;" />
|
||||
<div style="font-size: 13px; color: #9a3412; line-height: 1.5;">
|
||||
<strong>WeKnoraCloud 凭证已失效</strong><br />
|
||||
{{ weKnoraCloudReinitReason || '服务重启后加密密钥已变更,已保存的凭证无法解密。' }}
|
||||
</div>
|
||||
</div>
|
||||
<div class="weknoracloud-config-card" style="background: var(--td-bg-color-container); border: 1px solid var(--td-component-stroke); border-radius: 8px; padding: 20px;">
|
||||
<div style="display: flex; align-items: flex-end; gap: 16px; flex-wrap: wrap;">
|
||||
<t-form-item label="APPID" style="margin-bottom: 0;">
|
||||
<t-input v-model="weKnoraCloudForm.appId" placeholder="请输入 APPID" style="width: 240px;" />
|
||||
</t-form-item>
|
||||
<t-form-item label="APPSECRET" style="margin-bottom: 0;">
|
||||
<t-input
|
||||
v-model="weKnoraCloudForm.appSecret"
|
||||
type="password"
|
||||
placeholder="请输入 APPSECRET"
|
||||
style="width: 240px;"
|
||||
/>
|
||||
</t-form-item>
|
||||
<t-button
|
||||
theme="primary"
|
||||
:loading="weKnoraCloudLoading"
|
||||
@click="handleWeKnoraCloudInit"
|
||||
>
|
||||
保存并初始化
|
||||
</t-button>
|
||||
</div>
|
||||
<p style="color: var(--td-text-color-secondary); font-size: 12px; margin-top: 12px; margin-bottom: 0;">
|
||||
提交后将自动创建或更新三个模型(Chat / Embedding / Rerank)并设为各类型默认
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 对话模型 -->
|
||||
<div class="model-category-section" data-model-type="chat">
|
||||
<div class="category-header">
|
||||
<div class="header-info">
|
||||
<div class="settings-group model-type-group" data-model-type="chat">
|
||||
<div class="section-subheader">
|
||||
<div class="subheader-text">
|
||||
<h3>{{ $t('modelSettings.chat.title') }}</h3>
|
||||
<p>{{ $t('modelSettings.chat.desc') }}</p>
|
||||
<p class="section-desc">{{ $t('modelSettings.chat.desc') }}</p>
|
||||
</div>
|
||||
<t-button size="small" theme="primary" @click="openAddDialog('chat')" class="add-model-btn">
|
||||
<t-button theme="primary" size="small" @click="openAddDialog('chat')">
|
||||
<template #icon>
|
||||
<t-icon name="add" class="add-icon" />
|
||||
<add-icon />
|
||||
</template>
|
||||
{{ $t('modelSettings.actions.addModel') }}
|
||||
</t-button>
|
||||
|
|
@ -65,24 +99,27 @@
|
|||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div v-else class="empty-state">
|
||||
<p class="empty-text">{{ $t('modelSettings.chat.empty') }}</p>
|
||||
<t-button theme="default" variant="outline" size="small" @click="openAddDialog('chat')">
|
||||
<div v-else class="empty-models">
|
||||
<p>{{ $t('modelSettings.chat.empty') }}</p>
|
||||
<t-button theme="primary" size="small" @click="openAddDialog('chat')">
|
||||
<template #icon>
|
||||
<add-icon />
|
||||
</template>
|
||||
{{ $t('modelSettings.actions.addModel') }}
|
||||
</t-button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Embedding 模型 -->
|
||||
<div class="model-category-section" data-model-type="embedding">
|
||||
<div class="category-header">
|
||||
<div class="header-info">
|
||||
<div class="settings-group model-type-group" data-model-type="embedding">
|
||||
<div class="section-subheader">
|
||||
<div class="subheader-text">
|
||||
<h3>{{ $t('modelSettings.embedding.title') }}</h3>
|
||||
<p>{{ $t('modelSettings.embedding.desc') }}</p>
|
||||
<p class="section-desc">{{ $t('modelSettings.embedding.desc') }}</p>
|
||||
</div>
|
||||
<t-button size="small" theme="primary" @click="openAddDialog('embedding')" class="add-model-btn">
|
||||
<t-button theme="primary" size="small" @click="openAddDialog('embedding')">
|
||||
<template #icon>
|
||||
<t-icon name="add" class="add-icon" />
|
||||
<add-icon />
|
||||
</template>
|
||||
{{ $t('modelSettings.actions.addModel') }}
|
||||
</t-button>
|
||||
|
|
@ -115,24 +152,27 @@
|
|||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div v-else class="empty-state">
|
||||
<p class="empty-text">{{ $t('modelSettings.embedding.empty') }}</p>
|
||||
<t-button theme="default" variant="outline" size="small" @click="openAddDialog('embedding')">
|
||||
<div v-else class="empty-models">
|
||||
<p>{{ $t('modelSettings.embedding.empty') }}</p>
|
||||
<t-button theme="primary" size="small" @click="openAddDialog('embedding')">
|
||||
<template #icon>
|
||||
<add-icon />
|
||||
</template>
|
||||
{{ $t('modelSettings.actions.addModel') }}
|
||||
</t-button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- ReRank 模型 -->
|
||||
<div class="model-category-section" data-model-type="rerank">
|
||||
<div class="category-header">
|
||||
<div class="header-info">
|
||||
<div class="settings-group model-type-group" data-model-type="rerank">
|
||||
<div class="section-subheader">
|
||||
<div class="subheader-text">
|
||||
<h3>{{ $t('modelSettings.rerank.title') }}</h3>
|
||||
<p>{{ $t('modelSettings.rerank.desc') }}</p>
|
||||
<p class="section-desc">{{ $t('modelSettings.rerank.desc') }}</p>
|
||||
</div>
|
||||
<t-button size="small" theme="primary" @click="openAddDialog('rerank')" class="add-model-btn">
|
||||
<t-button theme="primary" size="small" @click="openAddDialog('rerank')">
|
||||
<template #icon>
|
||||
<t-icon name="add" class="add-icon" />
|
||||
<add-icon />
|
||||
</template>
|
||||
{{ $t('modelSettings.actions.addModel') }}
|
||||
</t-button>
|
||||
|
|
@ -164,24 +204,27 @@
|
|||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div v-else class="empty-state">
|
||||
<p class="empty-text">{{ $t('modelSettings.rerank.empty') }}</p>
|
||||
<t-button theme="default" variant="outline" size="small" @click="openAddDialog('rerank')">
|
||||
<div v-else class="empty-models">
|
||||
<p>{{ $t('modelSettings.rerank.empty') }}</p>
|
||||
<t-button theme="primary" size="small" @click="openAddDialog('rerank')">
|
||||
<template #icon>
|
||||
<add-icon />
|
||||
</template>
|
||||
{{ $t('modelSettings.actions.addModel') }}
|
||||
</t-button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- VLLM 视觉模型 -->
|
||||
<div class="model-category-section" data-model-type="vllm">
|
||||
<div class="category-header">
|
||||
<div class="header-info">
|
||||
<div class="settings-group model-type-group" data-model-type="vllm">
|
||||
<div class="section-subheader">
|
||||
<div class="subheader-text">
|
||||
<h3>{{ $t('modelSettings.vllm.title') }}</h3>
|
||||
<p>{{ $t('modelSettings.vllm.desc') }}</p>
|
||||
<p class="section-desc">{{ $t('modelSettings.vllm.desc') }}</p>
|
||||
</div>
|
||||
<t-button size="small" theme="primary" @click="openAddDialog('vllm')" class="add-model-btn">
|
||||
<t-button theme="primary" size="small" @click="openAddDialog('vllm')">
|
||||
<template #icon>
|
||||
<t-icon name="add" class="add-icon" />
|
||||
<add-icon />
|
||||
</template>
|
||||
{{ $t('modelSettings.actions.addModel') }}
|
||||
</t-button>
|
||||
|
|
@ -213,24 +256,27 @@
|
|||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div v-else class="empty-state">
|
||||
<p class="empty-text">{{ $t('modelSettings.vllm.empty') }}</p>
|
||||
<t-button theme="default" variant="outline" size="small" @click="openAddDialog('vllm')">
|
||||
<div v-else class="empty-models">
|
||||
<p>{{ $t('modelSettings.vllm.empty') }}</p>
|
||||
<t-button theme="primary" size="small" @click="openAddDialog('vllm')">
|
||||
<template #icon>
|
||||
<add-icon />
|
||||
</template>
|
||||
{{ $t('modelSettings.actions.addModel') }}
|
||||
</t-button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- STT 语音模型 -->
|
||||
<div class="model-category-section" data-model-type="asr">
|
||||
<div class="category-header">
|
||||
<div class="header-info">
|
||||
<div class="settings-group model-type-group" data-model-type="asr">
|
||||
<div class="section-subheader">
|
||||
<div class="subheader-text">
|
||||
<h3>{{ $t('modelSettings.asr.title') }}</h3>
|
||||
<p>{{ $t('modelSettings.asr.desc') }}</p>
|
||||
<p class="section-desc">{{ $t('modelSettings.asr.desc') }}</p>
|
||||
</div>
|
||||
<t-button size="small" theme="primary" @click="openAddDialog('asr')" class="add-model-btn">
|
||||
<t-button theme="primary" size="small" @click="openAddDialog('asr')">
|
||||
<template #icon>
|
||||
<t-icon name="add" class="add-icon" />
|
||||
<add-icon />
|
||||
</template>
|
||||
{{ $t('modelSettings.actions.addModel') }}
|
||||
</t-button>
|
||||
|
|
@ -261,9 +307,12 @@
|
|||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div v-else class="empty-state">
|
||||
<p class="empty-text">{{ $t('modelSettings.asr.empty') }}</p>
|
||||
<t-button theme="default" variant="outline" size="small" @click="openAddDialog('asr')">
|
||||
<div v-else class="empty-models">
|
||||
<p>{{ $t('modelSettings.asr.empty') }}</p>
|
||||
<t-button theme="primary" size="small" @click="openAddDialog('asr')">
|
||||
<template #icon>
|
||||
<add-icon />
|
||||
</template>
|
||||
{{ $t('modelSettings.actions.addModel') }}
|
||||
</t-button>
|
||||
</div>
|
||||
|
|
@ -283,9 +332,10 @@
|
|||
<script setup lang="ts">
|
||||
import { ref, computed, onMounted } from 'vue'
|
||||
import { MessagePlugin } from 'tdesign-vue-next'
|
||||
import { AddIcon } from 'tdesign-icons-vue-next'
|
||||
import { useI18n } from 'vue-i18n'
|
||||
import ModelEditorDialog from '@/components/ModelEditorDialog.vue'
|
||||
import { listModels, createModel, updateModel as updateModelAPI, deleteModel as deleteModelAPI, type ModelConfig } from '@/api/model'
|
||||
import { listModels, createModel, updateModel as updateModelAPI, deleteModel as deleteModelAPI, initializeWeKnoraCloud, getWeKnoraCloudStatus, type ModelConfig } from '@/api/model'
|
||||
|
||||
const { t } = useI18n()
|
||||
|
||||
|
|
@ -294,6 +344,38 @@ const currentModelType = ref<'chat' | 'embedding' | 'rerank' | 'vllm' | 'asr'>('
|
|||
const editingModel = ref<any>(null)
|
||||
const loading = ref(true)
|
||||
|
||||
// WeKnoraCloud 配置
|
||||
const weKnoraCloudForm = ref({ appId: '', appSecret: '' })
|
||||
const weKnoraCloudLoading = ref(false)
|
||||
const weKnoraCloudNeedsReinit = ref(false)
|
||||
const weKnoraCloudReinitReason = ref('')
|
||||
|
||||
const handleWeKnoraCloudInit = async () => {
|
||||
if (!weKnoraCloudForm.value.appId || !weKnoraCloudForm.value.appSecret) {
|
||||
MessagePlugin.warning('请填写 APPID 和 APPSECRET')
|
||||
return
|
||||
}
|
||||
weKnoraCloudLoading.value = true
|
||||
try {
|
||||
const result = await initializeWeKnoraCloud({
|
||||
app_id: weKnoraCloudForm.value.appId,
|
||||
app_secret: weKnoraCloudForm.value.appSecret,
|
||||
})
|
||||
const updatedCount = result.models.filter((m: any) => m.action === 'updated').length
|
||||
const createdCount = result.models.filter((m: any) => m.action === 'created').length
|
||||
MessagePlugin.success(`初始化成功:新建 ${createdCount} 个,更新 ${updatedCount} 个模型`)
|
||||
weKnoraCloudForm.value.appId = ''
|
||||
weKnoraCloudForm.value.appSecret = ''
|
||||
weKnoraCloudNeedsReinit.value = false
|
||||
weKnoraCloudReinitReason.value = ''
|
||||
await loadModels()
|
||||
} catch (err: any) {
|
||||
MessagePlugin.error(err?.message || 'WeKnoraCloud 初始化失败')
|
||||
} finally {
|
||||
weKnoraCloudLoading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
// 模型列表数据
|
||||
const allModels = ref<ModelConfig[]>([])
|
||||
|
||||
|
|
@ -351,6 +433,10 @@ const loadModels = async () => {
|
|||
// 直接获取所有模型,不分类型
|
||||
const models = await listModels()
|
||||
allModels.value = models
|
||||
// 检查 WeKnoraCloud 凭证状态
|
||||
const status = await getWeKnoraCloudStatus()
|
||||
weKnoraCloudNeedsReinit.value = status.needs_reinit
|
||||
weKnoraCloudReinitReason.value = status.reason || ''
|
||||
} catch (error: any) {
|
||||
console.error('加载模型列表失败:', error)
|
||||
MessagePlugin.error(error.message)
|
||||
|
|
@ -553,63 +639,90 @@ onMounted(() => {
|
|||
.section-description {
|
||||
font-size: 14px;
|
||||
color: var(--td-text-color-secondary);
|
||||
margin: 0 0 20px 0;
|
||||
margin: 0 0 16px 0;
|
||||
line-height: 1.5;
|
||||
}
|
||||
}
|
||||
|
||||
.model-category-section {
|
||||
.builtin-models-hint {
|
||||
margin-top: 4px;
|
||||
padding: 10px 12px;
|
||||
background: var(--td-bg-color-secondarycontainer);
|
||||
border: 1px solid var(--td-component-stroke);
|
||||
border-radius: 6px;
|
||||
}
|
||||
|
||||
.builtin-hint-label {
|
||||
margin: 0 0 4px 0;
|
||||
font-size: 12px;
|
||||
font-weight: 500;
|
||||
color: var(--td-text-color-placeholder);
|
||||
letter-spacing: 0.02em;
|
||||
}
|
||||
|
||||
.builtin-hint-text {
|
||||
margin: 0 0 6px 0;
|
||||
font-size: 13px;
|
||||
line-height: 1.55;
|
||||
color: var(--td-text-color-secondary);
|
||||
}
|
||||
|
||||
.builtin-hint-link {
|
||||
font-size: 13px;
|
||||
color: var(--td-text-color-secondary);
|
||||
text-decoration: none;
|
||||
|
||||
&:hover {
|
||||
color: var(--td-brand-color);
|
||||
text-decoration: underline;
|
||||
}
|
||||
}
|
||||
|
||||
.settings-group {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.model-type-group {
|
||||
margin-bottom: 32px;
|
||||
padding-bottom: 32px;
|
||||
border-bottom: 1px solid var(--td-component-stroke);
|
||||
|
||||
&:last-child {
|
||||
&:last-of-type {
|
||||
margin-bottom: 0;
|
||||
padding-bottom: 0;
|
||||
border-bottom: none;
|
||||
}
|
||||
}
|
||||
|
||||
.category-header {
|
||||
.section-subheader {
|
||||
display: flex;
|
||||
align-items: flex-start;
|
||||
justify-content: space-between;
|
||||
gap: 16px;
|
||||
margin-bottom: 16px;
|
||||
|
||||
.header-info {
|
||||
.subheader-text {
|
||||
flex: 1;
|
||||
|
||||
h3 {
|
||||
font-size: 15px;
|
||||
font-weight: 500;
|
||||
color: var(--td-text-color-primary);
|
||||
margin: 0 0 4px 0;
|
||||
}
|
||||
|
||||
p {
|
||||
font-size: 13px;
|
||||
color: var(--td-text-color-secondary);
|
||||
margin: 0;
|
||||
line-height: 1.5;
|
||||
}
|
||||
min-width: 0;
|
||||
}
|
||||
}
|
||||
|
||||
// 添加模型按钮样式优化
|
||||
:deep(.add-model-btn) {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
font-weight: 500;
|
||||
height: 32px;
|
||||
padding: 0 16px;
|
||||
font-size: 14px;
|
||||
flex-shrink: 0;
|
||||
h3 {
|
||||
font-size: 16px;
|
||||
font-weight: 600;
|
||||
color: var(--td-text-color-primary);
|
||||
margin: 0 0 4px 0;
|
||||
}
|
||||
|
||||
.add-icon {
|
||||
font-size: 14px;
|
||||
width: 14px;
|
||||
height: 14px;
|
||||
.section-desc {
|
||||
font-size: 13px;
|
||||
color: var(--td-text-color-secondary);
|
||||
margin: 0;
|
||||
line-height: 1.5;
|
||||
}
|
||||
|
||||
:deep(.t-button) {
|
||||
flex-shrink: 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -623,29 +736,24 @@ onMounted(() => {
|
|||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
padding: 12px 16px;
|
||||
padding: 14px 16px;
|
||||
border: 1px solid var(--td-component-stroke);
|
||||
border-radius: 6px;
|
||||
background: var(--td-bg-color-secondarycontainer);
|
||||
transition: all 0.15s ease;
|
||||
border-radius: 8px;
|
||||
background: var(--td-bg-color-container);
|
||||
transition: border-color 0.2s ease, background-color 0.2s ease;
|
||||
position: relative;
|
||||
overflow: visible;
|
||||
|
||||
&:hover {
|
||||
border-color: var(--td-brand-color);
|
||||
background: var(--td-bg-color-container);
|
||||
box-shadow: 0 1px 4px rgba(7, 192, 95, 0.08);
|
||||
}
|
||||
|
||||
// 内置模型样式
|
||||
&.builtin-model {
|
||||
background: var(--td-bg-color-secondarycontainer);
|
||||
border-color: var(--td-component-border);
|
||||
border-color: var(--td-component-stroke);
|
||||
|
||||
&:hover {
|
||||
border-color: var(--td-component-stroke);
|
||||
background: var(--td-bg-color-secondarycontainer);
|
||||
box-shadow: none;
|
||||
border-color: var(--td-brand-color-light);
|
||||
}
|
||||
|
||||
.model-info {
|
||||
|
|
@ -655,7 +763,7 @@ onMounted(() => {
|
|||
|
||||
.model-meta {
|
||||
.source-tag {
|
||||
background: var(--td-bg-color-secondarycontainer);
|
||||
background: var(--td-bg-color-container);
|
||||
color: var(--td-text-color-placeholder);
|
||||
}
|
||||
}
|
||||
|
|
@ -708,8 +816,6 @@ onMounted(() => {
|
|||
align-items: center;
|
||||
gap: 4px;
|
||||
flex-shrink: 0;
|
||||
opacity: 0;
|
||||
transition: opacity 0.15s ease;
|
||||
position: relative;
|
||||
z-index: 1001;
|
||||
|
||||
|
|
@ -724,125 +830,20 @@ onMounted(() => {
|
|||
}
|
||||
}
|
||||
|
||||
.model-card:hover .model-actions {
|
||||
opacity: 1;
|
||||
}
|
||||
|
||||
.empty-state {
|
||||
padding: 48px 0;
|
||||
.empty-models {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
gap: 16px;
|
||||
padding: 32px;
|
||||
text-align: center;
|
||||
color: var(--td-text-color-placeholder);
|
||||
border: 1px dashed var(--td-component-stroke);
|
||||
border-radius: 8px;
|
||||
font-size: 14px;
|
||||
|
||||
.empty-text {
|
||||
font-size: 13px;
|
||||
color: var(--td-text-color-placeholder);
|
||||
margin: 0 0 16px 0;
|
||||
}
|
||||
}
|
||||
|
||||
.builtin-models-info {
|
||||
margin-top: 16px;
|
||||
|
||||
.info-box {
|
||||
background: var(--td-success-color-light);
|
||||
border: 1px solid var(--td-success-color-focus);
|
||||
border-left: 3px solid var(--td-brand-color);
|
||||
border-radius: 6px;
|
||||
padding: 16px;
|
||||
}
|
||||
|
||||
.info-header {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
margin-bottom: 8px;
|
||||
|
||||
.info-icon {
|
||||
font-size: 16px;
|
||||
color: var(--td-brand-color);
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.info-title {
|
||||
font-size: 14px;
|
||||
font-weight: 500;
|
||||
color: var(--td-brand-color-active);
|
||||
}
|
||||
}
|
||||
|
||||
.info-content {
|
||||
font-size: 13px;
|
||||
line-height: 1.6;
|
||||
color: var(--td-success-color);
|
||||
|
||||
p {
|
||||
margin: 0 0 6px 0;
|
||||
|
||||
&:last-child {
|
||||
margin-bottom: 0;
|
||||
}
|
||||
|
||||
&.doc-link {
|
||||
margin-top: 10px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
|
||||
.link-icon {
|
||||
font-size: 13px;
|
||||
color: var(--td-brand-color);
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
a {
|
||||
color: var(--td-brand-color);
|
||||
text-decoration: none;
|
||||
font-weight: 500;
|
||||
transition: color 0.15s;
|
||||
|
||||
&:hover {
|
||||
color: var(--td-brand-color-active);
|
||||
text-decoration: underline;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// TDesign 组件样式覆盖
|
||||
:deep(.t-button) {
|
||||
&.add-model-btn {
|
||||
border-radius: 6px;
|
||||
font-weight: 500;
|
||||
transition: all 0.15s ease;
|
||||
|
||||
&:hover {
|
||||
background: var(--td-brand-color);
|
||||
border-color: var(--td-brand-color);
|
||||
}
|
||||
|
||||
&:active {
|
||||
background: var(--td-brand-color-active);
|
||||
border-color: var(--td-brand-color-active);
|
||||
}
|
||||
}
|
||||
|
||||
&.t-size-s {
|
||||
height: 32px;
|
||||
padding: 0 12px;
|
||||
font-size: 13px;
|
||||
border-radius: 6px;
|
||||
|
||||
&.t-button--variant-outline {
|
||||
color: var(--td-text-color-secondary);
|
||||
border-color: var(--td-component-stroke);
|
||||
|
||||
&:hover {
|
||||
color: var(--td-brand-color);
|
||||
border-color: var(--td-brand-color);
|
||||
background: rgba(7, 192, 95, 0.04);
|
||||
}
|
||||
}
|
||||
p {
|
||||
margin: 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -201,6 +201,7 @@ const navItems = computed(() => [
|
|||
{ key: 'cos', label: t('settings.storage.cos') },
|
||||
{ key: 'tos', label: t('settings.storage.tos') },
|
||||
{ key: 's3', label: 'AWS S3' },
|
||||
{ key: 'oss', label: t('settings.storage.oss') },
|
||||
]
|
||||
},
|
||||
{ key: 'mcp', icon: 'tools', label: t('settings.mcpService') },
|
||||
|
|
|
|||
|
|
@ -34,6 +34,7 @@
|
|||
<t-option value="cos" :label="$t('settings.storage.engineCos')" />
|
||||
<t-option value="tos" :label="$t('settings.storage.engineTos')" />
|
||||
<t-option value="s3" label="AWS S3" />
|
||||
<t-option value="oss" :label="$t('settings.storage.engineOss')" />
|
||||
</t-select>
|
||||
</div>
|
||||
</div>
|
||||
|
|
@ -422,6 +423,80 @@
|
|||
</div>
|
||||
</div>
|
||||
|
||||
<!-- OSS -->
|
||||
<div class="engine-section" data-model-type="oss">
|
||||
<div class="engine-header">
|
||||
<div class="engine-header-info">
|
||||
<div class="engine-title-row">
|
||||
<h3>{{ $t('settings.storage.ossTitle') }}</h3>
|
||||
<t-tag theme="success" variant="light" size="small">{{ $t('settings.storage.configurable') }}</t-tag>
|
||||
</div>
|
||||
<p>
|
||||
{{ $t('settings.storage.ossDesc') }}
|
||||
<a class="engine-link" href="https://oss.console.aliyun.com/" target="_blank" rel="noopener">{{ $t('settings.storage.console') }} ↗</a>
|
||||
<a class="engine-link" href="https://help.aliyun.com/zh/oss/" target="_blank" rel="noopener">{{ $t('settings.storage.docs') }} ↗</a>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="engine-form">
|
||||
<div class="form-field">
|
||||
<label>Endpoint</label>
|
||||
<t-input
|
||||
v-model="config.oss.endpoint"
|
||||
placeholder="e.g. https://oss-cn-hangzhou.aliyuncs.com"
|
||||
clearable
|
||||
/>
|
||||
</div>
|
||||
<div class="form-field">
|
||||
<label>Region</label>
|
||||
<t-input
|
||||
v-model="config.oss.region"
|
||||
placeholder="e.g. cn-hangzhou"
|
||||
clearable
|
||||
/>
|
||||
</div>
|
||||
<div class="form-field">
|
||||
<label>Access Key</label>
|
||||
<t-input
|
||||
v-model="config.oss.access_key"
|
||||
:placeholder="$t('settings.storage.ossAccessKeyPlaceholder')"
|
||||
clearable
|
||||
/>
|
||||
</div>
|
||||
<div class="form-field">
|
||||
<label>Secret Key</label>
|
||||
<t-input
|
||||
v-model="config.oss.secret_key"
|
||||
type="password"
|
||||
:placeholder="$t('settings.storage.ossSecretKeyPlaceholder')"
|
||||
clearable
|
||||
/>
|
||||
</div>
|
||||
<div class="form-field">
|
||||
<label>{{ $t('settings.storage.bucketName') }}</label>
|
||||
<t-input
|
||||
v-model="config.oss.bucket_name"
|
||||
:placeholder="$t('settings.storage.bucketPlaceholder')"
|
||||
clearable
|
||||
/>
|
||||
</div>
|
||||
<div class="form-field">
|
||||
<label>{{ $t('settings.storage.pathPrefix') }}</label>
|
||||
<t-input
|
||||
v-model="config.oss.path_prefix"
|
||||
:placeholder="$t('settings.storage.prefixPlaceholder')"
|
||||
clearable
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="test-bar">
|
||||
<t-button size="small" variant="outline" :loading="checkingOss" @click="onCheckOss">{{ $t('settings.storage.testConnection') }}</t-button>
|
||||
<span v-if="ossCheckResult" :class="['test-msg', ossCheckResult.ok ? 'success' : 'error']">
|
||||
{{ ossCheckResult.message }}
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Save -->
|
||||
<div class="save-bar">
|
||||
<t-button theme="primary" :loading="saving" @click="onSave">{{ $t('settings.storage.saveConfig') }}</t-button>
|
||||
|
|
@ -476,6 +551,17 @@ const defaultConfig = (): StorageEngineConfig => ({
|
|||
bucket_name: '',
|
||||
path_prefix: '',
|
||||
},
|
||||
oss: {
|
||||
endpoint: '',
|
||||
region: '',
|
||||
access_key: '',
|
||||
secret_key: '',
|
||||
bucket_name: '',
|
||||
path_prefix: '',
|
||||
use_temp_bucket: false,
|
||||
temp_bucket_name: '',
|
||||
temp_region: '',
|
||||
},
|
||||
})
|
||||
|
||||
const loading = ref(true)
|
||||
|
|
@ -501,6 +587,8 @@ const checkingTos = ref(false)
|
|||
const tosCheckResult = ref<{ ok: boolean; message: string } | null>(null)
|
||||
const checkingS3 = ref(false)
|
||||
const s3CheckResult = ref<{ ok: boolean; message: string } | null>(null)
|
||||
const checkingOss = ref(false)
|
||||
const ossCheckResult = ref<{ ok: boolean; message: string } | null>(null)
|
||||
|
||||
const minioAvailable = computed(() => {
|
||||
if (config.value.minio?.mode === 'remote') {
|
||||
|
|
@ -558,6 +646,19 @@ async function loadConfig() {
|
|||
path_prefix: d.s3.path_prefix || '',
|
||||
}
|
||||
: defaultConfig().s3!,
|
||||
oss: d.oss
|
||||
? {
|
||||
endpoint: d.oss.endpoint || '',
|
||||
region: d.oss.region || '',
|
||||
access_key: d.oss.access_key || '',
|
||||
secret_key: d.oss.secret_key || '',
|
||||
bucket_name: d.oss.bucket_name || '',
|
||||
path_prefix: d.oss.path_prefix || '',
|
||||
use_temp_bucket: d.oss.use_temp_bucket ?? false,
|
||||
temp_bucket_name: d.oss.temp_bucket_name || '',
|
||||
temp_region: d.oss.temp_region || '',
|
||||
}
|
||||
: defaultConfig().oss!,
|
||||
}
|
||||
}
|
||||
} catch {
|
||||
|
|
@ -649,6 +750,18 @@ function buildPayload(): StorageEngineConfig {
|
|||
bucket_name: (config.value.s3?.bucket_name || '').trim(),
|
||||
path_prefix: (config.value.s3?.path_prefix || '').trim(),
|
||||
},
|
||||
oss: {
|
||||
endpoint: (config.value.oss?.endpoint || '').trim(),
|
||||
region: (config.value.oss?.region || '').trim(),
|
||||
access_key: (config.value.oss?.access_key || '').trim(),
|
||||
secret_key: (config.value.oss?.secret_key || '').trim(),
|
||||
bucket_name: (config.value.oss?.bucket_name || '').trim(),
|
||||
path_prefix: (config.value.oss?.path_prefix || '').trim(),
|
||||
// Temp bucket fields: not exposed in UI; server manages these independently
|
||||
use_temp_bucket: config.value.oss?.use_temp_bucket ?? false,
|
||||
temp_bucket_name: (config.value.oss?.temp_bucket_name || '').trim(),
|
||||
temp_region: (config.value.oss?.temp_region || '').trim(),
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -728,6 +841,20 @@ async function onCheckS3() {
|
|||
}
|
||||
}
|
||||
|
||||
async function onCheckOss() {
|
||||
checkingOss.value = true
|
||||
ossCheckResult.value = null
|
||||
try {
|
||||
const payload = buildPayload()
|
||||
const res = await checkStorageEngine({ provider: 'oss', oss: payload.oss })
|
||||
ossCheckResult.value = res?.data ?? { ok: false, message: t('settings.storage.unknownError') }
|
||||
} catch (e: unknown) {
|
||||
ossCheckResult.value = { ok: false, message: e instanceof Error ? e.message : t('settings.storage.requestFailed') }
|
||||
} finally {
|
||||
checkingOss.value = false
|
||||
}
|
||||
}
|
||||
|
||||
onMounted(loadAll)
|
||||
</script>
|
||||
|
||||
|
|
@ -872,7 +999,7 @@ onMounted(loadAll)
|
|||
label {
|
||||
font-size: 13px;
|
||||
font-weight: 500;
|
||||
color: var(--td-text-color-secondary)555;
|
||||
color: var(--td-text-color-secondary);
|
||||
}
|
||||
|
||||
&--inline {
|
||||
|
|
|
|||
|
|
@ -33,11 +33,11 @@
|
|||
{{ systemInfo?.version || $t('system.unknown') }}
|
||||
<t-tag
|
||||
v-if="systemInfo?.edition"
|
||||
theme="default"
|
||||
:theme="systemInfo.edition === 'lite' ? 'primary' : 'default'"
|
||||
variant="light"
|
||||
size="small"
|
||||
style="margin-left: 8px;"
|
||||
>{{ systemInfo.edition || 'Standard' }}</t-tag>
|
||||
>{{ systemInfo.edition === 'lite' ? 'Lite' : 'Standard' }}</t-tag>
|
||||
<span v-if="systemInfo?.commit_id" class="commit-info">
|
||||
({{ systemInfo.commit_id }})
|
||||
</span>
|
||||
|
|
|
|||
|
|
@ -64,7 +64,7 @@
|
|||
<t-option v-for="pt in providerTypes" :key="pt.id" :value="pt.id" :label="pt.name">
|
||||
<div class="provider-option">
|
||||
<span>{{ pt.name }}</span>
|
||||
<t-tag v-if="pt.free" theme="success" size="small" variant="light">{{ t('webSearchSettings.free') }}</t-tag>
|
||||
<t-tag v-if="isProviderFree(pt)" theme="success" size="small" variant="light">{{ t('webSearchSettings.free') }}</t-tag>
|
||||
</div>
|
||||
</t-option>
|
||||
</t-select>
|
||||
|
|
@ -113,7 +113,7 @@
|
|||
<div class="dialog-footer">
|
||||
<div class="footer-left">
|
||||
<t-button
|
||||
v-if="selectedProviderType && !selectedProviderType.free"
|
||||
v-if="selectedProviderType && !isProviderFree(selectedProviderType)"
|
||||
theme="default"
|
||||
variant="outline"
|
||||
:loading="testing"
|
||||
|
|
@ -179,6 +179,10 @@ const selectedProviderType = computed(() => {
|
|||
return providerTypes.value.find(pt => pt.id === providerForm.value.provider)
|
||||
})
|
||||
|
||||
const isProviderFree = (providerType: WebSearchProviderTypeInfo) => {
|
||||
return !providerType.requires_api_key && !providerType.requires_engine_id
|
||||
}
|
||||
|
||||
// ===== Methods =====
|
||||
const onProviderTypeChange = () => {
|
||||
providerForm.value.parameters = {}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,20 @@
|
|||
// Cynhyrchwyd y ffeil hon yn awtomatig. PEIDIWCH Â MODIWL
|
||||
// This file is automatically generated. DO NOT EDIT
|
||||
|
||||
export function AutoCheckForUpdates():Promise<void>;
|
||||
|
||||
export function CheckForUpdates():Promise<void>;
|
||||
|
||||
export function GetAPIBaseURL():Promise<string>;
|
||||
|
||||
export function GetAPILanBaseURL():Promise<string>;
|
||||
|
||||
export function GetDesktopHTTPBindPublicSetting():Promise<boolean>;
|
||||
|
||||
export function GetDesktopHTTPPortSetting():Promise<number>;
|
||||
|
||||
export function GetDesktopListenPublicActive():Promise<boolean>;
|
||||
|
||||
export function SetDesktopHTTPBindPublicSetting(arg1:boolean):Promise<void>;
|
||||
|
||||
export function SetDesktopHTTPPortSetting(arg1:number):Promise<void>;
|
||||
|
|
@ -0,0 +1,39 @@
|
|||
// @ts-check
|
||||
// Cynhyrchwyd y ffeil hon yn awtomatig. PEIDIWCH Â MODIWL
|
||||
// This file is automatically generated. DO NOT EDIT
|
||||
|
||||
export function AutoCheckForUpdates() {
|
||||
return window['go']['main']['App']['AutoCheckForUpdates']();
|
||||
}
|
||||
|
||||
export function CheckForUpdates() {
|
||||
return window['go']['main']['App']['CheckForUpdates']();
|
||||
}
|
||||
|
||||
export function GetAPIBaseURL() {
|
||||
return window['go']['main']['App']['GetAPIBaseURL']();
|
||||
}
|
||||
|
||||
export function GetAPILanBaseURL() {
|
||||
return window['go']['main']['App']['GetAPILanBaseURL']();
|
||||
}
|
||||
|
||||
export function GetDesktopHTTPBindPublicSetting() {
|
||||
return window['go']['main']['App']['GetDesktopHTTPBindPublicSetting']();
|
||||
}
|
||||
|
||||
export function GetDesktopHTTPPortSetting() {
|
||||
return window['go']['main']['App']['GetDesktopHTTPPortSetting']();
|
||||
}
|
||||
|
||||
export function GetDesktopListenPublicActive() {
|
||||
return window['go']['main']['App']['GetDesktopListenPublicActive']();
|
||||
}
|
||||
|
||||
export function SetDesktopHTTPBindPublicSetting(arg1) {
|
||||
return window['go']['main']['App']['SetDesktopHTTPBindPublicSetting'](arg1);
|
||||
}
|
||||
|
||||
export function SetDesktopHTTPPortSetting(arg1) {
|
||||
return window['go']['main']['App']['SetDesktopHTTPPortSetting'](arg1);
|
||||
}
|
||||
|
|
@ -0,0 +1,24 @@
|
|||
{
|
||||
"name": "@wailsapp/runtime",
|
||||
"version": "2.0.0",
|
||||
"description": "Wails Javascript runtime library",
|
||||
"main": "runtime.js",
|
||||
"types": "runtime.d.ts",
|
||||
"scripts": {
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/wailsapp/wails.git"
|
||||
},
|
||||
"keywords": [
|
||||
"Wails",
|
||||
"Javascript",
|
||||
"Go"
|
||||
],
|
||||
"author": "Lea Anthony <lea.anthony@gmail.com>",
|
||||
"license": "MIT",
|
||||
"bugs": {
|
||||
"url": "https://github.com/wailsapp/wails/issues"
|
||||
},
|
||||
"homepage": "https://github.com/wailsapp/wails#readme"
|
||||
}
|
||||
|
|
@ -0,0 +1,330 @@
|
|||
/*
|
||||
_ __ _ __
|
||||
| | / /___ _(_) /____
|
||||
| | /| / / __ `/ / / ___/
|
||||
| |/ |/ / /_/ / / (__ )
|
||||
|__/|__/\__,_/_/_/____/
|
||||
The electron alternative for Go
|
||||
(c) Lea Anthony 2019-present
|
||||
*/
|
||||
|
||||
export interface Position {
|
||||
x: number;
|
||||
y: number;
|
||||
}
|
||||
|
||||
export interface Size {
|
||||
w: number;
|
||||
h: number;
|
||||
}
|
||||
|
||||
export interface Screen {
|
||||
isCurrent: boolean;
|
||||
isPrimary: boolean;
|
||||
width : number
|
||||
height : number
|
||||
}
|
||||
|
||||
// Environment information such as platform, buildtype, ...
|
||||
export interface EnvironmentInfo {
|
||||
buildType: string;
|
||||
platform: string;
|
||||
arch: string;
|
||||
}
|
||||
|
||||
// [EventsEmit](https://wails.io/docs/reference/runtime/events#eventsemit)
|
||||
// emits the given event. Optional data may be passed with the event.
|
||||
// This will trigger any event listeners.
|
||||
export function EventsEmit(eventName: string, ...data: any): void;
|
||||
|
||||
// [EventsOn](https://wails.io/docs/reference/runtime/events#eventson) sets up a listener for the given event name.
|
||||
export function EventsOn(eventName: string, callback: (...data: any) => void): () => void;
|
||||
|
||||
// [EventsOnMultiple](https://wails.io/docs/reference/runtime/events#eventsonmultiple)
|
||||
// sets up a listener for the given event name, but will only trigger a given number times.
|
||||
export function EventsOnMultiple(eventName: string, callback: (...data: any) => void, maxCallbacks: number): () => void;
|
||||
|
||||
// [EventsOnce](https://wails.io/docs/reference/runtime/events#eventsonce)
|
||||
// sets up a listener for the given event name, but will only trigger once.
|
||||
export function EventsOnce(eventName: string, callback: (...data: any) => void): () => void;
|
||||
|
||||
// [EventsOff](https://wails.io/docs/reference/runtime/events#eventsoff)
|
||||
// unregisters the listener for the given event name.
|
||||
export function EventsOff(eventName: string, ...additionalEventNames: string[]): void;
|
||||
|
||||
// [EventsOffAll](https://wails.io/docs/reference/runtime/events#eventsoffall)
|
||||
// unregisters all listeners.
|
||||
export function EventsOffAll(): void;
|
||||
|
||||
// [LogPrint](https://wails.io/docs/reference/runtime/log#logprint)
|
||||
// logs the given message as a raw message
|
||||
export function LogPrint(message: string): void;
|
||||
|
||||
// [LogTrace](https://wails.io/docs/reference/runtime/log#logtrace)
|
||||
// logs the given message at the `trace` log level.
|
||||
export function LogTrace(message: string): void;
|
||||
|
||||
// [LogDebug](https://wails.io/docs/reference/runtime/log#logdebug)
|
||||
// logs the given message at the `debug` log level.
|
||||
export function LogDebug(message: string): void;
|
||||
|
||||
// [LogError](https://wails.io/docs/reference/runtime/log#logerror)
|
||||
// logs the given message at the `error` log level.
|
||||
export function LogError(message: string): void;
|
||||
|
||||
// [LogFatal](https://wails.io/docs/reference/runtime/log#logfatal)
|
||||
// logs the given message at the `fatal` log level.
|
||||
// The application will quit after calling this method.
|
||||
export function LogFatal(message: string): void;
|
||||
|
||||
// [LogInfo](https://wails.io/docs/reference/runtime/log#loginfo)
|
||||
// logs the given message at the `info` log level.
|
||||
export function LogInfo(message: string): void;
|
||||
|
||||
// [LogWarning](https://wails.io/docs/reference/runtime/log#logwarning)
|
||||
// logs the given message at the `warning` log level.
|
||||
export function LogWarning(message: string): void;
|
||||
|
||||
// [WindowReload](https://wails.io/docs/reference/runtime/window#windowreload)
|
||||
// Forces a reload by the main application as well as connected browsers.
|
||||
export function WindowReload(): void;
|
||||
|
||||
// [WindowReloadApp](https://wails.io/docs/reference/runtime/window#windowreloadapp)
|
||||
// Reloads the application frontend.
|
||||
export function WindowReloadApp(): void;
|
||||
|
||||
// [WindowSetAlwaysOnTop](https://wails.io/docs/reference/runtime/window#windowsetalwaysontop)
|
||||
// Sets the window AlwaysOnTop or not on top.
|
||||
export function WindowSetAlwaysOnTop(b: boolean): void;
|
||||
|
||||
// [WindowSetSystemDefaultTheme](https://wails.io/docs/next/reference/runtime/window#windowsetsystemdefaulttheme)
|
||||
// *Windows only*
|
||||
// Sets window theme to system default (dark/light).
|
||||
export function WindowSetSystemDefaultTheme(): void;
|
||||
|
||||
// [WindowSetLightTheme](https://wails.io/docs/next/reference/runtime/window#windowsetlighttheme)
|
||||
// *Windows only*
|
||||
// Sets window to light theme.
|
||||
export function WindowSetLightTheme(): void;
|
||||
|
||||
// [WindowSetDarkTheme](https://wails.io/docs/next/reference/runtime/window#windowsetdarktheme)
|
||||
// *Windows only*
|
||||
// Sets window to dark theme.
|
||||
export function WindowSetDarkTheme(): void;
|
||||
|
||||
// [WindowCenter](https://wails.io/docs/reference/runtime/window#windowcenter)
|
||||
// Centers the window on the monitor the window is currently on.
|
||||
export function WindowCenter(): void;
|
||||
|
||||
// [WindowSetTitle](https://wails.io/docs/reference/runtime/window#windowsettitle)
|
||||
// Sets the text in the window title bar.
|
||||
export function WindowSetTitle(title: string): void;
|
||||
|
||||
// [WindowFullscreen](https://wails.io/docs/reference/runtime/window#windowfullscreen)
|
||||
// Makes the window full screen.
|
||||
export function WindowFullscreen(): void;
|
||||
|
||||
// [WindowUnfullscreen](https://wails.io/docs/reference/runtime/window#windowunfullscreen)
|
||||
// Restores the previous window dimensions and position prior to full screen.
|
||||
export function WindowUnfullscreen(): void;
|
||||
|
||||
// [WindowIsFullscreen](https://wails.io/docs/reference/runtime/window#windowisfullscreen)
|
||||
// Returns the state of the window, i.e. whether the window is in full screen mode or not.
|
||||
export function WindowIsFullscreen(): Promise<boolean>;
|
||||
|
||||
// [WindowSetSize](https://wails.io/docs/reference/runtime/window#windowsetsize)
|
||||
// Sets the width and height of the window.
|
||||
export function WindowSetSize(width: number, height: number): void;
|
||||
|
||||
// [WindowGetSize](https://wails.io/docs/reference/runtime/window#windowgetsize)
|
||||
// Gets the width and height of the window.
|
||||
export function WindowGetSize(): Promise<Size>;
|
||||
|
||||
// [WindowSetMaxSize](https://wails.io/docs/reference/runtime/window#windowsetmaxsize)
|
||||
// Sets the maximum window size. Will resize the window if the window is currently larger than the given dimensions.
|
||||
// Setting a size of 0,0 will disable this constraint.
|
||||
export function WindowSetMaxSize(width: number, height: number): void;
|
||||
|
||||
// [WindowSetMinSize](https://wails.io/docs/reference/runtime/window#windowsetminsize)
|
||||
// Sets the minimum window size. Will resize the window if the window is currently smaller than the given dimensions.
|
||||
// Setting a size of 0,0 will disable this constraint.
|
||||
export function WindowSetMinSize(width: number, height: number): void;
|
||||
|
||||
// [WindowSetPosition](https://wails.io/docs/reference/runtime/window#windowsetposition)
|
||||
// Sets the window position relative to the monitor the window is currently on.
|
||||
export function WindowSetPosition(x: number, y: number): void;
|
||||
|
||||
// [WindowGetPosition](https://wails.io/docs/reference/runtime/window#windowgetposition)
|
||||
// Gets the window position relative to the monitor the window is currently on.
|
||||
export function WindowGetPosition(): Promise<Position>;
|
||||
|
||||
// [WindowHide](https://wails.io/docs/reference/runtime/window#windowhide)
|
||||
// Hides the window.
|
||||
export function WindowHide(): void;
|
||||
|
||||
// [WindowShow](https://wails.io/docs/reference/runtime/window#windowshow)
|
||||
// Shows the window, if it is currently hidden.
|
||||
export function WindowShow(): void;
|
||||
|
||||
// [WindowMaximise](https://wails.io/docs/reference/runtime/window#windowmaximise)
|
||||
// Maximises the window to fill the screen.
|
||||
export function WindowMaximise(): void;
|
||||
|
||||
// [WindowToggleMaximise](https://wails.io/docs/reference/runtime/window#windowtogglemaximise)
|
||||
// Toggles between Maximised and UnMaximised.
|
||||
export function WindowToggleMaximise(): void;
|
||||
|
||||
// [WindowUnmaximise](https://wails.io/docs/reference/runtime/window#windowunmaximise)
|
||||
// Restores the window to the dimensions and position prior to maximising.
|
||||
export function WindowUnmaximise(): void;
|
||||
|
||||
// [WindowIsMaximised](https://wails.io/docs/reference/runtime/window#windowismaximised)
|
||||
// Returns the state of the window, i.e. whether the window is maximised or not.
|
||||
export function WindowIsMaximised(): Promise<boolean>;
|
||||
|
||||
// [WindowMinimise](https://wails.io/docs/reference/runtime/window#windowminimise)
|
||||
// Minimises the window.
|
||||
export function WindowMinimise(): void;
|
||||
|
||||
// [WindowUnminimise](https://wails.io/docs/reference/runtime/window#windowunminimise)
|
||||
// Restores the window to the dimensions and position prior to minimising.
|
||||
export function WindowUnminimise(): void;
|
||||
|
||||
// [WindowIsMinimised](https://wails.io/docs/reference/runtime/window#windowisminimised)
|
||||
// Returns the state of the window, i.e. whether the window is minimised or not.
|
||||
export function WindowIsMinimised(): Promise<boolean>;
|
||||
|
||||
// [WindowIsNormal](https://wails.io/docs/reference/runtime/window#windowisnormal)
|
||||
// Returns the state of the window, i.e. whether the window is normal or not.
|
||||
export function WindowIsNormal(): Promise<boolean>;
|
||||
|
||||
// [WindowSetBackgroundColour](https://wails.io/docs/reference/runtime/window#windowsetbackgroundcolour)
|
||||
// Sets the background colour of the window to the given RGBA colour definition. This colour will show through for all transparent pixels.
|
||||
export function WindowSetBackgroundColour(R: number, G: number, B: number, A: number): void;
|
||||
|
||||
// [ScreenGetAll](https://wails.io/docs/reference/runtime/window#screengetall)
|
||||
// Gets the all screens. Call this anew each time you want to refresh data from the underlying windowing system.
|
||||
export function ScreenGetAll(): Promise<Screen[]>;
|
||||
|
||||
// [BrowserOpenURL](https://wails.io/docs/reference/runtime/browser#browseropenurl)
|
||||
// Opens the given URL in the system browser.
|
||||
export function BrowserOpenURL(url: string): void;
|
||||
|
||||
// [Environment](https://wails.io/docs/reference/runtime/intro#environment)
|
||||
// Returns information about the environment
|
||||
export function Environment(): Promise<EnvironmentInfo>;
|
||||
|
||||
// [Quit](https://wails.io/docs/reference/runtime/intro#quit)
|
||||
// Quits the application.
|
||||
export function Quit(): void;
|
||||
|
||||
// [Hide](https://wails.io/docs/reference/runtime/intro#hide)
|
||||
// Hides the application.
|
||||
export function Hide(): void;
|
||||
|
||||
// [Show](https://wails.io/docs/reference/runtime/intro#show)
|
||||
// Shows the application.
|
||||
export function Show(): void;
|
||||
|
||||
// [ClipboardGetText](https://wails.io/docs/reference/runtime/clipboard#clipboardgettext)
|
||||
// Returns the current text stored on clipboard
|
||||
export function ClipboardGetText(): Promise<string>;
|
||||
|
||||
// [ClipboardSetText](https://wails.io/docs/reference/runtime/clipboard#clipboardsettext)
|
||||
// Sets a text on the clipboard
|
||||
export function ClipboardSetText(text: string): Promise<boolean>;
|
||||
|
||||
// [OnFileDrop](https://wails.io/docs/reference/runtime/draganddrop#onfiledrop)
|
||||
// OnFileDrop listens to drag and drop events and calls the callback with the coordinates of the drop and an array of path strings.
|
||||
export function OnFileDrop(callback: (x: number, y: number ,paths: string[]) => void, useDropTarget: boolean) :void
|
||||
|
||||
// [OnFileDropOff](https://wails.io/docs/reference/runtime/draganddrop#dragandddropoff)
|
||||
// OnFileDropOff removes the drag and drop listeners and handlers.
|
||||
export function OnFileDropOff() :void
|
||||
|
||||
// Check if the file path resolver is available
|
||||
export function CanResolveFilePaths(): boolean;
|
||||
|
||||
// Resolves file paths for an array of files
|
||||
export function ResolveFilePaths(files: File[]): void
|
||||
|
||||
// Notification types
|
||||
export interface NotificationOptions {
|
||||
id: string;
|
||||
title: string;
|
||||
subtitle?: string; // macOS and Linux only
|
||||
body?: string;
|
||||
categoryId?: string;
|
||||
data?: { [key: string]: any };
|
||||
}
|
||||
|
||||
export interface NotificationAction {
|
||||
id?: string;
|
||||
title?: string;
|
||||
destructive?: boolean; // macOS-specific
|
||||
}
|
||||
|
||||
export interface NotificationCategory {
|
||||
id?: string;
|
||||
actions?: NotificationAction[];
|
||||
hasReplyField?: boolean;
|
||||
replyPlaceholder?: string;
|
||||
replyButtonTitle?: string;
|
||||
}
|
||||
|
||||
// [InitializeNotifications](https://wails.io/docs/reference/runtime/notification#initializenotifications)
|
||||
// Initializes the notification service for the application.
|
||||
// This must be called before sending any notifications.
|
||||
export function InitializeNotifications(): Promise<void>;
|
||||
|
||||
// [CleanupNotifications](https://wails.io/docs/reference/runtime/notification#cleanupnotifications)
|
||||
// Cleans up notification resources and releases any held connections.
|
||||
export function CleanupNotifications(): Promise<void>;
|
||||
|
||||
// [IsNotificationAvailable](https://wails.io/docs/reference/runtime/notification#isnotificationavailable)
|
||||
// Checks if notifications are available on the current platform.
|
||||
export function IsNotificationAvailable(): Promise<boolean>;
|
||||
|
||||
// [RequestNotificationAuthorization](https://wails.io/docs/reference/runtime/notification#requestnotificationauthorization)
|
||||
// Requests notification authorization from the user (macOS only).
|
||||
export function RequestNotificationAuthorization(): Promise<boolean>;
|
||||
|
||||
// [CheckNotificationAuthorization](https://wails.io/docs/reference/runtime/notification#checknotificationauthorization)
|
||||
// Checks the current notification authorization status (macOS only).
|
||||
export function CheckNotificationAuthorization(): Promise<boolean>;
|
||||
|
||||
// [SendNotification](https://wails.io/docs/reference/runtime/notification#sendnotification)
|
||||
// Sends a basic notification with the given options.
|
||||
export function SendNotification(options: NotificationOptions): Promise<void>;
|
||||
|
||||
// [SendNotificationWithActions](https://wails.io/docs/reference/runtime/notification#sendnotificationwithactions)
|
||||
// Sends a notification with action buttons. Requires a registered category.
|
||||
export function SendNotificationWithActions(options: NotificationOptions): Promise<void>;
|
||||
|
||||
// [RegisterNotificationCategory](https://wails.io/docs/reference/runtime/notification#registernotificationcategory)
|
||||
// Registers a notification category that can be used with SendNotificationWithActions.
|
||||
export function RegisterNotificationCategory(category: NotificationCategory): Promise<void>;
|
||||
|
||||
// [RemoveNotificationCategory](https://wails.io/docs/reference/runtime/notification#removenotificationcategory)
|
||||
// Removes a previously registered notification category.
|
||||
export function RemoveNotificationCategory(categoryId: string): Promise<void>;
|
||||
|
||||
// [RemoveAllPendingNotifications](https://wails.io/docs/reference/runtime/notification#removeallpendingnotifications)
|
||||
// Removes all pending notifications from the notification center.
|
||||
export function RemoveAllPendingNotifications(): Promise<void>;
|
||||
|
||||
// [RemovePendingNotification](https://wails.io/docs/reference/runtime/notification#removependingnotification)
|
||||
// Removes a specific pending notification by its identifier.
|
||||
export function RemovePendingNotification(identifier: string): Promise<void>;
|
||||
|
||||
// [RemoveAllDeliveredNotifications](https://wails.io/docs/reference/runtime/notification#removealldeliverednotifications)
|
||||
// Removes all delivered notifications from the notification center.
|
||||
export function RemoveAllDeliveredNotifications(): Promise<void>;
|
||||
|
||||
// [RemoveDeliveredNotification](https://wails.io/docs/reference/runtime/notification#removedeliverednotification)
|
||||
// Removes a specific delivered notification by its identifier.
|
||||
export function RemoveDeliveredNotification(identifier: string): Promise<void>;
|
||||
|
||||
// [RemoveNotification](https://wails.io/docs/reference/runtime/notification#removenotification)
|
||||
// Removes a notification by its identifier (cross-platform convenience function).
|
||||
export function RemoveNotification(identifier: string): Promise<void>;
|
||||
|
|
@ -0,0 +1,298 @@
|
|||
/*
|
||||
_ __ _ __
|
||||
| | / /___ _(_) /____
|
||||
| | /| / / __ `/ / / ___/
|
||||
| |/ |/ / /_/ / / (__ )
|
||||
|__/|__/\__,_/_/_/____/
|
||||
The electron alternative for Go
|
||||
(c) Lea Anthony 2019-present
|
||||
*/
|
||||
|
||||
export function LogPrint(message) {
|
||||
window.runtime.LogPrint(message);
|
||||
}
|
||||
|
||||
export function LogTrace(message) {
|
||||
window.runtime.LogTrace(message);
|
||||
}
|
||||
|
||||
export function LogDebug(message) {
|
||||
window.runtime.LogDebug(message);
|
||||
}
|
||||
|
||||
export function LogInfo(message) {
|
||||
window.runtime.LogInfo(message);
|
||||
}
|
||||
|
||||
export function LogWarning(message) {
|
||||
window.runtime.LogWarning(message);
|
||||
}
|
||||
|
||||
export function LogError(message) {
|
||||
window.runtime.LogError(message);
|
||||
}
|
||||
|
||||
export function LogFatal(message) {
|
||||
window.runtime.LogFatal(message);
|
||||
}
|
||||
|
||||
export function EventsOnMultiple(eventName, callback, maxCallbacks) {
|
||||
return window.runtime.EventsOnMultiple(eventName, callback, maxCallbacks);
|
||||
}
|
||||
|
||||
export function EventsOn(eventName, callback) {
|
||||
return EventsOnMultiple(eventName, callback, -1);
|
||||
}
|
||||
|
||||
export function EventsOff(eventName, ...additionalEventNames) {
|
||||
return window.runtime.EventsOff(eventName, ...additionalEventNames);
|
||||
}
|
||||
|
||||
export function EventsOffAll() {
|
||||
return window.runtime.EventsOffAll();
|
||||
}
|
||||
|
||||
export function EventsOnce(eventName, callback) {
|
||||
return EventsOnMultiple(eventName, callback, 1);
|
||||
}
|
||||
|
||||
export function EventsEmit(eventName) {
|
||||
let args = [eventName].slice.call(arguments);
|
||||
return window.runtime.EventsEmit.apply(null, args);
|
||||
}
|
||||
|
||||
export function WindowReload() {
|
||||
window.runtime.WindowReload();
|
||||
}
|
||||
|
||||
export function WindowReloadApp() {
|
||||
window.runtime.WindowReloadApp();
|
||||
}
|
||||
|
||||
export function WindowSetAlwaysOnTop(b) {
|
||||
window.runtime.WindowSetAlwaysOnTop(b);
|
||||
}
|
||||
|
||||
export function WindowSetSystemDefaultTheme() {
|
||||
window.runtime.WindowSetSystemDefaultTheme();
|
||||
}
|
||||
|
||||
export function WindowSetLightTheme() {
|
||||
window.runtime.WindowSetLightTheme();
|
||||
}
|
||||
|
||||
export function WindowSetDarkTheme() {
|
||||
window.runtime.WindowSetDarkTheme();
|
||||
}
|
||||
|
||||
export function WindowCenter() {
|
||||
window.runtime.WindowCenter();
|
||||
}
|
||||
|
||||
export function WindowSetTitle(title) {
|
||||
window.runtime.WindowSetTitle(title);
|
||||
}
|
||||
|
||||
export function WindowFullscreen() {
|
||||
window.runtime.WindowFullscreen();
|
||||
}
|
||||
|
||||
export function WindowUnfullscreen() {
|
||||
window.runtime.WindowUnfullscreen();
|
||||
}
|
||||
|
||||
export function WindowIsFullscreen() {
|
||||
return window.runtime.WindowIsFullscreen();
|
||||
}
|
||||
|
||||
export function WindowGetSize() {
|
||||
return window.runtime.WindowGetSize();
|
||||
}
|
||||
|
||||
export function WindowSetSize(width, height) {
|
||||
window.runtime.WindowSetSize(width, height);
|
||||
}
|
||||
|
||||
export function WindowSetMaxSize(width, height) {
|
||||
window.runtime.WindowSetMaxSize(width, height);
|
||||
}
|
||||
|
||||
export function WindowSetMinSize(width, height) {
|
||||
window.runtime.WindowSetMinSize(width, height);
|
||||
}
|
||||
|
||||
export function WindowSetPosition(x, y) {
|
||||
window.runtime.WindowSetPosition(x, y);
|
||||
}
|
||||
|
||||
export function WindowGetPosition() {
|
||||
return window.runtime.WindowGetPosition();
|
||||
}
|
||||
|
||||
export function WindowHide() {
|
||||
window.runtime.WindowHide();
|
||||
}
|
||||
|
||||
export function WindowShow() {
|
||||
window.runtime.WindowShow();
|
||||
}
|
||||
|
||||
export function WindowMaximise() {
|
||||
window.runtime.WindowMaximise();
|
||||
}
|
||||
|
||||
export function WindowToggleMaximise() {
|
||||
window.runtime.WindowToggleMaximise();
|
||||
}
|
||||
|
||||
export function WindowUnmaximise() {
|
||||
window.runtime.WindowUnmaximise();
|
||||
}
|
||||
|
||||
export function WindowIsMaximised() {
|
||||
return window.runtime.WindowIsMaximised();
|
||||
}
|
||||
|
||||
export function WindowMinimise() {
|
||||
window.runtime.WindowMinimise();
|
||||
}
|
||||
|
||||
export function WindowUnminimise() {
|
||||
window.runtime.WindowUnminimise();
|
||||
}
|
||||
|
||||
export function WindowSetBackgroundColour(R, G, B, A) {
|
||||
window.runtime.WindowSetBackgroundColour(R, G, B, A);
|
||||
}
|
||||
|
||||
export function ScreenGetAll() {
|
||||
return window.runtime.ScreenGetAll();
|
||||
}
|
||||
|
||||
export function WindowIsMinimised() {
|
||||
return window.runtime.WindowIsMinimised();
|
||||
}
|
||||
|
||||
export function WindowIsNormal() {
|
||||
return window.runtime.WindowIsNormal();
|
||||
}
|
||||
|
||||
export function BrowserOpenURL(url) {
|
||||
window.runtime.BrowserOpenURL(url);
|
||||
}
|
||||
|
||||
export function Environment() {
|
||||
return window.runtime.Environment();
|
||||
}
|
||||
|
||||
export function Quit() {
|
||||
window.runtime.Quit();
|
||||
}
|
||||
|
||||
export function Hide() {
|
||||
window.runtime.Hide();
|
||||
}
|
||||
|
||||
export function Show() {
|
||||
window.runtime.Show();
|
||||
}
|
||||
|
||||
export function ClipboardGetText() {
|
||||
return window.runtime.ClipboardGetText();
|
||||
}
|
||||
|
||||
export function ClipboardSetText(text) {
|
||||
return window.runtime.ClipboardSetText(text);
|
||||
}
|
||||
|
||||
/**
|
||||
* Callback for OnFileDrop returns a slice of file path strings when a drop is finished.
|
||||
*
|
||||
* @export
|
||||
* @callback OnFileDropCallback
|
||||
* @param {number} x - x coordinate of the drop
|
||||
* @param {number} y - y coordinate of the drop
|
||||
* @param {string[]} paths - A list of file paths.
|
||||
*/
|
||||
|
||||
/**
|
||||
* OnFileDrop listens to drag and drop events and calls the callback with the coordinates of the drop and an array of path strings.
|
||||
*
|
||||
* @export
|
||||
* @param {OnFileDropCallback} callback - Callback for OnFileDrop returns a slice of file path strings when a drop is finished.
|
||||
* @param {boolean} [useDropTarget=true] - Only call the callback when the drop finished on an element that has the drop target style. (--wails-drop-target)
|
||||
*/
|
||||
export function OnFileDrop(callback, useDropTarget) {
|
||||
return window.runtime.OnFileDrop(callback, useDropTarget);
|
||||
}
|
||||
|
||||
/**
|
||||
* OnFileDropOff removes the drag and drop listeners and handlers.
|
||||
*/
|
||||
export function OnFileDropOff() {
|
||||
return window.runtime.OnFileDropOff();
|
||||
}
|
||||
|
||||
export function CanResolveFilePaths() {
|
||||
return window.runtime.CanResolveFilePaths();
|
||||
}
|
||||
|
||||
export function ResolveFilePaths(files) {
|
||||
return window.runtime.ResolveFilePaths(files);
|
||||
}
|
||||
|
||||
export function InitializeNotifications() {
|
||||
return window.runtime.InitializeNotifications();
|
||||
}
|
||||
|
||||
export function CleanupNotifications() {
|
||||
return window.runtime.CleanupNotifications();
|
||||
}
|
||||
|
||||
export function IsNotificationAvailable() {
|
||||
return window.runtime.IsNotificationAvailable();
|
||||
}
|
||||
|
||||
export function RequestNotificationAuthorization() {
|
||||
return window.runtime.RequestNotificationAuthorization();
|
||||
}
|
||||
|
||||
export function CheckNotificationAuthorization() {
|
||||
return window.runtime.CheckNotificationAuthorization();
|
||||
}
|
||||
|
||||
export function SendNotification(options) {
|
||||
return window.runtime.SendNotification(options);
|
||||
}
|
||||
|
||||
export function SendNotificationWithActions(options) {
|
||||
return window.runtime.SendNotificationWithActions(options);
|
||||
}
|
||||
|
||||
export function RegisterNotificationCategory(category) {
|
||||
return window.runtime.RegisterNotificationCategory(category);
|
||||
}
|
||||
|
||||
export function RemoveNotificationCategory(categoryId) {
|
||||
return window.runtime.RemoveNotificationCategory(categoryId);
|
||||
}
|
||||
|
||||
export function RemoveAllPendingNotifications() {
|
||||
return window.runtime.RemoveAllPendingNotifications();
|
||||
}
|
||||
|
||||
export function RemovePendingNotification(identifier) {
|
||||
return window.runtime.RemovePendingNotification(identifier);
|
||||
}
|
||||
|
||||
export function RemoveAllDeliveredNotifications() {
|
||||
return window.runtime.RemoveAllDeliveredNotifications();
|
||||
}
|
||||
|
||||
export function RemoveDeliveredNotification(identifier) {
|
||||
return window.runtime.RemoveDeliveredNotification(identifier);
|
||||
}
|
||||
|
||||
export function RemoveNotification(identifier) {
|
||||
return window.runtime.RemoveNotification(identifier);
|
||||
}
|
||||
34
go.mod
34
go.mod
|
|
@ -24,12 +24,13 @@ require (
|
|||
github.com/google/uuid v1.6.0
|
||||
github.com/gorilla/websocket v1.5.3
|
||||
github.com/hibiken/asynq v0.25.1
|
||||
github.com/joho/godotenv v1.5.1
|
||||
github.com/larksuite/oapi-sdk-go/v3 v3.5.3
|
||||
github.com/longbridgeapp/opencc v0.3.13
|
||||
github.com/mark3labs/mcp-go v0.43.0
|
||||
github.com/milvus-io/milvus/client/v2 v2.6.2
|
||||
github.com/minio/minio-go/v7 v7.0.91
|
||||
github.com/neo4j/neo4j-go-driver/v6 v6.0.0-alpha.1
|
||||
github.com/neo4j/neo4j-go-driver/v6 v6.0.0
|
||||
github.com/ollama/ollama v0.11.4
|
||||
github.com/open-dingtalk/dingtalk-stream-sdk-go v0.9.1
|
||||
github.com/panjf2000/ants/v2 v2.11.3
|
||||
|
|
@ -50,6 +51,7 @@ require (
|
|||
github.com/tencentyun/cos-go-sdk-v5 v0.7.65
|
||||
github.com/tiktoken-go/tokenizer v0.7.0
|
||||
github.com/volcengine/ve-tos-golang-sdk/v2 v2.7.23
|
||||
github.com/wailsapp/wails/v2 v2.12.0
|
||||
github.com/weaviate/weaviate v1.33.0-rc.1
|
||||
github.com/weaviate/weaviate-go-client/v5 v5.5.0
|
||||
github.com/yanyiwu/gojieba v1.4.5
|
||||
|
|
@ -61,12 +63,14 @@ require (
|
|||
go.opentelemetry.io/otel/trace v1.38.0
|
||||
go.uber.org/dig v1.18.1
|
||||
golang.org/x/crypto v0.46.0
|
||||
golang.org/x/mod v0.31.0
|
||||
golang.org/x/net v0.48.0
|
||||
golang.org/x/sync v0.19.0
|
||||
golang.org/x/sys v0.40.0
|
||||
golang.org/x/time v0.14.0
|
||||
google.golang.org/api v0.259.0
|
||||
google.golang.org/grpc v1.78.0
|
||||
google.golang.org/protobuf v1.36.11
|
||||
gopkg.in/natefinch/lumberjack.v2 v2.2.1
|
||||
gopkg.in/yaml.v3 v3.0.1
|
||||
gorm.io/driver/postgres v1.5.11
|
||||
gorm.io/driver/sqlite v1.6.0
|
||||
|
|
@ -77,6 +81,7 @@ require (
|
|||
cloud.google.com/go/auth v0.18.0 // indirect
|
||||
cloud.google.com/go/auth/oauth2adapt v0.2.8 // indirect
|
||||
cloud.google.com/go/compute/metadata v0.9.0 // indirect
|
||||
git.sr.ht/~jackmordaunt/go-toast/v2 v2.0.3 // indirect
|
||||
github.com/JohannesKaufmann/dom v0.2.0 // indirect
|
||||
github.com/KyleBanks/depth v1.2.1 // indirect
|
||||
github.com/andybalholm/brotli v1.2.0 // indirect
|
||||
|
|
@ -98,6 +103,7 @@ require (
|
|||
github.com/aws/smithy-go v1.24.2 // indirect
|
||||
github.com/bahlo/generic-list-go v0.2.0 // indirect
|
||||
github.com/beorn7/perks v1.0.1 // indirect
|
||||
github.com/bep/debounce v1.2.1 // indirect
|
||||
github.com/blang/semver/v4 v4.0.0 // indirect
|
||||
github.com/buger/jsonparser v1.1.1 // indirect
|
||||
github.com/bytedance/sonic v1.14.0 // indirect
|
||||
|
|
@ -132,7 +138,7 @@ require (
|
|||
github.com/elastic/elastic-transport-go/v8 v8.7.0 // indirect
|
||||
github.com/felixge/httpsnoop v1.0.4 // indirect
|
||||
github.com/form3tech-oss/jwt-go v3.2.5+incompatible // indirect
|
||||
github.com/fsnotify/fsnotify v1.8.0 // indirect
|
||||
github.com/fsnotify/fsnotify v1.9.0 // indirect
|
||||
github.com/fxamacker/cbor/v2 v2.7.0 // indirect
|
||||
github.com/gabriel-vasile/mimetype v1.4.8 // indirect
|
||||
github.com/getsentry/sentry-go v0.30.0 // indirect
|
||||
|
|
@ -168,7 +174,7 @@ require (
|
|||
github.com/gobwas/ws v1.4.0 // indirect
|
||||
github.com/goccy/go-json v0.10.5 // indirect
|
||||
github.com/goccy/go-yaml v1.18.0 // indirect
|
||||
github.com/godbus/dbus/v5 v5.0.4 // indirect
|
||||
github.com/godbus/dbus/v5 v5.1.0 // indirect
|
||||
github.com/gogo/protobuf v1.3.2 // indirect
|
||||
github.com/golang/protobuf v1.5.4 // indirect
|
||||
github.com/google/btree v1.1.3 // indirect
|
||||
|
|
@ -186,6 +192,7 @@ require (
|
|||
github.com/jackc/pgservicefile v0.0.0-20240606120523-5a60cdf6a761 // indirect
|
||||
github.com/jackc/pgx/v5 v5.7.2 // indirect
|
||||
github.com/jackc/puddle/v2 v2.2.2 // indirect
|
||||
github.com/jchv/go-winloader v0.0.0-20210711035445-715c2860da7e // indirect
|
||||
github.com/jinzhu/inflection v1.0.0 // indirect
|
||||
github.com/jinzhu/now v1.1.5 // indirect
|
||||
github.com/jonboulle/clockwork v0.5.0 // indirect
|
||||
|
|
@ -195,12 +202,19 @@ require (
|
|||
github.com/klauspost/cpuid/v2 v2.3.0 // indirect
|
||||
github.com/kr/pretty v0.3.1 // indirect
|
||||
github.com/kr/text v0.2.0 // indirect
|
||||
github.com/labstack/echo/v4 v4.13.3 // indirect
|
||||
github.com/labstack/gommon v0.4.2 // indirect
|
||||
github.com/leaanthony/go-ansi-parser v1.6.1 // indirect
|
||||
github.com/leaanthony/gosod v1.0.4 // indirect
|
||||
github.com/leaanthony/slicer v1.6.0 // indirect
|
||||
github.com/leaanthony/u v1.1.1 // indirect
|
||||
github.com/leodido/go-urn v1.4.0 // indirect
|
||||
github.com/lib/pq v1.10.9 // indirect
|
||||
github.com/liuzl/cedar-go v0.0.0-20170805034717-80a9c64b256d // indirect
|
||||
github.com/liuzl/da v0.0.0-20180704015230-14771aad5b1d // indirect
|
||||
github.com/lufia/plan9stats v0.0.0-20251013123823-9fd1530e3ec3 // indirect
|
||||
github.com/mailru/easyjson v0.9.0 // indirect
|
||||
github.com/mattn/go-colorable v0.1.13 // indirect
|
||||
github.com/mattn/go-isatty v0.0.20 // indirect
|
||||
github.com/mattn/go-runewidth v0.0.16 // indirect
|
||||
github.com/mattn/go-sqlite3 v1.14.22 // indirect
|
||||
|
|
@ -218,6 +232,7 @@ require (
|
|||
github.com/opencontainers/runtime-spec v1.0.2 // indirect
|
||||
github.com/pelletier/go-toml/v2 v2.2.4 // indirect
|
||||
github.com/pierrec/lz4/v4 v4.1.22 // indirect
|
||||
github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c // indirect
|
||||
github.com/pkg/errors v0.9.1 // indirect
|
||||
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
|
||||
github.com/power-devops/perfstat v0.0.0-20240221224432-82ca36839d55 // indirect
|
||||
|
|
@ -231,7 +246,7 @@ require (
|
|||
github.com/rogpeppe/go-internal v1.14.1 // indirect
|
||||
github.com/rs/xid v1.6.0 // indirect
|
||||
github.com/sagikazarmark/locafero v0.7.0 // indirect
|
||||
github.com/samber/lo v1.27.0 // indirect
|
||||
github.com/samber/lo v1.49.1 // indirect
|
||||
github.com/shirou/gopsutil/v3 v3.23.12 // indirect
|
||||
github.com/shoenig/go-m1cpu v0.1.6 // indirect
|
||||
github.com/soheilhy/cmux v0.1.5 // indirect
|
||||
|
|
@ -246,11 +261,16 @@ require (
|
|||
github.com/tidwall/pretty v1.2.0 // indirect
|
||||
github.com/tklauser/go-sysconf v0.3.16 // indirect
|
||||
github.com/tklauser/numcpus v0.11.0 // indirect
|
||||
github.com/tkrajina/go-reflector v0.5.8 // indirect
|
||||
github.com/tmc/grpc-websocket-proxy v0.0.0-20201229170055-e5319fda7802 // indirect
|
||||
github.com/twitchyliquid64/golang-asm v0.15.1 // indirect
|
||||
github.com/twpayne/go-geom v1.6.1 // indirect
|
||||
github.com/uber/jaeger-client-go v2.30.0+incompatible // indirect
|
||||
github.com/ugorji/go/codec v1.3.0 // indirect
|
||||
github.com/valyala/bytebufferpool v1.0.0 // indirect
|
||||
github.com/valyala/fasttemplate v1.2.2 // indirect
|
||||
github.com/wailsapp/go-webview2 v1.0.22 // indirect
|
||||
github.com/wailsapp/mimetype v1.4.1 // indirect
|
||||
github.com/wk8/go-ordered-map/v2 v2.1.8 // indirect
|
||||
github.com/x448/float16 v0.8.4 // indirect
|
||||
github.com/xiang90/probing v0.0.0-20190116061207-43a291ad63a2 // indirect
|
||||
|
|
@ -279,18 +299,16 @@ require (
|
|||
go.yaml.in/yaml/v3 v3.0.4 // indirect
|
||||
golang.org/x/arch v0.20.0 // indirect
|
||||
golang.org/x/exp v0.0.0-20251209150349-8475f28825e9 // indirect
|
||||
golang.org/x/mod v0.31.0 // indirect
|
||||
golang.org/x/oauth2 v0.34.0 // indirect
|
||||
golang.org/x/sys v0.40.0 // indirect
|
||||
golang.org/x/telemetry v0.0.0-20251208220230-2638a1023523 // indirect
|
||||
golang.org/x/text v0.32.0 // indirect
|
||||
golang.org/x/time v0.14.0 // indirect
|
||||
golang.org/x/tools v0.40.0 // indirect
|
||||
golang.org/x/xerrors v0.0.0-20240903120638-7835f813f4da // indirect
|
||||
google.golang.org/genproto v0.0.0-20251202230838-ff82c1b0f217 // indirect
|
||||
google.golang.org/genproto/googleapis/api v0.0.0-20251202230838-ff82c1b0f217 // indirect
|
||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20251222181119-0a764e51fe1b // indirect
|
||||
gopkg.in/inf.v0 v0.9.1 // indirect
|
||||
gopkg.in/natefinch/lumberjack.v2 v2.2.1 // indirect
|
||||
gopkg.in/yaml.v2 v2.4.0 // indirect
|
||||
k8s.io/apimachinery v0.32.3 // indirect
|
||||
sigs.k8s.io/yaml v1.4.0 // indirect
|
||||
|
|
|
|||
58
go.sum
58
go.sum
|
|
@ -1328,6 +1328,8 @@ dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7
|
|||
entgo.io/ent v0.14.3 h1:wokAV/kIlH9TeklJWGGS7AYJdVckr0DloWjIcO9iIIQ=
|
||||
entgo.io/ent v0.14.3/go.mod h1:aDPE/OziPEu8+OWbzy4UlvWmD2/kbRuWfK2A40hcxJM=
|
||||
gioui.org v0.0.0-20210308172011-57750fc8a0a6/go.mod h1:RSH6KIUZ0p2xy5zHDxgAM4zumjgTw83q2ge/PI+yyw8=
|
||||
git.sr.ht/~jackmordaunt/go-toast/v2 v2.0.3 h1:N3IGoHHp9pb6mj1cbXbuaSXV/UMKwmbKLf53nQmtqMA=
|
||||
git.sr.ht/~jackmordaunt/go-toast/v2 v2.0.3/go.mod h1:QtOLZGz8olr4qH2vWK0QH0w0O4T9fEIjMuWpKUsH7nc=
|
||||
git.sr.ht/~sbinet/gg v0.3.1/go.mod h1:KGYtlADtqsqANL9ueOFkWymvzUvLMQllU5Ixo+8v3pc=
|
||||
github.com/AndreasBriese/bbloom v0.0.0-20190306092124-e2d15f34fcf9/go.mod h1:bOvUY6CB00SOBii9/FifXqc0awNKxLFCL/+pkDPuyl8=
|
||||
github.com/Azure/go-ansiterm v0.0.0-20250102033503-faa5f7b0171c h1:udKWzYgxTojEKWjV8V+WSxDXJ4NFATAsZjh8iIbsQIg=
|
||||
|
|
@ -1444,6 +1446,8 @@ github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24
|
|||
github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8=
|
||||
github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM=
|
||||
github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw=
|
||||
github.com/bep/debounce v1.2.1 h1:v67fRdBA9UQu2NhLFXrSg0Brw7CexQekrBwDMM8bzeY=
|
||||
github.com/bep/debounce v1.2.1/go.mod h1:H8yggRPQKLUhUoqrJC1bO2xNya7vanpDl7xR3ISbCJ0=
|
||||
github.com/bgentry/speakeasy v0.1.0/go.mod h1:+zsyZBPWlz7T6j88CTgSN5bM796AkVf0kBD4zp0CCIs=
|
||||
github.com/bketelsen/crypt v0.0.3-0.20200106085610-5cbc8cc4026c/go.mod h1:MKsuJmJgSg28kpZDP6UIiPt0e0Oz0kqKNGyRaWEPv84=
|
||||
github.com/blang/semver/v4 v4.0.0 h1:1PFHFE6yCCTv8C1TeyNNarDzntLi7wMI5i/pzqYIsAM=
|
||||
|
|
@ -1641,8 +1645,8 @@ github.com/form3tech-oss/jwt-go v3.2.5+incompatible/go.mod h1:pbq4aXjuKjdthFRnoD
|
|||
github.com/frankban/quicktest v1.14.6 h1:7Xjx+VpznH+oBnejlPUj8oUpdxnVs4f8XU8WnHkI4W8=
|
||||
github.com/frankban/quicktest v1.14.6/go.mod h1:4ptaffx2x8+WTWXmUCuVU6aPUX1/Mz7zb5vbUoiM6w0=
|
||||
github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo=
|
||||
github.com/fsnotify/fsnotify v1.8.0 h1:dAwr6QBTBZIkG8roQaJjGof0pp0EeF+tNV7YBP3F/8M=
|
||||
github.com/fsnotify/fsnotify v1.8.0/go.mod h1:8jBTzvmWwFyi3Pb8djgCCO5IBqzKJ/Jwo8TRcHyHii0=
|
||||
github.com/fsnotify/fsnotify v1.9.0 h1:2Ml+OJNzbYCTzsxtv8vKSFD9PbJjmhYF14k/jKC7S9k=
|
||||
github.com/fsnotify/fsnotify v1.9.0/go.mod h1:8jBTzvmWwFyi3Pb8djgCCO5IBqzKJ/Jwo8TRcHyHii0=
|
||||
github.com/fxamacker/cbor/v2 v2.7.0 h1:iM5WgngdRBanHcxugY4JySA0nk1wZorNOpTgCMedv5E=
|
||||
github.com/fxamacker/cbor/v2 v2.7.0/go.mod h1:pxXPTn3joSm21Gbwsv0w9OSA2y1HFR9qXEeXQVeNoDQ=
|
||||
github.com/gabriel-vasile/mimetype v1.4.8 h1:FfZ3gj38NjllZIeJAmMhr+qKL8Wu+nOoI3GqacKw1NM=
|
||||
|
|
@ -1784,8 +1788,9 @@ github.com/goccy/go-yaml v1.9.8/go.mod h1:JubOolP3gh0HpiBc4BLRD4YmjEjHAmIIB2aaXK
|
|||
github.com/goccy/go-yaml v1.11.0/go.mod h1:H+mJrWtjPTJAHvRbV09MCK9xYwODM+wRTVFFTWckfng=
|
||||
github.com/goccy/go-yaml v1.18.0 h1:8W7wMFS12Pcas7KU+VVkaiCng+kG8QiFeFwzFb+rwuw=
|
||||
github.com/goccy/go-yaml v1.18.0/go.mod h1:XBurs7gK8ATbW4ZPGKgcbrY1Br56PdM69F7LkFRi1kA=
|
||||
github.com/godbus/dbus/v5 v5.0.4 h1:9349emZab16e7zQvpmsbtjc18ykshndd8y2PG3sgJbA=
|
||||
github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA=
|
||||
github.com/godbus/dbus/v5 v5.1.0 h1:4KLkAxT3aOY8Li4FRJe/KvhoNFFxo0m6fNuFUO8QJUk=
|
||||
github.com/godbus/dbus/v5 v5.1.0/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA=
|
||||
github.com/gogo/googleapis v0.0.0-20180223154316-0cd9801be74a/go.mod h1:gf4bu3Q80BeJ6H1S1vYPm8/ELATdvryBaNFGgqEef3s=
|
||||
github.com/gogo/googleapis v1.4.1/go.mod h1:2lpHqI5OcWCtVElxXnPt+s8oJvMpySlOyM6xDCrzib4=
|
||||
github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ=
|
||||
|
|
@ -2022,12 +2027,16 @@ github.com/jackc/pgx/v5 v5.7.2 h1:mLoDLV6sonKlvjIEsV56SkWNCnuNv531l94GaIzO+XI=
|
|||
github.com/jackc/pgx/v5 v5.7.2/go.mod h1:ncY89UGWxg82EykZUwSpUKEfccBGGYq1xjrOpsbsfGQ=
|
||||
github.com/jackc/puddle/v2 v2.2.2 h1:PR8nw+E/1w0GLuRFSmiioY6UooMp6KJv0/61nB7icHo=
|
||||
github.com/jackc/puddle/v2 v2.2.2/go.mod h1:vriiEXHvEE654aYKXXjOvZM39qJ0q+azkZFrfEOc3H4=
|
||||
github.com/jchv/go-winloader v0.0.0-20210711035445-715c2860da7e h1:Q3+PugElBCf4PFpxhErSzU3/PY5sFL5Z6rfv4AbGAck=
|
||||
github.com/jchv/go-winloader v0.0.0-20210711035445-715c2860da7e/go.mod h1:alcuEEnZsY1WQsagKhZDsoPCRoOijYqhZvPwLG0kzVs=
|
||||
github.com/jinzhu/inflection v1.0.0 h1:K317FqzuhWc8YvSVlFMCCUb36O/S9MCKRDI7QkRKD/E=
|
||||
github.com/jinzhu/inflection v1.0.0/go.mod h1:h+uFLlag+Qp1Va5pdKtLDYj+kHp5pxUVkryuEj+Srlc=
|
||||
github.com/jinzhu/now v1.1.5 h1:/o9tlHleP7gOFmsnYNz3RGnqzefHA47wQpKrrdTIwXQ=
|
||||
github.com/jinzhu/now v1.1.5/go.mod h1:d3SSVoowX0Lcu0IBviAWJpolVfI5UJVZZ7cO71lE/z8=
|
||||
github.com/jmoiron/sqlx v1.3.5 h1:vFFPA71p1o5gAeqtEAwLU4dnX2napprKtHr7PYIcN3g=
|
||||
github.com/jmoiron/sqlx v1.3.5/go.mod h1:nRVWtLre0KfCLJvgxzCsLVMogSvQ1zNJtpYr2Ccp0mQ=
|
||||
github.com/joho/godotenv v1.5.1 h1:7eLL/+HRGLY0ldzfGMeQkb7vMd0as4CfYvUVzLqw0N0=
|
||||
github.com/joho/godotenv v1.5.1/go.mod h1:f4LDr5Voq0i2e/R5DDNOoa2zzDfwtkZa6DnEwAbqwq4=
|
||||
github.com/jonboulle/clockwork v0.1.0/go.mod h1:Ii8DK3G1RaLaWxj9trq07+26W01tbo22gdxWY5EU2bo=
|
||||
github.com/jonboulle/clockwork v0.2.2/go.mod h1:Pkfl5aHPm1nk2H9h0bjmnJD/BcgbGXUBGnn1kMkgxc8=
|
||||
github.com/jonboulle/clockwork v0.5.0 h1:Hyh9A8u51kptdkR+cqRpT1EebBwTn1oK9YfGYbdFz6I=
|
||||
|
|
@ -2091,9 +2100,23 @@ github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
|
|||
github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0SNc=
|
||||
github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw=
|
||||
github.com/labstack/echo/v4 v4.5.0/go.mod h1:czIriw4a0C1dFun+ObrXp7ok03xON0N1awStJ6ArI7Y=
|
||||
github.com/labstack/echo/v4 v4.13.3 h1:pwhpCPrTl5qry5HRdM5FwdXnhXSLSY+WE+YQSeCaafY=
|
||||
github.com/labstack/echo/v4 v4.13.3/go.mod h1:o90YNEeQWjDozo584l7AwhJMHN0bOC4tAfg+Xox9q5g=
|
||||
github.com/labstack/gommon v0.3.0/go.mod h1:MULnywXg0yavhxWKc+lOruYdAhDwPK9wf0OL7NoOu+k=
|
||||
github.com/labstack/gommon v0.4.2 h1:F8qTUNXgG1+6WQmqoUWnz8WiEU60mXVVw0P4ht1WRA0=
|
||||
github.com/labstack/gommon v0.4.2/go.mod h1:QlUFxVM+SNXhDL/Z7YhocGIBYOiwB0mXm1+1bAPHPyU=
|
||||
github.com/larksuite/oapi-sdk-go/v3 v3.5.3 h1:xvf8Dv29kBXC5/DNDCLhHkAFW8l/0LlQJimO5Zn+JUk=
|
||||
github.com/larksuite/oapi-sdk-go/v3 v3.5.3/go.mod h1:ZEplY+kwuIrj/nqw5uSCINNATcH3KdxSN7y+UxYY5fI=
|
||||
github.com/leaanthony/debme v1.2.1 h1:9Tgwf+kjcrbMQ4WnPcEIUcQuIZYqdWftzZkBr+i/oOc=
|
||||
github.com/leaanthony/debme v1.2.1/go.mod h1:3V+sCm5tYAgQymvSOfYQ5Xx2JCr+OXiD9Jkw3otUjiA=
|
||||
github.com/leaanthony/go-ansi-parser v1.6.1 h1:xd8bzARK3dErqkPFtoF9F3/HgN8UQk0ed1YDKpEz01A=
|
||||
github.com/leaanthony/go-ansi-parser v1.6.1/go.mod h1:+vva/2y4alzVmmIEpk9QDhA7vLC5zKDTRwfZGOp3IWU=
|
||||
github.com/leaanthony/gosod v1.0.4 h1:YLAbVyd591MRffDgxUOU1NwLhT9T1/YiwjKZpkNFeaI=
|
||||
github.com/leaanthony/gosod v1.0.4/go.mod h1:GKuIL0zzPj3O1SdWQOdgURSuhkF+Urizzxh26t9f1cw=
|
||||
github.com/leaanthony/slicer v1.6.0 h1:1RFP5uiPJvT93TAHi+ipd3NACobkW53yUiBqZheE/Js=
|
||||
github.com/leaanthony/slicer v1.6.0/go.mod h1:o/Iz29g7LN0GqH3aMjWAe90381nyZlDNquK+mtH2Fj8=
|
||||
github.com/leaanthony/u v1.1.1 h1:TUFjwDGlNX+WuwVEzDqQwC2lOv0P4uhTQw7CMFdiK7M=
|
||||
github.com/leaanthony/u v1.1.1/go.mod h1:9+o6hejoRljvZ3BzdYlVL0JYCwtnAsVuN9pVTQcaRfI=
|
||||
github.com/ledongthuc/pdf v0.0.0-20220302134840-0c2507a12d80 h1:6Yzfa6GP0rIo/kULo2bwGEkFvCePZ3qHDDTC3/J9Swo=
|
||||
github.com/ledongthuc/pdf v0.0.0-20220302134840-0c2507a12d80/go.mod h1:imJHygn/1yfhB7XSJJKlFZKl/J+dCPAknuiaGOshXAs=
|
||||
github.com/leodido/go-urn v1.2.0/go.mod h1:+8+nEpDfqqsY+g338gtMEUOtuK+4dEMhiQEgxpxOKII=
|
||||
|
|
@ -2121,11 +2144,15 @@ github.com/mailru/easyjson v0.9.0 h1:PrnmzHw7262yW8sTBwxi1PdJA3Iw/EKBa8psRf7d9a4
|
|||
github.com/mailru/easyjson v0.9.0/go.mod h1:1+xMtQp2MRNVL/V1bOzuP3aP8VNwRW55fQUto+XFtTU=
|
||||
github.com/mark3labs/mcp-go v0.43.0 h1:lgiKcWMddh4sngbU+hoWOZ9iAe/qp/m851RQpj3Y7jA=
|
||||
github.com/mark3labs/mcp-go v0.43.0/go.mod h1:YnJfOL382MIWDx1kMY+2zsRHU/q78dBg9aFb8W6Thdw=
|
||||
github.com/matryer/is v1.4.0/go.mod h1:8I/i5uYgLzgsgEloJE1U6xx5HkBQpAZvepWuujKwMRU=
|
||||
github.com/matryer/is v1.4.1 h1:55ehd8zaGABKLXQUe2awZ99BD/PTc2ls+KV/dXphgEQ=
|
||||
github.com/matryer/is v1.4.1/go.mod h1:8I/i5uYgLzgsgEloJE1U6xx5HkBQpAZvepWuujKwMRU=
|
||||
github.com/mattn/go-colorable v0.0.9/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaOChaDxuIBZU=
|
||||
github.com/mattn/go-colorable v0.1.2/go.mod h1:U0ppj6V5qS13XJ6of8GYAs25YV2eR4EVcfRqFIhoBtE=
|
||||
github.com/mattn/go-colorable v0.1.8/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc=
|
||||
github.com/mattn/go-colorable v0.1.9/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc=
|
||||
github.com/mattn/go-colorable v0.1.11/go.mod h1:u5H1YNBxpqRaxsYJYSkiCWKzEfiAb1Gb520KVy5xxl4=
|
||||
github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA=
|
||||
github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg=
|
||||
github.com/mattn/go-isatty v0.0.3/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4=
|
||||
github.com/mattn/go-isatty v0.0.7/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s=
|
||||
|
|
@ -2202,8 +2229,8 @@ github.com/nats-io/jwt v0.3.0/go.mod h1:fRYCDE99xlTsqUzISS1Bi75UBJ6ljOJQOAAu5Vgl
|
|||
github.com/nats-io/nats.go v1.9.1/go.mod h1:ZjDU1L/7fJ09jvUSRVBR2e7+RnLiiIQyqyzEE/Zbp4w=
|
||||
github.com/nats-io/nkeys v0.1.0/go.mod h1:xpnFELMwJABBLVhffcfd1MZx6VsNRFpEugbxziKVo7w=
|
||||
github.com/nats-io/nuid v1.0.1/go.mod h1:19wcPz3Ph3q0Jbyiqsd0kePYG7A95tJPxeL+1OSON2c=
|
||||
github.com/neo4j/neo4j-go-driver/v6 v6.0.0-alpha.1 h1:nV3ZdYJTi73jel0mm3dpWumNY3i3nwyo25y69SPGwyg=
|
||||
github.com/neo4j/neo4j-go-driver/v6 v6.0.0-alpha.1/go.mod h1:hzSTfNfM31p1uRSzL1F/BAYOgaiTarE6OAQBajfsm+I=
|
||||
github.com/neo4j/neo4j-go-driver/v6 v6.0.0 h1:xVAi6YLOfzXUx+1Lc/F2dUhpbN76BfKleZbAlnDFRiA=
|
||||
github.com/neo4j/neo4j-go-driver/v6 v6.0.0/go.mod h1:hzSTfNfM31p1uRSzL1F/BAYOgaiTarE6OAQBajfsm+I=
|
||||
github.com/oklog/ulid v1.3.1 h1:EGfNDEx6MqHz8B3uNV6QAib1UR2Lm97sHi3ocA6ESJ4=
|
||||
github.com/oklog/ulid v1.3.1/go.mod h1:CirwcVhetQ6Lv90oh/F+FBtV6XMibvdAFo93nm5qn4U=
|
||||
github.com/olekukonko/tablewriter v0.0.5 h1:P2Ga83D34wi1o9J6Wh1mRuqd4mF/x/lgBS7N7AbDhec=
|
||||
|
|
@ -2246,6 +2273,8 @@ github.com/pierrec/lz4/v4 v4.1.22/go.mod h1:gZWDp/Ze/IJXGXf23ltt2EXimqmTUXEy0GFu
|
|||
github.com/pingcap/errors v0.11.4/go.mod h1:Oi8TUi2kEtXXLMJk9l1cGmz20kV3TaQ0usTwv5KuLY8=
|
||||
github.com/pingcap/errors v0.11.5-0.20211224045212-9687c2b0f87c h1:xpW9bvK+HuuTmyFqUwr+jcCvpVkK7sumiz+ko5H9eq4=
|
||||
github.com/pingcap/errors v0.11.5-0.20211224045212-9687c2b0f87c/go.mod h1:X2r9ueLEUZgtx2cIogM0v4Zj5uvvzhuuiu7Pn8HzMPg=
|
||||
github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c h1:+mdjkGKdHQG3305AYmdv1U2eRNDiU2ErMBj1gwrq8eQ=
|
||||
github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c/go.mod h1:7rwL4CYBLnjLxUqIJNnCWiEdr3bn6IUYi15bNlnbCCU=
|
||||
github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e/go.mod h1:pJLUxLENpZxwdsKMEsNbx1VGcRFpLqf3715MtcvvzbA=
|
||||
github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
||||
github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
||||
|
|
@ -2332,8 +2361,8 @@ github.com/ryanuber/columnize v0.0.0-20160712163229-9b3edd62028f/go.mod h1:sm1tb
|
|||
github.com/ryanuber/columnize v2.1.0+incompatible/go.mod h1:sm1tb6uqfes/u+d4ooFouqFdy9/2g9QGwK3SQygK0Ts=
|
||||
github.com/sagikazarmark/locafero v0.7.0 h1:5MqpDsTGNDhY8sGp0Aowyf0qKsPrhewaLSsFaodPcyo=
|
||||
github.com/sagikazarmark/locafero v0.7.0/go.mod h1:2za3Cg5rMaTMoG/2Ulr9AwtFaIppKXTRYnozin4aB5k=
|
||||
github.com/samber/lo v1.27.0 h1:GOyDWxsblvqYobqsmUuMddPa2/mMzkKyojlXol4+LaQ=
|
||||
github.com/samber/lo v1.27.0/go.mod h1:it33p9UtPMS7z72fP4gw/EIfQB2eI8ke7GR2wc6+Rhg=
|
||||
github.com/samber/lo v1.49.1 h1:4BIFyVfuQSEpluc7Fua+j1NolZHiEHEpaSEKdsH0tew=
|
||||
github.com/samber/lo v1.49.1/go.mod h1:dO6KHFzUKXgP8LDhU0oI8d2hekjXnGOu0DB8Jecxd6o=
|
||||
github.com/sashabaranov/go-openai v1.40.5 h1:SwIlNdWflzR1Rxd1gv3pUg6pwPc6cQ2uMoHs8ai+/NY=
|
||||
github.com/sashabaranov/go-openai v1.40.5/go.mod h1:lj5b/K+zjTSFxVLijLSTDZuP7adOgerWeFyZLUhAKRg=
|
||||
github.com/schollz/closestmatch v2.1.0+incompatible/go.mod h1:RtP1ddjLong6gTkbtmuhtR2uUrrJOpYzYRvbcPAid+g=
|
||||
|
|
@ -2428,8 +2457,6 @@ github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.0.563/go.mod
|
|||
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/kms v1.0.563/go.mod h1:uom4Nvi9W+Qkom0exYiJ9VWJjXwyxtPYTkKkaLMlfE0=
|
||||
github.com/tencentyun/cos-go-sdk-v5 v0.7.65 h1:+WBbfwThfZSbxpf1Dw6fyMwyzVtWBBExqfDJ5giiR2s=
|
||||
github.com/tencentyun/cos-go-sdk-v5 v0.7.65/go.mod h1:8+hG+mQMuRP/OIS9d83syAvXvrMj9HhkND6Q1fLghw0=
|
||||
github.com/thoas/go-funk v0.9.1 h1:O549iLZqPpTUQ10ykd26sZhzD+rmR5pWhuElrhbC20M=
|
||||
github.com/thoas/go-funk v0.9.1/go.mod h1:+IWnUfUmFO1+WVYQWQtIJHeRRdaIyyYglZN7xzUPe4Q=
|
||||
github.com/tidwall/gjson v1.17.1 h1:wlYEnwqAHgzmhNUFfw7Xalt2JzQvsMx2Se4PcoFCT/U=
|
||||
github.com/tidwall/gjson v1.17.1/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk=
|
||||
github.com/tidwall/match v1.1.1 h1:+Ho715JplO36QYgwN9PGYNhgZvoUSc9X2c80KVTi+GA=
|
||||
|
|
@ -2444,6 +2471,8 @@ github.com/tklauser/go-sysconf v0.3.16/go.mod h1:/qNL9xxDhc7tx3HSRsLWNnuzbVfh3e7
|
|||
github.com/tklauser/numcpus v0.6.1/go.mod h1:1XfjsgE2zo8GVw7POkMbHENHzVg3GzmoZ9fESEdAacY=
|
||||
github.com/tklauser/numcpus v0.11.0 h1:nSTwhKH5e1dMNsCdVBukSZrURJRoHbSEQjdEbY+9RXw=
|
||||
github.com/tklauser/numcpus v0.11.0/go.mod h1:z+LwcLq54uWZTX0u/bGobaV34u6V7KNlTZejzM6/3MQ=
|
||||
github.com/tkrajina/go-reflector v0.5.8 h1:yPADHrwmUbMq4RGEyaOUpz2H90sRsETNVpjzo3DLVQQ=
|
||||
github.com/tkrajina/go-reflector v0.5.8/go.mod h1:ECbqLgccecY5kPmPmXg1MrHW585yMcDkVl6IvJe64T4=
|
||||
github.com/tmc/grpc-websocket-proxy v0.0.0-20190109142713-0ad062ec5ee5/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U=
|
||||
github.com/tmc/grpc-websocket-proxy v0.0.0-20201229170055-e5319fda7802 h1:uruHq4dN7GR16kFc5fp3d1RIYzJW5onx8Ybykw2YQFA=
|
||||
github.com/tmc/grpc-websocket-proxy v0.0.0-20201229170055-e5319fda7802/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U=
|
||||
|
|
@ -2468,10 +2497,13 @@ github.com/uptrace/bun/dialect/pgdialect v1.1.12/go.mod h1:Ij6WIxQILxLlL2frUBxUB
|
|||
github.com/uptrace/bun/driver/pgdriver v1.1.12 h1:3rRWB1GK0psTJrHwxzNfEij2MLibggiLdTqjTtfHc1w=
|
||||
github.com/uptrace/bun/driver/pgdriver v1.1.12/go.mod h1:ssYUP+qwSEgeDDS1xm2XBip9el1y9Mi5mTAvLoiADLM=
|
||||
github.com/urfave/negroni v1.0.0/go.mod h1:Meg73S6kFm/4PpbYdq35yYWoCZ9mS/YSx+lKnmiohz4=
|
||||
github.com/valyala/bytebufferpool v1.0.0 h1:GqA5TC/0021Y/b9FG4Oi9Mr3q7XYx6KllzawFIhcdPw=
|
||||
github.com/valyala/bytebufferpool v1.0.0/go.mod h1:6bBcMArwyJ5K/AmCkWv1jt77kVWyCJ6HpOuEn7z0Csc=
|
||||
github.com/valyala/fasthttp v1.6.0/go.mod h1:FstJa9V+Pj9vQ7OJie2qMHdwemEDaDiSdBnvPM1Su9w=
|
||||
github.com/valyala/fasttemplate v1.0.1/go.mod h1:UQGH1tvbgY+Nz5t2n7tXsz52dQxojPUpymEIMZ47gx8=
|
||||
github.com/valyala/fasttemplate v1.2.1/go.mod h1:KHLXt3tVN2HBp8eijSv/kGJopbvo7S+qRAEEKiv+SiQ=
|
||||
github.com/valyala/fasttemplate v1.2.2 h1:lxLXG0uE3Qnshl9QyaK6XJxMXlQZELvChBOCmQD0Loo=
|
||||
github.com/valyala/fasttemplate v1.2.2/go.mod h1:KHLXt3tVN2HBp8eijSv/kGJopbvo7S+qRAEEKiv+SiQ=
|
||||
github.com/valyala/tcplisten v0.0.0-20161114210144-ceec8f93295a/go.mod h1:v3UYOV9WzVtRmSR+PDvWpU/qWl4Wa5LApYYX4ZtKbio=
|
||||
github.com/vmihailenco/bufpool v0.1.11 h1:gOq2WmBrq0i2yW5QJ16ykccQ4wH9UyEsgLm6czKAd94=
|
||||
github.com/vmihailenco/bufpool v0.1.11/go.mod h1:AFf/MOy3l2CFTKbxwt0mp2MwnqjNEs5H/UxrkA5jxTQ=
|
||||
|
|
@ -2483,6 +2515,12 @@ github.com/vmihailenco/tagparser/v2 v2.0.0 h1:y09buUbR+b5aycVFQs/g70pqKVZNBmxwAh
|
|||
github.com/vmihailenco/tagparser/v2 v2.0.0/go.mod h1:Wri+At7QHww0WTrCBeu4J6bNtoV6mEfg5OIWRZA9qds=
|
||||
github.com/volcengine/ve-tos-golang-sdk/v2 v2.7.23 h1:PvDvNKGXNNH8arQZRdu0zpwkaatXjkJQTiAmI3H8njA=
|
||||
github.com/volcengine/ve-tos-golang-sdk/v2 v2.7.23/go.mod h1:IrjK84IJJTuOZOTMv/P18Ydjy/x+ow7fF7q11jAxXLM=
|
||||
github.com/wailsapp/go-webview2 v1.0.22 h1:YT61F5lj+GGaat5OB96Aa3b4QA+mybD0Ggq6NZijQ58=
|
||||
github.com/wailsapp/go-webview2 v1.0.22/go.mod h1:qJmWAmAmaniuKGZPWwne+uor3AHMB5PFhqiK0Bbj8kc=
|
||||
github.com/wailsapp/mimetype v1.4.1 h1:pQN9ycO7uo4vsUUuPeHEYoUkLVkaRntMnHJxVwYhwHs=
|
||||
github.com/wailsapp/mimetype v1.4.1/go.mod h1:9aV5k31bBOv5z6u+QP8TltzvNGJPmNJD4XlAL3U+j3o=
|
||||
github.com/wailsapp/wails/v2 v2.12.0 h1:BHO/kLNWFHYjCzucxbzAYZWUjub1Tvb4cSguQozHn5c=
|
||||
github.com/wailsapp/wails/v2 v2.12.0/go.mod h1:mo1bzK1DEJrobt7YrBjgxvb5Sihb1mhAY09hppbibQg=
|
||||
github.com/weaviate/weaviate v1.33.0-rc.1 h1:3Kol9BmA9JOj1I4vOkz0tu4A87K3dKVAnr8k8DMhBs8=
|
||||
github.com/weaviate/weaviate v1.33.0-rc.1/go.mod h1:MmHF/hZDL0I8j0qAMEa9/TS4ISLaYlIp1Bc3e/n3eUU=
|
||||
github.com/weaviate/weaviate-go-client/v5 v5.5.0 h1:+5qkHodrL3/Qc7kXvMXnDaIxSBN5+djivLqzmCx7VS4=
|
||||
|
|
@ -2804,6 +2842,7 @@ golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v
|
|||
golang.org/x/net v0.0.0-20210316092652-d523dce5a7f4/go.mod h1:RBQZq4jEuRlivfhVLdyRGr576XBO4/greRjx4P4O3yc=
|
||||
golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM=
|
||||
golang.org/x/net v0.0.0-20210503060351-7fd8e65b6420/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
|
||||
golang.org/x/net v0.0.0-20210505024714-0287a6fb4125/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
|
||||
golang.org/x/net v0.0.0-20210813160813-60bc85c4be6d/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
|
||||
golang.org/x/net v0.0.0-20211008194852-3b03d305991f/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
|
||||
golang.org/x/net v0.0.0-20211015210444-4f30a5c0130f/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
|
||||
|
|
@ -2959,6 +2998,7 @@ golang.org/x/sys v0.0.0-20200523222454-059865788121/go.mod h1:h1NjWce9XRLGQEsW7w
|
|||
golang.org/x/sys v0.0.0-20200615200032-f1bc736245b1/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20200625212154-ddb9806d33ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20200803210538-64077c9b5642/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20200810151505-1b9f1253b3ed/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20200905004654-be1d3432aa8f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20200923182605-d9f96fdee20d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
|
|
|
|||
|
|
@ -60,13 +60,44 @@ func NewSQLiteRetrieveEngineRepository(db *gorm.DB) interfaces.RetrieveEngineRep
|
|||
}
|
||||
|
||||
func initFTS5(db *gorm.DB) {
|
||||
sql := `CREATE VIRTUAL TABLE IF NOT EXISTS lite_embeddings_fts USING fts5(
|
||||
content, source_id, chunk_id, knowledge_id, knowledge_base_id,
|
||||
content='lite_embeddings', content_rowid='id',
|
||||
tokenize='unicode61'
|
||||
)`
|
||||
if err := db.Exec(sql).Error; err != nil {
|
||||
logger.GetLogger(context.Background()).Warnf("[SQLite] Failed to create FTS5 table: %v", err)
|
||||
var sqlStr string
|
||||
db.Raw("SELECT sql FROM sqlite_master WHERE type='table' AND name='lite_embeddings_fts'").Scan(&sqlStr)
|
||||
// If the table exists but is not contentless (i.e. uses content='lite_embeddings'), recreate it
|
||||
if sqlStr != "" && strings.Contains(sqlStr, "content='lite_embeddings'") {
|
||||
logger.GetLogger(context.Background()).Infof("[SQLite] Migrating FTS5 table to contentless table with manual bigram tokenization")
|
||||
db.Exec("DROP TABLE IF EXISTS lite_embeddings_fts")
|
||||
sqlStr = "" // Trigger recreate
|
||||
}
|
||||
|
||||
if sqlStr == "" {
|
||||
createSQL := `CREATE VIRTUAL TABLE IF NOT EXISTS lite_embeddings_fts USING fts5(
|
||||
content, source_id, chunk_id, knowledge_id, knowledge_base_id,
|
||||
content='',
|
||||
contentless_delete=1,
|
||||
tokenize='unicode61'
|
||||
)`
|
||||
if err := db.Exec(createSQL).Error; err != nil {
|
||||
logger.GetLogger(context.Background()).Warnf("[SQLite] Failed to create FTS5 table: %v", err)
|
||||
return
|
||||
}
|
||||
logger.GetLogger(context.Background()).Infof("[SQLite] Populating contentless FTS5 table from lite_embeddings with bigrams")
|
||||
|
||||
// To populate, we need to read all rows and insert them via Go to apply bigram tokenization
|
||||
type Row struct {
|
||||
ID uint
|
||||
Content string
|
||||
SourceID string
|
||||
ChunkID string
|
||||
KnowledgeID string
|
||||
KnowledgeBaseID string
|
||||
}
|
||||
var rows []Row
|
||||
db.Raw("SELECT id, content, source_id, chunk_id, knowledge_id, knowledge_base_id FROM lite_embeddings").Scan(&rows)
|
||||
for _, r := range rows {
|
||||
db.Exec(`INSERT INTO lite_embeddings_fts(rowid, content, source_id, chunk_id, knowledge_id, knowledge_base_id)
|
||||
VALUES(?, ?, ?, ?, ?, ?)`,
|
||||
r.ID, tokenizeCJKBigram(r.Content), r.SourceID, r.ChunkID, r.KnowledgeID, r.KnowledgeBaseID)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -276,7 +307,7 @@ func (r *sqliteRepository) keywordsRetrieve(ctx context.Context, params types.Re
|
|||
SELECT e.id, e.source_id, e.source_type, e.chunk_id,
|
||||
e.knowledge_id, e.knowledge_base_id, e.tag_id,
|
||||
e.content,
|
||||
bm25(lite_embeddings_fts) AS score
|
||||
(bm25(lite_embeddings_fts) * -1000000.0) AS score
|
||||
FROM lite_embeddings_fts
|
||||
JOIN lite_embeddings e ON e.id = lite_embeddings_fts.rowid
|
||||
WHERE lite_embeddings_fts MATCH ?
|
||||
|
|
@ -290,7 +321,7 @@ func (r *sqliteRepository) keywordsRetrieve(ctx context.Context, params types.Re
|
|||
args = append(args, wp.args...)
|
||||
}
|
||||
|
||||
sql += " ORDER BY score ASC LIMIT ?"
|
||||
sql += " ORDER BY score DESC LIMIT ?"
|
||||
args = append(args, params.TopK)
|
||||
|
||||
type ftsResult struct {
|
||||
|
|
@ -315,11 +346,12 @@ func (r *sqliteRepository) keywordsRetrieve(ctx context.Context, params types.Re
|
|||
items := make([]*types.IndexWithScore, len(rows))
|
||||
for i, row := range rows {
|
||||
|
||||
// bm25 越小越相关 → 转成正向分数
|
||||
score := -row.Score
|
||||
// bm25 is originally negative and very small, we multiplied it by -1000000.0 in SQL
|
||||
// to make it positive and human-readable.
|
||||
score := row.Score
|
||||
|
||||
logger.GetLogger(ctx).Infof("[SQLite] keywordsRetrieve: #%d chunk_id=%s, bm25_raw=%.4f, score=%.4f, content_preview=%.60s",
|
||||
i+1, row.ChunkID, row.Score, score, row.Content)
|
||||
logger.GetLogger(ctx).Infof("[SQLite] keywordsRetrieve: #%d chunk_id=%s, score=%.4f, content_preview=%.60s",
|
||||
i+1, row.ChunkID, score, row.Content)
|
||||
|
||||
items[i] = &types.IndexWithScore{
|
||||
ID: fmt.Sprintf("%d", row.ID),
|
||||
|
|
@ -488,6 +520,9 @@ func (r *sqliteRepository) deleteRowsAndVecs(_ context.Context, rows []sqliteEmb
|
|||
r.db.Exec(fmt.Sprintf("DELETE FROM %s WHERE rowid = ?", tbl), id)
|
||||
}
|
||||
}
|
||||
for _, row := range rows {
|
||||
r.db.Exec("DELETE FROM lite_embeddings_fts WHERE rowid = ?", row.ID)
|
||||
}
|
||||
}
|
||||
|
||||
func (r *sqliteRepository) copyVec(_ context.Context, srcID, dstID uint, dim int) {
|
||||
|
|
@ -505,8 +540,9 @@ func (r *sqliteRepository) syncFTS5Insert(_ context.Context, row *sqliteEmbeddin
|
|||
if row.ID == 0 {
|
||||
return
|
||||
}
|
||||
tokenizedContent := tokenizeCJKBigram(row.Content)
|
||||
sql := `INSERT INTO lite_embeddings_fts(rowid, content, source_id, chunk_id, knowledge_id, knowledge_base_id) VALUES(?, ?, ?, ?, ?, ?)`
|
||||
r.db.Exec(sql, row.ID, row.Content, row.SourceID, row.ChunkID, row.KnowledgeID, row.KnowledgeBaseID)
|
||||
r.db.Exec(sql, row.ID, tokenizedContent, row.SourceID, row.ChunkID, row.KnowledgeID, row.KnowledgeBaseID)
|
||||
}
|
||||
|
||||
type whereClause struct {
|
||||
|
|
@ -553,61 +589,77 @@ func toInterfaceSlice(ss []string) []interface{} {
|
|||
return out
|
||||
}
|
||||
|
||||
// sanitizeFTS5Query builds an FTS5 query from user input.
|
||||
// CJK characters are split into overlapping bigrams (mimicking CJK analyzers used
|
||||
// by Elasticsearch etc.) and joined with OR for broad partial matching.
|
||||
// Non-CJK words are kept intact. BM25 ranking naturally boosts documents
|
||||
// that match more tokens.
|
||||
// tokenizeCJKBigram splits continuous CJK character sequences into overlapping bigrams.
|
||||
// Non-CJK words are kept intact. This approach maximizes recall for CJK search.
|
||||
func tokenizeCJKBigram(text string) string {
|
||||
var parts []string
|
||||
var currentCJK []rune
|
||||
var currentNonCJK strings.Builder
|
||||
|
||||
flushCJK := func() {
|
||||
if len(currentCJK) == 0 {
|
||||
return
|
||||
}
|
||||
if len(currentCJK) == 1 {
|
||||
parts = append(parts, string(currentCJK[0]))
|
||||
} else {
|
||||
for i := 0; i < len(currentCJK)-1; i++ {
|
||||
parts = append(parts, string(currentCJK[i])+string(currentCJK[i+1]))
|
||||
}
|
||||
}
|
||||
currentCJK = currentCJK[:0]
|
||||
}
|
||||
|
||||
flushNonCJK := func() {
|
||||
if currentNonCJK.Len() > 0 {
|
||||
parts = append(parts, currentNonCJK.String())
|
||||
currentNonCJK.Reset()
|
||||
}
|
||||
}
|
||||
|
||||
for _, r := range text {
|
||||
// unicode.Han covers Chinese characters
|
||||
if unicode.Is(unicode.Han, r) {
|
||||
flushNonCJK()
|
||||
currentCJK = append(currentCJK, r)
|
||||
} else if unicode.IsSpace(r) || unicode.IsPunct(r) || unicode.IsSymbol(r) {
|
||||
// Delimiters
|
||||
flushCJK()
|
||||
flushNonCJK()
|
||||
} else {
|
||||
// Alphanumeric or other languages
|
||||
flushCJK()
|
||||
currentNonCJK.WriteRune(r)
|
||||
}
|
||||
}
|
||||
flushCJK()
|
||||
flushNonCJK()
|
||||
|
||||
return strings.Join(parts, " ")
|
||||
}
|
||||
|
||||
// sanitizeFTS5Query builds an FTS5 query from user input by applying bigram tokenization.
|
||||
func sanitizeFTS5Query(q string) string {
|
||||
q = strings.TrimSpace(q)
|
||||
if q == "" {
|
||||
return q
|
||||
}
|
||||
|
||||
var cjkRunes []rune
|
||||
var nonCJKWords []string
|
||||
var buf strings.Builder
|
||||
|
||||
flushNonCJK := func() {
|
||||
if buf.Len() > 0 {
|
||||
nonCJKWords = append(nonCJKWords, buf.String())
|
||||
buf.Reset()
|
||||
}
|
||||
}
|
||||
|
||||
for _, r := range q {
|
||||
if unicode.Is(unicode.Han, r) {
|
||||
flushNonCJK()
|
||||
cjkRunes = append(cjkRunes, r)
|
||||
} else if unicode.IsSpace(r) || r == '|' {
|
||||
flushNonCJK()
|
||||
} else if r == '"' || r == '*' || r == '(' || r == ')' || r == '{' || r == '}' {
|
||||
// skip FTS5 special characters
|
||||
} else {
|
||||
buf.WriteRune(r)
|
||||
}
|
||||
}
|
||||
flushNonCJK()
|
||||
// Tokenize input query with bigrams (same as during indexing)
|
||||
tokenized := tokenizeCJKBigram(q)
|
||||
fields := strings.Fields(tokenized)
|
||||
|
||||
var parts []string
|
||||
|
||||
// CJK bigrams for better matching (e.g. "苹果第四季度" → "苹果" OR "果第" OR "第四" OR ...)
|
||||
if len(cjkRunes) == 1 {
|
||||
parts = append(parts, `"`+string(cjkRunes[0])+`"`)
|
||||
} else {
|
||||
for i := 0; i < len(cjkRunes)-1; i++ {
|
||||
bigram := string(cjkRunes[i]) + string(cjkRunes[i+1])
|
||||
parts = append(parts, `"`+bigram+`"`)
|
||||
for _, f := range fields {
|
||||
if f != "" {
|
||||
parts = append(parts, `"`+f+`"`)
|
||||
}
|
||||
}
|
||||
|
||||
for _, w := range nonCJKWords {
|
||||
w = strings.ReplaceAll(w, `"`, `""`)
|
||||
parts = append(parts, `"`+w+`"`)
|
||||
}
|
||||
|
||||
if len(parts) == 0 {
|
||||
return `"` + strings.ReplaceAll(q, `"`, `""`) + `"`
|
||||
return ""
|
||||
}
|
||||
|
||||
// Use OR because we want fuzzy match across multiple bigrams/words
|
||||
return strings.Join(parts, " OR ")
|
||||
}
|
||||
|
|
|
|||
|
|
@ -59,6 +59,15 @@ func (r *vectorStoreRepository) Update(ctx context.Context, store *types.VectorS
|
|||
).Select("name").Updates(store).Error
|
||||
}
|
||||
|
||||
// UpdateConnectionConfig updates only the connection_config JSONB column.
|
||||
// Used for saving auto-detected metadata (e.g., server version) without
|
||||
// touching user-immutable fields like engine_type or index_config.
|
||||
func (r *vectorStoreRepository) UpdateConnectionConfig(ctx context.Context, store *types.VectorStore) error {
|
||||
return r.db.WithContext(ctx).Model(&types.VectorStore{}).Where(
|
||||
"id = ? AND tenant_id = ?", store.ID, store.TenantID,
|
||||
).Select("connection_config").Updates(store).Error
|
||||
}
|
||||
|
||||
// Delete soft-deletes a vector store
|
||||
func (r *vectorStoreRepository) Delete(ctx context.Context, tenantID uint64, id string) error {
|
||||
return r.db.WithContext(ctx).Where(
|
||||
|
|
|
|||
|
|
@ -15,15 +15,15 @@ import (
|
|||
|
||||
// PluginSearch implements search functionality for chat pipeline
|
||||
type PluginSearch struct {
|
||||
knowledgeBaseService interfaces.KnowledgeBaseService
|
||||
knowledgeService interfaces.KnowledgeService
|
||||
chunkService interfaces.ChunkService
|
||||
config *config.Config
|
||||
webSearchService interfaces.WebSearchService
|
||||
tenantService interfaces.TenantService
|
||||
sessionService interfaces.SessionService
|
||||
webSearchStateService interfaces.WebSearchStateService
|
||||
webSearchProviderRepo interfaces.WebSearchProviderRepository
|
||||
knowledgeBaseService interfaces.KnowledgeBaseService
|
||||
knowledgeService interfaces.KnowledgeService
|
||||
chunkService interfaces.ChunkService
|
||||
config *config.Config
|
||||
webSearchService interfaces.WebSearchService
|
||||
tenantService interfaces.TenantService
|
||||
sessionService interfaces.SessionService
|
||||
webSearchStateService interfaces.WebSearchStateService
|
||||
webSearchProviderRepo interfaces.WebSearchProviderRepository
|
||||
}
|
||||
|
||||
func NewPluginSearch(eventManager *EventManager,
|
||||
|
|
@ -620,21 +620,34 @@ func (p *PluginSearch) searchWebIfEnabled(ctx context.Context, chatManage *types
|
|||
return nil
|
||||
}
|
||||
tenant, _ := types.TenantInfoFromContext(ctx)
|
||||
if tenant == nil || tenant.WebSearchConfig == nil {
|
||||
providerID := chatManage.WebSearchProviderID
|
||||
|
||||
var webConfig *types.WebSearchConfig
|
||||
if tenant != nil && tenant.WebSearchConfig != nil {
|
||||
// Clone tenant config so we can safely override MaxResults
|
||||
cfg := *tenant.WebSearchConfig
|
||||
webConfig = &cfg
|
||||
} else if providerID != "" {
|
||||
webConfig = &types.WebSearchConfig{
|
||||
MaxResults: 10,
|
||||
}
|
||||
} else {
|
||||
pipelineWarn(ctx, "Search", "web_config_missing", map[string]interface{}{
|
||||
"tenant_id": chatManage.TenantID,
|
||||
})
|
||||
return nil
|
||||
}
|
||||
|
||||
// Use provider ID already resolved by session layer (agent config > tenant default)
|
||||
providerID := chatManage.WebSearchProviderID
|
||||
// Apply agent-level web search overrides
|
||||
if chatManage.WebSearchMaxResults > 0 {
|
||||
webConfig.MaxResults = chatManage.WebSearchMaxResults
|
||||
}
|
||||
|
||||
pipelineInfo(ctx, "Search", "web_request", map[string]interface{}{
|
||||
"tenant_id": chatManage.TenantID,
|
||||
"provider_id": providerID,
|
||||
})
|
||||
webResults, err := p.webSearchService.Search(ctx, providerID, tenant.WebSearchConfig, chatManage.RewriteQuery)
|
||||
webResults, err := p.webSearchService.Search(ctx, providerID, webConfig, chatManage.RewriteQuery)
|
||||
if err != nil {
|
||||
pipelineWarn(ctx, "Search", "web_search_error", map[string]interface{}{
|
||||
"tenant_id": chatManage.TenantID,
|
||||
|
|
@ -643,22 +656,22 @@ func (p *PluginSearch) searchWebIfEnabled(ctx context.Context, chatManage *types
|
|||
return nil
|
||||
}
|
||||
// Build questions using RewriteQuery only
|
||||
questions := []string{strings.TrimSpace(chatManage.RewriteQuery)}
|
||||
// questions := []string{strings.TrimSpace(chatManage.RewriteQuery)}
|
||||
// Load session-scoped temp KB state from Redis using WebSearchStateRepository
|
||||
tempKBID, seen, ids := p.webSearchStateService.GetWebSearchTempKBState(ctx, chatManage.SessionID)
|
||||
compressed, kbID, newSeen, newIDs, err := p.webSearchService.CompressWithRAG(
|
||||
ctx, chatManage.SessionID, tempKBID, questions, webResults, tenant.WebSearchConfig,
|
||||
p.knowledgeBaseService, p.knowledgeService, seen, ids,
|
||||
)
|
||||
if err != nil {
|
||||
pipelineWarn(ctx, "Search", "web_compress_error", map[string]interface{}{
|
||||
"error": err.Error(),
|
||||
})
|
||||
} else {
|
||||
webResults = compressed
|
||||
// Persist temp KB state back into Redis using WebSearchStateRepository
|
||||
p.webSearchStateService.SaveWebSearchTempKBState(ctx, chatManage.SessionID, kbID, newSeen, newIDs)
|
||||
}
|
||||
// tempKBID, seen, ids := p.webSearchStateService.GetWebSearchTempKBState(ctx, chatManage.SessionID)
|
||||
// compressed, kbID, newSeen, newIDs, err := p.webSearchService.CompressWithRAG(
|
||||
// ctx, chatManage.SessionID, tempKBID, questions, webResults, webConfig,
|
||||
// p.knowledgeBaseService, p.knowledgeService, seen, ids,
|
||||
// )
|
||||
// if err != nil {
|
||||
// pipelineWarn(ctx, "Search", "web_compress_error", map[string]interface{}{
|
||||
// "error": err.Error(),
|
||||
// })
|
||||
// } else {
|
||||
// webResults = compressed
|
||||
// // Persist temp KB state back into Redis using WebSearchStateRepository
|
||||
// p.webSearchStateService.SaveWebSearchTempKBState(ctx, chatManage.SessionID, kbID, newSeen, newIDs)
|
||||
// }
|
||||
res := searchutil.ConvertWebSearchResults(webResults)
|
||||
pipelineInfo(ctx, "Search", "web_hits", map[string]interface{}{
|
||||
"hit_count": len(res),
|
||||
|
|
|
|||
|
|
@ -101,6 +101,30 @@ func NewFileServiceFromStorageConfig(
|
|||
svc, err := NewS3FileService(sec.S3.Endpoint, sec.S3.AccessKey, sec.S3.SecretKey, sec.S3.BucketName, sec.S3.Region, pathPrefix)
|
||||
return svc, p, err
|
||||
|
||||
case "oss":
|
||||
if sec == nil || sec.OSS == nil || sec.OSS.Endpoint == "" || sec.OSS.Region == "" || sec.OSS.AccessKey == "" || sec.OSS.SecretKey == "" || sec.OSS.BucketName == "" {
|
||||
return nil, p, fmt.Errorf("incomplete oss config")
|
||||
}
|
||||
pathPrefix := strings.TrimSpace(sec.OSS.PathPrefix)
|
||||
if pathPrefix == "" {
|
||||
pathPrefix = "weknora/"
|
||||
}
|
||||
var svc interfaces.FileService
|
||||
var err error
|
||||
if sec.OSS.UseTempBucket && sec.OSS.TempBucketName != "" {
|
||||
svc, err = NewOssFileServiceWithTempBucket(
|
||||
sec.OSS.Endpoint, sec.OSS.Region, sec.OSS.AccessKey, sec.OSS.SecretKey,
|
||||
sec.OSS.BucketName, pathPrefix,
|
||||
sec.OSS.TempBucketName, sec.OSS.TempRegion,
|
||||
)
|
||||
} else {
|
||||
svc, err = NewOssFileService(
|
||||
sec.OSS.Endpoint, sec.OSS.Region, sec.OSS.AccessKey, sec.OSS.SecretKey,
|
||||
sec.OSS.BucketName, pathPrefix,
|
||||
)
|
||||
}
|
||||
return svc, p, err
|
||||
|
||||
default:
|
||||
return nil, p, fmt.Errorf("unsupported provider %q", p)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,331 @@
|
|||
package file
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
"mime/multipart"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/Tencent/WeKnora/internal/types/interfaces"
|
||||
"github.com/Tencent/WeKnora/internal/utils"
|
||||
"github.com/aws/aws-sdk-go-v2/aws"
|
||||
"github.com/aws/aws-sdk-go-v2/config"
|
||||
"github.com/aws/aws-sdk-go-v2/credentials"
|
||||
"github.com/aws/aws-sdk-go-v2/service/s3"
|
||||
"github.com/aws/aws-sdk-go-v2/service/s3/types"
|
||||
"github.com/google/uuid"
|
||||
)
|
||||
|
||||
// ossFileService implements the FileService interface for Aliyun OSS
|
||||
// using the S3-compatible protocol with virtual-hosted style addressing.
|
||||
type ossFileService struct {
|
||||
client *s3.Client
|
||||
tempClient *s3.Client
|
||||
pathPrefix string
|
||||
bucketName string
|
||||
tempBucketName string
|
||||
}
|
||||
|
||||
const ossScheme = "oss://"
|
||||
|
||||
// newOSSClient creates a bare s3.Client configured for OSS S3-compatible mode.
|
||||
// OSS uses virtual-hosted style addressing and does not support aws-chunked encoding.
|
||||
func newOSSClient(endpoint, region, accessKey, secretKey string) (*s3.Client, error) {
|
||||
cfg, err := config.LoadDefaultConfig(context.Background(),
|
||||
config.WithRegion(region),
|
||||
config.WithCredentialsProvider(credentials.NewStaticCredentialsProvider(accessKey, secretKey, "")),
|
||||
// Disable automatic aws-chunked encoding — OSS does not support it.
|
||||
config.WithRequestChecksumCalculation(aws.RequestChecksumCalculationWhenRequired),
|
||||
config.WithResponseChecksumValidation(aws.ResponseChecksumValidationWhenRequired),
|
||||
)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to load AWS config: %w", err)
|
||||
}
|
||||
|
||||
client := s3.NewFromConfig(cfg, func(o *s3.Options) {
|
||||
o.BaseEndpoint = aws.String(endpoint)
|
||||
o.UsePathStyle = false
|
||||
})
|
||||
|
||||
return client, nil
|
||||
}
|
||||
|
||||
// ossBucketExists checks if the bucket exists using the provided client.
|
||||
func ossBucketExists(ctx context.Context, client *s3.Client, bucketName string) (bool, error) {
|
||||
_, err := client.HeadBucket(ctx, &s3.HeadBucketInput{
|
||||
Bucket: aws.String(bucketName),
|
||||
})
|
||||
if err != nil {
|
||||
var notFound *types.NotFound
|
||||
if errors.As(err, ¬Found) {
|
||||
return false, nil
|
||||
}
|
||||
return false, err
|
||||
}
|
||||
return true, nil
|
||||
}
|
||||
|
||||
// ossCreateBucket creates a new bucket using the provided client.
|
||||
func ossCreateBucket(ctx context.Context, client *s3.Client, bucketName string) error {
|
||||
_, err := client.CreateBucket(ctx, &s3.CreateBucketInput{
|
||||
Bucket: aws.String(bucketName),
|
||||
})
|
||||
return err
|
||||
}
|
||||
|
||||
// ossEnsureBucket checks if the bucket exists and creates it if missing.
|
||||
func ossEnsureBucket(ctx context.Context, client *s3.Client, bucketName string) error {
|
||||
exists, err := ossBucketExists(ctx, client, bucketName)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to check bucket: %w", err)
|
||||
}
|
||||
if !exists {
|
||||
if err := ossCreateBucket(ctx, client, bucketName); err != nil {
|
||||
return fmt.Errorf("failed to create bucket: %w", err)
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// NewOssFileService creates an Aliyun OSS file service.
|
||||
// It verifies that the bucket exists and creates it if missing.
|
||||
func NewOssFileService(endpoint, region, accessKey, secretKey, bucketName, pathPrefix string) (interfaces.FileService, error) {
|
||||
return NewOssFileServiceWithTempBucket(endpoint, region, accessKey, secretKey, bucketName, pathPrefix, "", "")
|
||||
}
|
||||
|
||||
// NewOssFileServiceWithTempBucket creates an Aliyun OSS file service with optional temp bucket.
|
||||
func NewOssFileServiceWithTempBucket(endpoint, region, accessKey, secretKey, bucketName, pathPrefix, tempBucketName, tempRegion string) (interfaces.FileService, error) {
|
||||
client, err := newOSSClient(endpoint, region, accessKey, secretKey)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if err := ossEnsureBucket(context.Background(), client, bucketName); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
var tempClient *s3.Client
|
||||
if tempBucketName != "" {
|
||||
if tempRegion == "" {
|
||||
tempRegion = region
|
||||
}
|
||||
tempClient, err = newOSSClient(endpoint, tempRegion, accessKey, secretKey)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to initialize OSS temp client: %w", err)
|
||||
}
|
||||
if err := ossEnsureBucket(context.Background(), tempClient, tempBucketName); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
|
||||
// Normalize pathPrefix: ensure it ends with '/' if not empty
|
||||
if pathPrefix != "" && !strings.HasSuffix(pathPrefix, "/") {
|
||||
pathPrefix += "/"
|
||||
}
|
||||
|
||||
return &ossFileService{
|
||||
client: client,
|
||||
tempClient: tempClient,
|
||||
pathPrefix: pathPrefix,
|
||||
bucketName: bucketName,
|
||||
tempBucketName: tempBucketName,
|
||||
}, nil
|
||||
}
|
||||
|
||||
// CheckOssConnectivity tests OSS connectivity using the provided credentials.
|
||||
func CheckOssConnectivity(ctx context.Context, endpoint, region, accessKey, secretKey, bucketName string) error {
|
||||
client, err := newOSSClient(endpoint, region, accessKey, secretKey)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
checkCtx, cancel := context.WithTimeout(ctx, 10*time.Second)
|
||||
defer cancel()
|
||||
|
||||
exists, err := ossBucketExists(checkCtx, client, bucketName)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to check bucket: %w", err)
|
||||
}
|
||||
if !exists {
|
||||
return fmt.Errorf("bucket %q does not exist", bucketName)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// parseOssFilePath extracts bucket and object key from: oss://{bucket}/{objectKey}
|
||||
func parseOssFilePath(filePath string) (bucketName string, objectKey string, err error) {
|
||||
if !strings.HasPrefix(filePath, ossScheme) {
|
||||
return "", "", fmt.Errorf("invalid OSS file path: %s", filePath)
|
||||
}
|
||||
|
||||
rest := strings.TrimPrefix(filePath, ossScheme)
|
||||
parts := strings.SplitN(rest, "/", 2)
|
||||
if len(parts) != 2 || parts[0] == "" || parts[1] == "" {
|
||||
return "", "", fmt.Errorf("invalid OSS file path: %s", filePath)
|
||||
}
|
||||
return parts[0], parts[1], nil
|
||||
}
|
||||
|
||||
// CheckConnectivity verifies OSS is reachable and the main bucket exists.
|
||||
func (s *ossFileService) CheckConnectivity(ctx context.Context) error {
|
||||
checkCtx, cancel := context.WithTimeout(ctx, 10*time.Second)
|
||||
defer cancel()
|
||||
|
||||
exists, err := ossBucketExists(checkCtx, s.client, s.bucketName)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if !exists {
|
||||
return fmt.Errorf("bucket %q does not exist", s.bucketName)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// SaveFile saves a file to OSS.
|
||||
func (s *ossFileService) SaveFile(ctx context.Context,
|
||||
file *multipart.FileHeader, tenantID uint64, knowledgeID string,
|
||||
) (string, error) {
|
||||
ext := filepath.Ext(file.Filename)
|
||||
objectName := fmt.Sprintf("%s%d/%s/%s%s", s.pathPrefix, tenantID, knowledgeID, uuid.New().String(), ext)
|
||||
|
||||
src, err := file.Open()
|
||||
if err != nil {
|
||||
return "", fmt.Errorf("failed to open file: %w", err)
|
||||
}
|
||||
defer src.Close()
|
||||
|
||||
contentType := file.Header.Get("Content-Type")
|
||||
if contentType == "" {
|
||||
contentType = getContentTypeByExt(ext)
|
||||
}
|
||||
|
||||
_, err = s.client.PutObject(ctx, &s3.PutObjectInput{
|
||||
Bucket: aws.String(s.bucketName),
|
||||
Key: aws.String(objectName),
|
||||
Body: src,
|
||||
ContentType: aws.String(contentType),
|
||||
})
|
||||
if err != nil {
|
||||
return "", fmt.Errorf("failed to upload file to OSS: %w", err)
|
||||
}
|
||||
|
||||
return fmt.Sprintf("oss://%s/%s", s.bucketName, objectName), nil
|
||||
}
|
||||
|
||||
// SaveBytes saves bytes data to OSS.
|
||||
// If temp is true and temp bucket is configured, saves to temp bucket.
|
||||
// Otherwise saves to main bucket.
|
||||
func (s *ossFileService) SaveBytes(ctx context.Context, data []byte, tenantID uint64, fileName string, temp bool) (string, error) {
|
||||
safeName, err := utils.SafeFileName(fileName)
|
||||
if err != nil {
|
||||
return "", fmt.Errorf("invalid file name: %w", err)
|
||||
}
|
||||
ext := filepath.Ext(safeName)
|
||||
|
||||
// If requesting temp bucket and it is configured, use it
|
||||
if temp && s.tempClient != nil {
|
||||
objectName := fmt.Sprintf("exports/%d/%s%s", tenantID, uuid.New().String(), ext)
|
||||
_, err := s.tempClient.PutObject(ctx, &s3.PutObjectInput{
|
||||
Bucket: aws.String(s.tempBucketName),
|
||||
Key: aws.String(objectName),
|
||||
Body: bytes.NewReader(data),
|
||||
ContentType: aws.String("text/csv; charset=utf-8"),
|
||||
})
|
||||
if err != nil {
|
||||
return "", fmt.Errorf("failed to upload bytes to OSS temp bucket: %w", err)
|
||||
}
|
||||
return fmt.Sprintf("oss://%s/%s", s.tempBucketName, objectName), nil
|
||||
}
|
||||
|
||||
// Save to main bucket
|
||||
objectName := fmt.Sprintf("%s%d/exports/%s%s", s.pathPrefix, tenantID, uuid.New().String(), ext)
|
||||
_, err = s.client.PutObject(ctx, &s3.PutObjectInput{
|
||||
Bucket: aws.String(s.bucketName),
|
||||
Key: aws.String(objectName),
|
||||
Body: bytes.NewReader(data),
|
||||
ContentType: aws.String("text/csv; charset=utf-8"),
|
||||
})
|
||||
if err != nil {
|
||||
return "", fmt.Errorf("failed to upload bytes to OSS: %w", err)
|
||||
}
|
||||
|
||||
return fmt.Sprintf("oss://%s/%s", s.bucketName, objectName), nil
|
||||
}
|
||||
|
||||
// GetFile retrieves a file from OSS by its path.
|
||||
func (s *ossFileService) GetFile(ctx context.Context, filePath string) (io.ReadCloser, error) {
|
||||
bucketName, objectName, err := parseOssFilePath(filePath)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if err := utils.SafeObjectKey(objectName); err != nil {
|
||||
return nil, fmt.Errorf("invalid file path: %w", err)
|
||||
}
|
||||
|
||||
resp, err := s.client.GetObject(ctx, &s3.GetObjectInput{
|
||||
Bucket: aws.String(bucketName),
|
||||
Key: aws.String(objectName),
|
||||
})
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to get file from OSS: %w", err)
|
||||
}
|
||||
|
||||
return resp.Body, nil
|
||||
}
|
||||
|
||||
// DeleteFile removes a file from OSS.
|
||||
func (s *ossFileService) DeleteFile(ctx context.Context, filePath string) error {
|
||||
bucketName, objectName, err := parseOssFilePath(filePath)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if err := utils.SafeObjectKey(objectName); err != nil {
|
||||
return fmt.Errorf("invalid file path: %w", err)
|
||||
}
|
||||
|
||||
_, err = s.client.DeleteObject(ctx, &s3.DeleteObjectInput{
|
||||
Bucket: aws.String(bucketName),
|
||||
Key: aws.String(objectName),
|
||||
})
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to delete file from OSS: %w", err)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// GetFileURL returns a presigned download URL for the file.
|
||||
func (s *ossFileService) GetFileURL(ctx context.Context, filePath string) (string, error) {
|
||||
bucketName, objectName, err := parseOssFilePath(filePath)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
if err := utils.SafeObjectKey(objectName); err != nil {
|
||||
return "", fmt.Errorf("invalid file path: %w", err)
|
||||
}
|
||||
|
||||
// Determine which client to use
|
||||
var client *s3.Client
|
||||
if bucketName == s.tempBucketName && s.tempClient != nil {
|
||||
client = s.tempClient
|
||||
} else {
|
||||
client = s.client
|
||||
}
|
||||
|
||||
presignClient := s3.NewPresignClient(client)
|
||||
|
||||
presignedReq, err := presignClient.PresignGetObject(ctx, &s3.GetObjectInput{
|
||||
Bucket: aws.String(bucketName),
|
||||
Key: aws.String(objectName),
|
||||
}, s3.WithPresignExpires(24*time.Hour))
|
||||
if err != nil {
|
||||
return "", fmt.Errorf("failed to generate OSS presigned URL: %w", err)
|
||||
}
|
||||
|
||||
return presignedReq.URL, nil
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue