Files
ssw-ontology/web/src/views/LoginView.vue
T
admin 901c2d55f4 feat(auth): 账号密码登录 + session cookie + 导入核对工作台
**账号密码登录与会话体系**

- 后端 handlers_auth.go:bcrypt 校验 + 进程内 session store (TTL 8h)
  /api/v1/auth/{login,logout,me,change-password}
- access_control.go:principalFromRequest 优先识别 session cookie;
  API KEY + session 双轨并存(dev 模式两个 KEY 都为空 → 跳过 loginRequired
  保留旧开发体验,任一 KEY 设置后立即开启真实鉴权)
- handlers_mcp.go:所有受管接口复用 authMiddleware,过期 session 401
- handlers_connector.go:连接器读路径同样接入
- main.go:挂 /api/v1/auth/* + 新增 loginRequired() 中间件
- 启动时为 manager/connector/ingest 三个内置主体写 bcrypt('changeme')
  首次登录后强制改密(前端 App.vue 弹修改密码对话框)

**前端登录 UI**

- LoginView.vue:账号+密码登录表单(默认密码 changeme)
- App.vue:登录守卫 + 顶栏用户菜单(修改密码 / 退出登录)
- api.js:所有 request 默认 credentials: include 携带 cookie
  新增 authLogin/authLogout/authMe/changePassword + mcpCall (JSON-RPC over SSE)

**导入核对工作台 (manager-only)**

- ReviewView.vue + components/ReviewWorkbench.vue +
  composables/useReviewWorkbench.js(多 tab:扫描 / 资料 / 核对 / 应用)
- import-review.html + entry-review.js 多入口(vite.config.js 加 rollup input)
- 对应 ssw-ontology-reviewer skill:本体差距自动扫描 + JSON 执行清单
  → 应用到 ontology

**依赖升级**

- go.mod:go 1.25.0 精确化 + golang.org/x/{crypto,net,sync,sys,text}
  升级到 bcrypt 兼容版本
2026-08-21 17:06:17 +08:00

60 lines
2.2 KiB
Vue
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<template>
<div class="login-wrap">
<div class="login-card">
<div class="brand">
<div class="logo">🕸️</div>
<h1>尚数网本体管理平台</h1>
</div>
<el-form :model="form" label-width="0" size="default" @submit.prevent="submit">
<el-form-item>
<el-input v-model="form.name" placeholder="用户名 (manager / connector / ingest)" autofocus @keyup.enter="submit" />
</el-form-item>
<el-form-item>
<el-input v-model="form.password" type="password" show-password placeholder="密码" @keyup.enter="submit" />
</el-form-item>
<el-button type="primary" native-type="submit" :loading="loading" style="width:100%" @click="submit">登录</el-button>
</el-form>
<el-alert v-if="err" :title="err" type="error" :closable="false" show-icon style="margin-top:14px" />
<p class="hint">
首次部署默认密码 <code>changeme</code>,登录后请立即在「用户管理 → 编辑」改密。
</p>
</div>
</div>
</template>
<script setup>
import { ref, reactive } from 'vue'
import { ElMessage } from 'element-plus'
import { api } from '../api.js'
const emit = defineEmits(['logged-in'])
const form = reactive({ name: '', password: '' })
const err = ref('')
const loading = ref(false)
async function submit() {
err.value = ''
if (!form.name || !form.password) { err.value = '请填写用户名与密码'; return }
loading.value = true
try {
await api.authLogin(form.name, form.password)
ElMessage.success('登录成功')
emit('logged-in')
} catch (e) {
err.value = e.message || '登录失败'
} finally {
loading.value = false
}
}
</script>
<style scoped>
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: linear-gradient(120deg, #1b3f9c, #2f6bff); }
.login-card { background: #fff; padding: 36px 32px; border-radius: 12px; box-shadow: 0 20px 60px rgba(0,0,0,.18); width: 360px; }
.brand { text-align: center; margin-bottom: 24px; }
.logo { font-size: 36px; }
h1 { margin: 8px 0 4px; font-size: 18px; }
.hint { color: #8a93a6; font-size: 12px; margin-top: 14px; text-align: center; }
code { background: #f5f7fb; padding: 2px 6px; border-radius: 4px; }
</style>