mirror of
https://github.com/xinnan-tech/xiaozhi-esp32-server.git
synced 2026-11-28 04:59:52 +01:00
feat(manager-mobile): westernize H5 app, copy, and shared crypto
- English locale defaults; remove duplicate zh-only locale files - SM2 utility sharing with the web client where applicable
This commit is contained in:
parent
2685479e64
commit
2be70e8e6c
76 changed files with 2040 additions and 5302 deletions
|
|
@ -1,51 +1,51 @@
|
||||||
## 智控台移动版(manager-mobile)
|
## Xiaozhi Control Panel Mobile Version (manager-mobile)
|
||||||
基于 uni-app v3 + Vue 3 + Vite 的跨端移动管理端,支持 App(Android & iOS)和微信小程序。
|
Cross-platform mobile management client based on uni-app v3 + Vue 3 + Vite, supporting App (Android & iOS) and WeChat Mini Program.
|
||||||
|
|
||||||
### 平台兼容性
|
### Platform Compatibility
|
||||||
|
|
||||||
| H5 | iOS | Android | 微信小程序 |
|
| H5 | iOS | Android | WeChat Mini Program |
|
||||||
| -- | --- | ------- | ---------- |
|
| -- | --- | ------- | ---------- |
|
||||||
| √ | √ | √ | √ |
|
| √ | √ | √ | √ |
|
||||||
|
|
||||||
提示:不同 UI 组件在不同平台的适配度略有差异,请以对应组件库文档为准。
|
Note: Different UI components have slight differences in adaptation across platforms, please refer to the corresponding component library documentation.
|
||||||
|
|
||||||
### 开发环境要求
|
### Development Environment Requirements
|
||||||
- Node >= 18
|
- Node >= 18
|
||||||
- pnpm >= 7.30(建议使用项目中声明的 `pnpm@10.x`)
|
- pnpm >= 7.30 (recommended to use `pnpm@10.x` declared in the project)
|
||||||
- 可选:HBuilderX(App 调试/打包)、微信开发者工具(微信小程序)
|
- Optional: HBuilderX (App debugging/packaging), WeChat Developer Tools (WeChat Mini Program)
|
||||||
|
|
||||||
### 快速开始
|
### Quick Start
|
||||||
1) 配置环境变量
|
1) Configure environment variables
|
||||||
- 复制 `env/.env.example` 为 `env/.env.development`
|
- Copy `env/.env.example` to `env/.env.development`
|
||||||
- 根据实际情况修改配置项(特别是 `VITE_SERVER_BASEURL`、`VITE_UNI_APPID`、`VITE_WX_APPID`)
|
- Modify configuration items according to actual situation (especially `VITE_SERVER_BASEURL`, `VITE_UNI_APPID`, `VITE_WX_APPID`)
|
||||||
|
|
||||||
2) 安装依赖
|
2) Install dependencies
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
pnpm i
|
pnpm i
|
||||||
```
|
```
|
||||||
|
|
||||||
3) 本地开发(热更新)
|
3) Local development (hot reload)
|
||||||
- h5: `pnpm dev:h5`,然后观察启动日志显示的ip端口号
|
- h5: `pnpm dev:h5`, then observe the ip port number displayed in the startup log
|
||||||
- 微信小程序:`pnpm dev:mp` 或 `pnpm dev:mp-weixin`,然后用微信开发者工具导入 `dist/dev/mp-weixin`
|
- WeChat Mini Program: `pnpm dev:mp` or `pnpm dev:mp-weixin`, then import `dist/dev/mp-weixin` with WeChat Developer Tools
|
||||||
- App:用 HBuilderX 导入 `manager-mobile`,然后参考下面的教程就能运行了
|
- App: Import `manager-mobile` with HBuilderX, then follow the tutorial below to run
|
||||||
|
|
||||||
### 环境变量与配置
|
### Environment Variables and Configuration
|
||||||
项目使用自定义 `env` 目录存放环境文件,按 Vite 规范命名:`.env.development`、`.env.production` 等。
|
The project uses a custom `env` directory to store environment files, named according to Vite specifications: `.env.development`, `.env.production`, etc.
|
||||||
|
|
||||||
关键变量(部分):
|
Key variables (partial):
|
||||||
- VITE_APP_TITLE:应用名称(写入 `manifest.config.ts`)
|
- VITE_APP_TITLE: Application name (written to `manifest.config.ts`)
|
||||||
- VITE_UNI_APPID:uni-app 应用 appid(App)
|
- VITE_UNI_APPID: uni-app application appid (App)
|
||||||
- VITE_WX_APPID:微信小程序 appid(mp-weixin)
|
- VITE_WX_APPID: WeChat Mini Program appid (mp-weixin)
|
||||||
- VITE_FALLBACK_LOCALE:默认语言,如 `zh-Hans`
|
- VITE_FALLBACK_LOCALE: Default language, such as `zh-Hans`
|
||||||
- VITE_SERVER_BASEURL:服务端基础地址(HTTP 请求 baseURL)
|
- VITE_SERVER_BASEURL: Server base address (HTTP request baseURL)
|
||||||
- VITE_DELETE_CONSOLE:构建时是否移除 console(`true`/`false`)
|
- VITE_DELETE_CONSOLE: Whether to remove console during build (`true`/`false`)
|
||||||
- VITE_SHOW_SOURCEMAP:是否生成 sourcemap(默认关闭)
|
- VITE_SHOW_SOURCEMAP: Whether to generate sourcemap (default off)
|
||||||
- VITE_LOGIN_URL:未登录跳转的登录页路径(路由拦截器使用)
|
- VITE_LOGIN_URL: Login page path for unauthenticated redirect (used by route interceptor)
|
||||||
|
|
||||||
示例(`env/.env.development`):
|
Example (`env/.env.development`):
|
||||||
```env
|
```env
|
||||||
VITE_APP_TITLE=小智
|
VITE_APP_TITLE=Xiaozhi
|
||||||
VITE_FALLBACK_LOCALE=zh-Hans
|
VITE_FALLBACK_LOCALE=zh-Hans
|
||||||
VITE_UNI_APPID=
|
VITE_UNI_APPID=
|
||||||
VITE_WX_APPID=
|
VITE_WX_APPID=
|
||||||
|
|
@ -57,111 +57,111 @@ VITE_SHOW_SOURCEMAP=false
|
||||||
VITE_LOGIN_URL=/pages/login/index
|
VITE_LOGIN_URL=/pages/login/index
|
||||||
```
|
```
|
||||||
|
|
||||||
说明:
|
Note:
|
||||||
- `manifest.config.ts` 会从 `env` 读取标题、appid、语言等配置。
|
- `manifest.config.ts` will read title, appid, language and other configurations from `env`.
|
||||||
|
|
||||||
### 重要注意事项
|
### Important Notes
|
||||||
⚠️ **部署前必须修改的配置项:**
|
⚠️ **Configuration items that must be modified before deployment:**
|
||||||
|
|
||||||
1. **应用 ID 配置**
|
1. **Application ID Configuration**
|
||||||
- `VITE_UNI_APPID`:需要在 [DCloud 开发者中心](https://dev.dcloud.net.cn/) 创建应用并获取 AppID
|
- `VITE_UNI_APPID`: Need to create an application in [DCloud Developer Center](https://dev.dcloud.net.cn/) and get AppID
|
||||||
- `VITE_WX_APPID`:需要在 [微信公众平台](https://mp.weixin.qq.com/) 注册小程序并获取 AppID
|
- `VITE_WX_APPID`: Need to register a mini program in [WeChat Public Platform](https://mp.weixin.qq.com/) and get AppID
|
||||||
|
|
||||||
2. **服务端地址**
|
2. **Server Address**
|
||||||
- `VITE_SERVER_BASEURL`:修改为您的实际服务端地址
|
- `VITE_SERVER_BASEURL`: Modify to your actual server address
|
||||||
|
|
||||||
3. **应用信息**
|
3. **Application Information**
|
||||||
- `VITE_APP_TITLE`:修改为您的应用名称
|
- `VITE_APP_TITLE`: Modify to your application name
|
||||||
- 更新 `src/static/logo.png` 等图标资源
|
- Update icon resources such as `src/static/logo.png`
|
||||||
|
|
||||||
4. **其他配置**
|
4. **Other Configuration**
|
||||||
- 检查 `manifest.config.ts` 中的应用配置信息
|
- Check application configuration information in `manifest.config.ts`
|
||||||
- 根据需要修改 `src/layouts/fg-tabbar/tabbarList.ts` 中的 tabbar 配置
|
- Modify tabbar configuration in `src/layouts/fg-tabbar/tabbarList.ts` as needed
|
||||||
|
|
||||||
### 详细操作指南
|
### Detailed Operation Guide
|
||||||
|
|
||||||
#### 1. 获取 uni-app AppID
|
#### 1. Get uni-app AppID
|
||||||

|

|
||||||
- 复制生成的 AppID 到环境变量 `VITE_UNI_APPID` 中
|
- Copy the generated AppID to environment variable `VITE_UNI_APPID`
|
||||||
|
|
||||||
#### 2. 本地运行步骤
|
#### 2. Local Running Steps
|
||||||

|

|
||||||
|
|
||||||
**App 本地调试:**
|
**App Local Debugging:**
|
||||||
1. 用 HBuilderX 导入 `manager-mobile` 目录
|
1. Import `manager-mobile` directory with HBuilderX
|
||||||
2. 重新识别项目
|
2. Re-identify the project
|
||||||
3. 连接手机或使用模拟器进行真机调试
|
3. Connect phone or use simulator for real device debugging
|
||||||
|
|
||||||
**项目识别问题解决:**
|
**Project Recognition Issue Resolution:**
|
||||||

|

|
||||||
|
|
||||||
如果 HBuilderX 无法正确识别项目类型:
|
If HBuilderX cannot correctly identify the project type:
|
||||||
- 在项目根目录右键选择"重新识别项目类型"
|
- Right-click in the project root directory and select "Re-identify Project Type"
|
||||||
- 确保项目被识别为 "uni-app" 项目
|
- Ensure the project is identified as a "uni-app" project
|
||||||
|
|
||||||
### 路由与鉴权
|
### Routing and Authentication
|
||||||
- 在 `src/main.ts` 中注册了路由拦截插件 `routeInterceptor`。
|
- Route interceptor plugin `routeInterceptor` is registered in `src/main.ts`.
|
||||||
- 黑名单拦截:仅对配置为需要登录的页面进行校验(来源 `@/utils` 的 `getNeedLoginPages`)。
|
- Blacklist interception: Only validates pages configured to require login (from `getNeedLoginPages` in `@/utils`).
|
||||||
- 登录判断:基于用户信息(`pinia` 的 `useUserStore`),未登录将跳转到 `VITE_LOGIN_URL`,并附带重定向回原页面的参数。
|
- Login determination: Based on user information (`useUserStore` from `pinia`), unauthenticated users will be redirected to `VITE_LOGIN_URL` with parameters to redirect back to the original page.
|
||||||
|
|
||||||
### 网络请求
|
### Network Requests
|
||||||
- 基于 `alova` + `@alova/adapter-uniapp`,统一在 `src/http/request/alova.ts` 创建实例。
|
- Based on `alova` + `@alova/adapter-uniapp`, unified instance creation in `src/http/request/alova.ts`.
|
||||||
- `baseURL` 读取环境配置(`getEnvBaseUrl`),可通过 `method.config.meta.domain` 动态切换域名。
|
- `baseURL` reads environment configuration (`getEnvBaseUrl`), can dynamically switch domains through `method.config.meta.domain`.
|
||||||
- 认证:默认从本地 `token`(`uni.getStorageSync('token')`)注入 `Authorization` 头,缺失则重定向登录。
|
- Authentication: Default injection of `Authorization` header from local `token` (`uni.getStorageSync('token')`), redirect to login if missing.
|
||||||
- 响应:统一处理 `statusCode !== 200` 的 HTTP 错误与业务 `code !== 0` 的错误;`401` 会清除 token 并跳转登录。
|
- Response: Unified handling of HTTP errors with `statusCode !== 200` and business errors with `code !== 0`; `401` will clear token and redirect to login.
|
||||||
|
|
||||||
### 构建与发布
|
### Build and Release
|
||||||
|
|
||||||
**微信小程序:**
|
**WeChat Mini Program:**
|
||||||
1. 确保已配置正确的 `VITE_WX_APPID`
|
1. Ensure correct `VITE_WX_APPID` is configured
|
||||||
2. 运行 `pnpm build:mp`,产物在 `dist/build/mp-weixin`
|
2. Run `pnpm build:mp`, output in `dist/build/mp-weixin`
|
||||||
3. 用微信开发者工具导入项目目录,并上传代码
|
3. Import project directory with WeChat Developer Tools and upload code
|
||||||
4. 在微信公众平台提交审核
|
4. Submit for review in WeChat Public Platform
|
||||||
|
|
||||||
**Android & iOS App:**
|
**Android & iOS App:**
|
||||||
|
|
||||||
#### 3. App 打包发行步骤
|
#### 3. App Packaging and Release Steps
|
||||||
|
|
||||||
**步骤一:准备打包**
|
**Step 1: Prepare Packaging**
|
||||||

|

|
||||||
|
|
||||||
1. 确保已配置正确的 `VITE_UNI_APPID`
|
1. Ensure correct `VITE_UNI_APPID` is configured
|
||||||
2. 运行 `pnpm build:app`,产物在 `dist/build/app`
|
2. Run `pnpm build:app`, output in `dist/build/app`
|
||||||
3. 用 HBuilderX 导入项目目录
|
3. Import project directory with HBuilderX
|
||||||
4. 在 HBuilderX 中点击"发行" → "原生App-云打包"
|
4. Click "Release" → "Native App-Cloud Packaging" in HBuilderX
|
||||||
|
|
||||||
**步骤二:配置打包参数**
|
**Step 2: Configure Packaging Parameters**
|
||||||

|

|
||||||
|
|
||||||
1. **应用图标和启动图**:上传应用图标和启动页面图片
|
1. **App Icon and Launch Screen**: Upload app icon and launch screen images
|
||||||
2. **应用版本号**:设置版本号和版本名称
|
2. **App Version Number**: Set version number and version name
|
||||||
3. **签名证书**:
|
3. **Signature Certificate**:
|
||||||
- Android:上传 keystore 证书文件
|
- Android: Upload keystore certificate file
|
||||||
- iOS:配置开发者证书和描述文件
|
- iOS: Configure developer certificate and provisioning profile
|
||||||
4. **包名配置**:设置应用的包名(Bundle ID)
|
4. **Package Name Configuration**: Set app package name (Bundle ID)
|
||||||
5. **打包类型**:选择测试包或正式包
|
5. **Packaging Type**: Choose test package or release package
|
||||||
6. 点击"打包"开始云打包流程
|
6. Click "Package" to start cloud packaging process
|
||||||
|
|
||||||
**发布到应用商店:**
|
**Release to App Stores:**
|
||||||
- **Android**:将生成的 APK 文件上传到各大 Android 应用市场
|
- **Android**: Upload generated APK file to major Android app markets
|
||||||
- **iOS**:将生成的 IPA 文件通过 App Store Connect 上传到 App Store(需要 Apple 开发者账号)
|
- **iOS**: Upload generated IPA file to App Store through App Store Connect (requires Apple Developer account)
|
||||||
|
|
||||||
### 约定与工程化
|
### Conventions and Engineering
|
||||||
- 页面与分包:由 `@uni-helper/vite-plugin-uni-pages` 与 `pages.config.ts` 统一生成;tabbar 配置在 `src/layouts/fg-tabbar/tabbarList.ts`。
|
- Pages and sub-packages: Generated by `@uni-helper/vite-plugin-uni-pages` and `pages.config.ts`; tabbar configuration in `src/layouts/fg-tabbar/tabbarList.ts`.
|
||||||
- 组件与 hooks 自动导入:见 `vite.config.ts` 中 `unplugin-auto-import` 与 `@uni-helper/vite-plugin-uni-components`。
|
- Component and hooks auto-import: See `unplugin-auto-import` and `@uni-helper/vite-plugin-uni-components` in `vite.config.ts`.
|
||||||
- 样式:使用 UnoCSS 与 `src/style/index.scss`。
|
- Styling: Uses UnoCSS and `src/style/index.scss`.
|
||||||
- 状态管理:`pinia` + `pinia-plugin-persistedstate`。
|
- State management: `pinia` + `pinia-plugin-persistedstate`.
|
||||||
- 代码规范:内置 `eslint`、`husky`、`lint-staged`,提交前自动格式化(`lint-staged`)。
|
- Code standards: Built-in `eslint`, `husky`, `lint-staged`, auto-format before commit (`lint-staged`).
|
||||||
|
|
||||||
### 常用脚本
|
### Common Scripts
|
||||||
```bash
|
```bash
|
||||||
# 开发
|
# Development
|
||||||
pnpm dev:mp # 等价 dev:mp-weixin
|
pnpm dev:mp # Equivalent to dev:mp-weixin
|
||||||
|
|
||||||
# 构建
|
# Build
|
||||||
pnpm build:mp # 等价 build:mp-weixin
|
pnpm build:mp # Equivalent to build:mp-weixin
|
||||||
|
|
||||||
# 其他
|
# Others
|
||||||
pnpm type-check
|
pnpm type-check
|
||||||
pnpm lint && pnpm lint:fix
|
pnpm lint && pnpm lint:fix
|
||||||
```
|
```
|
||||||
|
|
|
||||||
11
main/manager-mobile/env/.env
vendored
11
main/manager-mobile/env/.env
vendored
|
|
@ -1,19 +1,20 @@
|
||||||
VITE_APP_TITLE = '小智'
|
VITE_APP_TITLE = 'Xiao Zhi'
|
||||||
VITE_APP_PORT = 9000
|
VITE_APP_PORT = 9000
|
||||||
|
|
||||||
VITE_UNI_APPID = '__UNI__36A515E'
|
VITE_UNI_APPID = '__UNI__36A515E'
|
||||||
VITE_WX_APPID = 'wxa2abb91f64032a2b'
|
VITE_WX_APPID = 'wxa2abb91f64032a2b'
|
||||||
|
|
||||||
# h5部署网站的base,配置到 manifest.config.ts 里的 h5.router.base
|
# The base path for the H5 website deployment, configured in manifest.config.ts under h5.router.base
|
||||||
VITE_APP_PUBLIC_BASE=/
|
VITE_APP_PUBLIC_BASE=/
|
||||||
|
|
||||||
# 登录页面
|
# Login Page
|
||||||
VITE_LOGIN_URL = '/pages/login/index'
|
VITE_LOGIN_URL = '/pages/login/index'
|
||||||
# 第一个请求地址
|
|
||||||
|
# Primary API endpoint URL
|
||||||
VITE_SERVER_BASEURL = 'https://2662r3426b.vicp.fun/xiaozhi'
|
VITE_SERVER_BASEURL = 'https://2662r3426b.vicp.fun/xiaozhi'
|
||||||
|
|
||||||
VITE_UPLOAD_BASEURL = '/otaMag/upload'
|
VITE_UPLOAD_BASEURL = '/otaMag/upload'
|
||||||
|
|
||||||
# h5是否需要配置代理
|
# Whether the H5 app requires proxy configuration
|
||||||
VITE_APP_PROXY=true
|
VITE_APP_PROXY=true
|
||||||
VITE_APP_PROXY_PREFIX = '/xiaozhi'
|
VITE_APP_PROXY_PREFIX = '/xiaozhi'
|
||||||
|
|
@ -7,14 +7,14 @@ export default uniHelper({
|
||||||
ignores: [
|
ignores: [
|
||||||
'src/uni_modules/',
|
'src/uni_modules/',
|
||||||
'dist',
|
'dist',
|
||||||
// unplugin-auto-import 生成的类型文件,每次提交都改变,所以加入这里吧,与 .gitignore 配合使用
|
// Type files generated by unplugin-auto-import, changes on every commit, so add them here to work with .gitignore
|
||||||
'auto-import.d.ts',
|
'auto-import.d.ts',
|
||||||
// vite-plugin-uni-pages 生成的类型文件,每次切换分支都一堆不同的,所以直接 .gitignore
|
// Type files generated by vite-plugin-uni-pages, many differences on every branch switch, so directly .gitignore
|
||||||
'uni-pages.d.ts',
|
'uni-pages.d.ts',
|
||||||
// 插件生成的文件
|
// Plugin generated files
|
||||||
'src/pages.json',
|
'src/pages.json',
|
||||||
'src/manifest.json',
|
'src/manifest.json',
|
||||||
// 忽略自动生成文件
|
// Ignore auto-generated files
|
||||||
'src/service/app/**',
|
'src/service/app/**',
|
||||||
],
|
],
|
||||||
rules: {
|
rules: {
|
||||||
|
|
|
||||||
|
|
@ -4,13 +4,13 @@ import process from 'node:process'
|
||||||
import { defineManifestConfig } from '@uni-helper/vite-plugin-uni-manifest'
|
import { defineManifestConfig } from '@uni-helper/vite-plugin-uni-manifest'
|
||||||
import { loadEnv } from 'vite'
|
import { loadEnv } from 'vite'
|
||||||
|
|
||||||
// 手动解析命令行参数获取 mode
|
// Manually parse command line arguments to get mode
|
||||||
function getMode() {
|
function getMode() {
|
||||||
const args = process.argv.slice(2)
|
const args = process.argv.slice(2)
|
||||||
const modeFlagIndex = args.findIndex(arg => arg === '--mode')
|
const modeFlagIndex = args.findIndex(arg => arg === '--mode')
|
||||||
return modeFlagIndex !== -1 ? args[modeFlagIndex + 1] : args[0] === 'build' ? 'production' : 'development' // 默认 development
|
return modeFlagIndex !== -1 ? args[modeFlagIndex + 1] : args[0] === 'build' ? 'production' : 'development' // Default development
|
||||||
}
|
}
|
||||||
// 获取环境变量的范例
|
// Example of getting environment variables
|
||||||
const env = loadEnv(getMode(), path.resolve(process.cwd(), 'env'))
|
const env = loadEnv(getMode(), path.resolve(process.cwd(), 'env'))
|
||||||
const {
|
const {
|
||||||
VITE_APP_TITLE,
|
VITE_APP_TITLE,
|
||||||
|
|
@ -33,7 +33,7 @@ export default defineManifestConfig({
|
||||||
// base: VITE_APP_PUBLIC_BASE,
|
// base: VITE_APP_PUBLIC_BASE,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
/* 5+App特有相关 */
|
/* 5+App specific */
|
||||||
'app-plus': {
|
'app-plus': {
|
||||||
usingComponents: true,
|
usingComponents: true,
|
||||||
nvueStyleCompiler: 'uni-app',
|
nvueStyleCompiler: 'uni-app',
|
||||||
|
|
@ -47,11 +47,11 @@ export default defineManifestConfig({
|
||||||
autoclose: true,
|
autoclose: true,
|
||||||
delay: 0,
|
delay: 0,
|
||||||
},
|
},
|
||||||
/* 模块配置 */
|
/* Module configuration */
|
||||||
modules: {},
|
modules: {},
|
||||||
/* 应用发布信息 */
|
/* Application distribution information */
|
||||||
distribute: {
|
distribute: {
|
||||||
/* android打包配置 */
|
/* Android packaging configuration */
|
||||||
android: {
|
android: {
|
||||||
minSdkVersion: 30,
|
minSdkVersion: 30,
|
||||||
targetSdkVersion: 30,
|
targetSdkVersion: 30,
|
||||||
|
|
@ -76,11 +76,11 @@ export default defineManifestConfig({
|
||||||
'<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>',
|
'<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>',
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
/* ios打包配置 */
|
/* iOS packaging configuration */
|
||||||
ios: {},
|
ios: {},
|
||||||
/* SDK配置 */
|
/* SDK configuration */
|
||||||
sdkConfigs: {},
|
sdkConfigs: {},
|
||||||
/* 图标配置 */
|
/* Icon configuration */
|
||||||
icons: {
|
icons: {
|
||||||
android: {
|
android: {
|
||||||
hdpi: 'unpackage/res/icons/72x72.png',
|
hdpi: 'unpackage/res/icons/72x72.png',
|
||||||
|
|
@ -115,14 +115,14 @@ export default defineManifestConfig({
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
/* 快应用特有相关 */
|
/* Quick app specific */
|
||||||
'quickapp': {},
|
'quickapp': {},
|
||||||
/* 小程序特有相关 */
|
/* Mini program specific */
|
||||||
'mp-weixin': {
|
'mp-weixin': {
|
||||||
appid: VITE_WX_APPID,
|
appid: VITE_WX_APPID,
|
||||||
setting: {
|
setting: {
|
||||||
urlCheck: false,
|
urlCheck: false,
|
||||||
// 是否启用 ES6 转 ES5
|
// Whether to enable ES6 to ES5 conversion
|
||||||
es6: true,
|
es6: true,
|
||||||
minified: true,
|
minified: true,
|
||||||
},
|
},
|
||||||
|
|
@ -133,7 +133,7 @@ export default defineManifestConfig({
|
||||||
// __usePrivacyCheck__: true,
|
// __usePrivacyCheck__: true,
|
||||||
permission: {
|
permission: {
|
||||||
'scope.userLocation': {
|
'scope.userLocation': {
|
||||||
desc: 'WiFi配网功能需要获取位置权限',
|
desc: 'WiFi configuration function requires location permission',
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
requiredPrivateInfos: ['getLocation'],
|
requiredPrivateInfos: ['getLocation'],
|
||||||
|
|
|
||||||
|
|
@ -4,20 +4,20 @@
|
||||||
"version": "3.4.0",
|
"version": "3.4.0",
|
||||||
"unibest-version": "3.4.0",
|
"unibest-version": "3.4.0",
|
||||||
"packageManager": "pnpm@10.10.0",
|
"packageManager": "pnpm@10.10.0",
|
||||||
"description": "xiaozhi-esp32-server的移动端管理后台",
|
"description": "Mobile management backend for xiaozhi-esp32-server",
|
||||||
"generate-time": "2025-08-04",
|
"generate-time": "2025-08-04",
|
||||||
"author": {
|
"author": {
|
||||||
"name": "huangjunsen",
|
"name": "huangjunsen",
|
||||||
"zhName": "黄俊森",
|
"zhName": "Huang Junsen",
|
||||||
"email": "huangjunsen@xiaozhi.com",
|
"email": "huangjunsen@xiaozhi.com",
|
||||||
"github": "https://github.com/huangjunsen0406",
|
"github": "https://github.com/huangjunsen0406",
|
||||||
"gitee": "https://gitee.com/huang-jun-sen"
|
"gitee": "https://gitee.com/huang-jun-sen"
|
||||||
},
|
},
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"homepage": "https://github.com/xinnan-tech/xiaozhi-esp32-server",
|
"homepage": "https://github.com/lapy/xiaozhi-esp32-server",
|
||||||
"repository": "https://github.com/xinnan-tech/xiaozhi-esp32-server",
|
"repository": "https://github.com/lapy/xiaozhi-esp32-server",
|
||||||
"bugs": {
|
"bugs": {
|
||||||
"url": "https://github.com/xinnan-tech/xiaozhi-esp32-server/issues"
|
"url": "https://github.com/lapy/xiaozhi-esp32-server/issues"
|
||||||
},
|
},
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=18",
|
"node": ">=18",
|
||||||
|
|
@ -100,7 +100,7 @@
|
||||||
"js-cookie": "^3.0.5",
|
"js-cookie": "^3.0.5",
|
||||||
"pinia": "2.0.36",
|
"pinia": "2.0.36",
|
||||||
"pinia-plugin-persistedstate": "3.2.1",
|
"pinia-plugin-persistedstate": "3.2.1",
|
||||||
"sm-crypto": "^0.3.13",
|
"sm-crypto": "^0.4.0",
|
||||||
"vue": "^3.4.21",
|
"vue": "^3.4.21",
|
||||||
"wot-design-uni": "^1.9.1",
|
"wot-design-uni": "^1.9.1",
|
||||||
"z-paging": "2.8.7"
|
"z-paging": "2.8.7"
|
||||||
|
|
@ -154,7 +154,7 @@
|
||||||
"vue-tsc": "^2.2.10"
|
"vue-tsc": "^2.2.10"
|
||||||
},
|
},
|
||||||
"resolutions": {
|
"resolutions": {
|
||||||
"bin-wrapper": "npm:bin-wrapper-china"
|
"bin-wrapper": "npm:bin-wrapper"
|
||||||
},
|
},
|
||||||
"lint-staged": {
|
"lint-staged": {
|
||||||
"*": "eslint --fix"
|
"*": "eslint --fix"
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@ import { tabBar } from './src/layouts/fg-tabbar/tabbarList'
|
||||||
export default defineUniPages({
|
export default defineUniPages({
|
||||||
globalStyle: {
|
globalStyle: {
|
||||||
navigationStyle: 'default',
|
navigationStyle: 'default',
|
||||||
navigationBarTitleText: '小智',
|
navigationBarTitleText: 'XiaoZhi',
|
||||||
navigationBarBackgroundColor: '#f8f8f8',
|
navigationBarBackgroundColor: '#f8f8f8',
|
||||||
navigationBarTextStyle: 'black',
|
navigationBarTextStyle: 'black',
|
||||||
backgroundColor: '#FFFFFF',
|
backgroundColor: '#FFFFFF',
|
||||||
|
|
@ -18,6 +18,6 @@ export default defineUniPages({
|
||||||
'z-paging/components/z-paging$1/z-paging$1.vue',
|
'z-paging/components/z-paging$1/z-paging$1.vue',
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
// tabbar 的配置统一在 "./src/layouts/fg-tabbar/tabbarList.ts" 文件中
|
// tabbar configuration is unified in "./src/layouts/fg-tabbar/tabbarList.ts" file
|
||||||
tabBar: tabBar as any,
|
tabBar: tabBar as any,
|
||||||
})
|
})
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@ settings:
|
||||||
excludeLinksFromLockfile: false
|
excludeLinksFromLockfile: false
|
||||||
|
|
||||||
overrides:
|
overrides:
|
||||||
bin-wrapper: npm:bin-wrapper-china
|
bin-wrapper: npm:bin-wrapper
|
||||||
|
|
||||||
patchedDependencies:
|
patchedDependencies:
|
||||||
'@dcloudio/uni-h5':
|
'@dcloudio/uni-h5':
|
||||||
|
|
@ -91,6 +91,9 @@ importers:
|
||||||
pinia-plugin-persistedstate:
|
pinia-plugin-persistedstate:
|
||||||
specifier: 3.2.1
|
specifier: 3.2.1
|
||||||
version: 3.2.1(pinia@2.0.36(typescript@5.7.2)(vue@3.5.15(typescript@5.7.2)))
|
version: 3.2.1(pinia@2.0.36(typescript@5.7.2)(vue@3.5.15(typescript@5.7.2)))
|
||||||
|
sm-crypto:
|
||||||
|
specifier: ^0.4.0
|
||||||
|
version: 0.4.0
|
||||||
vue:
|
vue:
|
||||||
specifier: ^3.4.21
|
specifier: ^3.4.21
|
||||||
version: 3.5.15(typescript@5.7.2)
|
version: 3.5.15(typescript@5.7.2)
|
||||||
|
|
@ -4719,6 +4722,9 @@ packages:
|
||||||
resolution: {integrity: sha512-wpxZs9NoxZaJESJGIZTyDEaYpl0FKSA+FB9aJiyemKhMwkxQg63h4T1KJgUGHpTqPDNRcmmYLugrRjJlBtWvRA==}
|
resolution: {integrity: sha512-wpxZs9NoxZaJESJGIZTyDEaYpl0FKSA+FB9aJiyemKhMwkxQg63h4T1KJgUGHpTqPDNRcmmYLugrRjJlBtWvRA==}
|
||||||
hasBin: true
|
hasBin: true
|
||||||
|
|
||||||
|
jsbn@1.1.0:
|
||||||
|
resolution: {integrity: sha512-4bYVV3aAMtDTTu4+xsDYa6sy9GyJ69/amsu9sYF2zqjiEoZA5xJi3BrfX3uY+/IekIu7MwdObdbDWpoZdBv3/A==}
|
||||||
|
|
||||||
jsdoc-type-pratt-parser@4.1.0:
|
jsdoc-type-pratt-parser@4.1.0:
|
||||||
resolution: {integrity: sha512-Hicd6JK5Njt2QB6XYFS7ok9e37O8AYk3jTcppG4YVQnYjOemymvTcmc7OWsmq/Qqj5TdRFO5/x/tIPmBeRtGHg==}
|
resolution: {integrity: sha512-Hicd6JK5Njt2QB6XYFS7ok9e37O8AYk3jTcppG4YVQnYjOemymvTcmc7OWsmq/Qqj5TdRFO5/x/tIPmBeRtGHg==}
|
||||||
engines: {node: '>=12.0.0'}
|
engines: {node: '>=12.0.0'}
|
||||||
|
|
@ -6020,6 +6026,9 @@ packages:
|
||||||
resolution: {integrity: sha512-bSiSngZ/jWeX93BqeIAbImyTbEihizcwNjFoRUIY/T1wWQsfsm2Vw1agPKylXvQTU7iASGdHhyqRlqQzfz+Htg==}
|
resolution: {integrity: sha512-bSiSngZ/jWeX93BqeIAbImyTbEihizcwNjFoRUIY/T1wWQsfsm2Vw1agPKylXvQTU7iASGdHhyqRlqQzfz+Htg==}
|
||||||
engines: {node: '>=18'}
|
engines: {node: '>=18'}
|
||||||
|
|
||||||
|
sm-crypto@0.4.0:
|
||||||
|
resolution: {integrity: sha512-OexH2V1EqmhXuOIPGoCl55OjMF0wwPUM/zhUjT0Q6vHBeopSRvTNRy76/1eRoFs3VBKt39hdFnxwpFmooHYa2A==}
|
||||||
|
|
||||||
source-map-js@1.2.1:
|
source-map-js@1.2.1:
|
||||||
resolution: {integrity: sha512-UXWMKhLOwVKb728IUtQPXxfYU+usdybtUrK/8uGE8CQMvrhOpwvzDBwj0QhSL7MQc7vIsISBG8VQ8+IDQxpfQA==}
|
resolution: {integrity: sha512-UXWMKhLOwVKb728IUtQPXxfYU+usdybtUrK/8uGE8CQMvrhOpwvzDBwj0QhSL7MQc7vIsISBG8VQ8+IDQxpfQA==}
|
||||||
engines: {node: '>=0.10.0'}
|
engines: {node: '>=0.10.0'}
|
||||||
|
|
@ -12652,6 +12661,8 @@ snapshots:
|
||||||
dependencies:
|
dependencies:
|
||||||
argparse: 2.0.1
|
argparse: 2.0.1
|
||||||
|
|
||||||
|
jsbn@1.1.0: {}
|
||||||
|
|
||||||
jsdoc-type-pratt-parser@4.1.0: {}
|
jsdoc-type-pratt-parser@4.1.0: {}
|
||||||
|
|
||||||
jsdom@16.7.0:
|
jsdom@16.7.0:
|
||||||
|
|
@ -14145,6 +14156,10 @@ snapshots:
|
||||||
ansi-styles: 6.2.1
|
ansi-styles: 6.2.1
|
||||||
is-fullwidth-code-point: 5.0.0
|
is-fullwidth-code-point: 5.0.0
|
||||||
|
|
||||||
|
sm-crypto@0.4.0:
|
||||||
|
dependencies:
|
||||||
|
jsbn: 1.1.0
|
||||||
|
|
||||||
source-map-js@1.2.1: {}
|
source-map-js@1.2.1: {}
|
||||||
|
|
||||||
source-map-support@0.5.21:
|
source-map-support@0.5.21:
|
||||||
|
|
|
||||||
|
|
@ -1,13 +1,13 @@
|
||||||
// # 执行 `pnpm upgrade` 后会升级 `uniapp` 相关依赖
|
// # After executing `pnpm upgrade`, uniapp related dependencies will be upgraded
|
||||||
// # 在升级完后,会自动添加很多无用依赖,这需要删除以减小依赖包体积
|
// # After upgrade, many useless dependencies will be automatically added, which need to be deleted to reduce package size
|
||||||
// # 只需要执行下面的命令即可
|
// # Just execute the following command
|
||||||
|
|
||||||
const { exec } = require('node:child_process')
|
const { exec } = require('node:child_process')
|
||||||
|
|
||||||
// 定义要执行的命令
|
// Define commands to execute
|
||||||
const dependencies = [
|
const dependencies = [
|
||||||
'@dcloudio/uni-app-harmony',
|
'@dcloudio/uni-app-harmony',
|
||||||
// TODO: 如果不需要某个平台的小程序,请手动删除或注释掉
|
// TODO: If you don't need mini programs for certain platforms, please manually delete or comment out
|
||||||
'@dcloudio/uni-mp-alipay',
|
'@dcloudio/uni-mp-alipay',
|
||||||
'@dcloudio/uni-mp-baidu',
|
'@dcloudio/uni-mp-baidu',
|
||||||
'@dcloudio/uni-mp-jd',
|
'@dcloudio/uni-mp-jd',
|
||||||
|
|
@ -17,19 +17,19 @@ const dependencies = [
|
||||||
'@dcloudio/uni-mp-toutiao',
|
'@dcloudio/uni-mp-toutiao',
|
||||||
'@dcloudio/uni-mp-xhs',
|
'@dcloudio/uni-mp-xhs',
|
||||||
'@dcloudio/uni-quickapp-webview',
|
'@dcloudio/uni-quickapp-webview',
|
||||||
// i18n模板要注释掉下面的
|
// i18n template should comment out the following
|
||||||
'vue-i18n',
|
'vue-i18n',
|
||||||
]
|
]
|
||||||
|
|
||||||
// 使用exec执行命令
|
// Use exec to execute commands
|
||||||
exec(`pnpm un ${dependencies.join(' ')}`, (error, stdout, stderr) => {
|
exec(`pnpm un ${dependencies.join(' ')}`, (error, stdout, stderr) => {
|
||||||
if (error) {
|
if (error) {
|
||||||
// 如果有错误,打印错误信息
|
// If there is an error, print error information
|
||||||
console.error(`执行出错: ${error}`)
|
console.error(`Execution error: ${error}`)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
// 打印正常输出
|
// Print normal output
|
||||||
console.log(`stdout: ${stdout}`)
|
console.log(`stdout: ${stdout}`)
|
||||||
// 如果有错误输出,也打印出来
|
// If there is error output, print it out too
|
||||||
console.error(`stderr: ${stderr}`)
|
console.error(`stderr: ${stderr}`)
|
||||||
})
|
})
|
||||||
|
|
|
||||||
|
|
@ -1,78 +1,23 @@
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { onHide, onLaunch, onShow } from '@dcloudio/uni-app'
|
import { onHide, onLaunch, onShow } from '@dcloudio/uni-app'
|
||||||
import { watch, onMounted } from 'vue'
|
|
||||||
import { usePageAuth } from '@/hooks/usePageAuth'
|
import { usePageAuth } from '@/hooks/usePageAuth'
|
||||||
import { useConfigStore } from '@/store'
|
import { useConfigStore } from '@/store'
|
||||||
import { t } from '@/i18n'
|
|
||||||
import { useLangStore } from '@/store/lang'
|
|
||||||
import 'abortcontroller-polyfill/dist/abortcontroller-polyfill-only'
|
import 'abortcontroller-polyfill/dist/abortcontroller-polyfill-only'
|
||||||
|
|
||||||
usePageAuth()
|
usePageAuth()
|
||||||
|
|
||||||
const configStore = useConfigStore()
|
const configStore = useConfigStore()
|
||||||
const langStore = useLangStore()
|
|
||||||
|
|
||||||
onLaunch(() => {
|
onLaunch(() => {
|
||||||
console.log('App Launch')
|
console.log('App Launch')
|
||||||
// 获取公共配置
|
// Get public config
|
||||||
configStore.fetchPublicConfig().catch((error) => {
|
configStore.fetchPublicConfig().catch((error) => {
|
||||||
console.error('获取公共配置失败:', error)
|
console.error('Failed to get public config:', error)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
onShow(() => {
|
onShow(() => {
|
||||||
console.log('App Show')
|
console.log('App Show')
|
||||||
// 使用setTimeout延迟执行,确保tabBar已经初始化
|
|
||||||
setTimeout(() => {
|
|
||||||
updateTabBarText()
|
|
||||||
}, 100)
|
|
||||||
})
|
})
|
||||||
|
|
||||||
// 动态更新tabBar文本
|
|
||||||
function updateTabBarText() {
|
|
||||||
try {
|
|
||||||
// 设置首页tabBar文本
|
|
||||||
uni.setTabBarItem({
|
|
||||||
index: 0,
|
|
||||||
text: t('tabBar.home'),
|
|
||||||
success: () => {},
|
|
||||||
fail: (err) => {
|
|
||||||
console.log('设置首页tabBar文本失败:', err)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
// 设置配网tabBar文本
|
|
||||||
uni.setTabBarItem({
|
|
||||||
index: 1,
|
|
||||||
text: t('tabBar.deviceConfig'),
|
|
||||||
success: () => {},
|
|
||||||
fail: (err) => {
|
|
||||||
console.log('设置配网tabBar文本失败:', err)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
// 设置系统tabBar文本
|
|
||||||
uni.setTabBarItem({
|
|
||||||
index: 2,
|
|
||||||
text: t('tabBar.settings'),
|
|
||||||
success: () => {},
|
|
||||||
fail: (err) => {
|
|
||||||
console.log('设置系统tabBar文本失败:', err)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
} catch (error) {
|
|
||||||
console.log('更新tabBar文本时出错:', error)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// 监听语言切换事件
|
|
||||||
onMounted(() => {
|
|
||||||
// 监听语言变化,当语言改变时自动更新tabBar文本
|
|
||||||
watch(() => langStore.currentLang, () => {
|
|
||||||
console.log('语言已切换,更新tabBar文本')
|
|
||||||
// 语言切换后立即更新tabBar文本
|
|
||||||
updateTabBarText()
|
|
||||||
})
|
|
||||||
})
|
|
||||||
|
|
||||||
onHide(() => {
|
onHide(() => {
|
||||||
console.log('App Hide')
|
console.log('App Hide')
|
||||||
})
|
})
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,7 @@ import type {
|
||||||
} from './types'
|
} from './types'
|
||||||
import { http } from '@/http/request/alova'
|
import { http } from '@/http/request/alova'
|
||||||
|
|
||||||
// 获取智能体详情
|
// Get agent details
|
||||||
export function getAgentDetail(id: string) {
|
export function getAgentDetail(id: string) {
|
||||||
return http.Get<AgentDetail>(`/agent/${id}`, {
|
return http.Get<AgentDetail>(`/agent/${id}`, {
|
||||||
meta: {
|
meta: {
|
||||||
|
|
@ -20,7 +20,7 @@ export function getAgentDetail(id: string) {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// 获取角色模板列表
|
// Get role template list
|
||||||
export function getRoleTemplates() {
|
export function getRoleTemplates() {
|
||||||
return http.Get<RoleTemplate[]>('/agent/template', {
|
return http.Get<RoleTemplate[]>('/agent/template', {
|
||||||
meta: {
|
meta: {
|
||||||
|
|
@ -33,7 +33,7 @@ export function getRoleTemplates() {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// 获取模型选项
|
// Get model options
|
||||||
export function getModelOptions(modelType: string, modelName: string = '') {
|
export function getModelOptions(modelType: string, modelName: string = '') {
|
||||||
return http.Get<ModelOption[]>('/models/names', {
|
return http.Get<ModelOption[]>('/models/names', {
|
||||||
params: {
|
params: {
|
||||||
|
|
@ -50,7 +50,7 @@ export function getModelOptions(modelType: string, modelName: string = '') {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// 获取智能体列表
|
// Get agent list
|
||||||
export function getAgentList() {
|
export function getAgentList() {
|
||||||
return http.Get<Agent[]>('/agent/list', {
|
return http.Get<Agent[]>('/agent/list', {
|
||||||
meta: {
|
meta: {
|
||||||
|
|
@ -63,7 +63,7 @@ export function getAgentList() {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// 创建智能体
|
// Create agent
|
||||||
export function createAgent(data: AgentCreateData) {
|
export function createAgent(data: AgentCreateData) {
|
||||||
return http.Post<string>('/agent', data, {
|
return http.Post<string>('/agent', data, {
|
||||||
meta: {
|
meta: {
|
||||||
|
|
@ -73,7 +73,7 @@ export function createAgent(data: AgentCreateData) {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// 删除智能体
|
// Delete agent
|
||||||
export function deleteAgent(id: string) {
|
export function deleteAgent(id: string) {
|
||||||
return http.Delete(`/agent/${id}`, {
|
return http.Delete(`/agent/${id}`, {
|
||||||
meta: {
|
meta: {
|
||||||
|
|
@ -83,7 +83,7 @@ export function deleteAgent(id: string) {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// 获取TTS音色列表
|
// Get TTS voice list
|
||||||
export function getTTSVoices(ttsModelId: string, voiceName: string = '') {
|
export function getTTSVoices(ttsModelId: string, voiceName: string = '') {
|
||||||
return http.Get<{ id: string, name: string }[]>(`/models/${ttsModelId}/voices`, {
|
return http.Get<{ id: string, name: string }[]>(`/models/${ttsModelId}/voices`, {
|
||||||
params: {
|
params: {
|
||||||
|
|
@ -99,7 +99,7 @@ export function getTTSVoices(ttsModelId: string, voiceName: string = '') {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// 更新智能体
|
// Update agent
|
||||||
export function updateAgent(id: string, data: Partial<AgentDetail>) {
|
export function updateAgent(id: string, data: Partial<AgentDetail>) {
|
||||||
return http.Put(`/agent/${id}`, data, {
|
return http.Put(`/agent/${id}`, data, {
|
||||||
meta: {
|
meta: {
|
||||||
|
|
@ -112,7 +112,7 @@ export function updateAgent(id: string, data: Partial<AgentDetail>) {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// 获取插件列表
|
// Get plugin list
|
||||||
export function getPluginFunctions() {
|
export function getPluginFunctions() {
|
||||||
return http.Get<any[]>(`/models/provider/plugin/names`, {
|
return http.Get<any[]>(`/models/provider/plugin/names`, {
|
||||||
meta: {
|
meta: {
|
||||||
|
|
@ -125,18 +125,17 @@ export function getPluginFunctions() {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// 获取mcp接入点
|
// Get MCP access point
|
||||||
export function getMcpAddress(agentId: string) {
|
export function getMcpAddress(agentId: string) {
|
||||||
return http.Get<string>(`/agent/mcp/address/${agentId}`, {
|
return http.Get<string>(`/agent/mcp/address/${agentId}`, {
|
||||||
meta: {
|
meta: {
|
||||||
ignoreAuth: false,
|
ignoreAuth: false,
|
||||||
toast: false,
|
toast: false,
|
||||||
isExposeError: true,
|
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// 获取mcp工具
|
// Get MCP tools
|
||||||
export function getMcpTools(agentId: string) {
|
export function getMcpTools(agentId: string) {
|
||||||
return http.Get<string[]>(`/agent/mcp/tools/${agentId}`, {
|
return http.Get<string[]>(`/agent/mcp/tools/${agentId}`, {
|
||||||
meta: {
|
meta: {
|
||||||
|
|
@ -149,7 +148,7 @@ export function getMcpTools(agentId: string) {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// 获取声纹列表
|
// Get voiceprint list
|
||||||
export function getVoicePrintList(agentId: string) {
|
export function getVoicePrintList(agentId: string) {
|
||||||
return http.Get<any[]>(`/agent/voice-print/list/${agentId}`, {
|
return http.Get<any[]>(`/agent/voice-print/list/${agentId}`, {
|
||||||
meta: {
|
meta: {
|
||||||
|
|
@ -162,7 +161,7 @@ export function getVoicePrintList(agentId: string) {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// 获取语音对话记录
|
// Get voice conversation records
|
||||||
export function getChatHistoryUser(agentId: string) {
|
export function getChatHistoryUser(agentId: string) {
|
||||||
return http.Get<any[]>(`/agent/${agentId}/chat-history/user`, {
|
return http.Get<any[]>(`/agent/${agentId}/chat-history/user`, {
|
||||||
meta: {
|
meta: {
|
||||||
|
|
@ -175,7 +174,7 @@ export function getChatHistoryUser(agentId: string) {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// 新增声纹说话人
|
// Add voiceprint speaker
|
||||||
export function createVoicePrint(data: { agentId: string, audioId: string, sourceName: string, introduce: string }) {
|
export function createVoicePrint(data: { agentId: string, audioId: string, sourceName: string, introduce: string }) {
|
||||||
return http.Post('/agent/voice-print', data, {
|
return http.Post('/agent/voice-print', data, {
|
||||||
meta: {
|
meta: {
|
||||||
|
|
@ -184,39 +183,3 @@ export function createVoicePrint(data: { agentId: string, audioId: string, sourc
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// 获取智能体标签
|
|
||||||
export function getAgentTags(agentId: string) {
|
|
||||||
return http.Get<any[]>(`/agent/${agentId}/tags`, {
|
|
||||||
meta: {
|
|
||||||
ignoreAuth: false,
|
|
||||||
toast: false,
|
|
||||||
},
|
|
||||||
cacheFor: {
|
|
||||||
expire: 0,
|
|
||||||
},
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
// 更新智能体标签
|
|
||||||
export function updateAgentTags(agentId: string, data) {
|
|
||||||
return http.Put(`/agent/${agentId}/tags`, data, {
|
|
||||||
meta: {
|
|
||||||
ignoreAuth: false,
|
|
||||||
isExposeError: true,
|
|
||||||
},
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
// 获取所有语言
|
|
||||||
export function getAllLanguage(modelId: string) {
|
|
||||||
return http.Get<{ id: string, name: string, languages: string }[]>(`/models/${modelId}/voices`, {
|
|
||||||
meta: {
|
|
||||||
ignoreAuth: false,
|
|
||||||
toast: false,
|
|
||||||
},
|
|
||||||
cacheFor: {
|
|
||||||
expire: 0,
|
|
||||||
},
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
// 智能体列表数据类型
|
// Agent list data type
|
||||||
export interface Agent {
|
export interface Agent {
|
||||||
id: string
|
id: string
|
||||||
agentName: string
|
agentName: string
|
||||||
|
|
@ -11,15 +11,14 @@ export interface Agent {
|
||||||
summaryMemory: string | null
|
summaryMemory: string | null
|
||||||
lastConnectedAt: string | null
|
lastConnectedAt: string | null
|
||||||
deviceCount: number
|
deviceCount: number
|
||||||
tags: Record<string, string>[]
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 智能体创建数据类型
|
// Agent creation data type
|
||||||
export interface AgentCreateData {
|
export interface AgentCreateData {
|
||||||
agentName: string
|
agentName: string
|
||||||
}
|
}
|
||||||
|
|
||||||
// 智能体详情数据类型
|
// Agent details data type
|
||||||
export interface AgentDetail {
|
export interface AgentDetail {
|
||||||
id: string
|
id: string
|
||||||
userId: string
|
userId: string
|
||||||
|
|
@ -44,20 +43,7 @@ export interface AgentDetail {
|
||||||
createdAt: string
|
createdAt: string
|
||||||
updater: string
|
updater: string
|
||||||
updatedAt: string
|
updatedAt: string
|
||||||
ttsLanguage: string
|
|
||||||
ttsVolume: number
|
|
||||||
ttsRate: number
|
|
||||||
ttsPitch: number
|
|
||||||
functions: AgentFunction[]
|
functions: AgentFunction[]
|
||||||
contextProviders: Providers[]
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface Providers {
|
|
||||||
url: string
|
|
||||||
headers: Array<{
|
|
||||||
key: string
|
|
||||||
value: string
|
|
||||||
}>
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface AgentFunction {
|
export interface AgentFunction {
|
||||||
|
|
@ -67,7 +53,7 @@ export interface AgentFunction {
|
||||||
paramInfo: Record<string, string | number | boolean> | null
|
paramInfo: Record<string, string | number | boolean> | null
|
||||||
}
|
}
|
||||||
|
|
||||||
// 角色模板数据类型
|
// Role template data type
|
||||||
export interface RoleTemplate {
|
export interface RoleTemplate {
|
||||||
id: string
|
id: string
|
||||||
agentCode: string
|
agentCode: string
|
||||||
|
|
@ -92,7 +78,7 @@ export interface RoleTemplate {
|
||||||
updatedAt: string
|
updatedAt: string
|
||||||
}
|
}
|
||||||
|
|
||||||
// 模型选项数据类型
|
// Model options data type
|
||||||
export interface ModelOption {
|
export interface ModelOption {
|
||||||
id: string
|
id: string
|
||||||
modelName: string
|
modelName: string
|
||||||
|
|
@ -112,7 +98,7 @@ export interface PluginDefinition {
|
||||||
modelType: string
|
modelType: string
|
||||||
providerCode: string
|
providerCode: string
|
||||||
name: string
|
name: string
|
||||||
fields: PluginField[] // 注意:原始是字符串,需要先 JSON.parse
|
fields: PluginField[] // Note: Original is string, need to JSON.parse first
|
||||||
sort: number
|
sort: number
|
||||||
updater: string
|
updater: string
|
||||||
updateDate: string
|
updateDate: string
|
||||||
|
|
|
||||||
|
|
@ -1,28 +1,29 @@
|
||||||
import { http } from '@/http/request/alova'
|
import { http } from '@/http/request/alova'
|
||||||
|
|
||||||
// 登录接口数据类型
|
// Login interface data type
|
||||||
export interface LoginData {
|
export interface LoginData {
|
||||||
username: string
|
username: string
|
||||||
password: string
|
password: string
|
||||||
|
captcha: string
|
||||||
captchaId: string
|
captchaId: string
|
||||||
areaCode?: string
|
areaCode?: string
|
||||||
mobile?: string
|
mobile?: string
|
||||||
}
|
}
|
||||||
|
|
||||||
// 登录响应数据类型
|
// Login response data type
|
||||||
export interface LoginResponse {
|
export interface LoginResponse {
|
||||||
token: string
|
token: string
|
||||||
expire: number
|
expire: number
|
||||||
clientHash: string
|
clientHash: string
|
||||||
}
|
}
|
||||||
|
|
||||||
// 验证码响应数据类型
|
// Captcha response data type
|
||||||
export interface CaptchaResponse {
|
export interface CaptchaResponse {
|
||||||
captchaId: string
|
captchaId: string
|
||||||
captchaImage: string
|
captchaImage: string
|
||||||
}
|
}
|
||||||
|
|
||||||
// 获取验证码
|
// Get captcha
|
||||||
export function getCaptcha(uuid: string) {
|
export function getCaptcha(uuid: string) {
|
||||||
return http.Get<string>('/user/captcha', {
|
return http.Get<string>('/user/captcha', {
|
||||||
params: { uuid },
|
params: { uuid },
|
||||||
|
|
@ -33,7 +34,7 @@ export function getCaptcha(uuid: string) {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// 用户登录
|
// User login
|
||||||
export function login(data: LoginData) {
|
export function login(data: LoginData) {
|
||||||
return http.Post<LoginResponse>('/user/login', data, {
|
return http.Post<LoginResponse>('/user/login', data, {
|
||||||
meta: {
|
meta: {
|
||||||
|
|
@ -43,7 +44,7 @@ export function login(data: LoginData) {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// 用户信息响应数据类型
|
// User info response data type
|
||||||
export interface UserInfo {
|
export interface UserInfo {
|
||||||
id: number
|
id: number
|
||||||
username: string
|
username: string
|
||||||
|
|
@ -54,12 +55,13 @@ export interface UserInfo {
|
||||||
superAdmin: number
|
superAdmin: number
|
||||||
}
|
}
|
||||||
|
|
||||||
// 公共配置响应数据类型
|
// Public config response data type
|
||||||
export interface PublicConfig {
|
export interface PublicConfig {
|
||||||
enableMobileRegister: boolean
|
enableMobileRegister: boolean
|
||||||
version: string
|
version: string
|
||||||
year: string
|
year: string
|
||||||
allowUserRegister: boolean
|
allowUserRegister: boolean
|
||||||
|
sm2PublicKey?: string
|
||||||
mobileAreaList: Array<{
|
mobileAreaList: Array<{
|
||||||
name: string
|
name: string
|
||||||
key: string
|
key: string
|
||||||
|
|
@ -67,10 +69,9 @@ export interface PublicConfig {
|
||||||
beianIcpNum: string
|
beianIcpNum: string
|
||||||
beianGaNum: string
|
beianGaNum: string
|
||||||
name: string
|
name: string
|
||||||
sm2PublicKey: string
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 获取用户信息
|
// Get user info
|
||||||
export function getUserInfo() {
|
export function getUserInfo() {
|
||||||
return http.Get<UserInfo>('/user/info', {
|
return http.Get<UserInfo>('/user/info', {
|
||||||
meta: {
|
meta: {
|
||||||
|
|
@ -80,7 +81,7 @@ export function getUserInfo() {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// 获取公共配置
|
// Get public config
|
||||||
export function getPublicConfig() {
|
export function getPublicConfig() {
|
||||||
return http.Get<PublicConfig>('/user/pub-config', {
|
return http.Get<PublicConfig>('/user/pub-config', {
|
||||||
meta: {
|
meta: {
|
||||||
|
|
@ -90,17 +91,15 @@ export function getPublicConfig() {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// 注册数据类型
|
// Registration data type
|
||||||
export interface RegisterData {
|
export interface RegisterData {
|
||||||
username: string
|
username: string
|
||||||
password: string
|
password: string
|
||||||
captchaId: string
|
captchaId: string
|
||||||
areaCode: string
|
mobileCaptcha?: string
|
||||||
mobile: string
|
|
||||||
mobileCaptcha: string
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 发送短信验证码
|
// Send SMS verification code
|
||||||
export function sendSmsCode(data: {
|
export function sendSmsCode(data: {
|
||||||
phone: string
|
phone: string
|
||||||
captcha: string
|
captcha: string
|
||||||
|
|
@ -114,7 +113,7 @@ export function sendSmsCode(data: {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// 用户注册
|
// User registration
|
||||||
export function register(data: RegisterData) {
|
export function register(data: RegisterData) {
|
||||||
return http.Post('/user/register', data, {
|
return http.Post('/user/register', data, {
|
||||||
meta: {
|
meta: {
|
||||||
|
|
@ -124,16 +123,12 @@ export function register(data: RegisterData) {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// 忘记密码数据类型
|
export function retrievePassword(data: {
|
||||||
export interface ForgotPasswordData {
|
|
||||||
phone: string
|
phone: string
|
||||||
code: string
|
code: string
|
||||||
password: string
|
password: string
|
||||||
captchaId: string
|
captchaId: string
|
||||||
}
|
}) {
|
||||||
|
|
||||||
// 忘记密码(找回密码)
|
|
||||||
export function retrievePassword(data: ForgotPasswordData) {
|
|
||||||
return http.Put('/user/retrieve-password', data, {
|
return http.Put('/user/retrieve-password', data, {
|
||||||
meta: {
|
meta: {
|
||||||
ignoreAuth: true,
|
ignoreAuth: true,
|
||||||
|
|
|
||||||
|
|
@ -6,9 +6,9 @@ import type {
|
||||||
import { http } from '@/http/request/alova'
|
import { http } from '@/http/request/alova'
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取聊天会话列表
|
* Get chat session list
|
||||||
* @param agentId 智能体ID
|
* @param agentId Agent ID
|
||||||
* @param params 分页参数
|
* @param params Pagination parameters
|
||||||
*/
|
*/
|
||||||
export function getChatSessions(agentId: string, params: GetSessionsParams) {
|
export function getChatSessions(agentId: string, params: GetSessionsParams) {
|
||||||
return http.Get<ChatSessionsResponse>(`/agent/${agentId}/sessions`, {
|
return http.Get<ChatSessionsResponse>(`/agent/${agentId}/sessions`, {
|
||||||
|
|
@ -24,9 +24,9 @@ export function getChatSessions(agentId: string, params: GetSessionsParams) {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取聊天记录详情
|
* Get chat record details
|
||||||
* @param agentId 智能体ID
|
* @param agentId Agent ID
|
||||||
* @param sessionId 会话ID
|
* @param sessionId Session ID
|
||||||
*/
|
*/
|
||||||
export function getChatHistory(agentId: string, sessionId: string) {
|
export function getChatHistory(agentId: string, sessionId: string) {
|
||||||
return http.Get<ChatMessage[]>(`/agent/${agentId}/chat-history/${sessionId}`, {
|
return http.Get<ChatMessage[]>(`/agent/${agentId}/chat-history/${sessionId}`, {
|
||||||
|
|
@ -41,8 +41,8 @@ export function getChatHistory(agentId: string, sessionId: string) {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取音频下载ID
|
* Get audio download ID
|
||||||
* @param audioId 音频ID
|
* @param audioId Audio ID
|
||||||
*/
|
*/
|
||||||
export function getAudioId(audioId: string) {
|
export function getAudioId(audioId: string) {
|
||||||
return http.Post<string>(`/agent/audio/${audioId}`, {}, {
|
return http.Post<string>(`/agent/audio/${audioId}`, {}, {
|
||||||
|
|
@ -54,10 +54,10 @@ export function getAudioId(audioId: string) {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取音频播放地址
|
* Get audio playback address
|
||||||
* @param downloadId 下载ID
|
* @param downloadId Download ID
|
||||||
*/
|
*/
|
||||||
export function getAudioPlayUrl(downloadId: string) {
|
export function getAudioPlayUrl(downloadId: string) {
|
||||||
// 根据需求文档,这个是直接返回二进制的,所以我们直接构造URL
|
// According to requirements document, this directly returns binary, so we directly construct URL
|
||||||
return `/agent/play/${downloadId}`
|
return `/agent/play/${downloadId}`
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
// 聊天会话列表项
|
// Chat session list item
|
||||||
export interface ChatSession {
|
export interface ChatSession {
|
||||||
sessionId: string
|
sessionId: string
|
||||||
createdAt: string
|
createdAt: string
|
||||||
|
|
@ -6,13 +6,13 @@ export interface ChatSession {
|
||||||
title: string
|
title: string
|
||||||
}
|
}
|
||||||
|
|
||||||
// 聊天会话列表响应
|
// Chat session list response
|
||||||
export interface ChatSessionsResponse {
|
export interface ChatSessionsResponse {
|
||||||
total: number
|
total: number
|
||||||
list: ChatSession[]
|
list: ChatSession[]
|
||||||
}
|
}
|
||||||
|
|
||||||
// 聊天消息
|
// Chat message
|
||||||
export interface ChatMessage {
|
export interface ChatMessage {
|
||||||
createdAt: string
|
createdAt: string
|
||||||
chatType: 1 | 2 | 3 // 1是用户,2是AI,3是参数说明
|
chatType: 1 | 2 | 3 // 1是用户,2是AI,3是参数说明
|
||||||
|
|
@ -21,19 +21,19 @@ export interface ChatMessage {
|
||||||
macAddress: string
|
macAddress: string
|
||||||
}
|
}
|
||||||
|
|
||||||
// 用户消息内容(需要解析JSON)
|
// User message content (needs JSON parsing)
|
||||||
export interface UserMessageContent {
|
export interface UserMessageContent {
|
||||||
speaker: string
|
speaker: string
|
||||||
content: string
|
content: string
|
||||||
}
|
}
|
||||||
|
|
||||||
// 获取聊天会话列表参数
|
// Get chat session list parameters
|
||||||
export interface GetSessionsParams {
|
export interface GetSessionsParams {
|
||||||
page: number
|
page: number
|
||||||
limit: number
|
limit: number
|
||||||
}
|
}
|
||||||
|
|
||||||
// 音频播放相关
|
// Audio playback related
|
||||||
export interface AudioResponse {
|
export interface AudioResponse {
|
||||||
data: string // 音频下载ID
|
data: string // Audio download ID
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2,15 +2,15 @@ import type { Device, FirmwareType } from './types'
|
||||||
import { http } from '@/http/request/alova'
|
import { http } from '@/http/request/alova'
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取设备类型列表
|
* Get device type list
|
||||||
*/
|
*/
|
||||||
export function getFirmwareTypes() {
|
export function getFirmwareTypes() {
|
||||||
return http.Get<FirmwareType[]>('/admin/dict/data/type/FIRMWARE_TYPE')
|
return http.Get<FirmwareType[]>('/admin/dict/data/type/FIRMWARE_TYPE')
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取绑定设备列表
|
* Get bound device list
|
||||||
* @param agentId 智能体ID
|
* @param agentId Agent ID
|
||||||
*/
|
*/
|
||||||
export function getBindDevices(agentId: string) {
|
export function getBindDevices(agentId: string) {
|
||||||
return http.Get<Device[]>(`/device/bind/${agentId}`, {
|
return http.Get<Device[]>(`/device/bind/${agentId}`, {
|
||||||
|
|
@ -25,34 +25,18 @@ export function getBindDevices(agentId: string) {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 添加设备
|
* Add device
|
||||||
* @param agentId 智能体ID
|
* @param agentId Agent ID
|
||||||
* @param code 验证码
|
* @param code Verification code
|
||||||
*/
|
*/
|
||||||
export function bindDevice(agentId: string, code: string) {
|
export function bindDevice(agentId: string, code: string) {
|
||||||
return http.Post(`/device/bind/${agentId}/${code}`, null)
|
return http.Post(`/device/bind/${agentId}/${code}`, null)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 手动添加设备
|
* Set device OTA update switch
|
||||||
* @param agentId 智能体ID
|
* @param deviceId Device ID (MAC address)
|
||||||
* @param board 设备类型
|
* @param autoUpdate Whether to auto update 0|1
|
||||||
* @param appVersion 固件版本
|
|
||||||
* @param macAddress MAC地址
|
|
||||||
*/
|
|
||||||
export function bindDeviceManual(data: {
|
|
||||||
agentId: string
|
|
||||||
board: string
|
|
||||||
appVersion: string
|
|
||||||
macAddress: string
|
|
||||||
}) {
|
|
||||||
return http.Post('/device/manual-add', data)
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 设置设备OTA升级开关
|
|
||||||
* @param deviceId 设备ID (MAC地址)
|
|
||||||
* @param autoUpdate 是否自动升级 0|1
|
|
||||||
*/
|
*/
|
||||||
export function updateDeviceAutoUpdate(deviceId: string, autoUpdate: number) {
|
export function updateDeviceAutoUpdate(deviceId: string, autoUpdate: number) {
|
||||||
return http.Put(`/device/update/${deviceId}`, {
|
return http.Put(`/device/update/${deviceId}`, {
|
||||||
|
|
@ -61,8 +45,8 @@ export function updateDeviceAutoUpdate(deviceId: string, autoUpdate: number) {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 解绑设备
|
* Unbind device
|
||||||
* @param deviceId 设备ID (MAC地址)
|
* @param deviceId Device ID (MAC address)
|
||||||
*/
|
*/
|
||||||
export function unbindDevice(deviceId: string) {
|
export function unbindDevice(deviceId: string) {
|
||||||
return http.Post('/device/unbind', {
|
return http.Post('/device/unbind', {
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
// 声纹信息响应类型
|
// Voiceprint info response type
|
||||||
export interface VoicePrint {
|
export interface VoicePrint {
|
||||||
id: string
|
id: string
|
||||||
audioId: string
|
audioId: string
|
||||||
|
|
@ -7,13 +7,13 @@ export interface VoicePrint {
|
||||||
createDate: string
|
createDate: string
|
||||||
}
|
}
|
||||||
|
|
||||||
// 语音对话记录类型
|
// Voice conversation record type
|
||||||
export interface ChatHistory {
|
export interface ChatHistory {
|
||||||
content: string
|
content: string
|
||||||
audioId: string
|
audioId: string
|
||||||
}
|
}
|
||||||
|
|
||||||
// 创建说话人数据类型
|
// Create speaker data type
|
||||||
export interface CreateSpeakerData {
|
export interface CreateSpeakerData {
|
||||||
agentId: string
|
agentId: string
|
||||||
audioId: string
|
audioId: string
|
||||||
|
|
@ -21,7 +21,7 @@ export interface CreateSpeakerData {
|
||||||
introduce: string
|
introduce: string
|
||||||
}
|
}
|
||||||
|
|
||||||
// 通用响应类型
|
// Generic response type
|
||||||
export interface ApiResponse<T = any> {
|
export interface ApiResponse<T = any> {
|
||||||
code: number
|
code: number
|
||||||
msg: string
|
msg: string
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@ import type {
|
||||||
} from './types'
|
} from './types'
|
||||||
import { http } from '@/http/request/alova'
|
import { http } from '@/http/request/alova'
|
||||||
|
|
||||||
// 获取声纹列表
|
// Get voiceprint list
|
||||||
export function getVoicePrintList(agentId: string) {
|
export function getVoicePrintList(agentId: string) {
|
||||||
return http.Get<VoicePrint[]>(`/agent/voice-print/list/${agentId}`, {
|
return http.Get<VoicePrint[]>(`/agent/voice-print/list/${agentId}`, {
|
||||||
meta: {
|
meta: {
|
||||||
|
|
@ -18,7 +18,7 @@ export function getVoicePrintList(agentId: string) {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// 获取语音对话记录(用于选择声纹向量)
|
// Get voice conversation records (for selecting voiceprint vectors)
|
||||||
export function getChatHistory(agentId: string) {
|
export function getChatHistory(agentId: string) {
|
||||||
return http.Get<ChatHistory[]>(`/agent/${agentId}/chat-history/user`, {
|
return http.Get<ChatHistory[]>(`/agent/${agentId}/chat-history/user`, {
|
||||||
meta: {
|
meta: {
|
||||||
|
|
@ -31,7 +31,7 @@ export function getChatHistory(agentId: string) {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// 新增说话人
|
// Add speaker
|
||||||
export function createVoicePrint(data: CreateSpeakerData) {
|
export function createVoicePrint(data: CreateSpeakerData) {
|
||||||
return http.Post<null>('/agent/voice-print', data, {
|
return http.Post<null>('/agent/voice-print', data, {
|
||||||
meta: {
|
meta: {
|
||||||
|
|
@ -41,7 +41,7 @@ export function createVoicePrint(data: CreateSpeakerData) {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// 删除声纹
|
// Delete voiceprint
|
||||||
export function deleteVoicePrint(id: string) {
|
export function deleteVoicePrint(id: string) {
|
||||||
return http.Delete<null>(`/agent/voice-print/${id}`, {
|
return http.Delete<null>(`/agent/voice-print/${id}`, {
|
||||||
meta: {
|
meta: {
|
||||||
|
|
@ -51,7 +51,7 @@ export function deleteVoicePrint(id: string) {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// 更新声纹信息
|
// Update voiceprint info
|
||||||
export function updateVoicePrint(data: VoicePrint) {
|
export function updateVoicePrint(data: VoicePrint) {
|
||||||
return http.Put<null>('/agent/voice-print', data, {
|
return http.Put<null>('/agent/voice-print', data, {
|
||||||
meta: {
|
meta: {
|
||||||
|
|
@ -60,13 +60,3 @@ export function updateVoicePrint(data: VoicePrint) {
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// 获取音频下载ID
|
|
||||||
export function getAudioDownloadId(audioId: string) {
|
|
||||||
return http.Post<string>(`/agent/audio/${audioId}`, {}, {
|
|
||||||
meta: {
|
|
||||||
ignoreAuth: false,
|
|
||||||
toast: false,
|
|
||||||
},
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
|
||||||
|
|
@ -117,7 +117,7 @@ function handleTabClick(item: TabItem, index: number) {
|
||||||
border-radius: 2rpx;
|
border-radius: 2rpx;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* 适配不同尺寸屏幕 */
|
/* Adapt to different screen sizes */
|
||||||
@media (max-width: 375px) {
|
@media (max-width: 375px) {
|
||||||
.tab-text {
|
.tab-text {
|
||||||
font-size: 22rpx;
|
font-size: 22rpx;
|
||||||
|
|
|
||||||
18
main/manager-mobile/src/env.d.ts
vendored
18
main/manager-mobile/src/env.d.ts
vendored
|
|
@ -9,21 +9,21 @@ declare module '*.vue' {
|
||||||
}
|
}
|
||||||
|
|
||||||
interface ImportMetaEnv {
|
interface ImportMetaEnv {
|
||||||
/** 网站标题,应用名称 */
|
/** Website title, application name */
|
||||||
readonly VITE_APP_TITLE: string
|
readonly VITE_APP_TITLE: string
|
||||||
/** 服务端口号 */
|
/** Service port number */
|
||||||
readonly VITE_SERVER_PORT: string
|
readonly VITE_SERVER_PORT: string
|
||||||
/** 后台接口地址 */
|
/** Backend API address */
|
||||||
readonly VITE_SERVER_BASEURL: string
|
readonly VITE_SERVER_BASEURL: string
|
||||||
/** H5是否需要代理 */
|
/** Whether H5 needs proxy */
|
||||||
readonly VITE_APP_PROXY: 'true' | 'false'
|
readonly VITE_APP_PROXY: 'true' | 'false'
|
||||||
/** H5是否需要代理,需要的话有个前缀 */
|
/** Whether H5 needs proxy, if needed there is a prefix */
|
||||||
readonly VITE_APP_PROXY_PREFIX: string // 一般是/api
|
readonly VITE_APP_PROXY_PREFIX: string // Usually /api
|
||||||
/** 上传图片地址 */
|
/** Upload image address */
|
||||||
readonly VITE_UPLOAD_BASEURL: string
|
readonly VITE_UPLOAD_BASEURL: string
|
||||||
/** 是否清除console */
|
/** Whether to clear console */
|
||||||
readonly VITE_DELETE_CONSOLE: string
|
readonly VITE_DELETE_CONSOLE: string
|
||||||
// 更多环境变量...
|
// More environment variables...
|
||||||
}
|
}
|
||||||
|
|
||||||
interface ImportMeta {
|
interface ImportMeta {
|
||||||
|
|
|
||||||
|
|
@ -8,15 +8,15 @@ function isLogined() {
|
||||||
const userStore = useUserStore()
|
const userStore = useUserStore()
|
||||||
return !!userStore.userInfo.username
|
return !!userStore.userInfo.username
|
||||||
}
|
}
|
||||||
// 检查当前页面是否需要登录
|
// Check if current page requires login
|
||||||
export function usePageAuth() {
|
export function usePageAuth() {
|
||||||
onLoad((options) => {
|
onLoad((options) => {
|
||||||
// 获取当前页面路径
|
// Get current page path
|
||||||
const pages = getCurrentPages()
|
const pages = getCurrentPages()
|
||||||
const currentPage = pages[pages.length - 1]
|
const currentPage = pages[pages.length - 1]
|
||||||
const currentPath = `/${currentPage.route}`
|
const currentPath = `/${currentPage.route}`
|
||||||
|
|
||||||
// 获取需要登录的页面列表
|
// Get list of pages that require login
|
||||||
let needLoginPages: string[] = []
|
let needLoginPages: string[] = []
|
||||||
if (isDev) {
|
if (isDev) {
|
||||||
needLoginPages = getNeedLoginPages()
|
needLoginPages = getNeedLoginPages()
|
||||||
|
|
@ -25,7 +25,7 @@ export function usePageAuth() {
|
||||||
needLoginPages = _needLoginPages
|
needLoginPages = _needLoginPages
|
||||||
}
|
}
|
||||||
|
|
||||||
// 检查当前页面是否需要登录
|
// Check if current page requires login
|
||||||
const isNeedLogin = needLoginPages.includes(currentPath)
|
const isNeedLogin = needLoginPages.includes(currentPath)
|
||||||
if (!isNeedLogin) {
|
if (!isNeedLogin) {
|
||||||
return
|
return
|
||||||
|
|
@ -36,7 +36,7 @@ export function usePageAuth() {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
// 构建重定向URL
|
// Build redirect URL
|
||||||
const queryString = Object.entries(options || {})
|
const queryString = Object.entries(options || {})
|
||||||
.map(([key, value]) => `${key}=${encodeURIComponent(String(value))}`)
|
.map(([key, value]) => `${key}=${encodeURIComponent(String(value))}`)
|
||||||
.join('&')
|
.join('&')
|
||||||
|
|
@ -44,7 +44,7 @@ export function usePageAuth() {
|
||||||
const currentFullPath = queryString ? `${currentPath}?${queryString}` : currentPath
|
const currentFullPath = queryString ? `${currentPath}?${queryString}` : currentPath
|
||||||
const redirectRoute = `${loginRoute}?redirect=${encodeURIComponent(currentFullPath)}`
|
const redirectRoute = `${loginRoute}?redirect=${encodeURIComponent(currentFullPath)}`
|
||||||
|
|
||||||
// 重定向到登录页
|
// Redirect to login page
|
||||||
uni.redirectTo({ url: redirectRoute })
|
uni.redirectTo({ url: redirectRoute })
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,9 @@
|
||||||
import type { Ref } from 'vue'
|
import type { Ref } from 'vue'
|
||||||
|
|
||||||
interface IUseRequestOptions<T> {
|
interface IUseRequestOptions<T> {
|
||||||
/** 是否立即执行 */
|
/** Whether to execute immediately */
|
||||||
immediate?: boolean
|
immediate?: boolean
|
||||||
/** 初始化数据 */
|
/** Initial data */
|
||||||
initialData?: T
|
initialData?: T
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -15,12 +15,12 @@ interface IUseRequestReturn<T> {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* useRequest是一个定制化的请求钩子,用于处理异步请求和响应。
|
* useRequest is a customized request hook for handling async requests and responses.
|
||||||
* @param func 一个执行异步请求的函数,返回一个包含响应数据的Promise。
|
* @param func A function that executes async requests, returns a Promise containing response data.
|
||||||
* @param options 包含请求选项的对象 {immediate, initialData}。
|
* @param options Object containing request options {immediate, initialData}.
|
||||||
* @param options.immediate 是否立即执行请求,默认为false。
|
* @param options.immediate Whether to execute request immediately, defaults to false.
|
||||||
* @param options.initialData 初始化数据,默认为undefined。
|
* @param options.initialData Initial data, defaults to undefined.
|
||||||
* @returns 返回一个对象{loading, error, data, run},包含请求的加载状态、错误信息、响应数据和手动触发请求的函数。
|
* @returns Returns an object {loading, error, data, run}, containing request loading status, error info, response data and manual trigger function.
|
||||||
*/
|
*/
|
||||||
export default function useRequest<T>(
|
export default function useRequest<T>(
|
||||||
func: () => Promise<IResData<T>>,
|
func: () => Promise<IResData<T>>,
|
||||||
|
|
|
||||||
|
|
@ -33,7 +33,7 @@ export default function useUpload<T extends TfileType>(options: TOptions<T> = {}
|
||||||
const handleFileChoose = ({ tempFilePath, size }: { tempFilePath: string, size: number }) => {
|
const handleFileChoose = ({ tempFilePath, size }: { tempFilePath: string, size: number }) => {
|
||||||
if (size > maxSize) {
|
if (size > maxSize) {
|
||||||
uni.showToast({
|
uni.showToast({
|
||||||
title: `文件大小不能超过 ${maxSize / 1024 / 1024}MB`,
|
title: `File size cannot exceed ${maxSize / 1024 / 1024}MB`,
|
||||||
icon: 'none',
|
icon: 'none',
|
||||||
})
|
})
|
||||||
return
|
return
|
||||||
|
|
@ -44,7 +44,7 @@ export default function useUpload<T extends TfileType>(options: TOptions<T> = {}
|
||||||
|
|
||||||
// if (!isTypeValid) {
|
// if (!isTypeValid) {
|
||||||
// uni.showToast({
|
// uni.showToast({
|
||||||
// title: `仅支持 ${accept.join(', ')} 格式的文件`,
|
// title: `Only supports ${accept.join(', ')} format files`,
|
||||||
// icon: 'none',
|
// icon: 'none',
|
||||||
// })
|
// })
|
||||||
// return
|
// return
|
||||||
|
|
@ -57,7 +57,7 @@ export default function useUpload<T extends TfileType>(options: TOptions<T> = {}
|
||||||
onSuccess: (res) => {
|
onSuccess: (res) => {
|
||||||
const { data: _data } = JSON.parse(res)
|
const { data: _data } = JSON.parse(res)
|
||||||
data.value = _data
|
data.value = _data
|
||||||
// console.log('上传成功', res)
|
// console.log('Upload successful', res)
|
||||||
success?.(_data)
|
success?.(_data)
|
||||||
},
|
},
|
||||||
onError: (err) => {
|
onError: (err) => {
|
||||||
|
|
@ -71,17 +71,17 @@ export default function useUpload<T extends TfileType>(options: TOptions<T> = {}
|
||||||
}
|
}
|
||||||
|
|
||||||
const run = () => {
|
const run = () => {
|
||||||
// 微信小程序从基础库 2.21.0 开始, wx.chooseImage 停止维护,请使用 uni.chooseMedia 代替。
|
// WeChat Mini Program from base library 2.21.0, wx.chooseImage is no longer maintained, please use uni.chooseMedia instead.
|
||||||
// 微信小程序在2023年10月17日之后,使用本API需要配置隐私协议
|
// WeChat Mini Program after October 17, 2023, using this API requires privacy protocol configuration
|
||||||
const chooseFileOptions = {
|
const chooseFileOptions = {
|
||||||
count: 1,
|
count: 1,
|
||||||
success: (res: any) => {
|
success: (res: any) => {
|
||||||
console.log('File selected successfully:', res)
|
console.log('File selected successfully:', res)
|
||||||
// 小程序中res:{errMsg: "chooseImage:ok", tempFiles: [{fileType: "image", size: 48976, tempFilePath: "http://tmp/5iG1WpIxTaJf3ece38692a337dc06df7eb69ecb49c6b.jpeg"}]}
|
// Mini program res:{errMsg: "chooseImage:ok", tempFiles: [{fileType: "image", size: 48976, tempFilePath: "http://tmp/5iG1WpIxTaJf3ece38692a337dc06df7eb69ecb49c6b.jpeg"}]}
|
||||||
// h5中res:{errMsg: "chooseImage:ok", tempFilePaths: "blob:http://localhost:9000/f74ab6b8-a14d-4cb6-a10d-fcf4511a0de5", tempFiles: [File]}
|
// h5 res:{errMsg: "chooseImage:ok", tempFilePaths: "blob:http://localhost:9000/f74ab6b8-a14d-4cb6-a10d-fcf4511a0de5", tempFiles: [File]}
|
||||||
// h5的File有以下字段:{name: "girl.jpeg", size: 48976, type: "image/jpeg"}
|
// h5 File has the following fields: {name: "girl.jpeg", size: 48976, type: "image/jpeg"}
|
||||||
// App中res:{errMsg: "chooseImage:ok", tempFilePaths: "file:///Users/feige/xxx/gallery/1522437259-compressed-IMG_0006.jpg", tempFiles: [File]}
|
// App res:{errMsg: "chooseImage:ok", tempFilePaths: "file:///Users/feige/xxx/gallery/1522437259-compressed-IMG_0006.jpg", tempFiles: [File]}
|
||||||
// App的File有以下字段:{path: "file:///Users/feige/xxx/gallery/1522437259-compressed-IMG_0006.jpg", size: 48976}
|
// App's File has the following fields: {path: "file:///Users/feige/xxx/gallery/1522437259-compressed-IMG_0006.jpg", size: 48976}
|
||||||
let tempFilePath = ''
|
let tempFilePath = ''
|
||||||
let size = 0
|
let size = 0
|
||||||
// #ifdef MP-WEIXIN
|
// #ifdef MP-WEIXIN
|
||||||
|
|
|
||||||
|
|
@ -1,34 +1,34 @@
|
||||||
# 请求库
|
# Request Library
|
||||||
|
|
||||||
当前项目使用 Alova 作为唯一的 HTTP 请求库:
|
The current project uses Alova as the only HTTP request library:
|
||||||
|
|
||||||
## 使用方式
|
## Usage
|
||||||
|
|
||||||
- **Alova HTTP**:路径(src/http/request/alova.ts)
|
- **Alova HTTP**: Path (src/http/request/alova.ts)
|
||||||
- **示例代码**:src/api/foo-alova.ts 和 src/api/foo.ts
|
- **Example code**: src/api/foo-alova.ts and src/api/foo.ts
|
||||||
- **API文档**:https://alova.js.org/
|
- **API documentation**: https://alova.js.org/
|
||||||
|
|
||||||
## 配置说明
|
## Configuration
|
||||||
|
|
||||||
Alova 实例已配置:
|
Alova instance is configured:
|
||||||
- 自动 Token 认证和刷新
|
- Automatic Token authentication and refresh
|
||||||
- 统一错误处理和提示
|
- Unified error handling and prompts
|
||||||
- 支持动态域名切换
|
- Support dynamic domain switching
|
||||||
- 内置请求/响应拦截器
|
- Built-in request/response interceptors
|
||||||
|
|
||||||
## 使用示例
|
## Usage Examples
|
||||||
|
|
||||||
```typescript
|
```typescript
|
||||||
import { http } from '@/http/request/alova'
|
import { http } from '@/http/request/alova'
|
||||||
|
|
||||||
// GET 请求
|
// GET request
|
||||||
http.Get<ResponseType>('/api/path', {
|
http.Get<ResponseType>('/api/path', {
|
||||||
params: { id: 1 },
|
params: { id: 1 },
|
||||||
headers: { 'Custom-Header': 'value' },
|
headers: { 'Custom-Header': 'value' },
|
||||||
meta: { toast: false } // 关闭错误提示
|
meta: { toast: false } // Disable error prompts
|
||||||
})
|
})
|
||||||
|
|
||||||
// POST 请求
|
// POST request
|
||||||
http.Post<ResponseType>('/api/path', data, {
|
http.Post<ResponseType>('/api/path', data, {
|
||||||
params: { query: 'param' },
|
params: { query: 'param' },
|
||||||
headers: { 'Content-Type': 'application/json' }
|
headers: { 'Content-Type': 'application/json' }
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,5 @@
|
||||||
import type { uniappRequestAdapter } from '@alova/adapter-uniapp'
|
import type { uniappRequestAdapter } from '@alova/adapter-uniapp'
|
||||||
import type { IResponse } from './types'
|
import type { IResponse } from './types'
|
||||||
import type { Language } from '@/store/lang'
|
|
||||||
import AdapterUniapp from '@alova/adapter-uniapp'
|
import AdapterUniapp from '@alova/adapter-uniapp'
|
||||||
import { createAlova } from 'alova'
|
import { createAlova } from 'alova'
|
||||||
import { createServerTokenAuthentication } from 'alova/client'
|
import { createServerTokenAuthentication } from 'alova/client'
|
||||||
|
|
@ -9,18 +8,8 @@ import { getEnvBaseUrl } from '@/utils'
|
||||||
import { toast } from '@/utils/toast'
|
import { toast } from '@/utils/toast'
|
||||||
import { ContentTypeEnum, ResultEnum, ShowMessage } from './enum'
|
import { ContentTypeEnum, ResultEnum, ShowMessage } from './enum'
|
||||||
|
|
||||||
// 语言映射, 用于设置 Accept-language 头
|
|
||||||
const langMap: Record<Language, string> = {
|
|
||||||
zh_CN: 'zh-CN',
|
|
||||||
en: 'en-US',
|
|
||||||
zh_TW: 'zh-TW',
|
|
||||||
de: 'de',
|
|
||||||
vi: 'vi',
|
|
||||||
pt_BR: 'pt-BR',
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 创建请求实例
|
* Create request instance
|
||||||
*/
|
*/
|
||||||
const { onAuthRequired, onResponseRefreshToken } = createServerTokenAuthentication<
|
const { onAuthRequired, onResponseRefreshToken } = createServerTokenAuthentication<
|
||||||
typeof VueHook,
|
typeof VueHook,
|
||||||
|
|
@ -35,7 +24,7 @@ const { onAuthRequired, onResponseRefreshToken } = createServerTokenAuthenticati
|
||||||
// await authLogin();
|
// await authLogin();
|
||||||
}
|
}
|
||||||
catch (error) {
|
catch (error) {
|
||||||
// 切换到登录页
|
// Switch to login page
|
||||||
await uni.reLaunch({ url: '/pages/login/index' })
|
await uni.reLaunch({ url: '/pages/login/index' })
|
||||||
throw error
|
throw error
|
||||||
}
|
}
|
||||||
|
|
@ -44,7 +33,7 @@ const { onAuthRequired, onResponseRefreshToken } = createServerTokenAuthenticati
|
||||||
})
|
})
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* alova 请求实例
|
* Alova request instance
|
||||||
*/
|
*/
|
||||||
const alovaInstance = createAlova({
|
const alovaInstance = createAlova({
|
||||||
baseURL: getEnvBaseUrl(),
|
baseURL: getEnvBaseUrl(),
|
||||||
|
|
@ -53,26 +42,10 @@ const alovaInstance = createAlova({
|
||||||
statesHook: VueHook,
|
statesHook: VueHook,
|
||||||
|
|
||||||
beforeRequest: onAuthRequired((method) => {
|
beforeRequest: onAuthRequired((method) => {
|
||||||
// h5动态获取最新的 baseURL,确保使用用户设置的服务器地址
|
// Set default Content-Type
|
||||||
const currentBaseUrl = getEnvBaseUrl()
|
|
||||||
if (currentBaseUrl !== method.baseURL) {
|
|
||||||
method.baseURL = currentBaseUrl
|
|
||||||
}
|
|
||||||
|
|
||||||
// 检查混合内容错误(HTTPS页面请求HTTP接口)
|
|
||||||
const currentProtocol = typeof window !== 'undefined' && window.location.protocol
|
|
||||||
const requestProtocol = method.baseURL?.split(':')[0]
|
|
||||||
const currentLang = langMap[uni.getStorageSync('app_language') as Language || 'zh_CN']
|
|
||||||
if (currentProtocol === 'https:' && requestProtocol === 'http') {
|
|
||||||
const errorMessage = '无法配置http协议地址,请检查接口地址'
|
|
||||||
throw new Error(errorMessage)
|
|
||||||
}
|
|
||||||
|
|
||||||
// 设置默认 Content-Type
|
|
||||||
method.config.headers = {
|
method.config.headers = {
|
||||||
'Content-Type': ContentTypeEnum.JSON,
|
'Content-Type': ContentTypeEnum.JSON,
|
||||||
'Accept': 'application/json, text/plain, */*',
|
'Accept': 'application/json, text/plain, */*',
|
||||||
'Accept-language': currentLang,
|
|
||||||
...method.config.headers,
|
...method.config.headers,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -80,22 +53,22 @@ const alovaInstance = createAlova({
|
||||||
const ignoreAuth = config.meta?.ignoreAuth
|
const ignoreAuth = config.meta?.ignoreAuth
|
||||||
console.log('ignoreAuth===>', ignoreAuth)
|
console.log('ignoreAuth===>', ignoreAuth)
|
||||||
|
|
||||||
// 处理认证信息
|
// Handle authentication info
|
||||||
if (!ignoreAuth) {
|
if (!ignoreAuth) {
|
||||||
const authInfo = JSON.parse(uni.getStorageSync('token') || '{}')
|
const token = uni.getStorageSync('token')
|
||||||
if (!authInfo.token) {
|
if (!token) {
|
||||||
// 跳转到登录页
|
// Jump to login page
|
||||||
uni.reLaunch({ url: '/pages/login/index' })
|
uni.reLaunch({ url: '/pages/login/index' })
|
||||||
throw new Error('[请求错误]:未登录')
|
throw new Error('[Request Error]: Not logged in')
|
||||||
}
|
}
|
||||||
// 添加 Authorization 头
|
// Add Authorization header
|
||||||
method.config.headers.Authorization = `Bearer ${authInfo.token}`
|
method.config.headers.Authorization = `Bearer ${token}`
|
||||||
}
|
}
|
||||||
|
|
||||||
// 处理动态域名
|
// Handle dynamic domain
|
||||||
if (config.meta?.domain) {
|
if (config.meta?.domain) {
|
||||||
method.baseURL = config.meta.domain
|
method.baseURL = config.meta.domain
|
||||||
console.log('当前域名', method.baseURL)
|
console.log('Current domain', method.baseURL)
|
||||||
}
|
}
|
||||||
}),
|
}),
|
||||||
|
|
||||||
|
|
@ -110,40 +83,36 @@ const alovaInstance = createAlova({
|
||||||
|
|
||||||
console.log(response)
|
console.log(response)
|
||||||
|
|
||||||
// 处理特殊请求类型(上传/下载)
|
// Handle special request types (upload/download)
|
||||||
if (requestType === 'upload' || requestType === 'download') {
|
if (requestType === 'upload' || requestType === 'download') {
|
||||||
return response
|
return response
|
||||||
}
|
}
|
||||||
|
|
||||||
// 处理 HTTP 状态码错误
|
// Handle HTTP status code errors
|
||||||
if (statusCode !== 200) {
|
if (statusCode !== 200) {
|
||||||
const errorMessage = ShowMessage(statusCode) || `HTTP请求错误[${statusCode}]`
|
const errorMessage = ShowMessage(statusCode) || `HTTP request error[${statusCode}]`
|
||||||
console.error('errorMessage===>', errorMessage)
|
console.error('errorMessage===>', errorMessage)
|
||||||
toast.error(errorMessage)
|
toast.error(errorMessage)
|
||||||
throw new Error(`${errorMessage}:${errMsg}`)
|
throw new Error(`${errorMessage}:${errMsg}`)
|
||||||
}
|
}
|
||||||
|
|
||||||
// 处理业务逻辑错误
|
// Handle business logic errors
|
||||||
const { code, msg, data } = rawData as IResponse
|
const { code, msg, data } = rawData as IResponse
|
||||||
if (code !== ResultEnum.Success) {
|
if (code !== ResultEnum.Success) {
|
||||||
// 检查是否为token失效
|
// Check if token is invalid
|
||||||
if (code === ResultEnum.Unauthorized) {
|
if (code === ResultEnum.Unauthorized) {
|
||||||
// 清除token并跳转到登录页
|
// Clear token and redirect to login page
|
||||||
uni.removeStorageSync('token')
|
uni.removeStorageSync('token')
|
||||||
uni.reLaunch({ url: '/pages/login/index' })
|
uni.reLaunch({ url: '/pages/login/index' })
|
||||||
throw new Error(`请求错误[${code}]:${msg}`)
|
throw new Error(`Request error[${code}]: ${msg}`)
|
||||||
}
|
|
||||||
|
|
||||||
if (config.meta?.isExposeError) {
|
|
||||||
return Promise.reject(msg)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (config.meta?.toast !== false) {
|
if (config.meta?.toast !== false) {
|
||||||
toast.warning(msg)
|
toast.warning(msg)
|
||||||
}
|
}
|
||||||
throw new Error(`请求错误[${code}]:${msg}`)
|
throw new Error(`Request error[${code}]: ${msg}`)
|
||||||
}
|
}
|
||||||
// 处理成功响应,返回业务数据
|
// Handle successful response, return business data
|
||||||
return data
|
return data
|
||||||
}),
|
}),
|
||||||
})
|
})
|
||||||
|
|
|
||||||
|
|
@ -1,18 +1,17 @@
|
||||||
export enum ResultEnum {
|
export enum ResultEnum {
|
||||||
Success = 0, // 成功
|
Success = 0, // Success
|
||||||
Error = 400, // 错误
|
Error = 400, // Error
|
||||||
Unauthorized = 401, // 未授权
|
Unauthorized = 401, // Unauthorized
|
||||||
Forbidden = 403, // 禁止访问(原为forbidden)
|
Forbidden = 403, // Forbidden access (originally forbidden)
|
||||||
NotFound = 404, // 未找到(原为notFound)
|
NotFound = 404, // Not found (originally notFound)
|
||||||
MethodNotAllowed = 405, // 方法不允许(原为methodNotAllowed)
|
MethodNotAllowed = 405, // Method not allowed (originally methodNotAllowed)
|
||||||
RequestTimeout = 408, // 请求超时(原为requestTimeout)
|
RequestTimeout = 408, // Request timeout (originally requestTimeout)
|
||||||
InternalServerError = 500, // 服务器错误(原为internalServerError)
|
InternalServerError = 500, // Server error (originally internalServerError)
|
||||||
NotImplemented = 501, // 未实现(原为notImplemented)
|
NotImplemented = 501, // Not implemented (originally notImplemented)
|
||||||
BadGateway = 502, // 网关错误(原为badGateway)
|
BadGateway = 502, // Gateway error (originally badGateway)
|
||||||
ServiceUnavailable = 503, // 服务不可用(原为serviceUnavailable)
|
ServiceUnavailable = 503, // Service unavailable (originally serviceUnavailable)
|
||||||
GatewayTimeout = 504, // 网关超时(原为gatewayTimeout)
|
GatewayTimeout = 504, // Gateway timeout (originally gatewayTimeout)
|
||||||
HttpVersionNotSupported = 505, // HTTP版本不支持(原为httpVersionNotSupported)
|
HttpVersionNotSupported = 505, // HTTP version not supported (originally httpVersionNotSupported)
|
||||||
MixedContent = 600, // 混合内容错误(HTTPS页面请求HTTP接口)
|
|
||||||
}
|
}
|
||||||
export enum ContentTypeEnum {
|
export enum ContentTypeEnum {
|
||||||
JSON = 'application/json;charset=UTF-8',
|
JSON = 'application/json;charset=UTF-8',
|
||||||
|
|
@ -20,51 +19,48 @@ export enum ContentTypeEnum {
|
||||||
FORM_DATA = 'multipart/form-data;charset=UTF-8',
|
FORM_DATA = 'multipart/form-data;charset=UTF-8',
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* 根据状态码,生成对应的错误信息
|
* Generate corresponding error message based on status code
|
||||||
* @param {number|string} status 状态码
|
* @param {number|string} status Status code
|
||||||
* @returns {string} 错误信息
|
* @returns {string} Error message
|
||||||
*/
|
*/
|
||||||
export function ShowMessage(status: number | string): string {
|
export function ShowMessage(status: number | string): string {
|
||||||
let message: string
|
let message: string
|
||||||
switch (status) {
|
switch (status) {
|
||||||
case 400:
|
case 400:
|
||||||
message = '请求错误(400)'
|
message = 'Request error (400)'
|
||||||
break
|
break
|
||||||
case 401:
|
case 401:
|
||||||
message = '未授权,请重新登录(401)'
|
message = 'Unauthorized, please login again (401)'
|
||||||
break
|
break
|
||||||
case 403:
|
case 403:
|
||||||
message = '拒绝访问(403)'
|
message = 'Access denied (403)'
|
||||||
break
|
break
|
||||||
case 404:
|
case 404:
|
||||||
message = '请求出错(404)'
|
message = 'Request error (404)'
|
||||||
break
|
break
|
||||||
case 408:
|
case 408:
|
||||||
message = '请求超时(408)'
|
message = 'Request timeout (408)'
|
||||||
break
|
break
|
||||||
case 500:
|
case 500:
|
||||||
message = '服务器错误(500)'
|
message = 'Server error (500)'
|
||||||
break
|
break
|
||||||
case 501:
|
case 501:
|
||||||
message = '服务未实现(501)'
|
message = 'Service not implemented (501)'
|
||||||
break
|
break
|
||||||
case 502:
|
case 502:
|
||||||
message = '网络错误(502)'
|
message = 'Network error (502)'
|
||||||
break
|
break
|
||||||
case 503:
|
case 503:
|
||||||
message = '服务不可用(503)'
|
message = 'Service unavailable (503)'
|
||||||
break
|
break
|
||||||
case 504:
|
case 504:
|
||||||
message = '网络超时(504)'
|
message = 'Network timeout (504)'
|
||||||
break
|
break
|
||||||
case 505:
|
case 505:
|
||||||
message = 'HTTP版本不受支持(505)'
|
message = 'HTTP version not supported (505)'
|
||||||
break
|
|
||||||
case 600:
|
|
||||||
message = '混合内容错误(600)'
|
|
||||||
break
|
break
|
||||||
default:
|
default:
|
||||||
message = `连接出错(${status})!`
|
message = `Connection error (${status})!`
|
||||||
}
|
}
|
||||||
return `${message},请检查网络或联系管理员!`
|
return `${message}, please check network or contact administrator!`
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
// 通用响应格式
|
// Common response format
|
||||||
export interface IResponse<T = any> {
|
export interface IResponse<T = any> {
|
||||||
code: number | string
|
code: number | string
|
||||||
data: T
|
data: T
|
||||||
|
|
@ -6,14 +6,14 @@ export interface IResponse<T = any> {
|
||||||
status: string | number
|
status: string | number
|
||||||
}
|
}
|
||||||
|
|
||||||
// 分页请求参数
|
// Pagination request parameters
|
||||||
export interface PageParams {
|
export interface PageParams {
|
||||||
page: number
|
page: number
|
||||||
pageSize: number
|
pageSize: number
|
||||||
[key: string]: any
|
[key: string]: any
|
||||||
}
|
}
|
||||||
|
|
||||||
// 分页响应数据
|
// Pagination response data
|
||||||
export interface PageResult<T> {
|
export interface PageResult<T> {
|
||||||
list: T[]
|
list: T[]
|
||||||
total: number
|
total: number
|
||||||
|
|
|
||||||
|
|
@ -2,49 +2,45 @@ import { ref } from 'vue'
|
||||||
import { useLangStore } from '@/store/lang'
|
import { useLangStore } from '@/store/lang'
|
||||||
import type { Language } from '@/store/lang'
|
import type { Language } from '@/store/lang'
|
||||||
|
|
||||||
// 导入各个语言的翻译文件
|
// Import translation files
|
||||||
import zh_CN from './zh_CN'
|
|
||||||
import en from './en'
|
import en from './en'
|
||||||
import zh_TW from './zh_TW'
|
|
||||||
import de from './de'
|
import de from './de'
|
||||||
import vi from './vi'
|
import vi from './vi'
|
||||||
import pt_BR from './pt_BR'
|
import pt_BR from './pt_BR'
|
||||||
|
|
||||||
// 语言包映射
|
// Language pack mapping
|
||||||
const messages = {
|
const messages = {
|
||||||
zh_CN: zh_CN,
|
|
||||||
en,
|
en,
|
||||||
zh_TW: zh_TW,
|
|
||||||
de,
|
de,
|
||||||
vi,
|
vi,
|
||||||
pt_BR: pt_BR,
|
pt_BR,
|
||||||
}
|
}
|
||||||
|
|
||||||
// 当前使用的语言
|
// Current language
|
||||||
const currentLang = ref<Language>('zh_CN')
|
const currentLang = ref<Language>('en')
|
||||||
|
|
||||||
// 初始化语言
|
// Initialize language
|
||||||
export function initI18n() {
|
export function initI18n() {
|
||||||
const langStore = useLangStore()
|
const langStore = useLangStore()
|
||||||
currentLang.value = langStore.currentLang
|
currentLang.value = langStore.currentLang
|
||||||
}
|
}
|
||||||
|
|
||||||
// 切换语言
|
// Switch language
|
||||||
export function changeLanguage(lang: Language) {
|
export function changeLanguage(lang: Language) {
|
||||||
currentLang.value = lang
|
currentLang.value = lang
|
||||||
const langStore = useLangStore()
|
const langStore = useLangStore()
|
||||||
langStore.changeLang(lang)
|
langStore.changeLang(lang)
|
||||||
}
|
}
|
||||||
|
|
||||||
// 获取翻译文本
|
// Get translated text
|
||||||
export function t(key: string, params?: Record<string, string | number>): string {
|
export function t(key: string, params?: Record<string, string | number>): string {
|
||||||
const langMessages = messages[currentLang.value]
|
const langMessages = messages[currentLang.value]
|
||||||
|
|
||||||
// 直接查找扁平键名
|
// Direct lookup for flat keys
|
||||||
if (langMessages && typeof langMessages === 'object' && key in langMessages) {
|
if (langMessages && typeof langMessages === 'object' && key in langMessages) {
|
||||||
let value = langMessages[key]
|
let value = langMessages[key]
|
||||||
if (typeof value === 'string') {
|
if (typeof value === 'string') {
|
||||||
// 处理参数替换
|
// Apply parameter replacements
|
||||||
if (params) {
|
if (params) {
|
||||||
let result = value
|
let result = value
|
||||||
Object.entries(params).forEach(([paramKey, paramValue]) => {
|
Object.entries(params).forEach(([paramKey, paramValue]) => {
|
||||||
|
|
@ -58,20 +54,18 @@ export function t(key: string, params?: Record<string, string | number>): string
|
||||||
return key
|
return key
|
||||||
}
|
}
|
||||||
|
|
||||||
return key // 如果找不到对应的翻译,返回key本身
|
return key // Return key if translation is missing
|
||||||
}
|
}
|
||||||
|
|
||||||
// 获取当前语言
|
// Get current language
|
||||||
export function getCurrentLanguage(): Language {
|
export function getCurrentLanguage(): Language {
|
||||||
return currentLang.value
|
return currentLang.value
|
||||||
}
|
}
|
||||||
|
|
||||||
// 获取支持的语言列表
|
// Get supported languages
|
||||||
export function getSupportedLanguages(): { code: Language, name: string }[] {
|
export function getSupportedLanguages(): { code: Language, name: string }[] {
|
||||||
return [
|
return [
|
||||||
{ code: 'zh_CN', name: '简体中文' },
|
|
||||||
{ code: 'en', name: 'English' },
|
{ code: 'en', name: 'English' },
|
||||||
{ code: 'zh_TW', name: '繁體中文' },
|
|
||||||
{ code: 'de', name: 'Deutsch' },
|
{ code: 'de', name: 'Deutsch' },
|
||||||
{ code: 'vi', name: 'Tiếng Việt' },
|
{ code: 'vi', name: 'Tiếng Việt' },
|
||||||
{ code: 'pt_BR', name: 'Português (Brasil)' },
|
{ code: 'pt_BR', name: 'Português (Brasil)' },
|
||||||
|
|
|
||||||
|
|
@ -1,503 +0,0 @@
|
||||||
// 简体中文语言包
|
|
||||||
export default {
|
|
||||||
// TabBar
|
|
||||||
'tabBar.home': '首页',
|
|
||||||
'tabBar.deviceConfig': '配网',
|
|
||||||
'tabBar.settings': '系统',
|
|
||||||
// 设置页面标题
|
|
||||||
'settings.title': '设置',
|
|
||||||
// 登录页面
|
|
||||||
'login.pageTitle': '登录',
|
|
||||||
'login.navigationTitle': '登录',
|
|
||||||
'login.fetchConfigError': '获取配置失败:',
|
|
||||||
'login.selectLanguage': '选择语言',
|
|
||||||
'login.selectLanguageTip': '中文',
|
|
||||||
'login.welcomeBack': '欢迎回来',
|
|
||||||
'login.pleaseLogin': '请登录您的账户',
|
|
||||||
'login.enterUsername': '请输入用户名',
|
|
||||||
'login.enterPassword': '请输入密码',
|
|
||||||
'login.enterCaptcha': '请输入验证码',
|
|
||||||
'login.loginButton': '登录',
|
|
||||||
'login.loggingIn': '登录中...',
|
|
||||||
'login.noAccount': '新用户注册',
|
|
||||||
'login.enterPhone': '请输入手机号码',
|
|
||||||
'login.selectCountry': '选择国家/地区',
|
|
||||||
'login.confirm': '确认',
|
|
||||||
'login.serverSetting': '服务端设置',
|
|
||||||
'login.requiredUsername': '用户名不能为空',
|
|
||||||
'login.requiredPassword': '密码不能为空',
|
|
||||||
'login.requiredCaptcha': '验证码不能为空',
|
|
||||||
'login.requiredMobile': '请输入正确的手机号码',
|
|
||||||
'login.captchaError': '图形验证码错误',
|
|
||||||
'login.forgotPassword': '忘记密码',
|
|
||||||
'login.userAgreement': '用户协议',
|
|
||||||
'login.privacyPolicy': '隐私政策',
|
|
||||||
|
|
||||||
// 注册页面
|
|
||||||
'register.pageTitle': '注册',
|
|
||||||
'register.createAccount': '创建账户',
|
|
||||||
'register.enterUsername': '请输入用户名',
|
|
||||||
'register.enterPassword': '请输入密码',
|
|
||||||
'register.confirmPassword': '请确认密码',
|
|
||||||
'register.enterPhone': '请输入手机号码',
|
|
||||||
'register.enterCode': '请输入验证码',
|
|
||||||
'register.getCode': '获取验证码',
|
|
||||||
'register.agreeTerms': '我已阅读并同意',
|
|
||||||
'register.terms': '《用户协议》',
|
|
||||||
'register.privacy': '《隐私政策》',
|
|
||||||
'register.registerButton': '注册',
|
|
||||||
'register.registering': '注册中...',
|
|
||||||
'register.haveAccount': '已有账户?',
|
|
||||||
'register.loginNow': '立即登录',
|
|
||||||
'register.selectCountry': '选择国家/地区',
|
|
||||||
'register.confirm': '确认',
|
|
||||||
'register.captchaSendSuccess': '验证码发送成功',
|
|
||||||
|
|
||||||
// 首页
|
|
||||||
'home.pageTitle': '首页',
|
|
||||||
'home.createAgent': '创建智能体',
|
|
||||||
'home.agentName': '智能体',
|
|
||||||
'home.modelInfo': '模型信息',
|
|
||||||
'home.lastActive': '最近活跃',
|
|
||||||
'home.greeting': '你好,小智',
|
|
||||||
'home.subtitle': '让我们度过',
|
|
||||||
'home.wonderfulDay': '美好的一天!',
|
|
||||||
'home.emptyState': '暂无智能体',
|
|
||||||
'home.deviceManagement': '设备管理',
|
|
||||||
'home.lastConversation': '最近对话:',
|
|
||||||
'home.delete': '删除',
|
|
||||||
'home.createFirstAgent': '点击右下角 + 号创建您的第一个智能体',
|
|
||||||
'home.dialogTitle': '创建智能体',
|
|
||||||
'home.inputPlaceholder': '例如:客服助手、语音助理、知识问答',
|
|
||||||
'home.createError': '名称长度必须在 1 到 64 个字符之间',
|
|
||||||
'home.createNow': '立即创建',
|
|
||||||
'home.justNow': '刚刚',
|
|
||||||
'home.minutesAgo': '分钟前',
|
|
||||||
'home.hoursAgo': '小时前',
|
|
||||||
'home.daysAgo': '天前',
|
|
||||||
'home.languageModel': '语言模型',
|
|
||||||
'home.voiceModel': '音色模型',
|
|
||||||
|
|
||||||
// Agent页面
|
|
||||||
'agent.pageTitle': '智能体',
|
|
||||||
'agent.roleConfig': '角色配置',
|
|
||||||
'agent.deviceManagement': '设备管理',
|
|
||||||
'agent.chatHistory': '聊天记录',
|
|
||||||
'agent.voiceprintManagement': '声纹管理',
|
|
||||||
'agent.editTitle': '编辑智能体',
|
|
||||||
'agent.toolsTitle': '编辑功能',
|
|
||||||
'agent.voiceActivityDetection': '语音活动检测',
|
|
||||||
'agent.speechRecognition': '语音识别',
|
|
||||||
'agent.largeLanguageModel': '大语言模型',
|
|
||||||
'agent.save': '保存',
|
|
||||||
'agent.cancel': '取消',
|
|
||||||
// Agent编辑页面
|
|
||||||
'agent.basicInfo': '基础信息',
|
|
||||||
'agent.agentName': '助手昵称',
|
|
||||||
'agent.inputAgentName': '请输入助手昵称',
|
|
||||||
'agent.roleMode': '角色模式',
|
|
||||||
'agent.agentTag': '智能体标签',
|
|
||||||
'agent.addAgentTag': '添加标签',
|
|
||||||
'agent.inputAgentTag': '请输入智能体标签',
|
|
||||||
'agent.contextProvider': '上下文源',
|
|
||||||
'agent.contextProviderSuccess': '已成功添加 {count} 个源。',
|
|
||||||
'agent.contextProviderDocLink': '如何部署上下文源',
|
|
||||||
'agent.editContextProvider': '编辑源',
|
|
||||||
'agent.roleDescription': '角色介绍',
|
|
||||||
'agent.inputRoleDescription': '请输入角色介绍',
|
|
||||||
'agent.modelConfig': '模型配置',
|
|
||||||
'agent.vad': '语音活动检测',
|
|
||||||
'agent.asr': '语音识别',
|
|
||||||
'agent.llm': '主语言模型',
|
|
||||||
'agent.slm': '小参数模型',
|
|
||||||
'agent.vllm': '视觉大模型',
|
|
||||||
'agent.intent': '意图识别',
|
|
||||||
'agent.memory': '记忆',
|
|
||||||
'agent.voiceSettings': '语音设置',
|
|
||||||
'agent.tts': '语音合成',
|
|
||||||
'agent.voiceprint': '角色音色',
|
|
||||||
'agent.plugins': '插件',
|
|
||||||
'agent.editFunctions': '编辑功能',
|
|
||||||
'agent.historyMemory': '历史记忆',
|
|
||||||
'agent.memoryContent': '记忆内容',
|
|
||||||
'agent.saving': '保存中...',
|
|
||||||
'agent.saveSuccess': '保存成功',
|
|
||||||
'agent.saveFail': '保存失败',
|
|
||||||
'agent.loadFail': '加载失败',
|
|
||||||
'agent.pleaseInputAgentName': '请输入智能体名称',
|
|
||||||
'agent.pleaseInputRoleDescription': '请输入角色介绍',
|
|
||||||
'agent.pleaseSelect': '请选择',
|
|
||||||
'agent.reportText': '上报文字',
|
|
||||||
'agent.reportTextVoice': '上报文字+语音',
|
|
||||||
'agent.reportMode': '上报模式',
|
|
||||||
'agent.language': '对话语言',
|
|
||||||
'agent.languageConfig': '语速音调',
|
|
||||||
'agent.ttsVolume': '音量',
|
|
||||||
'agent.ttsRate': '语速',
|
|
||||||
'agent.ttsPitch': '音调',
|
|
||||||
'agent.volumeHint': '-100=最小, 0=标准, 100=最大',
|
|
||||||
'agent.speedHint': '-100=最慢, 0=标准, 100=最快',
|
|
||||||
'agent.pitchHint': '-100=最低, 0=标准, 100=最高',
|
|
||||||
|
|
||||||
// 上下文源对话框相关
|
|
||||||
'contextProviderDialog.title': '编辑源',
|
|
||||||
'contextProviderDialog.noContextApi': '暂无上下文API',
|
|
||||||
'contextProviderDialog.add': '添加',
|
|
||||||
'contextProviderDialog.apiUrl': '接口地址',
|
|
||||||
'contextProviderDialog.apiUrlPlaceholder': 'http://api.example.com/data',
|
|
||||||
'contextProviderDialog.requestHeaders': '请求头',
|
|
||||||
'contextProviderDialog.headerKeyPlaceholder': 'Key',
|
|
||||||
'contextProviderDialog.headerValuePlaceholder': 'Value',
|
|
||||||
'contextProviderDialog.noHeaders': '暂无 Headers',
|
|
||||||
'contextProviderDialog.addHeader': '添加 Header',
|
|
||||||
'contextProviderDialog.cancel': '取消',
|
|
||||||
'contextProviderDialog.confirm': '确定',
|
|
||||||
|
|
||||||
// 手動添加設備對話框相關
|
|
||||||
'manualAddDeviceDialog.title': '手动添加设备',
|
|
||||||
'manualAddDeviceDialog.deviceType': '设备型号',
|
|
||||||
'manualAddDeviceDialog.deviceTypePlaceholder': '请选择设备型号',
|
|
||||||
'manualAddDeviceDialog.firmwareVersion': '固件版本',
|
|
||||||
'manualAddDeviceDialog.firmwareVersionPlaceholder': '请输入固件版本',
|
|
||||||
'manualAddDeviceDialog.macAddress': 'Mac地址',
|
|
||||||
'manualAddDeviceDialog.macAddressPlaceholder': '请输入Mac地址',
|
|
||||||
'manualAddDeviceDialog.confirm': '确定',
|
|
||||||
'manualAddDeviceDialog.cancel': '取消',
|
|
||||||
'manualAddDeviceDialog.requiredMacAddress': '请输入Mac地址',
|
|
||||||
'manualAddDeviceDialog.invalidMacAddress': '请输入正确的Mac地址格式,例如:00:1A:2B:3C:4D:5E',
|
|
||||||
'manualAddDeviceDialog.requiredDeviceType': '请选择设备型号',
|
|
||||||
'manualAddDeviceDialog.requiredFirmwareVersion': '请输入固件版本',
|
|
||||||
'manualAddDeviceDialog.getFirmwareTypeFailed': '获取固件类型失败',
|
|
||||||
'manualAddDeviceDialog.addSuccess': '设备添加成功',
|
|
||||||
'manualAddDeviceDialog.addFailed': '添加失败',
|
|
||||||
'manualAddDeviceDialog.bindWithCode': '6位验证码绑定',
|
|
||||||
|
|
||||||
// 聊天历史页面
|
|
||||||
'chatHistory.getChatSessions': '获取聊天会话列表',
|
|
||||||
'chatHistory.noSelectedAgent': '没有选中的智能体',
|
|
||||||
'chatHistory.getChatSessionsFailed': '获取聊天会话列表失败:',
|
|
||||||
'chatHistory.unknownTime': '未知时间',
|
|
||||||
'chatHistory.justNow': '刚刚',
|
|
||||||
'chatHistory.minutesAgo': '{minutes}分钟前',
|
|
||||||
'chatHistory.hoursAgo': '{hours}小时前',
|
|
||||||
'chatHistory.daysAgo': '{days}天前',
|
|
||||||
'chatHistory.conversationRecord': '对话记录',
|
|
||||||
'chatHistory.totalChats': '共 {count} 条对话',
|
|
||||||
'chatHistory.loading': '加载中...',
|
|
||||||
'chatHistory.noMoreData': '没有更多数据了',
|
|
||||||
'chatHistory.noChatRecords': '暂无聊天记录',
|
|
||||||
'chatHistory.chatRecordsDescription': '与智能体的对话记录会显示在这里',
|
|
||||||
// 聊天详情页面
|
|
||||||
'chatHistory.pageTitle': '聊天详情',
|
|
||||||
'chatHistory.assistantName': '智能助手',
|
|
||||||
'chatHistory.userName': '用户',
|
|
||||||
'chatHistory.aiAssistantName': 'AI助手',
|
|
||||||
'chatHistory.loadFailed': '获取聊天记录失败',
|
|
||||||
'chatHistory.parameterError': '页面参数错误',
|
|
||||||
'chatHistory.invalidAudioId': '音频ID无效',
|
|
||||||
'chatHistory.audioPlayFailed': '音频播放失败',
|
|
||||||
'chatHistory.playAudioFailed': '播放音频失败',
|
|
||||||
|
|
||||||
// 设备管理页面
|
|
||||||
'device.pageTitle': '设备管理',
|
|
||||||
'device.noDevices': '暂无设备',
|
|
||||||
'device.macAddress': 'MAC地址',
|
|
||||||
'device.firmwareVersion': '固件版本',
|
|
||||||
'device.lastConnected': '最近对话',
|
|
||||||
'device.otaUpdate': 'OTA升级',
|
|
||||||
'device.unbind': '解绑',
|
|
||||||
'device.confirmUnbind': '确定要解绑设备',
|
|
||||||
'device.bindDevice': '绑定新设备',
|
|
||||||
'device.deviceType': '设备类型',
|
|
||||||
'device.loading': '加载中...',
|
|
||||||
'device.neverConnected': '从未连接',
|
|
||||||
'device.justNow': '刚刚',
|
|
||||||
'device.minutesAgo': '{minutes}分钟前',
|
|
||||||
'device.hoursAgo': '{hours}小时前',
|
|
||||||
'device.daysAgo': '{days}天前',
|
|
||||||
'device.otaAutoUpdateEnabled': 'OTA自动升级已开启',
|
|
||||||
'device.otaAutoUpdateDisabled': 'OTA自动升级已关闭',
|
|
||||||
'device.operationFailed': '操作失败,请重试',
|
|
||||||
'device.deviceUnbound': '设备已解绑',
|
|
||||||
'device.unbindFailed': '解绑失败,请重试',
|
|
||||||
'device.unbindDevice': '解绑设备',
|
|
||||||
'device.confirmUnbindDevice': '确定要解绑设备 "{macAddress}" 吗?',
|
|
||||||
'device.cancel': '取消',
|
|
||||||
'device.noDevice': '暂无设备',
|
|
||||||
'device.pleaseSelectAgent': '请先选择智能体',
|
|
||||||
'device.deviceBindSuccess': '设备绑定成功!',
|
|
||||||
'device.bindFailed': '绑定失败,请检查验证码是否正确',
|
|
||||||
'device.enterDeviceCode': '请输入设备验证码',
|
|
||||||
'device.bindNow': '立即绑定',
|
|
||||||
'device.lastConnection': '最近对话',
|
|
||||||
'device.clickToBindFirstDevice': '点击右下角 + 号绑定您的第一个设备',
|
|
||||||
|
|
||||||
// 通用
|
|
||||||
'common.success': '成功',
|
|
||||||
'common.fail': '失败',
|
|
||||||
'common.loading': '加载中...',
|
|
||||||
'common.confirm': '确认',
|
|
||||||
'common.cancel': '取消',
|
|
||||||
'common.delete': '删除',
|
|
||||||
'common.edit': '编辑',
|
|
||||||
'common.add': '添加',
|
|
||||||
'common.pleaseSelect': '请选择',
|
|
||||||
'common.unknownError': '未知错误',
|
|
||||||
'common.networkError': '网络错误',
|
|
||||||
|
|
||||||
// SM2加密相关错误消息
|
|
||||||
'sm2.publicKeyNotConfigured': 'SM2公钥未配置,请联系管理员',
|
|
||||||
'sm2.encryptionFailed': '密码加密失败',
|
|
||||||
'sm2.keyGenerationFailed': '密钥对生成失败',
|
|
||||||
'sm2.invalidPublicKey': '无效的公钥格式',
|
|
||||||
'sm2.encryptionError': '加密过程中发生错误',
|
|
||||||
'sm2.publicKeyRetry': '正在重试获取公钥...',
|
|
||||||
'sm2.publicKeyRetryFailed': '公钥获取重试失败',
|
|
||||||
|
|
||||||
// Voiceprint page
|
|
||||||
'voiceprint.noSelectedAgent': '没有选中的智能体',
|
|
||||||
'voiceprint.pleaseSelectAgent': '请先选择智能体',
|
|
||||||
'voiceprint.fetchHistoryFailed': '获取对话记录失败',
|
|
||||||
'voiceprint.clickToSelectVector': '点击选择声纹向量',
|
|
||||||
'voiceprint.pleaseInputName': '请输入姓名',
|
|
||||||
'voiceprint.pleaseSelectVector': '请选择声纹向量',
|
|
||||||
'voiceprint.addSuccess': '添加成功',
|
|
||||||
'voiceprint.addFailed': '添加说话人失败',
|
|
||||||
'voiceprint.editSuccess': '编辑成功',
|
|
||||||
'voiceprint.editFailed': '编辑说话人失败',
|
|
||||||
'voiceprint.deleteConfirmMsg': '确定要删除这个说话人吗?',
|
|
||||||
'voiceprint.deleteConfirmTitle': '确认删除',
|
|
||||||
'voiceprint.deleteSuccess': '删除成功',
|
|
||||||
'voiceprint.loading': '加载中...',
|
|
||||||
'voiceprint.delete': '删除',
|
|
||||||
'voiceprint.emptyTitle': '暂无声纹数据',
|
|
||||||
'voiceprint.emptyDesc': '点击右下角 + 号添加您的第一个说话人',
|
|
||||||
'voiceprint.addSpeaker': '添加说话人',
|
|
||||||
'voiceprint.voiceVector': '声纹向量',
|
|
||||||
'voiceprint.name': '姓名',
|
|
||||||
'voiceprint.description': '描述',
|
|
||||||
'voiceprint.pleaseInputDescription': '请输入描述',
|
|
||||||
'voiceprint.cancel': '取消',
|
|
||||||
'voiceprint.save': '保存',
|
|
||||||
'voiceprint.editSpeaker': '编辑说话人',
|
|
||||||
'voiceprint.selectVector': '选择声纹向量',
|
|
||||||
'voiceprint.voiceprintInterfaceNotConfigured': '声纹接口未配置',
|
|
||||||
|
|
||||||
// 设置页面
|
|
||||||
'settings.pageTitle': '设置',
|
|
||||||
'settings.navigationTitle': '设置',
|
|
||||||
'settings.networkSettings': '网络设置',
|
|
||||||
'settings.serverApiUrl': '服务端接口地址',
|
|
||||||
'settings.validServerUrl': '请输入有效的服务端地址(以 http 或 https 开头,并以 /xiaozhi 结尾)',
|
|
||||||
'settings.saveSettings': '保存设置',
|
|
||||||
'settings.resetDefault': '恢复默认',
|
|
||||||
'settings.restartApp': '重启应用',
|
|
||||||
'settings.restartNow': '立即重启',
|
|
||||||
'settings.restartLater': '稍后',
|
|
||||||
// 关于我们
|
|
||||||
'settings.aboutApp': '关于小智智控台',
|
|
||||||
'settings.aboutContent': '小智智控台\n\n基于 Vue.js 3 + uni-app 构建的跨平台移动端管理应用,为小智ESP32智能硬件提供设备管理、智能体配置等功能。\n\n© 2025 xiaozhi-esp32-server {version}',
|
|
||||||
'settings.restartSuccess': '已保存,可稍后手动重启应用',
|
|
||||||
'settings.serverUrlSavedAndCacheCleared': '服务端地址已保存,缓存已清除',
|
|
||||||
'settings.resetToDefaultAndCacheCleared': '已恢复默认设置,缓存已清除',
|
|
||||||
'settings.resetSuccess': '重置成功',
|
|
||||||
'settings.enterServerUrl': '请输入服务端地址',
|
|
||||||
'settings.clearCacheFailed': '清除缓存失败',
|
|
||||||
'settings.cacheManagement': '缓存管理',
|
|
||||||
'settings.totalCacheSize': '总缓存大小',
|
|
||||||
'settings.appDataSize': '应用数据总大小',
|
|
||||||
'settings.cacheClear': '缓存清理',
|
|
||||||
'settings.clearAllCache': '清空所有缓存数据',
|
|
||||||
'settings.clearCache': '清除缓存',
|
|
||||||
'settings.modifyWillClearCache': '修改将清除缓存',
|
|
||||||
'settings.appInfo': '应用信息',
|
|
||||||
'settings.aboutUs': '关于我们',
|
|
||||||
'settings.appVersion': '应用版本与团队信息',
|
|
||||||
'settings.confirmClear': '确认清除',
|
|
||||||
'settings.confirmClearMessage': '确定要清除所有缓存吗?这将删除所有数据包括登录状态,需要重新登录。',
|
|
||||||
'settings.cacheCleared': '缓存清除成功,即将跳转到登录页',
|
|
||||||
'settings.languageSettings': '语言设置',
|
|
||||||
'settings.language': '语言',
|
|
||||||
'settings.selectLanguage': '选择语言',
|
|
||||||
'settings.languageChanged': '语言切换成功',
|
|
||||||
|
|
||||||
// 重置密码页面
|
|
||||||
'retrievePassword.title': '重置密码',
|
|
||||||
'retrievePassword.subtitle': '通过手机号找回您的账户密码',
|
|
||||||
'retrievePassword.mobileRequired': '请输入手机号码',
|
|
||||||
'retrievePassword.inputCorrectMobile': '请输入正确的手机号码',
|
|
||||||
'retrievePassword.captchaRequired': '请输入图形验证码',
|
|
||||||
'retrievePassword.mobileCaptchaRequired': '请输入短信验证码',
|
|
||||||
'retrievePassword.newPasswordRequired': '请输入新密码',
|
|
||||||
'retrievePassword.confirmNewPasswordRequired': '请确认新密码',
|
|
||||||
'retrievePassword.passwordsNotMatch': '两次输入的密码不一致',
|
|
||||||
'retrievePassword.mobilePlaceholder': '请输入手机号码',
|
|
||||||
'retrievePassword.captchaPlaceholder': '请输入图形验证码',
|
|
||||||
'retrievePassword.mobileCaptchaPlaceholder': '请输入短信验证码',
|
|
||||||
'retrievePassword.newPasswordPlaceholder': '请输入新密码',
|
|
||||||
'retrievePassword.confirmNewPasswordPlaceholder': '请确认新密码',
|
|
||||||
'retrievePassword.getMobileCaptcha': '获取验证码',
|
|
||||||
'retrievePassword.captchaSendSuccess': '验证码发送成功',
|
|
||||||
'retrievePassword.passwordUpdateSuccess': '密码重置成功',
|
|
||||||
'retrievePassword.resetButton': '重置密码',
|
|
||||||
'retrievePassword.goToLogin': '返回登录',
|
|
||||||
|
|
||||||
// 消息提示
|
|
||||||
'message.loginSuccess': '登录成功!',
|
|
||||||
'message.loginFail': '登录失败',
|
|
||||||
'message.registerSuccess': '注册成功',
|
|
||||||
'message.registerFail': '注册失败',
|
|
||||||
'message.saveSuccess': '保存成功',
|
|
||||||
'message.saveFail': '保存失败',
|
|
||||||
'message.deleteSuccess': '删除成功',
|
|
||||||
'message.deleteFail': '删除失败',
|
|
||||||
'message.bindSuccess': '绑定成功',
|
|
||||||
'message.bindFail': '绑定失败',
|
|
||||||
'message.unbindSuccess': '解绑成功',
|
|
||||||
'message.unbindFail': '解绑失败',
|
|
||||||
'message.networkError': '网络错误,请检查网络连接',
|
|
||||||
'message.serverError': '服务器错误,请稍后再试',
|
|
||||||
'message.invalidAddress': '地址可能无效,请检查服务端是否启动或网络连接是否正常;也可能因 HTTPS 协议问题导致无法发送请求',
|
|
||||||
'message.languageChanged': '语言已切换',
|
|
||||||
'message.passwordError': '账号或密码错误',
|
|
||||||
'message.phoneRegistered': '此手机号码已经注册过',
|
|
||||||
|
|
||||||
// Agent工具页面
|
|
||||||
'agent.tools.pageTitle': 'Agent工具',
|
|
||||||
'agent.tools.unselected': '未选',
|
|
||||||
'agent.tools.selected': '已选',
|
|
||||||
'agent.tools.noMorePlugins': '暂无更多插件',
|
|
||||||
'agent.tools.pleaseSelectPlugin': '请选择插件功能',
|
|
||||||
'agent.tools.builtInPlugins': '内置插件',
|
|
||||||
'agent.tools.mcpAccessPoint': 'mcp接入点',
|
|
||||||
'agent.tools.copy': '复制',
|
|
||||||
'agent.tools.noTools': '暂无工具',
|
|
||||||
'agent.tools.parameterConfig': '参数配置',
|
|
||||||
'agent.tools.noParamsNeeded': '无需配置参数',
|
|
||||||
'agent.tools.pleaseInput': '请输入',
|
|
||||||
'agent.tools.inputOneItemPerLine': '每行输入一个项目',
|
|
||||||
'agent.tools.pleaseInputValidJson': '请输入有效的JSON格式',
|
|
||||||
'agent.tools.enableFunction': '启用功能',
|
|
||||||
'agent.tools.toggleFunction': '开启或关闭此功能',
|
|
||||||
'agent.tools.jsonFormatError': 'JSON格式错误',
|
|
||||||
'agent.tools.noMcpAddressToCopy': '暂无MCP地址可复制',
|
|
||||||
'agent.tools.mcpAddressCopied': 'MCP地址已复制到剪贴板',
|
|
||||||
'agent.tools.copyFailed': '复制失败,请重试',
|
|
||||||
'agent.tools.defaultValue': '默认值',
|
|
||||||
'agent.tools.notSelected': '未选',
|
|
||||||
'agent.tools.clickToConfigure': '点击配置',
|
|
||||||
'agent.tools.mcpEndpoint': 'MCP接入点',
|
|
||||||
'agent.tools.eachLineOneItem': '每行输入一个项目',
|
|
||||||
|
|
||||||
// 设备配置页面
|
|
||||||
'deviceConfig.pageTitle': '设备配置',
|
|
||||||
'deviceConfig.wifiConfig': 'WiFi配网',
|
|
||||||
'deviceConfig.ultrasonicConfig': '超声波配网',
|
|
||||||
'deviceConfig.selectConfigMethod': '选择配网方式',
|
|
||||||
'deviceConfig.networkConfig': '网络配置',
|
|
||||||
'deviceConfig.selectedNetwork': '选中网络',
|
|
||||||
'deviceConfig.signal': '信号',
|
|
||||||
'deviceConfig.openNetwork': '开放网络',
|
|
||||||
'deviceConfig.encryptedNetwork': '加密网络',
|
|
||||||
'deviceConfig.password': '密码',
|
|
||||||
'deviceConfig.pleaseEnterPassword': '请输入WiFi密码',
|
|
||||||
'deviceConfig.startConfig': '开始配网',
|
|
||||||
'deviceConfig.connectToXiaozhiHotspot': '请先连接xiaozhi热点 (xiaozhi-XXXXXX)',
|
|
||||||
'deviceConfig.detecting': '检测中...',
|
|
||||||
'deviceConfig.reDetect': '重新检测',
|
|
||||||
'deviceConfig.alreadyConnected': '已连接xiaozhi热点',
|
|
||||||
'deviceConfig.refreshStatus': '刷新状态',
|
|
||||||
'deviceConfig.wifiNetworks': 'WiFi网络',
|
|
||||||
'deviceConfig.selectWifiNetwork': '选择WiFi网络',
|
|
||||||
'deviceConfig.refreshScan': '刷新扫描',
|
|
||||||
'deviceConfig.noWifiNetworks': '暂无WiFi网络',
|
|
||||||
'deviceConfig.clickToRefreshScan': '请点击刷新扫描',
|
|
||||||
'deviceConfig.signalStrong': '信号强',
|
|
||||||
'deviceConfig.signalGood': '信号良好',
|
|
||||||
'deviceConfig.signalFair': '信号一般',
|
|
||||||
'deviceConfig.signalWeak': '信号弱',
|
|
||||||
'deviceConfig.channel': '频道',
|
|
||||||
'deviceConfig.about': '约',
|
|
||||||
'deviceConfig.seconds': '秒',
|
|
||||||
'deviceConfig.generating': '生成中...',
|
|
||||||
'deviceConfig.playing': '播放中...',
|
|
||||||
'deviceConfig.generateAndPlaySoundWave': '生成并播放声波',
|
|
||||||
'deviceConfig.playSoundWave': '播放声波',
|
|
||||||
'deviceConfig.stopPlaying': '停止播放',
|
|
||||||
'deviceConfig.autoLoopPlaySoundWave': '自动循环播放声波',
|
|
||||||
'deviceConfig.configAudioFile': '配网音频文件',
|
|
||||||
'deviceConfig.duration': '时长',
|
|
||||||
'deviceConfig.ultrasonicConfigInstructions': '超声波配网说明',
|
|
||||||
'deviceConfig.ensureWifiNetworkSelectedAndPasswordEntered': '确保已选择WiFi网络并输入密码',
|
|
||||||
'deviceConfig.clickGenerateAndPlaySoundWave': '点击生成并播放声波,系统会将配网信息编码为音频',
|
|
||||||
'deviceConfig.bringPhoneCloseToXiaozhiDevice': '将手机靠近xiaozhi设备(距离1-2米)',
|
|
||||||
'deviceConfig.duringAudioPlaybackXiaozhiWillReceive': '音频播放时,xiaozhi会接收并解码配网信息',
|
|
||||||
'deviceConfig.afterConfigSuccessDeviceWillConnect': '配网成功后设备会自动连接WiFi网络',
|
|
||||||
'deviceConfig.usesAfskModulation': '使用AFSK调制技术,通过1800Hz和1500Hz频率传输数据',
|
|
||||||
'deviceConfig.ensureModeratePhoneVolume': '请确保手机音量适中,避免环境噪音干扰',
|
|
||||||
'deviceConfig.generatingUltrasonicConfigAudio': '生成超声波配网音频',
|
|
||||||
'deviceConfig.configData': '配网数据',
|
|
||||||
'deviceConfig.dataBytesLength': '数据字节长度',
|
|
||||||
'deviceConfig.bitStreamLength': '比特流长度',
|
|
||||||
'deviceConfig.base64Length': 'base64长度',
|
|
||||||
'deviceConfig.audioFileTooLarge': '音频文件过大,请缩短SSID或密码长度',
|
|
||||||
'deviceConfig.audioGenerationSuccess': '音频生成成功',
|
|
||||||
'deviceConfig.samplePoints': '采样点数',
|
|
||||||
'deviceConfig.soundWaveGenerationSuccess': '声波生成成功',
|
|
||||||
'deviceConfig.audioGenerationFailed': '音频生成失败',
|
|
||||||
'deviceConfig.soundWaveGenerationFailed': '声波生成失败',
|
|
||||||
'deviceConfig.pleaseGenerateAudioFirst': '请先生成音频',
|
|
||||||
'deviceConfig.startPlayingUltrasonicConfigAudio': '开始播放超声波配网音频',
|
|
||||||
'deviceConfig.ultrasonicAudioStartedPlaying': '超声波音频开始播放',
|
|
||||||
'deviceConfig.startPlayingConfigSoundWave': '开始播放配网声波',
|
|
||||||
'deviceConfig.ultrasonicAudioPlaybackEnded': '超声波音频播放结束',
|
|
||||||
'deviceConfig.audioPlaybackFailed': '音频播放失败',
|
|
||||||
'deviceConfig.audioResourceBusy': '音频资源繁忙,请稍后重试',
|
|
||||||
'deviceConfig.audioFormatNotSupported': '音频格式不支持,可能是data URI问题',
|
|
||||||
'deviceConfig.audioFileError': '音频文件错误',
|
|
||||||
'deviceConfig.cleaningUpAudioContext': '清理音频上下文',
|
|
||||||
'deviceConfig.cleaningUpAudioContextFailed': '清理音频上下文失败',
|
|
||||||
'deviceConfig.stoppedPlayingUltrasonicAudio': '停止播放超声波音频',
|
|
||||||
'deviceConfig.stoppedPlaying': '已停止播放',
|
|
||||||
'deviceConfig.configMethod': '配网方式',
|
|
||||||
'deviceConfig.enterWifiPassword': '请输入WiFi密码',
|
|
||||||
'deviceConfig.xiaozhi': 'xiaozhi',
|
|
||||||
'deviceConfig.connectXiaozhiHotspot': '请连接xiaozhi热点',
|
|
||||||
'deviceConfig.wifiScanResponse': 'WiFi扫描响应',
|
|
||||||
'deviceConfig.scanSuccess': '扫描成功',
|
|
||||||
'deviceConfig.networks': '个网络',
|
|
||||||
'deviceConfig.wifiScanFailed': 'WiFi扫描失败',
|
|
||||||
'deviceConfig.scanFailedCheckConnection': '扫描失败,请检查连接',
|
|
||||||
'deviceConfig.checking': '检查中',
|
|
||||||
'deviceConfig.reCheck': '重新检查',
|
|
||||||
'deviceConfig.connectedXiaozhiHotspot': '已连接xiaozhi热点',
|
|
||||||
'deviceConfig.wifiNetwork': 'WiFi网络',
|
|
||||||
'deviceConfig.wifiPassword': 'WiFi密码',
|
|
||||||
'deviceConfig.scanning': '扫描中',
|
|
||||||
'deviceConfig.cancel': '取消',
|
|
||||||
'deviceConfig.clickRefreshScan': '请点击刷新扫描',
|
|
||||||
'deviceConfig.esp32ConnectionCheckFailed': 'ESP32连接检查失败',
|
|
||||||
'deviceConfig.startWifiConfig': '开始WiFi配网',
|
|
||||||
'deviceConfig.configSuccess': '配网成功',
|
|
||||||
'deviceConfig.deviceWillConnectTo': '设备将连接到',
|
|
||||||
'deviceConfig.deviceWillRestart': '设备将重启',
|
|
||||||
'deviceConfig.pleaseDisconnectXiaozhiHotspot': '请断开xiaozhi热点连接',
|
|
||||||
'deviceConfig.configFailed': '配网失败',
|
|
||||||
'deviceConfig.wifiConfigFailed': 'WiFi配网失败',
|
|
||||||
'deviceConfig.pleaseCheckNetworkConnection': '请检查网络连接',
|
|
||||||
'deviceConfig.startWifiConfigButton': '开始配网',
|
|
||||||
'deviceConfig.configuring': '配网中...',
|
|
||||||
'deviceConfig.wifiConfigInstructions': 'WiFi配网说明',
|
|
||||||
'deviceConfig.phoneConnectXiaozhiHotspot': '手机连接xiaozhi热点',
|
|
||||||
'deviceConfig.selectTargetWifiNetwork': '选择目标WiFi网络',
|
|
||||||
'deviceConfig.enterWifiPasswordIfNeeded': '如有需要请输入WiFi密码',
|
|
||||||
'deviceConfig.clickStartConfigAndWait': '点击开始配网并等待',
|
|
||||||
'deviceConfig.afterConfigSuccessDeviceWillRestart': '配网成功后设备将自动重启',
|
|
||||||
'deviceConfig.audioPlaybackError': '音频播放错误',
|
|
||||||
'deviceConfig.playbackFailed': '播放失败',
|
|
||||||
|
|
||||||
// Voiceprint page
|
|
||||||
'voiceprint.audioNotExist': '该音频不存在',
|
|
||||||
'voiceprint.getAudioFailed': '获取音频失败',
|
|
||||||
'voiceprint.audioPlayFailed': '音频播放失败',
|
|
||||||
}
|
|
||||||
|
|
@ -1,503 +0,0 @@
|
||||||
// 繁體中文語言包
|
|
||||||
export default {
|
|
||||||
// TabBar
|
|
||||||
'tabBar.home': '首頁',
|
|
||||||
'tabBar.deviceConfig': '配網',
|
|
||||||
'tabBar.settings': '系統',
|
|
||||||
// 設置頁面標題
|
|
||||||
'settings.title': '設置',
|
|
||||||
// 登錄頁面
|
|
||||||
'login.pageTitle': '登錄',
|
|
||||||
'login.navigationTitle': '登錄',
|
|
||||||
'login.fetchConfigError': '獲取配置失敗:',
|
|
||||||
'login.selectLanguage': '選擇語言',
|
|
||||||
'login.selectLanguageTip': '繁體',
|
|
||||||
'login.welcomeBack': '歡迎回來',
|
|
||||||
'login.pleaseLogin': '請登錄您的賬戶',
|
|
||||||
'login.enterUsername': '請輸入用戶名',
|
|
||||||
'login.enterPassword': '請輸入密碼',
|
|
||||||
'login.enterCaptcha': '請輸入驗證碼',
|
|
||||||
'login.loginButton': '登錄',
|
|
||||||
'login.loggingIn': '登錄中...',
|
|
||||||
'login.noAccount': '新用戶註冊',
|
|
||||||
'login.enterPhone': '請輸入手機號碼',
|
|
||||||
'login.selectCountry': '選擇國家/地區',
|
|
||||||
'login.confirm': '確認',
|
|
||||||
'login.serverSetting': '服務端設置',
|
|
||||||
'login.requiredUsername': '用戶名不能為空',
|
|
||||||
'login.requiredPassword': '密碼不能為空',
|
|
||||||
'login.requiredCaptcha': '驗證碼不能為空',
|
|
||||||
'login.requiredMobile': '請輸入正確的手機號碼',
|
|
||||||
'login.captchaError': '圖形驗證碼錯誤',
|
|
||||||
'login.forgotPassword': '忘記密碼',
|
|
||||||
'login.userAgreement': '用戶協議',
|
|
||||||
'login.privacyPolicy': '隱私政策',
|
|
||||||
|
|
||||||
// 忘記密碼頁面
|
|
||||||
'retrievePassword.title': '重置密碼',
|
|
||||||
'retrievePassword.subtitle': '請輸入您的手機號碼以重置密碼',
|
|
||||||
'retrievePassword.mobileRequired': '請輸入手機號碼',
|
|
||||||
'retrievePassword.inputCorrectMobile': '請輸入正確的手機號碼',
|
|
||||||
'retrievePassword.captchaRequired': '請輸入圖形驗證碼',
|
|
||||||
'retrievePassword.mobileCaptchaRequired': '請輸入手機驗證碼',
|
|
||||||
'retrievePassword.newPasswordRequired': '請輸入新密碼',
|
|
||||||
'retrievePassword.confirmNewPasswordRequired': '請確認新密碼',
|
|
||||||
'retrievePassword.passwordsNotMatch': '兩次輸入的密碼不一致',
|
|
||||||
'retrievePassword.mobilePlaceholder': '請輸入手機號碼',
|
|
||||||
'retrievePassword.captchaPlaceholder': '請輸入圖形驗證碼',
|
|
||||||
'retrievePassword.mobileCaptchaPlaceholder': '請輸入手機驗證碼',
|
|
||||||
'retrievePassword.newPasswordPlaceholder': '請輸入新密碼',
|
|
||||||
'retrievePassword.confirmNewPasswordPlaceholder': '請確認新密碼',
|
|
||||||
'retrievePassword.getMobileCaptcha': '獲取驗證碼',
|
|
||||||
'retrievePassword.captchaSendSuccess': '驗證碼發送成功',
|
|
||||||
'retrievePassword.passwordUpdateSuccess': '密碼重置成功',
|
|
||||||
'retrievePassword.resetButton': '重置密碼',
|
|
||||||
'retrievePassword.goToLogin': '返回登錄',
|
|
||||||
|
|
||||||
// 註冊頁面
|
|
||||||
'register.pageTitle': '註冊',
|
|
||||||
'register.createAccount': '創建賬戶',
|
|
||||||
'register.enterUsername': '請輸入用戶名',
|
|
||||||
'register.enterPassword': '請輸入密碼',
|
|
||||||
'register.confirmPassword': '請確認密碼',
|
|
||||||
'register.enterPhone': '請輸入手機號碼',
|
|
||||||
'register.enterCode': '請輸入驗證碼',
|
|
||||||
'register.getCode': '獲取驗證碼',
|
|
||||||
'register.agreeTerms': '我已閱讀並同意',
|
|
||||||
'register.terms': '《用戶協議》',
|
|
||||||
'register.privacy': '《隱私政策》',
|
|
||||||
'register.registerButton': '註冊',
|
|
||||||
'register.registering': '註冊中...',
|
|
||||||
'register.haveAccount': '已有賬戶?',
|
|
||||||
'register.loginNow': '立即登錄',
|
|
||||||
'register.selectCountry': '選擇國家/地區',
|
|
||||||
'register.confirm': '確認',
|
|
||||||
'register.captchaSendSuccess': '驗證碼發送成功',
|
|
||||||
|
|
||||||
// 首頁
|
|
||||||
'home.pageTitle': '首頁',
|
|
||||||
'home.createAgent': '創建智能體',
|
|
||||||
'home.agentName': '智能體',
|
|
||||||
'home.modelInfo': '模型信息',
|
|
||||||
'home.lastActive': '最近活躍',
|
|
||||||
'home.greeting': '你好,小智',
|
|
||||||
'home.subtitle': '讓我們度過',
|
|
||||||
'home.wonderfulDay': '美好的一天!',
|
|
||||||
'home.emptyState': '暫無智能體',
|
|
||||||
'home.deviceManagement': '設備管理',
|
|
||||||
'home.lastConversation': '最近對話:',
|
|
||||||
'home.delete': '刪除',
|
|
||||||
'home.createFirstAgent': '點擊右下角 + 號創建您的第一個智能體',
|
|
||||||
'home.dialogTitle': '創建智能體',
|
|
||||||
'home.inputPlaceholder': '例如:客服助手、語音助理、知識問答',
|
|
||||||
'home.createError': '暱稱長度必須在 1 到 64 個字元之間。',
|
|
||||||
'home.createNow': '立即創建',
|
|
||||||
'home.justNow': '剛剛',
|
|
||||||
'home.minutesAgo': '分鐘前',
|
|
||||||
'home.hoursAgo': '小時前',
|
|
||||||
'home.daysAgo': '天前',
|
|
||||||
'home.languageModel': '語言模型',
|
|
||||||
'home.voiceModel': '音色模型',
|
|
||||||
|
|
||||||
// Agent頁面
|
|
||||||
'agent.pageTitle': '智能體',
|
|
||||||
'agent.roleConfig': '角色配置',
|
|
||||||
'agent.deviceManagement': '設備管理',
|
|
||||||
'agent.chatHistory': '聊天記錄',
|
|
||||||
'agent.voiceprintManagement': '聲紋管理',
|
|
||||||
'agent.editTitle': '編輯智能體',
|
|
||||||
'agent.toolsTitle': '編輯功能',
|
|
||||||
'agent.voiceActivityDetection': '語音活動檢測',
|
|
||||||
'agent.speechRecognition': '語音識別',
|
|
||||||
'agent.largeLanguageModel': '大語言模型',
|
|
||||||
'agent.save': '保存',
|
|
||||||
'agent.cancel': '取消',
|
|
||||||
// Agent編輯頁面
|
|
||||||
'agent.basicInfo': '基礎資訊',
|
|
||||||
'agent.agentName': '助手暱稱',
|
|
||||||
'agent.inputAgentName': '請輸入助手暱稱',
|
|
||||||
'agent.roleMode': '角色模式',
|
|
||||||
'agent.agentTag': '智慧體標籤',
|
|
||||||
'agent.addAgentTag': '添加標籤',
|
|
||||||
'agent.inputAgentTag': '請輸入智慧體標籤',
|
|
||||||
'agent.contextProvider': '上下文源',
|
|
||||||
'agent.contextProviderSuccess': '已成功添加 {count} 個源。',
|
|
||||||
'agent.contextProviderDocLink': '如何部署上下文源',
|
|
||||||
'agent.editContextProvider': '編輯源',
|
|
||||||
'agent.roleDescription': '角色介紹',
|
|
||||||
'agent.inputRoleDescription': '請輸入角色介紹',
|
|
||||||
'agent.modelConfig': '模型配置',
|
|
||||||
'agent.vad': '語音活動檢測',
|
|
||||||
'agent.asr': '語音識別',
|
|
||||||
'agent.llm': '主語言模型',
|
|
||||||
'agent.slm': '小參數模型',
|
|
||||||
'agent.vllm': '視覺大模型',
|
|
||||||
'agent.intent': '意圖識別',
|
|
||||||
'agent.memory': '記憶',
|
|
||||||
'agent.voiceSettings': '語音設置',
|
|
||||||
'agent.tts': '語音合成',
|
|
||||||
'agent.voiceprint': '角色音色',
|
|
||||||
'agent.plugins': '外掛',
|
|
||||||
'agent.editFunctions': '編輯功能',
|
|
||||||
'agent.historyMemory': '歷史記憶',
|
|
||||||
'agent.memoryContent': '記憶內容',
|
|
||||||
'agent.saving': '儲存中...',
|
|
||||||
'agent.saveSuccess': '儲存成功',
|
|
||||||
'agent.saveFail': '儲存失敗',
|
|
||||||
'agent.loadFail': '加載失敗',
|
|
||||||
'agent.pleaseInputAgentName': '請輸入助手暱稱',
|
|
||||||
'agent.pleaseInputRoleDescription': '請輸入角色介紹',
|
|
||||||
'agent.pleaseSelect': '請選擇',
|
|
||||||
'agent.reportText': '上报文字',
|
|
||||||
'agent.reportTextVoice': '上报文字+语音',
|
|
||||||
'agent.reportMode': '上報模式',
|
|
||||||
'agent.language': '對話語言',
|
|
||||||
'agent.languageConfig': '語速音調',
|
|
||||||
'agent.ttsVolume': '音量',
|
|
||||||
'agent.ttsRate': '語速',
|
|
||||||
'agent.ttsPitch': '音調',
|
|
||||||
'agent.volumeHint': '-100=最小, 0=標準, 100=最大',
|
|
||||||
'agent.speedHint': '-100=最慢, 0=標準, 100=最快',
|
|
||||||
'agent.pitchHint': '-100=最低, 0=標準, 100=最高',
|
|
||||||
|
|
||||||
// 上下文源对话框相关
|
|
||||||
'contextProviderDialog.title': '編輯源',
|
|
||||||
'contextProviderDialog.noContextApi': '暫無上下文API',
|
|
||||||
'contextProviderDialog.add': '添加',
|
|
||||||
'contextProviderDialog.apiUrl': '介面地址',
|
|
||||||
'contextProviderDialog.apiUrlPlaceholder': 'http://api.example.com/data',
|
|
||||||
'contextProviderDialog.requestHeaders': '請求頭',
|
|
||||||
'contextProviderDialog.headerKeyPlaceholder': 'Key',
|
|
||||||
'contextProviderDialog.headerValuePlaceholder': 'Value',
|
|
||||||
'contextProviderDialog.noHeaders': '暫無 Headers',
|
|
||||||
'contextProviderDialog.addHeader': '添加 Header',
|
|
||||||
'contextProviderDialog.cancel': '取消',
|
|
||||||
'contextProviderDialog.confirm': '確定',
|
|
||||||
|
|
||||||
// 手動添加設備對話框相關
|
|
||||||
'manualAddDeviceDialog.title': '手動添加設備',
|
|
||||||
'manualAddDeviceDialog.deviceType': '設備型號',
|
|
||||||
'manualAddDeviceDialog.deviceTypePlaceholder': '請選擇設備型號',
|
|
||||||
'manualAddDeviceDialog.firmwareVersion': '固件版本',
|
|
||||||
'manualAddDeviceDialog.firmwareVersionPlaceholder': '請輸入固件版本',
|
|
||||||
'manualAddDeviceDialog.macAddress': 'Mac地址',
|
|
||||||
'manualAddDeviceDialog.macAddressPlaceholder': '請輸入Mac地址',
|
|
||||||
'manualAddDeviceDialog.confirm': '確定',
|
|
||||||
'manualAddDeviceDialog.cancel': '取消',
|
|
||||||
'manualAddDeviceDialog.requiredMacAddress': '請輸入Mac地址',
|
|
||||||
'manualAddDeviceDialog.invalidMacAddress': '請輸入正確的Mac地址格式,例如:00:1A:2B:3C:4D:5E',
|
|
||||||
'manualAddDeviceDialog.requiredDeviceType': '請選擇設備型號',
|
|
||||||
'manualAddDeviceDialog.requiredFirmwareVersion': '請輸入固件版本',
|
|
||||||
'manualAddDeviceDialog.getFirmwareTypeFailed': '獲取固件類型失敗',
|
|
||||||
'manualAddDeviceDialog.addSuccess': '設備添加成功',
|
|
||||||
'manualAddDeviceDialog.addFailed': '添加失敗',
|
|
||||||
'manualAddDeviceDialog.bindWithCode': '6位驗證碼綁定',
|
|
||||||
|
|
||||||
// 聊天歷史頁面
|
|
||||||
'chatHistory.getChatSessions': '獲取聊天會話列表',
|
|
||||||
'chatHistory.noSelectedAgent': '沒有選中的智能體',
|
|
||||||
'chatHistory.getChatSessionsFailed': '獲取聊天會話列表失敗:',
|
|
||||||
'chatHistory.unknownTime': '未知時間',
|
|
||||||
'chatHistory.justNow': '剛剛',
|
|
||||||
'chatHistory.minutesAgo': '{minutes}分鐘前',
|
|
||||||
'chatHistory.hoursAgo': '{hours}小時前',
|
|
||||||
'chatHistory.daysAgo': '{days}天前',
|
|
||||||
'chatHistory.conversationRecord': '對話記錄',
|
|
||||||
'chatHistory.totalChats': '共 {count} 條對話',
|
|
||||||
'chatHistory.loading': '加載中...',
|
|
||||||
'chatHistory.noMoreData': '沒有更多數據了',
|
|
||||||
'chatHistory.noChatRecords': '暫無聊天記錄',
|
|
||||||
'chatHistory.chatRecordsDescription': '與智能體的對話記錄會顯示在這裡',
|
|
||||||
// 聊天詳情頁面
|
|
||||||
'chatHistory.pageTitle': '聊天詳情',
|
|
||||||
'chatHistory.assistantName': '智能助手',
|
|
||||||
'chatHistory.userName': '用戶',
|
|
||||||
'chatHistory.aiAssistantName': 'AI助手',
|
|
||||||
'chatHistory.loadFailed': '獲取聊天記錄失敗',
|
|
||||||
'chatHistory.parameterError': '頁面參數錯誤',
|
|
||||||
'chatHistory.invalidAudioId': '音頻ID無效',
|
|
||||||
'chatHistory.audioPlayFailed': '音頻播放失敗',
|
|
||||||
'chatHistory.playAudioFailed': '播放音頻失敗',
|
|
||||||
|
|
||||||
// 設備管理頁面
|
|
||||||
'device.pageTitle': '設備管理',
|
|
||||||
'device.noDevices': '暫無設備',
|
|
||||||
'device.macAddress': 'MAC地址',
|
|
||||||
'device.firmwareVersion': '固件版本',
|
|
||||||
'device.lastConnected': '最近對話',
|
|
||||||
'device.otaUpdate': 'OTA升級',
|
|
||||||
'device.unbind': '解除綁定',
|
|
||||||
'device.confirmUnbind': '確定要解綁設備',
|
|
||||||
'device.bindDevice': '綁定新設備',
|
|
||||||
'device.deviceType': '設備類型',
|
|
||||||
'device.loading': '加載中...',
|
|
||||||
'device.neverConnected': '從未連接',
|
|
||||||
'device.justNow': '剛剛',
|
|
||||||
'device.minutesAgo': '{minutes}分鐘前',
|
|
||||||
'device.hoursAgo': '{hours}小時前',
|
|
||||||
'device.daysAgo': '{days}天前',
|
|
||||||
'device.otaAutoUpdateEnabled': 'OTA自動升級已開啟',
|
|
||||||
'device.otaAutoUpdateDisabled': 'OTA自動升級已關閉',
|
|
||||||
'device.operationFailed': '操作失敗,請重試',
|
|
||||||
'device.deviceUnbound': '設備已解除綁定',
|
|
||||||
'device.unbindFailed': '解除綁定失敗,請重試',
|
|
||||||
'device.unbindDevice': '解除綁定設備',
|
|
||||||
'device.confirmUnbindDevice': '確定要解除綁定設備 "{macAddress}" 嗎?',
|
|
||||||
'device.cancel': '取消',
|
|
||||||
'device.noDevice': '暫無設備',
|
|
||||||
'device.pleaseSelectAgent': '請先選擇智能體',
|
|
||||||
'device.deviceBindSuccess': '設備綁定成功!',
|
|
||||||
'device.bindFailed': '綁定失敗,請檢查驗證碼是否正確',
|
|
||||||
'device.enterDeviceCode': '請輸入設備驗證碼',
|
|
||||||
'device.bindNow': '立即綁定',
|
|
||||||
'device.lastConnection': '最近對話',
|
|
||||||
'device.clickToBindFirstDevice': '點擊右下角 + 號綁定您的第一個設備',
|
|
||||||
|
|
||||||
// 通用
|
|
||||||
'common.success': '成功',
|
|
||||||
'common.fail': '失敗',
|
|
||||||
'common.loading': '加載中...',
|
|
||||||
'common.confirm': '確認',
|
|
||||||
'common.cancel': '取消',
|
|
||||||
'common.delete': '刪除',
|
|
||||||
'common.edit': '編輯',
|
|
||||||
'common.add': '添加',
|
|
||||||
'common.pleaseSelect': '請選擇',
|
|
||||||
'common.unknownError': '未知錯誤',
|
|
||||||
'common.networkError': '網路錯誤',
|
|
||||||
|
|
||||||
// SM2加密相關錯誤消息
|
|
||||||
'sm2.publicKeyNotConfigured': 'SM2公鑰未配置,請聯繫管理員',
|
|
||||||
'sm2.encryptionFailed': '密碼加密失敗',
|
|
||||||
'sm2.keyGenerationFailed': '金鑰對生成失敗',
|
|
||||||
'sm2.invalidPublicKey': '無效的公鑰格式',
|
|
||||||
'sm2.encryptionError': '加密過程中發生錯誤',
|
|
||||||
'sm2.publicKeyRetry': '正在重試獲取公鑰...',
|
|
||||||
'sm2.publicKeyRetryFailed': '公鑰獲取重試失敗',
|
|
||||||
|
|
||||||
// Voiceprint page
|
|
||||||
'voiceprint.noSelectedAgent': '沒有選中的智能體',
|
|
||||||
'voiceprint.pleaseSelectAgent': '請先選擇智能體',
|
|
||||||
'voiceprint.fetchHistoryFailed': '獲取對話記錄失敗',
|
|
||||||
'voiceprint.clickToSelectVector': '點擊選擇聲紋向量',
|
|
||||||
'voiceprint.pleaseInputName': '請輸入姓名',
|
|
||||||
'voiceprint.pleaseSelectVector': '請選擇聲紋向量',
|
|
||||||
'voiceprint.addSuccess': '添加成功',
|
|
||||||
'voiceprint.addFailed': '添加說話人失敗',
|
|
||||||
'voiceprint.editSuccess': '編輯成功',
|
|
||||||
'voiceprint.editFailed': '編輯說話人失敗',
|
|
||||||
'voiceprint.deleteConfirmMsg': '確定要刪除這個說話人嗎?',
|
|
||||||
'voiceprint.deleteConfirmTitle': '確認刪除',
|
|
||||||
'voiceprint.deleteSuccess': '刪除成功',
|
|
||||||
'voiceprint.loading': '加載中...',
|
|
||||||
'voiceprint.delete': '刪除',
|
|
||||||
'voiceprint.emptyTitle': '暫無聲紋數據',
|
|
||||||
'voiceprint.emptyDesc': '點擊右下角 + 號添加您的第一個說話人',
|
|
||||||
'voiceprint.addSpeaker': '添加說話人',
|
|
||||||
'voiceprint.voiceVector': '聲紋向量',
|
|
||||||
'voiceprint.name': '姓名',
|
|
||||||
'voiceprint.description': '描述',
|
|
||||||
'voiceprint.pleaseInputDescription': '請輸入描述',
|
|
||||||
'voiceprint.cancel': '取消',
|
|
||||||
'voiceprint.save': '保存',
|
|
||||||
'voiceprint.editSpeaker': '編輯說話人',
|
|
||||||
'voiceprint.selectVector': '選擇聲紋向量',
|
|
||||||
'voiceprint.voiceprintInterfaceNotConfigured': '聲紋接口未配置',
|
|
||||||
|
|
||||||
// 設置頁面
|
|
||||||
'settings.pageTitle': '設置',
|
|
||||||
'settings.navigationTitle': '設置',
|
|
||||||
'settings.networkSettings': '網絡設置',
|
|
||||||
'settings.serverApiUrl': '服務端接口地址',
|
|
||||||
'settings.validServerUrl': '請輸入有效的服務端地址(以 http 或 https 開頭,並以 /xiaozhi 結尾)',
|
|
||||||
'settings.saveSettings': '保存設置',
|
|
||||||
'settings.resetDefault': '恢復默認',
|
|
||||||
'settings.restartApp': '重啟應用',
|
|
||||||
'settings.restartNow': '立即重啟',
|
|
||||||
'settings.restartLater': '稍後',
|
|
||||||
// 關於我們
|
|
||||||
'settings.aboutApp': '關於小智智控台',
|
|
||||||
'settings.aboutContent': '小智智控台\n\n基於 Vue.js 3 + uni-app 構建的跨平台移動端管理應用,為小智ESP32智能硬體提供設備管理、智能體配置等功能。\n\n© 2025 xiaozhi-esp32-server {version}',
|
|
||||||
'settings.restartSuccess': '已保存,可稍後手動重啟應用',
|
|
||||||
'settings.serverUrlSavedAndCacheCleared': '服務端地址已保存,緩存已清除',
|
|
||||||
'settings.resetToDefaultAndCacheCleared': '已恢復默認設置,緩存已清除',
|
|
||||||
'settings.resetSuccess': '重置成功',
|
|
||||||
'settings.enterServerUrl': '請輸入服務端地址',
|
|
||||||
'settings.clearCacheFailed': '清除緩存失敗',
|
|
||||||
'settings.cacheManagement': '緩存管理',
|
|
||||||
'settings.totalCacheSize': '總緩存大小',
|
|
||||||
'settings.appDataSize': '應用數據總大小',
|
|
||||||
'settings.cacheClear': '緩存清理',
|
|
||||||
'settings.clearAllCache': '清空所有緩存數據',
|
|
||||||
'settings.clearCache': '清除緩存',
|
|
||||||
'settings.modifyWillClearCache': '修改將清除緩存',
|
|
||||||
'settings.appInfo': '應用信息',
|
|
||||||
'settings.aboutUs': '關於我們',
|
|
||||||
'settings.appVersion': '應用版本與團隊信息',
|
|
||||||
'settings.confirmClear': '確認清除',
|
|
||||||
'settings.confirmClearMessage': '確定要清除所有緩存嗎?這將刪除所有數據包括登錄狀態,需要重新登錄。',
|
|
||||||
'settings.cacheCleared': '緩存清除成功,即將跳轉到登錄頁',
|
|
||||||
'settings.languageSettings': '語言設置',
|
|
||||||
'settings.language': '語言',
|
|
||||||
'settings.selectLanguage': '選擇語言',
|
|
||||||
'settings.languageChanged': '語言切換成功',
|
|
||||||
|
|
||||||
// 消息提示
|
|
||||||
'message.loginSuccess': '登錄成功!',
|
|
||||||
'message.loginFail': '登錄失敗',
|
|
||||||
'message.registerSuccess': '註冊成功',
|
|
||||||
'message.registerFail': '註冊失敗',
|
|
||||||
'message.saveSuccess': '保存成功',
|
|
||||||
'message.saveFail': '保存失敗',
|
|
||||||
'message.deleteSuccess': '刪除成功',
|
|
||||||
'message.deleteFail': '刪除失敗',
|
|
||||||
'message.bindSuccess': '綁定成功',
|
|
||||||
'message.bindFail': '綁定失敗',
|
|
||||||
'message.unbindSuccess': '解除綁定成功',
|
|
||||||
'message.unbindFail': '解除綁定失敗',
|
|
||||||
'message.networkError': '網絡錯誤,請檢查網絡連接',
|
|
||||||
'message.serverError': '服務器錯誤,請稍後再試',
|
|
||||||
'message.invalidAddress': '地址可能無效,請檢查服務端是否啟動或網絡連接是否正常; 也可能因HTTPS協定問題導致無法發送請求常',
|
|
||||||
'message.languageChanged': '語言已切換',
|
|
||||||
'message.passwordError': '帳號或密碼錯誤',
|
|
||||||
'message.phoneRegistered': '此手機號已經註冊過',
|
|
||||||
|
|
||||||
// Agent工具頁面
|
|
||||||
'agent.tools.pageTitle': 'Agent工具',
|
|
||||||
'agent.tools.unselected': '未選',
|
|
||||||
'agent.tools.selected': '已選',
|
|
||||||
'agent.tools.noMorePlugins': '暫無更多插件',
|
|
||||||
'agent.tools.pleaseSelectPlugin': '請選擇插件功能',
|
|
||||||
'agent.tools.builtInPlugins': '內置插件',
|
|
||||||
'agent.tools.mcpAccessPoint': 'mcp接入點',
|
|
||||||
'agent.tools.copy': '複製',
|
|
||||||
'agent.tools.noTools': '暫無工具',
|
|
||||||
'agent.tools.parameterConfig': '參數配置',
|
|
||||||
'agent.tools.noParamsNeeded': '無需配置參數',
|
|
||||||
'agent.tools.pleaseInput': '請輸入',
|
|
||||||
'agent.tools.inputOneItemPerLine': '每行輸入一個項目',
|
|
||||||
'agent.tools.pleaseInputValidJson': '請輸入有效的JSON格式',
|
|
||||||
'agent.tools.enableFunction': '啟用功能',
|
|
||||||
'agent.tools.toggleFunction': '開啟或關閉此功能',
|
|
||||||
'agent.tools.jsonFormatError': 'JSON格式錯誤',
|
|
||||||
'agent.tools.noMcpAddressToCopy': '暫無MCP地址可複製',
|
|
||||||
'agent.tools.mcpAddressCopied': 'MCP地址已複製到剪貼簿',
|
|
||||||
'agent.tools.copyFailed': '複製失敗,請重試',
|
|
||||||
'agent.tools.defaultValue': '默認值',
|
|
||||||
'agent.tools.notSelected': '未選',
|
|
||||||
'agent.tools.clickToConfigure': '點擊配置',
|
|
||||||
'agent.tools.mcpEndpoint': 'MCP接入點',
|
|
||||||
'agent.tools.eachLineOneItem': '每行輸入一個項目',
|
|
||||||
|
|
||||||
// 設備配置頁面
|
|
||||||
'deviceConfig.pageTitle': '設備配置',
|
|
||||||
'deviceConfig.wifiConfig': 'WiFi配網',
|
|
||||||
'deviceConfig.ultrasonicConfig': '超聲波配網',
|
|
||||||
'deviceConfig.selectConfigMethod': '選擇配網方式',
|
|
||||||
'deviceConfig.networkConfig': '網絡配置',
|
|
||||||
'deviceConfig.selectedNetwork': '選中網絡',
|
|
||||||
'deviceConfig.signal': '信號',
|
|
||||||
'deviceConfig.openNetwork': '開放網絡',
|
|
||||||
'deviceConfig.encryptedNetwork': '加密網絡',
|
|
||||||
'deviceConfig.password': '密碼',
|
|
||||||
'deviceConfig.pleaseEnterPassword': '請輸入WiFi密碼',
|
|
||||||
'deviceConfig.startConfig': '開始配網',
|
|
||||||
'deviceConfig.connectToXiaozhiHotspot': '請先連接xiaozhi熱點 (xiaozhi-XXXXXX)',
|
|
||||||
'deviceConfig.detecting': '檢測中...',
|
|
||||||
'deviceConfig.reDetect': '重新檢測',
|
|
||||||
'deviceConfig.alreadyConnected': '已連接xiaozhi熱點',
|
|
||||||
'deviceConfig.refreshStatus': '刷新狀態',
|
|
||||||
'deviceConfig.wifiNetworks': 'WiFi網絡',
|
|
||||||
'deviceConfig.selectWifiNetwork': '選擇WiFi網絡',
|
|
||||||
'deviceConfig.refreshScan': '刷新掃描',
|
|
||||||
'deviceConfig.noWifiNetworks': '暫無WiFi網絡',
|
|
||||||
'deviceConfig.clickToRefreshScan': '請點擊刷新掃描',
|
|
||||||
'deviceConfig.signalStrong': '信號強',
|
|
||||||
'deviceConfig.signalGood': '信號良好',
|
|
||||||
'deviceConfig.signalFair': '信號一般',
|
|
||||||
'deviceConfig.signalWeak': '信號弱',
|
|
||||||
'deviceConfig.channel': '頻道',
|
|
||||||
'deviceConfig.about': '約',
|
|
||||||
'deviceConfig.seconds': '秒',
|
|
||||||
'deviceConfig.generating': '生成中...',
|
|
||||||
'deviceConfig.playing': '播放中...',
|
|
||||||
'deviceConfig.generateAndPlaySoundWave': '生成並播放聲波',
|
|
||||||
'deviceConfig.playSoundWave': '播放聲波',
|
|
||||||
'deviceConfig.stopPlaying': '停止播放',
|
|
||||||
'deviceConfig.autoLoopPlaySoundWave': '自動循環播放聲波',
|
|
||||||
'deviceConfig.configAudioFile': '配網音頻文件',
|
|
||||||
'deviceConfig.duration': '時長',
|
|
||||||
'deviceConfig.ultrasonicConfigInstructions': '超聲波配網說明',
|
|
||||||
'deviceConfig.ensureWifiNetworkSelectedAndPasswordEntered': '確保已選擇WiFi網絡並輸入密碼',
|
|
||||||
'deviceConfig.clickGenerateAndPlaySoundWave': '點擊生成並播放聲波,系統會將配網信息編碼為音頻',
|
|
||||||
'deviceConfig.bringPhoneCloseToXiaozhiDevice': '將手機靠近xiaozhi設備(距離1-2米)',
|
|
||||||
'deviceConfig.duringAudioPlaybackXiaozhiWillReceive': '音頻播放時,xiaozhi會接收並解碼配網信息',
|
|
||||||
'deviceConfig.afterConfigSuccessDeviceWillConnect': '配網成功後設備會自動連接WiFi網絡',
|
|
||||||
'deviceConfig.usesAfskModulation': '使用AFSK調制技術,通過1800Hz和1500Hz頻率傳輸數據',
|
|
||||||
'deviceConfig.ensureModeratePhoneVolume': '請確保手機音量適中,避免環境噪音干擾',
|
|
||||||
'deviceConfig.generatingUltrasonicConfigAudio': '生成超聲波配網音頻',
|
|
||||||
'deviceConfig.configData': '配網數據',
|
|
||||||
'deviceConfig.dataBytesLength': '數據字節長度',
|
|
||||||
'deviceConfig.bitStreamLength': '比特流長度',
|
|
||||||
'deviceConfig.base64Length': 'base64長度',
|
|
||||||
'deviceConfig.audioFileTooLarge': '音頻文件過大,請縮短SSID或密碼長度',
|
|
||||||
'deviceConfig.audioGenerationSuccess': '音頻生成成功',
|
|
||||||
'deviceConfig.samplePoints': '採樣點數',
|
|
||||||
'deviceConfig.soundWaveGenerationSuccess': '聲波生成成功',
|
|
||||||
'deviceConfig.audioGenerationFailed': '音頻生成失敗',
|
|
||||||
'deviceConfig.soundWaveGenerationFailed': '聲波生成失敗',
|
|
||||||
'deviceConfig.pleaseGenerateAudioFirst': '請先生成音頻',
|
|
||||||
'deviceConfig.startPlayingUltrasonicConfigAudio': '開始播放超聲波配網音頻',
|
|
||||||
'deviceConfig.ultrasonicAudioStartedPlaying': '超聲波音頻開始播放',
|
|
||||||
'deviceConfig.startPlayingConfigSoundWave': '開始播放配網聲波',
|
|
||||||
'deviceConfig.ultrasonicAudioPlaybackEnded': '超聲波音頻播放結束',
|
|
||||||
'deviceConfig.audioPlaybackFailed': '音頻播放失敗',
|
|
||||||
'deviceConfig.audioResourceBusy': '音頻資源繁忙,請稍後重試',
|
|
||||||
'deviceConfig.audioFormatNotSupported': '音頻格式不支援,可能是data URI問題',
|
|
||||||
'deviceConfig.audioFileError': '音頻文件錯誤',
|
|
||||||
'deviceConfig.cleaningUpAudioContext': '清理音頻上下文',
|
|
||||||
'deviceConfig.cleaningUpAudioContextFailed': '清理音頻上下文失敗',
|
|
||||||
'deviceConfig.stoppedPlayingUltrasonicAudio': '停止播放超聲波音頻',
|
|
||||||
'deviceConfig.stoppedPlaying': '已停止播放',
|
|
||||||
'deviceConfig.configMethod': '配網方式',
|
|
||||||
'deviceConfig.enterWifiPassword': '請輸入WiFi密碼',
|
|
||||||
'deviceConfig.xiaozhi': 'xiaozhi',
|
|
||||||
'deviceConfig.connectXiaozhiHotspot': '請連接xiaozhi熱點',
|
|
||||||
'deviceConfig.wifiScanResponse': 'WiFi掃描響應',
|
|
||||||
'deviceConfig.scanSuccess': '掃描成功',
|
|
||||||
'deviceConfig.networks': '個網絡',
|
|
||||||
'deviceConfig.wifiScanFailed': 'WiFi掃描失敗',
|
|
||||||
'deviceConfig.scanFailedCheckConnection': '掃描失敗,請檢查連接',
|
|
||||||
'deviceConfig.checking': '檢查中',
|
|
||||||
'deviceConfig.reCheck': '重新檢查',
|
|
||||||
'deviceConfig.connectedXiaozhiHotspot': '已連接xiaozhi熱點',
|
|
||||||
'deviceConfig.wifiNetwork': 'WiFi網絡',
|
|
||||||
'deviceConfig.wifiPassword': 'WiFi密碼',
|
|
||||||
'deviceConfig.scanning': '掃描中',
|
|
||||||
'deviceConfig.cancel': '取消',
|
|
||||||
'deviceConfig.clickRefreshScan': '請點擊刷新掃描',
|
|
||||||
'deviceConfig.esp32ConnectionCheckFailed': 'ESP32連接檢查失敗',
|
|
||||||
'deviceConfig.startWifiConfig': '開始WiFi配網',
|
|
||||||
'deviceConfig.configSuccess': '配網成功',
|
|
||||||
'deviceConfig.deviceWillConnectTo': '設備將連接到',
|
|
||||||
'deviceConfig.deviceWillRestart': '設備將重啟',
|
|
||||||
'deviceConfig.pleaseDisconnectXiaozhiHotspot': '請斷開xiaozhi熱點連接',
|
|
||||||
'deviceConfig.configFailed': '配網失敗',
|
|
||||||
'deviceConfig.wifiConfigFailed': 'WiFi配網失敗',
|
|
||||||
'deviceConfig.pleaseCheckNetworkConnection': '請檢查網絡連接',
|
|
||||||
'deviceConfig.startWifiConfigButton': '開始配網',
|
|
||||||
'deviceConfig.configuring': '配網中...',
|
|
||||||
'deviceConfig.wifiConfigInstructions': 'WiFi配網說明',
|
|
||||||
'deviceConfig.phoneConnectXiaozhiHotspot': '手機連接xiaozhi熱點',
|
|
||||||
'deviceConfig.selectTargetWifiNetwork': '選擇目標WiFi網絡',
|
|
||||||
'deviceConfig.enterWifiPasswordIfNeeded': '如有需要請輸入WiFi密碼',
|
|
||||||
'deviceConfig.clickStartConfigAndWait': '點擊開始配網並等待',
|
|
||||||
'deviceConfig.afterConfigSuccessDeviceWillRestart': '配網成功後設備將自動重啟',
|
|
||||||
'deviceConfig.audioPlaybackError': '音頻播放錯誤',
|
|
||||||
'deviceConfig.playbackFailed': '播放失敗',
|
|
||||||
|
|
||||||
// Voiceprint page
|
|
||||||
'voiceprint.audioNotExist': '該音頻不存在',
|
|
||||||
'voiceprint.getAudioFailed': '獲取音頻失敗',
|
|
||||||
'voiceprint.audioPlayFailed': '音頻播放失敗',
|
|
||||||
}
|
|
||||||
|
|
@ -7,7 +7,7 @@ const customTabbarEnable
|
||||||
= selectedTabbarStrategy === TABBAR_MAP.CUSTOM_TABBAR_WITH_CACHE
|
= selectedTabbarStrategy === TABBAR_MAP.CUSTOM_TABBAR_WITH_CACHE
|
||||||
|| selectedTabbarStrategy === TABBAR_MAP.CUSTOM_TABBAR_WITHOUT_CACHE
|
|| selectedTabbarStrategy === TABBAR_MAP.CUSTOM_TABBAR_WITHOUT_CACHE
|
||||||
|
|
||||||
/** tabbarList 里面的 path 从 pages.config.ts 得到 */
|
/** Path in tabbarList comes from pages.config.ts */
|
||||||
const tabbarList = _tabBarList.map(item => ({ ...item, path: `/${item.pagePath}` }))
|
const tabbarList = _tabBarList.map(item => ({ ...item, path: `/${item.pagePath}` }))
|
||||||
function selectTabBar({ value: index }: { value: number }) {
|
function selectTabBar({ value: index }: { value: number }) {
|
||||||
const url = tabbarList[index].path
|
const url = tabbarList[index].path
|
||||||
|
|
@ -20,7 +20,7 @@ function selectTabBar({ value: index }: { value: number }) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
onLoad(() => {
|
onLoad(() => {
|
||||||
// 解决原生 tabBar 未隐藏导致有2个 tabBar 的问题
|
// Solve the problem of having 2 tabBars due to native tabBar not being hidden
|
||||||
const hideRedundantTabbarEnable = selectedTabbarStrategy === TABBAR_MAP.CUSTOM_TABBAR_WITH_CACHE
|
const hideRedundantTabbarEnable = selectedTabbarStrategy === TABBAR_MAP.CUSTOM_TABBAR_WITH_CACHE
|
||||||
hideRedundantTabbarEnable
|
hideRedundantTabbarEnable
|
||||||
&& uni.hideTabBar({
|
&& uni.hideTabBar({
|
||||||
|
|
|
||||||
|
|
@ -1,17 +1,17 @@
|
||||||
# tabbar 说明
|
# Tabbar Description
|
||||||
|
|
||||||
`tabbar` 分为 `4 种` 情况:
|
`tabbar` is divided into `4 types` of situations:
|
||||||
|
|
||||||
- 0 `无 tabbar`,只有一个页面入口,底部无 `tabbar` 显示;常用语临时活动页。
|
- 0 `No tabbar`, only one page entry, no `tabbar` display at bottom; commonly used for temporary activity pages.
|
||||||
- 1 `原生 tabbar`,使用 `switchTab` 切换 tabbar,`tabbar` 页面有缓存。
|
- 1 `Native tabbar`, uses `switchTab` to switch tabbar, `tabbar` pages have cache.
|
||||||
- 优势:原生自带的 tabbar,最先渲染,有缓存。
|
- Advantages: Native built-in tabbar, renders first, has cache.
|
||||||
- 劣势:只能使用 2 组图片来切换选中和非选中状态,修改颜色只能重新换图片(或者用 iconfont)。
|
- Disadvantages: Can only use 2 sets of images to switch selected and unselected states, changing colors requires replacing images (or using iconfont).
|
||||||
- 2 `有缓存自定义 tabbar`,使用 `switchTab` 切换 tabbar,`tabbar` 页面有缓存。使用了第三方 UI 库的 `tabbar` 组件,并隐藏了原生 `tabbar` 的显示。
|
- 2 `Cached custom tabbar`, uses `switchTab` to switch tabbar, `tabbar` pages have cache. Uses third-party UI library `tabbar` component and hides native `tabbar` display.
|
||||||
- 优势:可以随意配置自己想要的 `svg icon`,切换字体颜色方便。有缓存。可以实现各种花里胡哨的动效等。
|
- Advantages: Can freely configure desired `svg icon`, easy to switch font colors. Has cache. Can implement various fancy animations etc.
|
||||||
- 劣势:首次点击 tababr 会闪烁。
|
- Disadvantages: First click on tabbar will flicker.
|
||||||
- 3 `无缓存自定义 tabbar`,使用 `navigateTo` 切换 `tabbar`,`tabbar` 页面无缓存。使用了第三方 UI 库的 `tabbar` 组件。
|
- 3 `No-cache custom tabbar`, uses `navigateTo` to switch `tabbar`, `tabbar` pages have no cache. Uses third-party UI library `tabbar` component.
|
||||||
- 优势:可以随意配置自己想要的 svg icon,切换字体颜色方便。可以实现各种花里胡哨的动效等。
|
- Advantages: Can freely configure desired svg icons, easy to switch font colors. Can implement various fancy animations etc.
|
||||||
- 劣势:首次点击 `tababr` 会闪烁,无缓存。
|
- Disadvantages: First click on `tabbar` will flicker, no cache.
|
||||||
|
|
||||||
|
|
||||||
> 注意:花里胡哨的效果需要自己实现,本模版不提供。
|
> Note: Fancy effects need to be implemented by yourself, this template does not provide them.
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
/**
|
/**
|
||||||
* tabbar 状态,增加 storageSync 保证刷新浏览器时在正确的 tabbar 页面
|
* Tabbar state, add storageSync to ensure correct tabbar page when refreshing browser
|
||||||
* 使用reactive简单状态,而不是 pinia 全局状态
|
* Use reactive simple state instead of pinia global state
|
||||||
*/
|
*/
|
||||||
export const tabbarStore = reactive({
|
export const tabbarStore = reactive({
|
||||||
curIdx: uni.getStorageSync('app-tabbar-index') || 0,
|
curIdx: uni.getStorageSync('app-tabbar-index') || 0,
|
||||||
|
|
|
||||||
|
|
@ -6,13 +6,13 @@ type FgTabBarItem = TabBar['list'][0] & {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* tabbar 选择的策略,更详细的介绍见 tabbar.md 文件
|
* Tabbar selection strategy, see tabbar.md file for more detailed introduction
|
||||||
* 0: 'NO_TABBAR' `无 tabbar`
|
* 0: 'NO_TABBAR' `No tabbar`
|
||||||
* 1: 'NATIVE_TABBAR' `完全原生 tabbar`
|
* 1: 'NATIVE_TABBAR' `Fully native tabbar`
|
||||||
* 2: 'CUSTOM_TABBAR_WITH_CACHE' `有缓存自定义 tabbar`
|
* 2: 'CUSTOM_TABBAR_WITH_CACHE' `Custom tabbar with cache`
|
||||||
* 3: 'CUSTOM_TABBAR_WITHOUT_CACHE' `无缓存自定义 tabbar`
|
* 3: 'CUSTOM_TABBAR_WITHOUT_CACHE' `Custom tabbar without cache`
|
||||||
*
|
*
|
||||||
* 温馨提示:本文件的任何代码更改了之后,都需要重新运行,否则 pages.json 不会更新导致错误
|
* Friendly reminder: After any code changes in this file, need to restart, otherwise pages.json will not update causing errors
|
||||||
*/
|
*/
|
||||||
export const TABBAR_MAP = {
|
export const TABBAR_MAP = {
|
||||||
NO_TABBAR: 0,
|
NO_TABBAR: 0,
|
||||||
|
|
@ -20,27 +20,27 @@ export const TABBAR_MAP = {
|
||||||
CUSTOM_TABBAR_WITH_CACHE: 2,
|
CUSTOM_TABBAR_WITH_CACHE: 2,
|
||||||
CUSTOM_TABBAR_WITHOUT_CACHE: 3,
|
CUSTOM_TABBAR_WITHOUT_CACHE: 3,
|
||||||
}
|
}
|
||||||
// TODO:通过这里切换使用tabbar的策略
|
// TODO: Switch tabbar strategy here
|
||||||
export const selectedTabbarStrategy = TABBAR_MAP.NATIVE_TABBAR
|
export const selectedTabbarStrategy = TABBAR_MAP.NATIVE_TABBAR
|
||||||
|
|
||||||
// selectedTabbarStrategy==NATIVE_TABBAR(1) 时,需要填 iconPath 和 selectedIconPath
|
// When selectedTabbarStrategy==NATIVE_TABBAR(1), need to fill iconPath and selectedIconPath
|
||||||
// selectedTabbarStrategy==CUSTOM_TABBAR(2,3) 时,需要填 icon 和 iconType
|
// When selectedTabbarStrategy==CUSTOM_TABBAR(2,3), need to fill icon and iconType
|
||||||
// selectedTabbarStrategy==NO_TABBAR(0) 时,tabbarList 不生效
|
// When selectedTabbarStrategy==NO_TABBAR(0), tabbarList is not effective
|
||||||
export const tabbarList: FgTabBarItem[] = [
|
export const tabbarList: FgTabBarItem[] = [
|
||||||
{
|
{
|
||||||
iconPath: 'static/tabbar/robot.png',
|
iconPath: 'static/tabbar/robot.png',
|
||||||
selectedIconPath: 'static/tabbar/robot_activate.png',
|
selectedIconPath: 'static/tabbar/robot_activate.png',
|
||||||
pagePath: 'pages/index/index',
|
pagePath: 'pages/index/index',
|
||||||
text: '首页',
|
text: 'Home',
|
||||||
icon: 'home',
|
icon: 'home',
|
||||||
// 选用 UI 框架自带的 icon 时,iconType 为 uiLib
|
// When using UI framework built-in icon, iconType is uiLib
|
||||||
iconType: 'uiLib',
|
iconType: 'uiLib',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
iconPath: 'static/tabbar/network.png',
|
iconPath: 'static/tabbar/network.png',
|
||||||
selectedIconPath: 'static/tabbar/network_activate.png',
|
selectedIconPath: 'static/tabbar/network_activate.png',
|
||||||
pagePath: 'pages/device-config/index',
|
pagePath: 'pages/device-config/index',
|
||||||
text: '配网',
|
text: 'Network Config',
|
||||||
icon: 'i-carbon-network-3',
|
icon: 'i-carbon-network-3',
|
||||||
iconType: 'uiLib',
|
iconType: 'uiLib',
|
||||||
},
|
},
|
||||||
|
|
@ -48,18 +48,18 @@ export const tabbarList: FgTabBarItem[] = [
|
||||||
iconPath: 'static/tabbar/system.png',
|
iconPath: 'static/tabbar/system.png',
|
||||||
selectedIconPath: 'static/tabbar/system_activate.png',
|
selectedIconPath: 'static/tabbar/system_activate.png',
|
||||||
pagePath: 'pages/settings/index',
|
pagePath: 'pages/settings/index',
|
||||||
text: '系统',
|
text: 'System',
|
||||||
icon: 'i-carbon-settings',
|
icon: 'i-carbon-settings',
|
||||||
iconType: 'uiLib',
|
iconType: 'uiLib',
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
|
|
||||||
// NATIVE_TABBAR(1) 和 CUSTOM_TABBAR_WITH_CACHE(2) 时,需要tabbar缓存
|
// When NATIVE_TABBAR(1) and CUSTOM_TABBAR_WITH_CACHE(2), tabbar cache is needed
|
||||||
export const cacheTabbarEnable = selectedTabbarStrategy === TABBAR_MAP.NATIVE_TABBAR
|
export const cacheTabbarEnable = selectedTabbarStrategy === TABBAR_MAP.NATIVE_TABBAR
|
||||||
|| selectedTabbarStrategy === TABBAR_MAP.CUSTOM_TABBAR_WITH_CACHE
|
|| selectedTabbarStrategy === TABBAR_MAP.CUSTOM_TABBAR_WITH_CACHE
|
||||||
|
|
||||||
const _tabbar: TabBar = {
|
const _tabbar: TabBar = {
|
||||||
// 只有微信小程序支持 custom。App 和 H5 不生效
|
// Only WeChat Mini Program supports custom. App and H5 are not effective
|
||||||
custom: selectedTabbarStrategy === TABBAR_MAP.CUSTOM_TABBAR_WITH_CACHE,
|
custom: selectedTabbarStrategy === TABBAR_MAP.CUSTOM_TABBAR_WITH_CACHE,
|
||||||
color: '#e6e6e6',
|
color: '#e6e6e6',
|
||||||
selectedColor: '#667dea',
|
selectedColor: '#667dea',
|
||||||
|
|
@ -72,5 +72,5 @@ const _tabbar: TabBar = {
|
||||||
list: tabbarList as unknown as TabBar['list'],
|
list: tabbarList as unknown as TabBar['list'],
|
||||||
}
|
}
|
||||||
|
|
||||||
// 0和1 需要显示底部的tabbar的各种配置,以利用缓存
|
// 0 and 1 need to display various configurations of bottom tabbar to utilize cache
|
||||||
export const tabBar = cacheTabbarEnable ? _tabbar : undefined
|
export const tabBar = cacheTabbarEnable ? _tabbar : undefined
|
||||||
|
|
|
||||||
|
|
@ -7,19 +7,12 @@ import store from './store'
|
||||||
import '@/style/index.scss'
|
import '@/style/index.scss'
|
||||||
import 'virtual:uno.css'
|
import 'virtual:uno.css'
|
||||||
|
|
||||||
// 导入国际化相关功能
|
|
||||||
import { initI18n } from './i18n'
|
|
||||||
import { useLangStore } from './store/lang'
|
|
||||||
|
|
||||||
export function createApp() {
|
export function createApp() {
|
||||||
const app = createSSRApp(App)
|
const app = createSSRApp(App)
|
||||||
app.use(store)
|
app.use(store)
|
||||||
app.use(routeInterceptor)
|
app.use(routeInterceptor)
|
||||||
app.use(VueQueryPlugin)
|
app.use(VueQueryPlugin)
|
||||||
|
|
||||||
// 初始化国际化
|
|
||||||
initI18n()
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
app,
|
app,
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
{
|
{
|
||||||
"name": "小智",
|
"name": "Xiao Zhi",
|
||||||
"appid": "__UNI__36A515E",
|
"appid": "__UNI__36A515E",
|
||||||
"description": "",
|
"description": "",
|
||||||
"versionName": "1.0.0",
|
"versionName": "1.0.0",
|
||||||
|
|
@ -97,7 +97,7 @@
|
||||||
},
|
},
|
||||||
"permission": {
|
"permission": {
|
||||||
"scope.userLocation": {
|
"scope.userLocation": {
|
||||||
"desc": "WiFi配网功能需要获取位置权限"
|
"desc": "WiFi configuration function requires location permission"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"requiredPrivateInfos": [
|
"requiredPrivateInfos": [
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
{
|
{
|
||||||
"layout": "default",
|
"layout": "default",
|
||||||
"style": {
|
"style": {
|
||||||
"navigationBarTitleText": "分包页面"
|
"navigationBarTitleText": "Sub-package Page"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</route>
|
</route>
|
||||||
|
|
@ -17,7 +17,7 @@
|
||||||
http://localhost:9000/#/pages-sub/demo/index
|
http://localhost:9000/#/pages-sub/demo/index
|
||||||
</view>
|
</view>
|
||||||
<view class="text-green-500">
|
<view class="text-green-500">
|
||||||
分包页面demo
|
Sub-package page demo
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</template>
|
</template>
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
{
|
{
|
||||||
"globalStyle": {
|
"globalStyle": {
|
||||||
"navigationStyle": "default",
|
"navigationStyle": "default",
|
||||||
"navigationBarTitleText": "智控台",
|
"navigationBarTitleText": "XiaoZhi",
|
||||||
"navigationBarBackgroundColor": "#f8f8f8",
|
"navigationBarBackgroundColor": "#f8f8f8",
|
||||||
"navigationBarTextStyle": "black",
|
"navigationBarTextStyle": "black",
|
||||||
"backgroundColor": "#FFFFFF"
|
"backgroundColor": "#FFFFFF"
|
||||||
|
|
@ -29,7 +29,7 @@
|
||||||
"iconPath": "static/tabbar/robot.png",
|
"iconPath": "static/tabbar/robot.png",
|
||||||
"selectedIconPath": "static/tabbar/robot_activate.png",
|
"selectedIconPath": "static/tabbar/robot_activate.png",
|
||||||
"pagePath": "pages/index/index",
|
"pagePath": "pages/index/index",
|
||||||
"text": "首页",
|
"text": "Home",
|
||||||
"icon": "home",
|
"icon": "home",
|
||||||
"iconType": "uiLib"
|
"iconType": "uiLib"
|
||||||
},
|
},
|
||||||
|
|
@ -37,7 +37,7 @@
|
||||||
"iconPath": "static/tabbar/network.png",
|
"iconPath": "static/tabbar/network.png",
|
||||||
"selectedIconPath": "static/tabbar/network_activate.png",
|
"selectedIconPath": "static/tabbar/network_activate.png",
|
||||||
"pagePath": "pages/device-config/index",
|
"pagePath": "pages/device-config/index",
|
||||||
"text": "配网",
|
"text": "Network Config",
|
||||||
"icon": "i-carbon-network-3",
|
"icon": "i-carbon-network-3",
|
||||||
"iconType": "uiLib"
|
"iconType": "uiLib"
|
||||||
},
|
},
|
||||||
|
|
@ -45,7 +45,7 @@
|
||||||
"iconPath": "static/tabbar/system.png",
|
"iconPath": "static/tabbar/system.png",
|
||||||
"selectedIconPath": "static/tabbar/system_activate.png",
|
"selectedIconPath": "static/tabbar/system_activate.png",
|
||||||
"pagePath": "pages/settings/index",
|
"pagePath": "pages/settings/index",
|
||||||
"text": "系统",
|
"text": "System",
|
||||||
"icon": "i-carbon-settings",
|
"icon": "i-carbon-settings",
|
||||||
"iconType": "uiLib"
|
"iconType": "uiLib"
|
||||||
}
|
}
|
||||||
|
|
@ -58,7 +58,7 @@
|
||||||
"layout": "tabbar",
|
"layout": "tabbar",
|
||||||
"style": {
|
"style": {
|
||||||
"navigationStyle": "custom",
|
"navigationStyle": "custom",
|
||||||
"navigationBarTitleText": "首页"
|
"navigationBarTitleText": "Home"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
@ -70,7 +70,25 @@
|
||||||
"type": "page",
|
"type": "page",
|
||||||
"layout": "default",
|
"layout": "default",
|
||||||
"style": {
|
"style": {
|
||||||
"navigationBarTitleText": "智能体",
|
"navigationBarTitleText": "Agent",
|
||||||
|
"navigationStyle": "custom"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"path": "pages/agent/provider",
|
||||||
|
"type": "page",
|
||||||
|
"layout": "default",
|
||||||
|
"style": {
|
||||||
|
"navigationBarTitleText": "Edit Sources",
|
||||||
|
"navigationStyle": "custom"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"path": "pages/agent/speedPitch",
|
||||||
|
"type": "page",
|
||||||
|
"layout": "default",
|
||||||
|
"style": {
|
||||||
|
"navigationBarTitleText": "Voice Settings",
|
||||||
"navigationStyle": "custom"
|
"navigationStyle": "custom"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
@ -79,7 +97,7 @@
|
||||||
"type": "page",
|
"type": "page",
|
||||||
"layout": "default",
|
"layout": "default",
|
||||||
"style": {
|
"style": {
|
||||||
"navigationBarTitleText": "编辑功能",
|
"navigationBarTitleText": "Edit Functions",
|
||||||
"navigationStyle": "custom"
|
"navigationStyle": "custom"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
@ -89,7 +107,7 @@
|
||||||
"layout": "default",
|
"layout": "default",
|
||||||
"style": {
|
"style": {
|
||||||
"navigationStyle": "custom",
|
"navigationStyle": "custom",
|
||||||
"navigationBarTitleText": "聊天详情"
|
"navigationBarTitleText": "Chat Details"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
@ -104,7 +122,7 @@
|
||||||
"path": "pages/device-config/index",
|
"path": "pages/device-config/index",
|
||||||
"type": "page",
|
"type": "page",
|
||||||
"style": {
|
"style": {
|
||||||
"navigationBarTitleText": "设备配置",
|
"navigationBarTitleText": "Device Configuration",
|
||||||
"navigationStyle": "custom"
|
"navigationStyle": "custom"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
@ -126,13 +144,31 @@
|
||||||
"navigationBarTitleText": "Login"
|
"navigationBarTitleText": "Login"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"path": "pages/login/privacy-policy-en",
|
||||||
|
"type": "page",
|
||||||
|
"layout": "default",
|
||||||
|
"style": {
|
||||||
|
"navigationStyle": "custom",
|
||||||
|
"navigationBarTitleText": "Privacy Policy"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"path": "pages/login/user-agreement-en",
|
||||||
|
"type": "page",
|
||||||
|
"layout": "default",
|
||||||
|
"style": {
|
||||||
|
"navigationStyle": "custom",
|
||||||
|
"navigationBarTitleText": "User Agreement"
|
||||||
|
}
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"path": "pages/register/index",
|
"path": "pages/register/index",
|
||||||
"type": "page",
|
"type": "page",
|
||||||
"layout": "default",
|
"layout": "default",
|
||||||
"style": {
|
"style": {
|
||||||
"navigationStyle": "custom",
|
"navigationStyle": "custom",
|
||||||
"navigationBarTitleText": "注册"
|
"navigationBarTitleText": "Register"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
@ -140,7 +176,7 @@
|
||||||
"type": "page",
|
"type": "page",
|
||||||
"layout": "default",
|
"layout": "default",
|
||||||
"style": {
|
"style": {
|
||||||
"navigationBarTitleText": "设置",
|
"navigationBarTitleText": "Settings",
|
||||||
"navigationStyle": "custom"
|
"navigationStyle": "custom"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
@ -158,7 +194,7 @@
|
||||||
"type": "page",
|
"type": "page",
|
||||||
"layout": "default",
|
"layout": "default",
|
||||||
"style": {
|
"style": {
|
||||||
"navigationBarTitleText": "分包页面"
|
"navigationBarTitleText": "Sub-package Page"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
|
||||||
File diff suppressed because it is too large
Load diff
|
|
@ -2,7 +2,7 @@
|
||||||
{
|
{
|
||||||
"layout": "default",
|
"layout": "default",
|
||||||
"style": {
|
"style": {
|
||||||
"navigationBarTitleText": "智能体",
|
"navigationBarTitleText": "Agent",
|
||||||
"navigationStyle": "custom"
|
"navigationStyle": "custom"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -12,7 +12,6 @@
|
||||||
import { onLoad } from '@dcloudio/uni-app'
|
import { onLoad } from '@dcloudio/uni-app'
|
||||||
import { computed, onMounted, ref } from 'vue'
|
import { computed, onMounted, ref } from 'vue'
|
||||||
import CustomTabs from '@/components/custom-tabs/index.vue'
|
import CustomTabs from '@/components/custom-tabs/index.vue'
|
||||||
import { t } from '@/i18n'
|
|
||||||
import ChatHistory from '@/pages/chat-history/index.vue'
|
import ChatHistory from '@/pages/chat-history/index.vue'
|
||||||
import DeviceManagement from '@/pages/device/index.vue'
|
import DeviceManagement from '@/pages/device/index.vue'
|
||||||
import VoiceprintManagement from '@/pages/voiceprint/index.vue'
|
import VoiceprintManagement from '@/pages/voiceprint/index.vue'
|
||||||
|
|
@ -22,7 +21,7 @@ defineOptions({
|
||||||
name: 'AgentIndex',
|
name: 'AgentIndex',
|
||||||
})
|
})
|
||||||
|
|
||||||
// 获取屏幕边界到安全区域距离
|
// Get distance from screen boundary to safe area
|
||||||
let safeAreaInsets: any
|
let safeAreaInsets: any
|
||||||
let systemInfo: any
|
let systemInfo: any
|
||||||
|
|
||||||
|
|
@ -43,67 +42,67 @@ systemInfo = uni.getSystemInfoSync()
|
||||||
safeAreaInsets = systemInfo.safeAreaInsets
|
safeAreaInsets = systemInfo.safeAreaInsets
|
||||||
// #endif
|
// #endif
|
||||||
|
|
||||||
// 智能体ID
|
|
||||||
|
// Agent ID
|
||||||
const currentAgentId = ref('default')
|
const currentAgentId = ref('default')
|
||||||
|
|
||||||
// 当前 tab
|
// Current tab
|
||||||
const currentTab = ref('agent-config')
|
const currentTab = ref('agent-config')
|
||||||
|
|
||||||
// 刷新和加载状态
|
// Refresh and loading status
|
||||||
const refreshing = ref(false)
|
const refreshing = ref(false)
|
||||||
const refresherEnabled = ref(false)
|
|
||||||
|
|
||||||
// 子组件引用
|
// Calculate whether to enable pull-to-refresh (not enabled on role edit page)
|
||||||
|
const refresherEnabled = computed(() => {
|
||||||
|
return currentTab.value !== 'agent-config'
|
||||||
|
})
|
||||||
|
|
||||||
|
// Child component reference
|
||||||
const deviceRef = ref()
|
const deviceRef = ref()
|
||||||
const chatRef = ref()
|
const chatRef = ref()
|
||||||
const voiceprintRef = ref()
|
const voiceprintRef = ref()
|
||||||
|
|
||||||
// 更新刷新器状态
|
// Tab configuration
|
||||||
function updateRefresherEnabled(value: boolean) {
|
|
||||||
refresherEnabled.value = value
|
|
||||||
}
|
|
||||||
|
|
||||||
// Tab 配置
|
|
||||||
const tabList = [
|
const tabList = [
|
||||||
{
|
{
|
||||||
label: t('agent.roleConfig'),
|
label: 'Role Configuration',
|
||||||
value: 'agent-config',
|
value: 'agent-config',
|
||||||
icon: '/static/tabbar/robot.png',
|
icon: '/static/tabbar/robot.png',
|
||||||
activeIcon: '/static/tabbar/robot_activate.png',
|
activeIcon: '/static/tabbar/robot_activate.png',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: t('agent.deviceManagement'),
|
label: 'Device Management',
|
||||||
value: 'device-management',
|
value: 'device-management',
|
||||||
icon: '/static/tabbar/device.png',
|
icon: '/static/tabbar/device.png',
|
||||||
activeIcon: '/static/tabbar/device_activate.png',
|
activeIcon: '/static/tabbar/device_activate.png',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: t('agent.chatHistory'),
|
label: 'Chat History',
|
||||||
value: 'chat-history',
|
value: 'chat-history',
|
||||||
icon: '/static/tabbar/chat.png',
|
icon: '/static/tabbar/chat.png',
|
||||||
activeIcon: '/static/tabbar/chat_activate.png',
|
activeIcon: '/static/tabbar/chat_activate.png',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: t('agent.voiceprintManagement'),
|
label: 'Voiceprint Management',
|
||||||
value: 'voiceprint-management',
|
value: 'voiceprint-management',
|
||||||
icon: '/static/tabbar/microphone.png',
|
icon: '/static/tabbar/microphone.png',
|
||||||
activeIcon: '/static/tabbar/microphone_activate.png',
|
activeIcon: '/static/tabbar/microphone_activate.png',
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
|
|
||||||
// 返回上一页
|
// Return to previous page
|
||||||
function goBack() {
|
function goBack() {
|
||||||
uni.navigateBack()
|
uni.navigateBack()
|
||||||
}
|
}
|
||||||
|
|
||||||
// 处理 tab 切换
|
// Handle tab switching
|
||||||
function handleTabChange(item: any) {
|
function handleTabChange(item: any) {
|
||||||
console.log('Tab changed:', item)
|
console.log('Tab changed:', item)
|
||||||
}
|
}
|
||||||
|
|
||||||
// 下拉刷新
|
// Pull to refresh
|
||||||
async function onRefresh() {
|
async function onRefresh() {
|
||||||
// 角色编辑页面不需要刷新
|
// Agent edit page does not need refresh
|
||||||
if (currentTab.value === 'agent-config') {
|
if (currentTab.value === 'agent-config') {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
@ -130,55 +129,51 @@ async function onRefresh() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (error) {
|
catch (error) {
|
||||||
console.error('刷新失败:', error)
|
console.error('Refresh failed:', error)
|
||||||
}
|
}
|
||||||
finally {
|
finally {
|
||||||
refreshing.value = false
|
refreshing.value = false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 触底加载更多
|
// Load more on reach bottom
|
||||||
async function onLoadMore() {
|
async function onLoadMore() {
|
||||||
// 只有聊天记录需要加载更多
|
// Only chat history needs to load more
|
||||||
if (currentTab.value === 'chat-history' && chatRef.value?.loadMore) {
|
if (currentTab.value === 'chat-history' && chatRef.value?.loadMore) {
|
||||||
await chatRef.value.loadMore()
|
await chatRef.value.loadMore()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
watch(() => currentTab.value, (newTab) => {
|
// Receive page parameters
|
||||||
updateRefresherEnabled(newTab !== 'agent-config')
|
|
||||||
})
|
|
||||||
|
|
||||||
// 接收页面参数
|
|
||||||
onLoad((options) => {
|
onLoad((options) => {
|
||||||
if (options?.agentId) {
|
if (options?.agentId) {
|
||||||
currentAgentId.value = options.agentId
|
currentAgentId.value = options.agentId
|
||||||
console.log('接收到智能体ID:', options.agentId)
|
console.log('Received agent ID:', options.agentId)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
// 页面初始化
|
// Page initialization
|
||||||
})
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<view class="h-screen flex flex-col bg-[#f5f7fb]">
|
<view class="h-screen flex flex-col bg-[#f5f7fb]">
|
||||||
<!-- 导航栏 -->
|
<!-- Navigation Bar -->
|
||||||
<wd-navbar :title="t('agent.pageTitle')" safe-area-inset-top>
|
<wd-navbar title="Agent" safe-area-inset-top>
|
||||||
<template #left>
|
<template #left>
|
||||||
<wd-icon name="arrow-left" size="18" @click="goBack" />
|
<wd-icon name="arrow-left" size="18" @click="goBack" />
|
||||||
</template>
|
</template>
|
||||||
</wd-navbar>
|
</wd-navbar>
|
||||||
|
|
||||||
<!-- 自定义 Tabs -->
|
<!-- Custom Tabs -->
|
||||||
<CustomTabs
|
<CustomTabs
|
||||||
v-model="currentTab"
|
v-model="currentTab"
|
||||||
:tab-list="tabList"
|
:tab-list="tabList"
|
||||||
@change="handleTabChange"
|
@change="handleTabChange"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<!-- 主内容滚动区域 -->
|
<!-- Main content scroll area -->
|
||||||
<scroll-view
|
<scroll-view
|
||||||
scroll-y
|
scroll-y
|
||||||
:style="{ height: `calc(100vh - ${safeAreaInsets?.top || 0}px - 180rpx)` }"
|
:style="{ height: `calc(100vh - ${safeAreaInsets?.top || 0}px - 180rpx)` }"
|
||||||
|
|
@ -189,7 +184,7 @@ onMounted(async () => {
|
||||||
@refresherrefresh="onRefresh"
|
@refresherrefresh="onRefresh"
|
||||||
@scrolltolower="onLoadMore"
|
@scrolltolower="onLoadMore"
|
||||||
>
|
>
|
||||||
<!-- Tab 内容 -->
|
<!-- Tab content -->
|
||||||
<view class="flex-1">
|
<view class="flex-1">
|
||||||
<AgentEdit
|
<AgentEdit
|
||||||
v-if="currentTab === 'agent-config'"
|
v-if="currentTab === 'agent-config'"
|
||||||
|
|
@ -209,7 +204,6 @@ onMounted(async () => {
|
||||||
v-else-if="currentTab === 'voiceprint-management'"
|
v-else-if="currentTab === 'voiceprint-management'"
|
||||||
ref="voiceprintRef"
|
ref="voiceprintRef"
|
||||||
:agent-id="currentAgentId"
|
:agent-id="currentAgentId"
|
||||||
@update-refresher-enabled="updateRefresherEnabled"
|
|
||||||
/>
|
/>
|
||||||
</view>
|
</view>
|
||||||
</scroll-view>
|
</scroll-view>
|
||||||
|
|
|
||||||
|
|
@ -2,25 +2,29 @@
|
||||||
{
|
{
|
||||||
"layout": "default",
|
"layout": "default",
|
||||||
"style": {
|
"style": {
|
||||||
"navigationBarTitleText": "编辑源",
|
"navigationBarTitleText": "Edit Sources",
|
||||||
"navigationStyle": "custom"
|
"navigationStyle": "custom"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</route>
|
</route>
|
||||||
|
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import type { Providers } from '@/api/agent/types'
|
|
||||||
import { onMounted, ref } from 'vue'
|
import { onMounted, ref } from 'vue'
|
||||||
import { t } from '@/i18n'
|
import { t } from '@/i18n'
|
||||||
import { useProvider } from '@/store/provider'
|
import { useProvider, type ContextProvider } from '@/store/provider'
|
||||||
|
|
||||||
defineOptions({
|
defineOptions({
|
||||||
name: 'Provider',
|
name: 'Provider',
|
||||||
})
|
})
|
||||||
|
|
||||||
|
interface EditableContextProvider {
|
||||||
|
url: string
|
||||||
|
headers: { key: string, value: string }[]
|
||||||
|
}
|
||||||
|
|
||||||
const providerStore = useProvider()
|
const providerStore = useProvider()
|
||||||
|
|
||||||
const localProviders = ref<Providers[]>([])
|
const localProviders = ref<EditableContextProvider[]>([])
|
||||||
|
|
||||||
function initLocalData() {
|
function initLocalData() {
|
||||||
localProviders.value = providerStore.providers.map((p) => {
|
localProviders.value = providerStore.providers.map((p) => {
|
||||||
|
|
@ -59,7 +63,7 @@ function handleConfirm() {
|
||||||
const result = localProviders.value
|
const result = localProviders.value
|
||||||
.filter(p => p.url.trim() !== '')
|
.filter(p => p.url.trim() !== '')
|
||||||
.map((p) => {
|
.map((p) => {
|
||||||
const headersObj = {}
|
const headersObj: Record<string, string> = {}
|
||||||
p.headers.forEach((h) => {
|
p.headers.forEach((h) => {
|
||||||
if (h.key.trim()) {
|
if (h.key.trim()) {
|
||||||
headersObj[h.key.trim()] = h.value
|
headersObj[h.key.trim()] = h.value
|
||||||
|
|
@ -71,7 +75,7 @@ function handleConfirm() {
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
providerStore.updateProviders(result as Providers[])
|
providerStore.updateProviders(result)
|
||||||
goBack()
|
goBack()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -86,7 +90,7 @@ onMounted(() => {
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<view class="h-screen flex flex-col bg-[#f5f7fb]">
|
<view class="h-screen flex flex-col bg-[#f5f7fb]">
|
||||||
<!-- 头部导航 -->
|
<!-- Header navigation -->
|
||||||
<wd-navbar
|
<wd-navbar
|
||||||
:title="t('contextProviderDialog.title')"
|
:title="t('contextProviderDialog.title')"
|
||||||
safe-area-inset-top
|
safe-area-inset-top
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
{
|
{
|
||||||
"layout": "default",
|
"layout": "default",
|
||||||
"style": {
|
"style": {
|
||||||
"navigationBarTitleText": "语音设置",
|
"navigationBarTitleText": "Voice Settings",
|
||||||
"navigationStyle": "custom"
|
"navigationStyle": "custom"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -29,7 +29,7 @@ function handleConfirm() {
|
||||||
goBack()
|
goBack()
|
||||||
}
|
}
|
||||||
|
|
||||||
// 返回上一页并更新配置
|
// Return to the previous page after saving the local settings.
|
||||||
function goBack() {
|
function goBack() {
|
||||||
uni.navigateBack()
|
uni.navigateBack()
|
||||||
}
|
}
|
||||||
|
|
@ -45,7 +45,7 @@ onMounted(() => {
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<view class="h-screen flex flex-col bg-[#f5f7fb]">
|
<view class="h-screen flex flex-col bg-[#f5f7fb]">
|
||||||
<!-- 头部导航 -->
|
<!-- Header navigation -->
|
||||||
<wd-navbar
|
<wd-navbar
|
||||||
:title="t('agent.languageConfig')"
|
:title="t('agent.languageConfig')"
|
||||||
safe-area-inset-top
|
safe-area-inset-top
|
||||||
|
|
@ -59,7 +59,7 @@ onMounted(() => {
|
||||||
</wd-navbar>
|
</wd-navbar>
|
||||||
<view class="flex flex-1 flex-col overflow-hidden">
|
<view class="flex flex-1 flex-col overflow-hidden">
|
||||||
<view class="flex flex-1 flex-col gap-[50rpx] overflow-y-auto px-[40rpx] py-[50rpx]">
|
<view class="flex flex-1 flex-col gap-[50rpx] overflow-y-auto px-[40rpx] py-[50rpx]">
|
||||||
<!-- 音量调节 -->
|
<!-- Volume control -->
|
||||||
<view class="flex flex-col gap-[20rpx]">
|
<view class="flex flex-col gap-[20rpx]">
|
||||||
<text class="text-[30rpx] text-[#232338] font-semibold">
|
<text class="text-[30rpx] text-[#232338] font-semibold">
|
||||||
{{ t('agent.ttsVolume') }}
|
{{ t('agent.ttsVolume') }}
|
||||||
|
|
@ -83,7 +83,7 @@ onMounted(() => {
|
||||||
</text>
|
</text>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
<!-- 语速调节 -->
|
<!-- Speech rate control -->
|
||||||
<view class="flex flex-col gap-[20rpx]">
|
<view class="flex flex-col gap-[20rpx]">
|
||||||
<text class="text-[30rpx] text-[#232338] font-semibold">
|
<text class="text-[30rpx] text-[#232338] font-semibold">
|
||||||
{{ t('agent.ttsRate') }}
|
{{ t('agent.ttsRate') }}
|
||||||
|
|
@ -107,7 +107,7 @@ onMounted(() => {
|
||||||
</text>
|
</text>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
<!-- 音调调节 -->
|
<!-- Pitch control -->
|
||||||
<view class="flex flex-col gap-[20rpx]">
|
<view class="flex flex-col gap-[20rpx]">
|
||||||
<text class="text-[30rpx] text-[#232338] font-semibold">
|
<text class="text-[30rpx] text-[#232338] font-semibold">
|
||||||
{{ t('agent.ttsPitch') }}
|
{{ t('agent.ttsPitch') }}
|
||||||
|
|
@ -142,7 +142,7 @@ onMounted(() => {
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<style scoped lang="scss">
|
<style scoped lang="scss">
|
||||||
/* 自定义滑块样式 */
|
/* Slider theme overrides */
|
||||||
:deep(.wd-slider) {
|
:deep(.wd-slider) {
|
||||||
--wd-slider-bar-background: #e6ebff;
|
--wd-slider-bar-background: #e6ebff;
|
||||||
--wd-slider-bar-active-background: #336cff;
|
--wd-slider-bar-active-background: #336cff;
|
||||||
|
|
|
||||||
|
|
@ -2,39 +2,38 @@
|
||||||
{
|
{
|
||||||
"layout": "default",
|
"layout": "default",
|
||||||
"style": {
|
"style": {
|
||||||
"navigationBarTitleText": "编辑功能",
|
"navigationBarTitleText": "Edit Functions",
|
||||||
"navigationStyle": "custom"
|
"navigationStyle": "custom",
|
||||||
}
|
},
|
||||||
}
|
}
|
||||||
</route>
|
</route>
|
||||||
|
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { useMessage } from 'wot-design-uni'
|
import { useMessage } from 'wot-design-uni'
|
||||||
import { getMcpAddress, getMcpTools } from '@/api/agent/agent'
|
import { getMcpAddress, getMcpTools } from '@/api/agent/agent'
|
||||||
import { t } from '@/i18n'
|
|
||||||
import { usePluginStore } from '@/store'
|
import { usePluginStore } from '@/store'
|
||||||
|
|
||||||
const message = useMessage()
|
const message = useMessage()
|
||||||
const pluginStore = usePluginStore()
|
const pluginStore = usePluginStore()
|
||||||
|
|
||||||
const segmentedList = ref<string[]>([t('agent.tools.notSelected'), t('agent.tools.selected')])
|
const segmentedList = ref<string[]>(['Unselected', 'Selected'])
|
||||||
const currentSegmented = ref(t('agent.tools.notSelected'))
|
const currentSegmented = ref('Unselected')
|
||||||
const notSelectedList = ref<any[]>([])
|
const notSelectedList = ref<any[]>([])
|
||||||
const selectedList = ref<any[]>([])
|
const selectedList = ref<any[]>([])
|
||||||
|
|
||||||
// 使用计算属性从store获取数据
|
// Use computed properties to get data from store
|
||||||
const allFunctions = computed(() => pluginStore.allFunctions)
|
const allFunctions = computed(() => pluginStore.allFunctions)
|
||||||
const functions = computed(() => pluginStore.currentFunctions)
|
const functions = computed(() => pluginStore.currentFunctions)
|
||||||
const agentId = computed(() => pluginStore.currentAgentId)
|
const agentId = computed(() => pluginStore.currentAgentId)
|
||||||
const mcpAddress = ref('')
|
const mcpAddress = ref('')
|
||||||
const mcpTools = ref<string[]>([])
|
const mcpTools = ref<string[]>([])
|
||||||
|
|
||||||
// 初始化时从本地存储加载MCP地址
|
// Load MCP address from local storage on initialization
|
||||||
if (uni.getStorageSync(`cachedMcpAddress_${agentId.value}`)) {
|
if (uni.getStorageSync('cachedMcpAddress_' + agentId.value)) {
|
||||||
mcpAddress.value = uni.getStorageSync(`cachedMcpAddress_${agentId.value}`)
|
mcpAddress.value = uni.getStorageSync('cachedMcpAddress_' + agentId.value)
|
||||||
}
|
}
|
||||||
|
|
||||||
// 参数编辑相关
|
// Parameter editing related
|
||||||
const showParamDialog = ref(false)
|
const showParamDialog = ref(false)
|
||||||
const currentFunction = ref<any>(null)
|
const currentFunction = ref<any>(null)
|
||||||
const tempParams = ref<Record<string, any>>({})
|
const tempParams = ref<Record<string, any>>({})
|
||||||
|
|
@ -56,71 +55,68 @@ async function mergeFunctions() {
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
// 未选的插件
|
// Unselected plugins
|
||||||
notSelectedList.value = allFunctions.value.filter(
|
notSelectedList.value = allFunctions.value.filter(
|
||||||
item => !selectedList.value.some(f => f.id === item.id),
|
item => !selectedList.value.some(f => f.id === item.id),
|
||||||
)
|
)
|
||||||
|
|
||||||
if (agentId.value) {
|
if (agentId.value) {
|
||||||
// 优先获取并显示MCP地址
|
// Prioritize getting and displaying MCP address
|
||||||
try {
|
try {
|
||||||
const address = await getMcpAddress(agentId.value)
|
const address = await getMcpAddress(agentId.value)
|
||||||
mcpAddress.value = address
|
mcpAddress.value = address
|
||||||
// 缓存到本地存储,下次打开页面可以立即显示
|
// Cache to local storage, can display immediately next time page opens
|
||||||
uni.setStorageSync(`cachedMcpAddress_${agentId.value}`, address)
|
uni.setStorageSync('cachedMcpAddress_' + agentId.value, address)
|
||||||
}
|
} catch (error) {
|
||||||
catch (error) {
|
console.error('Failed to get MCP address:', error)
|
||||||
mcpAddress.value = error
|
|
||||||
console.error('获取MCP地址失败:', error)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 异步获取MCP工具列表,不阻塞UI显示
|
// Asynchronously get MCP tool list, don't block UI display
|
||||||
try {
|
try {
|
||||||
const tools = await getMcpTools(agentId.value)
|
const tools = await getMcpTools(agentId.value)
|
||||||
mcpTools.value = tools || []
|
mcpTools.value = tools || []
|
||||||
}
|
} catch (error) {
|
||||||
catch (error) {
|
console.error('Failed to get MCP tool list:', error)
|
||||||
console.error('获取MCP工具列表失败:', error)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 添加插件到已选
|
// Add plugin to selected
|
||||||
function selectFunction(func: any) {
|
function selectFunction(func: any) {
|
||||||
// 添加到已选列表
|
// Add to selected list
|
||||||
selectedList.value = [...selectedList.value, {
|
selectedList.value.push({
|
||||||
id: func.id,
|
id: func.id,
|
||||||
name: func.name,
|
name: func.name,
|
||||||
params: { ...func.params },
|
params: { ...func.params },
|
||||||
fieldsMeta: func.fieldsMeta,
|
fieldsMeta: func.fieldsMeta,
|
||||||
}]
|
})
|
||||||
|
|
||||||
// 从未选列表中移除
|
// Remove from unselected list
|
||||||
notSelectedList.value = notSelectedList.value.filter(
|
notSelectedList.value = notSelectedList.value.filter(
|
||||||
item => item.id !== func.id,
|
item => item.id !== func.id,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
// 从已选中移除插件
|
// Remove plugin from selected
|
||||||
function removeFunction(func: any) {
|
function removeFunction(func: any) {
|
||||||
// 从已选列表中移除
|
// Remove from selected list
|
||||||
selectedList.value = selectedList.value.filter(item => item.id !== func.id)
|
selectedList.value = selectedList.value.filter(item => item.id !== func.id)
|
||||||
|
|
||||||
// 添加回未选列表
|
// Add back to unselected list
|
||||||
const originalFunc = allFunctions.value.find(f => f.id === func.id)
|
const originalFunc = allFunctions.value.find(f => f.id === func.id)
|
||||||
if (originalFunc) {
|
if (originalFunc) {
|
||||||
notSelectedList.value.push(originalFunc)
|
notSelectedList.value.push(originalFunc)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 编辑插件参数
|
// Edit plugin parameters
|
||||||
function editFunction(func: any) {
|
function editFunction(func: any) {
|
||||||
currentFunction.value = func
|
currentFunction.value = func
|
||||||
|
|
||||||
// 直接使用当前函数的参数
|
// Use current function parameters directly
|
||||||
tempParams.value = { ...func.params }
|
tempParams.value = { ...func.params }
|
||||||
|
|
||||||
// 初始化文本缓存
|
// Initialize text cache
|
||||||
if (func.fieldsMeta) {
|
if (func.fieldsMeta) {
|
||||||
func.fieldsMeta.forEach((field: any) => {
|
func.fieldsMeta.forEach((field: any) => {
|
||||||
if (field.type === 'array') {
|
if (field.type === 'array') {
|
||||||
|
|
@ -144,11 +140,11 @@ function editFunction(func: any) {
|
||||||
showParamDialog.value = true
|
showParamDialog.value = true
|
||||||
}
|
}
|
||||||
|
|
||||||
// 处理参数变化 - 实时保存
|
// Handle parameter changes - real-time save
|
||||||
function handleParamChange(key: string, value: any, field: any) {
|
function handleParamChange(key: string, value: any, field: any) {
|
||||||
tempParams.value[key] = value
|
tempParams.value[key] = value
|
||||||
|
|
||||||
// 实时更新到 selectedList
|
// Real-time update to selectedList
|
||||||
if (currentFunction.value) {
|
if (currentFunction.value) {
|
||||||
const index = selectedList.value.findIndex(
|
const index = selectedList.value.findIndex(
|
||||||
f => f.id === currentFunction.value.id,
|
f => f.id === currentFunction.value.id,
|
||||||
|
|
@ -159,14 +155,14 @@ function handleParamChange(key: string, value: any, field: any) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 处理数组类型参数变化 - 实时保存
|
// Handle array type parameter changes - real-time save
|
||||||
function handleArrayChange(key: string, value: string, field: any) {
|
function handleArrayChange(key: string, value: string, field: any) {
|
||||||
arrayTextCache.value[key] = value
|
arrayTextCache.value[key] = value
|
||||||
// 转换为数组存储
|
// Convert to array storage
|
||||||
const arrayValue = value.split('\n').filter(Boolean)
|
const arrayValue = value.split('\n').filter(Boolean)
|
||||||
tempParams.value[key] = arrayValue
|
tempParams.value[key] = arrayValue
|
||||||
|
|
||||||
// 实时更新到 selectedList
|
// Real-time update to selectedList
|
||||||
if (currentFunction.value) {
|
if (currentFunction.value) {
|
||||||
const index = selectedList.value.findIndex(
|
const index = selectedList.value.findIndex(
|
||||||
f => f.id === currentFunction.value.id,
|
f => f.id === currentFunction.value.id,
|
||||||
|
|
@ -177,14 +173,14 @@ function handleArrayChange(key: string, value: string, field: any) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 处理JSON类型参数变化 - 实时保存
|
// Handle JSON type parameter changes - real-time save
|
||||||
function handleJsonChange(key: string, value: string, field: any) {
|
function handleJsonChange(key: string, value: string, field: any) {
|
||||||
jsonTextCache.value[key] = value
|
jsonTextCache.value[key] = value
|
||||||
try {
|
try {
|
||||||
const jsonValue = JSON.parse(value)
|
const jsonValue = JSON.parse(value)
|
||||||
tempParams.value[key] = jsonValue
|
tempParams.value[key] = jsonValue
|
||||||
|
|
||||||
// 实时更新到 selectedList
|
// Real-time update to selectedList
|
||||||
if (currentFunction.value) {
|
if (currentFunction.value) {
|
||||||
const index = selectedList.value.findIndex(
|
const index = selectedList.value.findIndex(
|
||||||
f => f.id === currentFunction.value.id,
|
f => f.id === currentFunction.value.id,
|
||||||
|
|
@ -195,11 +191,11 @@ function handleJsonChange(key: string, value: string, field: any) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch {
|
catch {
|
||||||
message.alert(t('agent.tools.jsonFormatError'))
|
message.alert('JSON format error')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 关闭参数编辑弹窗
|
// Close parameter edit dialog
|
||||||
function closeParamEdit() {
|
function closeParamEdit() {
|
||||||
showParamDialog.value = false
|
showParamDialog.value = false
|
||||||
tempParams.value = {}
|
tempParams.value = {}
|
||||||
|
|
@ -207,15 +203,24 @@ function closeParamEdit() {
|
||||||
jsonTextCache.value = {}
|
jsonTextCache.value = {}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 返回上一页并更新配置
|
// Go back to previous page and update configuration
|
||||||
function goBack() {
|
function goBack() {
|
||||||
|
const finalFunctions = selectedList.value.map(f => ({
|
||||||
|
pluginId: f.id,
|
||||||
|
paramInfo: f.params,
|
||||||
|
}))
|
||||||
|
|
||||||
|
// Update to store
|
||||||
|
pluginStore.updateFunctions(finalFunctions)
|
||||||
|
|
||||||
|
// Return directly
|
||||||
uni.navigateBack()
|
uni.navigateBack()
|
||||||
}
|
}
|
||||||
|
|
||||||
// 复制MCP地址
|
// Copy MCP address
|
||||||
function copyMcpAddress() {
|
function copyMcpAddress() {
|
||||||
if (!mcpAddress.value) {
|
if (!mcpAddress.value) {
|
||||||
message.alert(t('agent.tools.noMcpAddressToCopy'))
|
message.alert('No MCP address to copy')
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -223,15 +228,15 @@ function copyMcpAddress() {
|
||||||
data: mcpAddress.value,
|
data: mcpAddress.value,
|
||||||
showToast: false,
|
showToast: false,
|
||||||
success: () => {
|
success: () => {
|
||||||
message.alert(t('agent.tools.mcpAddressCopied'))
|
message.alert('MCP address copied to clipboard')
|
||||||
},
|
},
|
||||||
fail: () => {
|
fail: () => {
|
||||||
message.alert(t('agent.tools.copyFailed'))
|
message.alert('Copy failed, please try again')
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// 渲染参数字段的辅助函数
|
// Helper function for rendering parameter fields
|
||||||
function getFieldDisplayValue(field: any, value: any) {
|
function getFieldDisplayValue(field: any, value: any) {
|
||||||
if (field.type === 'array') {
|
if (field.type === 'array') {
|
||||||
return Array.isArray(value) ? value.join('\n') : value || ''
|
return Array.isArray(value) ? value.join('\n') : value || ''
|
||||||
|
|
@ -239,33 +244,24 @@ function getFieldDisplayValue(field: any, value: any) {
|
||||||
return value || ''
|
return value || ''
|
||||||
}
|
}
|
||||||
|
|
||||||
// 字段说明
|
// Field description
|
||||||
function getFieldRemark(field: any) {
|
function getFieldRemark(field: any) {
|
||||||
let description = field.label || ''
|
let description = field.label || ''
|
||||||
if (field.default) {
|
if (field.default) {
|
||||||
description += `(${t('agent.tools.defaultValue')}:${field.default})`
|
description += ` (Default: ${field.default})`
|
||||||
}
|
}
|
||||||
return description
|
return description
|
||||||
}
|
}
|
||||||
|
|
||||||
// 监听已选列表变化,实时更新插件配置,避免用户不点击返回按钮导致配置丢失
|
|
||||||
watch(() => selectedList.value, (newSelectedList) => {
|
|
||||||
const finalFunctions = newSelectedList.map(f => ({
|
|
||||||
pluginId: f.id,
|
|
||||||
paramInfo: f.params,
|
|
||||||
}))
|
|
||||||
pluginStore.updateFunctions(finalFunctions)
|
|
||||||
})
|
|
||||||
|
|
||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
// 直接从store获取数据并合并
|
// Get data directly from store and merge
|
||||||
await mergeFunctions()
|
await mergeFunctions()
|
||||||
})
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<view class="h-screen flex flex-col bg-[#f5f7fb]">
|
<view class="h-screen flex flex-col bg-[#f5f7fb]">
|
||||||
<!-- 头部导航 -->
|
<!-- Header navigation -->
|
||||||
<wd-navbar
|
<wd-navbar
|
||||||
title=""
|
title=""
|
||||||
safe-area-inset-top
|
safe-area-inset-top
|
||||||
|
|
@ -278,32 +274,32 @@ onMounted(async () => {
|
||||||
</template>
|
</template>
|
||||||
</wd-navbar>
|
</wd-navbar>
|
||||||
|
|
||||||
<!-- 内容区域 -->
|
<!-- Content area -->
|
||||||
<scroll-view
|
<scroll-view
|
||||||
scroll-y
|
scroll-y
|
||||||
class="box-border flex-1 bg-transparent px-[20rpx]"
|
class="box-border flex-1 bg-transparent px-[20rpx]"
|
||||||
:style="{ height: 'calc(100vh - 120rpx)' }"
|
:style="{ height: 'calc(100vh - 120rpx)' }"
|
||||||
:scroll-with-animation="true"
|
:scroll-with-animation="true"
|
||||||
>
|
>
|
||||||
<!-- 内置插件区域 -->
|
<!-- Built-in plugin area -->
|
||||||
<view class="mt-[20rpx] flex flex-1 flex-col">
|
<view class="mt-[20rpx] flex flex-1 flex-col">
|
||||||
<view class="text-[32rpx] text-[#333] font-medium">
|
<view class="text-[32rpx] text-[#333] font-medium">
|
||||||
{{ t('agent.tools.builtInPlugins') }}
|
Built-in Plugins
|
||||||
</view>
|
</view>
|
||||||
<view
|
<view
|
||||||
class="mt-[20rpx] box-border flex flex-1 flex-col rounded-[10rpx] bg-white p-[20rpx]"
|
class="mt-[20rpx] box-border flex flex-1 flex-col rounded-[10rpx] bg-white p-[20rpx]"
|
||||||
>
|
>
|
||||||
<!-- 分段控制器 -->
|
<!-- Segmented controller -->
|
||||||
<wd-segmented
|
<wd-segmented
|
||||||
v-model:value="currentSegmented"
|
v-model:value="currentSegmented"
|
||||||
:options="segmentedList"
|
:options="segmentedList"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<!-- 插件列表 -->
|
<!-- Plugin list -->
|
||||||
<view class="mt-[20rpx] flex-1 overflow-hidden">
|
<view class="mt-[20rpx] flex-1 overflow-hidden">
|
||||||
<!-- 未选插件 -->
|
<!-- Unselected plugins -->
|
||||||
<scroll-view
|
<scroll-view
|
||||||
v-if="currentSegmented === t('agent.tools.notSelected')"
|
v-if="currentSegmented === 'Unselected'"
|
||||||
class="max-h-[600rpx] bg-transparent"
|
class="max-h-[600rpx] bg-transparent"
|
||||||
scroll-y
|
scroll-y
|
||||||
>
|
>
|
||||||
|
|
@ -311,7 +307,7 @@ onMounted(async () => {
|
||||||
v-if="notSelectedList.length === 0"
|
v-if="notSelectedList.length === 0"
|
||||||
class="h-[400rpx] flex items-center justify-center"
|
class="h-[400rpx] flex items-center justify-center"
|
||||||
>
|
>
|
||||||
<wd-status-tip image="content" :tip="t('agent.tools.noMorePlugins')" />
|
<wd-status-tip image="content" tip="No more plugins" />
|
||||||
</view>
|
</view>
|
||||||
<view v-else class="p-[20rpx] space-y-[20rpx]">
|
<view v-else class="p-[20rpx] space-y-[20rpx]">
|
||||||
<view
|
<view
|
||||||
|
|
@ -341,13 +337,13 @@ onMounted(async () => {
|
||||||
</view>
|
</view>
|
||||||
</scroll-view>
|
</scroll-view>
|
||||||
|
|
||||||
<!-- 已选插件 -->
|
<!-- Selected plugins -->
|
||||||
<scroll-view v-else class="max-h-[600rpx] bg-transparent" scroll-y>
|
<scroll-view v-else class="max-h-[600rpx] bg-transparent" scroll-y>
|
||||||
<view
|
<view
|
||||||
v-if="selectedList.length === 0"
|
v-if="selectedList.length === 0"
|
||||||
class="h-[400rpx] flex items-center justify-center"
|
class="h-[400rpx] flex items-center justify-center"
|
||||||
>
|
>
|
||||||
<wd-status-tip image="content" :tip="t('agent.tools.pleaseSelectPlugin')" />
|
<wd-status-tip image="content" tip="Please select plugin functions" />
|
||||||
</view>
|
</view>
|
||||||
<view v-else class="p-[20rpx] space-y-[20rpx]">
|
<view v-else class="p-[20rpx] space-y-[20rpx]">
|
||||||
<view
|
<view
|
||||||
|
|
@ -363,11 +359,11 @@ onMounted(async () => {
|
||||||
{{ func.name }}
|
{{ func.name }}
|
||||||
</view>
|
</view>
|
||||||
<view class="text-[24rpx] text-[#1677ff]">
|
<view class="text-[24rpx] text-[#1677ff]">
|
||||||
{{ t('agent.tools.clickToConfigure') }}
|
Click to configure parameters
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
<view class="flex space-x-[20rpx]">
|
<view class="flex space-x-[20rpx]">
|
||||||
<!-- 配置按钮 -->
|
<!-- Configure button -->
|
||||||
<view
|
<view
|
||||||
class="h-[60rpx] w-[60rpx] flex items-center justify-center rounded-full bg-[#1677ff]"
|
class="h-[60rpx] w-[60rpx] flex items-center justify-center rounded-full bg-[#1677ff]"
|
||||||
@click="editFunction(func)"
|
@click="editFunction(func)"
|
||||||
|
|
@ -376,7 +372,7 @@ onMounted(async () => {
|
||||||
⚙
|
⚙
|
||||||
</text>
|
</text>
|
||||||
</view>
|
</view>
|
||||||
<!-- 移除按钮 -->
|
<!-- Remove button -->
|
||||||
<view
|
<view
|
||||||
class="h-[60rpx] w-[60rpx] flex items-center justify-center rounded-full bg-[#ff4757]"
|
class="h-[60rpx] w-[60rpx] flex items-center justify-center rounded-full bg-[#ff4757]"
|
||||||
@click="removeFunction(func)"
|
@click="removeFunction(func)"
|
||||||
|
|
@ -394,10 +390,10 @@ onMounted(async () => {
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
<!-- MCP接入点区域 -->
|
<!-- MCP access point area -->
|
||||||
<view class="mt-[20rpx] flex flex-1 flex-col">
|
<view class="mt-[20rpx] flex flex-1 flex-col">
|
||||||
<view class="text-[32rpx] text-[#333] font-medium">
|
<view class="text-[32rpx] text-[#333] font-medium">
|
||||||
{{ t('agent.tools.mcpEndpoint') }}
|
MCP Access Point
|
||||||
</view>
|
</view>
|
||||||
<view
|
<view
|
||||||
class="mt-[20rpx] box-border flex flex-1 flex-col rounded-[10rpx] bg-white p-[20rpx]"
|
class="mt-[20rpx] box-border flex flex-1 flex-col rounded-[10rpx] bg-white p-[20rpx]"
|
||||||
|
|
@ -413,17 +409,17 @@ onMounted(async () => {
|
||||||
class="ml-[20rpx] h-[70rpx] flex items-center justify-center rounded-[10rpx] bg-[#1677ff] px-[20rpx] text-[24rpx] text-white"
|
class="ml-[20rpx] h-[70rpx] flex items-center justify-center rounded-[10rpx] bg-[#1677ff] px-[20rpx] text-[24rpx] text-white"
|
||||||
@click="copyMcpAddress"
|
@click="copyMcpAddress"
|
||||||
>
|
>
|
||||||
{{ t('agent.tools.copy') }}
|
Copy
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
<!-- 工具列表 -->
|
<!-- Tool list -->
|
||||||
<view class="mt-[20rpx] flex-1 overflow-hidden">
|
<view class="mt-[20rpx] flex-1 overflow-hidden">
|
||||||
<scroll-view class="max-h-[600rpx] bg-transparent" scroll-y>
|
<scroll-view class="max-h-[600rpx] bg-transparent" scroll-y>
|
||||||
<view
|
<view
|
||||||
v-if="mcpTools && mcpTools.length === 0"
|
v-if="mcpTools && mcpTools.length === 0"
|
||||||
class="h-[400rpx] flex items-center justify-center"
|
class="h-[400rpx] flex items-center justify-center"
|
||||||
>
|
>
|
||||||
<wd-status-tip image="content" :tip="t('agent.tools.noTools')" />
|
<wd-status-tip image="content" tip="No tools" />
|
||||||
</view>
|
</view>
|
||||||
<view v-else class="p-[20rpx]">
|
<view v-else class="p-[20rpx]">
|
||||||
<view class="flex flex-wrap">
|
<view class="flex flex-wrap">
|
||||||
|
|
@ -442,10 +438,10 @@ onMounted(async () => {
|
||||||
</view>
|
</view>
|
||||||
</scroll-view>
|
</scroll-view>
|
||||||
|
|
||||||
<!-- 参数编辑弹窗 -->
|
<!-- Parameter edit dialog -->
|
||||||
<wd-action-sheet
|
<wd-action-sheet
|
||||||
v-model="showParamDialog"
|
v-model="showParamDialog"
|
||||||
:title="`${t('agent.tools.parameterConfig')} - ${currentFunction?.name || ''}`"
|
:title="`Parameter Configuration - ${currentFunction?.name || ''}`"
|
||||||
custom-header-class="h-[75vh]"
|
custom-header-class="h-[75vh]"
|
||||||
@close="closeParamEdit"
|
@close="closeParamEdit"
|
||||||
>
|
>
|
||||||
|
|
@ -455,7 +451,7 @@ onMounted(async () => {
|
||||||
:style="{ height: 'calc(75vh - 60rpx)' }"
|
:style="{ height: 'calc(75vh - 60rpx)' }"
|
||||||
>
|
>
|
||||||
<view class="p-[30rpx] pb-[40rpx]">
|
<view class="p-[30rpx] pb-[40rpx]">
|
||||||
<!-- 无参数提示 -->
|
<!-- No parameters prompt -->
|
||||||
<view
|
<view
|
||||||
v-if="
|
v-if="
|
||||||
!currentFunction?.fieldsMeta
|
!currentFunction?.fieldsMeta
|
||||||
|
|
@ -464,11 +460,11 @@ onMounted(async () => {
|
||||||
class="h-[400rpx] flex items-center justify-center"
|
class="h-[400rpx] flex items-center justify-center"
|
||||||
>
|
>
|
||||||
<text class="text-[28rpx] text-[#999]">
|
<text class="text-[28rpx] text-[#999]">
|
||||||
{{ currentFunction?.name }} {{ t('agent.tools.noParamsNeeded') }}
|
{{ currentFunction?.name }} requires no parameter configuration
|
||||||
</text>
|
</text>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
<!-- 参数表单 - 卡片式布局 -->
|
<!-- Parameter form - card layout -->
|
||||||
<view v-else class="flex flex-col gap-[24rpx]">
|
<view v-else class="flex flex-col gap-[24rpx]">
|
||||||
<view
|
<view
|
||||||
v-for="field in currentFunction.fieldsMeta"
|
v-for="field in currentFunction.fieldsMeta"
|
||||||
|
|
@ -476,7 +472,7 @@ onMounted(async () => {
|
||||||
class="border border-[#eeeeee] rounded-[20rpx] bg-white p-[30rpx]"
|
class="border border-[#eeeeee] rounded-[20rpx] bg-white p-[30rpx]"
|
||||||
style="box-shadow: 0 2rpx 12rpx rgba(0, 0, 0, 0.04);"
|
style="box-shadow: 0 2rpx 12rpx rgba(0, 0, 0, 0.04);"
|
||||||
>
|
>
|
||||||
<!-- 字段信息 -->
|
<!-- Field information -->
|
||||||
<view class="mb-[24rpx]">
|
<view class="mb-[24rpx]">
|
||||||
<text class="mb-[8rpx] block text-[32rpx] text-[#232338] font-medium">
|
<text class="mb-[8rpx] block text-[32rpx] text-[#232338] font-medium">
|
||||||
{{ field.label }}
|
{{ field.label }}
|
||||||
|
|
@ -486,57 +482,57 @@ onMounted(async () => {
|
||||||
</text>
|
</text>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
<!-- 输入控件 -->
|
<!-- Input controls -->
|
||||||
<view>
|
<view>
|
||||||
<!-- 字符串类型 -->
|
<!-- String type -->
|
||||||
<input
|
<input
|
||||||
v-if="field.type === 'string'"
|
v-if="field.type === 'string'"
|
||||||
v-model="tempParams[field.key]"
|
v-model="tempParams[field.key]"
|
||||||
class="box-border h-[80rpx] w-full border border-[#eeeeee] rounded-[12rpx] bg-[#f5f7fb] p-[16rpx_20rpx] text-[28rpx] text-[#232338] focus:border-[#336cff] focus:bg-white placeholder:text-[#9d9ea3]"
|
class="box-border h-[80rpx] w-full border border-[#eeeeee] rounded-[12rpx] bg-[#f5f7fb] p-[16rpx_20rpx] text-[28rpx] text-[#232338] focus:border-[#336cff] focus:bg-white placeholder:text-[#9d9ea3]"
|
||||||
type="text"
|
type="text"
|
||||||
:placeholder="`${t('agent.tools.pleaseInput')}${field.label}`"
|
:placeholder="`Please enter ${field.label}`"
|
||||||
@input="
|
@input="
|
||||||
handleParamChange(field.key, $event.detail.value, field)
|
handleParamChange(field.key, $event.detail.value, field)
|
||||||
"
|
"
|
||||||
>
|
>
|
||||||
|
|
||||||
<!-- 数组类型 -->
|
<!-- Array type -->
|
||||||
<view v-else-if="field.type === 'array'">
|
<view v-else-if="field.type === 'array'">
|
||||||
<text class="mb-[16rpx] block text-[24rpx] text-[#65686f]">
|
<text class="mb-[16rpx] block text-[24rpx] text-[#65686f]">
|
||||||
{{ t('agent.tools.eachLineOneItem') }}
|
Enter one item per line
|
||||||
</text>
|
</text>
|
||||||
<textarea
|
<textarea
|
||||||
v-model="arrayTextCache[field.key]"
|
v-model="arrayTextCache[field.key]"
|
||||||
class="box-border min-h-[200rpx] w-full border border-[#eeeeee] rounded-[12rpx] bg-[#f5f7fb] p-[20rpx] text-[26rpx] text-[#232338] leading-[1.6] focus:border-[#336cff] focus:bg-white placeholder:text-[#9d9ea3]"
|
class="box-border min-h-[200rpx] w-full border border-[#eeeeee] rounded-[12rpx] bg-[#f5f7fb] p-[20rpx] text-[26rpx] text-[#232338] leading-[1.6] focus:border-[#336cff] focus:bg-white placeholder:text-[#9d9ea3]"
|
||||||
:placeholder="`${t('agent.tools.pleaseInput')}${field.label},${t('agent.tools.eachLineOneItem')}`"
|
:placeholder="`Please enter ${field.label}, one per line`"
|
||||||
@input="
|
@input="
|
||||||
handleArrayChange(field.key, $event.detail.value, field)
|
handleArrayChange(field.key, $event.detail.value, field)
|
||||||
"
|
"
|
||||||
/>
|
/>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
<!-- JSON类型 -->
|
<!-- JSON Type -->
|
||||||
<view v-else-if="field.type === 'json'">
|
<view v-else-if="field.type === 'json'">
|
||||||
<text class="mb-[16rpx] block text-[24rpx] text-[#65686f]">
|
<text class="mb-[16rpx] block text-[24rpx] text-[#65686f]">
|
||||||
{{ t('agent.tools.pleaseInputValidJson') }}
|
Please enter valid JSON format
|
||||||
</text>
|
</text>
|
||||||
<textarea
|
<textarea
|
||||||
v-model="jsonTextCache[field.key]"
|
v-model="jsonTextCache[field.key]"
|
||||||
class="box-border min-h-[300rpx] w-full border border-[#eeeeee] rounded-[12rpx] bg-[#f5f7fb] p-[20rpx] text-[26rpx] text-[#232338] leading-[1.6] font-mono focus:border-[#336cff] focus:bg-white placeholder:text-[#9d9ea3]"
|
class="box-border min-h-[300rpx] w-full border border-[#eeeeee] rounded-[12rpx] bg-[#f5f7fb] p-[20rpx] text-[26rpx] text-[#232338] leading-[1.6] font-mono focus:border-[#336cff] focus:bg-white placeholder:text-[#9d9ea3]"
|
||||||
:placeholder="t('agent.tools.pleaseInputValidJson')"
|
placeholder="Please enter valid JSON format"
|
||||||
@blur="
|
@blur="
|
||||||
handleJsonChange(field.key, $event.detail.value, field)
|
handleJsonChange(field.key, $event.detail.value, field)
|
||||||
"
|
"
|
||||||
/>
|
/>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
<!-- 数字类型 -->
|
<!-- Number type -->
|
||||||
<input
|
<input
|
||||||
v-else-if="field.type === 'number'"
|
v-else-if="field.type === 'number'"
|
||||||
v-model="tempParams[field.key]"
|
v-model="tempParams[field.key]"
|
||||||
class="box-border h-[80rpx] w-full border border-[#eeeeee] rounded-[12rpx] bg-[#f5f7fb] p-[16rpx_20rpx] text-[28rpx] text-[#232338] focus:border-[#336cff] focus:bg-white placeholder:text-[#9d9ea3]"
|
class="box-border h-[80rpx] w-full border border-[#eeeeee] rounded-[12rpx] bg-[#f5f7fb] p-[16rpx_20rpx] text-[28rpx] text-[#232338] focus:border-[#336cff] focus:bg-white placeholder:text-[#9d9ea3]"
|
||||||
type="number"
|
type="number"
|
||||||
:placeholder="`${t('agent.tools.pleaseInput')}${field.label}`"
|
:placeholder="`Please enter ${field.label}`"
|
||||||
@input="
|
@input="
|
||||||
handleParamChange(
|
handleParamChange(
|
||||||
field.key,
|
field.key,
|
||||||
|
|
@ -546,17 +542,17 @@ onMounted(async () => {
|
||||||
"
|
"
|
||||||
>
|
>
|
||||||
|
|
||||||
<!-- 布尔类型 -->
|
<!-- Boolean type -->
|
||||||
<view
|
<view
|
||||||
v-else-if="field.type === 'boolean' || field.type === 'bool'"
|
v-else-if="field.type === 'boolean' || field.type === 'bool'"
|
||||||
class="flex items-center justify-between py-[20rpx]"
|
class="flex items-center justify-between py-[20rpx]"
|
||||||
>
|
>
|
||||||
<view class="flex-1">
|
<view class="flex-1">
|
||||||
<text class="mb-[8rpx] block text-[28rpx] text-[#232338]">
|
<text class="mb-[8rpx] block text-[28rpx] text-[#232338]">
|
||||||
{{ t('agent.tools.enableFunction') }}
|
Enable function
|
||||||
</text>
|
</text>
|
||||||
<text class="block text-[24rpx] text-[#65686f]">
|
<text class="block text-[24rpx] text-[#65686f]">
|
||||||
{{ t('agent.tools.toggleFunction') }}
|
Turn this function on or off
|
||||||
</text>
|
</text>
|
||||||
</view>
|
</view>
|
||||||
<switch
|
<switch
|
||||||
|
|
@ -567,13 +563,13 @@ onMounted(async () => {
|
||||||
/>
|
/>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
<!-- 默认字符串类型 -->
|
<!-- Default string type -->
|
||||||
<input
|
<input
|
||||||
v-else
|
v-else
|
||||||
v-model="tempParams[field.key]"
|
v-model="tempParams[field.key]"
|
||||||
class="box-border h-[80rpx] w-full border border-[#eeeeee] rounded-[12rpx] bg-[#f5f7fb] p-[16rpx_20rpx] text-[28rpx] text-[#232338] focus:border-[#336cff] focus:bg-white placeholder:text-[#9d9ea3]"
|
class="box-border h-[80rpx] w-full border border-[#eeeeee] rounded-[12rpx] bg-[#f5f7fb] p-[16rpx_20rpx] text-[28rpx] text-[#232338] focus:border-[#336cff] focus:bg-white placeholder:text-[#9d9ea3]"
|
||||||
type="text"
|
type="text"
|
||||||
:placeholder="`${t('agent.tools.pleaseInput')}${field.label}`"
|
:placeholder="`Please enter ${field.label}`"
|
||||||
@input="
|
@input="
|
||||||
handleParamChange(field.key, $event.detail.value, field)
|
handleParamChange(field.key, $event.detail.value, field)
|
||||||
"
|
"
|
||||||
|
|
@ -586,9 +582,3 @@ onMounted(async () => {
|
||||||
</wd-action-sheet>
|
</wd-action-sheet>
|
||||||
</view>
|
</view>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<style scoped lang="scss">
|
|
||||||
::v-deep .wd-action-sheet__header {
|
|
||||||
padding-right: 30rpx;
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@
|
||||||
"layout": "default",
|
"layout": "default",
|
||||||
"style": {
|
"style": {
|
||||||
"navigationStyle": "custom",
|
"navigationStyle": "custom",
|
||||||
"navigationBarTitleText": "聊天详情"
|
"navigationBarTitleText": "Chat Details"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</route>
|
</route>
|
||||||
|
|
@ -13,15 +13,14 @@ import type { ChatMessage, UserMessageContent } from '@/api/chat-history/types'
|
||||||
import { onLoad, onUnload } from '@dcloudio/uni-app'
|
import { onLoad, onUnload } from '@dcloudio/uni-app'
|
||||||
import { computed, ref } from 'vue'
|
import { computed, ref } from 'vue'
|
||||||
import { getAudioId, getChatHistory } from '@/api/chat-history/chat-history'
|
import { getAudioId, getChatHistory } from '@/api/chat-history/chat-history'
|
||||||
import { t } from '@/i18n'
|
import { getEnvBaseUrl } from '@/utils'
|
||||||
import { debounce, getEnvBaseUrl } from '@/utils'
|
|
||||||
import { toast } from '@/utils/toast'
|
import { toast } from '@/utils/toast'
|
||||||
|
|
||||||
defineOptions({
|
defineOptions({
|
||||||
name: 'ChatDetail',
|
name: 'ChatDetail',
|
||||||
})
|
})
|
||||||
|
|
||||||
// 获取屏幕边界到安全区域距离
|
// Get distance from screen boundary to safe area
|
||||||
let safeAreaInsets: any
|
let safeAreaInsets: any
|
||||||
let systemInfo: any
|
let systemInfo: any
|
||||||
|
|
||||||
|
|
@ -42,36 +41,36 @@ systemInfo = uni.getSystemInfoSync()
|
||||||
safeAreaInsets = systemInfo.safeAreaInsets
|
safeAreaInsets = systemInfo.safeAreaInsets
|
||||||
// #endif
|
// #endif
|
||||||
|
|
||||||
// 页面参数
|
// Page parameters
|
||||||
const sessionId = ref('')
|
const sessionId = ref('')
|
||||||
const agentId = ref('')
|
const agentId = ref('')
|
||||||
|
|
||||||
// 智能体信息(简化)
|
// Agent information (simplified)
|
||||||
const currentAgent = computed(() => {
|
const currentAgent = computed(() => {
|
||||||
return {
|
return {
|
||||||
id: agentId.value,
|
id: agentId.value,
|
||||||
agentName: t('chatHistory.assistantName'),
|
agentName: 'AI Assistant',
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
// 聊天数据
|
// Chat data
|
||||||
const messageList = ref<ChatMessage[]>([])
|
const messageList = ref<ChatMessage[]>([])
|
||||||
const loading = ref(false)
|
const loading = ref(false)
|
||||||
|
|
||||||
// 音频播放相关
|
// Audio playback related
|
||||||
const audioContext = ref<UniApp.InnerAudioContext | null>(null)
|
const audioContext = ref<UniApp.InnerAudioContext | null>(null)
|
||||||
const playingAudioId = ref<string | null>(null)
|
const playingAudioId = ref<string | null>(null)
|
||||||
const expandedToolResults = ref({})
|
const expandedToolResults = ref({})
|
||||||
|
|
||||||
// 返回上一页
|
// Return to previous page
|
||||||
function goBack() {
|
function goBack() {
|
||||||
uni.navigateBack()
|
uni.navigateBack()
|
||||||
}
|
}
|
||||||
|
|
||||||
// 加载聊天记录
|
// Load chat records
|
||||||
async function loadChatHistory() {
|
async function loadChatHistory() {
|
||||||
if (!sessionId.value || !agentId.value) {
|
if (!sessionId.value || !agentId.value) {
|
||||||
console.error('缺少必要参数')
|
console.error('Missing required parameters')
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -81,15 +80,15 @@ async function loadChatHistory() {
|
||||||
messageList.value = response
|
messageList.value = response
|
||||||
}
|
}
|
||||||
catch (error) {
|
catch (error) {
|
||||||
console.error('获取聊天记录失败:', error)
|
console.error('Failed to get chat history:', error)
|
||||||
toast.error(t('chatHistory.loadFailed'))
|
toast.error('Failed to get chat history')
|
||||||
}
|
}
|
||||||
finally {
|
finally {
|
||||||
loading.value = false
|
loading.value = false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 解析用户消息内容
|
// Parse user message content
|
||||||
function parseUserMessage(content: string): UserMessageContent | null {
|
function parseUserMessage(content: string): UserMessageContent | null {
|
||||||
try {
|
try {
|
||||||
return JSON.parse(content)
|
return JSON.parse(content)
|
||||||
|
|
@ -99,31 +98,31 @@ function parseUserMessage(content: string): UserMessageContent | null {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 获取消息显示内容
|
// Get message display content
|
||||||
function getMessageContent(message: ChatMessage): string {
|
function getMessageContent(message: ChatMessage): string {
|
||||||
if (message.chatType === 1) {
|
if (message.chatType === 1) {
|
||||||
// 用户消息,需要解析JSON
|
// User message, need to parse JSON
|
||||||
const parsed = parseUserMessage(message.content)
|
const parsed = parseUserMessage(message.content)
|
||||||
return parsed ? parsed.content : message.content
|
return parsed ? parsed.content : message.content
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// AI消息,直接显示
|
// AI message, display directly
|
||||||
return message.content
|
return message.content
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 获取说话人名称
|
// Get speaker name
|
||||||
function getSpeakerName(message: ChatMessage): string {
|
function getSpeakerName(message: ChatMessage): string {
|
||||||
if (message.chatType === 1) {
|
if (message.chatType === 1) {
|
||||||
const parsed = parseUserMessage(message.content)
|
const parsed = parseUserMessage(message.content)
|
||||||
return parsed ? parsed.speaker : t('chatHistory.userName')
|
return parsed ? parsed.speaker : 'User'
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
return currentAgent.value?.agentName || t('chatHistory.aiAssistantName')
|
return currentAgent.value?.agentName || 'AI Assistant'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 格式化时间
|
// Format time
|
||||||
function formatTime(timeStr: string) {
|
function formatTime(timeStr: string) {
|
||||||
if (!timeStr)
|
if (!timeStr)
|
||||||
return t('chatHistory.unknownTime')
|
return t('chatHistory.unknownTime')
|
||||||
|
|
@ -171,41 +170,36 @@ function formatTime(timeStr: string) {
|
||||||
return `${year}-${month}-${day}`
|
return `${year}-${month}-${day}`
|
||||||
}
|
}
|
||||||
|
|
||||||
// 播放音频
|
// Play audio
|
||||||
const playAudio = debounce(async (audioId: string) => {
|
async function playAudio(audioId: string) {
|
||||||
if (!audioId) {
|
if (!audioId) {
|
||||||
toast.error(t('chatHistory.invalidAudioId'))
|
toast.error('Invalid audio ID')
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// 如果正在播放其他音频,先停止
|
// If playing other audio, stop first
|
||||||
if (audioContext.value) {
|
if (audioContext.value) {
|
||||||
audioContext.value.stop()
|
audioContext.value.stop()
|
||||||
}
|
audioContext.value.destroy()
|
||||||
// 如果当前音频ID与请求ID相同暂停播放
|
audioContext.value = null
|
||||||
if (playingAudioId.value === audioId) {
|
|
||||||
playingAudioId.value = null
|
|
||||||
return
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 获取音频下载ID
|
// Get audio download ID
|
||||||
const downloadId = await getAudioId(audioId)
|
const downloadId = await getAudioId(audioId)
|
||||||
|
|
||||||
// 构造音频播放地址
|
// Construct audio playback URL
|
||||||
const baseUrl = getEnvBaseUrl()
|
const baseUrl = getEnvBaseUrl()
|
||||||
const audioUrl = `${baseUrl}/agent/play/${downloadId}`
|
const audioUrl = `${baseUrl}/agent/play/${downloadId}`
|
||||||
|
|
||||||
// 创建音频上下文
|
// Create audio context
|
||||||
if (!audioContext.value) {
|
|
||||||
audioContext.value = uni.createInnerAudioContext()
|
audioContext.value = uni.createInnerAudioContext()
|
||||||
}
|
|
||||||
audioContext.value.src = audioUrl
|
audioContext.value.src = audioUrl
|
||||||
|
|
||||||
// 设置播放状态
|
// Set playback status
|
||||||
playingAudioId.value = audioId
|
playingAudioId.value = audioId
|
||||||
|
|
||||||
// 监听播放完成
|
// Listen for playback completion
|
||||||
audioContext.value.onEnded(() => {
|
audioContext.value.onEnded(() => {
|
||||||
playingAudioId.value = null
|
playingAudioId.value = null
|
||||||
if (audioContext.value) {
|
if (audioContext.value) {
|
||||||
|
|
@ -214,10 +208,10 @@ const playAudio = debounce(async (audioId: string) => {
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
// 监听播放错误
|
// Listen for playback errors
|
||||||
audioContext.value.onError((error) => {
|
audioContext.value.onError((error) => {
|
||||||
console.error('音频播放失败:', error)
|
console.error('Audio playback failed:', error)
|
||||||
toast.error(t('chatHistory.audioPlayFailed'))
|
toast.error('Audio playback failed')
|
||||||
playingAudioId.value = null
|
playingAudioId.value = null
|
||||||
if (audioContext.value) {
|
if (audioContext.value) {
|
||||||
audioContext.value.destroy()
|
audioContext.value.destroy()
|
||||||
|
|
@ -225,15 +219,15 @@ const playAudio = debounce(async (audioId: string) => {
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
// 开始播放
|
// Start playback
|
||||||
audioContext.value.play()
|
audioContext.value.play()
|
||||||
}
|
}
|
||||||
catch (error) {
|
catch (error) {
|
||||||
console.error('播放音频失败:', error)
|
console.error('Audio playback failed:', error)
|
||||||
toast.error(t('chatHistory.playAudioFailed'))
|
toast.error('Audio playback failed')
|
||||||
playingAudioId.value = null
|
playingAudioId.value = null
|
||||||
}
|
}
|
||||||
}, 400)
|
}
|
||||||
|
|
||||||
function extractContentFromString(content: string) {
|
function extractContentFromString(content: string) {
|
||||||
if (!content || content.trim() === '') {
|
if (!content || content.trim() === '') {
|
||||||
|
|
@ -287,8 +281,8 @@ onLoad((options) => {
|
||||||
agentId.value = options.agentId
|
agentId.value = options.agentId
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
console.error('缺少必要参数')
|
console.error('Missing required parameters')
|
||||||
toast.error(t('chatHistory.parameterError'))
|
toast.error('Page parameter error')
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
@ -308,17 +302,17 @@ onUnload(() => {
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<view class="h-screen flex flex-col bg-[#f5f7fb]">
|
<view class="h-screen flex flex-col bg-[#f5f7fb]">
|
||||||
<!-- 状态栏背景 -->
|
<!-- Status bar background -->
|
||||||
<view class="w-full bg-white" :style="{ height: `${safeAreaInsets?.top}px` }" />
|
<view class="w-full bg-white" :style="{ height: `${safeAreaInsets?.top}px` }" />
|
||||||
|
|
||||||
<!-- 导航栏 -->
|
<!-- Navigation bar -->
|
||||||
<wd-navbar :title="t('chatHistory.pageTitle')">
|
<wd-navbar title="Chat Details">
|
||||||
<template #left>
|
<template #left>
|
||||||
<wd-icon name="arrow-left" size="18" @click="goBack" />
|
<wd-icon name="arrow-left" size="18" @click="goBack" />
|
||||||
</template>
|
</template>
|
||||||
</wd-navbar>
|
</wd-navbar>
|
||||||
|
|
||||||
<!-- 聊天消息列表 -->
|
<!-- Chat message list -->
|
||||||
<scroll-view
|
<scroll-view
|
||||||
scroll-y
|
scroll-y
|
||||||
:style="{ height: `calc(100vh - ${safeAreaInsets?.top || 0}px - 120rpx)` }"
|
:style="{ height: `calc(100vh - ${safeAreaInsets?.top || 0}px - 120rpx)` }"
|
||||||
|
|
@ -328,7 +322,7 @@ onUnload(() => {
|
||||||
<view v-if="loading" class="flex flex-col items-center justify-center gap-[20rpx] p-[100rpx_0]">
|
<view v-if="loading" class="flex flex-col items-center justify-center gap-[20rpx] p-[100rpx_0]">
|
||||||
<wd-loading />
|
<wd-loading />
|
||||||
<text class="text-[28rpx] text-[#65686f]">
|
<text class="text-[28rpx] text-[#65686f]">
|
||||||
{{ t('chatHistory.loading') }}
|
Loading...
|
||||||
</text>
|
</text>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
|
|
@ -351,7 +345,7 @@ onUnload(() => {
|
||||||
'tool-message': message.chatType === 3,
|
'tool-message': message.chatType === 3,
|
||||||
}"
|
}"
|
||||||
>
|
>
|
||||||
<!-- 消息气泡 -->
|
<!-- Message bubble -->
|
||||||
<view
|
<view
|
||||||
class="shadow-message break-words rounded-[20rpx] p-[24rpx] leading-[1.4]"
|
class="shadow-message break-words rounded-[20rpx] p-[24rpx] leading-[1.4]"
|
||||||
:class="{
|
:class="{
|
||||||
|
|
@ -409,9 +403,9 @@ onUnload(() => {
|
||||||
/>
|
/>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
<!-- 消息内容容器 -->
|
<!-- Message content container -->
|
||||||
<view class="min-w-0 flex-1">
|
<view class="min-w-0 flex-1">
|
||||||
<!-- 消息内容 -->
|
<!-- Message content -->
|
||||||
<text class="block text-[28rpx]">
|
<text class="block text-[28rpx]">
|
||||||
{{ getMessageContent(message) }}
|
{{ getMessageContent(message) }}
|
||||||
</text>
|
</text>
|
||||||
|
|
@ -419,7 +413,7 @@ onUnload(() => {
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
<!-- 说话人信息 -->
|
<!-- Speaker information -->
|
||||||
<text
|
<text
|
||||||
class="mx-[12rpx] text-[22rpx] text-[#9d9ea3]"
|
class="mx-[12rpx] text-[22rpx] text-[#9d9ea3]"
|
||||||
:class="{
|
:class="{
|
||||||
|
|
@ -437,7 +431,7 @@ onUnload(() => {
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
/* 自定义阴影和动画效果,无法用UnoCSS表示的样式 */
|
/* Custom shadow and animation effects, styles that cannot be represented by UnoCSS */
|
||||||
.shadow-message {
|
.shadow-message {
|
||||||
box-shadow: 0 2rpx 8rpx rgba(0, 0, 0, 0.06);
|
box-shadow: 0 2rpx 8rpx rgba(0, 0, 0, 0.06);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -39,7 +39,7 @@ systemInfo = uni.getSystemInfoSync()
|
||||||
safeAreaInsets = systemInfo.safeAreaInsets
|
safeAreaInsets = systemInfo.safeAreaInsets
|
||||||
// #endif
|
// #endif
|
||||||
|
|
||||||
// 聊天会话数据
|
// Chat session data
|
||||||
const sessionList = ref<ChatSession[]>([])
|
const sessionList = ref<ChatSession[]>([])
|
||||||
const loading = ref(false)
|
const loading = ref(false)
|
||||||
const loadingMore = ref(false)
|
const loadingMore = ref(false)
|
||||||
|
|
@ -47,7 +47,7 @@ const hasMore = ref(true)
|
||||||
const currentPage = ref(0)
|
const currentPage = ref(0)
|
||||||
const pageSize = 10
|
const pageSize = 10
|
||||||
|
|
||||||
// 使用传入的智能体ID
|
// Use passed agent ID
|
||||||
const currentAgentId = computed(() => {
|
const currentAgentId = computed(() => {
|
||||||
return props.agentId
|
return props.agentId
|
||||||
})
|
})
|
||||||
|
|
@ -57,7 +57,7 @@ async function loadChatSessions(page = 1, isUpdate = false) {
|
||||||
try {
|
try {
|
||||||
// 检查是否有当前选中的智能体
|
// 检查是否有当前选中的智能体
|
||||||
if (!currentAgentId.value) {
|
if (!currentAgentId.value) {
|
||||||
console.warn(t('chatHistory.noSelectedAgent'))
|
console.warn('No selected agent')
|
||||||
sessionList.value = []
|
sessionList.value = []
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
@ -84,12 +84,12 @@ async function loadChatSessions(page = 1, isUpdate = false) {
|
||||||
sessionList.value.push(...(response.list || []))
|
sessionList.value.push(...(response.list || []))
|
||||||
}
|
}
|
||||||
|
|
||||||
// 更新分页信息
|
// Update pagination info
|
||||||
hasMore.value = (response.list?.length || 0) === pageSize
|
hasMore.value = (response.list?.length || 0) === pageSize
|
||||||
currentPage.value = page
|
currentPage.value = page
|
||||||
}
|
}
|
||||||
catch (error) {
|
catch (error) {
|
||||||
console.error(t('chatHistory.getChatSessionsFailed'), error)
|
console.error('Failed to get chat session list:', error)
|
||||||
if (page === 1) {
|
if (page === 1) {
|
||||||
sessionList.value = []
|
sessionList.value = []
|
||||||
}
|
}
|
||||||
|
|
@ -100,14 +100,14 @@ async function loadChatSessions(page = 1, isUpdate = false) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 暴露给父组件的刷新方法
|
// Refresh method exposed to parent component
|
||||||
async function refresh() {
|
async function refresh() {
|
||||||
currentPage.value = 1
|
currentPage.value = 1
|
||||||
hasMore.value = true
|
hasMore.value = true
|
||||||
await loadChatSessions(1, true)
|
await loadChatSessions(1, true)
|
||||||
}
|
}
|
||||||
|
|
||||||
// 暴露给父组件的加载更多方法
|
// Load more method exposed to parent component
|
||||||
async function loadMore() {
|
async function loadMore() {
|
||||||
if (!hasMore.value || loadingMore.value) {
|
if (!hasMore.value || loadingMore.value) {
|
||||||
return
|
return
|
||||||
|
|
@ -115,47 +115,47 @@ async function loadMore() {
|
||||||
await loadChatSessions(currentPage.value + 1)
|
await loadChatSessions(currentPage.value + 1)
|
||||||
}
|
}
|
||||||
|
|
||||||
// 格式化时间
|
// Format time
|
||||||
function formatTime(timeStr: string) {
|
function formatTime(timeStr: string) {
|
||||||
if (!timeStr)
|
if (!timeStr)
|
||||||
return t('chatHistory.unknownTime')
|
return 'Unknown time'
|
||||||
|
|
||||||
// 处理时间字符串,确保格式正确
|
// Process time string to ensure correct format
|
||||||
const date = new Date(timeStr.replace(' ', 'T')) // 转换为ISO格式
|
const date = new Date(timeStr.replace(' ', 'T')) // Convert to ISO format
|
||||||
const now = new Date()
|
const now = new Date()
|
||||||
|
|
||||||
// 检查日期是否有效
|
// Check if date is valid
|
||||||
if (Number.isNaN(date.getTime())) {
|
if (Number.isNaN(date.getTime())) {
|
||||||
return timeStr // 如果解析失败,直接返回原字符串
|
return timeStr // If parsing fails, return original string directly
|
||||||
}
|
}
|
||||||
|
|
||||||
const diff = now.getTime() - date.getTime()
|
const diff = now.getTime() - date.getTime()
|
||||||
|
|
||||||
// 小于1分钟
|
// Less than 1 minute
|
||||||
if (diff < 60000)
|
if (diff < 60000)
|
||||||
return t('chatHistory.justNow')
|
return 'Just now'
|
||||||
|
|
||||||
// 小于1小时
|
// Less than 1 hour
|
||||||
if (diff < 3600000)
|
if (diff < 3600000)
|
||||||
return t('chatHistory.minutesAgo', { minutes: Math.floor(diff / 60000) })
|
return `${Math.floor(diff / 60000)} minutes ago`
|
||||||
|
|
||||||
// 小于1天(24小时)
|
// Less than 1 day (24 hours)
|
||||||
if (diff < 86400000)
|
if (diff < 86400000)
|
||||||
return t('chatHistory.hoursAgo', { hours: Math.floor(diff / 3600000) })
|
return `${Math.floor(diff / 3600000)} hours ago`
|
||||||
|
|
||||||
// 小于7天
|
// Less than 7 days
|
||||||
if (diff < 604800000) {
|
if (diff < 604800000) {
|
||||||
const days = Math.floor(diff / 86400000)
|
const days = Math.floor(diff / 86400000)
|
||||||
return t('chatHistory.daysAgo', { days })
|
return `${days} days ago`
|
||||||
}
|
}
|
||||||
|
|
||||||
// 超过7天,显示具体日期
|
// More than 7 days, show specific date
|
||||||
const year = date.getFullYear()
|
const year = date.getFullYear()
|
||||||
const month = String(date.getMonth() + 1).padStart(2, '0')
|
const month = String(date.getMonth() + 1).padStart(2, '0')
|
||||||
const day = String(date.getDate()).padStart(2, '0')
|
const day = String(date.getDate()).padStart(2, '0')
|
||||||
const currentYear = now.getFullYear()
|
const currentYear = now.getFullYear()
|
||||||
|
|
||||||
// 如果是当前年份,不显示年份
|
// If current year, don't show year
|
||||||
if (year === currentYear) {
|
if (year === currentYear) {
|
||||||
return `${month}-${day}`
|
return `${month}-${day}`
|
||||||
}
|
}
|
||||||
|
|
@ -163,7 +163,7 @@ function formatTime(timeStr: string) {
|
||||||
return `${year}-${month}-${day}`
|
return `${year}-${month}-${day}`
|
||||||
}
|
}
|
||||||
|
|
||||||
// 进入聊天详情
|
// Enter chat details
|
||||||
function goToChatDetail(session: ChatSession) {
|
function goToChatDetail(session: ChatSession) {
|
||||||
uni.navigateTo({
|
uni.navigateTo({
|
||||||
url: `/pages/chat-history/detail?sessionId=${session.sessionId}&agentId=${currentAgentId.value}`,
|
url: `/pages/chat-history/detail?sessionId=${session.sessionId}&agentId=${currentAgentId.value}`,
|
||||||
|
|
@ -190,7 +190,7 @@ defineExpose({
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<view class="chat-history-container" style="background: #f5f7fb; min-height: 100%;">
|
<view class="chat-history-container" style="background: #f5f7fb; min-height: 100%;">
|
||||||
<!-- 加载状态 -->
|
<!-- Loading state -->
|
||||||
<view v-if="loading && sessionList.length === 0" class="loading-container">
|
<view v-if="loading && sessionList.length === 0" class="loading-container">
|
||||||
<wd-loading color="#336cff" />
|
<wd-loading color="#336cff" />
|
||||||
<text class="loading-text">
|
<text class="loading-text">
|
||||||
|
|
@ -198,9 +198,9 @@ defineExpose({
|
||||||
</text>
|
</text>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
<!-- 会话列表 -->
|
<!-- Session list -->
|
||||||
<view v-else-if="sessionList.length > 0" class="session-container">
|
<view v-else-if="sessionList.length > 0" class="session-container">
|
||||||
<!-- 聊天会话列表 -->
|
<!-- Chat session list -->
|
||||||
<view class="session-list">
|
<view class="session-list">
|
||||||
<view
|
<view
|
||||||
v-for="session in sessionList"
|
v-for="session in sessionList"
|
||||||
|
|
@ -220,7 +220,7 @@ defineExpose({
|
||||||
</view>
|
</view>
|
||||||
<view class="session-meta">
|
<view class="session-meta">
|
||||||
<text class="chat-count">
|
<text class="chat-count">
|
||||||
{{ t('chatHistory.totalChats', { count: session.chatCount }) }}
|
{{ session.chatCount }} messages
|
||||||
</text>
|
</text>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
|
|
@ -229,23 +229,23 @@ defineExpose({
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
<!-- 加载更多状态 -->
|
<!-- Load more state -->
|
||||||
<view v-if="loadingMore" class="loading-more">
|
<view v-if="loadingMore" class="loading-more">
|
||||||
<wd-loading color="#336cff" size="24" />
|
<wd-loading color="#336cff" size="24" />
|
||||||
<text class="loading-more-text">
|
<text class="loading-more-text">
|
||||||
{{ t('chatHistory.loading') }}
|
Loading...
|
||||||
</text>
|
</text>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
<!-- 没有更多数据 -->
|
<!-- No more data -->
|
||||||
<view v-else-if="!hasMore && sessionList.length > 0" class="no-more">
|
<view v-else-if="!hasMore && sessionList.length > 0" class="no-more">
|
||||||
<text class="no-more-text">
|
<text class="no-more-text">
|
||||||
{{ t('chatHistory.noMoreData') }}
|
No more data
|
||||||
</text>
|
</text>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
<!-- 空状态 -->
|
<!-- Empty state -->
|
||||||
<view v-else-if="!loading" class="empty-state">
|
<view v-else-if="!loading" class="empty-state">
|
||||||
<wd-icon name="chat" custom-class="empty-icon" />
|
<wd-icon name="chat" custom-class="empty-icon" />
|
||||||
<text class="empty-text">
|
<text class="empty-text">
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,8 @@
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { computed, ref } from 'vue'
|
import { computed, ref } from 'vue'
|
||||||
import { useToast } from 'wot-design-uni'
|
import { useToast } from 'wot-design-uni'
|
||||||
import { t } from '@/i18n'
|
|
||||||
|
|
||||||
// 类型定义
|
// Type definitions
|
||||||
interface WiFiNetwork {
|
interface WiFiNetwork {
|
||||||
ssid: string
|
ssid: string
|
||||||
rssi: number
|
rssi: number
|
||||||
|
|
@ -19,10 +18,10 @@ interface Props {
|
||||||
|
|
||||||
const props = defineProps<Props>()
|
const props = defineProps<Props>()
|
||||||
|
|
||||||
// Toast 实例
|
// Toast instance
|
||||||
const toast = useToast()
|
const toast = useToast()
|
||||||
|
|
||||||
// 响应式数据
|
// Reactive data
|
||||||
const generating = ref(false)
|
const generating = ref(false)
|
||||||
const playing = ref(false)
|
const playing = ref(false)
|
||||||
const audioGenerated = ref(false)
|
const audioGenerated = ref(false)
|
||||||
|
|
@ -30,15 +29,15 @@ const autoLoop = ref(true)
|
||||||
const audioFilePath = ref('')
|
const audioFilePath = ref('')
|
||||||
const audioContext = ref<any>(null)
|
const audioContext = ref<any>(null)
|
||||||
|
|
||||||
// AFSK调制参数 - 参考HTML文件
|
// AFSK modulation parameters - reference HTML file
|
||||||
const MARK = 1800 // 二进制1的频率 (Hz)
|
const MARK = 1800 // Frequency for binary 1 (Hz)
|
||||||
const SPACE = 1500 // 二进制0的频率 (Hz)
|
const SPACE = 1500 // Frequency for binary 0 (Hz)
|
||||||
const SAMPLE_RATE = 44100 // 采样率
|
const SAMPLE_RATE = 44100 // Sample rate
|
||||||
const BIT_RATE = 100 // 比特率 (bps)
|
const BIT_RATE = 100 // Bit rate (bps)
|
||||||
const START_BYTES = [0x01, 0x02] // 起始标记
|
const START_BYTES = [0x01, 0x02] // Start marker
|
||||||
const END_BYTES = [0x03, 0x04] // 结束标记
|
const END_BYTES = [0x03, 0x04] // End marker
|
||||||
|
|
||||||
// 计算属性
|
// Computed properties
|
||||||
const canGenerate = computed(() => {
|
const canGenerate = computed(() => {
|
||||||
if (!props.selectedNetwork)
|
if (!props.selectedNetwork)
|
||||||
return false
|
return false
|
||||||
|
|
@ -49,15 +48,15 @@ const canGenerate = computed(() => {
|
||||||
|
|
||||||
const audioLengthText = computed(() => {
|
const audioLengthText = computed(() => {
|
||||||
if (!props.selectedNetwork)
|
if (!props.selectedNetwork)
|
||||||
return '0秒'
|
return '0 seconds'
|
||||||
const dataStr = `${props.selectedNetwork.ssid}\n${props.password}`
|
const dataStr = `${props.selectedNetwork.ssid}\n${props.password}`
|
||||||
const textBytes = stringToBytes(dataStr)
|
const textBytes = stringToBytes(dataStr)
|
||||||
const totalBits = (START_BYTES.length + textBytes.length + 1 + END_BYTES.length) * 8
|
const totalBits = (START_BYTES.length + textBytes.length + 1 + END_BYTES.length) * 8
|
||||||
const duration = Math.ceil(totalBits / BIT_RATE)
|
const duration = Math.ceil(totalBits / BIT_RATE)
|
||||||
return `${t('deviceConfig.about')}${duration}${t('deviceConfig.seconds')}`
|
return `About ${duration} seconds`
|
||||||
})
|
})
|
||||||
|
|
||||||
// 字符串转字节数组 - uniapp兼容版本
|
// String to byte array - uniapp compatible version
|
||||||
function stringToBytes(str: string): number[] {
|
function stringToBytes(str: string): number[] {
|
||||||
const bytes: number[] = []
|
const bytes: number[] = []
|
||||||
for (let i = 0; i < str.length; i++) {
|
for (let i = 0; i < str.length; i++) {
|
||||||
|
|
@ -75,7 +74,7 @@ function stringToBytes(str: string): number[] {
|
||||||
bytes.push(0x80 | (code & 0x3F))
|
bytes.push(0x80 | (code & 0x3F))
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// 代理对处理
|
// Surrogate pair handling
|
||||||
i++
|
i++
|
||||||
const hi = code
|
const hi = code
|
||||||
const lo = str.charCodeAt(i)
|
const lo = str.charCodeAt(i)
|
||||||
|
|
@ -89,12 +88,12 @@ function stringToBytes(str: string): number[] {
|
||||||
return bytes
|
return bytes
|
||||||
}
|
}
|
||||||
|
|
||||||
// 校验和计算 - 参考HTML文件
|
// Checksum calculation - reference HTML file
|
||||||
function checksum(data: number[]): number {
|
function checksum(data: number[]): number {
|
||||||
return data.reduce((sum, b) => (sum + b) & 0xFF, 0)
|
return data.reduce((sum, b) => (sum + b) & 0xFF, 0)
|
||||||
}
|
}
|
||||||
|
|
||||||
// 字节转比特位 - 参考HTML文件
|
// Byte to bit conversion - reference HTML file
|
||||||
function toBits(byte: number): number[] {
|
function toBits(byte: number): number[] {
|
||||||
const bits: number[] = []
|
const bits: number[] = []
|
||||||
for (let i = 7; i >= 0; i--) {
|
for (let i = 7; i >= 0; i--) {
|
||||||
|
|
@ -103,7 +102,7 @@ function toBits(byte: number): number[] {
|
||||||
return bits
|
return bits
|
||||||
}
|
}
|
||||||
|
|
||||||
// AFSK调制 - 参考HTML文件算法
|
// AFSK modulation - reference HTML file algorithm
|
||||||
function afskModulate(bits: number[]): Float32Array {
|
function afskModulate(bits: number[]): Float32Array {
|
||||||
const samplesPerBit = SAMPLE_RATE / BIT_RATE
|
const samplesPerBit = SAMPLE_RATE / BIT_RATE
|
||||||
const totalSamples = Math.floor(bits.length * samplesPerBit)
|
const totalSamples = Math.floor(bits.length * samplesPerBit)
|
||||||
|
|
@ -120,7 +119,7 @@ function afskModulate(bits: number[]): Float32Array {
|
||||||
return buffer
|
return buffer
|
||||||
}
|
}
|
||||||
|
|
||||||
// 浮点转16位PCM - 参考HTML文件
|
// Float to 16-bit PCM - reference HTML file
|
||||||
function floatTo16BitPCM(floatSamples: Float32Array): Uint8Array {
|
function floatTo16BitPCM(floatSamples: Float32Array): Uint8Array {
|
||||||
const buffer = new Uint8Array(floatSamples.length * 2)
|
const buffer = new Uint8Array(floatSamples.length * 2)
|
||||||
for (let i = 0; i < floatSamples.length; i++) {
|
for (let i = 0; i < floatSamples.length; i++) {
|
||||||
|
|
@ -132,10 +131,10 @@ function floatTo16BitPCM(floatSamples: Float32Array): Uint8Array {
|
||||||
return buffer
|
return buffer
|
||||||
}
|
}
|
||||||
|
|
||||||
// base64编码表
|
// Base64 encoding table
|
||||||
const base64Chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'
|
const base64Chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'
|
||||||
|
|
||||||
// 兼容的base64编码实现
|
// Compatible base64 encoding implementation
|
||||||
function base64Encode(bytes: Uint8Array): string {
|
function base64Encode(bytes: Uint8Array): string {
|
||||||
let result = ''
|
let result = ''
|
||||||
let i = 0
|
let i = 0
|
||||||
|
|
@ -156,11 +155,11 @@ function base64Encode(bytes: Uint8Array): string {
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
|
||||||
// 数组转base64编码 - 兼容版本
|
// Array to base64 encoding - compatible version
|
||||||
function arrayBufferToBase64(buffer: ArrayBuffer): string {
|
function arrayBufferToBase64(buffer: ArrayBuffer): string {
|
||||||
const bytes = new Uint8Array(buffer)
|
const bytes = new Uint8Array(buffer)
|
||||||
|
|
||||||
// 尝试使用原生btoa,如果不存在则使用自定义实现
|
// Try to use native btoa, if not available use custom implementation
|
||||||
if (typeof btoa !== 'undefined') {
|
if (typeof btoa !== 'undefined') {
|
||||||
let binary = ''
|
let binary = ''
|
||||||
for (let i = 0; i < bytes.byteLength; i++) {
|
for (let i = 0; i < bytes.byteLength; i++) {
|
||||||
|
|
@ -173,7 +172,7 @@ function arrayBufferToBase64(buffer: ArrayBuffer): string {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 构建WAV文件 - 返回ArrayBuffer而不是Blob
|
// Build WAV file - return ArrayBuffer instead of Blob
|
||||||
function buildWav(pcm: Uint8Array): ArrayBuffer {
|
function buildWav(pcm: Uint8Array): ArrayBuffer {
|
||||||
const wavHeader = new Uint8Array(44)
|
const wavHeader = new Uint8Array(44)
|
||||||
const dataLen = pcm.length
|
const dataLen = pcm.length
|
||||||
|
|
@ -211,7 +210,7 @@ function buildWav(pcm: Uint8Array): ArrayBuffer {
|
||||||
writeStr(36, 'data')
|
writeStr(36, 'data')
|
||||||
write32(40, dataLen)
|
write32(40, dataLen)
|
||||||
|
|
||||||
// 合并header和数据
|
// Merge header and data
|
||||||
const result = new ArrayBuffer(44 + dataLen)
|
const result = new ArrayBuffer(44 + dataLen)
|
||||||
const resultView = new Uint8Array(result)
|
const resultView = new Uint8Array(result)
|
||||||
resultView.set(wavHeader)
|
resultView.set(wavHeader)
|
||||||
|
|
@ -220,7 +219,7 @@ function buildWav(pcm: Uint8Array): ArrayBuffer {
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
|
||||||
// 生成并播放声波 - 主要功能函数
|
// Generate and play sound wave - main function
|
||||||
async function generateAndPlay() {
|
async function generateAndPlay() {
|
||||||
if (!canGenerate.value || !props.selectedNetwork)
|
if (!canGenerate.value || !props.selectedNetwork)
|
||||||
return
|
return
|
||||||
|
|
@ -228,26 +227,26 @@ async function generateAndPlay() {
|
||||||
generating.value = true
|
generating.value = true
|
||||||
|
|
||||||
try {
|
try {
|
||||||
console.log(t('deviceConfig.generatingUltrasonicConfigAudio') + '...')
|
console.log('Generating ultrasonic configuration audio...')
|
||||||
|
|
||||||
// 准备配网数据 - 参考HTML文件格式
|
// Prepare network configuration data - reference HTML file format
|
||||||
const dataStr = `${props.selectedNetwork.ssid}\n${props.password}`
|
const dataStr = `${props.selectedNetwork.ssid}\n${props.password}`
|
||||||
const textBytes = stringToBytes(dataStr)
|
const textBytes = stringToBytes(dataStr)
|
||||||
const fullBytes = [...START_BYTES, ...textBytes, checksum(textBytes), ...END_BYTES]
|
const fullBytes = [...START_BYTES, ...textBytes, checksum(textBytes), ...END_BYTES]
|
||||||
|
|
||||||
console.log(t('deviceConfig.configData') + ':', { ssid: props.selectedNetwork.ssid, password: props.password })
|
console.log('Network config data:', { ssid: props.selectedNetwork.ssid, password: props.password })
|
||||||
console.log(t('deviceConfig.dataBytesLength') + ':', textBytes.length)
|
console.log('Data byte length:', textBytes.length)
|
||||||
|
|
||||||
// 转换为比特流
|
// Convert to bit stream
|
||||||
let bits: number[] = []
|
let bits: number[] = []
|
||||||
fullBytes.forEach((b) => {
|
fullBytes.forEach((b) => {
|
||||||
bits = bits.concat(toBits(b))
|
bits = bits.concat(toBits(b))
|
||||||
})
|
})
|
||||||
|
|
||||||
console.log(t('deviceConfig.bitStreamLength') + ':', bits.length)
|
console.log('Bit stream length:', bits.length)
|
||||||
|
|
||||||
// AFSK调制 - 减少采样率降低文件大小
|
// AFSK modulation - reduce sample rate to lower file size
|
||||||
const reducedSampleRate = 22050 // 降低采样率
|
const reducedSampleRate = 22050 // Reduced sample rate
|
||||||
const samplesPerBit = reducedSampleRate / BIT_RATE
|
const samplesPerBit = reducedSampleRate / BIT_RATE
|
||||||
const totalSamples = Math.floor(bits.length * samplesPerBit)
|
const totalSamples = Math.floor(bits.length * samplesPerBit)
|
||||||
const floatBuf = new Float32Array(totalSamples)
|
const floatBuf = new Float32Array(totalSamples)
|
||||||
|
|
@ -256,46 +255,46 @@ async function generateAndPlay() {
|
||||||
const freq = bits[i] ? MARK : SPACE
|
const freq = bits[i] ? MARK : SPACE
|
||||||
for (let j = 0; j < samplesPerBit; j++) {
|
for (let j = 0; j < samplesPerBit; j++) {
|
||||||
const t = (i * samplesPerBit + j) / reducedSampleRate
|
const t = (i * samplesPerBit + j) / reducedSampleRate
|
||||||
floatBuf[i * samplesPerBit + j] = Math.sin(2 * Math.PI * freq * t) * 0.5 // 降低音量
|
floatBuf[i * samplesPerBit + j] = Math.sin(2 * Math.PI * freq * t) * 0.5 // Reduce volume
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const pcmBuf = floatTo16BitPCM(floatBuf)
|
const pcmBuf = floatTo16BitPCM(floatBuf)
|
||||||
|
|
||||||
// 生成WAV文件 - 使用降低的采样率
|
// Generate WAV file - use reduced sample rate
|
||||||
const wavBuffer = buildWavOptimized(pcmBuf, reducedSampleRate)
|
const wavBuffer = buildWavOptimized(pcmBuf, reducedSampleRate)
|
||||||
const base64 = arrayBufferToBase64(wavBuffer)
|
const base64 = arrayBufferToBase64(wavBuffer)
|
||||||
const dataUri = `data:audio/wav;base64,${base64}`
|
const dataUri = `data:audio/wav;base64,${base64}`
|
||||||
|
|
||||||
console.log(t('deviceConfig.base64Length') + ':', base64.length, t('deviceConfig.about'), Math.round(base64.length / 1024), 'KB')
|
console.log('base64 length:', base64.length, 'approx', Math.round(base64.length / 1024), 'KB')
|
||||||
|
|
||||||
// 检查数据大小
|
// Check data size
|
||||||
if (base64.length > 1024 * 1024) { // 超过1MB
|
if (base64.length > 1024 * 1024) { // Over 1MB
|
||||||
throw new Error(t('deviceConfig.audioFileTooLarge'))
|
throw new Error('Audio file too large, please shorten SSID or password length')
|
||||||
}
|
}
|
||||||
|
|
||||||
audioFilePath.value = dataUri
|
audioFilePath.value = dataUri
|
||||||
audioGenerated.value = true
|
audioGenerated.value = true
|
||||||
|
|
||||||
console.log(t('deviceConfig.audioGenerationSuccess') + ',比特流长度:', bits.length, t('deviceConfig.samplePoints') + ':', floatBuf.length)
|
console.log('Audio generation successful, bit stream length:', bits.length, 'sample count:', floatBuf.length)
|
||||||
|
|
||||||
toast.success(t('deviceConfig.soundWaveGenerationSuccess'))
|
toast.success('Sound wave generated successfully')
|
||||||
|
|
||||||
// 延迟播放
|
// Delayed playback
|
||||||
setTimeout(async () => {
|
setTimeout(async () => {
|
||||||
await playAudio()
|
await playAudio()
|
||||||
}, 800) // 增加延迟时间
|
}, 800) // Increase delay time
|
||||||
}
|
}
|
||||||
catch (error) {
|
catch (error) {
|
||||||
console.error(t('deviceConfig.audioGenerationFailed') + ':', error)
|
console.error('Audio generation failed:', error)
|
||||||
toast.error(`${t('deviceConfig.soundWaveGenerationFailed')}: ${error.message || error}`)
|
toast.error(`Sound wave generation failed: ${error.message || error}`)
|
||||||
}
|
}
|
||||||
finally {
|
finally {
|
||||||
generating.value = false
|
generating.value = false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 优化的WAV构建函数
|
// Optimized WAV build function
|
||||||
function buildWavOptimized(pcm: Uint8Array, sampleRate: number): ArrayBuffer {
|
function buildWavOptimized(pcm: Uint8Array, sampleRate: number): ArrayBuffer {
|
||||||
const wavHeader = new Uint8Array(44)
|
const wavHeader = new Uint8Array(44)
|
||||||
const dataLen = pcm.length
|
const dataLen = pcm.length
|
||||||
|
|
@ -326,14 +325,14 @@ function buildWavOptimized(pcm: Uint8Array, sampleRate: number): ArrayBuffer {
|
||||||
write32(16, 16)
|
write32(16, 16)
|
||||||
write16(20, 1)
|
write16(20, 1)
|
||||||
write16(22, 1)
|
write16(22, 1)
|
||||||
write32(24, sampleRate) // 使用传入的采样率
|
write32(24, sampleRate) // Use passed sample rate
|
||||||
write32(28, sampleRate * 2)
|
write32(28, sampleRate * 2)
|
||||||
write16(32, 2)
|
write16(32, 2)
|
||||||
write16(34, 16)
|
write16(34, 16)
|
||||||
writeStr(36, 'data')
|
writeStr(36, 'data')
|
||||||
write32(40, dataLen)
|
write32(40, dataLen)
|
||||||
|
|
||||||
// 合并header和数据
|
// Merge header and data
|
||||||
const result = new ArrayBuffer(44 + dataLen)
|
const result = new ArrayBuffer(44 + dataLen)
|
||||||
const resultView = new Uint8Array(result)
|
const resultView = new Uint8Array(result)
|
||||||
resultView.set(wavHeader)
|
resultView.set(wavHeader)
|
||||||
|
|
@ -342,41 +341,41 @@ function buildWavOptimized(pcm: Uint8Array, sampleRate: number): ArrayBuffer {
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
|
||||||
// 播放音频
|
// Play audio
|
||||||
async function playAudio() {
|
async function playAudio() {
|
||||||
if (!audioFilePath.value) {
|
if (!audioFilePath.value) {
|
||||||
toast.error(t('deviceConfig.pleaseGenerateAudioFirst'))
|
toast.error('Please generate audio first')
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// 强制清理所有旧的音频实例
|
// Force cleanup of all old audio instances
|
||||||
await cleanupAudio()
|
await cleanupAudio()
|
||||||
|
|
||||||
// 等待一下确保清理完成
|
// Wait to ensure cleanup is complete
|
||||||
await new Promise(resolve => setTimeout(resolve, 200))
|
await new Promise(resolve => setTimeout(resolve, 200))
|
||||||
|
|
||||||
playing.value = true
|
playing.value = true
|
||||||
console.log(t('deviceConfig.startPlayingUltrasonicConfigAudio'))
|
console.log('Starting ultrasonic network config audio playback')
|
||||||
|
|
||||||
// 创建新的音频上下文
|
// Create new audio context
|
||||||
const innerAudioContext = uni.createInnerAudioContext()
|
const innerAudioContext = uni.createInnerAudioContext()
|
||||||
audioContext.value = innerAudioContext
|
audioContext.value = innerAudioContext
|
||||||
|
|
||||||
// 最简化的音频设置
|
// Simplified audio settings
|
||||||
innerAudioContext.src = audioFilePath.value
|
innerAudioContext.src = audioFilePath.value
|
||||||
innerAudioContext.loop = autoLoop.value
|
innerAudioContext.loop = autoLoop.value
|
||||||
innerAudioContext.volume = 0.8
|
innerAudioContext.volume = 0.8
|
||||||
innerAudioContext.autoplay = false
|
innerAudioContext.autoplay = false
|
||||||
|
|
||||||
// 简化的事件监听
|
// Simplified event listeners
|
||||||
innerAudioContext.onPlay(() => {
|
innerAudioContext.onPlay(() => {
|
||||||
console.log(t('deviceConfig.ultrasonicAudioStartedPlaying'))
|
console.log('Ultrasonic audio playback started')
|
||||||
toast.success(t('deviceConfig.startPlayingConfigSoundWave'))
|
toast.success('Started playing network config sound wave')
|
||||||
})
|
})
|
||||||
|
|
||||||
innerAudioContext.onEnded(() => {
|
innerAudioContext.onEnded(() => {
|
||||||
console.log(t('deviceConfig.ultrasonicAudioPlaybackEnded'))
|
console.log('Ultrasonic audio playback ended')
|
||||||
if (!autoLoop.value) {
|
if (!autoLoop.value) {
|
||||||
playing.value = false
|
playing.value = false
|
||||||
cleanupAudio()
|
cleanupAudio()
|
||||||
|
|
@ -384,18 +383,18 @@ async function playAudio() {
|
||||||
})
|
})
|
||||||
|
|
||||||
innerAudioContext.onError((error) => {
|
innerAudioContext.onError((error) => {
|
||||||
console.error(t('deviceConfig.audioPlaybackFailed') + ':', error)
|
console.error('Audio playback failed:', error)
|
||||||
playing.value = false
|
playing.value = false
|
||||||
|
|
||||||
let errorMsg = t('deviceConfig.audioPlaybackFailed')
|
let errorMsg = 'Audio playback failed'
|
||||||
if (error.errCode === -99) {
|
if (error.errCode === -99) {
|
||||||
errorMsg = t('deviceConfig.audioResourceBusy')
|
errorMsg = 'Audio resource busy, please try again later'
|
||||||
}
|
}
|
||||||
else if (error.errCode === 10004) {
|
else if (error.errCode === 10004) {
|
||||||
errorMsg = t('deviceConfig.audioFormatNotSupported')
|
errorMsg = 'Audio format not supported, possibly data URI issue'
|
||||||
}
|
}
|
||||||
else if (error.errCode === 10003) {
|
else if (error.errCode === 10003) {
|
||||||
errorMsg = t('deviceConfig.audioFileError')
|
errorMsg = 'Audio file error'
|
||||||
}
|
}
|
||||||
|
|
||||||
toast.error(errorMsg)
|
toast.error(errorMsg)
|
||||||
|
|
@ -404,36 +403,36 @@ async function playAudio() {
|
||||||
})
|
})
|
||||||
|
|
||||||
innerAudioContext.onStop(() => {
|
innerAudioContext.onStop(() => {
|
||||||
console.log('音频播放停止')
|
console.log('Audio playback stopped')
|
||||||
playing.value = false
|
playing.value = false
|
||||||
})
|
})
|
||||||
|
|
||||||
// 延迟播放
|
// Delayed playback
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
if (audioContext.value) {
|
if (audioContext.value) {
|
||||||
console.log('尝试播放音频,src长度:', audioFilePath.value.length)
|
console.log('Attempting to play audio, src length:', audioFilePath.value.length)
|
||||||
audioContext.value.play()
|
audioContext.value.play()
|
||||||
}
|
}
|
||||||
}, 300)
|
}, 300)
|
||||||
}
|
}
|
||||||
catch (error) {
|
catch (error) {
|
||||||
console.error(t('deviceConfig.audioPlaybackError') + ':', error)
|
console.error('Audio playback exception:', error)
|
||||||
playing.value = false
|
playing.value = false
|
||||||
await cleanupAudio()
|
await cleanupAudio()
|
||||||
toast.error(`${t('deviceConfig.playbackFailed')}: ${error.message}`)
|
toast.error(`Playback failed: ${error.message}`)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 清理音频资源
|
// Cleanup audio resources
|
||||||
async function cleanupAudio() {
|
async function cleanupAudio() {
|
||||||
if (audioContext.value) {
|
if (audioContext.value) {
|
||||||
try {
|
try {
|
||||||
audioContext.value.pause()
|
audioContext.value.pause()
|
||||||
audioContext.value.destroy()
|
audioContext.value.destroy()
|
||||||
console.log(t('deviceConfig.cleaningUpAudioContext'))
|
console.log('Cleanup audio context')
|
||||||
}
|
}
|
||||||
catch (e) {
|
catch (e) {
|
||||||
console.log(t('deviceConfig.cleaningUpAudioContextFailed') + ':', e)
|
console.log('Cleanup audio context failed:', e)
|
||||||
}
|
}
|
||||||
finally {
|
finally {
|
||||||
audioContext.value = null
|
audioContext.value = null
|
||||||
|
|
@ -441,39 +440,39 @@ async function cleanupAudio() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 停止播放
|
// Stop playback
|
||||||
async function stopAudio() {
|
async function stopAudio() {
|
||||||
playing.value = false
|
playing.value = false
|
||||||
await cleanupAudio()
|
await cleanupAudio()
|
||||||
|
|
||||||
console.log(t('deviceConfig.stoppedPlayingUltrasonicAudio'))
|
console.log('Stop ultrasonic audio playback')
|
||||||
toast.success(t('deviceConfig.stoppedPlaying'))
|
toast.success('Playback stopped')
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<view class="ultrasonic-config">
|
<view class="ultrasonic-config">
|
||||||
<!-- 选中的网络信息 -->
|
<!-- Selected network information -->
|
||||||
<view v-if="props.selectedNetwork" class="selected-network">
|
<view v-if="props.selectedNetwork" class="selected-network">
|
||||||
<view class="network-info">
|
<view class="network-info">
|
||||||
<view class="network-name">
|
<view class="network-name">
|
||||||
{{ t('deviceConfig.selectedNetwork') }}: {{ props.selectedNetwork.ssid }}
|
Selected network: {{ props.selectedNetwork.ssid }}
|
||||||
</view>
|
</view>
|
||||||
<view class="network-details">
|
<view class="network-details">
|
||||||
<text class="network-signal">
|
<text class="network-signal">
|
||||||
{{ t('deviceConfig.signal') }}: {{ props.selectedNetwork.rssi }}dBm
|
Signal: {{ props.selectedNetwork.rssi }}dBm
|
||||||
</text>
|
</text>
|
||||||
<text class="network-security">
|
<text class="network-security">
|
||||||
{{ props.selectedNetwork.authmode === 0 ? t('deviceConfig.openNetwork') : t('deviceConfig.encryptedNetwork') }}
|
{{ props.selectedNetwork.authmode === 0 ? 'Open network' : 'Encrypted network' }}
|
||||||
</text>
|
</text>
|
||||||
</view>
|
</view>
|
||||||
<view v-if="props.password" class="network-password">
|
<view v-if="props.password" class="network-password">
|
||||||
{{ t('deviceConfig.password') }}: {{ '*'.repeat(props.password.length) }}
|
Password: {{ '*'.repeat(props.password.length) }}
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
<!-- 超声波配网操作 -->
|
<!-- Ultrasonic network configuration operations -->
|
||||||
<view class="submit-section">
|
<view class="submit-section">
|
||||||
<wd-button
|
<wd-button
|
||||||
type="primary"
|
type="primary"
|
||||||
|
|
@ -483,7 +482,7 @@ async function stopAudio() {
|
||||||
:disabled="!canGenerate"
|
:disabled="!canGenerate"
|
||||||
@click="generateAndPlay"
|
@click="generateAndPlay"
|
||||||
>
|
>
|
||||||
{{ generating ? t('deviceConfig.generating') : '🎵 ' + t('deviceConfig.generateAndPlaySoundWave') }}
|
{{ generating ? 'Generating...' : '🎵 Generate and play sound wave' }}
|
||||||
</wd-button>
|
</wd-button>
|
||||||
|
|
||||||
<wd-button
|
<wd-button
|
||||||
|
|
@ -494,7 +493,7 @@ async function stopAudio() {
|
||||||
:loading="playing"
|
:loading="playing"
|
||||||
@click="playAudio"
|
@click="playAudio"
|
||||||
>
|
>
|
||||||
{{ playing ? t('deviceConfig.playing') : '🔊 ' + t('deviceConfig.playSoundWave') }}
|
{{ playing ? 'Playing...' : '🔊 Play sound wave' }}
|
||||||
</wd-button>
|
</wd-button>
|
||||||
|
|
||||||
<wd-button
|
<wd-button
|
||||||
|
|
@ -504,63 +503,62 @@ async function stopAudio() {
|
||||||
block
|
block
|
||||||
@click="stopAudio"
|
@click="stopAudio"
|
||||||
>
|
>
|
||||||
⏹️ {{ t('deviceConfig.stopPlaying') }}
|
⏹️ Stop playback
|
||||||
</wd-button>
|
</wd-button>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
<!-- 音频控制选项 -->
|
<!-- Audio control options -->
|
||||||
<view v-if="audioGenerated" class="audio-options">
|
<view v-if="audioGenerated" class="audio-options">
|
||||||
<view class="option-item">
|
<view class="option-item">
|
||||||
<wd-checkbox v-model="autoLoop">
|
<wd-checkbox v-model="autoLoop">
|
||||||
{{ t('deviceConfig.autoLoopPlaySoundWave') }}
|
Auto loop sound wave playback
|
||||||
</wd-checkbox>
|
</wd-checkbox>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
<!-- 音频播放器 -->
|
<!-- Audio player -->
|
||||||
<view v-if="audioGenerated" class="audio-player">
|
<view v-if="audioGenerated" class="audio-player">
|
||||||
<view class="player-info">
|
<view class="player-info">
|
||||||
<text class="audio-title">
|
<text class="audio-title">
|
||||||
{{ t('deviceConfig.configAudioFile') }}
|
Network config audio file
|
||||||
</text>
|
</text>
|
||||||
<text class="audio-duration">
|
<text class="audio-duration">
|
||||||
{{ t('deviceConfig.duration') }}: {{ audioLengthText }}
|
Duration: {{ audioLengthText }}
|
||||||
</text>
|
</text>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
<!-- 使用说明 -->
|
<!-- Usage instructions -->
|
||||||
<view class="help-section">
|
<view class="help-section">
|
||||||
<view class="help-title">
|
<view class="help-title">
|
||||||
{{ t('deviceConfig.ultrasonicConfigInstructions') }}
|
Ultrasonic Network Configuration Instructions
|
||||||
</view>
|
</view>
|
||||||
<view class="help-content">
|
<view class="help-content">
|
||||||
<text class="help-item">
|
<text class="help-item">
|
||||||
1. {{ t('deviceConfig.ensureWifiNetworkSelectedAndPasswordEntered') }}
|
• If configuration fails, please check if WiFi password is correct network is selected and password is entered
|
||||||
</text>
|
</text>
|
||||||
<text class="help-item">
|
<text class="help-item">
|
||||||
2. {{ t('deviceConfig.clickGenerateAndPlaySoundWave') }}
|
2. Click generate and play sound wave, system will encode network config info as audio
|
||||||
</text>
|
</text>
|
||||||
<text class="help-item">
|
<text class="help-item">
|
||||||
3. {{ t('deviceConfig.bringPhoneCloseToXiaozhiDevice') }}
|
3. Place phone close to device so device can hear the audio signal (distance 1-2 meters)
|
||||||
</text>
|
</text>
|
||||||
<text class="help-item">
|
<text class="help-item">
|
||||||
4. {{ t('deviceConfig.duringAudioPlaybackXiaozhiWillReceive') }}
|
4. During audio playback, device will receive and decode network config info
|
||||||
</text>
|
</text>
|
||||||
<text class="help-item">
|
<text class="help-item">
|
||||||
5. {{ t('deviceConfig.afterConfigSuccessDeviceWillConnect') }}
|
5. Device will automatically connect to WiFi network after receiving signal
|
||||||
</text>
|
</text>
|
||||||
<text class="help-tip">
|
<text class="help-tip">
|
||||||
{{ t('deviceConfig.usesAfskModulation') }}
|
Using AFSK modulation technology, transmitting data through 1800Hz and 1500Hz frequencies
|
||||||
</text>
|
</text>
|
||||||
<text class="help-tip">
|
<text class="help-tip">
|
||||||
{{ t('deviceConfig.ensureModeratePhoneVolume') }}
|
• Please ensure phone volume is set to moderate level, avoiding environmental noise interference
|
||||||
</text>
|
</text>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<style scoped>
|
<style scoped>
|
||||||
.ultrasonic-config {
|
.ultrasonic-config {
|
||||||
padding: 20rpx 0;
|
padding: 20rpx 0;
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@ import { computed, ref } from 'vue'
|
||||||
import { t } from '@/i18n'
|
import { t } from '@/i18n'
|
||||||
import { toast } from '@/utils/toast'
|
import { toast } from '@/utils/toast'
|
||||||
|
|
||||||
// 类型定义
|
// Type definitions
|
||||||
interface WiFiNetwork {
|
interface WiFiNetwork {
|
||||||
ssid: string
|
ssid: string
|
||||||
rssi: number
|
rssi: number
|
||||||
|
|
@ -22,7 +22,7 @@ const props = defineProps<Props>()
|
||||||
// 响应式数据
|
// 响应式数据
|
||||||
const configuring = ref(false)
|
const configuring = ref(false)
|
||||||
|
|
||||||
// 计算属性
|
// Computed properties
|
||||||
const canSubmit = computed(() => {
|
const canSubmit = computed(() => {
|
||||||
if (!props.selectedNetwork)
|
if (!props.selectedNetwork)
|
||||||
return false
|
return false
|
||||||
|
|
@ -31,7 +31,7 @@ const canSubmit = computed(() => {
|
||||||
return true
|
return true
|
||||||
})
|
})
|
||||||
|
|
||||||
// ESP32连接检查
|
// ESP32 connection check
|
||||||
async function checkESP32Connection() {
|
async function checkESP32Connection() {
|
||||||
try {
|
try {
|
||||||
const response = await uni.request({
|
const response = await uni.request({
|
||||||
|
|
@ -47,12 +47,12 @@ async function checkESP32Connection() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 提交配网
|
// Submit network configuration
|
||||||
async function submitConfig() {
|
async function submitConfig() {
|
||||||
if (!props.selectedNetwork)
|
if (!props.selectedNetwork)
|
||||||
return
|
return
|
||||||
|
|
||||||
// 检查ESP32连接
|
// Check ESP32 connection
|
||||||
const connected = await checkESP32Connection()
|
const connected = await checkESP32Connection()
|
||||||
if (!connected) {
|
if (!connected) {
|
||||||
toast.error(t('deviceConfig.connectXiaozhiHotspot'))
|
toast.error(t('deviceConfig.connectXiaozhiHotspot'))
|
||||||
|
|
@ -76,7 +76,7 @@ async function submitConfig() {
|
||||||
timeout: 15000,
|
timeout: 15000,
|
||||||
})
|
})
|
||||||
|
|
||||||
console.log('WiFi配网响应:', response)
|
console.log('WiFi configuration response:', response)
|
||||||
|
|
||||||
if (response.statusCode === 200 && (response.data as any)?.success) {
|
if (response.statusCode === 200 && (response.data as any)?.success) {
|
||||||
toast.success(`${t('deviceConfig.configSuccess')}!${t('deviceConfig.deviceWillConnectTo')} ${props.selectedNetwork.ssid},${t('deviceConfig.deviceWillRestart')}。${t('deviceConfig.pleaseDisconnectXiaozhiHotspot')}`)
|
toast.success(`${t('deviceConfig.configSuccess')}!${t('deviceConfig.deviceWillConnectTo')} ${props.selectedNetwork.ssid},${t('deviceConfig.deviceWillRestart')}。${t('deviceConfig.pleaseDisconnectXiaozhiHotspot')}`)
|
||||||
|
|
@ -90,7 +90,7 @@ async function submitConfig() {
|
||||||
}, 1500)
|
}, 1500)
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
const errorMsg = (response.data as any)?.error || t('deviceConfig.configFailed')
|
const errorMsg = (response.data as any)?.error || 'Configuration failed'
|
||||||
toast.error(errorMsg)
|
toast.error(errorMsg)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -106,24 +106,24 @@ async function submitConfig() {
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<view class="wifi-config">
|
<view class="wifi-config">
|
||||||
<!-- 选中的网络信息 -->
|
<!-- Selected network information -->
|
||||||
<view v-if="props.selectedNetwork" class="selected-network">
|
<view v-if="props.selectedNetwork" class="selected-network">
|
||||||
<view class="network-info">
|
<view class="network-info">
|
||||||
<view class="network-name">
|
<view class="network-name">
|
||||||
{{ t('deviceConfig.selectedNetwork') }}: {{ props.selectedNetwork.ssid }}
|
Selected Network: {{ props.selectedNetwork.ssid }}
|
||||||
</view>
|
</view>
|
||||||
<view class="network-details">
|
<view class="network-details">
|
||||||
<text class="network-signal">
|
<text class="network-signal">
|
||||||
{{ t('deviceConfig.signal') }}: {{ props.selectedNetwork.rssi }}dBm
|
Signal: {{ props.selectedNetwork.rssi }}dBm
|
||||||
</text>
|
</text>
|
||||||
<text class="network-security">
|
<text class="network-security">
|
||||||
{{ props.selectedNetwork.authmode === 0 ? t('deviceConfig.openNetwork') : t('deviceConfig.encryptedNetwork') }}
|
{{ props.selectedNetwork.authmode === 0 ? 'Open Network' : 'Encrypted Network' }}
|
||||||
</text>
|
</text>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
<!-- 配网按钮 -->
|
<!-- Configuration button -->
|
||||||
<view class="submit-section">
|
<view class="submit-section">
|
||||||
<wd-button
|
<wd-button
|
||||||
type="primary"
|
type="primary"
|
||||||
|
|
@ -133,30 +133,30 @@ async function submitConfig() {
|
||||||
:disabled="!canSubmit"
|
:disabled="!canSubmit"
|
||||||
@click="submitConfig"
|
@click="submitConfig"
|
||||||
>
|
>
|
||||||
{{ configuring ? t('deviceConfig.configuring') : t('deviceConfig.startWifiConfigButton') }}
|
{{ configuring ? 'Configuring...' : 'Start WiFi Configuration' }}
|
||||||
</wd-button>
|
</wd-button>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
<!-- 使用说明 -->
|
<!-- Usage instructions -->
|
||||||
<view class="help-section">
|
<view class="help-section">
|
||||||
<view class="help-title">
|
<view class="help-title">
|
||||||
{{ t('deviceConfig.wifiConfigInstructions') }}
|
{{ t('deviceConfig.wifiConfigInstructions') }}
|
||||||
</view>
|
</view>
|
||||||
<view class="help-content">
|
<view class="help-content">
|
||||||
<text class="help-item">
|
<text class="help-item">
|
||||||
1. {{ t('deviceConfig.phoneConnectXiaozhiHotspot') }} (xiaozhi-XXXXXX)
|
1. Connect phone to xiaozhi hotspot (xiaozhi-XXXXXX)
|
||||||
</text>
|
</text>
|
||||||
<text class="help-item">
|
<text class="help-item">
|
||||||
2. {{ t('deviceConfig.selectTargetWifiNetwork') }}
|
2. Select target WiFi network to configure
|
||||||
</text>
|
</text>
|
||||||
<text class="help-item">
|
<text class="help-item">
|
||||||
3. {{ t('deviceConfig.enterWifiPasswordIfNeeded') }}
|
3. Enter WiFi password (if required)
|
||||||
</text>
|
</text>
|
||||||
<text class="help-item">
|
<text class="help-item">
|
||||||
4. {{ t('deviceConfig.clickStartConfigAndWait') }}
|
4. Click start configuration and wait for device connection
|
||||||
</text>
|
</text>
|
||||||
<text class="help-tip">
|
<text class="help-tip">
|
||||||
{{ t('deviceConfig.afterConfigSuccessDeviceWillRestart') }}
|
After successful network configuration, the device will automatically restart and connect to the target WiFi
|
||||||
</text>
|
</text>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,8 @@
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { computed, onMounted, ref } from 'vue'
|
import { computed, onMounted, ref } from 'vue'
|
||||||
import { useToast } from 'wot-design-uni'
|
import { useToast } from 'wot-design-uni'
|
||||||
import { t } from '@/i18n'
|
|
||||||
|
|
||||||
// 类型定义
|
// Type definitions
|
||||||
interface WiFiNetwork {
|
interface WiFiNetwork {
|
||||||
ssid: string
|
ssid: string
|
||||||
rssi: number
|
rssi: number
|
||||||
|
|
@ -13,7 +12,7 @@ interface WiFiNetwork {
|
||||||
|
|
||||||
// Props
|
// Props
|
||||||
interface Props {
|
interface Props {
|
||||||
autoConnect?: boolean // 是否自动检测ESP32连接
|
autoConnect?: boolean // Whether to automatically detect ESP32 connection
|
||||||
}
|
}
|
||||||
|
|
||||||
const props = withDefaults(defineProps<Props>(), {
|
const props = withDefaults(defineProps<Props>(), {
|
||||||
|
|
@ -26,10 +25,10 @@ const emit = defineEmits<{
|
||||||
'connection-status': [connected: boolean]
|
'connection-status': [connected: boolean]
|
||||||
}>()
|
}>()
|
||||||
|
|
||||||
// Toast 实例
|
// Toast instance
|
||||||
const toast = useToast()
|
const toast = useToast()
|
||||||
|
|
||||||
// 响应式数据
|
// Reactive data
|
||||||
const isConnectedToESP32 = ref(false)
|
const isConnectedToESP32 = ref(false)
|
||||||
const checkingConnection = ref(false)
|
const checkingConnection = ref(false)
|
||||||
const scanning = ref(false)
|
const scanning = ref(false)
|
||||||
|
|
@ -38,14 +37,14 @@ const selectedNetwork = ref<WiFiNetwork | null>(null)
|
||||||
const password = ref('')
|
const password = ref('')
|
||||||
const selectorExpanded = ref(false)
|
const selectorExpanded = ref(false)
|
||||||
|
|
||||||
// 计算属性
|
// Computed properties
|
||||||
const networkDisplayText = computed(() => {
|
const networkDisplayText = computed(() => {
|
||||||
if (!selectedNetwork.value)
|
if (!selectedNetwork.value)
|
||||||
return t('deviceConfig.selectWifiNetwork')
|
return 'Please select WiFi network'
|
||||||
return selectedNetwork.value.ssid
|
return selectedNetwork.value.ssid
|
||||||
})
|
})
|
||||||
|
|
||||||
// 检查xiaozhi连接状态
|
// Check xiaozhi connection status
|
||||||
async function checkESP32Connection() {
|
async function checkESP32Connection() {
|
||||||
checkingConnection.value = true
|
checkingConnection.value = true
|
||||||
try {
|
try {
|
||||||
|
|
@ -56,19 +55,19 @@ async function checkESP32Connection() {
|
||||||
})
|
})
|
||||||
isConnectedToESP32.value = response.statusCode === 200
|
isConnectedToESP32.value = response.statusCode === 200
|
||||||
emit('connection-status', isConnectedToESP32.value)
|
emit('connection-status', isConnectedToESP32.value)
|
||||||
console.log(`${t('deviceConfig.xiaozhi')}连接状态:`, isConnectedToESP32.value)
|
console.log('xiaozhi connection status:', isConnectedToESP32.value)
|
||||||
}
|
}
|
||||||
catch (error) {
|
catch (error) {
|
||||||
isConnectedToESP32.value = false
|
isConnectedToESP32.value = false
|
||||||
emit('connection-status', false)
|
emit('connection-status', false)
|
||||||
console.log('xiaozhi连接检查失败:', error)
|
console.log('xiaozhi connection check failed:', error)
|
||||||
}
|
}
|
||||||
finally {
|
finally {
|
||||||
checkingConnection.value = false
|
checkingConnection.value = false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 扫描WiFi网络
|
// Scan WiFi networks
|
||||||
async function scanWifi() {
|
async function scanWifi() {
|
||||||
if (!isConnectedToESP32.value) {
|
if (!isConnectedToESP32.value) {
|
||||||
toast.error(t('deviceConfig.connectXiaozhiHotspot'))
|
toast.error(t('deviceConfig.connectXiaozhiHotspot'))
|
||||||
|
|
@ -76,7 +75,7 @@ async function scanWifi() {
|
||||||
}
|
}
|
||||||
|
|
||||||
scanning.value = true
|
scanning.value = true
|
||||||
console.log('开始扫描WiFi网络')
|
console.log('Start scanning WiFi networks')
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const response = await uni.request({
|
const response = await uni.request({
|
||||||
|
|
@ -91,7 +90,7 @@ async function scanWifi() {
|
||||||
const data = response.data as any
|
const data = response.data as any
|
||||||
if (data.success && Array.isArray(data.networks)) {
|
if (data.success && Array.isArray(data.networks)) {
|
||||||
wifiNetworks.value = data.networks
|
wifiNetworks.value = data.networks
|
||||||
console.log(`${t('deviceConfig.scanSuccess')},发现 ${data.networks.length} ${t('deviceConfig.networks')}`)
|
console.log(`Scan successful, found ${data.networks.length} networks`)
|
||||||
}
|
}
|
||||||
else if (data.aps && Array.isArray(data.aps)) {
|
else if (data.aps && Array.isArray(data.aps)) {
|
||||||
// 兼容 { data: { support_5g, aps } } 格式
|
// 兼容 { data: { support_5g, aps } } 格式
|
||||||
|
|
@ -104,7 +103,7 @@ async function scanWifi() {
|
||||||
console.log(`${t('deviceConfig.scanSuccess')},发现 ${data.aps.length} ${t('deviceConfig.networks')}`)
|
console.log(`${t('deviceConfig.scanSuccess')},发现 ${data.aps.length} ${t('deviceConfig.networks')}`)
|
||||||
}
|
}
|
||||||
else if (Array.isArray(response.data)) {
|
else if (Array.isArray(response.data)) {
|
||||||
// 兼容旧格式
|
// Compatible with old format
|
||||||
wifiNetworks.value = response.data.map((item: any) => ({
|
wifiNetworks.value = response.data.map((item: any) => ({
|
||||||
ssid: item.ssid,
|
ssid: item.ssid,
|
||||||
rssi: item.rssi,
|
rssi: item.rssi,
|
||||||
|
|
@ -113,7 +112,7 @@ async function scanWifi() {
|
||||||
}))
|
}))
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
throw new TypeError('扫描接口返回格式异常')
|
throw new TypeError('Scan interface returned abnormal format')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
@ -129,9 +128,9 @@ async function scanWifi() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 显示网络选择器
|
// Show network selector
|
||||||
async function showNetworkSelector() {
|
async function showNetworkSelector() {
|
||||||
// 实时检测xiaozhi连接状态
|
// Real-time detection of xiaozhi connection status
|
||||||
await checkESP32Connection()
|
await checkESP32Connection()
|
||||||
|
|
||||||
if (!isConnectedToESP32.value) {
|
if (!isConnectedToESP32.value) {
|
||||||
|
|
@ -141,29 +140,29 @@ async function showNetworkSelector() {
|
||||||
|
|
||||||
selectorExpanded.value = true
|
selectorExpanded.value = true
|
||||||
|
|
||||||
// 如果还没有网络列表,自动扫描
|
// If no network list yet, auto scan
|
||||||
if (wifiNetworks.value.length === 0) {
|
if (wifiNetworks.value.length === 0) {
|
||||||
scanWifi()
|
scanWifi()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 选择网络
|
// Select network
|
||||||
function selectNetwork(network: WiFiNetwork) {
|
function selectNetwork(network: WiFiNetwork) {
|
||||||
selectedNetwork.value = network
|
selectedNetwork.value = network
|
||||||
password.value = ''
|
password.value = ''
|
||||||
selectorExpanded.value = false
|
selectorExpanded.value = false
|
||||||
console.log('选择网络:', network.ssid)
|
console.log('Selected network:', network.ssid)
|
||||||
|
|
||||||
// 通知父组件
|
// Notify parent component
|
||||||
emit('network-selected', network, '')
|
emit('network-selected', network, '')
|
||||||
}
|
}
|
||||||
|
|
||||||
// 密码变化时通知父组件
|
// Notify parent component when password changes
|
||||||
function onPasswordChange() {
|
function onPasswordChange() {
|
||||||
emit('network-selected', selectedNetwork.value, password.value)
|
emit('network-selected', selectedNetwork.value, password.value)
|
||||||
}
|
}
|
||||||
|
|
||||||
// 获取当前选择的网络和密码
|
// Get currently selected network and password
|
||||||
function getSelectedNetworkInfo() {
|
function getSelectedNetworkInfo() {
|
||||||
return {
|
return {
|
||||||
network: selectedNetwork.value,
|
network: selectedNetwork.value,
|
||||||
|
|
@ -171,7 +170,7 @@ function getSelectedNetworkInfo() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 重置选择
|
// Reset selection
|
||||||
function reset() {
|
function reset() {
|
||||||
selectedNetwork.value = null
|
selectedNetwork.value = null
|
||||||
password.value = ''
|
password.value = ''
|
||||||
|
|
@ -180,18 +179,18 @@ function reset() {
|
||||||
emit('network-selected', null, '')
|
emit('network-selected', null, '')
|
||||||
}
|
}
|
||||||
|
|
||||||
// 获取信号强度描述
|
// Get signal strength description
|
||||||
function getSignalStrength(rssi: number): string {
|
function getSignalStrength(rssi: number): string {
|
||||||
if (rssi >= -50)
|
if (rssi >= -50)
|
||||||
return t('deviceConfig.signalStrong')
|
return 'Strong signal'
|
||||||
if (rssi >= -60)
|
if (rssi >= -60)
|
||||||
return t('deviceConfig.signalGood')
|
return 'Good signal'
|
||||||
if (rssi >= -70)
|
if (rssi >= -70)
|
||||||
return t('deviceConfig.signalFair')
|
return 'Fair signal'
|
||||||
return t('deviceConfig.signalWeak')
|
return 'Weak signal'
|
||||||
}
|
}
|
||||||
|
|
||||||
// 获取信号强度颜色
|
// Get signal strength color
|
||||||
function getSignalColor(rssi: number): string {
|
function getSignalColor(rssi: number): string {
|
||||||
if (rssi >= -50)
|
if (rssi >= -50)
|
||||||
return '#52c41a'
|
return '#52c41a'
|
||||||
|
|
@ -202,7 +201,7 @@ function getSignalColor(rssi: number): string {
|
||||||
return '#ff4d4f'
|
return '#ff4d4f'
|
||||||
}
|
}
|
||||||
|
|
||||||
// 暴露方法给父组件
|
// Expose methods to parent component
|
||||||
defineExpose({
|
defineExpose({
|
||||||
checkESP32Connection,
|
checkESP32Connection,
|
||||||
scanWifi,
|
scanWifi,
|
||||||
|
|
@ -210,7 +209,7 @@ defineExpose({
|
||||||
reset,
|
reset,
|
||||||
})
|
})
|
||||||
|
|
||||||
// 生命周期
|
// Lifecycle
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
if (props.autoConnect) {
|
if (props.autoConnect) {
|
||||||
checkESP32Connection()
|
checkESP32Connection()
|
||||||
|
|
@ -220,7 +219,7 @@ onMounted(() => {
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<view class="wifi-selector">
|
<view class="wifi-selector">
|
||||||
<!-- Xiaozhi连接状态 -->
|
<!-- Xiaozhi connection status -->
|
||||||
<view v-if="props.autoConnect" class="connection-status">
|
<view v-if="props.autoConnect" class="connection-status">
|
||||||
<view v-if="!isConnectedToESP32" class="status-warning">
|
<view v-if="!isConnectedToESP32" class="status-warning">
|
||||||
<view class="status-content">
|
<view class="status-content">
|
||||||
|
|
@ -266,7 +265,20 @@ onMounted(() => {
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
<!-- 展开的网络列表 -->
|
<!-- WiFi network selector -->
|
||||||
|
<view class="network-selector">
|
||||||
|
<view class="selector-item" @click="showNetworkSelector">
|
||||||
|
<text class="selector-label">
|
||||||
|
WiFi Network
|
||||||
|
</text>
|
||||||
|
<text class="selector-value">
|
||||||
|
{{ networkDisplayText }}
|
||||||
|
</text>
|
||||||
|
<wd-icon name="arrow-right" custom-class="arrow-icon" />
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
|
||||||
|
<!-- Expanded network list -->
|
||||||
<view v-if="selectorExpanded" class="network-list-overlay">
|
<view v-if="selectorExpanded" class="network-list-overlay">
|
||||||
<view class="network-list-container">
|
<view class="network-list-container">
|
||||||
<view class="list-header">
|
<view class="list-header">
|
||||||
|
|
@ -294,10 +306,10 @@ onMounted(() => {
|
||||||
<view class="network-list">
|
<view class="network-list">
|
||||||
<view v-if="wifiNetworks.length === 0 && !scanning" class="empty-state">
|
<view v-if="wifiNetworks.length === 0 && !scanning" class="empty-state">
|
||||||
<text class="empty-text">
|
<text class="empty-text">
|
||||||
{{ t('deviceConfig.noWifiNetworks') }}
|
No WiFi networks available
|
||||||
</text>
|
</text>
|
||||||
<text class="empty-tip">
|
<text class="empty-tip">
|
||||||
{{ t('deviceConfig.clickRefreshScan') }}
|
Please click refresh scan
|
||||||
</text>
|
</text>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
|
|
@ -314,10 +326,10 @@ onMounted(() => {
|
||||||
</view>
|
</view>
|
||||||
<view class="wifi-details">
|
<view class="wifi-details">
|
||||||
<text class="wifi-signal">
|
<text class="wifi-signal">
|
||||||
{{ t('deviceConfig.signal') }}: {{ network.rssi }}dBm
|
Signal: {{ network.rssi }}dBm
|
||||||
</text>
|
</text>
|
||||||
<text class="wifi-channel">
|
<text class="wifi-channel">
|
||||||
{{ t('deviceConfig.channel') }}: {{ network.channel }}
|
Channel: {{ network.channel }}
|
||||||
</text>
|
</text>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
|
|
@ -332,7 +344,7 @@ onMounted(() => {
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
<!-- 密码输入 -->
|
<!-- Password input -->
|
||||||
<view v-if="selectedNetwork && selectedNetwork.authmode > 0" class="password-section">
|
<view v-if="selectedNetwork && selectedNetwork.authmode > 0" class="password-section">
|
||||||
<view class="password-item">
|
<view class="password-item">
|
||||||
<text class="password-label">
|
<text class="password-label">
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,10 @@
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { ref } from 'vue'
|
import { ref } from 'vue'
|
||||||
import { t } from '@/i18n'
|
|
||||||
import UltrasonicConfig from './components/ultrasonic-config.vue'
|
import UltrasonicConfig from './components/ultrasonic-config.vue'
|
||||||
import WifiConfig from './components/wifi-config.vue'
|
import WifiConfig from './components/wifi-config.vue'
|
||||||
import WifiSelector from './components/wifi-selector.vue'
|
import WifiSelector from './components/wifi-selector.vue'
|
||||||
|
|
||||||
// 类型定义
|
// Type definitions
|
||||||
interface WiFiNetwork {
|
interface WiFiNetwork {
|
||||||
ssid: string
|
ssid: string
|
||||||
rssi: number
|
rssi: number
|
||||||
|
|
@ -13,16 +12,16 @@ interface WiFiNetwork {
|
||||||
channel: number
|
channel: number
|
||||||
}
|
}
|
||||||
|
|
||||||
// 配网类型
|
// Network configuration type
|
||||||
const configType = ref<'wifi' | 'ultrasonic'>('wifi')
|
const configType = ref<'wifi' | 'ultrasonic'>('wifi')
|
||||||
|
|
||||||
// 配网模式选择器状态
|
// Network configuration mode selector status
|
||||||
const configTypeSelectorShow = ref(false)
|
const configTypeSelectorShow = ref(false)
|
||||||
|
|
||||||
// WiFi选择器引用
|
// WiFi selector reference
|
||||||
const wifiSelectorRef = ref<InstanceType<typeof WifiSelector>>()
|
const wifiSelectorRef = ref<InstanceType<typeof WifiSelector>>()
|
||||||
|
|
||||||
// 选择的WiFi网络信息
|
// Selected WiFi network information
|
||||||
const selectedWifiInfo = ref<{
|
const selectedWifiInfo = ref<{
|
||||||
network: WiFiNetwork | null
|
network: WiFiNetwork | null
|
||||||
password: string
|
password: string
|
||||||
|
|
@ -31,81 +30,73 @@ const selectedWifiInfo = ref<{
|
||||||
password: '',
|
password: '',
|
||||||
})
|
})
|
||||||
|
|
||||||
// 配网模式选项
|
// Network configuration mode options
|
||||||
const configTypeOptions = [
|
const configTypeOptions = [
|
||||||
{
|
{
|
||||||
name: t('deviceConfig.wifiConfig'),
|
name: 'WiFi Configuration',
|
||||||
value: 'wifi' as const,
|
value: 'wifi' as const,
|
||||||
},
|
},
|
||||||
// {
|
// {
|
||||||
// name: t('deviceConfig.ultrasonicConfig'),
|
// name: 'Ultrasonic Configuration',
|
||||||
// value: 'ultrasonic' as const,
|
// value: 'ultrasonic' as const,
|
||||||
// },
|
// },
|
||||||
]
|
]
|
||||||
|
|
||||||
// 显示配网模式选择器
|
// Show network configuration mode selector
|
||||||
function showConfigTypeSelector() {
|
function showConfigTypeSelector() {
|
||||||
configTypeSelectorShow.value = true
|
configTypeSelectorShow.value = true
|
||||||
}
|
}
|
||||||
|
|
||||||
// 配网模式选择器确认
|
// Network configuration mode selector confirm
|
||||||
function onConfigTypeConfirm(item: { name: string, value: 'wifi' | 'ultrasonic' }) {
|
function onConfigTypeConfirm(item: { name: string, value: 'wifi' | 'ultrasonic' }) {
|
||||||
configType.value = item.value
|
configType.value = item.value
|
||||||
configTypeSelectorShow.value = false
|
configTypeSelectorShow.value = false
|
||||||
}
|
}
|
||||||
|
|
||||||
// 配网模式选择器取消
|
// Network configuration mode selector cancel
|
||||||
function onConfigTypeCancel() {
|
function onConfigTypeCancel() {
|
||||||
configTypeSelectorShow.value = false
|
configTypeSelectorShow.value = false
|
||||||
}
|
}
|
||||||
|
|
||||||
// WiFi网络选择事件
|
// WiFi network selection event
|
||||||
function onNetworkSelected(network: WiFiNetwork | null, password: string) {
|
function onNetworkSelected(network: WiFiNetwork | null, password: string) {
|
||||||
selectedWifiInfo.value = { network, password }
|
selectedWifiInfo.value = { network, password }
|
||||||
}
|
}
|
||||||
|
|
||||||
// ESP32连接状态变化事件
|
// ESP32 connection status change event
|
||||||
function onConnectionStatusChange(connected: boolean) {
|
function onConnectionStatusChange(connected: boolean) {
|
||||||
console.log('ESP32连接状态:', connected)
|
console.log('ESP32 connection status:', connected)
|
||||||
}
|
}
|
||||||
|
|
||||||
// 在组件挂载后设置导航栏标题
|
|
||||||
import { onMounted } from 'vue'
|
|
||||||
onMounted(() => {
|
|
||||||
uni.setNavigationBarTitle({
|
|
||||||
title: t('deviceConfig.pageTitle')
|
|
||||||
})
|
|
||||||
})
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<view class="min-h-screen bg-[#f5f7fb]">
|
<view class="min-h-screen bg-[#f5f7fb]">
|
||||||
<wd-navbar :title="t('deviceConfig.pageTitle')" safe-area-inset-top />
|
<wd-navbar title="Device Configuration" safe-area-inset-top />
|
||||||
|
|
||||||
<view class="box-border px-[20rpx]">
|
<view class="box-border px-[20rpx]">
|
||||||
<!-- 配网方式选择 -->
|
<!-- Configuration method selection -->
|
||||||
<view class="pb-[20rpx] first:pt-[20rpx]">
|
<view class="pb-[20rpx] first:pt-[20rpx]">
|
||||||
<text class="text-[32rpx] text-[#232338] font-bold">
|
<text class="text-[32rpx] text-[#232338] font-bold">
|
||||||
{{ t('deviceConfig.configMethod') }}
|
Configuration Method
|
||||||
</text>
|
</text>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
<view class="mb-[24rpx] border border-[#eeeeee] rounded-[20rpx] bg-[#fbfbfb] p-[24rpx]" style="box-shadow: 0 2rpx 12rpx rgba(0, 0, 0, 0.04);">
|
<view class="mb-[24rpx] border border-[#eeeeee] rounded-[20rpx] bg-[#fbfbfb] p-[24rpx]" style="box-shadow: 0 2rpx 12rpx rgba(0, 0, 0, 0.04);">
|
||||||
<view class="flex cursor-pointer items-center justify-between border border-[#eeeeee] rounded-[12rpx] bg-[#f5f7fb] p-[20rpx] transition-all duration-300 active:border-[#336cff] active:bg-[#eef3ff]" @click="showConfigTypeSelector">
|
<view class="flex cursor-pointer items-center justify-between border border-[#eeeeee] rounded-[12rpx] bg-[#f5f7fb] p-[20rpx] transition-all duration-300 active:border-[#336cff] active:bg-[#eef3ff]" @click="showConfigTypeSelector">
|
||||||
<text class="text-[28rpx] text-[#232338] font-medium">
|
<text class="text-[28rpx] text-[#232338] font-medium">
|
||||||
{{ t('deviceConfig.configMethod') }}
|
Configuration Method
|
||||||
</text>
|
</text>
|
||||||
<text class="mx-[16rpx] flex-1 text-right text-[26rpx] text-[#65686f]">
|
<text class="mx-[16rpx] flex-1 text-right text-[26rpx] text-[#65686f]">
|
||||||
{{ configType === 'wifi' ? t('deviceConfig.wifiConfig') : t('deviceConfig.ultrasonicConfig') }}
|
{{ configType === 'wifi' ? 'WiFi Configuration' : 'Ultrasonic Configuration' }}
|
||||||
</text>
|
</text>
|
||||||
<wd-icon name="arrow-right" custom-class="text-[20rpx] text-[#9d9ea3]" />
|
<wd-icon name="arrow-right" custom-class="text-[20rpx] text-[#9d9ea3]" />
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
<!-- WiFi网络选择 -->
|
<!-- WiFi network selection -->
|
||||||
<view class="pb-[20rpx]">
|
<view class="pb-[20rpx]">
|
||||||
<text class="text-[32rpx] text-[#232338] font-bold">
|
<text class="text-[32rpx] text-[#232338] font-bold">
|
||||||
{{ t('deviceConfig.networkConfig') }}
|
Network Configuration
|
||||||
</text>
|
</text>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
|
|
@ -117,16 +108,16 @@ onMounted(() => {
|
||||||
/>
|
/>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
<!-- 配网操作 -->
|
<!-- Configuration operation -->
|
||||||
<view v-if="selectedWifiInfo.network" class="flex-1">
|
<view v-if="selectedWifiInfo.network" class="flex-1">
|
||||||
<!-- WiFi配网组件 -->
|
<!-- WiFi configuration component -->
|
||||||
<wifi-config
|
<wifi-config
|
||||||
v-if="configType === 'wifi'"
|
v-if="configType === 'wifi'"
|
||||||
:selected-network="selectedWifiInfo.network"
|
:selected-network="selectedWifiInfo.network"
|
||||||
:password="selectedWifiInfo.password"
|
:password="selectedWifiInfo.password"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<!-- 超声波配网组件 -->
|
<!-- Ultrasonic configuration component -->
|
||||||
<ultrasonic-config
|
<ultrasonic-config
|
||||||
v-else-if="configType === 'ultrasonic'"
|
v-else-if="configType === 'ultrasonic'"
|
||||||
:selected-network="selectedWifiInfo.network"
|
:selected-network="selectedWifiInfo.network"
|
||||||
|
|
@ -135,7 +126,7 @@ onMounted(() => {
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
<!-- 配网模式选择器 -->
|
<!-- Configuration mode selector -->
|
||||||
<wd-action-sheet
|
<wd-action-sheet
|
||||||
v-model="configTypeSelectorShow"
|
v-model="configTypeSelectorShow"
|
||||||
:actions="configTypeOptions.map(item => ({ name: item.name, value: item.value }))"
|
:actions="configTypeOptions.map(item => ({ name: item.name, value: item.value }))"
|
||||||
|
|
@ -148,7 +139,7 @@ onMounted(() => {
|
||||||
<route lang="jsonc" type="page">
|
<route lang="jsonc" type="page">
|
||||||
{
|
{
|
||||||
"style": {
|
"style": {
|
||||||
"navigationBarTitleText": "设备配置",
|
"navigationBarTitleText": "Device Configuration",
|
||||||
"navigationStyle": "custom"
|
"navigationStyle": "custom"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2,29 +2,23 @@
|
||||||
import type { Device, FirmwareType } from '@/api/device'
|
import type { Device, FirmwareType } from '@/api/device'
|
||||||
import { computed, onMounted, ref } from 'vue'
|
import { computed, onMounted, ref } from 'vue'
|
||||||
import { useMessage } from 'wot-design-uni'
|
import { useMessage } from 'wot-design-uni'
|
||||||
import { bindDevice, bindDeviceManual, getBindDevices, getFirmwareTypes, unbindDevice, updateDeviceAutoUpdate } from '@/api/device'
|
import { bindDevice, getBindDevices, getFirmwareTypes, unbindDevice, updateDeviceAutoUpdate } from '@/api/device'
|
||||||
import { t } from '@/i18n'
|
|
||||||
import { toast } from '@/utils/toast'
|
import { toast } from '@/utils/toast'
|
||||||
|
|
||||||
defineOptions({
|
defineOptions({
|
||||||
name: 'DeviceManage',
|
name: 'DeviceManage',
|
||||||
})
|
})
|
||||||
|
|
||||||
const props = withDefaults(defineProps<Props>(), {
|
// Receive props
|
||||||
agentId: 'default',
|
|
||||||
})
|
|
||||||
|
|
||||||
const actions = [
|
|
||||||
{ key: 'code', name: t('manualAddDeviceDialog.bindWithCode') },
|
|
||||||
{ key: 'manual', name: t('manualAddDeviceDialog.title') },
|
|
||||||
]
|
|
||||||
|
|
||||||
// 接收props
|
|
||||||
interface Props {
|
interface Props {
|
||||||
agentId?: string
|
agentId?: string
|
||||||
}
|
}
|
||||||
|
|
||||||
// 获取屏幕边界到安全区域距离
|
const props = withDefaults(defineProps<Props>(), {
|
||||||
|
agentId: 'default'
|
||||||
|
})
|
||||||
|
|
||||||
|
// Get screen boundary to safe area distance
|
||||||
let safeAreaInsets: any
|
let safeAreaInsets: any
|
||||||
let systemInfo: any
|
let systemInfo: any
|
||||||
|
|
||||||
|
|
@ -45,63 +39,27 @@ systemInfo = uni.getSystemInfoSync()
|
||||||
safeAreaInsets = systemInfo.safeAreaInsets
|
safeAreaInsets = systemInfo.safeAreaInsets
|
||||||
// #endif
|
// #endif
|
||||||
|
|
||||||
// 设备数据
|
// Device data
|
||||||
const deviceList = ref<Device[]>([])
|
const deviceList = ref<Device[]>([])
|
||||||
const firmwareTypes = ref<FirmwareType[]>([])
|
const firmwareTypes = ref<FirmwareType[]>([])
|
||||||
const loading = ref(false)
|
const loading = ref(false)
|
||||||
const isBindDevice = ref(false)
|
|
||||||
|
|
||||||
// 手动绑定弹窗
|
// Message component
|
||||||
const isManualBindDialog = ref(false)
|
|
||||||
const manualBindForm = ref({
|
|
||||||
board: '',
|
|
||||||
appVersion: '',
|
|
||||||
macAddress: '',
|
|
||||||
})
|
|
||||||
|
|
||||||
// 表单校验错误提示
|
|
||||||
const formErrors = ref({
|
|
||||||
board: '',
|
|
||||||
appVersion: '',
|
|
||||||
macAddress: '',
|
|
||||||
})
|
|
||||||
|
|
||||||
// MAC地址正则校验
|
|
||||||
const macRegex = /^(?:[0-9A-F]{2}[:-]){5}[0-9A-F]{2}$/i
|
|
||||||
|
|
||||||
function selectBindMode(row) {
|
|
||||||
if (row.item.key === 'code') {
|
|
||||||
openBindDialog()
|
|
||||||
}
|
|
||||||
else if (row.item.key === 'manual') {
|
|
||||||
// 打开弹窗前重置表单和错误提示
|
|
||||||
manualBindForm.value = {
|
|
||||||
board: '',
|
|
||||||
appVersion: '',
|
|
||||||
macAddress: '',
|
|
||||||
}
|
|
||||||
formErrors.value = {
|
|
||||||
board: '',
|
|
||||||
appVersion: '',
|
|
||||||
macAddress: '',
|
|
||||||
}
|
|
||||||
isManualBindDialog.value = true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// 消息组件
|
|
||||||
const message = useMessage()
|
const message = useMessage()
|
||||||
|
|
||||||
// 使用传入的智能体ID
|
// Use passed agent ID
|
||||||
const currentAgentId = computed(() => {
|
const currentAgentId = computed(() => {
|
||||||
return props.agentId
|
return props.agentId
|
||||||
})
|
})
|
||||||
|
|
||||||
// 获取设备列表
|
// Get device list
|
||||||
async function loadDeviceList() {
|
async function loadDeviceList() {
|
||||||
try {
|
try {
|
||||||
// 检查是否有当前选中的智能体
|
console.log('Get device list')
|
||||||
|
|
||||||
|
// Check if there is currently selected agent
|
||||||
if (!currentAgentId.value) {
|
if (!currentAgentId.value) {
|
||||||
|
console.warn('No selected agent')
|
||||||
deviceList.value = []
|
deviceList.value = []
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
@ -111,7 +69,7 @@ async function loadDeviceList() {
|
||||||
deviceList.value = response || []
|
deviceList.value = response || []
|
||||||
}
|
}
|
||||||
catch (error) {
|
catch (error) {
|
||||||
console.error('获取设备列表失败:', error)
|
console.error('Failed to get device list:', error)
|
||||||
deviceList.value = []
|
deviceList.value = []
|
||||||
}
|
}
|
||||||
finally {
|
finally {
|
||||||
|
|
@ -119,107 +77,107 @@ async function loadDeviceList() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 暴露给父组件的刷新方法
|
// Refresh method exposed to parent component
|
||||||
async function refresh() {
|
async function refresh() {
|
||||||
await loadDeviceList()
|
await loadDeviceList()
|
||||||
}
|
}
|
||||||
|
|
||||||
// 获取设备类型名称
|
// Get device type name
|
||||||
function getDeviceTypeName(boardKey: string): string {
|
function getDeviceTypeName(boardKey: string): string {
|
||||||
const firmwareType = firmwareTypes.value.find(type => type.key === boardKey)
|
const firmwareType = firmwareTypes.value.find(type => type.key === boardKey)
|
||||||
return firmwareType?.name || boardKey
|
return firmwareType?.name || boardKey
|
||||||
}
|
}
|
||||||
|
|
||||||
// 格式化时间
|
// Format time
|
||||||
function formatTime(timeStr: string) {
|
function formatTime(timeStr: string) {
|
||||||
if (!timeStr)
|
if (!timeStr)
|
||||||
return t('device.neverConnected')
|
return 'Never connected'
|
||||||
const date = new Date(timeStr)
|
const date = new Date(timeStr)
|
||||||
const now = new Date()
|
const now = new Date()
|
||||||
const diff = now.getTime() - date.getTime()
|
const diff = now.getTime() - date.getTime()
|
||||||
|
|
||||||
if (diff < 60000)
|
if (diff < 60000)
|
||||||
return t('device.justNow')
|
return 'Just now'
|
||||||
if (diff < 3600000)
|
if (diff < 3600000)
|
||||||
return t('device.minutesAgo', { minutes: Math.floor(diff / 60000) })
|
return `${Math.floor(diff / 60000)} minutes ago`
|
||||||
if (diff < 86400000)
|
if (diff < 86400000)
|
||||||
return t('device.hoursAgo', { hours: Math.floor(diff / 3600000) })
|
return `${Math.floor(diff / 3600000)} hours ago`
|
||||||
if (diff < 604800000)
|
if (diff < 604800000)
|
||||||
return t('device.daysAgo', { days: Math.floor(diff / 86400000) })
|
return `${Math.floor(diff / 86400000)} days ago`
|
||||||
|
|
||||||
return date.toLocaleDateString()
|
return date.toLocaleDateString()
|
||||||
}
|
}
|
||||||
|
|
||||||
// 切换OTA自动更新
|
// Toggle OTA auto update
|
||||||
async function toggleAutoUpdate(device: Device) {
|
async function toggleAutoUpdate(device: Device) {
|
||||||
try {
|
try {
|
||||||
const newStatus = device.autoUpdate === 1 ? 0 : 1
|
const newStatus = device.autoUpdate === 1 ? 0 : 1
|
||||||
await updateDeviceAutoUpdate(device.id, newStatus)
|
await updateDeviceAutoUpdate(device.id, newStatus)
|
||||||
device.autoUpdate = newStatus
|
device.autoUpdate = newStatus
|
||||||
toast.success(newStatus === 1 ? t('device.otaAutoUpdateEnabled') : t('device.otaAutoUpdateDisabled'))
|
toast.success(newStatus === 1 ? 'OTA auto upgrade enabled' : 'OTA auto upgrade disabled')
|
||||||
}
|
}
|
||||||
catch (error: any) {
|
catch (error: any) {
|
||||||
console.error('更新设备OTA状态失败:', error)
|
console.error('Failed to update device OTA status:', error)
|
||||||
toast.error(t('device.operationFailed'))
|
toast.error('Operation failed, please try again')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 解绑设备
|
// Unbind device
|
||||||
async function handleUnbindDevice(device: Device) {
|
async function handleUnbindDevice(device: Device) {
|
||||||
try {
|
try {
|
||||||
await unbindDevice(device.id)
|
await unbindDevice(device.id)
|
||||||
await loadDeviceList()
|
await loadDeviceList()
|
||||||
toast.success(t('device.deviceUnbound'))
|
toast.success('Device unbound')
|
||||||
}
|
}
|
||||||
catch (error: any) {
|
catch (error: any) {
|
||||||
console.error('解绑设备失败:', error)
|
console.error('Failed to unbind device:', error)
|
||||||
toast.error(t('device.unbindFailed'))
|
toast.error('Unbind failed, please try again')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 确认解绑设备
|
// Confirm unbind device
|
||||||
function confirmUnbindDevice(device: Device) {
|
function confirmUnbindDevice(device: Device) {
|
||||||
message.confirm({
|
message.confirm({
|
||||||
title: t('device.unbindDevice'),
|
title: 'Unbind Device',
|
||||||
msg: t('device.confirmUnbindDevice', { macAddress: device.macAddress }),
|
msg: `Are you sure you want to unbind device "${device.macAddress}"?`,
|
||||||
confirmButtonText: t('device.confirmUnbind'),
|
confirmButtonText: 'Confirm Unbind',
|
||||||
cancelButtonText: t('device.cancel'),
|
cancelButtonText: 'Cancel',
|
||||||
}).then(() => {
|
}).then(() => {
|
||||||
handleUnbindDevice(device)
|
handleUnbindDevice(device)
|
||||||
}).catch(() => {
|
}).catch(() => {
|
||||||
// 用户取消
|
// User cancelled
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// 绑定新设备
|
// Bind new device
|
||||||
async function handleBindDevice(code: string) {
|
async function handleBindDevice(code: string) {
|
||||||
try {
|
try {
|
||||||
if (!currentAgentId.value) {
|
if (!currentAgentId.value) {
|
||||||
toast.error(t('device.pleaseSelectAgent'))
|
toast.error('Please select an agent first')
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
await bindDevice(currentAgentId.value, code.trim())
|
await bindDevice(currentAgentId.value, code.trim())
|
||||||
await loadDeviceList()
|
await loadDeviceList()
|
||||||
toast.success(t('device.deviceBindSuccess'))
|
toast.success('Device bound successfully!')
|
||||||
}
|
}
|
||||||
catch (error: any) {
|
catch (error: any) {
|
||||||
console.error('绑定设备失败:', error)
|
console.error('Failed to bind device:', error)
|
||||||
const errorMessage = error?.message || t('device.bindFailed')
|
const errorMessage = error?.message || 'Binding failed, please check if the verification code is correct'
|
||||||
toast.error(errorMessage)
|
toast.error(errorMessage)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 打开绑定设备对话框
|
// Open bind device dialog
|
||||||
function openBindDialog() {
|
function openBindDialog() {
|
||||||
message
|
message
|
||||||
.prompt({
|
.prompt({
|
||||||
title: t('device.bindDevice'),
|
title: 'Bind Device',
|
||||||
inputPlaceholder: t('device.enterDeviceCode'),
|
inputPlaceholder: 'Please enter device verification code',
|
||||||
inputValue: '',
|
inputValue: '',
|
||||||
inputPattern: /^\d{6}$/,
|
inputPattern: /^\d{6}$/,
|
||||||
confirmButtonText: t('device.bindNow'),
|
confirmButtonText: 'Bind Now',
|
||||||
cancelButtonText: t('device.cancel'),
|
cancelButtonText: 'Cancel',
|
||||||
})
|
})
|
||||||
.then(async (result: any) => {
|
.then(async (result: any) => {
|
||||||
if (result.value && String(result.value).trim()) {
|
if (result.value && String(result.value).trim()) {
|
||||||
|
|
@ -227,151 +185,29 @@ function openBindDialog() {
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.catch(() => {
|
.catch(() => {
|
||||||
// 用户取消操作
|
// User cancelled operation
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// 手动绑定设备
|
// Get device type list
|
||||||
async function handleManualBind() {
|
|
||||||
try {
|
|
||||||
// 先校验整个表单
|
|
||||||
const isValid = validateForm()
|
|
||||||
if (!isValid) {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!currentAgentId.value) {
|
|
||||||
toast.error(t('device.pleaseSelectAgent'))
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
await bindDeviceManual({
|
|
||||||
agentId: currentAgentId.value,
|
|
||||||
board: manualBindForm.value.board,
|
|
||||||
appVersion: manualBindForm.value.appVersion,
|
|
||||||
macAddress: manualBindForm.value.macAddress,
|
|
||||||
})
|
|
||||||
await loadDeviceList()
|
|
||||||
toast.success(t('manualAddDeviceDialog.addSuccess'))
|
|
||||||
isManualBindDialog.value = false
|
|
||||||
// 重置表单和错误提示
|
|
||||||
manualBindForm.value = {
|
|
||||||
board: '',
|
|
||||||
appVersion: '',
|
|
||||||
macAddress: '',
|
|
||||||
}
|
|
||||||
formErrors.value = {
|
|
||||||
board: '',
|
|
||||||
appVersion: '',
|
|
||||||
macAddress: '',
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (error: any) {
|
|
||||||
const errorMessage = error?.message || t('manualAddDeviceDialog.addFailed')
|
|
||||||
toast.error(errorMessage)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// 校验单个字段
|
|
||||||
function validateField(field: string) {
|
|
||||||
switch (field) {
|
|
||||||
case 'board':
|
|
||||||
if (!manualBindForm.value.board) {
|
|
||||||
formErrors.value.board = t('manualAddDeviceDialog.deviceTypePlaceholder')
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
formErrors.value.board = ''
|
|
||||||
}
|
|
||||||
break
|
|
||||||
case 'appVersion':
|
|
||||||
if (!manualBindForm.value.appVersion) {
|
|
||||||
formErrors.value.appVersion = t('manualAddDeviceDialog.firmwareVersionPlaceholder')
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
formErrors.value.appVersion = ''
|
|
||||||
}
|
|
||||||
break
|
|
||||||
case 'macAddress':
|
|
||||||
if (!manualBindForm.value.macAddress) {
|
|
||||||
formErrors.value.macAddress = t('manualAddDeviceDialog.macAddressPlaceholder')
|
|
||||||
}
|
|
||||||
else if (!macRegex.test(manualBindForm.value.macAddress)) {
|
|
||||||
formErrors.value.macAddress = t('manualAddDeviceDialog.invalidMacAddress')
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
formErrors.value.macAddress = ''
|
|
||||||
}
|
|
||||||
break
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// 清除字段错误提示
|
|
||||||
function clearFieldError(field: string) {
|
|
||||||
formErrors.value[field] = ''
|
|
||||||
}
|
|
||||||
|
|
||||||
// 处理选择器变化
|
|
||||||
function handlePickerChange() {
|
|
||||||
clearFieldError('board')
|
|
||||||
}
|
|
||||||
|
|
||||||
// 校验整个表单
|
|
||||||
function validateForm(): boolean {
|
|
||||||
let isValid = true
|
|
||||||
|
|
||||||
// 校验设备类型
|
|
||||||
if (!manualBindForm.value.board) {
|
|
||||||
formErrors.value.board = t('manualAddDeviceDialog.deviceTypePlaceholder')
|
|
||||||
isValid = false
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
formErrors.value.board = ''
|
|
||||||
}
|
|
||||||
|
|
||||||
// 校验固件版本
|
|
||||||
if (!manualBindForm.value.appVersion) {
|
|
||||||
formErrors.value.appVersion = t('manualAddDeviceDialog.firmwareVersionPlaceholder')
|
|
||||||
isValid = false
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
formErrors.value.appVersion = ''
|
|
||||||
}
|
|
||||||
|
|
||||||
// 校验MAC地址
|
|
||||||
if (!manualBindForm.value.macAddress) {
|
|
||||||
formErrors.value.macAddress = t('manualAddDeviceDialog.macAddressPlaceholder')
|
|
||||||
isValid = false
|
|
||||||
}
|
|
||||||
else if (!macRegex.test(manualBindForm.value.macAddress)) {
|
|
||||||
formErrors.value.macAddress = t('manualAddDeviceDialog.invalidMacAddress')
|
|
||||||
isValid = false
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
formErrors.value.macAddress = ''
|
|
||||||
}
|
|
||||||
|
|
||||||
return isValid
|
|
||||||
}
|
|
||||||
|
|
||||||
// 获取设备类型列表
|
|
||||||
async function loadFirmwareTypes() {
|
async function loadFirmwareTypes() {
|
||||||
try {
|
try {
|
||||||
const response = await getFirmwareTypes()
|
const response = await getFirmwareTypes()
|
||||||
firmwareTypes.value = response
|
firmwareTypes.value = response
|
||||||
}
|
}
|
||||||
catch (error) {
|
catch (error) {
|
||||||
console.error('获取设备类型失败:', error)
|
console.error('Failed to get device types:', error)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
// 智能体已简化为默认
|
// Agent simplified to default
|
||||||
|
|
||||||
loadFirmwareTypes()
|
loadFirmwareTypes()
|
||||||
loadDeviceList()
|
loadDeviceList()
|
||||||
})
|
})
|
||||||
|
|
||||||
// 暴露方法给父组件
|
// Expose methods to parent component
|
||||||
defineExpose({
|
defineExpose({
|
||||||
refresh,
|
refresh,
|
||||||
})
|
})
|
||||||
|
|
@ -379,17 +215,17 @@ defineExpose({
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<view class="device-container" style="background: #f5f7fb; min-height: 100%;">
|
<view class="device-container" style="background: #f5f7fb; min-height: 100%;">
|
||||||
<!-- 加载状态 -->
|
<!-- Loading state -->
|
||||||
<view v-if="loading && deviceList.length === 0" class="loading-container">
|
<view v-if="loading && deviceList.length === 0" class="loading-container">
|
||||||
<wd-loading color="#336cff" />
|
<wd-loading color="#336cff" />
|
||||||
<text class="loading-text">
|
<text class="loading-text">
|
||||||
{{ t('device.loading') }}
|
Loading...
|
||||||
</text>
|
</text>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
<!-- 设备列表 -->
|
<!-- Device list -->
|
||||||
<view v-else-if="deviceList.length > 0" class="device-list">
|
<view v-else-if="deviceList.length > 0" class="device-list">
|
||||||
<!-- 设备卡片列表 -->
|
<!-- Device card list -->
|
||||||
<view class="box-border flex flex-col gap-[24rpx] p-[20rpx]">
|
<view class="box-border flex flex-col gap-[24rpx] p-[20rpx]">
|
||||||
<view v-for="device in deviceList" :key="device.id">
|
<view v-for="device in deviceList" :key="device.id">
|
||||||
<wd-swipe-action>
|
<wd-swipe-action>
|
||||||
|
|
@ -404,19 +240,19 @@ defineExpose({
|
||||||
|
|
||||||
<view class="mb-[20rpx]">
|
<view class="mb-[20rpx]">
|
||||||
<text class="mb-[12rpx] block text-[28rpx] text-[#65686f] leading-[1.4]">
|
<text class="mb-[12rpx] block text-[28rpx] text-[#65686f] leading-[1.4]">
|
||||||
{{ t('device.macAddress') }}:{{ device.macAddress }}
|
MAC Address: {{ device.macAddress }}
|
||||||
</text>
|
</text>
|
||||||
<text class="mb-[12rpx] block text-[28rpx] text-[#65686f] leading-[1.4]">
|
<text class="mb-[12rpx] block text-[28rpx] text-[#65686f] leading-[1.4]">
|
||||||
{{ t('device.firmwareVersion') }}:{{ device.appVersion }}
|
Firmware Version: {{ device.appVersion }}
|
||||||
</text>
|
</text>
|
||||||
<text class="block text-[28rpx] text-[#65686f] leading-[1.4]">
|
<text class="block text-[28rpx] text-[#65686f] leading-[1.4]">
|
||||||
{{ t('device.lastConnection') }}:{{ formatTime(device.lastConnectedAt) }}
|
Last Conversation: {{ formatTime(device.lastConnectedAt) }}
|
||||||
</text>
|
</text>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
<view class="flex items-center justify-between border-[1rpx] border-[#eeeeee] rounded-[12rpx] bg-[#f5f7fb] p-[16rpx_20rpx]">
|
<view class="flex items-center justify-between border-[1rpx] border-[#eeeeee] rounded-[12rpx] bg-[#f5f7fb] p-[16rpx_20rpx]">
|
||||||
<text class="text-[28rpx] text-[#232338] font-medium">
|
<text class="text-[28rpx] text-[#232338] font-medium">
|
||||||
{{ t('device.otaUpdate') }}
|
OTA Update
|
||||||
</text>
|
</text>
|
||||||
<wd-switch
|
<wd-switch
|
||||||
:model-value="device.autoUpdate === 1"
|
:model-value="device.autoUpdate === 1"
|
||||||
|
|
@ -435,7 +271,7 @@ defineExpose({
|
||||||
@click.stop="confirmUnbindDevice(device)"
|
@click.stop="confirmUnbindDevice(device)"
|
||||||
>
|
>
|
||||||
<wd-icon name="delete" />
|
<wd-icon name="delete" />
|
||||||
<text>{{ t('device.unbind') }}</text>
|
<text>Unbind</text>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</template>
|
</template>
|
||||||
|
|
@ -444,102 +280,24 @@ defineExpose({
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
<!-- 空状态 -->
|
<!-- Empty state -->
|
||||||
<view v-else-if="!loading" class="empty-container">
|
<view v-else-if="!loading" class="empty-container">
|
||||||
<view class="flex flex-col items-center justify-center p-[100rpx_40rpx] text-center">
|
<view class="flex flex-col items-center justify-center p-[100rpx_40rpx] text-center">
|
||||||
<wd-icon name="phone" custom-class="text-[120rpx] text-[#d9d9d9] mb-[32rpx]" />
|
<wd-icon name="phone" custom-class="text-[120rpx] text-[#d9d9d9] mb-[32rpx]" />
|
||||||
<text class="mb-[16rpx] text-[32rpx] text-[#666666] font-medium">
|
<text class="mb-[16rpx] text-[32rpx] text-[#666666] font-medium">
|
||||||
{{ t('device.noDevice') }}
|
No devices yet
|
||||||
</text>
|
</text>
|
||||||
<text class="text-[26rpx] text-[#999999] leading-[1.5]">
|
<text class="text-[26rpx] text-[#999999] leading-[1.5]">
|
||||||
{{ t('device.clickToBindFirstDevice') }}
|
Click the + button in the bottom right to bind your first device
|
||||||
</text>
|
</text>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
<!-- FAB 绑定设备按钮 -->
|
<!-- FAB bind device button -->
|
||||||
<wd-fab type="primary" size="small" icon="add" :draggable="true" :expandable="false" @click="isBindDevice = true" />
|
<wd-fab type="primary" size="small" icon="add" :draggable="true" :expandable="false" @click="openBindDialog" />
|
||||||
|
|
||||||
<!-- MessageBox 组件 -->
|
<!-- MessageBox component -->
|
||||||
<wd-message-box />
|
<wd-message-box />
|
||||||
<wd-action-sheet v-model="isBindDevice" :actions="actions" @close="isBindDevice = false" @select="selectBindMode" />
|
|
||||||
|
|
||||||
<!-- 手动绑定设备弹窗 -->
|
|
||||||
<wd-popup v-model="isManualBindDialog" position="bottom" :close-on-click-modal="false" custom-style="border-radius: 24rpx 24rpx 0 0;">
|
|
||||||
<view class="manual-bind-dialog">
|
|
||||||
<view class="dialog-header">
|
|
||||||
<text class="dialog-title">
|
|
||||||
{{ t('manualAddDeviceDialog.title') }}
|
|
||||||
</text>
|
|
||||||
<wd-icon name="close" size="20" @click="isManualBindDialog = false" />
|
|
||||||
</view>
|
|
||||||
|
|
||||||
<view class="dialog-content">
|
|
||||||
<view class="form-item">
|
|
||||||
<text class="form-label">
|
|
||||||
{{ t('manualAddDeviceDialog.deviceType') }}
|
|
||||||
<text class="required">
|
|
||||||
*
|
|
||||||
</text>
|
|
||||||
</text>
|
|
||||||
<wd-picker
|
|
||||||
v-model="manualBindForm.board"
|
|
||||||
class="custom-wd-picker"
|
|
||||||
:columns="firmwareTypes.map(item => ({ value: item.key, label: item.name }))"
|
|
||||||
:placeholder="t('manualAddDeviceDialog.deviceTypePlaceholder')"
|
|
||||||
:cancel-button-text="t('common.cancel')"
|
|
||||||
:confirm-button-text="t('common.confirm')"
|
|
||||||
@confirm="handlePickerChange"
|
|
||||||
/>
|
|
||||||
<text v-if="formErrors.board" class="error-text">
|
|
||||||
{{ formErrors.board }}
|
|
||||||
</text>
|
|
||||||
</view>
|
|
||||||
|
|
||||||
<view class="form-item">
|
|
||||||
<text class="form-label">
|
|
||||||
{{ t('manualAddDeviceDialog.firmwareVersion') }}
|
|
||||||
<text class="required">
|
|
||||||
*
|
|
||||||
</text>
|
|
||||||
</text>
|
|
||||||
<wd-input
|
|
||||||
v-model="manualBindForm.appVersion"
|
|
||||||
:placeholder="t('manualAddDeviceDialog.firmwareVersionPlaceholder')"
|
|
||||||
@input="clearFieldError('appVersion')"
|
|
||||||
@blur="validateField('appVersion')"
|
|
||||||
/>
|
|
||||||
<text v-if="formErrors.appVersion" class="error-text">
|
|
||||||
{{ formErrors.appVersion }}
|
|
||||||
</text>
|
|
||||||
</view>
|
|
||||||
|
|
||||||
<view class="form-item">
|
|
||||||
<text class="form-label">
|
|
||||||
{{ t('manualAddDeviceDialog.macAddress') }}
|
|
||||||
<text class="required">
|
|
||||||
*
|
|
||||||
</text>
|
|
||||||
</text>
|
|
||||||
<wd-input
|
|
||||||
v-model="manualBindForm.macAddress"
|
|
||||||
:placeholder="t('manualAddDeviceDialog.macAddressPlaceholder')"
|
|
||||||
@input="validateField('macAddress')"
|
|
||||||
@blur="validateField('macAddress')"
|
|
||||||
/>
|
|
||||||
<text v-if="formErrors.macAddress" class="error-text">
|
|
||||||
{{ formErrors.macAddress }}
|
|
||||||
</text>
|
|
||||||
</view>
|
|
||||||
</view>
|
|
||||||
|
|
||||||
<view class="dialog-footer">
|
|
||||||
<wd-button block type="primary" @click="handleManualBind">
|
|
||||||
{{ t('manualAddDeviceDialog.confirm') }}
|
|
||||||
</wd-button>
|
|
||||||
</view>
|
|
||||||
</view>
|
|
||||||
</wd-popup>
|
|
||||||
</view>
|
</view>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
|
@ -568,64 +326,8 @@ defineExpose({
|
||||||
box-shadow: 0 2rpx 12rpx rgba(0, 0, 0, 0.04);
|
box-shadow: 0 2rpx 12rpx rgba(0, 0, 0, 0.04);
|
||||||
border: 1rpx solid #eeeeee;
|
border: 1rpx solid #eeeeee;
|
||||||
}
|
}
|
||||||
::v-deep .wd-action-sheet__popup,
|
|
||||||
::v-deep .wd-popup {
|
|
||||||
z-index: 100 !important;
|
|
||||||
}
|
|
||||||
.custom-wd-picker ::v-deep .wd-picker__cell {
|
|
||||||
padding-left: 0 !important;
|
|
||||||
}
|
|
||||||
|
|
||||||
:deep(.wd-icon) {
|
:deep(.wd-icon) {
|
||||||
font-size: 32rpx;
|
font-size: 32rpx;
|
||||||
}
|
}
|
||||||
|
|
||||||
.manual-bind-dialog {
|
|
||||||
padding: 32rpx;
|
|
||||||
background: #ffffff;
|
|
||||||
}
|
|
||||||
|
|
||||||
.dialog-header {
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
justify-content: space-between;
|
|
||||||
margin-bottom: 32rpx;
|
|
||||||
}
|
|
||||||
|
|
||||||
.dialog-title {
|
|
||||||
font-size: 36rpx;
|
|
||||||
font-weight: 600;
|
|
||||||
color: #232338;
|
|
||||||
}
|
|
||||||
|
|
||||||
.dialog-content {
|
|
||||||
margin-bottom: 32rpx;
|
|
||||||
}
|
|
||||||
|
|
||||||
.form-item {
|
|
||||||
margin-bottom: 24rpx;
|
|
||||||
}
|
|
||||||
|
|
||||||
.form-label {
|
|
||||||
display: block;
|
|
||||||
font-size: 28rpx;
|
|
||||||
color: #65686f;
|
|
||||||
margin-bottom: 12rpx;
|
|
||||||
}
|
|
||||||
|
|
||||||
.required {
|
|
||||||
color: #ff4d4f;
|
|
||||||
margin-left: 4rpx;
|
|
||||||
}
|
|
||||||
|
|
||||||
.error-text {
|
|
||||||
display: block;
|
|
||||||
font-size: 24rpx;
|
|
||||||
color: #ff4d4f;
|
|
||||||
margin-top: 8rpx;
|
|
||||||
}
|
|
||||||
|
|
||||||
.dialog-footer {
|
|
||||||
padding-top: 16rpx;
|
|
||||||
}
|
|
||||||
</style>
|
</style>
|
||||||
|
|
|
||||||
|
|
@ -14,17 +14,17 @@ import { onLoad } from "@dcloudio/uni-app";
|
||||||
import { useConfigStore } from "@/store";
|
import { useConfigStore } from "@/store";
|
||||||
import { getEnvBaseUrl, sm2Encrypt } from "@/utils";
|
import { getEnvBaseUrl, sm2Encrypt } from "@/utils";
|
||||||
import { toast } from "@/utils/toast";
|
import { toast } from "@/utils/toast";
|
||||||
// 导入国际化相关功能
|
// Import i18n helpers.
|
||||||
import { t, initI18n } from "@/i18n";
|
import { t, initI18n } from "@/i18n";
|
||||||
// 导入API接口
|
// Import API methods.
|
||||||
import { retrievePassword, sendSmsCode } from "@/api/auth";
|
import { retrievePassword, sendSmsCode } from "@/api/auth";
|
||||||
|
|
||||||
// 获取屏幕边界到安全区域距离
|
// Get the safe-area inset from the screen bounds.
|
||||||
let safeAreaInsets;
|
let safeAreaInsets;
|
||||||
let systemInfo;
|
let systemInfo;
|
||||||
|
|
||||||
// #ifdef MP-WEIXIN
|
// #ifdef MP-WEIXIN
|
||||||
// 微信小程序使用新的API
|
// WeChat Mini Program uses the newer window API.
|
||||||
systemInfo = uni.getWindowInfo();
|
systemInfo = uni.getWindowInfo();
|
||||||
safeAreaInsets = systemInfo.safeArea
|
safeAreaInsets = systemInfo.safeArea
|
||||||
? {
|
? {
|
||||||
|
|
@ -37,12 +37,12 @@ safeAreaInsets = systemInfo.safeArea
|
||||||
// #endif
|
// #endif
|
||||||
|
|
||||||
// #ifndef MP-WEIXIN
|
// #ifndef MP-WEIXIN
|
||||||
// 其他平台继续使用uni API
|
// Other platforms continue to use the classic uni API.
|
||||||
systemInfo = uni.getSystemInfoSync();
|
systemInfo = uni.getSystemInfoSync();
|
||||||
safeAreaInsets = systemInfo.safeAreaInsets;
|
safeAreaInsets = systemInfo.safeAreaInsets;
|
||||||
// #endif
|
// #endif
|
||||||
|
|
||||||
// 表单数据
|
// Form data model.
|
||||||
interface ForgotPasswordData {
|
interface ForgotPasswordData {
|
||||||
mobile: string;
|
mobile: string;
|
||||||
captcha: string;
|
captcha: string;
|
||||||
|
|
@ -60,21 +60,21 @@ const formData = ref<ForgotPasswordData>({
|
||||||
mobileCaptcha: "",
|
mobileCaptcha: "",
|
||||||
newPassword: "",
|
newPassword: "",
|
||||||
confirmPassword: "",
|
confirmPassword: "",
|
||||||
areaCode: "+86",
|
areaCode: "+1",
|
||||||
});
|
});
|
||||||
|
|
||||||
// 验证码图片
|
// Captcha image.
|
||||||
const captchaImage = ref("");
|
const captchaImage = ref("");
|
||||||
const loading = ref(false);
|
const loading = ref(false);
|
||||||
|
|
||||||
// 获取配置store
|
// Load public configuration from the store.
|
||||||
const configStore = useConfigStore();
|
const configStore = useConfigStore();
|
||||||
|
|
||||||
// State for area code action sheet
|
// State for area code action sheet
|
||||||
const showAreaCodeSheet = ref(false);
|
const showAreaCodeSheet = ref(false);
|
||||||
const selectedAreaCode = ref("+86");
|
const selectedAreaCode = ref("+1");
|
||||||
const areaCodeList = computed(() =>
|
const areaCodeList = computed(() =>
|
||||||
(configStore.config.mobileAreaList || []).map((item) => {
|
(configStore.config.mobileAreaList || [{ name: "United States", key: "+1" }]).map((item) => {
|
||||||
return {
|
return {
|
||||||
value: item.key,
|
value: item.key,
|
||||||
label: `${item.name} (${item.key})`,
|
label: `${item.name} (${item.key})`,
|
||||||
|
|
@ -82,39 +82,43 @@ const areaCodeList = computed(() =>
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
|
||||||
|
function isValidMobileNumber(value: string) {
|
||||||
|
const normalized = value.replace(/\D/g, "");
|
||||||
|
return normalized.length >= 4 && normalized.length <= 15;
|
||||||
|
}
|
||||||
|
|
||||||
const canSendMobileCaptcha = computed(() => {
|
const canSendMobileCaptcha = computed(() => {
|
||||||
const mobile = formData.value.mobile;
|
const mobile = formData.value.mobile;
|
||||||
const phoneRegex = /^1[3-9]\d{9}$/;
|
return isValidMobileNumber(mobile) && smsCountdown.value === 0;
|
||||||
return phoneRegex.test(mobile) && smsCountdown.value === 0;
|
|
||||||
});
|
});
|
||||||
|
|
||||||
// SM2公钥
|
// SM2 public key.
|
||||||
const sm2PublicKey = computed(() => {
|
const sm2PublicKey = computed(() => {
|
||||||
return configStore.config.sm2PublicKey;
|
return configStore.config.sm2PublicKey;
|
||||||
});
|
});
|
||||||
|
|
||||||
// 短信验证码倒计时
|
// SMS verification countdown.
|
||||||
const smsCountdown = ref(0);
|
const smsCountdown = ref(0);
|
||||||
const smsLoading = ref(false);
|
const smsLoading = ref(false);
|
||||||
|
|
||||||
// 打开区号选择弹窗
|
// Open the area-code picker.
|
||||||
function openAreaCodeSheet() {
|
function openAreaCodeSheet() {
|
||||||
showAreaCodeSheet.value = true;
|
showAreaCodeSheet.value = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 选择区号
|
// Select an area code.
|
||||||
function selectAreaCode(item: { value: string; label: string }) {
|
function selectAreaCode(item: { value: string; label: string }) {
|
||||||
selectedAreaCode.value = item.value;
|
selectedAreaCode.value = item.value;
|
||||||
formData.value.areaCode = item.value;
|
formData.value.areaCode = item.value;
|
||||||
showAreaCodeSheet.value = false;
|
showAreaCodeSheet.value = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 关闭区号选择弹窗
|
// Close the area-code picker.
|
||||||
function closeAreaCodeSheet() {
|
function closeAreaCodeSheet() {
|
||||||
showAreaCodeSheet.value = false;
|
showAreaCodeSheet.value = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 生成UUID
|
// Generate a UUID for the captcha request.
|
||||||
function generateUUID() {
|
function generateUUID() {
|
||||||
return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, (c) => {
|
return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, (c) => {
|
||||||
const r = (Math.random() * 16) | 0;
|
const r = (Math.random() * 16) | 0;
|
||||||
|
|
@ -123,18 +127,17 @@ function generateUUID() {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// 获取图形验证码
|
// Refresh the image captcha.
|
||||||
async function refreshCaptcha() {
|
async function refreshCaptcha() {
|
||||||
const uuid = generateUUID();
|
const uuid = generateUUID();
|
||||||
formData.value.captchaId = uuid;
|
formData.value.captchaId = uuid;
|
||||||
captchaImage.value = `${getEnvBaseUrl()}/user/captcha?uuid=${uuid}&t=${Date.now()}`;
|
captchaImage.value = `${getEnvBaseUrl()}/user/captcha?uuid=${uuid}&t=${Date.now()}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 发送短信验证码
|
// Send the SMS verification code.
|
||||||
async function handleSendSmsCode() {
|
async function handleSendSmsCode() {
|
||||||
// 手机号格式验证
|
// Validate the phone number format.
|
||||||
const phoneRegex = /^1[3-9]\d{9}$/;
|
if (!isValidMobileNumber(formData.value.mobile)) {
|
||||||
if (!phoneRegex.test(formData.value.mobile)) {
|
|
||||||
toast.warning(t("retrievePassword.inputCorrectMobile"));
|
toast.warning(t("retrievePassword.inputCorrectMobile"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
@ -146,9 +149,9 @@ async function handleSendSmsCode() {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
smsLoading.value = true;
|
smsLoading.value = true;
|
||||||
// 将手机号转换为国际格式
|
// Convert the phone number into international format.
|
||||||
const internationalPhone = formData.value.areaCode + formData.value.mobile;
|
const internationalPhone = formData.value.areaCode + formData.value.mobile;
|
||||||
// 调用发送短信验证码API
|
// Call the SMS code endpoint.
|
||||||
await sendSmsCode({
|
await sendSmsCode({
|
||||||
phone: internationalPhone,
|
phone: internationalPhone,
|
||||||
captcha: formData.value.captcha,
|
captcha: formData.value.captcha,
|
||||||
|
|
@ -157,7 +160,7 @@ async function handleSendSmsCode() {
|
||||||
|
|
||||||
toast.success(t("retrievePassword.captchaSendSuccess"));
|
toast.success(t("retrievePassword.captchaSendSuccess"));
|
||||||
|
|
||||||
// 开始倒计时
|
// Start the countdown timer.
|
||||||
smsCountdown.value = 60;
|
smsCountdown.value = 60;
|
||||||
const timer = setInterval(() => {
|
const timer = setInterval(() => {
|
||||||
smsCountdown.value--;
|
smsCountdown.value--;
|
||||||
|
|
@ -166,33 +169,32 @@ async function handleSendSmsCode() {
|
||||||
}
|
}
|
||||||
}, 1000);
|
}, 1000);
|
||||||
} catch (error: any) {
|
} catch (error: any) {
|
||||||
// 处理验证码错误
|
// Handle captcha validation errors.
|
||||||
if (error.message.includes("请求错误[10067]")) {
|
if (error.message.includes("10067")) {
|
||||||
toast.warning(t("login.captchaError"));
|
toast.warning(t("login.captchaError"));
|
||||||
}
|
}
|
||||||
// 发送失败重新获取图形验证码
|
// Refresh the image captcha after a failed send.
|
||||||
refreshCaptcha();
|
refreshCaptcha();
|
||||||
} finally {
|
} finally {
|
||||||
smsLoading.value = false;
|
smsLoading.value = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 重置密码
|
// Submit the password reset request.
|
||||||
async function handleResetPassword() {
|
async function handleResetPassword() {
|
||||||
// 表单验证
|
// Validate the form.
|
||||||
if (!formData.value.mobile) {
|
if (!formData.value.mobile) {
|
||||||
toast.warning(t("retrievePassword.mobileRequired"));
|
toast.warning(t("retrievePassword.mobileRequired"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 手机号格式验证
|
// Validate the phone number format.
|
||||||
const phoneRegex = /^1[3-9]\d{9}$/;
|
if (!isValidMobileNumber(formData.value.mobile)) {
|
||||||
if (!phoneRegex.test(formData.value.mobile)) {
|
|
||||||
toast.warning(t("retrievePassword.inputCorrectMobile"));
|
toast.warning(t("retrievePassword.inputCorrectMobile"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 将手机号转换为国际格式
|
// Convert the phone number into international format.
|
||||||
const internationalPhone = formData.value.areaCode + formData.value.mobile;
|
const internationalPhone = formData.value.areaCode + formData.value.mobile;
|
||||||
|
|
||||||
if (!formData.value.captcha) {
|
if (!formData.value.captcha) {
|
||||||
|
|
@ -223,25 +225,25 @@ async function handleResetPassword() {
|
||||||
try {
|
try {
|
||||||
loading.value = true;
|
loading.value = true;
|
||||||
|
|
||||||
// 检查SM2公钥是否配置
|
// Ensure the SM2 public key is configured.
|
||||||
if (!sm2PublicKey.value) {
|
if (!sm2PublicKey.value) {
|
||||||
toast.warning(t("sm2.publicKeyNotConfigured"));
|
toast.warning(t("sm2.publicKeyNotConfigured"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 加密密码
|
// Encrypt the password before sending it.
|
||||||
let encryptedPassword;
|
let encryptedPassword;
|
||||||
try {
|
try {
|
||||||
// 拼接图形验证码和新密码进行加密
|
// Concatenate captcha and new password before encryption.
|
||||||
const captchaAndPassword = formData.value.captcha + formData.value.newPassword;
|
const captchaAndPassword = formData.value.captcha + formData.value.newPassword;
|
||||||
encryptedPassword = sm2Encrypt(sm2PublicKey.value, captchaAndPassword);
|
encryptedPassword = sm2Encrypt(sm2PublicKey.value, captchaAndPassword);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("密码加密失败:", error);
|
console.error("Password encryption failed:", error);
|
||||||
toast.warning(t("sm2.encryptionFailed"));
|
toast.warning(t("sm2.encryptionFailed"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 调用重置密码API
|
// Call the password reset API.
|
||||||
await retrievePassword({
|
await retrievePassword({
|
||||||
phone: internationalPhone,
|
phone: internationalPhone,
|
||||||
code: formData.value.mobileCaptcha,
|
code: formData.value.mobileCaptcha,
|
||||||
|
|
@ -251,46 +253,46 @@ async function handleResetPassword() {
|
||||||
|
|
||||||
toast.success(t("retrievePassword.passwordUpdateSuccess"));
|
toast.success(t("retrievePassword.passwordUpdateSuccess"));
|
||||||
|
|
||||||
// 跳转到登录页
|
// Redirect back to the login page.
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
uni.redirectTo({
|
uni.redirectTo({
|
||||||
url: "/pages/login/index",
|
url: "/pages/login/index",
|
||||||
});
|
});
|
||||||
}, 1000);
|
}, 1000);
|
||||||
} catch (error: any) {
|
} catch (error: any) {
|
||||||
// 处理验证码错误
|
// Handle captcha validation errors.
|
||||||
if (error.message.includes("请求错误[10067]")) {
|
if (error.message.includes("10067")) {
|
||||||
toast.warning(t("login.captchaError"));
|
toast.warning(t("login.captchaError"));
|
||||||
}
|
}
|
||||||
// 重置失败重新获取验证码
|
// Refresh the captcha after a failed reset.
|
||||||
refreshCaptcha();
|
refreshCaptcha();
|
||||||
} finally {
|
} finally {
|
||||||
loading.value = false;
|
loading.value = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 返回登录
|
// Return to the login page.
|
||||||
function goBack() {
|
function goBack() {
|
||||||
uni.redirectTo({
|
uni.redirectTo({
|
||||||
url: "/pages/login/index",
|
url: "/pages/login/index",
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// 页面加载时获取验证码
|
// Fetch the captcha when the page loads.
|
||||||
onLoad(() => {
|
onLoad(() => {
|
||||||
refreshCaptcha();
|
refreshCaptcha();
|
||||||
});
|
});
|
||||||
|
|
||||||
// 组件挂载时确保配置已加载
|
// Ensure configuration and i18n are loaded on mount.
|
||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
if (!configStore.config.name) {
|
if (!configStore.config.name) {
|
||||||
try {
|
try {
|
||||||
await configStore.fetchPublicConfig();
|
await configStore.fetchPublicConfig();
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("获取配置失败:", error);
|
console.error("Failed to fetch configuration:", error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// 初始化国际化
|
// Initialize i18n for the current locale.
|
||||||
initI18n();
|
initI18n();
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
@ -317,7 +319,7 @@ onMounted(async () => {
|
||||||
|
|
||||||
<view class="form-container">
|
<view class="form-container">
|
||||||
<view class="form">
|
<view class="form">
|
||||||
<!-- 手机号输入 -->
|
<!-- Phone number input -->
|
||||||
<view class="input-group">
|
<view class="input-group">
|
||||||
<view class="input-wrapper mobile-wrapper">
|
<view class="input-wrapper mobile-wrapper">
|
||||||
<view class="area-code-selector" @click="openAreaCodeSheet">
|
<view class="area-code-selector" @click="openAreaCodeSheet">
|
||||||
|
|
@ -339,7 +341,7 @@ onMounted(async () => {
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
<!-- 图形验证码 -->
|
<!-- Image captcha -->
|
||||||
<view class="input-group">
|
<view class="input-group">
|
||||||
<view class="input-wrapper captcha-wrapper">
|
<view class="input-wrapper captcha-wrapper">
|
||||||
<wd-input
|
<wd-input
|
||||||
|
|
@ -355,7 +357,7 @@ onMounted(async () => {
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
<!-- 短信验证码 -->
|
<!-- SMS verification code -->
|
||||||
<view class="input-group">
|
<view class="input-group">
|
||||||
<view class="input-wrapper sms-wrapper">
|
<view class="input-wrapper sms-wrapper">
|
||||||
<wd-input
|
<wd-input
|
||||||
|
|
@ -377,7 +379,7 @@ onMounted(async () => {
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
<!-- 新密码 -->
|
<!-- New password -->
|
||||||
<view class="input-group">
|
<view class="input-group">
|
||||||
<view class="input-wrapper">
|
<view class="input-wrapper">
|
||||||
<wd-input
|
<wd-input
|
||||||
|
|
@ -391,7 +393,7 @@ onMounted(async () => {
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
<!-- 确认新密码 -->
|
<!-- Confirm new password -->
|
||||||
<view class="input-group">
|
<view class="input-group">
|
||||||
<view class="input-wrapper">
|
<view class="input-wrapper">
|
||||||
<wd-input
|
<wd-input
|
||||||
|
|
@ -405,12 +407,12 @@ onMounted(async () => {
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
<!-- 重置密码按钮 -->
|
<!-- Reset password button -->
|
||||||
<view class="reset-btn" @click="handleResetPassword">
|
<view class="reset-btn" @click="handleResetPassword">
|
||||||
{{ loading ? t("common.loading") : t("retrievePassword.resetButton") }}
|
{{ loading ? t("common.loading") : t("retrievePassword.resetButton") }}
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
<!-- 返回登录链接 -->
|
<!-- Return-to-login link -->
|
||||||
<view class="back-login-hint" @click="goBack">
|
<view class="back-login-hint" @click="goBack">
|
||||||
<text class="hint-text">
|
<text class="hint-text">
|
||||||
{{ t("retrievePassword.goToLogin") }}
|
{{ t("retrievePassword.goToLogin") }}
|
||||||
|
|
@ -419,7 +421,7 @@ onMounted(async () => {
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
<!-- 区号选择弹窗 -->
|
<!-- Area code selection sheet -->
|
||||||
<wd-action-sheet
|
<wd-action-sheet
|
||||||
v-model="showAreaCodeSheet"
|
v-model="showAreaCodeSheet"
|
||||||
:title="t('login.selectCountry')"
|
:title="t('login.selectCountry')"
|
||||||
|
|
@ -748,7 +750,7 @@ onMounted(async () => {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 区号选择弹窗样式
|
// Area code selection sheet styles.
|
||||||
.area-code-sheet {
|
.area-code-sheet {
|
||||||
background: #ffffff;
|
background: #ffffff;
|
||||||
border-radius: 24rpx 24rpx 0 0;
|
border-radius: 24rpx 24rpx 0 0;
|
||||||
|
|
|
||||||
|
|
@ -1,35 +1,33 @@
|
||||||
<!-- 使用 type="home" 属性设置首页,其他页面不需要设置,默认为page -->
|
<!-- Use type="home" attribute to set homepage, other pages do not need to set, default is page -->
|
||||||
<route lang="jsonc" type="home">
|
<route lang="jsonc" type="home">
|
||||||
{
|
{
|
||||||
"layout": "tabbar",
|
"layout": "tabbar",
|
||||||
"style": {
|
"style": {
|
||||||
// 'custom' 表示开启自定义导航栏,默认 'default'
|
// 'custom' means enable custom navigation bar, default is 'default'
|
||||||
"navigationStyle": "custom",
|
"navigationStyle": "custom",
|
||||||
"navigationBarTitleText": "首页"
|
"navigationBarTitleText": "Home"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</route>
|
</route>
|
||||||
|
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import type { Agent } from '@/api/agent/types'
|
import type { Agent } from '@/api/agent/types'
|
||||||
import { onMounted, ref } from 'vue'
|
import { ref } from 'vue'
|
||||||
// 在组件挂载后设置导航栏标题
|
|
||||||
import { useMessage } from 'wot-design-uni'
|
import { useMessage } from 'wot-design-uni'
|
||||||
import useZPaging from 'z-paging/components/z-paging/js/hooks/useZPaging.js'
|
import useZPaging from 'z-paging/components/z-paging/js/hooks/useZPaging.js'
|
||||||
import { createAgent, deleteAgent, getAgentList } from '@/api/agent/agent'
|
import { createAgent, deleteAgent, getAgentList } from '@/api/agent/agent'
|
||||||
import { t } from '@/i18n'
|
|
||||||
import { toast } from '@/utils/toast'
|
import { toast } from '@/utils/toast'
|
||||||
|
|
||||||
defineOptions({
|
defineOptions({
|
||||||
name: 'Home',
|
name: 'Home',
|
||||||
})
|
})
|
||||||
|
|
||||||
// 获取屏幕边界到安全区域距离
|
// Get distance from screen boundary to safe area
|
||||||
let safeAreaInsets: any
|
let safeAreaInsets: any
|
||||||
let systemInfo: any
|
let systemInfo: any
|
||||||
|
|
||||||
// #ifdef MP-WEIXIN
|
// #ifdef MP-WEIXIN
|
||||||
// 微信小程序使用新的API
|
// WeChat Mini Program uses new API
|
||||||
systemInfo = uni.getWindowInfo()
|
systemInfo = uni.getWindowInfo()
|
||||||
safeAreaInsets = systemInfo.safeArea
|
safeAreaInsets = systemInfo.safeArea
|
||||||
? {
|
? {
|
||||||
|
|
@ -42,93 +40,92 @@ safeAreaInsets = systemInfo.safeArea
|
||||||
// #endif
|
// #endif
|
||||||
|
|
||||||
// #ifndef MP-WEIXIN
|
// #ifndef MP-WEIXIN
|
||||||
// 其他平台继续使用uni API
|
// Other platforms continue to use uni API
|
||||||
systemInfo = uni.getSystemInfoSync()
|
systemInfo = uni.getSystemInfoSync()
|
||||||
safeAreaInsets = systemInfo.safeAreaInsets
|
safeAreaInsets = systemInfo.safeAreaInsets
|
||||||
// #endif
|
// #endif
|
||||||
|
|
||||||
// 智能体数据
|
// Agent data
|
||||||
const agentList = ref<Agent[]>([])
|
const agentList = ref<Agent[]>([])
|
||||||
const pagingRef = ref()
|
const pagingRef = ref()
|
||||||
useZPaging(pagingRef)
|
useZPaging(pagingRef)
|
||||||
// 消息组件
|
// Message component
|
||||||
const message = useMessage()
|
const message = useMessage()
|
||||||
|
|
||||||
// z-paging查询列表数据
|
// z-paging query list data
|
||||||
async function queryList(pageNo: number, pageSize: number) {
|
async function queryList(pageNo: number, pageSize: number) {
|
||||||
try {
|
try {
|
||||||
console.log('z-paging获取智能体列表')
|
console.log('z-paging get agent list')
|
||||||
|
|
||||||
const response = await getAgentList()
|
const response = await getAgentList()
|
||||||
|
|
||||||
// 更新本地列表
|
// Update local list
|
||||||
agentList.value = response
|
agentList.value = response
|
||||||
|
|
||||||
// 直接返回全部数据,不需要分页处理
|
// Return all data directly, no pagination needed
|
||||||
pagingRef.value.complete(response)
|
pagingRef.value.complete(response)
|
||||||
}
|
}
|
||||||
catch (error) {
|
catch (error) {
|
||||||
console.error('获取智能体列表失败:', error)
|
console.error('Failed to get agent list:', error)
|
||||||
// 告知z-paging数据加载失败
|
// Tell z-paging data loading failed
|
||||||
pagingRef.value.complete(false)
|
pagingRef.value.complete(false)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 创建智能体
|
// Create agent
|
||||||
async function handleCreateAgent(agentName: string) {
|
async function handleCreateAgent(agentName: string) {
|
||||||
try {
|
try {
|
||||||
await createAgent({ agentName: agentName.trim() })
|
await createAgent({ agentName: agentName.trim() })
|
||||||
// 创建成功后刷新列表
|
// Refresh list after successful creation
|
||||||
pagingRef.value.reload()
|
pagingRef.value.reload()
|
||||||
toast.success(`${t('home.agentName')}"${agentName}"${t('message.saveSuccess')}`)
|
toast.success(`Agent "${agentName}" created successfully!`)
|
||||||
}
|
}
|
||||||
catch (error: any) {
|
catch (error: any) {
|
||||||
console.error('创建智能体失败:', error)
|
console.error('Failed to create agent:', error)
|
||||||
const errorMessage = error?.message || t('message.saveFail')
|
const errorMessage = error?.message || 'Creation failed, please try again'
|
||||||
toast.error(errorMessage)
|
toast.error(errorMessage)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 删除智能体
|
// Delete agent
|
||||||
async function handleDeleteAgent(agent: Agent) {
|
async function handleDeleteAgent(agent: Agent) {
|
||||||
try {
|
try {
|
||||||
await deleteAgent(agent.id)
|
await deleteAgent(agent.id)
|
||||||
// 删除成功后刷新列表
|
// Refresh list after successful deletion
|
||||||
pagingRef.value.reload()
|
pagingRef.value.reload()
|
||||||
toast.success(`${t('home.agentName')}${t('message.deleteSuccess')}`)
|
toast.success(`Agent "${agent.agentName}" has been deleted`)
|
||||||
}
|
}
|
||||||
catch (error: any) {
|
catch (error: any) {
|
||||||
console.error('删除智能体失败:', error)
|
console.error('Failed to delete agent:', error)
|
||||||
const errorMessage = error?.message || t('message.deleteFail')
|
const errorMessage = error?.message || 'Deletion failed, please try again'
|
||||||
toast.error(errorMessage)
|
toast.error(errorMessage)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 进入编辑页面
|
// Enter edit page
|
||||||
function goToEditAgent(agent: Agent) {
|
function goToEditAgent(agent: Agent) {
|
||||||
// 传递智能体ID到编辑页面
|
// Pass agent ID to edit page
|
||||||
uni.navigateTo({
|
uni.navigateTo({
|
||||||
url: `/pages/agent/index?agentId=${agent.id}`,
|
url: `/pages/agent/index?agentId=${agent.id}`,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// 点击卡片进入编辑
|
// Click card to enter edit
|
||||||
function handleCardClick(agent: Agent) {
|
function handleCardClick(agent: Agent) {
|
||||||
goToEditAgent(agent)
|
goToEditAgent(agent)
|
||||||
}
|
}
|
||||||
|
|
||||||
// 打开创建对话框
|
// Open create dialog
|
||||||
function openCreateDialog() {
|
function openCreateDialog() {
|
||||||
message
|
message
|
||||||
.prompt({
|
.prompt({
|
||||||
title: t('home.dialogTitle'),
|
title: 'Create Agent',
|
||||||
msg: '',
|
msg: '',
|
||||||
inputPlaceholder: t('home.inputPlaceholder'),
|
inputPlaceholder: 'e.g.: Customer Service Assistant, Voice Assistant, Knowledge Q&A',
|
||||||
inputValue: '',
|
inputValue: '',
|
||||||
inputPattern: /^.{1,64}$/i,
|
inputPattern: /^[\u4E00-\u9FA5a-z0-9\s]{1,50}$/i,
|
||||||
inputError: t('home.createError'),
|
confirmButtonText: 'Create Now',
|
||||||
confirmButtonText: t('home.createNow'),
|
cancelButtonText: 'Cancel',
|
||||||
cancelButtonText: t('common.cancel'),
|
|
||||||
})
|
})
|
||||||
.then(async (result: any) => {
|
.then(async (result: any) => {
|
||||||
if (result.value && String(result.value).trim()) {
|
if (result.value && String(result.value).trim()) {
|
||||||
|
|
@ -136,44 +133,38 @@ function openCreateDialog() {
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.catch(() => {
|
.catch(() => {
|
||||||
// 用户取消操作
|
// User cancelled operation
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// 格式化时间
|
// Format time
|
||||||
function formatTime(timeStr: string) {
|
function formatTime(timeStr: string) {
|
||||||
const date = new Date(timeStr)
|
const date = new Date(timeStr)
|
||||||
const now = new Date()
|
const now = new Date()
|
||||||
const diff = now.getTime() - date.getTime()
|
const diff = now.getTime() - date.getTime()
|
||||||
|
|
||||||
if (diff < 60000)
|
if (diff < 60000)
|
||||||
return t('home.justNow')
|
return 'Just now'
|
||||||
if (diff < 3600000)
|
if (diff < 3600000)
|
||||||
return `${Math.floor(diff / 60000)}${t('home.minutesAgo')}`
|
return `${Math.floor(diff / 60000)} minutes ago`
|
||||||
if (diff < 86400000)
|
if (diff < 86400000)
|
||||||
return `${Math.floor(diff / 3600000)}${t('home.hoursAgo')}`
|
return `${Math.floor(diff / 3600000)} hours ago`
|
||||||
return `${Math.floor(diff / 86400000)}${t('home.daysAgo')}`
|
return `${Math.floor(diff / 86400000)} days ago`
|
||||||
}
|
}
|
||||||
|
|
||||||
// 页面显示时刷新列表
|
// Refresh list when page shows
|
||||||
onShow(() => {
|
onShow(() => {
|
||||||
console.log('首页 onShow,刷新智能体列表')
|
console.log('Home onShow, refresh agent list')
|
||||||
if (pagingRef.value) {
|
if (pagingRef.value) {
|
||||||
pagingRef.value.refresh()
|
pagingRef.value.reload()
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
onMounted(() => {
|
|
||||||
uni.setNavigationBarTitle({
|
|
||||||
title: t('home.pageTitle'),
|
|
||||||
})
|
|
||||||
})
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<z-paging
|
<z-paging
|
||||||
ref="pagingRef" v-model="agentList" :refresher-enabled="true" :auto-show-back-to-top="true"
|
ref="pagingRef" v-model="agentList" :refresher-enabled="true" :auto-show-back-to-top="true"
|
||||||
:loading-more-enabled="false" :show-loading-more="false" :hide-empty-view="false" :empty-view-text="t('home.emptyState')"
|
:loading-more-enabled="false" :show-loading-more="false" :hide-empty-view="false" empty-view-text="No agents yet"
|
||||||
empty-view-img="" :refresher-threshold="80" :back-to-top-style="{
|
empty-view-img="" :refresher-threshold="80" :back-to-top-style="{
|
||||||
backgroundColor: '#fff',
|
backgroundColor: '#fff',
|
||||||
borderRadius: '50%',
|
borderRadius: '50%',
|
||||||
|
|
@ -181,33 +172,34 @@ onMounted(() => {
|
||||||
height: '56px',
|
height: '56px',
|
||||||
}" @query="queryList"
|
}" @query="queryList"
|
||||||
>
|
>
|
||||||
<!-- 固定在顶部的横幅区域 -->
|
<!-- Fixed top banner area -->
|
||||||
<template #top>
|
<template #top>
|
||||||
<view class="banner-section" :style="{ paddingTop: `${safeAreaInsets?.top + 100}rpx` }">
|
<view class="banner-section" :style="{ paddingTop: `${safeAreaInsets?.top + 100}rpx` }">
|
||||||
<view class="banner-content">
|
<view class="banner-content">
|
||||||
<view class="welcome-info">
|
<view class="welcome-info">
|
||||||
<text class="greeting">
|
<text class="greeting">
|
||||||
{{ t('home.greeting') }}
|
Hello, XiaoZhi
|
||||||
</text>
|
</text>
|
||||||
<text class="subtitle">
|
<text class="subtitle">
|
||||||
{{ t('home.subtitle') }} <text class="highlight">
|
Let's have a <text class="highlight">wonderful day!</text>
|
||||||
{{ t('home.wonderfulDay') }}
|
|
||||||
</text>
|
</text>
|
||||||
|
<text class="english-subtitle">
|
||||||
|
Hello, Let's have a wonderful day!
|
||||||
</text>
|
</text>
|
||||||
</view>
|
</view>
|
||||||
<view class="wave-decoration">
|
<view class="wave-decoration">
|
||||||
<!-- 添加波浪装饰 -->
|
<!-- Add wave decoration -->
|
||||||
<view class="wave" />
|
<view class="wave" />
|
||||||
<view class="wave wave-2" />
|
<view class="wave wave-2" />
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
<!-- 内容区域开始标识 -->
|
<!-- Content area start marker -->
|
||||||
<view class="content-section-header" />
|
<view class="content-section-header" />
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<!-- 智能体卡片列表 -->
|
<!-- Agent card list -->
|
||||||
<view class="agent-list">
|
<view class="agent-list">
|
||||||
<view v-for="agent in agentList" :key="agent.id" class="agent-item">
|
<view v-for="agent in agentList" :key="agent.id" class="agent-item">
|
||||||
<wd-swipe-action>
|
<wd-swipe-action>
|
||||||
|
|
@ -222,10 +214,10 @@ onMounted(() => {
|
||||||
|
|
||||||
<view class="model-info">
|
<view class="model-info">
|
||||||
<text class="model-text">
|
<text class="model-text">
|
||||||
{{ t('home.languageModel') }}: {{ agent.llmModelName }}
|
Language Model: {{ agent.llmModelName }}
|
||||||
</text>
|
</text>
|
||||||
<text class="model-text">
|
<text class="model-text">
|
||||||
{{ t('home.voiceModel') }}: {{ agent.ttsModelName }} ({{ agent.ttsVoiceName }})
|
Voice Model: {{ agent.ttsModelName }} ({{ agent.ttsVoiceName }})
|
||||||
</text>
|
</text>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
|
|
@ -233,18 +225,15 @@ onMounted(() => {
|
||||||
<view class="stat-chip">
|
<view class="stat-chip">
|
||||||
<wd-icon name="phone" custom-class="chip-icon" />
|
<wd-icon name="phone" custom-class="chip-icon" />
|
||||||
<text class="chip-text">
|
<text class="chip-text">
|
||||||
{{ t('home.deviceManagement') }}({{ agent.deviceCount }})
|
Device Management({{ agent.deviceCount }})
|
||||||
</text>
|
</text>
|
||||||
</view>
|
</view>
|
||||||
<view v-if="agent.lastConnectedAt" class="stat-chip">
|
<view v-if="agent.lastConnectedAt" class="stat-chip">
|
||||||
<wd-icon name="time" custom-class="chip-icon" />
|
<wd-icon name="time" custom-class="chip-icon" />
|
||||||
<text class="chip-text">
|
<text class="chip-text">
|
||||||
{{ t('home.lastConversation') }}{{ formatTime(agent.lastConnectedAt) }}
|
Last Conversation: {{ formatTime(agent.lastConnectedAt) }}
|
||||||
</text>
|
</text>
|
||||||
</view>
|
</view>
|
||||||
<text v-if="agent.tags" class="flex-1 truncate text-right text-[22rpx] text-[#666]">
|
|
||||||
{{ agent.tags.map(tag => tag.tagName).join(',') }}
|
|
||||||
</text>
|
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
|
|
@ -256,7 +245,7 @@ onMounted(() => {
|
||||||
<view class="swipe-actions">
|
<view class="swipe-actions">
|
||||||
<view class="action-btn delete-btn" @click.stop="handleDeleteAgent(agent)">
|
<view class="action-btn delete-btn" @click.stop="handleDeleteAgent(agent)">
|
||||||
<wd-icon name="delete" />
|
<wd-icon name="delete" />
|
||||||
<text>{{ t('home.delete') }}</text>
|
<text>Delete</text>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</template>
|
</template>
|
||||||
|
|
@ -264,23 +253,23 @@ onMounted(() => {
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
<!-- 自定义空状态 -->
|
<!-- Custom empty state -->
|
||||||
<template #empty>
|
<template #empty>
|
||||||
<view class="empty-state">
|
<view class="empty-state">
|
||||||
<wd-icon name="robot" custom-class="empty-icon" />
|
<wd-icon name="robot" custom-class="empty-icon" />
|
||||||
<text class="empty-text">
|
<text class="empty-text">
|
||||||
{{ t('home.emptyState') }}
|
No agents yet
|
||||||
</text>
|
</text>
|
||||||
<text class="empty-desc">
|
<text class="empty-desc">
|
||||||
{{ t('home.createFirstAgent') }}
|
Click the + button in the bottom right to create your first agent
|
||||||
</text>
|
</text>
|
||||||
</view>
|
</view>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<!-- FAB 新增按钮 -->
|
<!-- FAB add button -->
|
||||||
<wd-fab type="primary" icon="add" :draggable="true" :expandable="false" @click="openCreateDialog" />
|
<wd-fab type="primary" icon="add" :draggable="true" :expandable="false" @click="openCreateDialog" />
|
||||||
|
|
||||||
<!-- MessageBox 组件 -->
|
<!-- MessageBox component -->
|
||||||
<wd-message-box />
|
<wd-message-box />
|
||||||
</z-paging>
|
</z-paging>
|
||||||
</template>
|
</template>
|
||||||
|
|
@ -385,7 +374,7 @@ onMounted(() => {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 内容区域开始标识,创建白色背景过渡
|
// Content area start marker, create white background transition
|
||||||
.content-section-header {
|
.content-section-header {
|
||||||
background: #ffffff;
|
background: #ffffff;
|
||||||
border-radius: 32rpx 32rpx 0 0;
|
border-radius: 32rpx 32rpx 0 0;
|
||||||
|
|
@ -395,7 +384,7 @@ onMounted(() => {
|
||||||
z-index: 1;
|
z-index: 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
// z-paging内容区域样式
|
// z-paging content area styles
|
||||||
:deep(.z-paging-content) {
|
:deep(.z-paging-content) {
|
||||||
background: #ffffff;
|
background: #ffffff;
|
||||||
padding: 0 0 40rpx 0;
|
padding: 0 0 40rpx 0;
|
||||||
|
|
@ -435,7 +424,6 @@ onMounted(() => {
|
||||||
|
|
||||||
.card-main {
|
.card-main {
|
||||||
flex: 1;
|
flex: 1;
|
||||||
width: 100%;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.agent-title {
|
.agent-title {
|
||||||
|
|
@ -468,9 +456,7 @@ onMounted(() => {
|
||||||
}
|
}
|
||||||
|
|
||||||
.stats-row {
|
.stats-row {
|
||||||
width: 100%;
|
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
|
||||||
gap: 12rpx;
|
gap: 12rpx;
|
||||||
flex-wrap: wrap;
|
flex-wrap: wrap;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -10,22 +10,18 @@
|
||||||
|
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import type { LoginData } from '@/api/auth'
|
import type { LoginData } from '@/api/auth'
|
||||||
import type { Language } from '@/store/lang'
|
|
||||||
import { computed, onMounted, ref } from 'vue'
|
import { computed, onMounted, ref } from 'vue'
|
||||||
import { login } from '@/api/auth'
|
import { login } from '@/api/auth'
|
||||||
// 导入国际化相关功能
|
import { useConfigStore } from '@/store'
|
||||||
import { changeLanguage, getCurrentLanguage, getSupportedLanguages, initI18n, t } from '@/i18n'
|
|
||||||
import { useConfigStore, useUserStore } from '@/store'
|
|
||||||
// 导入SM2加密工具
|
|
||||||
import { getEnvBaseUrl, sm2Encrypt } from '@/utils'
|
import { getEnvBaseUrl, sm2Encrypt } from '@/utils'
|
||||||
import { toast } from '@/utils/toast'
|
import { toast } from '@/utils/toast'
|
||||||
|
|
||||||
// 获取屏幕边界到安全区域距离
|
// Get distance from screen boundary to safe area
|
||||||
let safeAreaInsets
|
let safeAreaInsets
|
||||||
let systemInfo
|
let systemInfo
|
||||||
|
|
||||||
// #ifdef MP-WEIXIN
|
// #ifdef MP-WEIXIN
|
||||||
// 微信小程序使用新的API
|
// WeChat Mini Program uses new API
|
||||||
systemInfo = uni.getWindowInfo()
|
systemInfo = uni.getWindowInfo()
|
||||||
safeAreaInsets = systemInfo.safeArea
|
safeAreaInsets = systemInfo.safeArea
|
||||||
? {
|
? {
|
||||||
|
|
@ -38,60 +34,61 @@ safeAreaInsets = systemInfo.safeArea
|
||||||
// #endif
|
// #endif
|
||||||
|
|
||||||
// #ifndef MP-WEIXIN
|
// #ifndef MP-WEIXIN
|
||||||
// 其他平台继续使用uni API
|
// Other platforms continue to use uni API
|
||||||
systemInfo = uni.getSystemInfoSync()
|
systemInfo = uni.getSystemInfoSync()
|
||||||
safeAreaInsets = systemInfo.safeAreaInsets
|
safeAreaInsets = systemInfo.safeAreaInsets
|
||||||
// #endif
|
// #endif
|
||||||
// 表单数据
|
// Form data
|
||||||
const formData = ref({
|
const formData = ref<LoginData>({
|
||||||
username: '',
|
username: '',
|
||||||
password: '',
|
password: '',
|
||||||
captcha: '',
|
captcha: '',
|
||||||
captchaId: '',
|
captchaId: '',
|
||||||
areaCode: '+86',
|
areaCode: '+1',
|
||||||
mobile: '',
|
mobile: '',
|
||||||
})
|
})
|
||||||
|
|
||||||
// 验证码图片
|
// Captcha image
|
||||||
const captchaImage = ref('')
|
const captchaImage = ref('')
|
||||||
const loading = ref(false)
|
const loading = ref(false)
|
||||||
|
|
||||||
// 登录方式:'username' | 'mobile'
|
// Login method: 'username' | 'mobile'
|
||||||
const loginType = ref<'username' | 'mobile'>('username')
|
const loginType = ref<'username' | 'mobile'>('username')
|
||||||
|
|
||||||
// 获取配置store
|
// Get config store
|
||||||
const configStore = useConfigStore()
|
const configStore = useConfigStore()
|
||||||
const userStore = useUserStore()
|
|
||||||
|
|
||||||
// 区号选择相关
|
// Area code selection related
|
||||||
const showAreaCodeSheet = ref(false)
|
const showAreaCodeSheet = ref(false)
|
||||||
const selectedAreaCode = ref('+86')
|
const selectedAreaCode = ref('+1')
|
||||||
const selectedAreaName = ref('中国大陆')
|
const selectedAreaName = ref('United States')
|
||||||
|
|
||||||
// 计算属性:是否启用手机号登录
|
// Computed property: whether mobile login is enabled
|
||||||
const enableMobileLogin = computed(() => {
|
const enableMobileLogin = computed(() => {
|
||||||
return configStore.config.enableMobileRegister
|
return configStore.config.enableMobileRegister
|
||||||
})
|
})
|
||||||
|
|
||||||
// 计算属性:区号列表
|
const sm2PublicKey = computed(() => configStore.config.sm2PublicKey)
|
||||||
|
|
||||||
|
// Computed property: area code list
|
||||||
const areaCodeList = computed(() => {
|
const areaCodeList = computed(() => {
|
||||||
return configStore.config.mobileAreaList || [{ name: '中国大陆', key: '+86' }]
|
return configStore.config.mobileAreaList || [{ name: 'United States', key: '+1' }]
|
||||||
})
|
})
|
||||||
|
|
||||||
// 切换登录方式
|
// Switch login method
|
||||||
function toggleLoginType() {
|
function toggleLoginType() {
|
||||||
loginType.value = loginType.value === 'username' ? 'mobile' : 'username'
|
loginType.value = loginType.value === 'username' ? 'mobile' : 'username'
|
||||||
// 清空输入框
|
// Clear input fields
|
||||||
formData.value.username = ''
|
formData.value.username = ''
|
||||||
formData.value.mobile = ''
|
formData.value.mobile = ''
|
||||||
}
|
}
|
||||||
|
|
||||||
// 打开区号选择弹窗
|
// Open area code selection dialog
|
||||||
function openAreaCodeSheet() {
|
function openAreaCodeSheet() {
|
||||||
showAreaCodeSheet.value = true
|
showAreaCodeSheet.value = true
|
||||||
}
|
}
|
||||||
|
|
||||||
// 选择区号
|
// Select area code
|
||||||
function selectAreaCode(item: { name: string, key: string }) {
|
function selectAreaCode(item: { name: string, key: string }) {
|
||||||
selectedAreaCode.value = item.key
|
selectedAreaCode.value = item.key
|
||||||
selectedAreaName.value = item.name
|
selectedAreaName.value = item.name
|
||||||
|
|
@ -99,42 +96,19 @@ function selectAreaCode(item: { name: string, key: string }) {
|
||||||
showAreaCodeSheet.value = false
|
showAreaCodeSheet.value = false
|
||||||
}
|
}
|
||||||
|
|
||||||
// 关闭区号选择弹窗
|
// Close area code selection dialog
|
||||||
function closeAreaCodeSheet() {
|
function closeAreaCodeSheet() {
|
||||||
showAreaCodeSheet.value = false
|
showAreaCodeSheet.value = false
|
||||||
}
|
}
|
||||||
|
|
||||||
// 跳转到注册页面
|
// Navigate to registration page
|
||||||
function goToRegister() {
|
function goToRegister() {
|
||||||
uni.navigateTo({
|
uni.navigateTo({
|
||||||
url: '/pages/register/index',
|
url: '/pages/register/index',
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// 跳转到忘记密码页面
|
// Generate UUID
|
||||||
function goToForgotPassword() {
|
|
||||||
uni.navigateTo({
|
|
||||||
url: '/pages/forgot-password/index',
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
// 跳转到用户协议
|
|
||||||
function goToUserAgreement() {
|
|
||||||
const lang = getCurrentLanguage() === 'zh_CN' ? 'zh' : 'en'
|
|
||||||
uni.navigateTo({
|
|
||||||
url: `/pages/login/user-agreement-${lang}`,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
// 跳转到隐私政策
|
|
||||||
function goToPrivacyPolicy() {
|
|
||||||
const lang = getCurrentLanguage() === 'zh_CN' ? 'zh' : 'en'
|
|
||||||
uni.navigateTo({
|
|
||||||
url: `/pages/login/privacy-policy-${lang}`,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
// 生成UUID
|
|
||||||
function generateUUID() {
|
function generateUUID() {
|
||||||
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, (c) => {
|
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, (c) => {
|
||||||
const r = Math.random() * 16 | 0
|
const r = Math.random() * 16 | 0
|
||||||
|
|
@ -143,96 +117,83 @@ function generateUUID() {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// 跳转至服务端设置页面
|
function isValidMobileNumber(value: string) {
|
||||||
|
const normalized = value.replace(/\D/g, '')
|
||||||
|
return normalized.length >= 4 && normalized.length <= 15
|
||||||
|
}
|
||||||
|
|
||||||
|
let skipReLaunch = false // Global or component scope
|
||||||
|
|
||||||
|
// Navigate to server settings page
|
||||||
function goToServerSetting() {
|
function goToServerSetting() {
|
||||||
uni.switchTab({
|
uni.switchTab({
|
||||||
url: '/pages/settings/index',
|
url: '/pages/settings/index',
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// 获取验证码
|
// Get verification code
|
||||||
async function refreshCaptcha() {
|
async function refreshCaptcha() {
|
||||||
const uuid = generateUUID()
|
const uuid = generateUUID()
|
||||||
formData.value.captchaId = uuid
|
formData.value.captchaId = uuid
|
||||||
captchaImage.value = `${getEnvBaseUrl()}/user/captcha?uuid=${uuid}&t=${Date.now()}`
|
captchaImage.value = `${getEnvBaseUrl()}/user/captcha?uuid=${uuid}&t=${Date.now()}`
|
||||||
}
|
}
|
||||||
|
|
||||||
// 登录
|
// Login
|
||||||
async function handleLogin() {
|
async function handleLogin() {
|
||||||
// 表单验证
|
// Form validation
|
||||||
if (loginType.value === 'username') {
|
if (loginType.value === 'username') {
|
||||||
if (!formData.value.username) {
|
if (!formData.value.username) {
|
||||||
toast.warning(t('login.enterUsername'))
|
toast.warning('Please enter a username')
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (!formData.value.mobile) {
|
if (!formData.value.mobile) {
|
||||||
toast.warning(t('login.enterPhone'))
|
toast.warning('Please enter a phone number')
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
// 手机号格式验证
|
// Phone number format validation
|
||||||
const phoneRegex = /^1[3-9]\d{9}$/
|
if (!isValidMobileNumber(formData.value.mobile)) {
|
||||||
if (!phoneRegex.test(formData.value.mobile)) {
|
toast.warning('Please enter a valid phone number')
|
||||||
toast.warning(t('login.enterPhone'))
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!formData.value.password) {
|
if (!formData.value.password) {
|
||||||
toast.warning(t('login.enterPassword'))
|
toast.warning('Please enter a password')
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if (!formData.value.captcha) {
|
if (!formData.value.captcha) {
|
||||||
toast.warning(t('login.enterCaptcha'))
|
toast.warning('Please enter the verification code')
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// 检查SM2公钥是否配置
|
if (!sm2PublicKey.value) {
|
||||||
const sm2PublicKey = configStore.config.sm2PublicKey
|
toast.warning('SM2 public key not configured, please contact administrator')
|
||||||
if (!sm2PublicKey) {
|
|
||||||
toast.warning(t('sm2.publicKeyNotConfigured'))
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
loading.value = true
|
loading.value = true
|
||||||
|
|
||||||
// 加密密码
|
// Build login data
|
||||||
let encryptedPassword
|
const loginData = { ...formData.value }
|
||||||
try {
|
|
||||||
// 拼接验证码和密码
|
|
||||||
const captchaAndPassword = formData.value.captcha + formData.value.password
|
|
||||||
encryptedPassword = sm2Encrypt(sm2PublicKey, captchaAndPassword)
|
|
||||||
}
|
|
||||||
catch (error) {
|
|
||||||
console.error('密码加密失败:', error)
|
|
||||||
toast.warning(t('sm2.encryptionFailed'))
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
// 构建登录数据
|
// If logging in with mobile, prefix area code to phone and assign to username
|
||||||
const loginData: LoginData = {
|
|
||||||
username: '',
|
|
||||||
password: encryptedPassword,
|
|
||||||
captchaId: formData.value.captchaId,
|
|
||||||
}
|
|
||||||
|
|
||||||
// 如果是手机号登录,将区号+手机号拼接到username字段
|
|
||||||
if (loginType.value === 'mobile') {
|
if (loginType.value === 'mobile') {
|
||||||
loginData.username = `${selectedAreaCode.value}${formData.value.mobile}`
|
loginData.username = `${selectedAreaCode.value}${formData.value.mobile}`
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
loginData.username = formData.value.username
|
const captchaAndPassword = `${formData.value.captcha}${formData.value.password}`
|
||||||
}
|
loginData.password = sm2Encrypt(sm2PublicKey.value, captchaAndPassword)
|
||||||
|
|
||||||
const response = await login(loginData)
|
const response = await login(loginData)
|
||||||
// 存储token
|
// Store token
|
||||||
uni.setStorageSync('token', JSON.stringify(response))
|
uni.setStorageSync('token', response.token)
|
||||||
await userStore.getUserInfo()
|
uni.setStorageSync('expire', response.expire)
|
||||||
|
|
||||||
toast.success(t('message.loginSuccess'))
|
toast.success('Login successful')
|
||||||
|
|
||||||
// 跳转到主页
|
// Navigate to the home page
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
uni.reLaunch({
|
uni.reLaunch({
|
||||||
url: '/pages/index/index',
|
url: '/pages/index/index',
|
||||||
|
|
@ -240,7 +201,7 @@ async function handleLogin() {
|
||||||
}, 1000)
|
}, 1000)
|
||||||
}
|
}
|
||||||
catch (error: any) {
|
catch (error: any) {
|
||||||
// 登录失败重新获取验证码
|
// On login failure, refresh captcha
|
||||||
refreshCaptcha()
|
refreshCaptcha()
|
||||||
}
|
}
|
||||||
finally {
|
finally {
|
||||||
|
|
@ -248,32 +209,19 @@ async function handleLogin() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 页面加载时获取验证码
|
// Fetch captcha on page load
|
||||||
onLoad(() => {
|
onLoad(() => {
|
||||||
refreshCaptcha()
|
refreshCaptcha()
|
||||||
})
|
})
|
||||||
|
|
||||||
// 语言切换相关
|
// Ensure configuration is loaded on mount
|
||||||
const showLanguageSheet = ref(false)
|
|
||||||
const supportedLanguages = getSupportedLanguages()
|
|
||||||
|
|
||||||
// 初始化国际化
|
|
||||||
initI18n()
|
|
||||||
|
|
||||||
// 切换语言
|
|
||||||
function handleLanguageChange(lang: Language) {
|
|
||||||
changeLanguage(lang)
|
|
||||||
showLanguageSheet.value = false
|
|
||||||
}
|
|
||||||
|
|
||||||
// 组件挂载时确保配置已加载
|
|
||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
if (!configStore.config.name) {
|
if (!configStore.config.name) {
|
||||||
try {
|
try {
|
||||||
await configStore.fetchPublicConfig()
|
await configStore.fetchPublicConfig()
|
||||||
}
|
}
|
||||||
catch (error) {
|
catch (error) {
|
||||||
console.error(t('login.fetchConfigError'), error)
|
console.error('Failed to fetch configuration:', error)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
@ -285,32 +233,26 @@ onMounted(async () => {
|
||||||
<view class="logo-section">
|
<view class="logo-section">
|
||||||
<wd-img :width="80" :height="80" round src="/static/logo.png" class="logo" />
|
<wd-img :width="80" :height="80" round src="/static/logo.png" class="logo" />
|
||||||
<text class="welcome-text">
|
<text class="welcome-text">
|
||||||
{{ t('login.welcomeBack') }}
|
Welcome back
|
||||||
</text>
|
</text>
|
||||||
<text class="subtitle">
|
<text class="subtitle">
|
||||||
{{ t('login.pleaseLogin') }}
|
Please sign in to your account
|
||||||
</text>
|
</text>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
<!-- 右上角按钮组 -->
|
<!-- Server settings button at top-right -->
|
||||||
<view class="top-right-buttons" :style="{ top: `${safeAreaInsets?.top + 10}px` }">
|
<view
|
||||||
<!-- 语言切换按钮 -->
|
class="server-btn"
|
||||||
<view class="lang-btn" @click="showLanguageSheet = true">
|
:style="{ top: `${safeAreaInsets?.top + 10}px` }"
|
||||||
<text class="lang-text-icon">
|
@click="goToServerSetting"
|
||||||
{{ t('login.selectLanguageTip') }}
|
>
|
||||||
</text>
|
|
||||||
</view>
|
|
||||||
|
|
||||||
<!-- 服务端设置按钮 -->
|
|
||||||
<view class="server-btn" @click="goToServerSetting">
|
|
||||||
<wd-icon name="setting" custom-class="server-icon" />
|
<wd-icon name="setting" custom-class="server-icon" />
|
||||||
</view>
|
</view>
|
||||||
</view>
|
|
||||||
|
|
||||||
<view class="form-container">
|
<view class="form-container">
|
||||||
<view class="form">
|
<view class="form">
|
||||||
<!-- 手机号登录 -->
|
<!-- Mobile login -->
|
||||||
<template v-if="loginType === 'mobile'">
|
<template v-if="loginType === 'mobile'">
|
||||||
<view class="input-group">
|
<view class="input-group">
|
||||||
<view class="input-wrapper mobile-wrapper">
|
<view class="input-wrapper mobile-wrapper">
|
||||||
|
|
@ -325,7 +267,7 @@ onMounted(async () => {
|
||||||
v-model="formData.mobile"
|
v-model="formData.mobile"
|
||||||
custom-class="styled-input"
|
custom-class="styled-input"
|
||||||
no-border
|
no-border
|
||||||
:placeholder="t('login.enterPhone')"
|
placeholder="Please enter your phone number"
|
||||||
type="number"
|
type="number"
|
||||||
:maxlength="11"
|
:maxlength="11"
|
||||||
/>
|
/>
|
||||||
|
|
@ -334,7 +276,7 @@ onMounted(async () => {
|
||||||
</view>
|
</view>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<!-- 用户名登录 -->
|
<!-- Username login -->
|
||||||
<template v-else>
|
<template v-else>
|
||||||
<view class="input-group">
|
<view class="input-group">
|
||||||
<view class="input-wrapper">
|
<view class="input-wrapper">
|
||||||
|
|
@ -342,7 +284,7 @@ onMounted(async () => {
|
||||||
v-model="formData.username"
|
v-model="formData.username"
|
||||||
custom-class="styled-input"
|
custom-class="styled-input"
|
||||||
no-border
|
no-border
|
||||||
:placeholder="t('login.enterUsername')"
|
placeholder="Please enter your username"
|
||||||
/>
|
/>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
|
|
@ -354,7 +296,7 @@ onMounted(async () => {
|
||||||
v-model="formData.password"
|
v-model="formData.password"
|
||||||
custom-class="styled-input"
|
custom-class="styled-input"
|
||||||
no-border
|
no-border
|
||||||
:placeholder="t('login.enterPassword')"
|
placeholder="Please enter your password"
|
||||||
clearable
|
clearable
|
||||||
show-password
|
show-password
|
||||||
:maxlength="20"
|
:maxlength="20"
|
||||||
|
|
@ -368,7 +310,7 @@ onMounted(async () => {
|
||||||
v-model="formData.captcha"
|
v-model="formData.captcha"
|
||||||
custom-class="styled-input"
|
custom-class="styled-input"
|
||||||
no-border
|
no-border
|
||||||
:placeholder="t('login.enterCaptcha')"
|
placeholder="Please enter the verification code"
|
||||||
:maxlength="6"
|
:maxlength="6"
|
||||||
/>
|
/>
|
||||||
<view class="captcha-image" @click="refreshCaptcha">
|
<view class="captcha-image" @click="refreshCaptcha">
|
||||||
|
|
@ -376,38 +318,30 @@ onMounted(async () => {
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
|
<view class="forgot-password">
|
||||||
|
<text class="forgot-text">
|
||||||
|
Forgot password?
|
||||||
|
</text>
|
||||||
|
</view>
|
||||||
|
|
||||||
<view
|
<view
|
||||||
class="login-btn"
|
class="login-btn"
|
||||||
@click="handleLogin"
|
@click="handleLogin"
|
||||||
>
|
>
|
||||||
{{ loading ? t('login.loggingIn') : t('login.loginButton') }}
|
{{ loading ? 'Signing in...' : 'Sign In' }}
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
<view class="hint-row">
|
|
||||||
<view class="register-hint">
|
<view class="register-hint">
|
||||||
|
<text class="hint-text">
|
||||||
|
Don't have an account?
|
||||||
|
</text>
|
||||||
<text class="register-link" @click="goToRegister">
|
<text class="register-link" @click="goToRegister">
|
||||||
{{ t('login.noAccount') }}
|
Register now
|
||||||
</text>
|
</text>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
<view class="forgot-password">
|
<!-- Login method switch -->
|
||||||
<text class="forgot-text" @click="goToForgotPassword">
|
|
||||||
{{ t('login.forgotPassword') }}
|
|
||||||
</text>
|
|
||||||
</view>
|
|
||||||
</view>
|
|
||||||
|
|
||||||
<view class="policy-links">
|
|
||||||
<text class="policy-link" @click="goToUserAgreement">
|
|
||||||
{{ t('login.userAgreement') }}
|
|
||||||
</text>
|
|
||||||
<text class="policy-divider">|</text>
|
|
||||||
<text class="policy-link" @click="goToPrivacyPolicy">
|
|
||||||
{{ t('login.privacyPolicy') }}
|
|
||||||
</text>
|
|
||||||
</view>
|
|
||||||
|
|
||||||
<!-- 登录方式切换 -->
|
|
||||||
<view v-if="enableMobileLogin" class="login-type-switch">
|
<view v-if="enableMobileLogin" class="login-type-switch">
|
||||||
<view class="switch-tabs">
|
<view class="switch-tabs">
|
||||||
<view
|
<view
|
||||||
|
|
@ -429,10 +363,10 @@ onMounted(async () => {
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
<!-- 区号选择弹窗 -->
|
<!-- Area code selection popup -->
|
||||||
<wd-action-sheet
|
<wd-action-sheet
|
||||||
v-model="showAreaCodeSheet"
|
v-model="showAreaCodeSheet"
|
||||||
:title="t('login.selectCountry')"
|
title="Select Country/Region"
|
||||||
:close-on-click-modal="true"
|
:close-on-click-modal="true"
|
||||||
@close="closeAreaCodeSheet"
|
@close="closeAreaCodeSheet"
|
||||||
>
|
>
|
||||||
|
|
@ -466,33 +400,11 @@ onMounted(async () => {
|
||||||
custom-class="confirm-btn"
|
custom-class="confirm-btn"
|
||||||
@click="closeAreaCodeSheet"
|
@click="closeAreaCodeSheet"
|
||||||
>
|
>
|
||||||
{{ t('login.confirm') }}
|
Confirm
|
||||||
</wd-button>
|
</wd-button>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</wd-action-sheet>
|
</wd-action-sheet>
|
||||||
|
|
||||||
<!-- 语言选择弹窗 -->
|
|
||||||
<wd-action-sheet
|
|
||||||
v-model="showLanguageSheet"
|
|
||||||
:title="t('login.selectLanguage')"
|
|
||||||
:close-on-click-modal="true"
|
|
||||||
>
|
|
||||||
<view class="language-sheet">
|
|
||||||
<scroll-view scroll-y class="language-list">
|
|
||||||
<view
|
|
||||||
v-for="lang in supportedLanguages"
|
|
||||||
:key="lang.code"
|
|
||||||
class="language-item"
|
|
||||||
@click="handleLanguageChange(lang.code)"
|
|
||||||
>
|
|
||||||
<text class="language-name">
|
|
||||||
{{ lang.name }}
|
|
||||||
</text>
|
|
||||||
</view>
|
|
||||||
</scroll-view>
|
|
||||||
</view>
|
|
||||||
</wd-action-sheet>
|
|
||||||
</view>
|
</view>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
|
@ -583,6 +495,7 @@ onMounted(async () => {
|
||||||
|
|
||||||
.input-wrapper {
|
.input-wrapper {
|
||||||
position: relative;
|
position: relative;
|
||||||
|
background: #f8f9fa;
|
||||||
border-radius: 16rpx;
|
border-radius: 16rpx;
|
||||||
padding: 20rpx 16rpx;
|
padding: 20rpx 16rpx;
|
||||||
border: 2rpx solid #e9ecef;
|
border: 2rpx solid #e9ecef;
|
||||||
|
|
@ -599,7 +512,7 @@ onMounted(async () => {
|
||||||
&.captcha-wrapper {
|
&.captcha-wrapper {
|
||||||
.captcha-image {
|
.captcha-image {
|
||||||
margin-left: 20rpx;
|
margin-left: 20rpx;
|
||||||
width: 150rpx;
|
width: 120rpx;
|
||||||
height: 60rpx;
|
height: 60rpx;
|
||||||
border-radius: 8rpx;
|
border-radius: 8rpx;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
|
|
@ -693,37 +606,10 @@ onMounted(async () => {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.hint-row {
|
|
||||||
display: flex;
|
|
||||||
justify-content: space-between;
|
|
||||||
align-items: center;
|
|
||||||
margin-bottom: 30rpx;
|
|
||||||
}
|
|
||||||
|
|
||||||
.policy-links {
|
|
||||||
display: flex;
|
|
||||||
justify-content: center;
|
|
||||||
align-items: center;
|
|
||||||
gap: 20rpx;
|
|
||||||
margin-bottom: 30rpx;
|
|
||||||
|
|
||||||
.policy-link {
|
|
||||||
color: #667eea;
|
|
||||||
font-size: 26rpx;
|
|
||||||
cursor: pointer;
|
|
||||||
|
|
||||||
&:hover {
|
|
||||||
text-decoration: underline;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
.policy-divider {
|
|
||||||
color: #999999;
|
|
||||||
font-size: 26rpx;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
.forgot-password {
|
.forgot-password {
|
||||||
|
text-align: right;
|
||||||
|
margin-bottom: 30rpx;
|
||||||
|
|
||||||
.forgot-text {
|
.forgot-text {
|
||||||
color: #667eea;
|
color: #667eea;
|
||||||
font-size: 26rpx;
|
font-size: 26rpx;
|
||||||
|
|
@ -761,6 +647,14 @@ onMounted(async () => {
|
||||||
}
|
}
|
||||||
|
|
||||||
.register-hint {
|
.register-hint {
|
||||||
|
text-align: center;
|
||||||
|
|
||||||
|
.hint-text {
|
||||||
|
color: #666666;
|
||||||
|
font-size: 26rpx;
|
||||||
|
margin-right: 8rpx;
|
||||||
|
}
|
||||||
|
|
||||||
.register-link {
|
.register-link {
|
||||||
color: #667eea;
|
color: #667eea;
|
||||||
font-size: 26rpx;
|
font-size: 26rpx;
|
||||||
|
|
@ -816,7 +710,7 @@ onMounted(async () => {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 区号选择弹窗样式
|
// Area code selection popup style
|
||||||
.area-code-sheet {
|
.area-code-sheet {
|
||||||
background: #ffffff;
|
background: #ffffff;
|
||||||
border-radius: 24rpx 24rpx 0 0;
|
border-radius: 24rpx 24rpx 0 0;
|
||||||
|
|
@ -913,52 +807,20 @@ onMounted(async () => {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// 右上角按钮组
|
|
||||||
.top-right-buttons {
|
|
||||||
position: absolute;
|
|
||||||
right: 20rpx;
|
|
||||||
display: flex;
|
|
||||||
gap: 20rpx;
|
|
||||||
z-index: 999;
|
|
||||||
}
|
|
||||||
|
|
||||||
// 语言切换按钮
|
|
||||||
.lang-btn {
|
|
||||||
width: 48rpx;
|
|
||||||
height: 48rpx;
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
justify-content: center;
|
|
||||||
cursor: pointer;
|
|
||||||
background: rgba(255, 255, 255, 0.15);
|
|
||||||
border-radius: 24rpx;
|
|
||||||
box-shadow: 0 4rpx 12rpx rgba(0, 0, 0, 0.2);
|
|
||||||
|
|
||||||
&:active {
|
|
||||||
transform: scale(0.95);
|
|
||||||
}
|
|
||||||
|
|
||||||
.lang-text-icon {
|
|
||||||
font-size: 18rpx;
|
|
||||||
color: #ffffff;
|
|
||||||
}
|
|
||||||
|
|
||||||
&:hover {
|
|
||||||
background: rgba(255, 255, 255, 0.25);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// 服务端设置按钮
|
|
||||||
.server-btn {
|
.server-btn {
|
||||||
|
position: absolute;
|
||||||
|
right: 20rpx; // Right margin
|
||||||
|
top: 40rpx; // Slightly below top, not touching status bar
|
||||||
width: 48rpx;
|
width: 48rpx;
|
||||||
height: 48rpx;
|
height: 48rpx;
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
|
z-index: 999;
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
background: rgba(255, 255, 255, 0.15);
|
background: rgba(255, 255, 255, 0.15); // Semi-transparent background, better look
|
||||||
border-radius: 24rpx;
|
border-radius: 24rpx; // Round button
|
||||||
box-shadow: 0 4rpx 12rpx rgba(0, 0, 0, 0.2);
|
box-shadow: 0 4rpx 12rpx rgba(0,0,0,0.2); // Shadow
|
||||||
|
|
||||||
&:active {
|
&:active {
|
||||||
transform: scale(0.95);
|
transform: scale(0.95);
|
||||||
|
|
@ -966,45 +828,12 @@ onMounted(async () => {
|
||||||
|
|
||||||
.server-icon {
|
.server-icon {
|
||||||
font-size: 28rpx;
|
font-size: 28rpx;
|
||||||
color: #ffffff;
|
color: #FFFFFF; // White icon
|
||||||
}
|
}
|
||||||
|
|
||||||
&:hover {
|
&:hover {
|
||||||
background: rgba(255, 255, 255, 0.25);
|
background: rgba(255, 255, 255, 0.25); // Hover effect
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// 语言选择弹窗样式
|
|
||||||
.language-sheet {
|
|
||||||
background: #ffffff;
|
|
||||||
border-radius: 24rpx 24rpx 0 0;
|
|
||||||
overflow: hidden;
|
|
||||||
|
|
||||||
.language-list {
|
|
||||||
max-height: 60vh;
|
|
||||||
padding: 0 40rpx;
|
|
||||||
|
|
||||||
.language-item {
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
padding: 32rpx 0;
|
|
||||||
border-bottom: 1rpx solid #f8f9fa;
|
|
||||||
cursor: pointer;
|
|
||||||
transition: background-color 0.3s ease;
|
|
||||||
|
|
||||||
&:hover {
|
|
||||||
background-color: #f8f9fa;
|
|
||||||
}
|
|
||||||
|
|
||||||
&:last-child {
|
|
||||||
border-bottom: none;
|
|
||||||
}
|
|
||||||
|
|
||||||
.language-name {
|
|
||||||
font-size: 32rpx;
|
|
||||||
color: #333333;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// Area code popup styles
|
||||||
</style>
|
</style>
|
||||||
|
|
|
||||||
|
|
@ -1,402 +0,0 @@
|
||||||
<route lang="jsonc" type="page">
|
|
||||||
{
|
|
||||||
"layout": "default",
|
|
||||||
"style": {
|
|
||||||
"navigationStyle": "custom",
|
|
||||||
"navigationBarTitleText": "隐私政策"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
</route>
|
|
||||||
|
|
||||||
<script lang="ts" setup>
|
|
||||||
import { t } from '@/i18n'
|
|
||||||
|
|
||||||
function goBack() {
|
|
||||||
uni.navigateBack()
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<template>
|
|
||||||
<view class="h-screen flex flex-col bg-[#f5f8fd]">
|
|
||||||
<wd-navbar
|
|
||||||
:title="t('login.privacyPolicy')"
|
|
||||||
safe-area-inset-top
|
|
||||||
left-arrow
|
|
||||||
:bordered="false"
|
|
||||||
@click-left="goBack"
|
|
||||||
>
|
|
||||||
<template #left>
|
|
||||||
<wd-icon name="arrow-left" size="18" />
|
|
||||||
</template>
|
|
||||||
</wd-navbar>
|
|
||||||
<scroll-view scroll-y class="box-border flex-1 px-[20rpx] py-[30rpx]" :scroll-with-animation="true">
|
|
||||||
<view class="rounded-[16rpx] bg-white px-[30rpx] py-[40rpx] shadow-[0_4rpx_20rpx_rgba(0,0,0,0.05)]">
|
|
||||||
<view class="mb-[40rpx] text-center">
|
|
||||||
<text class="text-[36rpx] text-[#1a1a1a] font-bold">
|
|
||||||
{{ t('login.privacyPolicy') }}
|
|
||||||
</text>
|
|
||||||
</view>
|
|
||||||
<view class="mb-[40rpx] text-center">
|
|
||||||
<text class="text-[24rpx] text-[#666666]">
|
|
||||||
更新日期:2026年3月10日
|
|
||||||
</text>
|
|
||||||
</view>
|
|
||||||
<view class="mb-[32rpx]">
|
|
||||||
<text class="text-[28rpx] text-[#333333] leading-[1.8]">
|
|
||||||
引言
|
|
||||||
</text>
|
|
||||||
</view>
|
|
||||||
<view class="mb-[24rpx]">
|
|
||||||
<text class="text-[28rpx] text-[#333333] leading-[1.8]">
|
|
||||||
欢迎您使用小智后端服务(以下简称"本服务")。本服务的运营方为本服务的实际部署者和管理者(以下简称"运营者"或"我们")。我们深知个人信息对您的重要性,将尽全力保护您的个人信息安全。
|
|
||||||
</text>
|
|
||||||
</view>
|
|
||||||
<view class="mb-[24rpx]">
|
|
||||||
<text class="text-[28rpx] text-[#333333] leading-[1.8]">
|
|
||||||
请您在使用本服务前,仔细阅读并充分理解本隐私政策的全部内容。一旦您开始使用本服务,即表示您已阅读并同意本隐私政策。
|
|
||||||
</text>
|
|
||||||
</view>
|
|
||||||
<view class="mb-[40rpx]">
|
|
||||||
<text class="text-[28rpx] text-[#333333] leading-[1.8]">
|
|
||||||
本隐私政策适用于您通过智控台(管理后台)、API接口及其他方式使用本服务时,我们对您个人信息的收集、存储、使用、共享、保护等行为。
|
|
||||||
</text>
|
|
||||||
</view>
|
|
||||||
<view class="mb-[32rpx]">
|
|
||||||
<text class="text-[30rpx] text-[#1a1a1a] font-bold">
|
|
||||||
一、我们收集的信息
|
|
||||||
</text>
|
|
||||||
</view>
|
|
||||||
<view class="mb-[24rpx]">
|
|
||||||
<text class="text-[28rpx] text-[#333333] leading-[1.8]">
|
|
||||||
为向您提供服务,我们可能需要收集以下信息:
|
|
||||||
</text>
|
|
||||||
</view>
|
|
||||||
<view class="mb-[16rpx] ml-[20rpx]">
|
|
||||||
<text class="text-[28rpx] text-[#333333] leading-[1.8]">
|
|
||||||
1.1 账号注册信息:当您注册账号时,我们会收集您的手机号码或用户名、密码等信息,用于创建和验证您的账号。
|
|
||||||
</text>
|
|
||||||
</view>
|
|
||||||
<view class="mb-[16rpx] ml-[20rpx]">
|
|
||||||
<text class="text-[28rpx] text-[#333333] leading-[1.8]">
|
|
||||||
1.2 设备信息:当您绑定硬件设备时,我们会收集设备的标识信息(如设备编码、MAC地址等)、设备型号、固件版本等,用于设备管理和服务提供。
|
|
||||||
</text>
|
|
||||||
</view>
|
|
||||||
<view class="mb-[16rpx] ml-[20rpx]">
|
|
||||||
<text class="text-[28rpx] text-[#333333] leading-[1.8]">
|
|
||||||
1.3 智能体配置信息:当您创建和配置智能体时,我们会收集您设定的角色模板、语言模型选择、语音参数配置等信息,用于提供个性化的AI交互服务。
|
|
||||||
</text>
|
|
||||||
</view>
|
|
||||||
<view class="mb-[16rpx] ml-[20rpx]">
|
|
||||||
<text class="text-[28rpx] text-[#333333] leading-[1.8]">
|
|
||||||
1.4 语音交互数据:在您使用语音交互功能时,本服务会通过语音活动检测(VAD)判断您的语音起止状态,并处理您的语音输入数据,将其传输至第三方语音识别(ASR)和语言模型(LLM)服务进行处理,以实现语音交互功能。
|
|
||||||
</text>
|
|
||||||
</view>
|
|
||||||
<view class="mb-[16rpx] ml-[20rpx]">
|
|
||||||
<text class="text-[28rpx] text-[#333333] leading-[1.8]">
|
|
||||||
1.5 图像数据:当您使用视觉模型功能时,我们可能会处理您通过设备摄像头采集的图像数据,并将其传输至第三方视觉模型服务进行分析和理解,用于实现图像识别、场景理解等功能。
|
|
||||||
</text>
|
|
||||||
</view>
|
|
||||||
<view class="mb-[16rpx] ml-[20rpx]">
|
|
||||||
<text class="text-[28rpx] text-[#333333] leading-[1.8]">
|
|
||||||
1.6 对话记忆数据:当您开启记忆功能时,本服务会存储您与智能体的交互历史摘要,用于在后续对话中提供更连贯、个性化的交互体验。
|
|
||||||
</text>
|
|
||||||
</view>
|
|
||||||
<view class="mb-[16rpx] ml-[20rpx]">
|
|
||||||
<text class="text-[28rpx] text-[#333333] leading-[1.8]">
|
|
||||||
1.7 知识库数据:当您使用知识库功能时,我们会收集和存储您上传的文档、文本等知识库内容,用于智能体在对话中进行知识检索和问答。
|
|
||||||
</text>
|
|
||||||
</view>
|
|
||||||
<view class="mb-[16rpx] ml-[20rpx]">
|
|
||||||
<text class="text-[28rpx] text-[#333333] leading-[1.8]">
|
|
||||||
1.8 声纹数据:当您使用声纹识别功能时,我们会收集和存储您的声纹特征样本,用于说话人身份验证和个性化服务。
|
|
||||||
</text>
|
|
||||||
</view>
|
|
||||||
<view class="mb-[16rpx] ml-[20rpx]">
|
|
||||||
<text class="text-[28rpx] text-[#333333] leading-[1.8]">
|
|
||||||
1.9 聊天历史数据:我们会存储您与智能体的对话历史记录,包括文本对话内容、对话时间、交互上下文等信息,用于提供连续性对话体验和历史查询功能。
|
|
||||||
</text>
|
|
||||||
</view>
|
|
||||||
<view class="mb-[16rpx] ml-[20rpx]">
|
|
||||||
<text class="text-[28rpx] text-[#333333] leading-[1.8]">
|
|
||||||
1.10 对话音频数据:在您使用语音交互功能时,我们可能会存储您与智能体交互的音频数据,用于优化语音交互质量和回溯查询。
|
|
||||||
</text>
|
|
||||||
</view>
|
|
||||||
<view class="mb-[16rpx] ml-[20rpx]">
|
|
||||||
<text class="text-[28rpx] text-[#333333] leading-[1.8]">
|
|
||||||
1.11 智能体配置数据:当您配置智能体时,我们会收集您设定的标签、插件配置、上下文提供者设置等信息,用于提供智能体定制化服务。
|
|
||||||
</text>
|
|
||||||
</view>
|
|
||||||
<view class="mb-[16rpx] ml-[20rpx]">
|
|
||||||
<text class="text-[28rpx] text-[#333333] leading-[1.8]">
|
|
||||||
1.12 设备固件数据:当您使用OTA升级功能时,我们会记录设备固件版本、升级历史等信息,用于设备管理和固件追溯。
|
|
||||||
</text>
|
|
||||||
</view>
|
|
||||||
<view class="mb-[16rpx] ml-[20rpx]">
|
|
||||||
<text class="text-[28rpx] text-[#333333] leading-[1.8]">
|
|
||||||
1.13 日志信息:当您使用本服务时,我们会自动收集服务日志信息,包括但不限于访问时间、IP地址、浏览器类型、操作记录等,用于服务运维和安全保障。
|
|
||||||
</text>
|
|
||||||
</view>
|
|
||||||
<view class="mb-[40rpx] ml-[20rpx]">
|
|
||||||
<text class="text-[28rpx] text-[#333333] leading-[1.8]">
|
|
||||||
1.14 验证码信息:当您使用手机号登录时,我们会通过短信服务向您发送验证码,用于身份验证。
|
|
||||||
</text>
|
|
||||||
</view>
|
|
||||||
<view class="mb-[32rpx]">
|
|
||||||
<text class="text-[30rpx] text-[#1a1a1a] font-bold">
|
|
||||||
二、我们如何使用收集的信息
|
|
||||||
</text>
|
|
||||||
</view>
|
|
||||||
<view class="mb-[24rpx]">
|
|
||||||
<text class="text-[28rpx] text-[#333333] leading-[1.8]">
|
|
||||||
我们收集的信息将用于以下目的:
|
|
||||||
</text>
|
|
||||||
</view>
|
|
||||||
<view class="mb-[16rpx] ml-[20rpx]">
|
|
||||||
<text class="text-[28rpx] text-[#333333] leading-[1.8]">
|
|
||||||
(1)提供、维护和改进本服务,包括账号管理、设备管理、智能体配置等核心功能。
|
|
||||||
</text>
|
|
||||||
</view>
|
|
||||||
<view class="mb-[16rpx] ml-[20rpx]">
|
|
||||||
<text class="text-[28rpx] text-[#333333] leading-[1.8]">
|
|
||||||
(2)处理您的语音交互请求,通过语音活动检测(VAD)识别语音输入,调用第三方AI模型服务完成语音识别、意图识别、语义理解和语音合成。
|
|
||||||
</text>
|
|
||||||
</view>
|
|
||||||
<view class="mb-[16rpx] ml-[20rpx]">
|
|
||||||
<text class="text-[28rpx] text-[#333333] leading-[1.8]">
|
|
||||||
(3)处理您的图像数据,调用第三方视觉模型服务完成图像识别和场景理解。
|
|
||||||
</text>
|
|
||||||
</view>
|
|
||||||
<view class="mb-[16rpx] ml-[20rpx]">
|
|
||||||
<text class="text-[28rpx] text-[#333333] leading-[1.8]">
|
|
||||||
(4)存储和管理您的对话记忆数据,以便在后续交互中提供更连贯的服务体验。
|
|
||||||
</text>
|
|
||||||
</view>
|
|
||||||
<view class="mb-[16rpx] ml-[20rpx]">
|
|
||||||
<text class="text-[28rpx] text-[#333333] leading-[1.8]">
|
|
||||||
(5)存储和检索您上传的知识库内容,以便智能体在对话中为您提供更准确的知识问答。
|
|
||||||
</text>
|
|
||||||
</view>
|
|
||||||
<view class="mb-[16rpx] ml-[20rpx]">
|
|
||||||
<text class="text-[28rpx] text-[#333333] leading-[1.8]">
|
|
||||||
(6)保障服务的安全性和稳定性,包括身份验证、安全防护、故障排查等。
|
|
||||||
</text>
|
|
||||||
</view>
|
|
||||||
<view class="mb-[40rpx] ml-[20rpx]">
|
|
||||||
<text class="text-[28rpx] text-[#333333] leading-[1.8]">
|
|
||||||
(7)遵守适用的法律法规和监管要求。
|
|
||||||
</text>
|
|
||||||
</view>
|
|
||||||
<view class="mb-[24rpx]">
|
|
||||||
<text class="text-[28rpx] text-[#333333] leading-[1.8]">
|
|
||||||
我们不会将您的个人信息用于与上述目的无关的其他用途。如需将信息用于本隐私政策未载明的其他目的,我们会事先征得您的同意。
|
|
||||||
</text>
|
|
||||||
</view>
|
|
||||||
<view class="mb-[32rpx]">
|
|
||||||
<text class="text-[30rpx] text-[#1a1a1a] font-bold">
|
|
||||||
三、信息的共享与披露
|
|
||||||
</text>
|
|
||||||
</view>
|
|
||||||
<view class="mb-[24rpx]">
|
|
||||||
<text class="text-[28rpx] text-[#333333] leading-[1.8]">
|
|
||||||
我们不会向第三方出售您的个人信息。仅在以下情形下,我们可能会共享或披露您的信息:
|
|
||||||
</text>
|
|
||||||
</view>
|
|
||||||
<view class="mb-[16rpx] ml-[20rpx]">
|
|
||||||
<text class="text-[28rpx] text-[#333333] leading-[1.8]">
|
|
||||||
3.1 第三方服务调用:为实现语音交互、视觉理解等功能,您的语音数据、图像数据和文本内容可能会被传输至第三方AI服务提供商(如语言模型、语音识别、语音合成、视觉模型服务商)进行处理。我们会选择具备合理安全保障能力的服务商,但请您知悉第三方服务商将按照其自身的隐私政策处理相关数据。
|
|
||||||
</text>
|
|
||||||
</view>
|
|
||||||
<view class="mb-[16rpx] ml-[20rpx]">
|
|
||||||
<text class="text-[28rpx] text-[#333333] leading-[1.8]">
|
|
||||||
3.2 法律要求:根据适用的法律法规、法律程序或政府主管部门的要求,我们可能需要披露您的个人信息。
|
|
||||||
</text>
|
|
||||||
</view>
|
|
||||||
<view class="mb-[16rpx] ml-[20rpx]">
|
|
||||||
<text class="text-[28rpx] text-[#333333] leading-[1.8]">
|
|
||||||
3.3 安全保障:为保护运营者、其他用户或公众的权益、财产或安全免遭损害,在合理必要的范围内使用或披露个人信息。
|
|
||||||
</text>
|
|
||||||
</view>
|
|
||||||
<view class="mb-[40rpx] ml-[20rpx]">
|
|
||||||
<text class="text-[28rpx] text-[#333333] leading-[1.8]">
|
|
||||||
3.4 征得同意:在获得您明确同意的前提下,我们可能会与第三方共享您的个人信息。
|
|
||||||
</text>
|
|
||||||
</view>
|
|
||||||
<view class="mb-[32rpx]">
|
|
||||||
<text class="text-[30rpx] text-[#1a1a1a] font-bold">
|
|
||||||
四、信息的存储与保护
|
|
||||||
</text>
|
|
||||||
</view>
|
|
||||||
<view class="mb-[16rpx] ml-[20rpx]">
|
|
||||||
<text class="text-[28rpx] text-[#333333] leading-[1.8]">
|
|
||||||
4.1 存储地点:您的个人信息将存储在运营者部署本服务的服务器上,包括但不限于数据库(MySQL/PostgreSQL)和缓存服务(Redis)。
|
|
||||||
</text>
|
|
||||||
</view>
|
|
||||||
<view class="mb-[16rpx] ml-[20rpx]">
|
|
||||||
<text class="text-[28rpx] text-[#333333] leading-[1.8]">
|
|
||||||
4.2 存储期限:我们将在为您提供服务所必需的期限内保留您的个人信息。当您注销账号后,我们将在合理时间内删除或匿名化处理您的个人信息,法律法规另有规定的除外。
|
|
||||||
</text>
|
|
||||||
</view>
|
|
||||||
<view class="mb-[16rpx] ml-[20rpx]">
|
|
||||||
<text class="text-[28rpx] text-[#333333] leading-[1.8]">
|
|
||||||
4.3 安全措施:我们采取合理的技术和管理措施保护您的个人信息安全,包括但不限于数据加密、访问控制、安全审计等。但请您理解,互联网并非绝对安全的环境,我们无法保证信息传输和存储的绝对安全性。
|
|
||||||
</text>
|
|
||||||
</view>
|
|
||||||
<view class="mb-[16rpx] ml-[20rpx]">
|
|
||||||
<text class="text-[28rpx] text-[#333333] leading-[1.8]">
|
|
||||||
4.4 安全事件处理:如发生个人信息安全事件,我们将按照法律法规的要求,及时向您告知安全事件的基本情况、可能的影响、已采取或将要采取的处置措施等。
|
|
||||||
</text>
|
|
||||||
</view>
|
|
||||||
<view class="mb-[16rpx] ml-[20rpx]">
|
|
||||||
<text class="text-[28rpx] text-[#333333] leading-[1.8]">
|
|
||||||
4.5 开源项目特别说明:本服务为开源项目,存在两种运营模式:
|
|
||||||
</text>
|
|
||||||
</view>
|
|
||||||
<view class="mb-[8rpx] ml-[40rpx]">
|
|
||||||
<text class="text-[28rpx] text-[#333333] leading-[1.8]">
|
|
||||||
(1)自行部署:如您自行部署本服务,运营者仅为代码提供方,实际的数据存储和处理由您自行负责。
|
|
||||||
</text>
|
|
||||||
</view>
|
|
||||||
<view class="mb-[8rpx] ml-[40rpx]">
|
|
||||||
<text class="text-[28rpx] text-[#333333] leading-[1.8]">
|
|
||||||
(2)测试平台:如您使用运营者部署的测试平台,您的数据将由运营人员负责管理和保护。
|
|
||||||
</text>
|
|
||||||
</view>
|
|
||||||
<view class="mb-[16rpx] ml-[20rpx]">
|
|
||||||
<text class="text-[28rpx] text-[#333333] leading-[1.8]">
|
|
||||||
4.6 数据跨境传输:本服务在提供智能交互功能时,可能需要调用境外第三方AI服务提供商的接口。
|
|
||||||
</text>
|
|
||||||
</view>
|
|
||||||
<view class="mb-[32rpx]">
|
|
||||||
<text class="text-[30rpx] text-[#1a1a1a] font-bold">
|
|
||||||
五、您的权利
|
|
||||||
</text>
|
|
||||||
</view>
|
|
||||||
<view class="mb-[16rpx] ml-[20rpx]">
|
|
||||||
<text class="text-[28rpx] text-[#333333] leading-[1.8]">
|
|
||||||
5.1 查询与访问:您可通过智控台查看和管理您的账号信息、设备信息、智能体配置等个人信息。
|
|
||||||
</text>
|
|
||||||
</view>
|
|
||||||
<view class="mb-[16rpx] ml-[20rpx]">
|
|
||||||
<text class="text-[28rpx] text-[#333333] leading-[1.8]">
|
|
||||||
5.2 更正与修改:当您发现个人信息有误时,您可通过智控台自行更正,或联系运营者协助处理。
|
|
||||||
</text>
|
|
||||||
</view>
|
|
||||||
<view class="mb-[16rpx] ml-[20rpx]">
|
|
||||||
<text class="text-[28rpx] text-[#333333] leading-[1.8]">
|
|
||||||
5.3 删除:在以下情形下,您可请求我们删除您的个人信息:(1)处理目的已实现、无法实现或不再必要;(2)我们违反法律法规或与您的约定收集、使用个人信息;(3)注销账号。
|
|
||||||
</text>
|
|
||||||
</view>
|
|
||||||
<view class="mb-[16rpx] ml-[20rpx]">
|
|
||||||
<text class="text-[28rpx] text-[#333333] leading-[1.8]">
|
|
||||||
5.4 账号注销:您可通过智控台的账号设置功能注销账号,或联系运营者进行处理。
|
|
||||||
</text>
|
|
||||||
</view>
|
|
||||||
<view class="mb-[40rpx] ml-[20rpx]">
|
|
||||||
<text class="text-[28rpx] text-[#333333] leading-[1.8]">
|
|
||||||
5.5 撤回同意:您可随时撤回您此前向我们作出的同意授权。
|
|
||||||
</text>
|
|
||||||
</view>
|
|
||||||
<view class="mb-[32rpx]">
|
|
||||||
<text class="text-[30rpx] text-[#1a1a1a] font-bold">
|
|
||||||
六、未成年人信息保护
|
|
||||||
</text>
|
|
||||||
</view>
|
|
||||||
<view class="mb-[16rpx] ml-[20rpx]">
|
|
||||||
<text class="text-[28rpx] text-[#333333] leading-[1.8]">
|
|
||||||
6.1 我们高度重视未成年人个人信息的保护。若您是未满18周岁的未成年人,请在监护人的指导和同意下使用本服务。
|
|
||||||
</text>
|
|
||||||
</view>
|
|
||||||
<view class="mb-[16rpx] ml-[20rpx]">
|
|
||||||
<text class="text-[28rpx] text-[#333333] leading-[1.8]">
|
|
||||||
6.2 如果监护人发现未成年人未经其同意向我们提供了个人信息,请联系运营者,我们将尽快删除相关信息。
|
|
||||||
</text>
|
|
||||||
</view>
|
|
||||||
<view class="mb-[40rpx] ml-[20rpx]">
|
|
||||||
<text class="text-[28rpx] text-[#333333] leading-[1.8]">
|
|
||||||
6.3 对于经监护人同意使用本服务的未成年人,我们将按照法律法规的规定,给予其个人信息更严格的保护。
|
|
||||||
</text>
|
|
||||||
</view>
|
|
||||||
<view class="mb-[32rpx]">
|
|
||||||
<text class="text-[30rpx] text-[#1a1a1a] font-bold">
|
|
||||||
七、第三方服务说明
|
|
||||||
</text>
|
|
||||||
</view>
|
|
||||||
<view class="mb-[16rpx] ml-[20rpx]">
|
|
||||||
<text class="text-[28rpx] text-[#333333] leading-[1.8]">
|
|
||||||
7.1 本服务在提供智能交互功能时,需要调用第三方服务,包括但不限于:语音活动检测服务(VAD)、语音识别服务(ASR)、大语言模型服务(LLM)、语音合成服务(TTS)、视觉模型服务、短信验证码服务、MQTT消息代理服务、数据库服务。
|
|
||||||
</text>
|
|
||||||
</view>
|
|
||||||
<view class="mb-[40rpx] ml-[20rpx]">
|
|
||||||
<text class="text-[28rpx] text-[#333333] leading-[1.8]">
|
|
||||||
7.2 上述第三方服务提供商将按照其各自的隐私政策对数据进行处理。我们建议您在使用本服务前,了解相关第三方服务商的隐私政策。
|
|
||||||
</text>
|
|
||||||
</view>
|
|
||||||
<view class="mb-[32rpx]">
|
|
||||||
<text class="text-[30rpx] text-[#1a1a1a] font-bold">
|
|
||||||
八、Cookie及类似技术的使用
|
|
||||||
</text>
|
|
||||||
</view>
|
|
||||||
<view class="mb-[16rpx] ml-[20rpx]">
|
|
||||||
<text class="text-[28rpx] text-[#333333] leading-[1.8]">
|
|
||||||
8.1 本服务可能使用Cookie及类似技术来保存您的登录状态、记录您的偏好设置等,以便为您提供更好的使用体验。
|
|
||||||
</text>
|
|
||||||
</view>
|
|
||||||
<view class="mb-[40rpx] ml-[20rpx]">
|
|
||||||
<text class="text-[28rpx] text-[#333333] leading-[1.8]">
|
|
||||||
8.2 您可以通过浏览器设置管理Cookie。但请注意,如果禁用Cookie,可能会影响本服务的部分功能。
|
|
||||||
</text>
|
|
||||||
</view>
|
|
||||||
<view class="mb-[32rpx]">
|
|
||||||
<text class="text-[30rpx] text-[#1a1a1a] font-bold">
|
|
||||||
九、隐私政策的变更
|
|
||||||
</text>
|
|
||||||
</view>
|
|
||||||
<view class="mb-[16rpx] ml-[20rpx]">
|
|
||||||
<text class="text-[28rpx] text-[#333333] leading-[1.8]">
|
|
||||||
9.1 我们可能会根据业务调整、法律法规变化等原因对本隐私政策进行修订。修订后的隐私政策将通过本平台公告等方式予以发布。
|
|
||||||
</text>
|
|
||||||
</view>
|
|
||||||
<view class="mb-[40rpx] ml-[20rpx]">
|
|
||||||
<text class="text-[28rpx] text-[#333333] leading-[1.8]">
|
|
||||||
9.2 如您在隐私政策修订后继续使用本服务,则视为您已接受修订后的隐私政策。
|
|
||||||
</text>
|
|
||||||
</view>
|
|
||||||
<view class="mb-[32rpx]">
|
|
||||||
<text class="text-[30rpx] text-[#1a1a1a] font-bold">
|
|
||||||
十、信息安全提示
|
|
||||||
</text>
|
|
||||||
</view>
|
|
||||||
<view class="mb-[16rpx] ml-[20rpx]">
|
|
||||||
<text class="text-[28rpx] text-[#333333] leading-[1.8]">
|
|
||||||
10.1 请勿在与AI的语音或文字交互中透露您的财产账户、银行卡号、信用卡号、密码、身份证号等敏感个人信息,否则由此带来的损失由您自行承担。
|
|
||||||
</text>
|
|
||||||
</view>
|
|
||||||
<view class="mb-[16rpx] ml-[20rpx]">
|
|
||||||
<text class="text-[28rpx] text-[#333333] leading-[1.8]">
|
|
||||||
10.2 请妥善保管您的账号和密码,不要将账号信息告知他人或与他人共享账号。
|
|
||||||
</text>
|
|
||||||
</view>
|
|
||||||
<view class="mb-[40rpx] ml-[20rpx]">
|
|
||||||
<text class="text-[28rpx] text-[#333333] leading-[1.8]">
|
|
||||||
10.3 如您发现个人信息可能被泄露,请及时联系运营者采取措施。
|
|
||||||
</text>
|
|
||||||
</view>
|
|
||||||
<view class="mb-[32rpx]">
|
|
||||||
<text class="text-[30rpx] text-[#1a1a1a] font-bold">
|
|
||||||
十一、适用法律
|
|
||||||
</text>
|
|
||||||
</view>
|
|
||||||
<view class="mb-[16rpx] ml-[20rpx]">
|
|
||||||
<text class="text-[28rpx] text-[#333333] leading-[1.8]">
|
|
||||||
11.1 本隐私政策的制定、解释、执行及争议解决均适用中华人民共和国法律法规(为本隐私政策之目的,不包括港澳台地区法律)。
|
|
||||||
</text>
|
|
||||||
</view>
|
|
||||||
<view class="mb-[40rpx] ml-[20rpx]">
|
|
||||||
<text class="text-[28rpx] text-[#333333] leading-[1.8]">
|
|
||||||
11.2 如本隐私政策的任何条款与中华人民共和国现行法律法规相抵触,以法律法规的规定为准,其余条款仍然有效。
|
|
||||||
</text>
|
|
||||||
</view>
|
|
||||||
</view>
|
|
||||||
</scroll-view>
|
|
||||||
</view>
|
|
||||||
</template>
|
|
||||||
|
|
@ -1,542 +0,0 @@
|
||||||
<route lang="jsonc" type="page">
|
|
||||||
{
|
|
||||||
"layout": "default",
|
|
||||||
"style": {
|
|
||||||
"navigationStyle": "custom",
|
|
||||||
"navigationBarTitleText": "用户协议"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
</route>
|
|
||||||
|
|
||||||
<script lang="ts" setup>
|
|
||||||
import { t } from '@/i18n'
|
|
||||||
|
|
||||||
function goBack() {
|
|
||||||
uni.navigateBack()
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<template>
|
|
||||||
<view class="h-screen flex flex-col bg-[#f5f8fd]">
|
|
||||||
<wd-navbar
|
|
||||||
:title="t('login.userAgreement')"
|
|
||||||
safe-area-inset-top
|
|
||||||
left-arrow
|
|
||||||
:bordered="false"
|
|
||||||
@click-left="goBack"
|
|
||||||
>
|
|
||||||
<template #left>
|
|
||||||
<wd-icon name="arrow-left" size="18" />
|
|
||||||
</template>
|
|
||||||
</wd-navbar>
|
|
||||||
<scroll-view scroll-y class="box-border flex-1 px-[30rpx] py-[30rpx]">
|
|
||||||
<view class="rounded-[16rpx] bg-white px-[30rpx] py-[40rpx] shadow-[0_4rpx_20rpx_rgba(0,0,0,0.05)]">
|
|
||||||
<view class="mb-[40rpx] text-center">
|
|
||||||
<text class="text-[36rpx] text-[#1a1a1a] font-bold">
|
|
||||||
{{ t('login.userAgreement') }}
|
|
||||||
</text>
|
|
||||||
</view>
|
|
||||||
<view class="mb-[40rpx] text-center">
|
|
||||||
<text class="text-[24rpx] text-[#666666]">
|
|
||||||
更新日期:2026年3月10日
|
|
||||||
</text>
|
|
||||||
</view>
|
|
||||||
<view class="mb-[32rpx]">
|
|
||||||
<text class="text-[28rpx] text-[#333333] font-semibold">
|
|
||||||
提示条款
|
|
||||||
</text>
|
|
||||||
</view>
|
|
||||||
<view class="mb-[24rpx] ml-[20rpx]">
|
|
||||||
<text class="text-[28rpx] text-[#333333] leading-[1.8]">
|
|
||||||
欢迎您使用小智后端服务(以下简称"本服务")。本服务旨在为小智AI硬件设备提供后端服务支持,包括但不限于智能语音交互、视觉理解、意图识别、对话记忆、知识库问答、设备管理、智能体管理等功能。本服务的运营方为本服务的实际部署者和管理者(以下简称"运营者"或"我们")。
|
|
||||||
</text>
|
|
||||||
</view>
|
|
||||||
<view class="mb-[24rpx] ml-[20rpx]">
|
|
||||||
<text class="text-[28rpx] text-[#333333] leading-[1.8]">
|
|
||||||
在您注册、登录或使用本服务之前,请您务必审慎阅读、充分理解本协议各条款内容,特别是以加粗形式提示您注意的可能与您利益有重大关系的条款,包括但不限于免责声明、责任限制等条款。
|
|
||||||
</text>
|
|
||||||
</view>
|
|
||||||
<view class="mb-[24rpx] ml-[20rpx]">
|
|
||||||
<text class="text-[28rpx] text-[#333333] leading-[1.8]">
|
|
||||||
当您按照页面提示完成注册、登录或以其他方式使用本服务时,即表示您已充分阅读、理解并接受本协议的全部内容。如果您不同意本协议或其中任何条款,请立即停止使用本服务。
|
|
||||||
</text>
|
|
||||||
</view>
|
|
||||||
<view class="mb-[40rpx] ml-[20rpx]">
|
|
||||||
<text class="text-[28rpx] text-[#333333] leading-[1.8]">
|
|
||||||
本协议可能根据实际情况进行更新和修订,修订后的协议将通过本平台公告等方式予以公示。修订后的协议自公示之日起生效,如您在协议修订后继续使用本服务,则视为您已接受修订后的协议。
|
|
||||||
</text>
|
|
||||||
</view>
|
|
||||||
|
|
||||||
<view class="mb-[32rpx]">
|
|
||||||
<text class="text-[28rpx] text-[#333333] font-semibold">
|
|
||||||
一、定义
|
|
||||||
</text>
|
|
||||||
</view>
|
|
||||||
<view class="mb-[24rpx] ml-[20rpx]">
|
|
||||||
<text class="text-[28rpx] text-[#333333] leading-[1.8]">
|
|
||||||
小智后端服务:指小智后端服务及其部署运行的后端服务系统,包括但不限于智控台(管理后台)、API接口、WebSocket通信服务等。
|
|
||||||
</text>
|
|
||||||
</view>
|
|
||||||
<view class="mb-[24rpx] ml-[20rpx]">
|
|
||||||
<text class="text-[28rpx] text-[#333333] leading-[1.8]">
|
|
||||||
智控台:指本服务提供的Web管理界面,用于设备管理、智能体配置、用户管理等功能。
|
|
||||||
</text>
|
|
||||||
</view>
|
|
||||||
<view class="mb-[24rpx] ml-[20rpx]">
|
|
||||||
<text class="text-[28rpx] text-[#333333] leading-[1.8]">
|
|
||||||
用户:指通过注册或其他方式使用本服务的自然人、法人或其他组织,以下简称"您"。
|
|
||||||
</text>
|
|
||||||
</view>
|
|
||||||
<view class="mb-[24rpx] ml-[20rpx]">
|
|
||||||
<text class="text-[28rpx] text-[#333333] leading-[1.8]">
|
|
||||||
智能体:指在本服务中创建和配置的AI角色,包含语言模型、语音识别、语音合成、视觉理解、意图识别、对话记忆、知识库等能力的集合。
|
|
||||||
</text>
|
|
||||||
</view>
|
|
||||||
<view class="mb-[40rpx] ml-[20rpx]">
|
|
||||||
<text class="text-[28rpx] text-[#333333] leading-[1.8]">
|
|
||||||
设备:指通过本服务进行连接和管理的ESP32等硬件设备。
|
|
||||||
</text>
|
|
||||||
</view>
|
|
||||||
|
|
||||||
<view class="mb-[32rpx]">
|
|
||||||
<text class="text-[28rpx] text-[#333333] font-semibold">
|
|
||||||
二、协议范围
|
|
||||||
</text>
|
|
||||||
</view>
|
|
||||||
<view class="mb-[24rpx] ml-[20rpx]">
|
|
||||||
<text class="text-[28rpx] text-[#333333] leading-[1.8]">
|
|
||||||
本协议是您与运营者之间关于使用本服务的法律协议。本协议适用于您通过智控台或其他方式使用本服务的全部行为。
|
|
||||||
</text>
|
|
||||||
</view>
|
|
||||||
<view class="mb-[40rpx] ml-[20rpx]">
|
|
||||||
<text class="text-[28rpx] text-[#333333] leading-[1.8]">
|
|
||||||
本服务的源代码遵循相应的开源许可证。本协议约束您对本服务的使用行为,不影响开源许可证本身赋予您的权利。
|
|
||||||
</text>
|
|
||||||
</view>
|
|
||||||
|
|
||||||
<view class="mb-[32rpx]">
|
|
||||||
<text class="text-[28rpx] text-[#333333] font-semibold">
|
|
||||||
三、账号注册与使用
|
|
||||||
</text>
|
|
||||||
</view>
|
|
||||||
<view class="mb-[24rpx] ml-[20rpx]">
|
|
||||||
<text class="text-[28rpx] text-[#333333] leading-[1.8]">
|
|
||||||
3.1 用户资格:您确认,在使用本服务前,您应当具备中华人民共和国法律规定的与您行为相适应的民事行为能力。若您为未成年人,应在法定监护人的陪同和指导下使用本服务。
|
|
||||||
</text>
|
|
||||||
</view>
|
|
||||||
<view class="mb-[24rpx] ml-[20rpx]">
|
|
||||||
<text class="text-[28rpx] text-[#333333] leading-[1.8]">
|
|
||||||
3.2 账号注册:您可通过手机号验证码或用户名密码等方式注册和登录本服务。您应当提供真实、准确、完整的注册信息,并及时更新。
|
|
||||||
</text>
|
|
||||||
</view>
|
|
||||||
<view class="mb-[24rpx] ml-[20rpx]">
|
|
||||||
<text class="text-[28rpx] text-[#333333] leading-[1.8]">
|
|
||||||
3.3 账号安全:您应妥善保管您的账号和密码,因您的原因导致账号泄露或被他人冒用所产生的一切后果,由您自行承担。如发现账号存在安全隐患,请立即联系运营者。
|
|
||||||
</text>
|
|
||||||
</view>
|
|
||||||
<view class="mb-[24rpx] ml-[20rpx]">
|
|
||||||
<text class="text-[28rpx] text-[#333333] leading-[1.8]">
|
|
||||||
3.4 账号使用限制:您的账号仅限您本人使用,未经运营者同意,不得以任何方式将账号转让、出租或借给第三方使用。
|
|
||||||
</text>
|
|
||||||
</view>
|
|
||||||
<view class="mb-[40rpx] ml-[20rpx]">
|
|
||||||
<text class="text-[28rpx] text-[#333333] leading-[1.8]">
|
|
||||||
3.5 账号注销:如您需要注销账号,可通过智控台的账号设置功能进行操作,或联系运营者进行处理。账号注销后,相关数据将被删除且无法恢复,请谨慎操作。
|
|
||||||
</text>
|
|
||||||
</view>
|
|
||||||
|
|
||||||
<view class="mb-[32rpx]">
|
|
||||||
<text class="text-[28rpx] text-[#333333] font-semibold">
|
|
||||||
四、服务内容
|
|
||||||
</text>
|
|
||||||
</view>
|
|
||||||
<view class="mb-[24rpx] ml-[20rpx]">
|
|
||||||
<text class="text-[28rpx] text-[#333333] leading-[1.8]">
|
|
||||||
4.1 服务概述:本服务依托人工智能技术,通过API接口调用第三方生成式人工智能模型,为连接的硬件设备提供智能交互服务,包括但不限于语音活动检测(VAD)、语音识别(ASR)、语义理解(LLM)、语音合成(TTS)、视觉理解(VLLM)、意图识别(Intent)、对话记忆(Memory)、知识库(RAG)等。
|
|
||||||
</text>
|
|
||||||
</view>
|
|
||||||
<view class="mb-[24rpx] ml-[20rpx]">
|
|
||||||
<text class="text-[28rpx] text-[#333333] leading-[1.8]">
|
|
||||||
4.2 智能体管理:您可通过智控台创建和配置智能体,包括设定角色模板、选择语言模型、配置语音参数、设置意图识别规则、管理知识库、开启对话记忆、配置智能体插件等。智能体的设定内容不得违反国家法律法规。
|
|
||||||
</text>
|
|
||||||
</view>
|
|
||||||
<view class="mb-[24rpx] ml-[20rpx]">
|
|
||||||
<text class="text-[28rpx] text-[#333333] leading-[1.8]">
|
|
||||||
4.3 设备管理:您可通过智控台绑定和管理您的硬件设备,进行设备配置、固件更新、OTA远程升级等操作。您应确保所管理的设备为您合法拥有或已获得授权。
|
|
||||||
</text>
|
|
||||||
</view>
|
|
||||||
<view class="mb-[24rpx] ml-[20rpx]">
|
|
||||||
<text class="text-[28rpx] text-[#333333] leading-[1.8]">
|
|
||||||
4.4 视觉理解:本服务支持通过设备摄像头采集图像,调用第三方视觉模型进行图像识别和场景理解。您应确保采集图像的行为符合相关法律法规,不得侵犯他人隐私。
|
|
||||||
</text>
|
|
||||||
</view>
|
|
||||||
<view class="mb-[24rpx] ml-[20rpx]">
|
|
||||||
<text class="text-[28rpx] text-[#333333] leading-[1.8]">
|
|
||||||
4.5 意图识别:本服务可通过意图识别功能理解用户指令的意图,并据此触发相应的操作或服务,如控制智能设备、查询信息等。
|
|
||||||
</text>
|
|
||||||
</view>
|
|
||||||
<view class="mb-[24rpx] ml-[20rpx]">
|
|
||||||
<text class="text-[28rpx] text-[#333333] leading-[1.8]">
|
|
||||||
4.6 对话记忆:本服务可记录和存储您与智能体的交互历史摘要,以便在后续对话中提供更连贯、个性化的交互体验。您可在智控台管理或清除记忆数据。
|
|
||||||
</text>
|
|
||||||
</view>
|
|
||||||
<view class="mb-[24rpx] ml-[20rpx]">
|
|
||||||
<text class="text-[28rpx] text-[#333333] leading-[1.8]">
|
|
||||||
4.7 知识库:本服务支持您上传文档、文本等内容构建知识库,智能体可在对话中检索知识库内容为您提供问答服务。您应确保上传的知识库内容不侵犯第三方知识产权,且不包含违反法律法规的内容。
|
|
||||||
</text>
|
|
||||||
</view>
|
|
||||||
<view class="mb-[24rpx] ml-[20rpx]">
|
|
||||||
<text class="text-[28rpx] text-[#333333] leading-[1.8]">
|
|
||||||
4.8 声纹识别:本服务支持声纹识别功能,您可注册声纹样本以实现说话人身份验证和个性化服务。声纹数据将用于身份验证目的。
|
|
||||||
</text>
|
|
||||||
</view>
|
|
||||||
<view class="mb-[24rpx] ml-[20rpx]">
|
|
||||||
<text class="text-[28rpx] text-[#333333] leading-[1.8]">
|
|
||||||
4.9 语音克隆:本服务支持语音克隆功能,您可通过提供音频样本克隆自定义音色。克隆音色仅供您本人使用,不得用于仿冒他人或从事违法违规活动。
|
|
||||||
</text>
|
|
||||||
</view>
|
|
||||||
<view class="mb-[24rpx] ml-[20rpx]">
|
|
||||||
<text class="text-[28rpx] text-[#333333] leading-[1.8]">
|
|
||||||
4.10 MCP接入点:本服务支持MCP(Model Context Protocol)协议,可作为MCP Server向外部提供工具调用能力,也可作为MCP Client调用外部MCP服务,实现与外部系统的标准化集成。
|
|
||||||
</text>
|
|
||||||
</view>
|
|
||||||
<view class="mb-[24rpx] ml-[20rpx]">
|
|
||||||
<text class="text-[28rpx] text-[#333333] leading-[1.8]">
|
|
||||||
4.11 上下文提供者:本服务支持上下文提供者(Context Provider)功能,可从外部数据源获取实时信息,如天气、新闻、股票等,为智能体提供更丰富的知识来源。
|
|
||||||
</text>
|
|
||||||
</view>
|
|
||||||
<view class="mb-[24rpx] ml-[20rpx]">
|
|
||||||
<text class="text-[28rpx] text-[#333333] leading-[1.8]">
|
|
||||||
4.12 MQTT协议:本服务支持MQTT(Message Queuing Telemetry Transport)协议,用于与物联网设备之间的消息通信。您可通过MQTT协议实现设备控制指令下发、设备状态监控等功能。
|
|
||||||
</text>
|
|
||||||
</view>
|
|
||||||
<view class="mb-[24rpx] ml-[20rpx]">
|
|
||||||
<text class="text-[28rpx] text-[#333333] leading-[1.8]">
|
|
||||||
4.13 服务说明:本服务所依赖的第三方AI模型生成的对话、答复内容仅供参考,不构成任何专业建议。您不得将输出内容作为医疗、法律、金融等领域的专业建议。您根据输出内容所作的任何判断或决策,由您自行承担全部责任。
|
|
||||||
</text>
|
|
||||||
</view>
|
|
||||||
<view class="mb-[24rpx] ml-[20rpx]">
|
|
||||||
<text class="text-[28rpx] text-[#333333] leading-[1.8]">
|
|
||||||
4.14 服务费用:本服务为免费开源项目,不向用户收取任何使用费用,仅提供调用第三方服务的平台能力,不涉及任何付费功能或增值服务。
|
|
||||||
</text>
|
|
||||||
</view>
|
|
||||||
<view class="mb-[24rpx] ml-[40rpx]">
|
|
||||||
<text class="text-[28rpx] text-[#333333] leading-[1.8]">
|
|
||||||
本服务支持多种AI服务提供商,不同提供商的收费模式如下:
|
|
||||||
</text>
|
|
||||||
</view>
|
|
||||||
<view class="mb-[16rpx] ml-[60rpx]">
|
|
||||||
<text class="text-[28rpx] text-[#333333] leading-[1.8]">
|
|
||||||
(1)免费服务:部分服务商提供免费额度或完全免费的服务,如智谱AI(glm-4-flash等免费模型)、微软EdgeTTS语音合成等。
|
|
||||||
</text>
|
|
||||||
</view>
|
|
||||||
<view class="mb-[16rpx] ml-[60rpx]">
|
|
||||||
<text class="text-[28rpx] text-[#333333] leading-[1.8]">
|
|
||||||
(2)按量付费服务:部分服务商按API调用量计费,如OpenAI、阿里云智能语音、百度文心、讯飞等。您需要自行向第三方服务商支付相应费用,该等费用与本服务无关。
|
|
||||||
</text>
|
|
||||||
</view>
|
|
||||||
<view class="mb-[40rpx] ml-[60rpx]">
|
|
||||||
<text class="text-[28rpx] text-[#333333] leading-[1.8]">
|
|
||||||
(3)本地部署方案:本服务支持完全本地部署的AI方案,如FunASR语音识别、FishSpeech语音合成、Ollama本地大模型等。本地部署无需网络费用和API调用费用,但需要本地具备足够的计算资源。
|
|
||||||
</text>
|
|
||||||
</view>
|
|
||||||
<view class="mb-[24rpx] ml-[20rpx]">
|
|
||||||
<text class="text-[28rpx] text-[#333333] leading-[1.8]">
|
|
||||||
4.15 服务变更:运营者保留根据实际情况对服务内容进行调整、升级或终止的权利,并将尽可能提前予以通知。
|
|
||||||
</text>
|
|
||||||
</view>
|
|
||||||
|
|
||||||
<view class="mb-[32rpx]">
|
|
||||||
<text class="text-[28rpx] text-[#333333] font-semibold">
|
|
||||||
五、用户行为规范
|
|
||||||
</text>
|
|
||||||
</view>
|
|
||||||
<view class="mb-[24rpx] ml-[20rpx]">
|
|
||||||
<text class="text-[28rpx] text-[#333333] leading-[1.8]">
|
|
||||||
5.1 合法使用:您在使用本服务时,应遵守中华人民共和国的法律法规及相关国际条约,不得利用本服务从事任何违法违规活动。
|
|
||||||
</text>
|
|
||||||
</view>
|
|
||||||
<view class="mb-[24rpx] ml-[20rpx]">
|
|
||||||
<text class="text-[28rpx] text-[#333333] leading-[1.8]">
|
|
||||||
5.2 禁止行为:您承诺在使用本服务时不得实施以下行为:
|
|
||||||
</text>
|
|
||||||
</view>
|
|
||||||
<view class="mb-[16rpx] ml-[40rpx]">
|
|
||||||
<text class="text-[28rpx] text-[#333333] leading-[1.8]">
|
|
||||||
(1)发布、传输、存储危害国家安全、社会稳定的内容,包括但不限于涉及颠覆国家政权、损害国家荣誉和利益、煽动民族仇恨等内容。
|
|
||||||
</text>
|
|
||||||
</view>
|
|
||||||
<view class="mb-[16rpx] ml-[40rpx]">
|
|
||||||
<text class="text-[28rpx] text-[#333333] leading-[1.8]">
|
|
||||||
(2)发布、传输、存储侵犯他人合法权益的内容,包括但不限于侵犯知识产权、隐私权、名誉权等。
|
|
||||||
</text>
|
|
||||||
</view>
|
|
||||||
<view class="mb-[16rpx] ml-[40rpx]">
|
|
||||||
<text class="text-[28rpx] text-[#333333] leading-[1.8]">
|
|
||||||
(3)发布、传输、存储淫秽、色情、暴力、恐怖或教唆犯罪的内容。
|
|
||||||
</text>
|
|
||||||
</view>
|
|
||||||
<view class="mb-[16rpx] ml-[40rpx]">
|
|
||||||
<text class="text-[28rpx] text-[#333333] leading-[1.8]">
|
|
||||||
(4)发布虚假信息、散布谣言或从事欺诈行为。
|
|
||||||
</text>
|
|
||||||
</view>
|
|
||||||
<view class="mb-[16rpx] ml-[40rpx]">
|
|
||||||
<text class="text-[28rpx] text-[#333333] leading-[1.8]">
|
|
||||||
(5)以任何方式干扰本服务的正常运行,包括但不限于攻击服务器、传播恶意程序、恶意消耗系统资源等。
|
|
||||||
</text>
|
|
||||||
</view>
|
|
||||||
<view class="mb-[16rpx] ml-[40rpx]">
|
|
||||||
<text class="text-[28rpx] text-[#333333] leading-[1.8]">
|
|
||||||
(6)未经授权对本服务进行反向工程、反编译或其他试图获取系统源代码的行为(本条不限制您依据开源许可证对开源代码的合法使用)。
|
|
||||||
</text>
|
|
||||||
</view>
|
|
||||||
<view class="mb-[16rpx] ml-[40rpx]">
|
|
||||||
<text class="text-[28rpx] text-[#333333] leading-[1.8]">
|
|
||||||
(7)利用本服务进行自动化批量操作,恶意消耗API调用配额或其他系统资源。
|
|
||||||
</text>
|
|
||||||
</view>
|
|
||||||
<view class="mb-[16rpx] ml-[40rpx]">
|
|
||||||
<text class="text-[28rpx] text-[#333333] leading-[1.8]">
|
|
||||||
(8)在智能体设定中输入违反法律法规或社会公序良俗的内容。
|
|
||||||
</text>
|
|
||||||
</view>
|
|
||||||
<view class="mb-[16rpx] ml-[40rpx]">
|
|
||||||
<text class="text-[28rpx] text-[#333333] leading-[1.8]">
|
|
||||||
(9)利用本服务伤害或企图伤害未成年人。
|
|
||||||
</text>
|
|
||||||
</view>
|
|
||||||
<view class="mb-[40rpx] ml-[40rpx]">
|
|
||||||
<text class="text-[28rpx] text-[#333333] leading-[1.8]">
|
|
||||||
(10)其他违反法律法规、本协议约定或可能损害运营者及第三方合法权益的行为。
|
|
||||||
</text>
|
|
||||||
</view>
|
|
||||||
<view class="mb-[24rpx] ml-[20rpx]">
|
|
||||||
<text class="text-[28rpx] text-[#333333] leading-[1.8]">
|
|
||||||
5.3 违规处理:如您违反上述行为规范,运营者有权视情节严重程度采取警告、限制功能、暂停服务、封禁账号等措施,并保留追究法律责任的权利。
|
|
||||||
</text>
|
|
||||||
</view>
|
|
||||||
|
|
||||||
<view class="mb-[32rpx]">
|
|
||||||
<text class="text-[28rpx] text-[#333333] font-semibold">
|
|
||||||
六、知识产权
|
|
||||||
</text>
|
|
||||||
</view>
|
|
||||||
<view class="mb-[24rpx] ml-[20rpx]">
|
|
||||||
<text class="text-[28rpx] text-[#333333] leading-[1.8]">
|
|
||||||
6.1 开源许可:本服务为开源项目,其源代码遵循相应的开源许可证。您可以在遵守该许可证条款的前提下使用相关源代码。
|
|
||||||
</text>
|
|
||||||
</view>
|
|
||||||
<view class="mb-[24rpx] ml-[20rpx]">
|
|
||||||
<text class="text-[28rpx] text-[#333333] leading-[1.8]">
|
|
||||||
6.2 服务内容权属:除开源代码外,本服务中的界面设计、图标、文案及其他运营者独立创作的内容,其知识产权归运营者所有。
|
|
||||||
</text>
|
|
||||||
</view>
|
|
||||||
<view class="mb-[24rpx] ml-[20rpx]">
|
|
||||||
<text class="text-[28rpx] text-[#333333] leading-[1.8]">
|
|
||||||
6.3 用户内容:您通过本服务输入、上传或生成的内容,其知识产权归属依照相关法律法规确定。您授予运营者为维护和改进服务之目的,对您输入内容进行存储和必要处理的权利。
|
|
||||||
</text>
|
|
||||||
</view>
|
|
||||||
<view class="mb-[40rpx] ml-[20rpx]">
|
|
||||||
<text class="text-[28rpx] text-[#333333] leading-[1.8]">
|
|
||||||
6.4 第三方权益:您在使用本服务时,应尊重第三方的知识产权及其他合法权益。因您侵犯第三方权益而引发的纠纷,由您自行承担全部责任。
|
|
||||||
</text>
|
|
||||||
</view>
|
|
||||||
|
|
||||||
<view class="mb-[32rpx]">
|
|
||||||
<text class="text-[28rpx] text-[#333333] font-semibold">
|
|
||||||
七、隐私保护
|
|
||||||
</text>
|
|
||||||
</view>
|
|
||||||
<view class="mb-[24rpx] ml-[20rpx]">
|
|
||||||
<text class="text-[28rpx] text-[#333333] leading-[1.8]">
|
|
||||||
7.1 信息收集:为提供本服务,运营者可能会收集您的注册信息(如手机号、用户名)、设备信息、使用日志等。具体的个人信息收集和使用规则请参阅《隐私政策》。
|
|
||||||
</text>
|
|
||||||
</view>
|
|
||||||
<view class="mb-[24rpx] ml-[20rpx]">
|
|
||||||
<text class="text-[28rpx] text-[#333333] leading-[1.8]">
|
|
||||||
7.2 信息保护:运营者将采取合理的技术和管理措施保护您的个人信息安全。但由于互联网的开放性,运营者不能绝对保证信息安全,请您注意保护个人敏感信息。
|
|
||||||
</text>
|
|
||||||
</view>
|
|
||||||
<view class="mb-[40rpx] ml-[20rpx]">
|
|
||||||
<text class="text-[28rpx] text-[#333333] leading-[1.8]">
|
|
||||||
7.3 信息安全提示:请勿在使用本服务过程中向AI透露您的财产账户、银行卡、密码等敏感个人信息,否则由此带来的损失由您自行承担。
|
|
||||||
</text>
|
|
||||||
</view>
|
|
||||||
|
|
||||||
<view class="mb-[32rpx]">
|
|
||||||
<text class="text-[28rpx] text-[#333333] font-semibold">
|
|
||||||
八、免责声明
|
|
||||||
</text>
|
|
||||||
</view>
|
|
||||||
<view class="mb-[24rpx] ml-[20rpx]">
|
|
||||||
<text class="text-[28rpx] text-[#333333] leading-[1.8]">
|
|
||||||
8.1 AI生成内容:本服务依赖第三方AI模型提供智能交互能力,AI生成的内容可能存在不准确、不完整或不恰当之处。运营者不对AI生成内容的真实性、准确性、完整性作任何保证。
|
|
||||||
</text>
|
|
||||||
</view>
|
|
||||||
<view class="mb-[24rpx] ml-[20rpx]">
|
|
||||||
<text class="text-[28rpx] text-[#333333] leading-[1.8]">
|
|
||||||
8.2 服务中断:因以下原因导致服务中断或异常,运营者不承担责任:
|
|
||||||
</text>
|
|
||||||
</view>
|
|
||||||
<view class="mb-[16rpx] ml-[40rpx]">
|
|
||||||
<text class="text-[28rpx] text-[#333333] leading-[1.8]">
|
|
||||||
(1)不可抗力因素,如自然灾害、疫情、战争等。
|
|
||||||
</text>
|
|
||||||
</view>
|
|
||||||
<view class="mb-[16rpx] ml-[40rpx]">
|
|
||||||
<text class="text-[28rpx] text-[#333333] leading-[1.8]">
|
|
||||||
(2)电力供应故障、通信网络故障等公共服务因素。
|
|
||||||
</text>
|
|
||||||
</view>
|
|
||||||
<view class="mb-[16rpx] ml-[40rpx]">
|
|
||||||
<text class="text-[28rpx] text-[#333333] leading-[1.8]">
|
|
||||||
(3)第三方AI模型服务商的服务故障或政策调整。
|
|
||||||
</text>
|
|
||||||
</view>
|
|
||||||
<view class="mb-[16rpx] ml-[40rpx]">
|
|
||||||
<text class="text-[28rpx] text-[#333333] leading-[1.8]">
|
|
||||||
(4)系统维护、升级导致的临时性服务中断。
|
|
||||||
</text>
|
|
||||||
</view>
|
|
||||||
<view class="mb-[16rpx] ml-[40rpx]">
|
|
||||||
<text class="text-[28rpx] text-[#333333] leading-[1.8]">
|
|
||||||
(5)黑客攻击、计算机病毒等网络安全事件。
|
|
||||||
</text>
|
|
||||||
</view>
|
|
||||||
<view class="mb-[16rpx] ml-[40rpx]">
|
|
||||||
<text class="text-[28rpx] text-[#333333] leading-[1.8]">
|
|
||||||
(6)法律法规或政府管制导致的服务调整。
|
|
||||||
</text>
|
|
||||||
</view>
|
|
||||||
<view class="mb-[40rpx] ml-[40rpx]">
|
|
||||||
<text class="text-[28rpx] text-[#333333] leading-[1.8]">
|
|
||||||
(7)其他非运营者过错导致的情形。
|
|
||||||
</text>
|
|
||||||
</view>
|
|
||||||
<view class="mb-[24rpx] ml-[20rpx]">
|
|
||||||
<text class="text-[28rpx] text-[#333333] leading-[1.8]">
|
|
||||||
8.3 第三方服务:本服务可能涉及第三方提供的语言模型、语音识别、语音合成、视觉模型、意图识别等服务。您在使用时应同时遵守第三方的服务条款。因第三方服务引发的问题,请直接与第三方联系。
|
|
||||||
</text>
|
|
||||||
</view>
|
|
||||||
<view class="mb-[24rpx] ml-[20rpx]">
|
|
||||||
<text class="text-[28rpx] text-[#333333] leading-[1.8]">
|
|
||||||
8.4 开源声明:本服务为开源项目,按"现状"提供。在法律允许的最大范围内,运营者不就本服务的适销性、特定用途适用性或不侵权性作任何明示或暗示的保证。
|
|
||||||
</text>
|
|
||||||
</view>
|
|
||||||
<view class="mb-[24rpx] ml-[20rpx]">
|
|
||||||
<text class="text-[28rpx] text-[#333333] leading-[1.8]">
|
|
||||||
8.5 开源软件特别声明:本项目为开源软件,本服务与对接的任何第三方API服务商(包括但不限于语音识别、大模型、语音合成等平台)均不存在商业合作关系,不为其服务质量及资金安全提供任何形式的担保。本软件不托管任何账户密钥、不参与资金流转、不承担充值资金损失风险。
|
|
||||||
</text>
|
|
||||||
</view>
|
|
||||||
<view class="mb-[40rpx] ml-[20rpx]">
|
|
||||||
<text class="text-[28rpx] text-[#333333] leading-[1.8]">
|
|
||||||
8.6 安全警告:本项目功能未完善,且未通过网络安全测评,请勿在生产环境中使用。如果您在公网环境中部署学习本项目,请务必做好必要的防护措施,包括但不限于设置强密码、限制访问权限、启用HTTPS加密传输等。
|
|
||||||
</text>
|
|
||||||
</view>
|
|
||||||
|
|
||||||
<view class="mb-[32rpx]">
|
|
||||||
<text class="text-[28rpx] text-[#333333] font-semibold">
|
|
||||||
九、未成年人保护
|
|
||||||
</text>
|
|
||||||
</view>
|
|
||||||
<view class="mb-[24rpx] ml-[20rpx]">
|
|
||||||
<text class="text-[28rpx] text-[#333333] leading-[1.8]">
|
|
||||||
9.1 若您是未满18周岁的未成年人,应在监护人的指导和同意下使用本服务。
|
|
||||||
</text>
|
|
||||||
</view>
|
|
||||||
<view class="mb-[24rpx] ml-[20rpx]">
|
|
||||||
<text class="text-[28rpx] text-[#333333] leading-[1.8]">
|
|
||||||
9.2 监护人应加强对未成年人使用本服务的监督,引导未成年人合理使用,避免过度依赖。
|
|
||||||
</text>
|
|
||||||
</view>
|
|
||||||
<view class="mb-[40rpx] ml-[20rpx]">
|
|
||||||
<text class="text-[28rpx] text-[#333333] leading-[1.8]">
|
|
||||||
9.3 未成年人在使用本服务时应注意个人信息保护,避免上传或透露个人敏感信息。
|
|
||||||
</text>
|
|
||||||
</view>
|
|
||||||
|
|
||||||
<view class="mb-[32rpx]">
|
|
||||||
<text class="text-[28rpx] text-[#333333] font-semibold">
|
|
||||||
十、协议终止
|
|
||||||
</text>
|
|
||||||
</view>
|
|
||||||
<view class="mb-[24rpx] ml-[20rpx]">
|
|
||||||
<text class="text-[28rpx] text-[#333333] leading-[1.8]">
|
|
||||||
10.1 用户终止:您有权随时停止使用本服务并注销账号。
|
|
||||||
</text>
|
|
||||||
</view>
|
|
||||||
<view class="mb-[24rpx] ml-[20rpx]">
|
|
||||||
<text class="text-[28rpx] text-[#333333] leading-[1.8]">
|
|
||||||
10.2 运营者终止:出现以下情形时,运营者有权终止向您提供服务:
|
|
||||||
</text>
|
|
||||||
</view>
|
|
||||||
<view class="mb-[16rpx] ml-[40rpx]">
|
|
||||||
<text class="text-[28rpx] text-[#333333] leading-[1.8]">
|
|
||||||
(1)您违反本协议的约定。
|
|
||||||
</text>
|
|
||||||
</view>
|
|
||||||
<view class="mb-[16rpx] ml-[40rpx]">
|
|
||||||
<text class="text-[28rpx] text-[#333333] leading-[1.8]">
|
|
||||||
(2)您利用本服务从事违法违规活动。
|
|
||||||
</text>
|
|
||||||
</view>
|
|
||||||
<view class="mb-[16rpx] ml-[40rpx]">
|
|
||||||
<text class="text-[28rpx] text-[#333333] leading-[1.8]">
|
|
||||||
(3)根据法律法规或政策要求。
|
|
||||||
</text>
|
|
||||||
</view>
|
|
||||||
<view class="mb-[40rpx] ml-[40rpx]">
|
|
||||||
<text class="text-[28rpx] text-[#333333] leading-[1.8]">
|
|
||||||
(4)运营者决定停止运营本服务。
|
|
||||||
</text>
|
|
||||||
</view>
|
|
||||||
<view class="mb-[24rpx] ml-[20rpx]">
|
|
||||||
<text class="text-[28rpx] text-[#333333] leading-[1.8]">
|
|
||||||
10.3 终止后处理:协议终止后,运营者无义务保留您的账号信息及相关数据。运营者仍有权依据本协议追究您在协议有效期内的违约责任。
|
|
||||||
</text>
|
|
||||||
</view>
|
|
||||||
|
|
||||||
<view class="mb-[32rpx]">
|
|
||||||
<text class="text-[28rpx] text-[#333333] font-semibold">
|
|
||||||
十一、法律适用与争议解决
|
|
||||||
</text>
|
|
||||||
</view>
|
|
||||||
<view class="mb-[24rpx] ml-[20rpx]">
|
|
||||||
<text class="text-[28rpx] text-[#333333] leading-[1.8]">
|
|
||||||
11.1 本协议的订立、生效、解释、修订、终止及争议解决均适用中华人民共和国法律。
|
|
||||||
</text>
|
|
||||||
</view>
|
|
||||||
<view class="mb-[24rpx] ml-[20rpx]">
|
|
||||||
<text class="text-[28rpx] text-[#333333] leading-[1.8]">
|
|
||||||
11.2 因本协议或本服务引发的争议,双方应友好协商解决;协商不成的,任何一方有权向运营者所在地有管辖权的人民法院提起诉讼。
|
|
||||||
</text>
|
|
||||||
</view>
|
|
||||||
<view class="mb-[40rpx] ml-[20rpx]">
|
|
||||||
<text class="text-[28rpx] text-[#333333] leading-[1.8]">
|
|
||||||
11.3 本协议的任何条款被认定为无效或不可执行,不影响其余条款的效力。
|
|
||||||
</text>
|
|
||||||
</view>
|
|
||||||
|
|
||||||
<view class="mb-[32rpx]">
|
|
||||||
<text class="text-[28rpx] text-[#333333] font-semibold">
|
|
||||||
十二、其他
|
|
||||||
</text>
|
|
||||||
</view>
|
|
||||||
<view class="mb-[24rpx] ml-[20rpx]">
|
|
||||||
<text class="text-[28rpx] text-[#333333] leading-[1.8]">
|
|
||||||
12.1 本协议构成您与运营者之间关于使用本服务的完整协议。
|
|
||||||
</text>
|
|
||||||
</view>
|
|
||||||
<view class="mb-[40rpx] ml-[20rpx]">
|
|
||||||
<text class="text-[28rpx] text-[#333333] leading-[1.8]">
|
|
||||||
12.2 运营者未行使或延迟行使本协议项下的任何权利,不构成对该权利的放弃。
|
|
||||||
</text>
|
|
||||||
</view>
|
|
||||||
</view>
|
|
||||||
</scroll-view>
|
|
||||||
</view>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<style lang="scss" scoped>
|
|
||||||
</style>
|
|
||||||
|
|
@ -3,28 +3,24 @@
|
||||||
"layout": "default",
|
"layout": "default",
|
||||||
"style": {
|
"style": {
|
||||||
"navigationStyle": "custom",
|
"navigationStyle": "custom",
|
||||||
"navigationBarTitleText": "注册"
|
"navigationBarTitleText": "Register"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</route>
|
</route>
|
||||||
|
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { computed, onMounted, ref } from 'vue';
|
import { computed, onMounted, ref } from 'vue'
|
||||||
import { register, sendSmsCode } from '@/api/auth';
|
import { register, sendSmsCode } from '@/api/auth'
|
||||||
import { useConfigStore } from '@/store';
|
import { useConfigStore } from '@/store'
|
||||||
import { getEnvBaseUrl } from '@/utils';
|
import { getEnvBaseUrl, sm2Encrypt } from '@/utils'
|
||||||
import { toast } from '@/utils/toast';
|
import { toast } from '@/utils/toast'
|
||||||
// 导入国际化相关功能
|
|
||||||
import { t, initI18n } from '@/i18n';
|
|
||||||
// 导入SM2加密工具
|
|
||||||
import { sm2Encrypt } from '@/utils';
|
|
||||||
|
|
||||||
// 获取屏幕边界到安全区域距离
|
// Get distance from screen boundary to safe area
|
||||||
let safeAreaInsets
|
let safeAreaInsets
|
||||||
let systemInfo
|
let systemInfo
|
||||||
|
|
||||||
// #ifdef MP-WEIXIN
|
// #ifdef MP-WEIXIN
|
||||||
// 微信小程序使用新的API
|
// WeChat Mini Program uses new API
|
||||||
systemInfo = uni.getWindowInfo()
|
systemInfo = uni.getWindowInfo()
|
||||||
safeAreaInsets = systemInfo.safeArea
|
safeAreaInsets = systemInfo.safeArea
|
||||||
? {
|
? {
|
||||||
|
|
@ -37,13 +33,13 @@ safeAreaInsets = systemInfo.safeArea
|
||||||
// #endif
|
// #endif
|
||||||
|
|
||||||
// #ifndef MP-WEIXIN
|
// #ifndef MP-WEIXIN
|
||||||
// 其他平台继续使用uni API
|
// Other platforms continue to use uni API
|
||||||
systemInfo = uni.getSystemInfoSync()
|
systemInfo = uni.getSystemInfoSync()
|
||||||
safeAreaInsets = systemInfo.safeAreaInsets
|
safeAreaInsets = systemInfo.safeAreaInsets
|
||||||
// #endif
|
// #endif
|
||||||
|
|
||||||
// 注册表单数据
|
// Registration form state
|
||||||
interface RegisterData {
|
interface RegisterFormData {
|
||||||
username: string
|
username: string
|
||||||
password: string
|
password: string
|
||||||
confirmPassword: string
|
confirmPassword: string
|
||||||
|
|
@ -54,64 +50,61 @@ interface RegisterData {
|
||||||
mobileCaptcha: string
|
mobileCaptcha: string
|
||||||
}
|
}
|
||||||
|
|
||||||
const formData = ref<RegisterData>({
|
const formData = ref<RegisterFormData>({
|
||||||
username: '',
|
username: '',
|
||||||
password: '',
|
password: '',
|
||||||
confirmPassword: '',
|
confirmPassword: '',
|
||||||
captcha: '',
|
captcha: '',
|
||||||
captchaId: '',
|
captchaId: '',
|
||||||
areaCode: '+86',
|
areaCode: '+1',
|
||||||
mobile: '',
|
mobile: '',
|
||||||
mobileCaptcha: '',
|
mobileCaptcha: '',
|
||||||
})
|
})
|
||||||
|
|
||||||
// 验证码图片
|
// Captcha image
|
||||||
const captchaImage = ref('')
|
const captchaImage = ref('')
|
||||||
const loading = ref(false)
|
const loading = ref(false)
|
||||||
const smsLoading = ref(false)
|
const smsLoading = ref(false)
|
||||||
const smsCountdown = ref(0)
|
const smsCountdown = ref(0)
|
||||||
|
|
||||||
// 注册方式:'username' | 'mobile'
|
// Registration method: 'username' | 'mobile'
|
||||||
const registerType = ref<'username' | 'mobile'>('username')
|
const registerType = ref<'username' | 'mobile'>('username')
|
||||||
|
|
||||||
// 获取配置store
|
// Get config store
|
||||||
const configStore = useConfigStore()
|
const configStore = useConfigStore()
|
||||||
|
|
||||||
// 区号选择相关
|
// Area code selection related
|
||||||
const showAreaCodeSheet = ref(false)
|
const showAreaCodeSheet = ref(false)
|
||||||
const selectedAreaCode = ref('+86')
|
const selectedAreaCode = ref('+1')
|
||||||
const selectedAreaName = ref('中国大陆')
|
const selectedAreaName = ref('United States')
|
||||||
|
|
||||||
// 计算属性:是否启用手机号注册
|
// Computed property: whether mobile registration is enabled
|
||||||
const enableMobileRegister = computed(() => {
|
const enableMobileRegister = computed(() => {
|
||||||
return configStore.config.enableMobileRegister
|
return configStore.config.enableMobileRegister
|
||||||
})
|
})
|
||||||
|
|
||||||
// 计算属性:区号列表
|
const sm2PublicKey = computed(() => configStore.config.sm2PublicKey)
|
||||||
|
|
||||||
|
// Computed property: area code list
|
||||||
const areaCodeList = computed(() => {
|
const areaCodeList = computed(() => {
|
||||||
return configStore.config.mobileAreaList || [{ name: '中国大陆', key: '+86' }]
|
return configStore.config.mobileAreaList || [{ name: 'United States', key: '+1' }]
|
||||||
})
|
})
|
||||||
|
|
||||||
// SM2公钥
|
// Switch registration method
|
||||||
const sm2PublicKey = computed(() => {
|
|
||||||
return configStore.config.sm2PublicKey
|
|
||||||
})
|
|
||||||
|
|
||||||
// 切换注册方式
|
|
||||||
function toggleRegisterType() {
|
function toggleRegisterType() {
|
||||||
registerType.value = registerType.value === 'username' ? 'mobile' : 'username'
|
registerType.value = registerType.value === 'username' ? 'mobile' : 'username'
|
||||||
// 清空输入框
|
// Clear input fields
|
||||||
formData.value.username = ''
|
formData.value.username = ''
|
||||||
formData.value.mobile = ''
|
formData.value.mobile = ''
|
||||||
formData.value.mobileCaptcha = ''
|
formData.value.mobileCaptcha = ''
|
||||||
}
|
}
|
||||||
|
|
||||||
// 打开区号选择弹窗
|
// Open area code selection dialog
|
||||||
function openAreaCodeSheet() {
|
function openAreaCodeSheet() {
|
||||||
showAreaCodeSheet.value = true
|
showAreaCodeSheet.value = true
|
||||||
}
|
}
|
||||||
|
|
||||||
// 选择区号
|
// Select area code
|
||||||
function selectAreaCode(item: { name: string, key: string }) {
|
function selectAreaCode(item: { name: string, key: string }) {
|
||||||
selectedAreaCode.value = item.key
|
selectedAreaCode.value = item.key
|
||||||
selectedAreaName.value = item.name
|
selectedAreaName.value = item.name
|
||||||
|
|
@ -119,12 +112,12 @@ function selectAreaCode(item: { name: string, key: string }) {
|
||||||
showAreaCodeSheet.value = false
|
showAreaCodeSheet.value = false
|
||||||
}
|
}
|
||||||
|
|
||||||
// 关闭区号选择弹窗
|
// Close area code selection dialog
|
||||||
function closeAreaCodeSheet() {
|
function closeAreaCodeSheet() {
|
||||||
showAreaCodeSheet.value = false
|
showAreaCodeSheet.value = false
|
||||||
}
|
}
|
||||||
|
|
||||||
// 生成UUID
|
// Generate UUID
|
||||||
function generateUUID() {
|
function generateUUID() {
|
||||||
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, (c) => {
|
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, (c) => {
|
||||||
const r = (Math.random() * 16) | 0
|
const r = (Math.random() * 16) | 0
|
||||||
|
|
@ -133,28 +126,28 @@ function generateUUID() {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// 获取验证码
|
// Get verification code
|
||||||
async function refreshCaptcha() {
|
async function refreshCaptcha() {
|
||||||
const uuid = generateUUID();
|
const uuid = generateUUID()
|
||||||
formData.value.captchaId = uuid;
|
formData.value.captchaId = uuid
|
||||||
captchaImage.value = `${getEnvBaseUrl()}/user/captcha?uuid=${uuid}&t=${Date.now()}`;
|
captchaImage.value = `${getEnvBaseUrl()}/user/captcha?uuid=${uuid}&t=${Date.now()}`
|
||||||
}
|
}
|
||||||
|
|
||||||
// 发送短信验证码
|
// Send SMS verification code
|
||||||
async function sendSmsVerification() {
|
async function sendSmsVerification() {
|
||||||
if (!formData.value.mobile) {
|
if (!formData.value.mobile) {
|
||||||
toast.warning(t('register.enterPhone'))
|
toast.warning('Please enter phone number')
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if (!formData.value.captcha) {
|
if (!formData.value.captcha) {
|
||||||
toast.warning(t('register.enterCode'))
|
toast.warning('Please enter captcha')
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// 手机号格式验证
|
// Phone number format validation
|
||||||
const phoneRegex = /^1[3-9]\d{9}$/
|
const phoneRegex = /^1[3-9]\d{9}$/
|
||||||
if (!phoneRegex.test(formData.value.mobile)) {
|
if (!phoneRegex.test(formData.value.mobile)) {
|
||||||
toast.warning(t('register.enterPhone'))
|
toast.warning('Please enter correct phone number')
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -166,9 +159,9 @@ async function sendSmsVerification() {
|
||||||
captchaId: formData.value.captchaId,
|
captchaId: formData.value.captchaId,
|
||||||
})
|
})
|
||||||
|
|
||||||
toast.success(t('register.captchaSendSuccess'))
|
toast.success('Verification code sent successfully')
|
||||||
|
|
||||||
// 开始倒计时
|
// Start countdown
|
||||||
smsCountdown.value = 60
|
smsCountdown.value = 60
|
||||||
const timer = setInterval(() => {
|
const timer = setInterval(() => {
|
||||||
smsCountdown.value--
|
smsCountdown.value--
|
||||||
|
|
@ -178,11 +171,7 @@ async function sendSmsVerification() {
|
||||||
}, 1000)
|
}, 1000)
|
||||||
}
|
}
|
||||||
catch (error: any) {
|
catch (error: any) {
|
||||||
// 处理验证码错误 - 从error.message中解析错误码
|
// Send failed, re-obtain graphic verification code
|
||||||
if (error.message.includes('请求错误[10067]')) {
|
|
||||||
toast.warning(t('login.captchaError'))
|
|
||||||
}
|
|
||||||
// 发送失败重新获取图形验证码
|
|
||||||
refreshCaptcha()
|
refreshCaptcha()
|
||||||
}
|
}
|
||||||
finally {
|
finally {
|
||||||
|
|
@ -190,105 +179,78 @@ async function sendSmsVerification() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 注册
|
// Register
|
||||||
async function handleRegister() {
|
async function handleRegister() {
|
||||||
// 表单验证
|
// Form validation
|
||||||
if (enableMobileRegister.value) {
|
if (registerType.value === 'username') {
|
||||||
// 手机号注册验证
|
if (!formData.value.username) {
|
||||||
if (!formData.value.mobile) {
|
toast.warning('Please enter username')
|
||||||
toast.warning(t('register.enterPhone'))
|
|
||||||
return
|
|
||||||
}
|
|
||||||
// 手机号格式验证
|
|
||||||
const phoneRegex = /^1[3-9]\d{9}$/
|
|
||||||
if (!phoneRegex.test(formData.value.mobile)) {
|
|
||||||
toast.warning(t('register.enterPhone'))
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if (!formData.value.mobileCaptcha) {
|
|
||||||
toast.warning(t('register.enterCode'))
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// 用户名注册验证
|
if (!formData.value.mobile) {
|
||||||
if (!formData.value.username) {
|
toast.warning('Please enter phone number')
|
||||||
toast.warning(t('register.enterUsername'))
|
return
|
||||||
|
}
|
||||||
|
// Phone number format validation
|
||||||
|
const phoneRegex = /^1[3-9]\d{9}$/
|
||||||
|
if (!phoneRegex.test(formData.value.mobile)) {
|
||||||
|
toast.warning('Please enter correct phone number')
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if (!formData.value.mobileCaptcha) {
|
||||||
|
toast.warning('Please enter SMS verification code')
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!formData.value.password) {
|
if (!formData.value.password) {
|
||||||
toast.warning(t('register.enterPassword'))
|
toast.warning('Please enter password')
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!formData.value.confirmPassword) {
|
if (!formData.value.confirmPassword) {
|
||||||
toast.warning(t('register.confirmPassword'))
|
toast.warning('Please confirm password')
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if (formData.value.password !== formData.value.confirmPassword) {
|
if (formData.value.password !== formData.value.confirmPassword) {
|
||||||
toast.warning(t('register.confirmPassword'))
|
toast.warning('The two passwords entered do not match')
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!formData.value.captcha) {
|
if (!formData.value.captcha) {
|
||||||
toast.warning(t('register.enterCode'))
|
toast.warning('Please enter verification code')
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// 检查SM2公钥是否配置
|
|
||||||
if (!sm2PublicKey.value) {
|
if (!sm2PublicKey.value) {
|
||||||
toast.warning(t('sm2.publicKeyNotConfigured'))
|
toast.warning('SM2 public key not configured, please contact administrator')
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
loading.value = true
|
loading.value = true
|
||||||
|
|
||||||
// 加密密码
|
// Build registration data
|
||||||
let encryptedPassword
|
|
||||||
try {
|
|
||||||
// 拼接验证码和密码
|
|
||||||
const captchaAndPassword = formData.value.captcha + formData.value.password
|
|
||||||
encryptedPassword = sm2Encrypt(sm2PublicKey.value, captchaAndPassword)
|
|
||||||
} catch (error) {
|
|
||||||
console.error('密码加密失败:', error)
|
|
||||||
toast.warning(t('sm2.encryptionFailed'))
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
// 构建注册数据
|
|
||||||
const registerData = {
|
const registerData = {
|
||||||
username: enableMobileRegister.value ? `${selectedAreaCode.value}${formData.value.mobile}` : formData.value.username,
|
username: registerType.value === 'mobile' ? `${selectedAreaCode.value}${formData.value.mobile}` : formData.value.username,
|
||||||
password: encryptedPassword,
|
password: sm2Encrypt(sm2PublicKey.value, `${formData.value.captcha}${formData.value.password}`),
|
||||||
captchaId: formData.value.captchaId,
|
captchaId: formData.value.captchaId,
|
||||||
areaCode: formData.value.areaCode,
|
|
||||||
mobile: formData.value.mobile,
|
|
||||||
mobileCaptcha: formData.value.mobileCaptcha,
|
mobileCaptcha: formData.value.mobileCaptcha,
|
||||||
}
|
}
|
||||||
|
|
||||||
await register(registerData)
|
await register(registerData)
|
||||||
toast.success(t('message.registerSuccess'))
|
toast.success('Registration successful')
|
||||||
|
|
||||||
// 跳转到登录页
|
// Jump to login page
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
uni.redirectTo({
|
uni.navigateBack()
|
||||||
url: '/pages/login/index'
|
|
||||||
})
|
|
||||||
}, 1000)
|
}, 1000)
|
||||||
}
|
}
|
||||||
catch (error: any) {
|
catch (error: any) {
|
||||||
// 处理验证码错误 - 从error.message中解析错误码
|
// Registration failed, re-obtain verification code
|
||||||
if (error.message.includes('请求错误[10067]')) {
|
|
||||||
toast.warning(t('login.captchaError'))
|
|
||||||
}
|
|
||||||
// 处理手机号码已注册错误
|
|
||||||
else if (error.message.includes('请求错误[10070]')) {
|
|
||||||
toast.warning(t('message.phoneRegistered'))
|
|
||||||
}
|
|
||||||
// 注册失败重新获取验证码
|
|
||||||
refreshCaptcha()
|
refreshCaptcha()
|
||||||
}
|
}
|
||||||
finally {
|
finally {
|
||||||
|
|
@ -296,33 +258,27 @@ async function handleRegister() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 返回登录
|
// Return to login
|
||||||
function goBack() {
|
function goBack() {
|
||||||
uni.redirectTo({
|
uni.navigateBack()
|
||||||
url: '/pages/login/index'
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 页面加载时获取验证码
|
// Get verification code when page loads
|
||||||
onLoad(() => {
|
onLoad(() => {
|
||||||
refreshCaptcha()
|
refreshCaptcha()
|
||||||
})
|
})
|
||||||
|
|
||||||
// 组件挂载时确保配置已加载
|
// Ensure configuration is loaded when component is mounted
|
||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
if (!configStore.config.name) {
|
if (!configStore.config.name) {
|
||||||
try {
|
try {
|
||||||
await configStore.fetchPublicConfig()
|
await configStore.fetchPublicConfig()
|
||||||
}
|
}
|
||||||
catch (error) {
|
catch (error) {
|
||||||
console.error('获取配置失败:', error)
|
console.error('Failed to get configuration:', error)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// 初始化国际化
|
|
||||||
initI18n()
|
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
|
|
@ -334,18 +290,18 @@ onMounted(async () => {
|
||||||
<view class="logo-section">
|
<view class="logo-section">
|
||||||
<wd-img :width="80" :height="80" round src="/static/logo.png" class="logo" />
|
<wd-img :width="80" :height="80" round src="/static/logo.png" class="logo" />
|
||||||
<text class="welcome-text">
|
<text class="welcome-text">
|
||||||
{{ t('register.pageTitle') }}
|
Welcome to Register
|
||||||
</text>
|
</text>
|
||||||
<text class="subtitle">
|
<text class="subtitle">
|
||||||
{{ t('register.createAccount') }}
|
Create Your New Account
|
||||||
</text>
|
</text>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
<view class="form-container">
|
<view class="form-container">
|
||||||
<view class="form">
|
<view class="form">
|
||||||
<!-- 手机号注册 -->
|
<!-- Mobile number registration -->
|
||||||
<template v-if="enableMobileRegister">
|
<template v-if="registerType === 'mobile'">
|
||||||
<view class="input-group">
|
<view class="input-group">
|
||||||
<view class="input-wrapper mobile-wrapper">
|
<view class="input-wrapper mobile-wrapper">
|
||||||
<view class="area-code-selector" @click="openAreaCodeSheet">
|
<view class="area-code-selector" @click="openAreaCodeSheet">
|
||||||
|
|
@ -359,7 +315,7 @@ onMounted(async () => {
|
||||||
v-model="formData.mobile"
|
v-model="formData.mobile"
|
||||||
custom-class="styled-input"
|
custom-class="styled-input"
|
||||||
no-border
|
no-border
|
||||||
:placeholder="t('register.enterPhone')"
|
placeholder="Please enter mobile number"
|
||||||
type="number"
|
type="number"
|
||||||
:maxlength="11"
|
:maxlength="11"
|
||||||
/>
|
/>
|
||||||
|
|
@ -368,7 +324,7 @@ onMounted(async () => {
|
||||||
</view>
|
</view>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<!-- 用户名注册 -->
|
<!-- Username registration -->
|
||||||
<template v-else>
|
<template v-else>
|
||||||
<view class="input-group">
|
<view class="input-group">
|
||||||
<view class="input-wrapper">
|
<view class="input-wrapper">
|
||||||
|
|
@ -376,7 +332,7 @@ onMounted(async () => {
|
||||||
v-model="formData.username"
|
v-model="formData.username"
|
||||||
custom-class="styled-input"
|
custom-class="styled-input"
|
||||||
no-border
|
no-border
|
||||||
:placeholder="t('register.enterUsername')"
|
placeholder="Please enter username"
|
||||||
/>
|
/>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
|
|
@ -388,7 +344,7 @@ onMounted(async () => {
|
||||||
v-model="formData.password"
|
v-model="formData.password"
|
||||||
custom-class="styled-input"
|
custom-class="styled-input"
|
||||||
no-border
|
no-border
|
||||||
:placeholder="t('register.enterPassword')"
|
placeholder="Please enter password"
|
||||||
show-password
|
show-password
|
||||||
:maxlength="20"
|
:maxlength="20"
|
||||||
/>
|
/>
|
||||||
|
|
@ -401,7 +357,7 @@ onMounted(async () => {
|
||||||
v-model="formData.confirmPassword"
|
v-model="formData.confirmPassword"
|
||||||
custom-class="styled-input"
|
custom-class="styled-input"
|
||||||
no-border
|
no-border
|
||||||
:placeholder="t('register.confirmPassword')"
|
placeholder="Please confirm password"
|
||||||
show-password
|
show-password
|
||||||
:maxlength="20"
|
:maxlength="20"
|
||||||
/>
|
/>
|
||||||
|
|
@ -414,7 +370,7 @@ onMounted(async () => {
|
||||||
v-model="formData.captcha"
|
v-model="formData.captcha"
|
||||||
custom-class="styled-input"
|
custom-class="styled-input"
|
||||||
no-border
|
no-border
|
||||||
:placeholder="t('register.enterCode')"
|
placeholder="Please enter verification code"
|
||||||
:maxlength="6"
|
:maxlength="6"
|
||||||
/>
|
/>
|
||||||
<view class="captcha-image" @click="refreshCaptcha">
|
<view class="captcha-image" @click="refreshCaptcha">
|
||||||
|
|
@ -423,14 +379,14 @@ onMounted(async () => {
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
<!-- 手机验证码输入框 -->
|
<!-- Mobile verification code input box -->
|
||||||
<view v-if="enableMobileRegister" class="input-group">
|
<view v-if="registerType === 'mobile'" class="input-group">
|
||||||
<view class="input-wrapper sms-wrapper">
|
<view class="input-wrapper sms-wrapper">
|
||||||
<wd-input
|
<wd-input
|
||||||
v-model="formData.mobileCaptcha"
|
v-model="formData.mobileCaptcha"
|
||||||
custom-class="styled-input"
|
custom-class="styled-input"
|
||||||
no-border
|
no-border
|
||||||
:placeholder="t('register.enterCode')"
|
placeholder="Please enter SMS verification code"
|
||||||
type="number"
|
type="number"
|
||||||
:maxlength="6"
|
:maxlength="6"
|
||||||
/>
|
/>
|
||||||
|
|
@ -440,7 +396,7 @@ onMounted(async () => {
|
||||||
custom-class="sms-btn"
|
custom-class="sms-btn"
|
||||||
@click="sendSmsVerification"
|
@click="sendSmsVerification"
|
||||||
>
|
>
|
||||||
{{ smsCountdown > 0 ? `${smsCountdown}s` : t('register.getCode') }}
|
{{ smsCountdown > 0 ? `${smsCountdown}s` : 'Get Verification Code' }}
|
||||||
</wd-button>
|
</wd-button>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
|
|
@ -451,25 +407,44 @@ onMounted(async () => {
|
||||||
:loading="loading"
|
:loading="loading"
|
||||||
@click="handleRegister"
|
@click="handleRegister"
|
||||||
>
|
>
|
||||||
{{ loading ? t('register.registering') : t('register.registerButton') }}
|
{{ loading ? 'Registering...' : 'Register' }}
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
<view class="login-hint">
|
<view class="login-hint">
|
||||||
<text class="hint-text">
|
<text class="hint-text">
|
||||||
{{ t('register.haveAccount') }}
|
Already have an account?
|
||||||
</text>
|
</text>
|
||||||
<text class="login-link" @click="goBack">
|
<text class="login-link" @click="goBack">
|
||||||
{{ t('register.loginNow') }}
|
Login Now
|
||||||
</text>
|
</text>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
|
<!-- Registration method switch -->
|
||||||
|
<view v-if="enableMobileRegister" class="register-type-switch">
|
||||||
|
<view class="switch-tabs">
|
||||||
|
<view
|
||||||
|
class="switch-tab"
|
||||||
|
:class="{ active: registerType === 'username' }"
|
||||||
|
@click="toggleRegisterType"
|
||||||
|
>
|
||||||
|
<wd-icon name="user" />
|
||||||
|
</view>
|
||||||
|
<view
|
||||||
|
class="switch-tab"
|
||||||
|
:class="{ active: registerType === 'mobile' }"
|
||||||
|
@click="toggleRegisterType"
|
||||||
|
>
|
||||||
|
<wd-icon name="phone" />
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
<!-- 区号选择弹窗 -->
|
<!-- Area code selection popup -->
|
||||||
<wd-action-sheet
|
<wd-action-sheet
|
||||||
v-model="showAreaCodeSheet"
|
v-model="showAreaCodeSheet"
|
||||||
:title="t('register.selectCountry')"
|
title="Select Country/Region"
|
||||||
:close-on-click-modal="true"
|
:close-on-click-modal="true"
|
||||||
@close="closeAreaCodeSheet"
|
@close="closeAreaCodeSheet"
|
||||||
>
|
>
|
||||||
|
|
@ -503,13 +478,11 @@ onMounted(async () => {
|
||||||
custom-class="confirm-btn"
|
custom-class="confirm-btn"
|
||||||
@click="closeAreaCodeSheet"
|
@click="closeAreaCodeSheet"
|
||||||
>
|
>
|
||||||
{{ t('register.confirm') }}
|
Confirm
|
||||||
</wd-button>
|
</wd-button>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</wd-action-sheet>
|
</wd-action-sheet>
|
||||||
|
|
||||||
|
|
||||||
</view>
|
</view>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
|
@ -642,7 +615,7 @@ onMounted(async () => {
|
||||||
&.captcha-wrapper {
|
&.captcha-wrapper {
|
||||||
.captcha-image {
|
.captcha-image {
|
||||||
margin-left: 20rpx;
|
margin-left: 20rpx;
|
||||||
width: 150rpx;
|
width: 120rpx;
|
||||||
height: 60rpx;
|
height: 60rpx;
|
||||||
border-radius: 8rpx;
|
border-radius: 8rpx;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
|
|
@ -833,7 +806,7 @@ onMounted(async () => {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 区号选择弹窗样式
|
// Area code selection popup styles
|
||||||
.area-code-sheet {
|
.area-code-sheet {
|
||||||
background: #ffffff;
|
background: #ffffff;
|
||||||
border-radius: 24rpx 24rpx 0 0;
|
border-radius: 24rpx 24rpx 0 0;
|
||||||
|
|
|
||||||
|
|
@ -1,21 +1,16 @@
|
||||||
<route lang="jsonc" type="page">
|
<route lang="jsonc" type="page">{
|
||||||
{
|
|
||||||
"layout": "default",
|
"layout": "default",
|
||||||
"style": {
|
"style": {
|
||||||
"navigationBarTitleText": "设置",
|
"navigationBarTitleText": "Settings",
|
||||||
"navigationStyle": "custom"
|
"navigationStyle": "custom"
|
||||||
}
|
}
|
||||||
}
|
}</route>
|
||||||
</route>
|
|
||||||
|
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import type { Language } from '@/store/lang'
|
|
||||||
import { computed, onMounted, reactive, ref } from 'vue'
|
|
||||||
import { useToast } from 'wot-design-uni'
|
|
||||||
import { changeLanguage, getCurrentLanguage, getSupportedLanguages, t } from '@/i18n'
|
|
||||||
import { useConfigStore } from '@/store'
|
|
||||||
import { clearServerBaseUrlOverride, getEnvBaseUrl, getServerBaseUrlOverride, setServerBaseUrlOverride } from '@/utils'
|
import { clearServerBaseUrlOverride, getEnvBaseUrl, getServerBaseUrlOverride, setServerBaseUrlOverride } from '@/utils'
|
||||||
import { isMp } from '@/utils/platform'
|
import { isMp } from '@/utils/platform'
|
||||||
|
import { computed, onMounted, reactive, ref } from 'vue'
|
||||||
|
import { useToast } from 'wot-design-uni'
|
||||||
|
|
||||||
defineOptions({
|
defineOptions({
|
||||||
name: 'SettingsPage',
|
name: 'SettingsPage',
|
||||||
|
|
@ -23,32 +18,30 @@ defineOptions({
|
||||||
|
|
||||||
const toast = useToast()
|
const toast = useToast()
|
||||||
|
|
||||||
// 缓存信息
|
// Cache information
|
||||||
const cacheInfo = reactive({
|
const cacheInfo = reactive({
|
||||||
storageSize: '0MB',
|
storageSize: '0MB',
|
||||||
imageCache: '0MB',
|
imageCache: '0MB',
|
||||||
dataCache: '0MB',
|
dataCache: '0MB',
|
||||||
})
|
})
|
||||||
|
|
||||||
const configStore = useConfigStore()
|
// Server address settings
|
||||||
|
|
||||||
// 服务端地址设置
|
|
||||||
const baseUrlInput = ref('')
|
const baseUrlInput = ref('')
|
||||||
const urlError = ref('')
|
const urlError = ref('')
|
||||||
|
|
||||||
// 系统信息(保留)
|
// System information (reserved)
|
||||||
const systemInfo = computed(() => {
|
const systemInfo = computed(() => {
|
||||||
const info = uni.getSystemInfoSync()
|
const info = uni.getSystemInfoSync()
|
||||||
return `${info.platform} ${info.system}`
|
return `${info.platform} ${info.system}`
|
||||||
})
|
})
|
||||||
|
|
||||||
// 读取本地覆盖地址
|
// Read local override address
|
||||||
function loadServerBaseUrl() {
|
function loadServerBaseUrl() {
|
||||||
const override = getServerBaseUrlOverride()
|
const override = getServerBaseUrlOverride()
|
||||||
baseUrlInput.value = override || getEnvBaseUrl()
|
baseUrlInput.value = override || getEnvBaseUrl()
|
||||||
}
|
}
|
||||||
|
|
||||||
// 获取缓存信息
|
// Get cache information
|
||||||
function getCacheInfo() {
|
function getCacheInfo() {
|
||||||
try {
|
try {
|
||||||
const info = uni.getStorageInfoSync()
|
const info = uni.getStorageInfoSync()
|
||||||
|
|
@ -56,11 +49,11 @@ function getCacheInfo() {
|
||||||
cacheInfo.storageSize = `${totalSize.toFixed(2)}MB`
|
cacheInfo.storageSize = `${totalSize.toFixed(2)}MB`
|
||||||
}
|
}
|
||||||
catch (error) {
|
catch (error) {
|
||||||
console.error('获取缓存信息失败:', error)
|
console.error('Failed to get cache information:', error)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 验证URL格式
|
// Validate URL format
|
||||||
function validateUrl() {
|
function validateUrl() {
|
||||||
urlError.value = ''
|
urlError.value = ''
|
||||||
|
|
||||||
|
|
@ -69,13 +62,13 @@ function validateUrl() {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!/^https?:\/\/.+\/xiaozhi$/.test(baseUrlInput.value)) {
|
if (!/^https?:\/\/.+\/xiaozhi$/.test(baseUrlInput.value)) {
|
||||||
urlError.value = t('settings.validServerUrl')
|
urlError.value = 'Please enter a valid server address (starting with http or https and ending with /xiaozhi)'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 测试服务端地址
|
// Test server address
|
||||||
async function testServerBaseUrl() {
|
async function testServerBaseUrl() {
|
||||||
// 先清除错误信息
|
// Clear error message first
|
||||||
urlError.value = ''
|
urlError.value = ''
|
||||||
|
|
||||||
if (!baseUrlInput.value || !/^https?:\/\/.+\/xiaozhi$/.test(baseUrlInput.value)) {
|
if (!baseUrlInput.value || !/^https?:\/\/.+\/xiaozhi$/.test(baseUrlInput.value)) {
|
||||||
|
|
@ -86,114 +79,80 @@ async function testServerBaseUrl() {
|
||||||
const response = await uni.request({
|
const response = await uni.request({
|
||||||
url: `${baseUrlInput.value}/api/ping`,
|
url: `${baseUrlInput.value}/api/ping`,
|
||||||
method: 'GET',
|
method: 'GET',
|
||||||
timeout: 3000,
|
timeout: 3000
|
||||||
})
|
})
|
||||||
|
|
||||||
if (response.statusCode === 200) {
|
if (response.statusCode === 200) {
|
||||||
return true
|
return true
|
||||||
}
|
} else {
|
||||||
else {
|
toast.error('Invalid address, please check if server is running or network connection is normal')
|
||||||
toast.error({
|
|
||||||
msg: t('message.invalidAddress'),
|
|
||||||
duration: 3000,
|
|
||||||
})
|
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
}
|
} catch (error) {
|
||||||
catch (error) {
|
console.error('Failed to test server address:', error)
|
||||||
console.error('测试服务端地址失败:', error)
|
toast.error('Invalid address, please check if server is running or network connection is normal')
|
||||||
toast.error({
|
|
||||||
msg: t('message.invalidAddress'),
|
|
||||||
duration: 3000,
|
|
||||||
})
|
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 保存服务端地址
|
// Save server address
|
||||||
async function saveServerBaseUrl() {
|
async function saveServerBaseUrl() {
|
||||||
if (!baseUrlInput.value || !/^https?:\/\/.+\/xiaozhi$/.test(baseUrlInput.value)) {
|
if (!baseUrlInput.value || !/^https?:\/\/.+\/xiaozhi$/.test(baseUrlInput.value)) {
|
||||||
toast.warning(t('settings.validServerUrl'))
|
toast.warning('Please enter a valid server address (starting with http or https and ending with /xiaozhi)')
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// 测试地址有效性
|
// Test address validity
|
||||||
const isServerValid = await testServerBaseUrl()
|
const isServerValid = await testServerBaseUrl()
|
||||||
if (!isServerValid) {
|
if (!isServerValid) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
setServerBaseUrlOverride(baseUrlInput.value)
|
setServerBaseUrlOverride(baseUrlInput.value)
|
||||||
// 处理config缓存无法更新的问题
|
|
||||||
uni.request({
|
|
||||||
url: `${getEnvBaseUrl()}/user/pub-config`,
|
|
||||||
method: 'GET',
|
|
||||||
success: (res: any) => {
|
|
||||||
if (res.statusCode === 200) {
|
|
||||||
configStore.setConfig(res.data.data)
|
|
||||||
uni.setStorageSync('config', res.data.data)
|
|
||||||
}
|
|
||||||
},
|
|
||||||
fail: (err) => {
|
|
||||||
console.error('获取SM2公钥失败:', err)
|
|
||||||
},
|
|
||||||
})
|
|
||||||
|
|
||||||
// 切换请求地址后清空所有缓存
|
// Clear all cache after switching request address
|
||||||
clearAllCacheAfterUrlChange()
|
clearAllCacheAfterUrlChange()
|
||||||
|
|
||||||
uni.showModal({
|
uni.showModal({
|
||||||
title: t('settings.restartApp'),
|
title: 'Restart App',
|
||||||
content: t('settings.serverUrlSavedAndCacheCleared'),
|
content: 'Server address saved and cache cleared, restart now to take effect?',
|
||||||
confirmText: t('settings.restartNow'),
|
confirmText: 'Restart Now',
|
||||||
cancelText: t('settings.restartLater'),
|
cancelText: 'Later',
|
||||||
success: (res) => {
|
success: (res) => {
|
||||||
if (res.confirm) {
|
if (res.confirm) {
|
||||||
restartApp()
|
restartApp()
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
toast.success(t('settings.restartSuccess'))
|
toast.success('Saved, you can manually restart the app later')
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// 语言切换
|
// Reset to env default
|
||||||
const supportedLanguages = getSupportedLanguages()
|
|
||||||
const currentLanguage = ref<Language>(getCurrentLanguage())
|
|
||||||
const showLanguageSheet = ref(false)
|
|
||||||
|
|
||||||
function handleLanguageChange(lang: Language) {
|
|
||||||
changeLanguage(lang)
|
|
||||||
showLanguageSheet.value = false
|
|
||||||
currentLanguage.value = lang
|
|
||||||
toast.success(t('settings.languageChanged'))
|
|
||||||
}
|
|
||||||
|
|
||||||
// 重置为 env 默认
|
|
||||||
function resetServerBaseUrl() {
|
function resetServerBaseUrl() {
|
||||||
clearServerBaseUrlOverride()
|
clearServerBaseUrlOverride()
|
||||||
baseUrlInput.value = getEnvBaseUrl()
|
baseUrlInput.value = getEnvBaseUrl()
|
||||||
|
|
||||||
// 切换请求地址后清空所有缓存
|
// Clear all cache after switching request address
|
||||||
clearAllCacheAfterUrlChange()
|
clearAllCacheAfterUrlChange()
|
||||||
|
|
||||||
uni.showModal({
|
uni.showModal({
|
||||||
title: t('settings.restartApp'),
|
title: 'Restart App',
|
||||||
content: t('settings.resetToDefaultAndCacheCleared'),
|
content: 'Reset to default address and cache cleared, restart now to take effect?',
|
||||||
confirmText: t('settings.restartNow'),
|
confirmText: 'Restart Now',
|
||||||
cancelText: t('settings.restartLater'),
|
cancelText: 'Later',
|
||||||
success: (res) => {
|
success: (res) => {
|
||||||
if (res.confirm) {
|
if (res.confirm) {
|
||||||
restartApp()
|
restartApp()
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
toast.success(t('settings.resetSuccess'))
|
toast.success('Reset complete, you can manually restart the app later')
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// 重启应用(App 原生重启;其他端回到首页)
|
// Restart app (Native app restart; other platforms return to home)
|
||||||
function restartApp() {
|
function restartApp() {
|
||||||
// #ifdef APP-PLUS
|
// #ifdef APP-PLUS
|
||||||
plus.runtime.restart()
|
plus.runtime.restart()
|
||||||
|
|
@ -203,49 +162,47 @@ function restartApp() {
|
||||||
// #endif
|
// #endif
|
||||||
}
|
}
|
||||||
|
|
||||||
// 切换地址后自动清空所有缓存
|
// Automatically clear all cache after switching address
|
||||||
function clearAllCacheAfterUrlChange() {
|
function clearAllCacheAfterUrlChange() {
|
||||||
try {
|
try {
|
||||||
// 备份运行时覆盖地址,确保清理后恢复
|
// Backup runtime override address, ensure recovery after cleanup
|
||||||
const preservedOverride = getServerBaseUrlOverride()
|
const preservedOverride = getServerBaseUrlOverride()
|
||||||
|
|
||||||
// 完全清空所有缓存,包括token
|
// Completely clear all cache, including token
|
||||||
uni.clearStorageSync()
|
uni.clearStorageSync()
|
||||||
|
|
||||||
// 清空localStorage(H5环境)
|
// Clear localStorage (H5 environment)
|
||||||
// #ifdef H5
|
// #ifdef H5
|
||||||
if (typeof localStorage !== 'undefined') {
|
if (typeof localStorage !== 'undefined') {
|
||||||
localStorage.clear()
|
localStorage.clear()
|
||||||
}
|
}
|
||||||
// #endif
|
// #endif
|
||||||
|
|
||||||
// 恢复运行时覆盖地址(如有),需要在清理完成后再写入
|
// Restore runtime override address (if any), need to write after cleanup is complete
|
||||||
if (preservedOverride) {
|
if (preservedOverride) {
|
||||||
setServerBaseUrlOverride(preservedOverride)
|
setServerBaseUrlOverride(preservedOverride)
|
||||||
}
|
}
|
||||||
|
|
||||||
// 重新获取缓存信息
|
// Re-get cache information
|
||||||
getCacheInfo()
|
getCacheInfo()
|
||||||
}
|
}
|
||||||
catch (error) {
|
catch (error) {
|
||||||
console.error('清除缓存失败:', error)
|
console.error('Clear cache failed:', error)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 清除缓存
|
// Clear cache
|
||||||
async function clearCache() {
|
async function clearCache() {
|
||||||
try {
|
try {
|
||||||
uni.showModal({
|
uni.showModal({
|
||||||
title: t('settings.confirmClear'),
|
title: 'Confirm Clear',
|
||||||
content: t('settings.confirmClearMessage'),
|
content: 'Are you sure you want to clear all cache? This will delete all data including login status and require re-login.',
|
||||||
confirmText: t('common.confirm'),
|
|
||||||
cancelText: t('common.cancel'),
|
|
||||||
success: (res) => {
|
success: (res) => {
|
||||||
if (res.confirm) {
|
if (res.confirm) {
|
||||||
clearAllCacheAfterUrlChange()
|
clearAllCacheAfterUrlChange()
|
||||||
toast.success(t('settings.cacheCleared'))
|
toast.success('Cache cleared successfully, redirecting to login page')
|
||||||
|
|
||||||
// 延迟跳转到登录页
|
// Delayed redirect to login page
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
uni.reLaunch({ url: '/pages/login/index' })
|
uni.reLaunch({ url: '/pages/login/index' })
|
||||||
}, 1500)
|
}, 1500)
|
||||||
|
|
@ -254,72 +211,60 @@ async function clearCache() {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
catch (error) {
|
catch (error) {
|
||||||
console.error('清除缓存失败:', error)
|
console.error('Clear cache failed:', error)
|
||||||
toast.error(t('settings.clearCacheFailed'))
|
toast.error('Clear cache failed')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 关于我们
|
// About us
|
||||||
function showAbout() {
|
function showAbout() {
|
||||||
uni.showModal({
|
uni.showModal({
|
||||||
title: t('settings.aboutApp', { appName: import.meta.env.VITE_APP_TITLE }),
|
title: `About Xiaozhi Control Panel`,
|
||||||
content: t('settings.aboutContent', {
|
content: `Xiaozhi Control Panel\n\nCross-platform mobile management application built with Vue.js 3 + uni-app, providing device management and agent configuration for Xiaozhi ESP32 smart hardware.\n\n© 2025 xiaozhi-esp32-server 0.8.3`,
|
||||||
appName: import.meta.env.VITE_APP_TITLE,
|
|
||||||
version: '0.9.2'
|
|
||||||
}),
|
|
||||||
showCancel: false,
|
showCancel: false,
|
||||||
confirmText: t('common.confirm'),
|
confirmText: 'OK',
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
// 仅在非小程序环境加载服务端地址设置
|
// Only load server address settings in non-mini-program environment
|
||||||
if (!isMp) {
|
if (!isMp) {
|
||||||
loadServerBaseUrl()
|
loadServerBaseUrl()
|
||||||
}
|
}
|
||||||
getCacheInfo()
|
getCacheInfo()
|
||||||
|
|
||||||
// 动态设置导航栏标题为国际化文本
|
|
||||||
uni.setNavigationBarTitle({
|
|
||||||
title: t('settings.title'),
|
|
||||||
})
|
|
||||||
})
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<view class="min-h-screen bg-[#f5f7fb]">
|
<view class="min-h-screen bg-[#f5f7fb]">
|
||||||
<wd-navbar :title="t('settings.title')" placeholder safe-area-inset-top fixed />
|
<wd-navbar title="Settings" placeholder safe-area-inset-top fixed />
|
||||||
|
|
||||||
<view class="p-[24rpx]">
|
<view class="p-[24rpx]">
|
||||||
<!-- 网络设置 - 仅在非小程序环境显示 -->
|
<!-- Network settings - only show in non-mini-program environment -->
|
||||||
<view v-if="!isMp" class="mb-[32rpx]">
|
<view v-if="!isMp" class="mb-[32rpx]">
|
||||||
<view class="mb-[24rpx] flex items-center">
|
<view class="mb-[24rpx] flex items-center">
|
||||||
<text class="text-[32rpx] text-[#232338] font-bold">
|
<text class="text-[32rpx] text-[#232338] font-bold">
|
||||||
{{ t('settings.networkSettings') }}
|
Network Settings
|
||||||
</text>
|
</text>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
<view
|
<view class="border border-[#eeeeee] rounded-[24rpx] bg-[#fbfbfb] p-[32rpx] overflow-hidden"
|
||||||
class="overflow-hidden border border-[#eeeeee] rounded-[24rpx] bg-[#fbfbfb] p-[32rpx]"
|
style="box-shadow: 0 4rpx 20rpx rgba(0, 0, 0, 0.06);">
|
||||||
style="box-shadow: 0 4rpx 20rpx rgba(0, 0, 0, 0.06);"
|
|
||||||
>
|
|
||||||
<view class="mb-[24rpx]">
|
<view class="mb-[24rpx]">
|
||||||
<text class="text-[28rpx] text-[#232338] font-semibold">
|
<text class="text-[28rpx] text-[#232338] font-semibold">
|
||||||
{{ t('settings.serverApiUrl') }}
|
Server API Address
|
||||||
</text>
|
</text>
|
||||||
<text class="mt-[8rpx] block text-[24rpx] text-[#9d9ea3]">
|
<text class="mt-[8rpx] block text-[24rpx] text-[#9d9ea3]">
|
||||||
{{ t('settings.modifyWillClearCache') }}
|
Cache will be cleared and app restarted after modification
|
||||||
</text>
|
</text>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
<view class="mb-[24rpx]">
|
<view class="mb-[24rpx]">
|
||||||
<view class="w-full overflow-hidden border border-[#eeeeee] rounded-[16rpx] bg-[#f5f7fb]">
|
<view class="w-full rounded-[16rpx] border border-[#eeeeee] bg-[#f5f7fb] overflow-hidden">
|
||||||
<wd-input
|
<wd-input v-model="baseUrlInput" type="text" clearable :maxlength="200"
|
||||||
v-model="baseUrlInput" type="text" clearable :maxlength="200"
|
placeholder="Enter server address, e.g. https://example.com/xiaozhi"
|
||||||
:placeholder="t('settings.enterServerUrl')"
|
custom-class="!border-none !bg-transparent h-[88rpx] px-[24rpx] items-center"
|
||||||
custom-class="!border-none !bg-transparent h-[64rpx] px-[24rpx] items-center"
|
input-class="text-[28rpx] text-[#232338]" @input="validateUrl" @blur="validateUrl" />
|
||||||
input-class="text-[28rpx] text-[#232338]" @input="validateUrl" @blur="validateUrl"
|
|
||||||
/>
|
|
||||||
</view>
|
</view>
|
||||||
<text v-if="urlError" class="mt-[8rpx] block text-[24rpx] text-[#ff4d4f]">
|
<text v-if="urlError" class="mt-[8rpx] block text-[24rpx] text-[#ff4d4f]">
|
||||||
{{ urlError }}
|
{{ urlError }}
|
||||||
|
|
@ -327,47 +272,40 @@ onMounted(async () => {
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
<view class="flex gap-[16rpx]">
|
<view class="flex gap-[16rpx]">
|
||||||
<wd-button
|
<wd-button type="primary"
|
||||||
type="primary"
|
|
||||||
custom-class="flex-1 h-[88rpx] rounded-[20rpx] text-[28rpx] font-semibold bg-[#336cff] border-none shadow-[0_4rpx_16rpx_rgba(51,108,255,0.3)] active:shadow-[0_2rpx_8rpx_rgba(51,108,255,0.4)] active:scale-98"
|
custom-class="flex-1 h-[88rpx] rounded-[20rpx] text-[28rpx] font-semibold bg-[#336cff] border-none shadow-[0_4rpx_16rpx_rgba(51,108,255,0.3)] active:shadow-[0_2rpx_8rpx_rgba(51,108,255,0.4)] active:scale-98"
|
||||||
@click="saveServerBaseUrl"
|
@click="saveServerBaseUrl">
|
||||||
>
|
Save Settings
|
||||||
{{ t('settings.saveSettings') }}
|
|
||||||
</wd-button>
|
</wd-button>
|
||||||
<wd-button
|
<wd-button type="default"
|
||||||
type="default"
|
|
||||||
custom-class="flex-1 h-[88rpx] rounded-[20rpx] text-[28rpx] font-semibold bg-white border-[#eeeeee] text-[#65686f] active:bg-[#f5f7fb]"
|
custom-class="flex-1 h-[88rpx] rounded-[20rpx] text-[28rpx] font-semibold bg-white border-[#eeeeee] text-[#65686f] active:bg-[#f5f7fb]"
|
||||||
@click="resetServerBaseUrl"
|
@click="resetServerBaseUrl">
|
||||||
>
|
Reset Default
|
||||||
{{ t('settings.resetDefault') }}
|
|
||||||
</wd-button>
|
</wd-button>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
<!-- 缓存管理 -->
|
<!-- Cache management -->
|
||||||
<view class="mb-[32rpx]">
|
<view class="mb-[32rpx]">
|
||||||
<view class="mb-[24rpx] flex items-center">
|
<view class="mb-[24rpx] flex items-center">
|
||||||
<text class="text-[32rpx] text-[#232338] font-bold">
|
<text class="text-[32rpx] text-[#232338] font-bold">
|
||||||
{{ t('settings.cacheManagement') }}
|
Cache Management
|
||||||
</text>
|
</text>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
<view
|
<view class="border border-[#eeeeee] rounded-[24rpx] bg-[#fbfbfb] p-[32rpx]"
|
||||||
class="border border-[#eeeeee] rounded-[24rpx] bg-[#fbfbfb] p-[32rpx]"
|
style="box-shadow: 0 4rpx 20rpx rgba(0, 0, 0, 0.06);">
|
||||||
style="box-shadow: 0 4rpx 20rpx rgba(0, 0, 0, 0.06);"
|
|
||||||
>
|
|
||||||
<view class="space-y-[16rpx]">
|
<view class="space-y-[16rpx]">
|
||||||
<!-- 缓存信息展示,参考插件样式 -->
|
<!-- Cache information display, reference plugin style -->
|
||||||
<view
|
<view
|
||||||
class="flex items-center justify-between border border-[#eeeeee] rounded-[16rpx] bg-[#f5f7fb] p-[24rpx] transition-all active:bg-[#eef3ff]"
|
class="flex items-center justify-between border border-[#eeeeee] rounded-[16rpx] bg-[#f5f7fb] p-[24rpx] transition-all active:bg-[#eef3ff]">
|
||||||
>
|
|
||||||
<view>
|
<view>
|
||||||
<text class="text-[28rpx] text-[#232338] font-medium">
|
<text class="text-[28rpx] text-[#232338] font-medium">
|
||||||
{{ t('settings.totalCacheSize') }}
|
Total Cache Size
|
||||||
</text>
|
</text>
|
||||||
<text class="mt-[4rpx] block text-[24rpx] text-[#9d9ea3]">
|
<text class="mt-[4rpx] block text-[24rpx] text-[#9d9ea3]">
|
||||||
{{ t('settings.appDataSize') }}
|
Total application data size
|
||||||
</text>
|
</text>
|
||||||
</view>
|
</view>
|
||||||
<text class="text-[28rpx] text-[#65686f] font-semibold">
|
<text class="text-[28rpx] text-[#65686f] font-semibold">
|
||||||
|
|
@ -375,51 +313,46 @@ onMounted(async () => {
|
||||||
</text>
|
</text>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
<!-- 清除缓存按钮,参考插件编辑按钮样式 -->
|
<!-- Clear cache button, reference plugin edit button style -->
|
||||||
<view
|
<view
|
||||||
class="flex items-center justify-between border border-[#eeeeee] rounded-[16rpx] bg-[#f5f7fb] p-[24rpx]"
|
class="flex items-center justify-between border border-[#eeeeee] rounded-[16rpx] bg-[#f5f7fb] p-[24rpx]">
|
||||||
>
|
|
||||||
<view>
|
<view>
|
||||||
<text class="text-[28rpx] text-[#232338] font-medium">
|
<text class="text-[28rpx] text-[#232338] font-medium">
|
||||||
{{ t('settings.cacheClear') }}
|
Cache Cleanup
|
||||||
</text>
|
</text>
|
||||||
<text class="mt-[4rpx] block text-[24rpx] text-[#9d9ea3]">
|
<text class="mt-[4rpx] block text-[24rpx] text-[#9d9ea3]">
|
||||||
{{ t('settings.clearAllCache') }}
|
Clear all cache data
|
||||||
</text>
|
</text>
|
||||||
</view>
|
</view>
|
||||||
<view
|
<view
|
||||||
class="cursor-pointer rounded-[24rpx] bg-[rgba(255,107,107,0.1)] px-[28rpx] py-[16rpx] text-[24rpx] text-[#ff6b6b] font-semibold transition-all duration-300 active:scale-95 active:bg-[#ff6b6b] active:text-white"
|
class="cursor-pointer rounded-[24rpx] bg-[rgba(255,107,107,0.1)] px-[28rpx] py-[16rpx] text-[24rpx] text-[#ff6b6b] font-semibold transition-all duration-300 active:scale-95 active:bg-[#ff6b6b] active:text-white"
|
||||||
@click="clearCache"
|
@click="clearCache">
|
||||||
>
|
Clear Cache
|
||||||
{{ t('settings.clearCache') }}
|
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
<!-- 应用信息 -->
|
<!-- Application information -->
|
||||||
<view class="mb-[32rpx]">
|
<view class="mb-[32rpx]">
|
||||||
<view class="mb-[24rpx] flex items-center">
|
<view class="mb-[24rpx] flex items-center">
|
||||||
<text class="text-[32rpx] text-[#232338] font-bold">
|
<text class="text-[32rpx] text-[#232338] font-bold">
|
||||||
{{ t('settings.appInfo') }}
|
Application Information
|
||||||
</text>
|
</text>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
<view
|
<view class="border border-[#eeeeee] rounded-[24rpx] bg-[#fbfbfb] p-[32rpx]"
|
||||||
class="border border-[#eeeeee] rounded-[24rpx] bg-[#fbfbfb] p-[32rpx]"
|
style="box-shadow: 0 4rpx 20rpx rgba(0, 0, 0, 0.06);">
|
||||||
style="box-shadow: 0 4rpx 20rpx rgba(0, 0, 0, 0.06);"
|
|
||||||
>
|
|
||||||
<view
|
<view
|
||||||
class="flex cursor-pointer items-center justify-between border border-[#eeeeee] rounded-[16rpx] bg-[#f5f7fb] p-[24rpx] transition-all active:bg-[#eef3ff]"
|
class="flex cursor-pointer items-center justify-between border border-[#eeeeee] rounded-[16rpx] bg-[#f5f7fb] p-[24rpx] transition-all active:bg-[#eef3ff]"
|
||||||
@click="showAbout"
|
@click="showAbout">
|
||||||
>
|
|
||||||
<view>
|
<view>
|
||||||
<text class="text-[28rpx] text-[#232338] font-medium">
|
<text class="text-[28rpx] text-[#232338] font-medium">
|
||||||
{{ t('settings.aboutUs') }}
|
About Us
|
||||||
</text>
|
</text>
|
||||||
<text class="mt-[4rpx] block text-[24rpx] text-[#9d9ea3]">
|
<text class="mt-[4rpx] block text-[24rpx] text-[#9d9ea3]">
|
||||||
{{ t('settings.appVersion') }}
|
Application version and team information
|
||||||
</text>
|
</text>
|
||||||
</view>
|
</view>
|
||||||
<wd-icon name="arrow-right" custom-class="text-[32rpx] text-[#9d9ea3]" />
|
<wd-icon name="arrow-right" custom-class="text-[32rpx] text-[#9d9ea3]" />
|
||||||
|
|
@ -427,89 +360,12 @@ onMounted(async () => {
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
<!-- 语言设置 -->
|
<!-- Bottom safe area -->
|
||||||
<view class="mb-[32rpx]">
|
<!-- Bottom safe area -->
|
||||||
<view class="mb-[24rpx] flex items-center">
|
|
||||||
<text class="text-[32rpx] text-[#232338] font-bold">
|
|
||||||
{{ t('settings.languageSettings') }}
|
|
||||||
</text>
|
|
||||||
</view>
|
|
||||||
|
|
||||||
<view
|
|
||||||
class="border border-[#eeeeee] rounded-[24rpx] bg-[#fbfbfb] p-[32rpx]"
|
|
||||||
style="box-shadow: 0 4rpx 20rpx rgba(0, 0, 0, 0.06);"
|
|
||||||
>
|
|
||||||
<view
|
|
||||||
class="flex cursor-pointer items-center justify-between border border-[#eeeeee] rounded-[16rpx] bg-[#f5f7fb] p-[24rpx] transition-all active:bg-[#eef3ff]"
|
|
||||||
@click="showLanguageSheet = true"
|
|
||||||
>
|
|
||||||
<view>
|
|
||||||
<text class="text-[32rpx] text-[#232338] font-medium">
|
|
||||||
{{ t('settings.language') }}
|
|
||||||
</text>
|
|
||||||
<text class="mt-[4rpx] block text-[24rpx] text-[#9d9ea3]">
|
|
||||||
{{ t('settings.selectLanguage') }}
|
|
||||||
</text>
|
|
||||||
</view>
|
|
||||||
<view class="flex items-center">
|
|
||||||
<text class="mr-[16rpx] text-[32rpx] text-[#9d9ea3] font-semibold">
|
|
||||||
{{ supportedLanguages.find(lang => lang.code === currentLanguage)?.name }}
|
|
||||||
</text>
|
|
||||||
<wd-icon name="arrow-right" custom-class="text-[32rpx] text-[#9d9ea3]" />
|
|
||||||
</view>
|
|
||||||
</view>
|
|
||||||
</view>
|
|
||||||
</view>
|
|
||||||
|
|
||||||
<!-- 语言选择弹窗 -->
|
|
||||||
<wd-action-sheet v-model="showLanguageSheet" :title="t('settings.selectLanguage')" :close-on-click-modal="true">
|
|
||||||
<view class="language-sheet">
|
|
||||||
<scroll-view scroll-y class="language-list">
|
|
||||||
<view
|
|
||||||
v-for="lang in supportedLanguages" :key="lang.code" class="language-item"
|
|
||||||
@click="handleLanguageChange(lang.code)"
|
|
||||||
>
|
|
||||||
<text class="language-name">
|
|
||||||
{{ lang.name }}
|
|
||||||
</text>
|
|
||||||
</view>
|
|
||||||
</scroll-view>
|
|
||||||
</view>
|
|
||||||
</wd-action-sheet>
|
|
||||||
|
|
||||||
<!-- 底部安全距离 -->
|
|
||||||
<!-- 底部安全距离 -->
|
|
||||||
<view style="height: env(safe-area-inset-bottom);" />
|
<view style="height: env(safe-area-inset-bottom);" />
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<style lang="scss" scoped>
|
<style lang="scss" scoped>
|
||||||
// 保持与 edit.vue 一致的风格,样式主要通过类名控制
|
// Keep consistent style with edit.vue, styles mainly controlled by class names</style>
|
||||||
|
|
||||||
// 语言选择弹窗样式
|
|
||||||
.language-sheet {
|
|
||||||
.language-list {
|
|
||||||
max-height: 50vh;
|
|
||||||
|
|
||||||
.language-item {
|
|
||||||
padding: 30rpx 0;
|
|
||||||
text-align: center;
|
|
||||||
border-bottom: 1rpx solid #f0f0f0;
|
|
||||||
|
|
||||||
.language-name {
|
|
||||||
font-size: 28rpx;
|
|
||||||
color: #333;
|
|
||||||
}
|
|
||||||
|
|
||||||
&:last-child {
|
|
||||||
border-bottom: none;
|
|
||||||
}
|
|
||||||
|
|
||||||
&:active {
|
|
||||||
background-color: #f5f7fb;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
|
|
|
||||||
|
|
@ -3,26 +3,22 @@ import type { ChatHistory, CreateSpeakerData, VoicePrint } from '@/api/voiceprin
|
||||||
import { computed, onMounted, ref } from 'vue'
|
import { computed, onMounted, ref } from 'vue'
|
||||||
import { useMessage } from 'wot-design-uni'
|
import { useMessage } from 'wot-design-uni'
|
||||||
import { useToast } from 'wot-design-uni/components/wd-toast'
|
import { useToast } from 'wot-design-uni/components/wd-toast'
|
||||||
import { createVoicePrint, deleteVoicePrint, getAudioDownloadId, getChatHistory, getVoicePrintList, updateVoicePrint } from '@/api/voiceprint'
|
import { createVoicePrint, deleteVoicePrint, getChatHistory, getVoicePrintList, updateVoicePrint } from '@/api/voiceprint'
|
||||||
import { t } from '@/i18n'
|
|
||||||
import { getEnvBaseUrl } from '@/utils'
|
|
||||||
|
|
||||||
defineOptions({
|
defineOptions({
|
||||||
name: 'VoicePrintManage',
|
name: 'VoicePrintManage',
|
||||||
})
|
})
|
||||||
|
|
||||||
const props = withDefaults(defineProps<Props>(), {
|
// Receive props
|
||||||
agentId: 'default',
|
|
||||||
})
|
|
||||||
|
|
||||||
const emits = defineEmits(['update-refresher-enabled'])
|
|
||||||
|
|
||||||
// 接收props
|
|
||||||
interface Props {
|
interface Props {
|
||||||
agentId?: string
|
agentId?: string
|
||||||
}
|
}
|
||||||
|
|
||||||
// 获取屏幕边界到安全区域距离
|
const props = withDefaults(defineProps<Props>(), {
|
||||||
|
agentId: 'default'
|
||||||
|
})
|
||||||
|
|
||||||
|
// Get screen boundary to safe area distance
|
||||||
let safeAreaInsets: any
|
let safeAreaInsets: any
|
||||||
let systemInfo: any
|
let systemInfo: any
|
||||||
|
|
||||||
|
|
@ -46,25 +42,21 @@ safeAreaInsets = systemInfo.safeAreaInsets
|
||||||
const message = useMessage()
|
const message = useMessage()
|
||||||
const toast = useToast()
|
const toast = useToast()
|
||||||
|
|
||||||
// 页面数据
|
// Page data
|
||||||
const voicePrintList = ref<VoicePrint[]>([])
|
const voicePrintList = ref<VoicePrint[]>([])
|
||||||
const chatHistoryList = ref<ChatHistory[]>([])
|
const chatHistoryList = ref<ChatHistory[]>([])
|
||||||
const chatHistoryActions = ref<any[]>([])
|
const chatHistoryActions = ref<any[]>([])
|
||||||
const swipeStates = ref<Record<string, 'left' | 'close' | 'right'>>({})
|
const swipeStates = ref<Record<string, 'left' | 'close' | 'right'>>({})
|
||||||
const loading = ref(false)
|
const loading = ref(false)
|
||||||
|
|
||||||
// 音频播放相关
|
// Use passed agent ID
|
||||||
const audioRef = ref<UniApp.InnerAudioContext | null>(null)
|
|
||||||
const playingAudioId = ref<string>('')
|
|
||||||
|
|
||||||
// 使用传入的智能体ID
|
|
||||||
const currentAgentId = computed(() => {
|
const currentAgentId = computed(() => {
|
||||||
return props.agentId
|
return props.agentId
|
||||||
})
|
})
|
||||||
|
|
||||||
// 智能体选择相关功能已移除
|
// Agent selection related functions have been removed
|
||||||
|
|
||||||
// 弹窗相关
|
// Dialog related
|
||||||
const showAddDialog = ref(false)
|
const showAddDialog = ref(false)
|
||||||
const showEditDialog = ref(false)
|
const showEditDialog = ref(false)
|
||||||
const showChatHistoryDialog = ref(false)
|
const showChatHistoryDialog = ref(false)
|
||||||
|
|
@ -82,14 +74,14 @@ const editForm = ref<VoicePrint>({
|
||||||
createDate: '',
|
createDate: '',
|
||||||
})
|
})
|
||||||
|
|
||||||
// 获取声纹列表
|
// Get voiceprint list
|
||||||
async function loadVoicePrintList() {
|
async function loadVoicePrintList() {
|
||||||
try {
|
try {
|
||||||
console.log('获取声纹列表')
|
console.log('Get voiceprint list')
|
||||||
|
|
||||||
// 检查是否有当前选中的智能体
|
// Check if there is currently selected agent
|
||||||
if (!currentAgentId.value) {
|
if (!currentAgentId.value) {
|
||||||
console.warn(t('voiceprint.noSelectedAgent'))
|
console.warn('No selected agent')
|
||||||
voicePrintList.value = []
|
voicePrintList.value = []
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
@ -97,7 +89,7 @@ async function loadVoicePrintList() {
|
||||||
loading.value = true
|
loading.value = true
|
||||||
const data = await getVoicePrintList(currentAgentId.value)
|
const data = await getVoicePrintList(currentAgentId.value)
|
||||||
|
|
||||||
// 初始化滑动状态
|
// Initialize swipe status
|
||||||
const list = data || []
|
const list = data || []
|
||||||
list.forEach((item) => {
|
list.forEach((item) => {
|
||||||
if (!swipeStates.value[item.id]) {
|
if (!swipeStates.value[item.id]) {
|
||||||
|
|
@ -108,7 +100,7 @@ async function loadVoicePrintList() {
|
||||||
voicePrintList.value = list
|
voicePrintList.value = list
|
||||||
}
|
}
|
||||||
catch (error) {
|
catch (error) {
|
||||||
console.error('获取声纹列表失败:', error)
|
console.error('Failed to get voiceprint list:', error)
|
||||||
voicePrintList.value = []
|
voicePrintList.value = []
|
||||||
}
|
}
|
||||||
finally {
|
finally {
|
||||||
|
|
@ -116,46 +108,42 @@ async function loadVoicePrintList() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 暴露给父组件的刷新方法
|
// Refresh method exposed to parent component
|
||||||
async function refresh() {
|
async function refresh() {
|
||||||
await loadVoicePrintList()
|
await loadVoicePrintList()
|
||||||
}
|
}
|
||||||
|
|
||||||
// 获取语音对话记录
|
// Get voice conversation records
|
||||||
async function loadChatHistory() {
|
async function loadChatHistory() {
|
||||||
try {
|
try {
|
||||||
if (!currentAgentId.value) {
|
if (!currentAgentId.value) {
|
||||||
toast.error(t('voiceprint.pleaseSelectAgent'))
|
toast.error('Please select an agent first')
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
const data = await getChatHistory(currentAgentId.value)
|
const data = await getChatHistory(currentAgentId.value)
|
||||||
chatHistoryList.value = data || []
|
chatHistoryList.value = data || []
|
||||||
// 转换为ActionSheet格式
|
// Convert to ActionSheet format
|
||||||
chatHistoryActions.value = chatHistoryList.value.map((item, index) => ({
|
chatHistoryActions.value = chatHistoryList.value.map((item, index) => ({
|
||||||
name: item.content,
|
name: item.content,
|
||||||
audioId: item.audioId,
|
audioId: item.audioId,
|
||||||
index,
|
index,
|
||||||
}))
|
}))
|
||||||
|
showChatHistoryDialog.value = true
|
||||||
}
|
}
|
||||||
catch (error) {
|
catch (error) {
|
||||||
console.error('获取对话记录失败:', error)
|
console.error('Failed to get conversation records:', error)
|
||||||
toast.error(t('voiceprint.fetchHistoryFailed'))
|
toast.error('Failed to get conversation records')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 打开添加弹窗
|
// Open add dialog
|
||||||
function openAddDialog() {
|
function openAddDialog() {
|
||||||
if (!currentAgentId.value) {
|
if (!currentAgentId.value) {
|
||||||
toast.error(t('voiceprint.pleaseSelectAgent'))
|
toast.error('Please select an agent first')
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// 检查声纹接口是否配置(通过尝试获取声纹列表来检测)
|
|
||||||
const checkVoicePrintConfig = async () => {
|
|
||||||
try {
|
|
||||||
await getVoicePrintList(currentAgentId.value)
|
|
||||||
// 接口正常,继续打开添加弹窗
|
|
||||||
addForm.value = {
|
addForm.value = {
|
||||||
agentId: currentAgentId.value,
|
agentId: currentAgentId.value,
|
||||||
audioId: '',
|
audioId: '',
|
||||||
|
|
@ -164,42 +152,22 @@ function openAddDialog() {
|
||||||
}
|
}
|
||||||
showAddDialog.value = true
|
showAddDialog.value = true
|
||||||
}
|
}
|
||||||
catch (error: any) {
|
|
||||||
// 捕捉声纹接口未配置错误
|
|
||||||
if (error.message && error.message.includes('请求错误[10054]')) {
|
|
||||||
toast.error(t('voiceprint.voiceprintInterfaceNotConfigured'))
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
// 其他错误,继续打开弹窗
|
|
||||||
addForm.value = {
|
|
||||||
agentId: currentAgentId.value,
|
|
||||||
audioId: '',
|
|
||||||
sourceName: '',
|
|
||||||
introduce: '',
|
|
||||||
}
|
|
||||||
showAddDialog.value = true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
checkVoicePrintConfig()
|
// Open edit dialog
|
||||||
}
|
|
||||||
|
|
||||||
// 打开编辑弹窗
|
|
||||||
function openEditDialog(item: VoicePrint) {
|
function openEditDialog(item: VoicePrint) {
|
||||||
editForm.value = { ...item }
|
editForm.value = { ...item }
|
||||||
showEditDialog.value = true
|
showEditDialog.value = true
|
||||||
}
|
}
|
||||||
|
|
||||||
// 获取选中音频的显示内容
|
// Get selected audio display content
|
||||||
function getSelectedAudioContent(audioId: string) {
|
function getSelectedAudioContent(audioId: string) {
|
||||||
if (!audioId)
|
if (!audioId)
|
||||||
return t('voiceprint.clickToSelectVector')
|
return 'Click to select voiceprint vector'
|
||||||
const chatItem = chatHistoryList.value.find(item => item.audioId === audioId)
|
const chatItem = chatHistoryList.value.find(item => item.audioId === audioId)
|
||||||
return chatItem ? chatItem.content : `已选择: ${audioId.substring(0, 8)}...`
|
return chatItem ? chatItem.content : `Selected: ${audioId.substring(0, 8)}...`
|
||||||
}
|
}
|
||||||
|
|
||||||
// 选择声纹向量
|
// Select voiceprint vector
|
||||||
function selectAudioId({ item }: { item: any }) {
|
function selectAudioId({ item }: { item: any }) {
|
||||||
if (showAddDialog.value) {
|
if (showAddDialog.value) {
|
||||||
addForm.value.audioId = item.audioId
|
addForm.value.audioId = item.audioId
|
||||||
|
|
@ -210,42 +178,37 @@ function selectAudioId({ item }: { item: any }) {
|
||||||
showChatHistoryDialog.value = false
|
showChatHistoryDialog.value = false
|
||||||
}
|
}
|
||||||
|
|
||||||
// 点击选择
|
// Submit add speaker
|
||||||
function handleItemClick(item: any) {
|
|
||||||
selectAudioId({ item })
|
|
||||||
}
|
|
||||||
|
|
||||||
// 提交添加说话人
|
|
||||||
async function submitAdd() {
|
async function submitAdd() {
|
||||||
if (!addForm.value.sourceName.trim()) {
|
if (!addForm.value.sourceName.trim()) {
|
||||||
toast.error(t('voiceprint.pleaseInputName'))
|
toast.error('Please enter name')
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if (!addForm.value.audioId) {
|
if (!addForm.value.audioId) {
|
||||||
toast.error(t('voiceprint.pleaseSelectVector'))
|
toast.error('Please select voiceprint vector')
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await createVoicePrint(addForm.value)
|
await createVoicePrint(addForm.value)
|
||||||
toast.success(t('voiceprint.addSuccess'))
|
toast.success('Added successfully')
|
||||||
showAddDialog.value = false
|
showAddDialog.value = false
|
||||||
await loadVoicePrintList()
|
await loadVoicePrintList()
|
||||||
}
|
}
|
||||||
catch (error) {
|
catch (error) {
|
||||||
console.error('添加说话人失败:', error)
|
console.error('Failed to add speaker:', error)
|
||||||
toast.error(t('voiceprint.addFailed'))
|
toast.error('Failed to add speaker')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 提交编辑说话人
|
// Submit edit speaker
|
||||||
async function submitEdit() {
|
async function submitEdit() {
|
||||||
if (!editForm.value.sourceName.trim()) {
|
if (!editForm.value.sourceName.trim()) {
|
||||||
toast.error(t('voiceprint.pleaseInputName'))
|
toast.error('Please enter name')
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if (!editForm.value.audioId) {
|
if (!editForm.value.audioId) {
|
||||||
toast.error(t('voiceprint.pleaseSelectVector'))
|
toast.error('Please select voiceprint vector')
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -257,140 +220,61 @@ async function submitEdit() {
|
||||||
introduce: editForm.value.introduce,
|
introduce: editForm.value.introduce,
|
||||||
createDate: editForm.value.createDate,
|
createDate: editForm.value.createDate,
|
||||||
})
|
})
|
||||||
toast.success(t('voiceprint.editSuccess'))
|
toast.success('Edited successfully')
|
||||||
showEditDialog.value = false
|
showEditDialog.value = false
|
||||||
await loadVoicePrintList()
|
await loadVoicePrintList()
|
||||||
}
|
}
|
||||||
catch (error) {
|
catch (error) {
|
||||||
console.error('编辑说话人失败:', error)
|
console.error('Failed to edit speaker:', error)
|
||||||
toast.error(t('voiceprint.editFailed'))
|
toast.error('Failed to edit speaker')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 处理编辑操作
|
// Handle edit operation
|
||||||
function handleEdit(item: VoicePrint) {
|
function handleEdit(item: VoicePrint) {
|
||||||
openEditDialog(item)
|
openEditDialog(item)
|
||||||
swipeStates.value[item.id] = 'close'
|
swipeStates.value[item.id] = 'close'
|
||||||
}
|
}
|
||||||
|
|
||||||
// 删除声纹
|
// Delete voiceprint
|
||||||
async function handleDelete(id: string) {
|
async function handleDelete(id: string) {
|
||||||
message.confirm({
|
message.confirm({
|
||||||
msg: t('voiceprint.deleteConfirmMsg'),
|
msg: 'Are you sure you want to delete this speaker?',
|
||||||
title: t('voiceprint.deleteConfirmTitle'),
|
title: 'Confirm Delete',
|
||||||
}).then(async () => {
|
}).then(async () => {
|
||||||
await deleteVoicePrint(id)
|
await deleteVoicePrint(id)
|
||||||
toast.success(t('voiceprint.deleteSuccess'))
|
toast.success('Delete successful')
|
||||||
await loadVoicePrintList()
|
await loadVoicePrintList()
|
||||||
}).catch(() => {
|
}).catch(() => {
|
||||||
console.log('点击了取消按钮')
|
console.log('Clicked cancel button')
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// 播放音频
|
|
||||||
async function playAudio(audioId: string, event: Event) {
|
|
||||||
event.stopPropagation() // 阻止事件冒泡,防止关闭下拉框
|
|
||||||
|
|
||||||
if (!audioId) {
|
|
||||||
toast.warning(t('voiceprint.audioNotExist'))
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
// 如果正在播放同一个音频,则停止
|
|
||||||
if (playingAudioId.value === audioId) {
|
|
||||||
stopAudio()
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
// 停止之前的音频
|
|
||||||
stopAudio()
|
|
||||||
|
|
||||||
try {
|
|
||||||
// 先获取音频下载ID
|
|
||||||
playingAudioId.value = audioId
|
|
||||||
const downloadId = await getAudioDownloadId(audioId)
|
|
||||||
|
|
||||||
if (!downloadId) {
|
|
||||||
toast.error(t('voiceprint.getAudioFailed'))
|
|
||||||
playingAudioId.value = ''
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
// 获取baseURL
|
|
||||||
const baseURL = getEnvBaseUrl()
|
|
||||||
const audioUrl = `${baseURL}/agent/play/${downloadId}`
|
|
||||||
|
|
||||||
// 创建新的音频实例
|
|
||||||
audioRef.value = uni.createInnerAudioContext()
|
|
||||||
audioRef.value.src = audioUrl
|
|
||||||
audioRef.value.autoplay = true
|
|
||||||
|
|
||||||
// 监听播放结束
|
|
||||||
audioRef.value.onEnded(() => {
|
|
||||||
playingAudioId.value = ''
|
|
||||||
})
|
|
||||||
|
|
||||||
// 监听播放错误
|
|
||||||
audioRef.value.onError((error) => {
|
|
||||||
console.error('音频播放错误:', error)
|
|
||||||
toast.error(t('voiceprint.audioPlayFailed'))
|
|
||||||
playingAudioId.value = ''
|
|
||||||
})
|
|
||||||
}
|
|
||||||
catch (error) {
|
|
||||||
console.error('播放音频失败:', error)
|
|
||||||
toast.error(t('voiceprint.audioPlayFailed'))
|
|
||||||
playingAudioId.value = ''
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// 停止音频
|
|
||||||
function stopAudio() {
|
|
||||||
if (audioRef.value) {
|
|
||||||
audioRef.value.stop()
|
|
||||||
audioRef.value.destroy()
|
|
||||||
audioRef.value = null
|
|
||||||
}
|
|
||||||
playingAudioId.value = ''
|
|
||||||
}
|
|
||||||
|
|
||||||
watch(() => [showAddDialog.value, showEditDialog.value], (newValues) => {
|
|
||||||
if (newValues.some((value: boolean) => value)) {
|
|
||||||
emits('update-refresher-enabled', false)
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
emits('update-refresher-enabled', true)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
// 智能体已简化为默认
|
// Agent simplified to default
|
||||||
|
|
||||||
loadVoicePrintList()
|
loadVoicePrintList()
|
||||||
loadChatHistory()
|
|
||||||
})
|
})
|
||||||
|
|
||||||
// 暴露方法给父组件
|
// Expose methods to parent component
|
||||||
defineExpose({
|
defineExpose({
|
||||||
showAddDialog,
|
|
||||||
showEditDialog,
|
|
||||||
refresh,
|
refresh,
|
||||||
})
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<view class="voiceprint-container" style="background: #f5f7fb; min-height: 100%;">
|
<view class="voiceprint-container" style="background: #f5f7fb; min-height: 100%;">
|
||||||
<!-- 加载状态 -->
|
<!-- Loading state -->
|
||||||
<view v-if="loading && voicePrintList.length === 0" class="loading-container">
|
<view v-if="loading && voicePrintList.length === 0" class="loading-container">
|
||||||
<wd-loading color="#336cff" />
|
<wd-loading color="#336cff" />
|
||||||
<text class="loading-text">
|
<text class="loading-text">
|
||||||
{{ t('voiceprint.loading') }}
|
Loading...
|
||||||
</text>
|
</text>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
<!-- 声纹列表 -->
|
<!-- Voiceprint list -->
|
||||||
<view v-else-if="voicePrintList.length > 0" class="voiceprint-list">
|
<view v-else-if="voicePrintList.length > 0" class="voiceprint-list">
|
||||||
<!-- 声纹卡片列表 -->
|
<!-- Voiceprint card list -->
|
||||||
<view class="box-border flex flex-col gap-[24rpx] p-[20rpx]">
|
<view class="box-border flex flex-col gap-[24rpx] p-[20rpx]">
|
||||||
<view v-for="item in voicePrintList" :key="item.id">
|
<view v-for="item in voicePrintList" :key="item.id">
|
||||||
<wd-swipe-action
|
<wd-swipe-action
|
||||||
|
|
@ -403,7 +287,7 @@ defineExpose({
|
||||||
{{ item.sourceName }}
|
{{ item.sourceName }}
|
||||||
</text>
|
</text>
|
||||||
<text class="mb-[12rpx] block text-[28rpx] text-[#65686f] leading-[1.4]">
|
<text class="mb-[12rpx] block text-[28rpx] text-[#65686f] leading-[1.4]">
|
||||||
{{ item.introduce || '暂无描述' }}
|
{{ item.introduce || 'No description' }}
|
||||||
</text>
|
</text>
|
||||||
<text class="block text-[24rpx] text-[#9d9ea3]">
|
<text class="block text-[24rpx] text-[#9d9ea3]">
|
||||||
{{ item.createDate }}
|
{{ item.createDate }}
|
||||||
|
|
@ -418,7 +302,7 @@ defineExpose({
|
||||||
@click="handleDelete(item.id)"
|
@click="handleDelete(item.id)"
|
||||||
>
|
>
|
||||||
<wd-icon name="delete" />
|
<wd-icon name="delete" />
|
||||||
{{ t('voiceprint.delete') }}
|
Delete
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</template>
|
</template>
|
||||||
|
|
@ -427,48 +311,49 @@ defineExpose({
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
<!-- 空状态 -->
|
<!-- Empty state -->
|
||||||
<view v-else-if="!loading" class="empty-container">
|
<view v-else-if="!loading" class="empty-container">
|
||||||
<view class="flex flex-col items-center justify-center p-[100rpx_40rpx] text-center">
|
<view class="flex flex-col items-center justify-center p-[100rpx_40rpx] text-center">
|
||||||
<wd-icon name="voice" custom-class="text-[120rpx] text-[#d9d9d9] mb-[32rpx]" />
|
<wd-icon name="voice" custom-class="text-[120rpx] text-[#d9d9d9] mb-[32rpx]" />
|
||||||
<text class="mb-[32rpx] text-[32rpx] text-[#666666] font-medium">
|
<text class="mb-[16rpx] text-[32rpx] text-[#666666] font-medium">
|
||||||
{{ t('voiceprint.emptyTitle') }}
|
No voiceprint data
|
||||||
</text>
|
</text>
|
||||||
<text class="text-[26rpx] text-[#999999] leading-[1.5]">
|
<text class="text-[26rpx] text-[#999999] leading-[1.5]">
|
||||||
{{ t('voiceprint.emptyDesc') }}
|
Click the + button in the bottom right corner to add your first speaker
|
||||||
</text>
|
</text>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
<!-- 浮动操作按钮 -->
|
<!-- Floating action button -->
|
||||||
<wd-fab custom-style="z-index:10" type="primary" size="small" :draggable="true" :expandable="false" @click="openAddDialog">
|
<wd-fab type="primary" size="small" :draggable="true" :expandable="false" @click="openAddDialog">
|
||||||
<wd-icon name="add" />
|
<wd-icon name="add" />
|
||||||
</wd-fab>
|
</wd-fab>
|
||||||
|
|
||||||
<!-- MessageBox 组件 -->
|
<!-- MessageBox component -->
|
||||||
<wd-message-box />
|
<wd-message-box />
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
<!-- 添加说话人弹窗 -->
|
<!-- Add speaker dialog -->
|
||||||
<wd-popup
|
<wd-popup
|
||||||
v-model="showAddDialog"
|
v-model="showAddDialog" position="center" custom-style="width: 90%; max-width: 400px; border-radius: 16px;"
|
||||||
position="center"
|
|
||||||
custom-style="width: 90%; max-width: 400px; border-radius: 16px;"
|
|
||||||
safe-area-inset-bottom
|
safe-area-inset-bottom
|
||||||
>
|
>
|
||||||
<view>
|
<view>
|
||||||
|
<view class="w-full flex items-center justify-between border-b-[2rpx] border-[#eeeeee] p-[32rpx_32rpx_24rpx]">
|
||||||
|
<text class="w-full text-center text-[32rpx] text-[#232338] font-semibold">
|
||||||
|
Add Speaker
|
||||||
|
</text>
|
||||||
|
</view>
|
||||||
|
|
||||||
<view class="p-[32rpx]">
|
<view class="p-[32rpx]">
|
||||||
<!-- 声纹向量选择 -->
|
<!-- Voiceprint Vector Selection -->
|
||||||
<view class="mb-[32rpx]">
|
<view class="mb-[32rpx]">
|
||||||
<text class="mb-[16rpx] block text-[28rpx] text-[#232338] font-medium">
|
<text class="mb-[16rpx] block text-[28rpx] text-[#232338] font-medium">
|
||||||
<text class="text-red">
|
* Voiceprint Vector
|
||||||
*
|
|
||||||
</text>
|
|
||||||
{{ t('voiceprint.voiceVector') }}
|
|
||||||
</text>
|
</text>
|
||||||
<view
|
<view
|
||||||
class="flex cursor-pointer items-center justify-between border-[1rpx] border-[#eeeeee] rounded-[12rpx] bg-[#f5f7fb] p-[20rpx] transition-all duration-300 active:bg-[#eef3ff]"
|
class="flex cursor-pointer items-center justify-between border-[1rpx] border-[#eeeeee] rounded-[12rpx] bg-[#f5f7fb] p-[20rpx] transition-all duration-300 active:bg-[#eef3ff]"
|
||||||
@click="showChatHistoryDialog = true"
|
@click="loadChatHistory"
|
||||||
>
|
>
|
||||||
<text
|
<text
|
||||||
class="m-r-[16rpx] flex-1 text-left text-[26rpx] text-[#232338]"
|
class="m-r-[16rpx] flex-1 text-left text-[26rpx] text-[#232338]"
|
||||||
|
|
@ -480,31 +365,25 @@ defineExpose({
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
<!-- 姓名 -->
|
<!-- Name -->
|
||||||
<view class="mb-[32rpx]">
|
<view class="mb-[32rpx]">
|
||||||
<text class="mb-[16rpx] block text-[28rpx] text-[#232338] font-medium">
|
<text class="mb-[16rpx] block text-[28rpx] text-[#232338] font-medium">
|
||||||
<text class="text-red">
|
* Name
|
||||||
*
|
|
||||||
</text>
|
|
||||||
{{ t('voiceprint.name') }}
|
|
||||||
</text>
|
</text>
|
||||||
<input
|
<input
|
||||||
v-model="addForm.sourceName"
|
v-model="addForm.sourceName"
|
||||||
class="box-border h-[80rpx] w-full border-[1rpx] border-[#eeeeee] rounded-[12rpx] bg-[#f5f7fb] p-[16rpx_20rpx] text-[28rpx] text-[#232338] leading-[1.4] outline-none focus:border-[#336cff] focus:bg-white placeholder:text-[#9d9ea3]"
|
class="box-border h-[80rpx] w-full border-[1rpx] border-[#eeeeee] rounded-[12rpx] bg-[#f5f7fb] p-[16rpx_20rpx] text-[28rpx] text-[#232338] leading-[1.4] outline-none focus:border-[#336cff] focus:bg-white placeholder:text-[#9d9ea3]"
|
||||||
type="text" :placeholder="t('voiceprint.pleaseInputName')"
|
type="text" placeholder="Please enter name"
|
||||||
>
|
>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
<!-- 描述 -->
|
<!-- Description -->
|
||||||
<view>
|
<view>
|
||||||
<text class="mb-[16rpx] block text-[28rpx] text-[#232338] font-medium">
|
<text class="mb-[16rpx] block text-[28rpx] text-[#232338] font-medium">
|
||||||
<text class="text-red">
|
* Description
|
||||||
*
|
|
||||||
</text>
|
|
||||||
{{ t('voiceprint.description') }}
|
|
||||||
</text>
|
</text>
|
||||||
<textarea
|
<textarea
|
||||||
v-model="addForm.introduce" :maxlength="100" :placeholder="t('voiceprint.pleaseInputDescription')"
|
v-model="addForm.introduce" :maxlength="100" placeholder="Please enter description"
|
||||||
class="box-border h-[200rpx] w-full resize-none border-[1rpx] border-[#eeeeee] rounded-[12rpx] bg-[#f5f7fb] p-[20rpx] text-[26rpx] text-[#232338] leading-[1.6] outline-none focus:border-[#336cff] focus:bg-white placeholder:text-[#9d9ea3]"
|
class="box-border h-[200rpx] w-full resize-none border-[1rpx] border-[#eeeeee] rounded-[12rpx] bg-[#f5f7fb] p-[20rpx] text-[26rpx] text-[#232338] leading-[1.6] outline-none focus:border-[#336cff] focus:bg-white placeholder:text-[#9d9ea3]"
|
||||||
/>
|
/>
|
||||||
<view class="mt-[8rpx] text-right text-[22rpx] text-[#9d9ea3]">
|
<view class="mt-[8rpx] text-right text-[22rpx] text-[#9d9ea3]">
|
||||||
|
|
@ -515,39 +394,36 @@ defineExpose({
|
||||||
|
|
||||||
<view class="flex gap-[16rpx] border-t-[2rpx] border-[#eeeeee] p-[24rpx_32rpx_32rpx]">
|
<view class="flex gap-[16rpx] border-t-[2rpx] border-[#eeeeee] p-[24rpx_32rpx_32rpx]">
|
||||||
<wd-button type="info" custom-class="flex-1" @click="showAddDialog = false">
|
<wd-button type="info" custom-class="flex-1" @click="showAddDialog = false">
|
||||||
{{ t('voiceprint.cancel') }}
|
Cancel
|
||||||
</wd-button>
|
</wd-button>
|
||||||
<wd-button type="primary" custom-class="flex-1" @click="submitAdd">
|
<wd-button type="primary" custom-class="flex-1" @click="submitAdd">
|
||||||
{{ t('voiceprint.save') }}
|
Save
|
||||||
</wd-button>
|
</wd-button>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</wd-popup>
|
</wd-popup>
|
||||||
|
|
||||||
<!-- 编辑说话人弹窗 -->
|
<!-- Edit speaker dialog -->
|
||||||
<wd-popup
|
<wd-popup
|
||||||
v-model="showEditDialog" position="center" custom-style="width: 90%; max-width: 400px; border-radius: 16px;"
|
v-model="showEditDialog" position="center" custom-style="width: 90%; max-width: 400px; border-radius: 16px;"
|
||||||
safe-area-inset-bottom
|
safe-area-inset-bottom
|
||||||
>
|
>
|
||||||
<view>
|
<view>
|
||||||
<view class="box-border w-full flex items-center justify-between border-b-[2rpx] border-[#eeeeee] p-[32rpx_32rpx_24rpx]">
|
<view class="w-full flex items-center justify-between border-b-[2rpx] border-[#eeeeee] p-[32rpx_32rpx_24rpx]">
|
||||||
<text class="w-full text-center text-[32rpx] text-[#232338] font-semibold">
|
<text class="w-full text-center text-[32rpx] text-[#232338] font-semibold">
|
||||||
{{ t('voiceprint.editSpeaker') }}
|
Edit Speaker
|
||||||
</text>
|
</text>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
<view class="p-[32rpx]">
|
<view class="p-[32rpx]">
|
||||||
<!-- 声纹向量选择 -->
|
<!-- Voiceprint Vector Selection -->
|
||||||
<view class="mb-[32rpx]">
|
<view class="mb-[32rpx]">
|
||||||
<text class="mb-[16rpx] block text-[28rpx] text-[#232338] font-medium">
|
<text class="mb-[16rpx] block text-[28rpx] text-[#232338] font-medium">
|
||||||
<text class="text-red">
|
* Voiceprint Vector
|
||||||
*
|
|
||||||
</text>
|
|
||||||
{{ t('voiceprint.voiceVector') }}
|
|
||||||
</text>
|
</text>
|
||||||
<view
|
<view
|
||||||
class="flex cursor-pointer items-center justify-between border-[1rpx] border-[#eeeeee] rounded-[12rpx] bg-[#f5f7fb] p-[20rpx] transition-all duration-300 active:bg-[#eef3ff]"
|
class="flex cursor-pointer items-center justify-between border-[1rpx] border-[#eeeeee] rounded-[12rpx] bg-[#f5f7fb] p-[20rpx] transition-all duration-300 active:bg-[#eef3ff]"
|
||||||
@click="showChatHistoryDialog = true"
|
@click="loadChatHistory"
|
||||||
>
|
>
|
||||||
<text
|
<text
|
||||||
class="m-r-[16rpx] flex-1 text-left text-[26rpx] text-[#232338]"
|
class="m-r-[16rpx] flex-1 text-left text-[26rpx] text-[#232338]"
|
||||||
|
|
@ -559,31 +435,25 @@ defineExpose({
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
<!-- 姓名 -->
|
<!-- Name -->
|
||||||
<view class="mb-[32rpx]">
|
<view class="mb-[32rpx]">
|
||||||
<text class="mb-[16rpx] block text-[28rpx] text-[#232338] font-medium">
|
<text class="mb-[16rpx] block text-[28rpx] text-[#232338] font-medium">
|
||||||
<text class="text-red">
|
* Name
|
||||||
*
|
|
||||||
</text>
|
|
||||||
{{ t('voiceprint.name') }}
|
|
||||||
</text>
|
</text>
|
||||||
<input
|
<input
|
||||||
v-model="editForm.sourceName"
|
v-model="editForm.sourceName"
|
||||||
class="box-border h-[80rpx] w-full border-[1rpx] border-[#eeeeee] rounded-[12rpx] bg-[#f5f7fb] p-[16rpx_20rpx] text-[28rpx] text-[#232338] leading-[1.4] outline-none focus:border-[#336cff] focus:bg-white placeholder:text-[#9d9ea3]"
|
class="box-border h-[80rpx] w-full border-[1rpx] border-[#eeeeee] rounded-[12rpx] bg-[#f5f7fb] p-[16rpx_20rpx] text-[28rpx] text-[#232338] leading-[1.4] outline-none focus:border-[#336cff] focus:bg-white placeholder:text-[#9d9ea3]"
|
||||||
type="text" :placeholder="t('voiceprint.pleaseInputName')"
|
type="text" placeholder="Please enter name"
|
||||||
>
|
>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
<!-- 描述 -->
|
<!-- Description -->
|
||||||
<view>
|
<view>
|
||||||
<text class="mb-[16rpx] block text-[28rpx] text-[#232338] font-medium">
|
<text class="mb-[16rpx] block text-[28rpx] text-[#232338] font-medium">
|
||||||
<text class="text-red">
|
* Description
|
||||||
*
|
|
||||||
</text>
|
|
||||||
{{ t('voiceprint.description') }}
|
|
||||||
</text>
|
</text>
|
||||||
<textarea
|
<textarea
|
||||||
v-model="editForm.introduce" :maxlength="100" :placeholder="t('voiceprint.pleaseInputDescription')"
|
v-model="editForm.introduce" :maxlength="100" placeholder="Please enter description"
|
||||||
class="box-border h-[200rpx] w-full resize-none border-[1rpx] border-[#eeeeee] rounded-[12rpx] bg-[#f5f7fb] p-[20rpx] text-[26rpx] text-[#232338] leading-[1.6] outline-none focus:border-[#336cff] focus:bg-white placeholder:text-[#9d9ea3]"
|
class="box-border h-[200rpx] w-full resize-none border-[1rpx] border-[#eeeeee] rounded-[12rpx] bg-[#f5f7fb] p-[20rpx] text-[26rpx] text-[#232338] leading-[1.6] outline-none focus:border-[#336cff] focus:bg-white placeholder:text-[#9d9ea3]"
|
||||||
/>
|
/>
|
||||||
<view class="mt-[8rpx] text-right text-[22rpx] text-[#9d9ea3]">
|
<view class="mt-[8rpx] text-right text-[22rpx] text-[#9d9ea3]">
|
||||||
|
|
@ -594,42 +464,23 @@ defineExpose({
|
||||||
|
|
||||||
<view class="flex gap-[16rpx] border-t-[2rpx] border-[#eeeeee] p-[24rpx_32rpx_32rpx]">
|
<view class="flex gap-[16rpx] border-t-[2rpx] border-[#eeeeee] p-[24rpx_32rpx_32rpx]">
|
||||||
<wd-button type="info" custom-class="flex-1" @click="showEditDialog = false">
|
<wd-button type="info" custom-class="flex-1" @click="showEditDialog = false">
|
||||||
{{ t('voiceprint.cancel') }}
|
Cancel
|
||||||
</wd-button>
|
</wd-button>
|
||||||
<wd-button type="primary" custom-class="flex-1" @click="submitEdit">
|
<wd-button type="primary" custom-class="flex-1" @click="submitEdit">
|
||||||
{{ t('voiceprint.save') }}
|
Save
|
||||||
</wd-button>
|
</wd-button>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</wd-popup>
|
</wd-popup>
|
||||||
|
|
||||||
<!-- 自定义语音对话记录选择弹出层 -->
|
<!-- Voice chat history selection action panel -->
|
||||||
<wd-popup v-model="showChatHistoryDialog" class="custom-popup" position="bottom" @close="stopAudio">
|
<wd-action-sheet
|
||||||
<view class="rounded-[20rpx] bg-white pb-[20rpx] pt-[20rpx]">
|
v-model="showChatHistoryDialog" :actions="chatHistoryActions" title="Select Voiceprint Vector"
|
||||||
<view class="max-h-[600rpx] overflow-y-auto rounded-[20rpx]">
|
@select="selectAudioId"
|
||||||
<view
|
|
||||||
v-for="item in chatHistoryActions"
|
|
||||||
:key="item.audioId"
|
|
||||||
class="flex items-center justify-between border-b border-[#f5f5f5] p-[32rpx] transition-all active:bg-[#f5f7fb]"
|
|
||||||
@click="handleItemClick(item)"
|
|
||||||
>
|
|
||||||
<text class="flex-1 text-[28rpx] text-[#232338]">
|
|
||||||
{{ item.name }}
|
|
||||||
</text>
|
|
||||||
<view class="ml-[20rpx]" @click.stop="playAudio(item.audioId, $event)">
|
|
||||||
<wd-icon
|
|
||||||
:name="playingAudioId === item.audioId ? 'pause-circle' : 'play-circle'"
|
|
||||||
size="24px"
|
|
||||||
:custom-class="playingAudioId === item.audioId ? 'text-[#336cff]' : 'text-[#9d9ea3]'"
|
|
||||||
/>
|
/>
|
||||||
</view>
|
|
||||||
</view>
|
|
||||||
</view>
|
|
||||||
</view>
|
|
||||||
</wd-popup>
|
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<style lang="scss" scoped>
|
<style scoped>
|
||||||
.voiceprint-container {
|
.voiceprint-container {
|
||||||
position: relative;
|
position: relative;
|
||||||
}
|
}
|
||||||
|
|
@ -648,10 +499,14 @@ defineExpose({
|
||||||
color: #666666;
|
color: #666666;
|
||||||
}
|
}
|
||||||
|
|
||||||
::v-deep .custom-popup {
|
:deep(.wd-swipe-action) {
|
||||||
.wd-popup {
|
border-radius: 20rpx;
|
||||||
padding: 20rpx !important;
|
overflow: hidden;
|
||||||
background: transparent;
|
box-shadow: 0 2rpx 12rpx rgba(0, 0, 0, 0.04);
|
||||||
|
border: 1rpx solid #eeeeee;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
:deep(.flex-1) {
|
||||||
|
flex: 1;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,8 @@
|
||||||
/**
|
/**
|
||||||
* by 菲鸽 on 2024-03-06
|
* by Feige on 2024-03-06
|
||||||
* 路由拦截,通常也是登录拦截
|
* Route interception, usually also login interception
|
||||||
* 可以设置路由白名单,或者黑名单,看业务需要选哪一个
|
* Can set route whitelist or blacklist, choose based on business needs
|
||||||
* 我这里应为大部分都可以随便进入,所以使用黑名单
|
* Here most pages can be accessed freely, so using blacklist
|
||||||
*/
|
*/
|
||||||
import { useUserStore } from '@/store'
|
import { useUserStore } from '@/store'
|
||||||
import { needLoginPages as _needLoginPages, getLastPage, getNeedLoginPages } from '@/utils'
|
import { needLoginPages as _needLoginPages, getLastPage, getNeedLoginPages } from '@/utils'
|
||||||
|
|
@ -17,16 +17,16 @@ function isLogined() {
|
||||||
|
|
||||||
const isDev = import.meta.env.DEV
|
const isDev = import.meta.env.DEV
|
||||||
|
|
||||||
// 黑名单登录拦截器 - (适用于大部分页面不需要登录,少部分页面需要登录)
|
// Blacklist login interceptor - (suitable for most pages not requiring login, few pages requiring login)
|
||||||
const navigateToInterceptor = {
|
const navigateToInterceptor = {
|
||||||
// 注意,这里的url是 '/' 开头的,如 '/pages/index/index',跟 'pages.json' 里面的 path 不同
|
// Note, the url here starts with '/', like '/pages/index/index', different from path in 'pages.json'
|
||||||
// 增加对相对路径的处理,BY 网友 @ideal
|
// Add handling for relative paths, BY netizen @ideal
|
||||||
invoke({ url }: { url: string }) {
|
invoke({ url }: { url: string }) {
|
||||||
// console.log(url) // /pages/route-interceptor/index?name=feige&age=30
|
// console.log(url) // /pages/route-interceptor/index?name=feige&age=30
|
||||||
let path = url.split('?')[0]
|
let path = url.split('?')[0]
|
||||||
console.log('页面变动')
|
console.log('Page change')
|
||||||
|
|
||||||
// 处理相对路径
|
// Handle relative paths
|
||||||
if (!path.startsWith('/')) {
|
if (!path.startsWith('/')) {
|
||||||
const currentPath = getLastPage().route
|
const currentPath = getLastPage().route
|
||||||
const normalizedCurrentPath = currentPath.startsWith('/') ? currentPath : `/${currentPath}`
|
const normalizedCurrentPath = currentPath.startsWith('/') ? currentPath : `/${currentPath}`
|
||||||
|
|
@ -35,7 +35,7 @@ const navigateToInterceptor = {
|
||||||
}
|
}
|
||||||
|
|
||||||
let needLoginPages: string[] = []
|
let needLoginPages: string[] = []
|
||||||
// 为了防止开发时出现BUG,这里每次都获取一下。生产环境可以移到函数外,性能更好
|
// To prevent bugs during development, get it every time here. In production environment, it can be moved outside the function for better performance
|
||||||
if (isDev) {
|
if (isDev) {
|
||||||
needLoginPages = getNeedLoginPages()
|
needLoginPages = getNeedLoginPages()
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<svg id="_图层_2" data-name="图层 2" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 113.39 113.39">
|
<svg id="_layer_2" data-name="layer 2" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 113.39 113.39">
|
||||||
<defs>
|
<defs>
|
||||||
<style>
|
<style>
|
||||||
.cls-1 {
|
.cls-1 {
|
||||||
|
|
@ -15,7 +15,7 @@
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
</defs>
|
</defs>
|
||||||
<g id="_图层_1-2" data-name="图层 1">
|
<g id="_layer_1-2" data-name="layer 1">
|
||||||
<g>
|
<g>
|
||||||
<rect class="cls-1" width="113.39" height="113.39" />
|
<rect class="cls-1" width="113.39" height="113.39" />
|
||||||
<g>
|
<g>
|
||||||
|
|
|
||||||
|
Before Width: | Height: | Size: 1.6 KiB After Width: | Height: | Size: 1.6 KiB |
|
|
@ -1,9 +1,9 @@
|
||||||
import type { PublicConfig } from '@/api/auth'
|
import type { PublicConfig } from '@/api/auth'
|
||||||
import { getPublicConfig } from '@/api/auth'
|
|
||||||
import { defineStore } from 'pinia'
|
import { defineStore } from 'pinia'
|
||||||
import { ref } from 'vue'
|
import { ref } from 'vue'
|
||||||
|
import { getPublicConfig } from '@/api/auth'
|
||||||
|
|
||||||
// 初始化状态
|
// Initialize state
|
||||||
const initialConfigState: PublicConfig = {
|
const initialConfigState: PublicConfig = {
|
||||||
enableMobileRegister: false,
|
enableMobileRegister: false,
|
||||||
version: '',
|
version: '',
|
||||||
|
|
@ -12,22 +12,21 @@ const initialConfigState: PublicConfig = {
|
||||||
mobileAreaList: [],
|
mobileAreaList: [],
|
||||||
beianIcpNum: '',
|
beianIcpNum: '',
|
||||||
beianGaNum: '',
|
beianGaNum: '',
|
||||||
sm2PublicKey: '',
|
|
||||||
name: import.meta.env.VITE_APP_TITLE,
|
name: import.meta.env.VITE_APP_TITLE,
|
||||||
}
|
}
|
||||||
|
|
||||||
export const useConfigStore = defineStore(
|
export const useConfigStore = defineStore(
|
||||||
'config',
|
'config',
|
||||||
() => {
|
() => {
|
||||||
// 定义全局配置
|
// Define global configuration
|
||||||
const config = ref<PublicConfig>({ ...initialConfigState })
|
const config = ref<PublicConfig>({ ...initialConfigState })
|
||||||
|
|
||||||
// 设置配置信息
|
// Set configuration info
|
||||||
const setConfig = (val: PublicConfig) => {
|
const setConfig = (val: PublicConfig) => {
|
||||||
config.value = val
|
config.value = val
|
||||||
}
|
}
|
||||||
|
|
||||||
// 获取公共配置
|
// Get public configuration
|
||||||
const fetchPublicConfig = async () => {
|
const fetchPublicConfig = async () => {
|
||||||
try {
|
try {
|
||||||
const configData = await getPublicConfig()
|
const configData = await getPublicConfig()
|
||||||
|
|
@ -37,12 +36,12 @@ export const useConfigStore = defineStore(
|
||||||
return configData
|
return configData
|
||||||
}
|
}
|
||||||
catch (error) {
|
catch (error) {
|
||||||
console.error('获取公共配置失败:', error)
|
console.error('Failed to get public configuration:', error)
|
||||||
throw error
|
throw error
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 重置配置
|
// Reset configuration
|
||||||
const resetConfig = () => {
|
const resetConfig = () => {
|
||||||
config.value = { ...initialConfigState }
|
config.value = { ...initialConfigState }
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
import { createPinia } from 'pinia'
|
import { createPinia } from 'pinia'
|
||||||
import { createPersistedState } from 'pinia-plugin-persistedstate' // 数据持久化
|
import { createPersistedState } from 'pinia-plugin-persistedstate' // Data persistence
|
||||||
|
|
||||||
const store = createPinia()
|
const store = createPinia()
|
||||||
store.use(
|
store.use(
|
||||||
|
|
@ -15,7 +15,6 @@ export default store
|
||||||
|
|
||||||
export * from './config'
|
export * from './config'
|
||||||
export * from './plugin'
|
export * from './plugin'
|
||||||
export * from './provider'
|
|
||||||
export * from './speedPitch'
|
export * from './speedPitch'
|
||||||
// 模块统一导出
|
// Module unified export
|
||||||
export * from './user'
|
export * from './user'
|
||||||
|
|
|
||||||
|
|
@ -1,25 +1,23 @@
|
||||||
import { ref } from 'vue'
|
import { ref } from 'vue'
|
||||||
import { defineStore } from 'pinia'
|
import { defineStore } from 'pinia'
|
||||||
|
|
||||||
// 支持的语言类型
|
// Supported language type
|
||||||
export type Language = 'zh_CN' | 'en' | 'zh_TW' | 'de' | 'vi' | 'pt_BR'
|
export type Language = 'en' | 'de' | 'vi' | 'pt_BR'
|
||||||
|
|
||||||
export interface LangStore {
|
const supportedLanguages: Language[] = ['en', 'de', 'vi', 'pt_BR']
|
||||||
currentLang: Language
|
|
||||||
changeLang: (lang: Language) => void
|
|
||||||
}
|
|
||||||
|
|
||||||
export const useLangStore = defineStore(
|
export const useLangStore = defineStore(
|
||||||
'lang',
|
'lang',
|
||||||
(): LangStore => {
|
() => {
|
||||||
// 从本地存储获取语言设置,如果没有则使用默认值
|
// Get language setting from local storage, fallback to default if missing or unsupported
|
||||||
const savedLang = uni.getStorageSync('app_language') as Language | null
|
const savedLang = uni.getStorageSync('app_language') as string | null
|
||||||
const currentLang = ref<Language>(savedLang || 'zh_CN')
|
const initialLang = supportedLanguages.includes(savedLang as Language) ? (savedLang as Language) : 'en'
|
||||||
|
const currentLang = ref<Language>(initialLang)
|
||||||
|
|
||||||
// 切换语言
|
// Switch language
|
||||||
const changeLang = (lang: Language) => {
|
const changeLang = (lang: Language) => {
|
||||||
currentLang.value = lang
|
currentLang.value = lang
|
||||||
// 将语言设置保存到本地存储
|
// Persist language setting
|
||||||
uni.setStorageSync('app_language', lang)
|
uni.setStorageSync('app_language', lang)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -5,36 +5,36 @@ import { ref } from 'vue'
|
||||||
export const usePluginStore = defineStore(
|
export const usePluginStore = defineStore(
|
||||||
'plugin',
|
'plugin',
|
||||||
() => {
|
() => {
|
||||||
// 所有可用插件
|
// All available plugins
|
||||||
const allFunctions = ref<PluginDefinition[]>([])
|
const allFunctions = ref<PluginDefinition[]>([])
|
||||||
|
|
||||||
// 当前智能体的插件配置
|
// Current agent plugin configuration
|
||||||
const currentFunctions = ref<AgentFunction[]>([])
|
const currentFunctions = ref<AgentFunction[]>([])
|
||||||
|
|
||||||
// 当前编辑的智能体ID
|
// Currently editing agent ID
|
||||||
const currentAgentId = ref('')
|
const currentAgentId = ref('')
|
||||||
|
|
||||||
// 设置所有可用插件
|
// Set all available plugins
|
||||||
const setAllFunctions = (functions: PluginDefinition[]) => {
|
const setAllFunctions = (functions: PluginDefinition[]) => {
|
||||||
allFunctions.value = functions
|
allFunctions.value = functions
|
||||||
}
|
}
|
||||||
|
|
||||||
// 设置当前智能体的插件配置
|
// Set current agent plugin configuration
|
||||||
const setCurrentFunctions = (functions: AgentFunction[]) => {
|
const setCurrentFunctions = (functions: AgentFunction[]) => {
|
||||||
currentFunctions.value = functions
|
currentFunctions.value = functions
|
||||||
}
|
}
|
||||||
|
|
||||||
// 设置当前智能体ID
|
// Set current agent ID
|
||||||
const setCurrentAgentId = (agentId: string) => {
|
const setCurrentAgentId = (agentId: string) => {
|
||||||
currentAgentId.value = agentId
|
currentAgentId.value = agentId
|
||||||
}
|
}
|
||||||
|
|
||||||
// 更新插件配置(用于保存时调用)
|
// Update plugin configuration (called when saving)
|
||||||
const updateFunctions = (functions: AgentFunction[]) => {
|
const updateFunctions = (functions: AgentFunction[]) => {
|
||||||
currentFunctions.value = functions
|
currentFunctions.value = functions
|
||||||
}
|
}
|
||||||
|
|
||||||
// 清空数据
|
// Clear data
|
||||||
const clear = () => {
|
const clear = () => {
|
||||||
allFunctions.value = []
|
allFunctions.value = []
|
||||||
currentFunctions.value = []
|
currentFunctions.value = []
|
||||||
|
|
@ -53,6 +53,6 @@ export const usePluginStore = defineStore(
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
persist: false, // 不持久化,每次进入页面重新加载
|
persist: false, // Not persistent, reload every time entering page
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,14 @@
|
||||||
import type { Providers } from '@/api/agent/types'
|
|
||||||
import { defineStore } from 'pinia'
|
import { defineStore } from 'pinia'
|
||||||
|
|
||||||
export const useProvider = defineStore('provider', () => {
|
export interface ContextProvider {
|
||||||
const providers = ref<Providers[]>([])
|
url: string
|
||||||
|
headers: Record<string, string>
|
||||||
|
}
|
||||||
|
|
||||||
const updateProviders = (val: Providers[]) => {
|
export const useProvider = defineStore('provider', () => {
|
||||||
|
const providers = ref<ContextProvider[]>([])
|
||||||
|
|
||||||
|
const updateProviders = (val: ContextProvider[]) => {
|
||||||
providers.value = val
|
providers.value = val
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@ import {
|
||||||
getUserInfo as _getUserInfo,
|
getUserInfo as _getUserInfo,
|
||||||
} from '@/api/auth'
|
} from '@/api/auth'
|
||||||
|
|
||||||
// 初始化状态
|
// Initialize state
|
||||||
const userInfoState: UserInfo & { avatar?: string, token?: string } = {
|
const userInfoState: UserInfo & { avatar?: string, token?: string } = {
|
||||||
id: 0,
|
id: 0,
|
||||||
username: '',
|
username: '',
|
||||||
|
|
@ -19,14 +19,14 @@ const userInfoState: UserInfo & { avatar?: string, token?: string } = {
|
||||||
}
|
}
|
||||||
|
|
||||||
export const useUserStore = defineStore(
|
export const useUserStore = defineStore(
|
||||||
'userInfo',
|
'user',
|
||||||
() => {
|
() => {
|
||||||
// 定义用户信息
|
// Define user info
|
||||||
const userInfo = ref<UserInfo & { avatar?: string, token?: string }>({ ...userInfoState })
|
const userInfo = ref<UserInfo & { avatar?: string, token?: string }>({ ...userInfoState })
|
||||||
// 设置用户信息
|
// Set user info
|
||||||
const setUserInfo = (val: UserInfo & { avatar?: string, token?: string }) => {
|
const setUserInfo = (val: UserInfo & { avatar?: string, token?: string }) => {
|
||||||
console.log('设置用户信息', val)
|
console.log('Set user info', val)
|
||||||
// 若头像为空 则使用默认头像
|
// If avatar is empty, use default avatar
|
||||||
if (!val.avatar) {
|
if (!val.avatar) {
|
||||||
val.avatar = userInfoState.avatar
|
val.avatar = userInfoState.avatar
|
||||||
}
|
}
|
||||||
|
|
@ -37,25 +37,32 @@ export const useUserStore = defineStore(
|
||||||
}
|
}
|
||||||
const setUserAvatar = (avatar: string) => {
|
const setUserAvatar = (avatar: string) => {
|
||||||
userInfo.value.avatar = avatar
|
userInfo.value.avatar = avatar
|
||||||
console.log('设置用户头像', avatar)
|
console.log('Set user avatar', avatar)
|
||||||
console.log('userInfo', userInfo.value)
|
console.log('userInfo', userInfo.value)
|
||||||
}
|
}
|
||||||
// 删除用户信息
|
// Delete user info
|
||||||
const removeUserInfo = () => {
|
const removeUserInfo = () => {
|
||||||
userInfo.value = { ...userInfoState }
|
userInfo.value = { ...userInfoState }
|
||||||
uni.removeStorageSync('userInfo')
|
uni.removeStorageSync('userInfo')
|
||||||
uni.removeStorageSync('token')
|
uni.removeStorageSync('token')
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* 获取用户信息
|
* Get user info
|
||||||
*/
|
*/
|
||||||
const getUserInfo = async () => {
|
const getUserInfo = async () => {
|
||||||
const userData = await _getUserInfo()
|
const userData = await _getUserInfo()
|
||||||
setUserInfo(userData)
|
const userInfoWithExtras = {
|
||||||
return userData
|
...userData,
|
||||||
|
avatar: userInfoState.avatar,
|
||||||
|
token: uni.getStorageSync('token') || '',
|
||||||
|
}
|
||||||
|
setUserInfo(userInfoWithExtras)
|
||||||
|
uni.setStorageSync('userInfo', userInfoWithExtras)
|
||||||
|
// TODO Can add method to get user routes here, dynamically generate routes based on user role
|
||||||
|
return userInfoWithExtras
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* 退出登录 并 删除用户信息
|
* Logout and delete user info
|
||||||
*/
|
*/
|
||||||
const logout = async () => {
|
const logout = async () => {
|
||||||
removeUserInfo()
|
removeUserInfo()
|
||||||
|
|
@ -71,12 +78,6 @@ export const useUserStore = defineStore(
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
persist: {
|
persist: true,
|
||||||
key: 'userInfo',
|
|
||||||
serializer: {
|
|
||||||
serialize: state => JSON.stringify(state.userInfo),
|
|
||||||
deserialize: value => ({ userInfo: JSON.parse(value) }),
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,8 @@
|
||||||
// 测试用的 iconfont,可生效
|
// Test iconfont, can take effect
|
||||||
// @import './iconfont.css';
|
// @import './iconfont.css';
|
||||||
|
|
||||||
.test {
|
.test {
|
||||||
// 可以通过 @apply 多个样式封装整体样式
|
// Can use @apply to encapsulate multiple styles into overall styles
|
||||||
@apply mt-4 ml-4;
|
@apply mt-4 ml-4;
|
||||||
|
|
||||||
padding-top: 4px;
|
padding-top: 4px;
|
||||||
|
|
@ -11,9 +11,9 @@
|
||||||
|
|
||||||
:root,
|
:root,
|
||||||
page {
|
page {
|
||||||
// 修改按主题色
|
// Modify by theme color
|
||||||
// --wot-color-theme: #37c2bc;
|
// --wot-color-theme: #37c2bc;
|
||||||
|
|
||||||
// 修改按钮背景色
|
// Modify button background color
|
||||||
// --wot-button-primary-bg-color: green;
|
// --wot-button-primary-bg-color: green;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
8
main/manager-mobile/src/typings.d.ts
vendored
8
main/manager-mobile/src/typings.d.ts
vendored
|
|
@ -1,4 +1,4 @@
|
||||||
// 全局要用的类型放到这里
|
// Global types used here
|
||||||
|
|
||||||
declare global {
|
declare global {
|
||||||
interface IResData<T> {
|
interface IResData<T> {
|
||||||
|
|
@ -7,7 +7,7 @@ declare global {
|
||||||
data: T
|
data: T
|
||||||
}
|
}
|
||||||
|
|
||||||
// uni.uploadFile文件上传参数
|
// uni.uploadFile file upload parameters
|
||||||
interface IUniUploadFileOptions {
|
interface IUniUploadFileOptions {
|
||||||
file?: File
|
file?: File
|
||||||
files?: UniApp.UploadFileOptionFiles[]
|
files?: UniApp.UploadFileOptionFiles[]
|
||||||
|
|
@ -19,10 +19,10 @@ declare global {
|
||||||
interface IUserInfo {
|
interface IUserInfo {
|
||||||
nickname?: string
|
nickname?: string
|
||||||
avatar?: string
|
avatar?: string
|
||||||
/** 微信的 openid,非微信没有这个字段 */
|
/** WeChat openid, non-WeChat does not have this field */
|
||||||
openid?: string
|
openid?: string
|
||||||
token?: string
|
token?: string
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export {} // 防止模块污染
|
export {} // Prevent module pollution
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,11 @@
|
||||||
// 枚举定义
|
// Enum definitions
|
||||||
|
|
||||||
export enum TestEnum {
|
export enum TestEnum {
|
||||||
A = '1',
|
A = '1',
|
||||||
B = '2',
|
B = '2',
|
||||||
}
|
}
|
||||||
|
|
||||||
// uni.uploadFile文件上传参数
|
// uni.uploadFile file upload parameters
|
||||||
export interface IUniUploadFileOptions {
|
export interface IUniUploadFileOptions {
|
||||||
file?: File
|
file?: File
|
||||||
files?: UniApp.UploadFileOptionFiles[]
|
files?: UniApp.UploadFileOptionFiles[]
|
||||||
|
|
|
||||||
|
|
@ -1,50 +1,50 @@
|
||||||
/* stylelint-disable comment-empty-line-before */
|
/* stylelint-disable comment-empty-line-before */
|
||||||
/**
|
/**
|
||||||
* 这里是uni-app内置的常用样式变量
|
* Here are uni-app built-in common style variables
|
||||||
*
|
*
|
||||||
* uni-app 官方扩展插件及插件市场(https://ext.dcloud.net.cn)上很多三方插件均使用了这些样式变量
|
* Many third-party plugins on uni-app official extension plugins and plugin market (https://ext.dcloud.net.cn) use these style variables
|
||||||
* 如果你是插件开发者,建议你使用scss预处理,并在插件代码中直接使用这些变量(无需 import 这个文件),方便用户通过搭积木的方式开发整体风格一致的App
|
* If you are a plugin developer, it is recommended to use scss preprocessing and directly use these variables in plugin code (no need to import this file), making it convenient for users to develop Apps with consistent overall style through building blocks
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 如果你是App开发者(插件使用者),你可以通过修改这些变量来定制自己的插件主题,实现自定义主题功能
|
* If you are an App developer (plugin user), you can customize your plugin theme by modifying these variables to achieve custom theme functionality
|
||||||
*
|
*
|
||||||
* 如果你的项目同样使用了scss预处理,你也可以直接在你的 scss 代码中使用如下变量,同时无需 import 这个文件
|
* If your project also uses scss preprocessing, you can directly use the following variables in your scss code without importing this file
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* 颜色变量 */
|
/* Color variables */
|
||||||
|
|
||||||
/* 行为相关颜色 */
|
/* Behavior related colors */
|
||||||
$uni-color-primary: #007aff;
|
$uni-color-primary: #007aff;
|
||||||
$uni-color-success: #4cd964;
|
$uni-color-success: #4cd964;
|
||||||
$uni-color-warning: #f0ad4e;
|
$uni-color-warning: #f0ad4e;
|
||||||
$uni-color-error: #dd524d;
|
$uni-color-error: #dd524d;
|
||||||
|
|
||||||
/* 文字基本颜色 */
|
/* Basic text colors */
|
||||||
$uni-text-color: #333; // 基本色
|
$uni-text-color: #333; // Basic color
|
||||||
$uni-text-color-inverse: #fff; // 反色
|
$uni-text-color-inverse: #fff; // Inverse color
|
||||||
$uni-text-color-grey: #999; // 辅助灰色,如加载更多的提示信息
|
$uni-text-color-grey: #999; // Auxiliary grey, such as load more prompt info
|
||||||
$uni-text-color-placeholder: #808080;
|
$uni-text-color-placeholder: #808080;
|
||||||
$uni-text-color-disable: #c0c0c0;
|
$uni-text-color-disable: #c0c0c0;
|
||||||
|
|
||||||
/* 背景颜色 */
|
/* Background colors */
|
||||||
$uni-bg-color: #fff;
|
$uni-bg-color: #fff;
|
||||||
$uni-bg-color-grey: #f8f8f8;
|
$uni-bg-color-grey: #f8f8f8;
|
||||||
$uni-bg-color-hover: #f1f1f1; // 点击状态颜色
|
$uni-bg-color-hover: #f1f1f1; // Click state color
|
||||||
$uni-bg-color-mask: rgb(0 0 0 / 40%); // 遮罩颜色
|
$uni-bg-color-mask: rgb(0 0 0 / 40%); // Mask color
|
||||||
|
|
||||||
/* 边框颜色 */
|
/* Border colors */
|
||||||
$uni-border-color: #c8c7cc;
|
$uni-border-color: #c8c7cc;
|
||||||
|
|
||||||
/* 尺寸变量 */
|
/* Size variables */
|
||||||
|
|
||||||
/* 文字尺寸 */
|
/* Text sizes */
|
||||||
$uni-font-size-sm: 12px;
|
$uni-font-size-sm: 12px;
|
||||||
$uni-font-size-base: 14px;
|
$uni-font-size-base: 14px;
|
||||||
$uni-font-size-lg: 16;
|
$uni-font-size-lg: 16;
|
||||||
|
|
||||||
/* 图片尺寸 */
|
/* Image sizes */
|
||||||
$uni-img-size-sm: 20px;
|
$uni-img-size-sm: 20px;
|
||||||
$uni-img-size-base: 26px;
|
$uni-img-size-base: 26px;
|
||||||
$uni-img-size-lg: 40px;
|
$uni-img-size-lg: 40px;
|
||||||
|
|
@ -55,23 +55,23 @@ $uni-border-radius-base: 3px;
|
||||||
$uni-border-radius-lg: 6px;
|
$uni-border-radius-lg: 6px;
|
||||||
$uni-border-radius-circle: 50%;
|
$uni-border-radius-circle: 50%;
|
||||||
|
|
||||||
/* 水平间距 */
|
/* Horizontal spacing */
|
||||||
$uni-spacing-row-sm: 5px;
|
$uni-spacing-row-sm: 5px;
|
||||||
$uni-spacing-row-base: 10px;
|
$uni-spacing-row-base: 10px;
|
||||||
$uni-spacing-row-lg: 15px;
|
$uni-spacing-row-lg: 15px;
|
||||||
|
|
||||||
/* 垂直间距 */
|
/* Vertical spacing */
|
||||||
$uni-spacing-col-sm: 4px;
|
$uni-spacing-col-sm: 4px;
|
||||||
$uni-spacing-col-base: 8px;
|
$uni-spacing-col-base: 8px;
|
||||||
$uni-spacing-col-lg: 12px;
|
$uni-spacing-col-lg: 12px;
|
||||||
|
|
||||||
/* 透明度 */
|
/* Opacity */
|
||||||
$uni-opacity-disabled: 0.3; // 组件禁用态的透明度
|
$uni-opacity-disabled: 0.3; // Component disabled state opacity
|
||||||
|
|
||||||
/* 文章场景相关 */
|
/* Article scenario related */
|
||||||
$uni-color-title: #2c405a; // 文章标题颜色
|
$uni-color-title: #2c405a; // Article title color
|
||||||
$uni-font-size-title: 20px;
|
$uni-font-size-title: 20px;
|
||||||
$uni-color-subtitle: #555; // 二级标题颜色
|
$uni-color-subtitle: #555; // Secondary title color
|
||||||
$uni-font-size-subtitle: 18px;
|
$uni-font-size-subtitle: 18px;
|
||||||
$uni-color-paragraph: #3f536e; // 文章段落颜色
|
$uni-color-paragraph: #3f536e; // Article paragraph color
|
||||||
$uni-font-size-paragraph: 15px;
|
$uni-font-size-paragraph: 15px;
|
||||||
|
|
|
||||||
|
|
@ -1,15 +1,14 @@
|
||||||
import smCrypto from 'sm-crypto'
|
|
||||||
import { pages, subPackages } from '@/pages.json'
|
import { pages, subPackages } from '@/pages.json'
|
||||||
|
import { sm2 } from 'sm-crypto'
|
||||||
import { isMpWeixin } from './platform'
|
import { isMpWeixin } from './platform'
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 运行时服务端地址覆盖存储键
|
* Runtime server address override storage key
|
||||||
*/
|
*/
|
||||||
export const SERVER_BASE_URL_OVERRIDE_KEY = 'server_base_url_override'
|
export const SERVER_BASE_URL_OVERRIDE_KEY = 'server_base_url_override'
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 设置/清除/获取 运行时覆盖的服务端地址
|
* Set/clear/get runtime override server address
|
||||||
*/
|
*/
|
||||||
export function setServerBaseUrlOverride(url: string) {
|
export function setServerBaseUrlOverride(url: string) {
|
||||||
uni.setStorageSync(SERVER_BASE_URL_OVERRIDE_KEY, url)
|
uni.setStorageSync(SERVER_BASE_URL_OVERRIDE_KEY, url)
|
||||||
|
|
@ -24,18 +23,23 @@ export function getServerBaseUrlOverride(): string | null {
|
||||||
return value || null
|
return value || null
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function sm2Encrypt(publicKey: string, plainText: string) {
|
||||||
|
const normalizedKey = publicKey.trim().replace(/^0x/i, '').replace(/^04/i, '')
|
||||||
|
return sm2.doEncrypt(plainText, normalizedKey, 1)
|
||||||
|
}
|
||||||
|
|
||||||
export function getLastPage() {
|
export function getLastPage() {
|
||||||
// getCurrentPages() 至少有1个元素,所以不再额外判断
|
// getCurrentPages() has at least 1 element, so no additional check needed
|
||||||
// const lastPage = getCurrentPages().at(-1)
|
// const lastPage = getCurrentPages().at(-1)
|
||||||
// 上面那个在低版本安卓中打包会报错,所以改用下面这个【虽然我加了 src/interceptions/prototype.ts,但依然报错】
|
// The above will cause errors in low version Android builds, so use the one below [Although I added src/interceptions/prototype.ts, it still reports errors]
|
||||||
const pages = getCurrentPages()
|
const pages = getCurrentPages()
|
||||||
return pages[pages.length - 1]
|
return pages[pages.length - 1]
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取当前页面路由的 path 路径和 redirectPath 路径
|
* Get current page route path and redirectPath
|
||||||
* path 如 '/pages/login/index'
|
* path like '/pages/login/index'
|
||||||
* redirectPath 如 '/pages/demo/base/route-interceptor'
|
* redirectPath like '/pages/demo/base/route-interceptor'
|
||||||
*/
|
*/
|
||||||
export function currRoute() {
|
export function currRoute() {
|
||||||
const lastPage = getLastPage()
|
const lastPage = getLastPage()
|
||||||
|
|
@ -44,10 +48,10 @@ export function currRoute() {
|
||||||
// console.log('lastPage.$page.fullpath:', currRoute.fullPath)
|
// console.log('lastPage.$page.fullpath:', currRoute.fullPath)
|
||||||
// console.log('lastPage.$page.options:', currRoute.options)
|
// console.log('lastPage.$page.options:', currRoute.options)
|
||||||
// console.log('lastPage.options:', (lastPage as any).options)
|
// console.log('lastPage.options:', (lastPage as any).options)
|
||||||
// 经过多端测试,只有 fullPath 靠谱,其他都不靠谱
|
// After multi-platform testing, only fullPath is reliable, others are not
|
||||||
const { fullPath } = currRoute as { fullPath: string }
|
const { fullPath } = currRoute as { fullPath: string }
|
||||||
// console.log(fullPath)
|
// console.log(fullPath)
|
||||||
// eg: /pages/login/index?redirect=%2Fpages%2Fdemo%2Fbase%2Froute-interceptor (小程序)
|
// eg: /pages/login/index?redirect=%2Fpages%2Fdemo%2Fbase%2Froute-interceptor (mini program)
|
||||||
// eg: /pages/login/index?redirect=%2Fpages%2Froute-interceptor%2Findex%3Fname%3Dfeige%26age%3D30(h5)
|
// eg: /pages/login/index?redirect=%2Fpages%2Froute-interceptor%2Findex%3Fname%3Dfeige%26age%3D30(h5)
|
||||||
return getUrlObj(fullPath)
|
return getUrlObj(fullPath)
|
||||||
}
|
}
|
||||||
|
|
@ -59,9 +63,9 @@ function ensureDecodeURIComponent(url: string) {
|
||||||
return url
|
return url
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* 解析 url 得到 path 和 query
|
* Parse url to get path and query
|
||||||
* 比如输入url: /pages/login/index?redirect=%2Fpages%2Fdemo%2Fbase%2Froute-interceptor
|
* For example input url: /pages/login/index?redirect=%2Fpages%2Fdemo%2Fbase%2Froute-interceptor
|
||||||
* 输出: {path: /pages/login/index, query: {redirect: /pages/demo/base/route-interceptor}}
|
* Output: {path: /pages/login/index, query: {redirect: /pages/demo/base/route-interceptor}}
|
||||||
*/
|
*/
|
||||||
export function getUrlObj(url: string) {
|
export function getUrlObj(url: string) {
|
||||||
const [path, queryStr] = url.split('?')
|
const [path, queryStr] = url.split('?')
|
||||||
|
|
@ -77,17 +81,17 @@ export function getUrlObj(url: string) {
|
||||||
queryStr.split('&').forEach((item) => {
|
queryStr.split('&').forEach((item) => {
|
||||||
const [key, value] = item.split('=')
|
const [key, value] = item.split('=')
|
||||||
// console.log(key, value)
|
// console.log(key, value)
|
||||||
query[key] = ensureDecodeURIComponent(value) // 这里需要统一 decodeURIComponent 一下,可以兼容h5和微信y
|
query[key] = ensureDecodeURIComponent(value) // Need to uniformly decodeURIComponent here to be compatible with h5 and WeChat
|
||||||
})
|
})
|
||||||
return { path, query }
|
return { path, query }
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* 得到所有的需要登录的 pages,包括主包和分包的
|
* Get all pages that need login, including main package and sub-packages
|
||||||
* 这里设计得通用一点,可以传递 key 作为判断依据,默认是 needLogin, 与 route-block 配对使用
|
* Designed to be more generic, can pass key as judgment basis, default is needLogin, used in pairs with route-block
|
||||||
* 如果没有传 key,则表示所有的 pages,如果传递了 key, 则表示通过 key 过滤
|
* If no key is passed, it means all pages; if key is passed, it means filter by key
|
||||||
*/
|
*/
|
||||||
export function getAllPages(key = 'needLogin') {
|
export function getAllPages(key = 'needLogin') {
|
||||||
// 这里处理主包
|
// Handle main package here
|
||||||
const mainPages = pages
|
const mainPages = pages
|
||||||
.filter(page => !key || page[key])
|
.filter(page => !key || page[key])
|
||||||
.map(page => ({
|
.map(page => ({
|
||||||
|
|
@ -95,7 +99,7 @@ export function getAllPages(key = 'needLogin') {
|
||||||
path: `/${page.path}`,
|
path: `/${page.path}`,
|
||||||
}))
|
}))
|
||||||
|
|
||||||
// 这里处理分包
|
// Handle sub-packages here
|
||||||
const subPages: any[] = []
|
const subPages: any[] = []
|
||||||
subPackages.forEach((subPageObj) => {
|
subPackages.forEach((subPageObj) => {
|
||||||
// console.log(subPageObj)
|
// console.log(subPageObj)
|
||||||
|
|
@ -116,35 +120,35 @@ export function getAllPages(key = 'needLogin') {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 得到所有的需要登录的 pages,包括主包和分包的
|
* Get all pages that need login, including main package and sub-packages
|
||||||
* 只得到 path 数组
|
* Only get path array
|
||||||
*/
|
*/
|
||||||
export const getNeedLoginPages = (): string[] => getAllPages('needLogin').map(page => page.path)
|
export const getNeedLoginPages = (): string[] => getAllPages('needLogin').map(page => page.path)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 得到所有的需要登录的 pages,包括主包和分包的
|
* Get all pages that need login, including main package and sub-packages
|
||||||
* 只得到 path 数组
|
* Only get path array
|
||||||
*/
|
*/
|
||||||
export const needLoginPages: string[] = getAllPages('needLogin').map(page => page.path)
|
export const needLoginPages: string[] = getAllPages('needLogin').map(page => page.path)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据微信小程序当前环境,判断应该获取的 baseUrl
|
* Determine the baseUrl to get based on WeChat mini program current environment
|
||||||
*/
|
*/
|
||||||
export function getEnvBaseUrl() {
|
export function getEnvBaseUrl() {
|
||||||
// 若存在用户设置的覆盖地址,优先返回
|
// If user-set override address exists, return it first
|
||||||
const override = getServerBaseUrlOverride()
|
const override = getServerBaseUrlOverride()
|
||||||
if (override)
|
if (override)
|
||||||
return override
|
return override
|
||||||
|
|
||||||
// 请求基准地址(默认来源于 env)
|
// Request base address (default from env)
|
||||||
let baseUrl = import.meta.env.VITE_SERVER_BASEURL
|
let baseUrl = import.meta.env.VITE_SERVER_BASEURL
|
||||||
|
|
||||||
// # 有些同学可能需要在微信小程序里面根据 develop、trial、release 分别设置上传地址,参考代码如下。
|
// # Some students may need to set upload addresses separately for develop, trial, release in WeChat mini program, reference code below.
|
||||||
const VITE_SERVER_BASEURL__WEIXIN_DEVELOP = 'https://ukw0y1.laf.run'
|
const VITE_SERVER_BASEURL__WEIXIN_DEVELOP = 'https://ukw0y1.laf.run'
|
||||||
const VITE_SERVER_BASEURL__WEIXIN_TRIAL = 'https://ukw0y1.laf.run'
|
const VITE_SERVER_BASEURL__WEIXIN_TRIAL = 'https://ukw0y1.laf.run'
|
||||||
const VITE_SERVER_BASEURL__WEIXIN_RELEASE = 'https://ukw0y1.laf.run'
|
const VITE_SERVER_BASEURL__WEIXIN_RELEASE = 'https://ukw0y1.laf.run'
|
||||||
|
|
||||||
// 微信小程序端环境区分
|
// WeChat mini program environment distinction
|
||||||
if (isMpWeixin) {
|
if (isMpWeixin) {
|
||||||
const {
|
const {
|
||||||
miniProgram: { envVersion },
|
miniProgram: { envVersion },
|
||||||
|
|
@ -167,17 +171,17 @@ export function getEnvBaseUrl() {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据微信小程序当前环境,判断应该获取的 UPLOAD_BASEURL
|
* Determine the UPLOAD_BASEURL to get based on WeChat mini program current environment
|
||||||
*/
|
*/
|
||||||
export function getEnvBaseUploadUrl() {
|
export function getEnvBaseUploadUrl() {
|
||||||
// 请求基准地址
|
// Request base address
|
||||||
let baseUploadUrl = import.meta.env.VITE_UPLOAD_BASEURL
|
let baseUploadUrl = import.meta.env.VITE_UPLOAD_BASEURL
|
||||||
|
|
||||||
const VITE_UPLOAD_BASEURL__WEIXIN_DEVELOP = 'https://ukw0y1.laf.run/upload'
|
const VITE_UPLOAD_BASEURL__WEIXIN_DEVELOP = 'https://ukw0y1.laf.run/upload'
|
||||||
const VITE_UPLOAD_BASEURL__WEIXIN_TRIAL = 'https://ukw0y1.laf.run/upload'
|
const VITE_UPLOAD_BASEURL__WEIXIN_TRIAL = 'https://ukw0y1.laf.run/upload'
|
||||||
const VITE_UPLOAD_BASEURL__WEIXIN_RELEASE = 'https://ukw0y1.laf.run/upload'
|
const VITE_UPLOAD_BASEURL__WEIXIN_RELEASE = 'https://ukw0y1.laf.run/upload'
|
||||||
|
|
||||||
// 微信小程序端环境区分
|
// WeChat mini program environment distinction
|
||||||
if (isMpWeixin) {
|
if (isMpWeixin) {
|
||||||
const {
|
const {
|
||||||
miniProgram: { envVersion },
|
miniProgram: { envVersion },
|
||||||
|
|
@ -200,57 +204,45 @@ export function getEnvBaseUploadUrl() {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 生成SM2密钥对(十六进制格式)
|
* Generate an SM2 key pair (hex-encoded), matching upstream xiaozhi crypto layout.
|
||||||
* @returns {Object} 包含公钥和私钥的对象
|
|
||||||
*/
|
*/
|
||||||
export function generateSm2KeyPairHex() {
|
export function generateSm2KeyPairHex() {
|
||||||
// 使用sm-crypto库生成SM2密钥对
|
|
||||||
const sm2 = smCrypto.sm2
|
const sm2 = smCrypto.sm2
|
||||||
const keypair = sm2.generateKeyPairHex()
|
const keypair = sm2.generateKeyPairHex()
|
||||||
|
|
||||||
return {
|
return {
|
||||||
publicKey: keypair.publicKey,
|
publicKey: keypair.publicKey,
|
||||||
privateKey: keypair.privateKey,
|
privateKey: keypair.privateKey,
|
||||||
clientPublicKey: keypair.publicKey, // 客户端公钥
|
clientPublicKey: keypair.publicKey,
|
||||||
clientPrivateKey: keypair.privateKey, // 客户端私钥
|
clientPrivateKey: keypair.privateKey,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* SM2公钥加密
|
* SM2 public-key encryption (hex in/out). Prepends 0x04 to match backend expectations.
|
||||||
* @param {string} publicKey 公钥(十六进制格式)
|
|
||||||
* @param {string} plainText 明文
|
|
||||||
* @returns {string} 加密后的密文(十六进制格式)
|
|
||||||
*/
|
*/
|
||||||
export function sm2Encrypt(publicKey: string, plainText: string): string {
|
export function sm2Encrypt(publicKey: string, plainText: string): string {
|
||||||
if (!publicKey) {
|
if (!publicKey) {
|
||||||
throw new Error('公钥不能为null或undefined')
|
throw new Error('Public key cannot be null or undefined')
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!plainText) {
|
if (!plainText) {
|
||||||
throw new Error('明文不能为空')
|
throw new Error('Plaintext cannot be empty')
|
||||||
}
|
}
|
||||||
|
|
||||||
const sm2 = smCrypto.sm2
|
const sm2 = smCrypto.sm2
|
||||||
// SM2加密,添加04前缀表示未压缩公钥
|
|
||||||
const encrypted = sm2.doEncrypt(plainText, publicKey, 1)
|
const encrypted = sm2.doEncrypt(plainText, publicKey, 1)
|
||||||
// 转换为十六进制格式(与后端保持一致,添加04前缀)
|
|
||||||
const result = `04${encrypted}`
|
const result = `04${encrypted}`
|
||||||
|
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* SM2私钥解密
|
* SM2 private-key decryption (hex). Strips a leading 04 prefix if present.
|
||||||
* @param {string} privateKey 私钥(十六进制格式)
|
|
||||||
* @param {string} cipherText 密文(十六进制格式)
|
|
||||||
* @returns {string} 解密后的明文
|
|
||||||
*/
|
*/
|
||||||
export function sm2Decrypt(privateKey: string, cipherText: string): string {
|
export function sm2Decrypt(privateKey: string, cipherText: string): string {
|
||||||
const sm2 = smCrypto.sm2
|
const sm2 = smCrypto.sm2
|
||||||
// 移除04前缀(与后端保持一致)
|
|
||||||
const dataWithoutPrefix = cipherText.startsWith('04') ? cipherText.substring(2) : cipherText
|
const dataWithoutPrefix = cipherText.startsWith('04') ? cipherText.substring(2) : cipherText
|
||||||
// SM2解密
|
|
||||||
return sm2.doDecrypt(dataWithoutPrefix, privateKey, 1)
|
return sm2.doDecrypt(dataWithoutPrefix, privateKey, 1)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -261,11 +253,11 @@ interface DebouncedFunction extends AnyFunction {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 防抖函数
|
* Debounce a function.
|
||||||
* @param fn 要防抖的函数
|
* @param fn function to debounce
|
||||||
* @param delay 延迟时间(毫秒),默认500ms
|
* @param delay delay in milliseconds, defaults to 500ms
|
||||||
* @param immediate 是否立即执行,默认false
|
* @param immediate whether to run immediately, defaults to false
|
||||||
* @returns 防抖处理后的函数
|
* @returns debounced function
|
||||||
*/
|
*/
|
||||||
export function debounce<T extends AnyFunction>(
|
export function debounce<T extends AnyFunction>(
|
||||||
fn: T,
|
fn: T,
|
||||||
|
|
@ -304,9 +296,9 @@ export function debounce<T extends AnyFunction>(
|
||||||
type DeepCloneTarget = string | number | boolean | null | undefined | object
|
type DeepCloneTarget = string | number | boolean | null | undefined | object
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 深拷贝方法
|
* Deep-clone a value.
|
||||||
* @param target 要拷贝的目标
|
* @param target target value to clone
|
||||||
* @returns 拷贝后的新对象
|
* @returns cloned value
|
||||||
*/
|
*/
|
||||||
export function deepClone<T extends DeepCloneTarget>(target: T): T {
|
export function deepClone<T extends DeepCloneTarget>(target: T): T {
|
||||||
if (target === null || typeof target !== 'object') {
|
if (target === null || typeof target !== 'object') {
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
/*
|
/*
|
||||||
* @Author: 菲鸽
|
* @Author: Feige
|
||||||
* @Date: 2024-03-28 19:13:55
|
* @Date: 2024-03-28 19:13:55
|
||||||
* @Last Modified by: 菲鸽
|
* @Last Modified by: Feige
|
||||||
* @Last Modified time: 2024-03-28 19:24:55
|
* @Last Modified time: 2024-03-28 19:24:55
|
||||||
*/
|
*/
|
||||||
export const platform = __UNI_PLATFORM__
|
export const platform = __UNI_PLATFORM__
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
/**
|
/**
|
||||||
* toast 弹窗组件
|
* Toast popup component
|
||||||
* 支持 success/error/warning/info 四种状态
|
* Supports success/error/warning/info four states
|
||||||
* 可配置 duration, position 等参数
|
* Configurable duration, position and other parameters
|
||||||
*/
|
*/
|
||||||
|
|
||||||
type ToastType = 'success' | 'error' | 'warning' | 'info'
|
type ToastType = 'success' | 'error' | 'warning' | 'info'
|
||||||
|
|
@ -25,14 +25,14 @@ export function showToast(options: ToastOptions | string) {
|
||||||
= typeof options === 'string'
|
= typeof options === 'string'
|
||||||
? { ...defaultOptions, message: options }
|
? { ...defaultOptions, message: options }
|
||||||
: { ...defaultOptions, ...options }
|
: { ...defaultOptions, ...options }
|
||||||
// 映射position到uniapp支持的格式
|
// Map position to uniapp supported format
|
||||||
const positionMap: Record<ToastOptions['position'], 'top' | 'bottom' | 'center'> = {
|
const positionMap: Record<ToastOptions['position'], 'top' | 'bottom' | 'center'> = {
|
||||||
top: 'top',
|
top: 'top',
|
||||||
middle: 'center',
|
middle: 'center',
|
||||||
bottom: 'bottom',
|
bottom: 'bottom',
|
||||||
}
|
}
|
||||||
|
|
||||||
// 映射图标类型
|
// Map icon type
|
||||||
const iconMap: Record<
|
const iconMap: Record<
|
||||||
ToastType,
|
ToastType,
|
||||||
'success' | 'error' | 'none' | 'loading' | 'fail' | 'exception'
|
'success' | 'error' | 'none' | 'loading' | 'fail' | 'exception'
|
||||||
|
|
@ -43,7 +43,7 @@ export function showToast(options: ToastOptions | string) {
|
||||||
info: 'none',
|
info: 'none',
|
||||||
}
|
}
|
||||||
|
|
||||||
// 调用uni.showToast显示提示
|
// Call uni.showToast to display prompt
|
||||||
uni.showToast({
|
uni.showToast({
|
||||||
title: mergedOptions.message,
|
title: mergedOptions.message,
|
||||||
duration: mergedOptions.duration,
|
duration: mergedOptions.duration,
|
||||||
|
|
|
||||||
|
|
@ -1,38 +1,39 @@
|
||||||
|
import type { Ref } from 'vue'
|
||||||
import { getEnvBaseUrl } from './index'
|
import { getEnvBaseUrl } from './index'
|
||||||
import { toast } from './toast'
|
import { toast } from './toast'
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 文件上传钩子函数使用示例
|
* File upload hook function usage example
|
||||||
* @example
|
* @example
|
||||||
* const { loading, error, data, progress, run } = useUpload<IUploadResult>(
|
* const { loading, error, data, progress, run } = useUpload<IUploadResult>(
|
||||||
* uploadUrl,
|
* uploadUrl,
|
||||||
* {},
|
* {},
|
||||||
* {
|
* {
|
||||||
* maxSize: 5, // 最大5MB
|
* maxSize: 5, // Maximum 5MB
|
||||||
* sourceType: ['album'], // 仅支持从相册选择
|
* sourceType: ['album'], // Only support selection from album
|
||||||
* onProgress: (p) => console.log(`上传进度:${p}%`),
|
* onProgress: (p) => console.log(`Upload progress: ${p}%`),
|
||||||
* onSuccess: (res) => console.log('上传成功', res),
|
* onSuccess: (res) => console.log('Upload successful', res),
|
||||||
* onError: (err) => console.error('上传失败', err),
|
* onError: (err) => console.error('Upload failed', err),
|
||||||
* },
|
* },
|
||||||
* )
|
* )
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 上传文件的URL配置
|
* Upload file URL configuration
|
||||||
*/
|
*/
|
||||||
export const uploadFileUrl = {
|
export const uploadFileUrl = {
|
||||||
/** 用户头像上传地址(动态读取当前生效的 BaseURL) */
|
/** User avatar upload address (dynamically read current effective BaseURL) */
|
||||||
get USER_AVATAR() {
|
get USER_AVATAR() {
|
||||||
return `${getEnvBaseUrl()}/user/avatar`
|
return `${getEnvBaseUrl()}/user/avatar`
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 通用文件上传函数(支持直接传入文件路径)
|
* General file upload function (supports direct file path input)
|
||||||
* @param url 上传地址
|
* @param url Upload address
|
||||||
* @param filePath 本地文件路径
|
* @param filePath Local file path
|
||||||
* @param formData 额外表单数据
|
* @param formData Additional form data
|
||||||
* @param options 上传选项
|
* @param options Upload options
|
||||||
*/
|
*/
|
||||||
export function useFileUpload<T = string>(url: string, filePath: string, formData: Record<string, any> = {}, options: Omit<UploadOptions, 'sourceType' | 'sizeType' | 'count'> = {}) {
|
export function useFileUpload<T = string>(url: string, filePath: string, formData: Record<string, any> = {}, options: Omit<UploadOptions, 'sourceType' | 'sizeType' | 'count'> = {}) {
|
||||||
return useUpload<T>(
|
return useUpload<T>(
|
||||||
|
|
@ -48,86 +49,86 @@ export function useFileUpload<T = string>(url: string, filePath: string, formDat
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface UploadOptions {
|
export interface UploadOptions {
|
||||||
/** 最大可选择的图片数量,默认为1 */
|
/** Maximum selectable image count, default is 1 */
|
||||||
count?: number
|
count?: number
|
||||||
/** 所选的图片的尺寸,original-原图,compressed-压缩图 */
|
/** Selected image size, original-original, compressed-compressed */
|
||||||
sizeType?: Array<'original' | 'compressed'>
|
sizeType?: Array<'original' | 'compressed'>
|
||||||
/** 选择图片的来源,album-相册,camera-相机 */
|
/** Image source, album-album, camera-camera */
|
||||||
sourceType?: Array<'album' | 'camera'>
|
sourceType?: Array<'album' | 'camera'>
|
||||||
/** 文件大小限制,单位:MB */
|
/** File size limit, unit: MB */
|
||||||
maxSize?: number //
|
maxSize?: number //
|
||||||
/** 上传进度回调函数 */
|
/** Upload progress callback function */
|
||||||
onProgress?: (progress: number) => void
|
onProgress?: (progress: number) => void
|
||||||
/** 上传成功回调函数 */
|
/** Upload success callback function */
|
||||||
onSuccess?: (res: Record<string, any>) => void
|
onSuccess?: (res: Record<string, any>) => void
|
||||||
/** 上传失败回调函数 */
|
/** Upload failure callback function */
|
||||||
onError?: (err: Error | UniApp.GeneralCallbackResult) => void
|
onError?: (err: Error | UniApp.GeneralCallbackResult) => void
|
||||||
/** 上传完成回调函数(无论成功失败) */
|
/** Upload complete callback function (regardless of success or failure) */
|
||||||
onComplete?: () => void
|
onComplete?: () => void
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 文件上传钩子函数
|
* File upload hook function
|
||||||
* @template T 上传成功后返回的数据类型
|
* @template T Data type returned after successful upload
|
||||||
* @param url 上传地址
|
* @param url Upload address
|
||||||
* @param formData 额外的表单数据
|
* @param formData Additional form data
|
||||||
* @param options 上传选项
|
* @param options Upload options
|
||||||
* @returns 上传状态和控制对象
|
* @returns Upload status and control object
|
||||||
*/
|
*/
|
||||||
export function useUpload<T = string>(url: string, formData: Record<string, any> = {}, options: UploadOptions = {},
|
export function useUpload<T = string>(url: string, formData: Record<string, any> = {}, options: UploadOptions = {},
|
||||||
/** 直接传入文件路径,跳过选择器 */
|
/** Pass file path directly, skip selector */
|
||||||
directFilePath?: string) {
|
directFilePath?: string) {
|
||||||
/** 上传中状态 */
|
/** Uploading status */
|
||||||
const loading = ref(false)
|
const loading = ref(false)
|
||||||
/** 上传错误状态 */
|
/** Upload error status */
|
||||||
const error = ref(false)
|
const error = ref(false)
|
||||||
/** 上传成功后的响应数据 */
|
/** Response data after successful upload */
|
||||||
const data = ref<T>()
|
const data = ref<T>()
|
||||||
/** 上传进度(0-100) */
|
/** Upload progress (0-100) */
|
||||||
const progress = ref(0)
|
const progress = ref(0)
|
||||||
|
|
||||||
/** 解构上传选项,设置默认值 */
|
/** Destructure upload options, set default values */
|
||||||
const {
|
const {
|
||||||
/** 最大可选择的图片数量 */
|
/** Maximum selectable image count */
|
||||||
count = 1,
|
count = 1,
|
||||||
/** 所选的图片的尺寸 */
|
/** Selected image dimensions */
|
||||||
sizeType = ['original', 'compressed'],
|
sizeType = ['original', 'compressed'],
|
||||||
/** 选择图片的来源 */
|
/** Image selection source */
|
||||||
sourceType = ['album', 'camera'],
|
sourceType = ['album', 'camera'],
|
||||||
/** 文件大小限制(MB) */
|
/** File size limit (MB) */
|
||||||
maxSize = 10,
|
maxSize = 10,
|
||||||
/** 进度回调 */
|
/** Progress callback */
|
||||||
onProgress,
|
onProgress,
|
||||||
/** 成功回调 */
|
/** Success callback */
|
||||||
onSuccess,
|
onSuccess,
|
||||||
/** 失败回调 */
|
/** Failure callback */
|
||||||
onError,
|
onError,
|
||||||
/** 完成回调 */
|
/** Complete callback */
|
||||||
onComplete,
|
onComplete,
|
||||||
} = options
|
} = options
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 检查文件大小是否超过限制
|
* Check if file size exceeds limit
|
||||||
* @param size 文件大小(字节)
|
* @param size File size (bytes)
|
||||||
* @returns 是否通过检查
|
* @returns Whether passes check
|
||||||
*/
|
*/
|
||||||
const checkFileSize = (size: number) => {
|
const checkFileSize = (size: number) => {
|
||||||
const sizeInMB = size / 1024 / 1024
|
const sizeInMB = size / 1024 / 1024
|
||||||
if (sizeInMB > maxSize) {
|
if (sizeInMB > maxSize) {
|
||||||
toast.warning(`文件大小不能超过${maxSize}MB`)
|
toast.warning(`File size cannot exceed ${maxSize}MB`)
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* 触发文件选择和上传
|
* Trigger file selection and upload
|
||||||
* 根据平台使用不同的选择器:
|
* Use different selectors based on platform:
|
||||||
* - 微信小程序使用 chooseMedia
|
* - WeChat Mini Program uses chooseMedia
|
||||||
* - 其他平台使用 chooseImage
|
* - Other platforms use chooseImage
|
||||||
*/
|
*/
|
||||||
const run = () => {
|
const run = () => {
|
||||||
if (directFilePath) {
|
if (directFilePath) {
|
||||||
// 直接使用传入的文件路径
|
// Directly use passed file path
|
||||||
loading.value = true
|
loading.value = true
|
||||||
progress.value = 0
|
progress.value = 0
|
||||||
uploadFile<T>({
|
uploadFile<T>({
|
||||||
|
|
@ -147,18 +148,18 @@ export function useUpload<T = string>(url: string, formData: Record<string, any>
|
||||||
}
|
}
|
||||||
|
|
||||||
// #ifdef MP-WEIXIN
|
// #ifdef MP-WEIXIN
|
||||||
// 微信小程序环境下使用 chooseMedia API
|
// Use chooseMedia API in WeChat Mini Program environment
|
||||||
uni.chooseMedia({
|
uni.chooseMedia({
|
||||||
count,
|
count,
|
||||||
mediaType: ['image'], // 仅支持图片类型
|
mediaType: ['image'], // Only support image type
|
||||||
sourceType,
|
sourceType,
|
||||||
success: (res) => {
|
success: (res) => {
|
||||||
const file = res.tempFiles[0]
|
const file = res.tempFiles[0]
|
||||||
// 检查文件大小是否符合限制
|
// Check if file size meets limit
|
||||||
if (!checkFileSize(file.size))
|
if (!checkFileSize(file.size))
|
||||||
return
|
return
|
||||||
|
|
||||||
// 开始上传
|
// Start upload
|
||||||
loading.value = true
|
loading.value = true
|
||||||
progress.value = 0
|
progress.value = 0
|
||||||
uploadFile<T>({
|
uploadFile<T>({
|
||||||
|
|
@ -176,7 +177,7 @@ export function useUpload<T = string>(url: string, formData: Record<string, any>
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
fail: (err) => {
|
fail: (err) => {
|
||||||
console.error('选择媒体文件失败:', err)
|
console.error('Failed to select media file:', err)
|
||||||
error.value = true
|
error.value = true
|
||||||
onError?.(err)
|
onError?.(err)
|
||||||
},
|
},
|
||||||
|
|
@ -184,15 +185,15 @@ export function useUpload<T = string>(url: string, formData: Record<string, any>
|
||||||
// #endif
|
// #endif
|
||||||
|
|
||||||
// #ifndef MP-WEIXIN
|
// #ifndef MP-WEIXIN
|
||||||
// 非微信小程序环境下使用 chooseImage API
|
// Use chooseImage API in non-WeChat Mini Program environment
|
||||||
uni.chooseImage({
|
uni.chooseImage({
|
||||||
count,
|
count,
|
||||||
sizeType,
|
sizeType,
|
||||||
sourceType,
|
sourceType,
|
||||||
success: (res) => {
|
success: (res) => {
|
||||||
console.log('选择图片成功:', res)
|
console.log('Image selection successful:', res)
|
||||||
|
|
||||||
// 开始上传
|
// Start upload
|
||||||
loading.value = true
|
loading.value = true
|
||||||
progress.value = 0
|
progress.value = 0
|
||||||
uploadFile<T>({
|
uploadFile<T>({
|
||||||
|
|
@ -210,7 +211,7 @@ export function useUpload<T = string>(url: string, formData: Record<string, any>
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
fail: (err) => {
|
fail: (err) => {
|
||||||
console.error('选择图片失败:', err)
|
console.error('Image selection failed:', err)
|
||||||
error.value = true
|
error.value = true
|
||||||
onError?.(err)
|
onError?.(err)
|
||||||
},
|
},
|
||||||
|
|
@ -222,38 +223,38 @@ export function useUpload<T = string>(url: string, formData: Record<string, any>
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 文件上传选项接口
|
* File upload options interface
|
||||||
* @template T 上传成功后返回的数据类型
|
* @template T Data type returned after successful upload
|
||||||
*/
|
*/
|
||||||
interface UploadFileOptions<T> {
|
interface UploadFileOptions<T> {
|
||||||
/** 上传地址 */
|
/** Upload URL */
|
||||||
url: string
|
url: string
|
||||||
/** 临时文件路径 */
|
/** Temporary file path */
|
||||||
tempFilePath: string
|
tempFilePath: string
|
||||||
/** 额外的表单数据 */
|
/** Additional form data */
|
||||||
formData: Record<string, any>
|
formData: Record<string, any>
|
||||||
/** 上传成功后的响应数据 */
|
/** Response data after successful upload */
|
||||||
data: Ref<T | undefined>
|
data: Ref<T | undefined>
|
||||||
/** 上传错误状态 */
|
/** Upload error status */
|
||||||
error: Ref<boolean>
|
error: Ref<boolean>
|
||||||
/** 上传中状态 */
|
/** Uploading status */
|
||||||
loading: Ref<boolean>
|
loading: Ref<boolean>
|
||||||
/** 上传进度(0-100) */
|
/** Upload progress (0-100) */
|
||||||
progress: Ref<number>
|
progress: Ref<number>
|
||||||
/** 上传进度回调 */
|
/** Upload progress callback */
|
||||||
onProgress?: (progress: number) => void
|
onProgress?: (progress: number) => void
|
||||||
/** 上传成功回调 */
|
/** Upload success callback */
|
||||||
onSuccess?: (res: Record<string, any>) => void
|
onSuccess?: (res: Record<string, any>) => void
|
||||||
/** 上传失败回调 */
|
/** Upload failure callback */
|
||||||
onError?: (err: Error | UniApp.GeneralCallbackResult) => void
|
onError?: (err: Error | UniApp.GeneralCallbackResult) => void
|
||||||
/** 上传完成回调 */
|
/** Upload complete callback */
|
||||||
onComplete?: () => void
|
onComplete?: () => void
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 执行文件上传
|
* Execute file upload
|
||||||
* @template T 上传成功后返回的数据类型
|
* @template T Data type returned after successful upload
|
||||||
* @param options 上传选项
|
* @param options Upload options
|
||||||
*/
|
*/
|
||||||
function uploadFile<T>({
|
function uploadFile<T>({
|
||||||
url,
|
url,
|
||||||
|
|
@ -269,59 +270,59 @@ function uploadFile<T>({
|
||||||
onComplete,
|
onComplete,
|
||||||
}: UploadFileOptions<T>) {
|
}: UploadFileOptions<T>) {
|
||||||
try {
|
try {
|
||||||
// 创建上传任务
|
// Create upload task
|
||||||
const uploadTask = uni.uploadFile({
|
const uploadTask = uni.uploadFile({
|
||||||
url,
|
url,
|
||||||
filePath: tempFilePath,
|
filePath: tempFilePath,
|
||||||
name: 'file', // 文件对应的 key
|
name: 'file', // Key corresponding to file
|
||||||
formData,
|
formData,
|
||||||
header: {
|
header: {
|
||||||
// H5环境下不需要手动设置Content-Type,让浏览器自动处理multipart格式
|
// In H5 environment, no need to manually set Content-Type, let browser handle multipart format
|
||||||
// #ifndef H5
|
// #ifndef H5
|
||||||
'Content-Type': 'multipart/form-data',
|
'Content-Type': 'multipart/form-data',
|
||||||
// #endif
|
// #endif
|
||||||
},
|
},
|
||||||
// 确保文件名称合法
|
// Ensure file name is valid
|
||||||
success: (uploadFileRes) => {
|
success: (uploadFileRes) => {
|
||||||
console.log('上传文件成功:', uploadFileRes)
|
console.log('File upload successful:', uploadFileRes)
|
||||||
try {
|
try {
|
||||||
// 解析响应数据
|
// Parse response data
|
||||||
const { data: _data } = JSON.parse(uploadFileRes.data)
|
const { data: _data } = JSON.parse(uploadFileRes.data)
|
||||||
// 上传成功
|
// Upload successful
|
||||||
data.value = _data as T
|
data.value = _data as T
|
||||||
onSuccess?.(_data)
|
onSuccess?.(_data)
|
||||||
}
|
}
|
||||||
catch (err) {
|
catch (err) {
|
||||||
// 响应解析错误
|
// Response parsing error
|
||||||
console.error('解析上传响应失败:', err)
|
console.error('Failed to parse upload response:', err)
|
||||||
error.value = true
|
error.value = true
|
||||||
onError?.(new Error('上传响应解析失败'))
|
onError?.(new Error('Upload response parsing failed'))
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
fail: (err) => {
|
fail: (err) => {
|
||||||
// 上传请求失败
|
// Upload request failed
|
||||||
console.error('上传文件失败:', err)
|
console.error('File upload failed:', err)
|
||||||
error.value = true
|
error.value = true
|
||||||
onError?.(err)
|
onError?.(err)
|
||||||
},
|
},
|
||||||
complete: () => {
|
complete: () => {
|
||||||
// 无论成功失败都执行
|
// Execute regardless of success or failure
|
||||||
loading.value = false
|
loading.value = false
|
||||||
onComplete?.()
|
onComplete?.()
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
// 监听上传进度
|
// Listen to upload progress
|
||||||
uploadTask.onProgressUpdate((res) => {
|
uploadTask.onProgressUpdate((res) => {
|
||||||
progress.value = res.progress
|
progress.value = res.progress
|
||||||
onProgress?.(res.progress)
|
onProgress?.(res.progress)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
catch (err) {
|
catch (err) {
|
||||||
// 创建上传任务失败
|
// Create upload task failed
|
||||||
console.error('创建上传任务失败:', err)
|
console.error('Failed to create upload task:', err)
|
||||||
error.value = true
|
error.value = true
|
||||||
loading.value = false
|
loading.value = false
|
||||||
onError?.(new Error('创建上传任务失败'))
|
onError?.(new Error('Failed to create upload task'))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,20 +1,22 @@
|
||||||
{
|
{
|
||||||
"compilerOptions": {
|
"compilerOptions": {
|
||||||
"composite": true,
|
"composite": true,
|
||||||
|
"target": "ES2015",
|
||||||
"lib": ["esnext", "dom"],
|
"lib": ["esnext", "dom"],
|
||||||
"baseUrl": ".",
|
"baseUrl": ".",
|
||||||
"module": "ESNext",
|
"module": "ESNext",
|
||||||
"moduleResolution": "Node",
|
"moduleResolution": "Node",
|
||||||
"paths": {
|
"paths": {
|
||||||
"@/*": ["./src/*"],
|
"@/*": ["./src/*"],
|
||||||
"@img/*": ["./src/static/*"]
|
"@img/*": ["./src/static/*"],
|
||||||
|
"wot-design-uni": ["./src/types/wot-design-uni-api.d.ts"],
|
||||||
|
"wot-design-uni/components/wd-toast": ["./src/types/wot-design-uni-toast.d.ts"]
|
||||||
},
|
},
|
||||||
"resolveJsonModule": true,
|
"resolveJsonModule": true,
|
||||||
"types": [
|
"types": [
|
||||||
"@dcloudio/types",
|
"@dcloudio/types",
|
||||||
"@uni-helper/uni-types",
|
"@uni-helper/uni-types",
|
||||||
"@types/wechat-miniprogram",
|
"@types/wechat-miniprogram",
|
||||||
"wot-design-uni/global.d.ts",
|
|
||||||
"z-paging/types",
|
"z-paging/types",
|
||||||
"./src/typings.d.ts"
|
"./src/typings.d.ts"
|
||||||
],
|
],
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,7 @@ export default defineConfig({
|
||||||
presets: [
|
presets: [
|
||||||
presetUni({
|
presetUni({
|
||||||
attributify: {
|
attributify: {
|
||||||
// prefix: 'fg-', // 如果加前缀,则需要在代码里面使用 `fg-` 前缀,如:<div fg-border="1px solid #000"></div>
|
// prefix: 'fg-', // If adding prefix, need to use `fg-` prefix in code, eg: <div fg-border="1px solid #000"></div>
|
||||||
prefixedOnly: true,
|
prefixedOnly: true,
|
||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
|
|
@ -24,14 +24,14 @@ export default defineConfig({
|
||||||
'vertical-align': 'middle',
|
'vertical-align': 'middle',
|
||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
// 支持css class属性化
|
// Support CSS class attributes
|
||||||
presetAttributify(),
|
presetAttributify(),
|
||||||
],
|
],
|
||||||
transformers: [
|
transformers: [
|
||||||
// 启用指令功能:主要用于支持 @apply、@screen 和 theme() 等 CSS 指令
|
// Enable directive functions: mainly for supporting @apply, @screen and theme() CSS directives
|
||||||
transformerDirectives(),
|
transformerDirectives(),
|
||||||
// 启用 () 分组功能
|
// Enable () grouping functionality
|
||||||
// 支持css class组合,eg: `<div class="hover:(bg-gray-400 font-medium) font-(light mono)">测试 unocss</div>`
|
// Support CSS class combinations, eg: `<div class="hover:(bg-gray-400 font-medium) font-(light mono)">test unocss</div>`
|
||||||
transformerVariantGroup(),
|
transformerVariantGroup(),
|
||||||
],
|
],
|
||||||
shortcuts: [
|
shortcuts: [
|
||||||
|
|
@ -53,11 +53,11 @@ export default defineConfig({
|
||||||
],
|
],
|
||||||
theme: {
|
theme: {
|
||||||
colors: {
|
colors: {
|
||||||
/** 主题色,用法如: text-primary */
|
/** Theme color, usage: text-primary */
|
||||||
primary: 'var(--wot-color-theme,#0957DE)',
|
primary: 'var(--wot-color-theme,#0957DE)',
|
||||||
},
|
},
|
||||||
fontSize: {
|
fontSize: {
|
||||||
/** 提供更小号的字体,用法如:text-2xs */
|
/** Provide smaller font size, usage: text-2xs */
|
||||||
'2xs': ['20rpx', '28rpx'],
|
'2xs': ['20rpx', '28rpx'],
|
||||||
'3xs': ['18rpx', '26rpx'],
|
'3xs': ['18rpx', '26rpx'],
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -9,10 +9,10 @@ import UniManifest from '@uni-helper/vite-plugin-uni-manifest'
|
||||||
// @see https://uni-helper.js.org/vite-plugin-uni-pages
|
// @see https://uni-helper.js.org/vite-plugin-uni-pages
|
||||||
import UniPages from '@uni-helper/vite-plugin-uni-pages'
|
import UniPages from '@uni-helper/vite-plugin-uni-pages'
|
||||||
// @see https://github.com/uni-helper/vite-plugin-uni-platform
|
// @see https://github.com/uni-helper/vite-plugin-uni-platform
|
||||||
// 需要与 @uni-helper/vite-plugin-uni-pages 插件一起使用
|
// Need to use with @uni-helper/vite-plugin-uni-pages plugin
|
||||||
import UniPlatform from '@uni-helper/vite-plugin-uni-platform'
|
import UniPlatform from '@uni-helper/vite-plugin-uni-platform'
|
||||||
/**
|
/**
|
||||||
* 分包优化、模块异步跨包调用、组件异步跨包引用
|
* Sub-package optimization, module async cross-package calls, component async cross-package references
|
||||||
* @see https://github.com/uni-ku/bundle-optimizer
|
* @see https://github.com/uni-ku/bundle-optimizer
|
||||||
*/
|
*/
|
||||||
import Optimization from '@uni-ku/bundle-optimizer'
|
import Optimization from '@uni-ku/bundle-optimizer'
|
||||||
|
|
@ -28,18 +28,18 @@ export default async ({ command, mode }) => {
|
||||||
const UnoCSS = (await import('unocss/vite')).default
|
const UnoCSS = (await import('unocss/vite')).default
|
||||||
// console.log(mode === process.env.NODE_ENV) // true
|
// console.log(mode === process.env.NODE_ENV) // true
|
||||||
|
|
||||||
// mode: 区分生产环境还是开发环境
|
// mode: Distinguish between production and development environment
|
||||||
console.log('command, mode -> ', command, mode)
|
console.log('command, mode -> ', command, mode)
|
||||||
// pnpm dev:h5 时得到 => serve development
|
// pnpm dev:h5 gets => serve development
|
||||||
// pnpm build:h5 时得到 => build production
|
// pnpm build:h5 gets => build production
|
||||||
// pnpm dev:mp-weixin 时得到 => build development (注意区别,command为build)
|
// pnpm dev:mp-weixin gets => build development (note difference, command is build)
|
||||||
// pnpm build:mp-weixin 时得到 => build production
|
// pnpm build:mp-weixin gets => build production
|
||||||
// pnpm dev:app 时得到 => build development (注意区别,command为build)
|
// pnpm dev:app gets => build development (note difference, command is build)
|
||||||
// pnpm build:app 时得到 => build production
|
// pnpm build:app gets => build production
|
||||||
// dev 和 build 命令可以分别使用 .env.development 和 .env.production 的环境变量
|
// dev and build commands can use .env.development and .env.production environment variables respectively
|
||||||
|
|
||||||
const { UNI_PLATFORM } = process.env
|
const { UNI_PLATFORM } = process.env
|
||||||
console.log('UNI_PLATFORM -> ', UNI_PLATFORM) // 得到 mp-weixin, h5, app 等
|
console.log('UNI_PLATFORM -> ', UNI_PLATFORM) // Get mp-weixin, h5, app etc.
|
||||||
|
|
||||||
const env = loadEnv(mode, path.resolve(process.cwd(), 'env'))
|
const env = loadEnv(mode, path.resolve(process.cwd(), 'env'))
|
||||||
const {
|
const {
|
||||||
|
|
@ -51,27 +51,27 @@ export default async ({ command, mode }) => {
|
||||||
VITE_APP_PROXY,
|
VITE_APP_PROXY,
|
||||||
VITE_APP_PROXY_PREFIX,
|
VITE_APP_PROXY_PREFIX,
|
||||||
} = env
|
} = env
|
||||||
console.log('环境变量 env -> ', env)
|
console.log('Environment variables env -> ', env)
|
||||||
|
|
||||||
return defineConfig({
|
return defineConfig({
|
||||||
envDir: './env', // 自定义env目录
|
envDir: './env', // Custom env directory
|
||||||
base: VITE_APP_PUBLIC_BASE,
|
base: VITE_APP_PUBLIC_BASE,
|
||||||
plugins: [
|
plugins: [
|
||||||
UniPages({
|
UniPages({
|
||||||
exclude: ['**/components/**/**.*'],
|
exclude: ['**/components/**/**.*'],
|
||||||
// homePage 通过 vue 文件的 route-block 的type="home"来设定
|
// homePage is set through route-block type="home" in vue files
|
||||||
// pages 目录为 src/pages,分包目录不能配置在pages目录下
|
// pages directory is src/pages, sub-package directories cannot be configured under pages directory
|
||||||
subPackages: ['src/pages-sub'], // 是个数组,可以配置多个,但是不能为pages里面的目录
|
subPackages: ['src/pages-sub'], // It's an array, can configure multiple, but cannot be directories inside pages
|
||||||
dts: 'src/types/uni-pages.d.ts',
|
dts: 'src/types/uni-pages.d.ts',
|
||||||
}),
|
}),
|
||||||
UniLayouts(),
|
UniLayouts(),
|
||||||
UniPlatform(),
|
UniPlatform(),
|
||||||
UniManifest(),
|
UniManifest(),
|
||||||
// UniXXX 需要在 Uni 之前引入
|
// UniXXX needs to be imported before Uni
|
||||||
{
|
{
|
||||||
// 临时解决 dcloudio 官方的 @dcloudio/uni-mp-compiler 出现的编译 BUG
|
// Temporarily fix compilation BUG in dcloudio official @dcloudio/uni-mp-compiler
|
||||||
// 参考 github issue: https://github.com/dcloudio/uni-app/issues/4952
|
// Reference github issue: https://github.com/dcloudio/uni-app/issues/4952
|
||||||
// 自定义插件禁用 vite:vue 插件的 devToolsEnabled,强制编译 vue 模板时 inline 为 true
|
// Custom plugin disables vite:vue plugin devToolsEnabled, forces inline to true when compiling vue templates
|
||||||
name: 'fix-vite-plugin-vue',
|
name: 'fix-vite-plugin-vue',
|
||||||
configResolved(config) {
|
configResolved(config) {
|
||||||
const plugin = config.plugins.find(p => p.name === 'vite:vue')
|
const plugin = config.plugins.find(p => p.name === 'vite:vue')
|
||||||
|
|
@ -84,10 +84,10 @@ export default async ({ command, mode }) => {
|
||||||
AutoImport({
|
AutoImport({
|
||||||
imports: ['vue', 'uni-app'],
|
imports: ['vue', 'uni-app'],
|
||||||
dts: 'src/types/auto-import.d.ts',
|
dts: 'src/types/auto-import.d.ts',
|
||||||
dirs: ['src/hooks'], // 自动导入 hooks
|
dirs: ['src/hooks'], // Auto import hooks
|
||||||
vueTemplate: true, // default false
|
vueTemplate: true, // default false
|
||||||
}),
|
}),
|
||||||
// Optimization 插件需要 page.json 文件,故应在 UniPages 插件之后执行
|
// Optimization plugin needs page.json file, so it should execute after UniPages plugin
|
||||||
Optimization({
|
Optimization({
|
||||||
enable: {
|
enable: {
|
||||||
'optimization': true,
|
'optimization': true,
|
||||||
|
|
@ -101,17 +101,17 @@ export default async ({ command, mode }) => {
|
||||||
}),
|
}),
|
||||||
|
|
||||||
ViteRestart({
|
ViteRestart({
|
||||||
// 通过这个插件,在修改vite.config.js文件则不需要重新运行也生效配置
|
// Through this plugin, modifying vite.config.js file does not need to restart to take effect
|
||||||
restart: ['vite.config.js'],
|
restart: ['vite.config.js'],
|
||||||
}),
|
}),
|
||||||
// h5环境增加 BUILD_TIME 和 BUILD_BRANCH
|
// Add BUILD_TIME and BUILD_BRANCH in h5 environment
|
||||||
UNI_PLATFORM === 'h5' && {
|
UNI_PLATFORM === 'h5' && {
|
||||||
name: 'html-transform',
|
name: 'html-transform',
|
||||||
transformIndexHtml(html) {
|
transformIndexHtml(html) {
|
||||||
return html.replace('%BUILD_TIME%', dayjs().format('YYYY-MM-DD HH:mm:ss'))
|
return html.replace('%BUILD_TIME%', dayjs().format('YYYY-MM-DD HH:mm:ss'))
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
// 打包分析插件,h5 + 生产环境才弹出
|
// Bundle analysis plugin, only pops up in h5 + production environment
|
||||||
UNI_PLATFORM === 'h5'
|
UNI_PLATFORM === 'h5'
|
||||||
&& mode === 'production'
|
&& mode === 'production'
|
||||||
&& visualizer({
|
&& visualizer({
|
||||||
|
|
@ -120,13 +120,13 @@ export default async ({ command, mode }) => {
|
||||||
gzipSize: true,
|
gzipSize: true,
|
||||||
brotliSize: true,
|
brotliSize: true,
|
||||||
}),
|
}),
|
||||||
// 只有在 app 平台时才启用 copyNativeRes 插件
|
// Only enable copyNativeRes plugin on app platform
|
||||||
// UNI_PLATFORM === 'app' && copyNativeRes(),
|
// UNI_PLATFORM === 'app' && copyNativeRes(),
|
||||||
Components({
|
Components({
|
||||||
extensions: ['vue'],
|
extensions: ['vue'],
|
||||||
deep: true, // 是否递归扫描子目录,
|
deep: true, // Whether to recursively scan subdirectories,
|
||||||
directoryAsNamespace: false, // 是否把目录名作为命名空间前缀,true 时组件名为 目录名+组件名,
|
directoryAsNamespace: false, // Whether to use directory name as namespace prefix, when true component name is directory+component name,
|
||||||
dts: 'src/types/components.d.ts', // 自动生成的组件类型声明文件路径(用于 TypeScript 支持)
|
dts: 'src/types/components.d.ts', // Auto-generated component type declaration file path (for TypeScript support)
|
||||||
}),
|
}),
|
||||||
Uni(),
|
Uni(),
|
||||||
],
|
],
|
||||||
|
|
@ -138,7 +138,7 @@ export default async ({ command, mode }) => {
|
||||||
postcss: {
|
postcss: {
|
||||||
plugins: [
|
plugins: [
|
||||||
// autoprefixer({
|
// autoprefixer({
|
||||||
// // 指定目标浏览器
|
// // Specify target browsers
|
||||||
// overrideBrowserslist: ['> 1%', 'last 2 versions'],
|
// overrideBrowserslist: ['> 1%', 'last 2 versions'],
|
||||||
// }),
|
// }),
|
||||||
],
|
],
|
||||||
|
|
@ -155,7 +155,7 @@ export default async ({ command, mode }) => {
|
||||||
host: '0.0.0.0',
|
host: '0.0.0.0',
|
||||||
hmr: true,
|
hmr: true,
|
||||||
port: Number.parseInt(VITE_APP_PORT, 10),
|
port: Number.parseInt(VITE_APP_PORT, 10),
|
||||||
// 仅 H5 端生效,其他端不生效(其他端走build,不走devServer)
|
// Only effective on H5 end, not effective on other ends (other ends use build, not devServer)
|
||||||
proxy: JSON.parse(VITE_APP_PROXY)
|
proxy: JSON.parse(VITE_APP_PROXY)
|
||||||
? {
|
? {
|
||||||
[VITE_APP_PROXY_PREFIX]: {
|
[VITE_APP_PROXY_PREFIX]: {
|
||||||
|
|
@ -171,10 +171,10 @@ export default async ({ command, mode }) => {
|
||||||
},
|
},
|
||||||
build: {
|
build: {
|
||||||
sourcemap: false,
|
sourcemap: false,
|
||||||
// 方便非h5端调试
|
// Convenient for non-h5 debugging
|
||||||
// sourcemap: VITE_SHOW_SOURCEMAP === 'true', // 默认是false
|
// sourcemap: VITE_SHOW_SOURCEMAP === 'true', // default is false
|
||||||
target: 'es6',
|
target: 'es6',
|
||||||
// 开发环境不用压缩
|
// No compression in development environment
|
||||||
minify: mode === 'development' ? false : 'esbuild',
|
minify: mode === 'development' ? false : 'esbuild',
|
||||||
|
|
||||||
},
|
},
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue