diff --git a/xiaoqu-agent-service/README.md b/xiaoqu-agent-service/README.md
index 08dfef8..4b24d43 100644
--- a/xiaoqu-agent-service/README.md
+++ b/xiaoqu-agent-service/README.md
@@ -141,6 +141,7 @@ nohup java -jar target/xiaoqu-agent-service.jar > target/app.log 2>&1 &
- 不提供默认 profile;数据库/Redis 连接信息明文写在 `application-dev.yml`(内网 dev 库,与 xiaoqu-franchisee pom.xml dev profile 同一惯例);生产/测试环境不得在配置文件写明文密码。
- dev 端口 **8088**,管理后台 `http://localhost:8088/`,MCP 端点 `http://localhost:8088/mcp`。
+- 「账号管理」仅内置 `admin` 可见并调用,支持账号添加、编辑、禁用与软删除;编辑时密码留空表示不修改。删除或禁用后已有会话立即失效;不能禁用/删除当前登录账号或最后一个正常账号,内置 `admin` 不可改名。
- Flyway 在 Web 服务启动前执行 `validate + migrate`;checksum、版本或 SQL 执行失败时应用不会启动。
- 新增 SQL 必须遵循 [sql/README.md](sql/README.md),禁止修改已合并的历史 migration。
@@ -258,7 +259,7 @@ curl -X POST http://localhost:8088/api/open/token/ensure \
**服务 Token(principalType=service)**:`serviceName` 必填;只能绑定「允许服务主体」的作用域(`agent_scope.service_enabled=1`,REQ-20260921-0004 起由标记驱动,取代原先的 sync 硬编码),旧版不限域密钥不可签发服务 Token。服务 Token 无用户身份:调 SYNC 变化流工具为全量;调在线查询工具按**总部视角全量可见、不做行过滤**(PermissionService 统一分支),走独立限流档 `app.rate-limit.service-query-per-minute`(默认 300/分钟);`warehouse.todo.list.query` 按当前登录人统计,服务身份调用返回 PERMISSION_DENIED。典型用法:运营后台免登录分页拉取全量数据(scope `ops-query`)。
-**签发规则(2026-09-04 起)**:一作用域一 Token。后台签发时选 N 个作用域会生成 N 把 token,每把独立绑定单作用域;编辑存量 token 时作用域为单选。
+**签发规则(2026-09-04 起)**:后台签发时选 N 个作用域会生成 N 把 Token,每把独立绑定单作用域;编辑存量 Token 时也可多选作用域。Token 列表通过 `agent_api_key.create_id` 展示签发后台账号,Open API 自动签发显示为「系统自动」。
## codegen(run-once)
diff --git a/xiaoqu-agent-service/front/src/App.vue b/xiaoqu-agent-service/front/src/App.vue
index f1ee644..6db8e9c 100644
--- a/xiaoqu-agent-service/front/src/App.vue
+++ b/xiaoqu-agent-service/front/src/App.vue
@@ -5,6 +5,7 @@ import { api, setCsrf } from './api'
const menus = [
{ id: 'tokens', label: '用户与 Token', icon: '👥' },
+ { id: 'accounts', label: '账号管理', icon: '▣' },
{ id: 'clients', label: '服务密钥', icon: '🔐' },
{ id: 'tools', label: '工具管理', icon: '🔧' },
{ id: 'scopes', label: '作用域管理', icon: '🧩' },
@@ -31,8 +32,11 @@ const toolFilter = reactive({ category: '', kind: '', keyword: '' })
const toolPage = reactive({ page: 1, pageSize: 20, total: 0 })
const auditFilter = reactive({ person: '', tokenPrefix: '', tool: '', result: '', client: '', from: '', to: '' })
const tokenDialog = ref(false)
-const tokenForm = reactive({ id: null, memo: '', scopeIds: [], scopeId: null, expireTime: null })
+const tokenForm = reactive({ id: null, memo: '', scopeIds: [], expireTime: null })
const issuedTokens = ref([])
+const accounts = ref([])
+const accountDialog = ref(false)
+const accountForm = reactive({ id: null, account: '', name: '', password: '', status: 1 })
const clientDialog = ref(false)
const clientForm = reactive({ id: null, name: '', memo: '', scopeIds: [] })
const issuedOpenKey = ref(null)
@@ -125,9 +129,11 @@ async function logout() {
}
async function switchMenu(id) {
+ if (id === 'accounts' && session.account !== 'admin') return
if (!openTabs.value.includes(id)) openTabs.value = [...openTabs.value, id]
current.value = id
if (id === 'tokens') await loadUsers()
+ if (id === 'accounts') await loadAccounts()
if (id === 'clients') await loadOpenClients()
if (id === 'tools') await Promise.all([loadTools(), loadAllTools()])
if (id === 'scopes') await loadScopes()
@@ -169,14 +175,14 @@ async function selectUser(user) {
function openToken(token = null) {
Object.assign(tokenForm, token ? {
- id: token.id, memo: token.memo || '', scopeIds: [], scopeId: token.scopeIds[0] ?? null,
+ id: token.id, memo: token.memo || '', scopeIds: [...token.scopeIds],
expireTime: token.expireTime || null,
- } : { id: null, memo: '', scopeIds: [], scopeId: null, expireTime: null })
+ } : { id: null, memo: '', scopeIds: [], expireTime: null })
tokenDialog.value = true
}
async function saveToken() {
- const scopeIds = tokenForm.id ? (tokenForm.scopeId ? [tokenForm.scopeId] : []) : tokenForm.scopeIds
+ const scopeIds = tokenForm.scopeIds
if (!scopeIds.length) return ElMessage.warning('至少选择一个作用域')
await run(async () => {
const body = JSON.stringify({ memo: tokenForm.memo, scopeIds, expireTime: tokenForm.expireTime })
@@ -209,6 +215,48 @@ async function deleteToken(token) {
}).catch(() => {})
}
+async function loadAccounts() {
+ accounts.value = await api('/accounts')
+}
+
+function openAccount(account = null) {
+ Object.assign(accountForm, account ? {
+ id: account.id, account: account.account, name: account.name || '', password: '', status: account.status,
+ } : { id: null, account: '', name: '', password: '', status: 1 })
+ accountDialog.value = true
+}
+
+async function saveAccount() {
+ if (!accountForm.account.trim()) return ElMessage.warning('请输入登录账号')
+ if (!accountForm.id && accountForm.password.length < 12) return ElMessage.warning('密码至少 12 位')
+ if (accountForm.password && accountForm.password.length < 12) return ElMessage.warning('密码至少 12 位')
+ await run(async () => {
+ const body = JSON.stringify({
+ account: accountForm.account, name: accountForm.name,
+ password: accountForm.password, status: accountForm.status,
+ })
+ if (accountForm.id) {
+ await api(`/accounts/${accountForm.id}`, { method: 'PUT', body })
+ } else {
+ await api('/accounts', { method: 'POST', body })
+ }
+ accountDialog.value = false
+ await loadAccounts()
+ ElMessage.success(accountForm.id ? '账号已更新' : '账号已添加')
+ }).catch(() => {})
+}
+
+async function deleteAccount(account) {
+ try {
+ await ElMessageBox.confirm(`确认删除账号“${account.account}”?删除后该账号将立即无法登录。`, '删除账号', { type: 'warning' })
+ } catch { return }
+ await run(async () => {
+ await api(`/accounts/${account.id}`, { method: 'DELETE' })
+ await loadAccounts()
+ ElMessage.success('账号已删除')
+ }).catch(() => {})
+}
+
async function loadOpenClients() {
;[openClients.value, scopes.value] = await Promise.all([api('/open-clients'), api('/scopes')])
}
@@ -380,6 +428,7 @@ onMounted(async () => {
趣 智能体服务后台