feat: add knowledge management functionality with CRUD operations and database schema

- Implemented KnowledgeHandler for managing knowledge groups and items, including listing, creating, updating, and deleting operations.
- Added database migration scripts to create necessary tables for knowledge management, including knowledge_groups, knowledge_items, knowledge_parse_tasks, and knowledge_chunks_meta.
- Introduced prompt_rule_knowledge_groups table to associate prompt rules with knowledge groups.
This commit is contained in:
2026-04-05 17:14:13 +08:00
parent 134dd063c3
commit 446f865cdf
62 changed files with 9503 additions and 2664 deletions
+154 -146
View File
@@ -1,18 +1,101 @@
<template>
<div class="page">
<div class="left" :style="{ background: `linear-gradient(135deg, ${primaryColor}e6, ${primaryColor}, ${primaryColor}cc)` }">
<div class="brand">
<div class="brand-icon"><StarOutlined :style="{ fontSize: '16px' }" /></div>
<span>{{ t('app.name') }}</span>
</div>
<div class="characters-area">
<AnimatedCharacters
:is-typing="isTyping"
:has-secret="!!formState.password"
:secret-visible="showPassword"
/>
</div>
<div class="footer-links">
<a href="#">Privacy Policy</a>
<a href="#">Terms of Service</a>
<a href="#">Contact</a>
</div>
<div class="deco-grid" />
<div class="deco-circle deco-circle-1" />
<div class="deco-circle deco-circle-2" />
</div>
<div class="right">
<div class="form-wrapper">
<div class="mobile-brand">
<div class="brand-icon"><StarOutlined :style="{ fontSize: '16px' }" /></div>
<span>{{ t('app.name') }}</span>
</div>
<div class="header">
<h1>{{ t('auth.welcomeBack') }}</h1>
<p>{{ t('auth.tenantAdminLogin') }}</p>
</div>
<form @submit.prevent="handleSubmit" class="form">
<div class="field">
<label for="login-email">{{ t('auth.email') }}</label>
<input id="login-email" type="email" placeholder="admin@geo.local" v-model="formState.email"
autocomplete="off" @focus="isTyping = true" @blur="isTyping = false" required />
</div>
<div class="field">
<label for="login-password">{{ t('auth.password') }}</label>
<div class="password-wrap">
<input id="login-password" :type="showPassword ? 'text' : 'password'"
placeholder="Admin@123" v-model="formState.password" required />
<button type="button" class="eye-btn" @click="showPassword = !showPassword">
<EyeInvisibleOutlined v-if="showPassword" />
<EyeOutlined v-else />
</button>
</div>
</div>
<div class="options">
<label class="remember"><input type="checkbox" v-model="remember" /> Remember for 30 days</label>
<a href="#" class="forgot">Forgot password?</a>
</div>
<button type="submit" class="btn-primary" :disabled="submitting"
:style="{ background: primaryColor }">
{{ submitting ? t('auth.loginAndEnter') + '...' : t('auth.loginAndEnter') }}
</button>
</form>
<div class="login-credentials">
<div class="login-credentials__row">
<span>{{ t("auth.defaultTestAccount") }}</span>
<strong>admin@geo.local</strong>
</div>
<div class="login-credentials__row">
<span>{{ t("auth.defaultTestPassword") }}</span>
<strong>Admin@123</strong>
</div>
</div>
</div>
</div>
</div>
</template>
<script setup lang="ts">
import { LockOutlined, MailOutlined } from "@ant-design/icons-vue";
import { message } from "ant-design-vue";
import { reactive, ref } from "vue";
import { useRoute, useRouter } from "vue-router";
import { useI18n } from "vue-i18n";
import { message } from "ant-design-vue";
import { StarOutlined, EyeOutlined, EyeInvisibleOutlined } from "@ant-design/icons-vue";
import { formatError } from "@/lib/errors";
import { useAuthStore } from "@/stores/auth";
import AnimatedCharacters from "@/components/login-animation/AnimatedCharacters.vue";
const authStore = useAuthStore();
const router = useRouter();
const route = useRoute();
const { t } = useI18n();
const primaryColor = ref('#1f5cff');
const submitting = ref(false);
const showPassword = ref(false);
const isTyping = ref(false);
const remember = ref(false);
const formState = reactive({
email: "admin@geo.local",
@@ -38,174 +121,99 @@ async function handleSubmit(): Promise<void> {
}
</script>
<template>
<div class="login-screen">
<div class="login-screen__cover">
<div class="login-screen__cover-copy">
<p class="eyebrow">Tenant Admin</p>
<h1>{{ t("app.name") }}</h1>
<p>{{ t("app.loginIntro") }}</p>
</div>
</div>
<div class="login-screen__form-container">
<div class="login-header">
<h2>{{ t("auth.welcomeBack") }}</h2>
<p>{{ t("auth.tenantAdminLogin") }}</p>
</div>
<a-form
layout="vertical"
:model="formState"
class="login-form"
@finish="handleSubmit"
@submit.prevent="handleSubmit"
>
<a-form-item :label="t('auth.email')" name="email">
<a-input v-model:value="formState.email" size="large" placeholder="admin@geo.local">
<template #prefix><MailOutlined class="login-form__icon" /></template>
</a-input>
</a-form-item>
<a-form-item :label="t('auth.password')" name="password">
<a-input-password v-model:value="formState.password" size="large" placeholder="Admin@123">
<template #prefix><LockOutlined class="login-form__icon" /></template>
</a-input-password>
</a-form-item>
<a-button
type="primary"
size="large"
block
html-type="submit"
:loading="submitting"
@click="handleSubmit"
>
{{ t("auth.loginAndEnter") }}
</a-button>
</a-form>
<div class="login-credentials">
<div class="login-credentials__row">
<span>{{ t("auth.defaultTestAccount") }}</span>
<strong>admin@geo.local</strong>
</div>
<div class="login-credentials__row">
<span>{{ t("auth.defaultTestPassword") }}</span>
<strong>Admin@123</strong>
</div>
</div>
</div>
</div>
</template>
<style scoped>
.login-screen {
display: grid;
grid-template-columns: minmax(0, 1.15fr) minmax(420px, 500px);
min-height: 100vh;
background: #eef3f9;
.page {
display: grid;
grid-template-columns: 1fr 1fr;
min-height: 100vh;
width: 100%;
flex: 1;
}
.login-screen__cover {
position: relative;
display: flex;
align-items: center;
justify-content: center;
padding: 48px;
background:
radial-gradient(circle at top left, rgba(112, 172, 255, 0.35), transparent 34%),
linear-gradient(135deg, #0f172a 0%, #1f5cff 48%, #57b5ff 100%);
color: #fff;
.left {
position: relative; display: flex; flex-direction: column; justify-content: space-between;
padding: 48px; color: white; overflow: hidden;
}
.brand { position: relative; z-index: 20; display: flex; align-items: center; gap: 8px; font-size: 18px; font-weight: 600; }
.brand-icon {
width: 32px; height: 32px; border-radius: 8px; background: rgba(255,255,255,0.1);
backdrop-filter: blur(8px); display: flex; align-items: center; justify-content: center;
}
.characters-area { position: relative; z-index: 20; display: flex; align-items: flex-end; justify-content: center; height: 500px; transform: scale(0.95); }
.footer-links { position: relative; z-index: 20; display: flex; gap: 32px; font-size: 14px; }
.footer-links a { color: rgba(255,255,255,0.6); transition: color 0.2s; }
.footer-links a:hover { color: white; }
.deco-grid {
position: absolute; inset: 0;
background-image: linear-gradient(to right, rgba(255,255,255,0.05) 1px, transparent 1px),
linear-gradient(to bottom, rgba(255,255,255,0.05) 1px, transparent 1px);
background-size: 20px 20px;
}
.deco-circle { position: absolute; border-radius: 50%; filter: blur(48px); }
.deco-circle-1 { top: 25%; right: 25%; width: 256px; height: 256px; background: rgba(255,255,255,0.1); }
.deco-circle-2 { bottom: 25%; left: 25%; width: 384px; height: 384px; background: rgba(255,255,255,0.05); }
.right { display: flex; align-items: center; justify-content: center; padding: 32px; background: #fff; }
.form-wrapper { width: 100%; max-width: 420px; }
.mobile-brand { display: none; }
.header { text-align: center; margin-bottom: 40px; }
.header h1 { font-size: 30px; font-weight: 700; letter-spacing: -0.5px; margin-bottom: 8px; color: #18181b; }
.header p { color: #71717a; font-size: 14px; margin: 0; }
.form { display: flex; flex-direction: column; gap: 20px; margin-bottom: 32px; }
.field { display: flex; flex-direction: column; gap: 8px; }
.field label { font-size: 14px; font-weight: 500; color: #18181b; }
.field input {
height: 48px; padding: 0 12px; border-radius: 6px; border: 1px solid #d4d4d8;
font-size: 14px; outline: none; background: #fff; transition: border-color 0.2s; color: #18181b;
}
.field input:focus { border-color: #1f5cff; box-shadow: 0 0 0 2px rgba(31,92,255,0.2); }
.password-wrap { position: relative; }
.password-wrap input { width: 100%; padding-right: 40px; box-sizing: border-box; }
.eye-btn {
position: absolute; right: 12px; top: 50%; transform: translateY(-50%);
background: none; border: none; color: #a1a1aa; transition: color 0.2s;
display: flex; align-items: center; justify-content: center; font-size: 18px; cursor: pointer;
}
.eye-btn:hover { color: #3f3f46; }
.options { display: flex; align-items: center; justify-content: space-between; font-size: 14px; }
.remember { display: flex; align-items: center; gap: 8px; cursor: pointer; color: #18181b; }
.remember input { width: 16px; height: 16px; accent-color: #1f5cff; cursor: pointer; }
.forgot { color: #1f5cff; font-weight: 500; }
.forgot:hover { text-decoration: underline; }
.login-screen__cover-copy {
max-width: 520px;
}
.login-screen__cover h1 {
margin: 0;
font-size: 56px;
line-height: 0.96;
}
.login-screen__cover p:last-child {
max-width: 420px;
margin: 18px 0 0;
color: rgba(255, 255, 255, 0.82);
font-size: 18px;
line-height: 1.6;
}
.login-screen__form-container {
display: flex;
flex-direction: column;
justify-content: center;
padding: 64px 48px;
background: rgba(255, 255, 255, 0.94);
backdrop-filter: blur(14px);
box-shadow: -16px 0 40px rgba(15, 23, 42, 0.08);
}
.login-header {
margin-bottom: 36px;
}
.login-header h2 {
margin: 0 0 8px;
font-size: 32px;
}
.login-header p {
margin: 0;
color: var(--muted);
}
.login-form__icon {
color: rgba(0, 0, 0, 0.25);
.btn-primary {
width: 100%; height: 48px; font-size: 16px; font-weight: 500; border: none; border-radius: 6px;
color: white; transition: opacity 0.2s; cursor: pointer;
}
.btn-primary:hover { opacity: 0.9; }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }
.login-credentials {
margin-top: 24px;
padding: 16px;
background: #f8fafc;
border: 1px solid #e6edf5;
border-radius: 16px;
border-radius: 12px;
}
.login-credentials__row {
display: flex;
justify-content: space-between;
gap: 12px;
}
.login-credentials__row + .login-credentials__row {
margin-top: 8px;
}
.login-credentials__row span {
color: var(--muted);
color: var(--muted, #71717a);
font-size: 13px;
}
.login-credentials__row strong {
color: #18181b;
font-size: 13px;
}
@media (max-width: 980px) {
.login-screen {
grid-template-columns: 1fr;
}
.login-screen__cover {
min-height: 280px;
}
}
@media (max-width: 640px) {
.login-screen__form-container,
.login-screen__cover {
padding: 32px 20px;
}
.login-screen__cover h1 {
font-size: 40px;
}
@media (max-width: 1023px) {
.page { grid-template-columns: 1fr; }
.left { display: none; }
.mobile-brand { display: flex; align-items: center; justify-content: center; gap: 8px; font-size: 18px; font-weight: 600; margin-bottom: 48px; color: #18181b; }
}
</style>