This commit is contained in:
Twilight 2024-05-30 11:05:16 +08:00
parent e6dc6370d6
commit 4acfa11b81
11 changed files with 615 additions and 437 deletions

View File

@ -3,11 +3,7 @@
<v-navigation-drawer v-model="drawer"> <v-navigation-drawer v-model="drawer">
<div class="pa-2"> <div class="pa-2">
<v-btn-group rounded="lg"> <v-btn-group rounded="lg">
<v-btn <v-btn density="default" icon="mdi-close" @click="drawer = !drawer"></v-btn>
density="default"
icon="mdi-close"
@click="drawer = !drawer"
></v-btn>
<v-btn density="default" icon="mdi-plus" title="创建资料库" @click="to('libraries.create')"> <v-btn density="default" icon="mdi-plus" title="创建资料库" @click="to('libraries.create')">
</v-btn> </v-btn>
@ -28,24 +24,22 @@
></v-list-item> ></v-list-item>
</template> --> </template> -->
<v-list-item <v-list-item rounded="lg" prepend-icon="mdi-home" title="首页" :to="{
rounded="lg" name: 'home',
prepend-icon="mdi-home" }"></v-list-item>
title="首页"
:to="{ <v-list-item rounded="lg" prepend-icon="mdi-account" title="登录" :to="{
name: 'home', name: 'login',
}" }" v-show="!logined"></v-list-item>
></v-list-item>
<v-list-item v-if="libraries" v-for="i in libraries.libraries" rounded="lg" prepend-icon="mdi-home" :title="i.name" :to="{
name: 'documents.list',
params: {
'LibraryId': i.id
}
}"></v-list-item>
<v-list-item
rounded="lg"
prepend-icon="mdi-account"
title="登录"
:to="{
name: 'login',
}"
v-show="!logined"
></v-list-item>
<!-- <v-list-item <!-- <v-list-item
prepend-icon="mdi-forum" prepend-icon="mdi-forum"
@ -64,45 +58,52 @@
</template> </template>
<script lang="ts" setup> <script lang="ts" setup>
import { ref } from "vue"; import { ref } from "vue"
import { useConfigStore } from "@/store/config"; import { useConfigStore } from "@/store/config"
import keycloak from "@/plugins/keycloak"; import keycloak from "@/plugins/keycloak"
import rpcPlugin from "@/plugins/rpc"; import rpcPlugin from "@/plugins/rpc"
import * as libraryPb from "@/proto/library/library"; import * as libraryPb from "@/proto/library/library"
import router from "@/router"; import router from "@/router"
const configStore = useConfigStore(); const configStore = useConfigStore()
const drawer = ref(false); const drawer = ref(false)
const logined = ref(false); const logined = ref(false)
const libraries = ref()
let inter = setInterval(() => { let inter = setInterval(() => {
logined.value = keycloak.authenticated === true; refreshLibraries()
clearInterval(inter)
logined.value = keycloak.authenticated === true
if (logined.value) { if (logined.value) {
clearInterval(inter); clearInterval(inter)
refreshLibraries() refreshLibraries()
} }
}, 1000); }, 1000)
function refreshLibraries() { function refreshLibraries() {
const useRpc = rpcPlugin() const useRpc = rpcPlugin()
let listLibrary: libraryPb.ListLibrariesRequest = { let listLibrary: libraryPb.ListLibrariesRequest = {
page: 1, page: 1,
}; }
useRpc.libraryServiceClient.listLibraries(listLibrary).then((res) => { useRpc.libraryServiceClient.listLibraries(listLibrary).then((res) => {
console.log(res); console.log(res)
}); libraries.value = res.response
console.log(libraries)
})
} }
function to(name: string) { function to(name: string) {
router.push({ router.push({
name: name, name: name,
}); })
} }

View File

@ -7,7 +7,9 @@ const staticConfig = {
checkLoginIframe: false, checkLoginIframe: false,
redirectUri: window.location.origin + "/auth/login", redirectUri: window.location.origin + "/auth/login",
rpc_base_url: "http://127.0.0.1:18081" rpcBaseUrl: "http://127.0.0.1:18081",
devMode: true
} }

View File

@ -1,26 +1,26 @@
import { GrpcWebFetchTransport } from "@protobuf-ts/grpcweb-transport"; import { GrpcWebFetchTransport } from "@protobuf-ts/grpcweb-transport"
import keycloak from "@/plugins/keycloak" import keycloak from "@/plugins/keycloak"
import { DocumentServiceClient } from "@/proto/document/document.client"; import { DocumentServiceClient } from "@/proto/document/document.client"
import { LibraryServiceClient } from "@/proto/library/library.client"; import { LibraryServiceClient } from "@/proto/library/library.client"
import config from "@/plugins/config" import config from "@/plugins/config"
export default () => { export default () => {
const transport = new GrpcWebFetchTransport({ const transport = new GrpcWebFetchTransport({
baseUrl: config.rpc_base_url, baseUrl: config.rpcBaseUrl,
format: "text", format: "text",
meta: { meta: {
"Authorization": "Bearer " + keycloak.idToken, "Authorization": "Bearer " + keycloak.idToken,
}, },
timeout: 100 * 1000, timeout: 100 * 1000,
}); })
const libraryServiceClient = new LibraryServiceClient(transport) const libraryServiceClient = new LibraryServiceClient(transport)
const documentClient = new DocumentServiceClient(transport) const documentClient = new DocumentServiceClient(transport)
return { return {
libraryServiceClient, libraryServiceClient,
documentClient documentClient
} }
} }

View File

@ -1,28 +1,28 @@
// @generated by protobuf-ts 2.9.4 with parameter generate_dependencies // @generated by protobuf-ts 2.9.4 with parameter generate_dependencies
// @generated from protobuf file "proto/document/document.proto" (package "DocumentService", syntax proto3) // @generated from protobuf file "proto/document/document.proto" (package "DocumentService", syntax proto3)
// tslint:disable // tslint:disable
import type {RpcOptions, RpcTransport, ServiceInfo, UnaryCall} from "@protobuf-ts/runtime-rpc"; import type { RpcTransport } from "@protobuf-ts/runtime-rpc";
import {stackIntercept} from "@protobuf-ts/runtime-rpc"; import type { ServiceInfo } from "@protobuf-ts/runtime-rpc";
import type { import { DocumentService } from "./document";
CreateDocumentBlockRequest, import type { UpdateDocumentBlockRequest } from "./document";
CreateDocumentRequest, import type { DeleteDocumentBlockRequest } from "./document";
DeleteDocumentBlockRequest, import type { GetDocumentBlocksRequest } from "./document";
DeleteDocumentRequest, import type { GetDocumentBlockRequest } from "./document";
Document, import type { DocumentBlock } from "./document";
DocumentBlock, import type { CreateDocumentBlockRequest } from "./document";
DocumentBlockList, import type { DocumentBlockList } from "./document";
DocumentList, import type { VectorSearchByTextInDocumentRequest } from "./document";
Empty, import type { Empty } from "./document";
GetDocumentBlockRequest, import type { DeleteDocumentRequest } from "./document";
GetDocumentBlocksRequest, import type { UpdateDocumentRequest } from "./document";
GetDocumentRequest, import type { GetDocumentRequest } from "./document";
ListDocumentsRequest, import type { Document } from "./document";
UpdateDocumentBlockRequest, import type { CreateDocumentRequest } from "./document";
UpdateDocumentRequest, import { stackIntercept } from "@protobuf-ts/runtime-rpc";
VectorSearchByTextInDocumentRequest import type { DocumentList } from "./document";
} from "./document"; import type { ListDocumentsRequest } from "./document";
import {DocumentService} from "./document"; import type { UnaryCall } from "@protobuf-ts/runtime-rpc";
import type { RpcOptions } from "@protobuf-ts/runtime-rpc";
/** /**
* @generated from protobuf service DocumentService.DocumentService * @generated from protobuf service DocumentService.DocumentService
*/ */

File diff suppressed because it is too large Load Diff

View File

@ -1,27 +1,27 @@
// @generated by protobuf-ts 2.9.4 with parameter generate_dependencies // @generated by protobuf-ts 2.9.4 with parameter generate_dependencies
// @generated from protobuf file "proto/library/library.proto" (package "LibraryService", syntax proto3) // @generated from protobuf file "proto/library/library.proto" (package "LibraryService", syntax proto3)
// tslint:disable // tslint:disable
import type {RpcOptions, RpcTransport, ServiceInfo, UnaryCall} from "@protobuf-ts/runtime-rpc"; import type { RpcTransport } from "@protobuf-ts/runtime-rpc";
import {stackIntercept} from "@protobuf-ts/runtime-rpc"; import type { ServiceInfo } from "@protobuf-ts/runtime-rpc";
import type { import { LibraryService } from "./library";
CreateLibraryRequest, import type { VectorSearchByTextFromLibraryResponse } from "./library";
DeleteLibraryRequest, import type { VectorSearchByTextFromLibraryRequest } from "./library";
DocumentTextSearchFromLibraryRequest, import type { DocumentTextSearchFromLibraryResponse } from "./library";
DocumentTextSearchFromLibraryResponse, import type { DocumentTextSearchFromLibraryRequest } from "./library";
DocumentVectorSearchByTextFromLibraryRequest, import type { DocumentVectorSearchByTextFromLibraryResponse } from "./library";
DocumentVectorSearchByTextFromLibraryResponse, import type { DocumentVectorSearchByTextFromLibraryRequest } from "./library";
GetLibraryRequest, import type { DeleteLibraryRequest } from "./library";
GetLibraryResponse, import type { UpdateLibraryResponse } from "./library";
Library, import type { UpdateLibraryRequest } from "./library";
LibraryList, import type { GetLibraryResponse } from "./library";
ListLibrariesRequest, import type { GetLibraryRequest } from "./library";
UpdateLibraryRequest, import type { Library } from "./library";
UpdateLibraryResponse, import type { CreateLibraryRequest } from "./library";
VectorSearchByTextFromLibraryRequest, import { stackIntercept } from "@protobuf-ts/runtime-rpc";
VectorSearchByTextFromLibraryResponse import type { LibraryList } from "./library";
} from "./library"; import type { ListLibrariesRequest } from "./library";
import {LibraryService} from "./library"; import type { UnaryCall } from "@protobuf-ts/runtime-rpc";
import type { RpcOptions } from "@protobuf-ts/runtime-rpc";
/** /**
* @generated from protobuf service LibraryService.LibraryService * @generated from protobuf service LibraryService.LibraryService
*/ */

View File

@ -1,23 +1,23 @@
// @generated by protobuf-ts 2.9.4 with parameter generate_dependencies // @generated by protobuf-ts 2.9.4 with parameter generate_dependencies
// @generated from protobuf file "proto/library/library.proto" (package "LibraryService", syntax proto3) // @generated from protobuf file "proto/library/library.proto" (package "LibraryService", syntax proto3)
// tslint:disable // tslint:disable
import {ServiceType} from "@protobuf-ts/runtime-rpc"; import { ServiceType } from "@protobuf-ts/runtime-rpc";
import type { import type { BinaryWriteOptions } from "@protobuf-ts/runtime";
BinaryReadOptions, import type { IBinaryWriter } from "@protobuf-ts/runtime";
BinaryWriteOptions, import { WireType } from "@protobuf-ts/runtime";
IBinaryReader, import type { BinaryReadOptions } from "@protobuf-ts/runtime";
IBinaryWriter, import type { IBinaryReader } from "@protobuf-ts/runtime";
PartialMessage import { UnknownFieldHandler } from "@protobuf-ts/runtime";
} from "@protobuf-ts/runtime"; import type { PartialMessage } from "@protobuf-ts/runtime";
import {MessageType, reflectionMergePartial, UnknownFieldHandler, WireType} from "@protobuf-ts/runtime"; import { reflectionMergePartial } from "@protobuf-ts/runtime";
import {DocumentList} from "../document/document"; import { MessageType } from "@protobuf-ts/runtime";
import { DocumentList } from "../document/document";
/** /**
* @generated from protobuf message LibraryService.Library * @generated from protobuf message LibraryService.Library
*/ */
export interface Library { export interface Library {
/** /**
* @generated from protobuf field: uint32 id = 1; * @generated from protobuf field: int32 id = 1;
*/ */
id: number; id: number;
/** /**
@ -59,9 +59,9 @@ export interface LibraryList {
*/ */
libraries: Library[]; libraries: Library[];
/** /**
* @generated from protobuf field: int64 total = 2; * @generated from protobuf field: int32 total = 2;
*/ */
total: bigint; total: number;
} }
/** /**
* @generated from protobuf message LibraryService.CreateLibraryRequest * @generated from protobuf message LibraryService.CreateLibraryRequest
@ -89,7 +89,7 @@ export interface CreateLibraryRequest {
*/ */
export interface DeleteLibraryRequest { export interface DeleteLibraryRequest {
/** /**
* @generated from protobuf field: uint32 id = 1; * @generated from protobuf field: int32 id = 1;
*/ */
id: number; id: number;
} }
@ -98,7 +98,7 @@ export interface DeleteLibraryRequest {
*/ */
export interface UpdateLibraryRequest { export interface UpdateLibraryRequest {
/** /**
* @generated from protobuf field: uint32 id = 1; * @generated from protobuf field: int32 id = 1;
*/ */
id: number; id: number;
/** /**
@ -132,7 +132,7 @@ export interface UpdateLibraryResponse {
*/ */
export interface GetLibraryRequest { export interface GetLibraryRequest {
/** /**
* @generated from protobuf field: uint32 id = 1; * @generated from protobuf field: int32 id = 1;
*/ */
id: number; id: number;
} }
@ -154,7 +154,7 @@ export interface DocumentVectorSearchByTextFromLibraryRequest {
*/ */
query: string; query: string;
/** /**
* @generated from protobuf field: uint32 library_id = 2; * @generated from protobuf field: int32 library_id = 2;
*/ */
libraryId: number; libraryId: number;
/** /**
@ -184,7 +184,7 @@ export interface DocumentTextSearchFromLibraryRequest {
*/ */
query: string; query: string;
/** /**
* @generated from protobuf field: uint32 library_id = 2; * @generated from protobuf field: int32 library_id = 2;
*/ */
libraryId: number; libraryId: number;
/** /**
@ -201,9 +201,9 @@ export interface DocumentTextSearchFromLibraryResponse {
*/ */
hits?: DocumentList; hits?: DocumentList;
/** /**
* @generated from protobuf field: int64 total = 2; * @generated from protobuf field: int32 total = 2;
*/ */
total: bigint; total: number;
} }
/** /**
* @generated from protobuf message LibraryService.VectorSearchByTextFromLibraryRequest * @generated from protobuf message LibraryService.VectorSearchByTextFromLibraryRequest
@ -214,7 +214,7 @@ export interface VectorSearchByTextFromLibraryRequest {
*/ */
query: string; query: string;
/** /**
* @generated from protobuf field: uint32 library_id = 2; * @generated from protobuf field: int32 library_id = 2;
*/ */
libraryId: number; libraryId: number;
} }
@ -236,15 +236,15 @@ export interface DocumentBlockList {
*/ */
content: string; content: string;
/** /**
* @generated from protobuf field: uint32 document_id = 2; * @generated from protobuf field: int32 document_id = 2;
*/ */
documentId: number; documentId: number;
/** /**
* @generated from protobuf field: uint32 library_id = 3; * @generated from protobuf field: int32 library_id = 3;
*/ */
libraryId: number; libraryId: number;
/** /**
* @generated from protobuf field: uint32 block_id = 4; * @generated from protobuf field: int32 block_id = 4;
*/ */
blockId: number; blockId: number;
} }
@ -265,7 +265,7 @@ export enum LibraryAccessibility {
class Library$Type extends MessageType<Library> { class Library$Type extends MessageType<Library> {
constructor() { constructor() {
super("LibraryService.Library", [ super("LibraryService.Library", [
{ no: 1, name: "id", kind: "scalar", T: 13 /*ScalarType.UINT32*/ }, { no: 1, name: "id", kind: "scalar", T: 5 /*ScalarType.INT32*/ },
{ no: 2, name: "name", kind: "scalar", T: 9 /*ScalarType.STRING*/ }, { no: 2, name: "name", kind: "scalar", T: 9 /*ScalarType.STRING*/ },
{ no: 3, name: "description", kind: "scalar", T: 9 /*ScalarType.STRING*/ }, { no: 3, name: "description", kind: "scalar", T: 9 /*ScalarType.STRING*/ },
{ no: 4, name: "icon", kind: "scalar", T: 9 /*ScalarType.STRING*/ }, { no: 4, name: "icon", kind: "scalar", T: 9 /*ScalarType.STRING*/ },
@ -290,8 +290,8 @@ class Library$Type extends MessageType<Library> {
while (reader.pos < end) { while (reader.pos < end) {
let [fieldNo, wireType] = reader.tag(); let [fieldNo, wireType] = reader.tag();
switch (fieldNo) { switch (fieldNo) {
case /* uint32 id */ 1: case /* int32 id */ 1:
message.id = reader.uint32(); message.id = reader.int32();
break; break;
case /* string name */ 2: case /* string name */ 2:
message.name = reader.string(); message.name = reader.string();
@ -320,9 +320,9 @@ class Library$Type extends MessageType<Library> {
return message; return message;
} }
internalBinaryWrite(message: Library, writer: IBinaryWriter, options: BinaryWriteOptions): IBinaryWriter { internalBinaryWrite(message: Library, writer: IBinaryWriter, options: BinaryWriteOptions): IBinaryWriter {
/* uint32 id = 1; */ /* int32 id = 1; */
if (message.id !== 0) if (message.id !== 0)
writer.tag(1, WireType.Varint).uint32(message.id); writer.tag(1, WireType.Varint).int32(message.id);
/* string name = 2; */ /* string name = 2; */
if (message.name !== "") if (message.name !== "")
writer.tag(2, WireType.LengthDelimited).string(message.name); writer.tag(2, WireType.LengthDelimited).string(message.name);
@ -400,13 +400,13 @@ class LibraryList$Type extends MessageType<LibraryList> {
constructor() { constructor() {
super("LibraryService.LibraryList", [ super("LibraryService.LibraryList", [
{ no: 1, name: "libraries", kind: "message", repeat: 1 /*RepeatType.PACKED*/, T: () => Library }, { no: 1, name: "libraries", kind: "message", repeat: 1 /*RepeatType.PACKED*/, T: () => Library },
{ no: 2, name: "total", kind: "scalar", T: 3 /*ScalarType.INT64*/, L: 0 /*LongType.BIGINT*/ } { no: 2, name: "total", kind: "scalar", T: 5 /*ScalarType.INT32*/ }
]); ]);
} }
create(value?: PartialMessage<LibraryList>): LibraryList { create(value?: PartialMessage<LibraryList>): LibraryList {
const message = globalThis.Object.create((this.messagePrototype!)); const message = globalThis.Object.create((this.messagePrototype!));
message.libraries = []; message.libraries = [];
message.total = 0n; message.total = 0;
if (value !== undefined) if (value !== undefined)
reflectionMergePartial<LibraryList>(this, message, value); reflectionMergePartial<LibraryList>(this, message, value);
return message; return message;
@ -419,8 +419,8 @@ class LibraryList$Type extends MessageType<LibraryList> {
case /* repeated LibraryService.Library libraries */ 1: case /* repeated LibraryService.Library libraries */ 1:
message.libraries.push(Library.internalBinaryRead(reader, reader.uint32(), options)); message.libraries.push(Library.internalBinaryRead(reader, reader.uint32(), options));
break; break;
case /* int64 total */ 2: case /* int32 total */ 2:
message.total = reader.int64().toBigInt(); message.total = reader.int32();
break; break;
default: default:
let u = options.readUnknownField; let u = options.readUnknownField;
@ -437,9 +437,9 @@ class LibraryList$Type extends MessageType<LibraryList> {
/* repeated LibraryService.Library libraries = 1; */ /* repeated LibraryService.Library libraries = 1; */
for (let i = 0; i < message.libraries.length; i++) for (let i = 0; i < message.libraries.length; i++)
Library.internalBinaryWrite(message.libraries[i], writer.tag(1, WireType.LengthDelimited).fork(), options).join(); Library.internalBinaryWrite(message.libraries[i], writer.tag(1, WireType.LengthDelimited).fork(), options).join();
/* int64 total = 2; */ /* int32 total = 2; */
if (message.total !== 0n) if (message.total !== 0)
writer.tag(2, WireType.Varint).int64(message.total); writer.tag(2, WireType.Varint).int32(message.total);
let u = options.writeUnknownFields; let u = options.writeUnknownFields;
if (u !== false) if (u !== false)
(u == true ? UnknownFieldHandler.onWrite : u)(this.typeName, message, writer); (u == true ? UnknownFieldHandler.onWrite : u)(this.typeName, message, writer);
@ -525,7 +525,7 @@ export const CreateLibraryRequest = new CreateLibraryRequest$Type();
class DeleteLibraryRequest$Type extends MessageType<DeleteLibraryRequest> { class DeleteLibraryRequest$Type extends MessageType<DeleteLibraryRequest> {
constructor() { constructor() {
super("LibraryService.DeleteLibraryRequest", [ super("LibraryService.DeleteLibraryRequest", [
{ no: 1, name: "id", kind: "scalar", T: 13 /*ScalarType.UINT32*/ } { no: 1, name: "id", kind: "scalar", T: 5 /*ScalarType.INT32*/ }
]); ]);
} }
create(value?: PartialMessage<DeleteLibraryRequest>): DeleteLibraryRequest { create(value?: PartialMessage<DeleteLibraryRequest>): DeleteLibraryRequest {
@ -540,8 +540,8 @@ class DeleteLibraryRequest$Type extends MessageType<DeleteLibraryRequest> {
while (reader.pos < end) { while (reader.pos < end) {
let [fieldNo, wireType] = reader.tag(); let [fieldNo, wireType] = reader.tag();
switch (fieldNo) { switch (fieldNo) {
case /* uint32 id */ 1: case /* int32 id */ 1:
message.id = reader.uint32(); message.id = reader.int32();
break; break;
default: default:
let u = options.readUnknownField; let u = options.readUnknownField;
@ -555,9 +555,9 @@ class DeleteLibraryRequest$Type extends MessageType<DeleteLibraryRequest> {
return message; return message;
} }
internalBinaryWrite(message: DeleteLibraryRequest, writer: IBinaryWriter, options: BinaryWriteOptions): IBinaryWriter { internalBinaryWrite(message: DeleteLibraryRequest, writer: IBinaryWriter, options: BinaryWriteOptions): IBinaryWriter {
/* uint32 id = 1; */ /* int32 id = 1; */
if (message.id !== 0) if (message.id !== 0)
writer.tag(1, WireType.Varint).uint32(message.id); writer.tag(1, WireType.Varint).int32(message.id);
let u = options.writeUnknownFields; let u = options.writeUnknownFields;
if (u !== false) if (u !== false)
(u == true ? UnknownFieldHandler.onWrite : u)(this.typeName, message, writer); (u == true ? UnknownFieldHandler.onWrite : u)(this.typeName, message, writer);
@ -572,7 +572,7 @@ export const DeleteLibraryRequest = new DeleteLibraryRequest$Type();
class UpdateLibraryRequest$Type extends MessageType<UpdateLibraryRequest> { class UpdateLibraryRequest$Type extends MessageType<UpdateLibraryRequest> {
constructor() { constructor() {
super("LibraryService.UpdateLibraryRequest", [ super("LibraryService.UpdateLibraryRequest", [
{ no: 1, name: "id", kind: "scalar", T: 13 /*ScalarType.UINT32*/ }, { no: 1, name: "id", kind: "scalar", T: 5 /*ScalarType.INT32*/ },
{ no: 2, name: "name", kind: "scalar", T: 9 /*ScalarType.STRING*/ }, { no: 2, name: "name", kind: "scalar", T: 9 /*ScalarType.STRING*/ },
{ no: 3, name: "description", kind: "scalar", T: 9 /*ScalarType.STRING*/ }, { no: 3, name: "description", kind: "scalar", T: 9 /*ScalarType.STRING*/ },
{ no: 4, name: "icon", kind: "scalar", T: 9 /*ScalarType.STRING*/ }, { no: 4, name: "icon", kind: "scalar", T: 9 /*ScalarType.STRING*/ },
@ -595,8 +595,8 @@ class UpdateLibraryRequest$Type extends MessageType<UpdateLibraryRequest> {
while (reader.pos < end) { while (reader.pos < end) {
let [fieldNo, wireType] = reader.tag(); let [fieldNo, wireType] = reader.tag();
switch (fieldNo) { switch (fieldNo) {
case /* uint32 id */ 1: case /* int32 id */ 1:
message.id = reader.uint32(); message.id = reader.int32();
break; break;
case /* string name */ 2: case /* string name */ 2:
message.name = reader.string(); message.name = reader.string();
@ -622,9 +622,9 @@ class UpdateLibraryRequest$Type extends MessageType<UpdateLibraryRequest> {
return message; return message;
} }
internalBinaryWrite(message: UpdateLibraryRequest, writer: IBinaryWriter, options: BinaryWriteOptions): IBinaryWriter { internalBinaryWrite(message: UpdateLibraryRequest, writer: IBinaryWriter, options: BinaryWriteOptions): IBinaryWriter {
/* uint32 id = 1; */ /* int32 id = 1; */
if (message.id !== 0) if (message.id !== 0)
writer.tag(1, WireType.Varint).uint32(message.id); writer.tag(1, WireType.Varint).int32(message.id);
/* string name = 2; */ /* string name = 2; */
if (message.name !== "") if (message.name !== "")
writer.tag(2, WireType.LengthDelimited).string(message.name); writer.tag(2, WireType.LengthDelimited).string(message.name);
@ -697,7 +697,7 @@ export const UpdateLibraryResponse = new UpdateLibraryResponse$Type();
class GetLibraryRequest$Type extends MessageType<GetLibraryRequest> { class GetLibraryRequest$Type extends MessageType<GetLibraryRequest> {
constructor() { constructor() {
super("LibraryService.GetLibraryRequest", [ super("LibraryService.GetLibraryRequest", [
{ no: 1, name: "id", kind: "scalar", T: 13 /*ScalarType.UINT32*/ } { no: 1, name: "id", kind: "scalar", T: 5 /*ScalarType.INT32*/ }
]); ]);
} }
create(value?: PartialMessage<GetLibraryRequest>): GetLibraryRequest { create(value?: PartialMessage<GetLibraryRequest>): GetLibraryRequest {
@ -712,8 +712,8 @@ class GetLibraryRequest$Type extends MessageType<GetLibraryRequest> {
while (reader.pos < end) { while (reader.pos < end) {
let [fieldNo, wireType] = reader.tag(); let [fieldNo, wireType] = reader.tag();
switch (fieldNo) { switch (fieldNo) {
case /* uint32 id */ 1: case /* int32 id */ 1:
message.id = reader.uint32(); message.id = reader.int32();
break; break;
default: default:
let u = options.readUnknownField; let u = options.readUnknownField;
@ -727,9 +727,9 @@ class GetLibraryRequest$Type extends MessageType<GetLibraryRequest> {
return message; return message;
} }
internalBinaryWrite(message: GetLibraryRequest, writer: IBinaryWriter, options: BinaryWriteOptions): IBinaryWriter { internalBinaryWrite(message: GetLibraryRequest, writer: IBinaryWriter, options: BinaryWriteOptions): IBinaryWriter {
/* uint32 id = 1; */ /* int32 id = 1; */
if (message.id !== 0) if (message.id !== 0)
writer.tag(1, WireType.Varint).uint32(message.id); writer.tag(1, WireType.Varint).int32(message.id);
let u = options.writeUnknownFields; let u = options.writeUnknownFields;
if (u !== false) if (u !== false)
(u == true ? UnknownFieldHandler.onWrite : u)(this.typeName, message, writer); (u == true ? UnknownFieldHandler.onWrite : u)(this.typeName, message, writer);
@ -791,7 +791,7 @@ class DocumentVectorSearchByTextFromLibraryRequest$Type extends MessageType<Docu
constructor() { constructor() {
super("LibraryService.DocumentVectorSearchByTextFromLibraryRequest", [ super("LibraryService.DocumentVectorSearchByTextFromLibraryRequest", [
{ no: 1, name: "query", kind: "scalar", T: 9 /*ScalarType.STRING*/ }, { no: 1, name: "query", kind: "scalar", T: 9 /*ScalarType.STRING*/ },
{ no: 2, name: "library_id", kind: "scalar", T: 13 /*ScalarType.UINT32*/ }, { no: 2, name: "library_id", kind: "scalar", T: 5 /*ScalarType.INT32*/ },
{ no: 3, name: "page", kind: "scalar", T: 5 /*ScalarType.INT32*/ } { no: 3, name: "page", kind: "scalar", T: 5 /*ScalarType.INT32*/ }
]); ]);
} }
@ -812,8 +812,8 @@ class DocumentVectorSearchByTextFromLibraryRequest$Type extends MessageType<Docu
case /* string query */ 1: case /* string query */ 1:
message.query = reader.string(); message.query = reader.string();
break; break;
case /* uint32 library_id */ 2: case /* int32 library_id */ 2:
message.libraryId = reader.uint32(); message.libraryId = reader.int32();
break; break;
case /* int32 page */ 3: case /* int32 page */ 3:
message.page = reader.int32(); message.page = reader.int32();
@ -833,9 +833,9 @@ class DocumentVectorSearchByTextFromLibraryRequest$Type extends MessageType<Docu
/* string query = 1; */ /* string query = 1; */
if (message.query !== "") if (message.query !== "")
writer.tag(1, WireType.LengthDelimited).string(message.query); writer.tag(1, WireType.LengthDelimited).string(message.query);
/* uint32 library_id = 2; */ /* int32 library_id = 2; */
if (message.libraryId !== 0) if (message.libraryId !== 0)
writer.tag(2, WireType.Varint).uint32(message.libraryId); writer.tag(2, WireType.Varint).int32(message.libraryId);
/* int32 page = 3; */ /* int32 page = 3; */
if (message.page !== 0) if (message.page !== 0)
writer.tag(3, WireType.Varint).int32(message.page); writer.tag(3, WireType.Varint).int32(message.page);
@ -908,7 +908,7 @@ class DocumentTextSearchFromLibraryRequest$Type extends MessageType<DocumentText
constructor() { constructor() {
super("LibraryService.DocumentTextSearchFromLibraryRequest", [ super("LibraryService.DocumentTextSearchFromLibraryRequest", [
{ no: 1, name: "query", kind: "scalar", T: 9 /*ScalarType.STRING*/ }, { no: 1, name: "query", kind: "scalar", T: 9 /*ScalarType.STRING*/ },
{ no: 2, name: "library_id", kind: "scalar", T: 13 /*ScalarType.UINT32*/ }, { no: 2, name: "library_id", kind: "scalar", T: 5 /*ScalarType.INT32*/ },
{ no: 3, name: "page", kind: "scalar", T: 5 /*ScalarType.INT32*/ } { no: 3, name: "page", kind: "scalar", T: 5 /*ScalarType.INT32*/ }
]); ]);
} }
@ -929,8 +929,8 @@ class DocumentTextSearchFromLibraryRequest$Type extends MessageType<DocumentText
case /* string query */ 1: case /* string query */ 1:
message.query = reader.string(); message.query = reader.string();
break; break;
case /* uint32 library_id */ 2: case /* int32 library_id */ 2:
message.libraryId = reader.uint32(); message.libraryId = reader.int32();
break; break;
case /* int32 page */ 3: case /* int32 page */ 3:
message.page = reader.int32(); message.page = reader.int32();
@ -950,9 +950,9 @@ class DocumentTextSearchFromLibraryRequest$Type extends MessageType<DocumentText
/* string query = 1; */ /* string query = 1; */
if (message.query !== "") if (message.query !== "")
writer.tag(1, WireType.LengthDelimited).string(message.query); writer.tag(1, WireType.LengthDelimited).string(message.query);
/* uint32 library_id = 2; */ /* int32 library_id = 2; */
if (message.libraryId !== 0) if (message.libraryId !== 0)
writer.tag(2, WireType.Varint).uint32(message.libraryId); writer.tag(2, WireType.Varint).int32(message.libraryId);
/* int32 page = 3; */ /* int32 page = 3; */
if (message.page !== 0) if (message.page !== 0)
writer.tag(3, WireType.Varint).int32(message.page); writer.tag(3, WireType.Varint).int32(message.page);
@ -971,12 +971,12 @@ class DocumentTextSearchFromLibraryResponse$Type extends MessageType<DocumentTex
constructor() { constructor() {
super("LibraryService.DocumentTextSearchFromLibraryResponse", [ super("LibraryService.DocumentTextSearchFromLibraryResponse", [
{ no: 1, name: "hits", kind: "message", T: () => DocumentList }, { no: 1, name: "hits", kind: "message", T: () => DocumentList },
{ no: 2, name: "total", kind: "scalar", T: 3 /*ScalarType.INT64*/, L: 0 /*LongType.BIGINT*/ } { no: 2, name: "total", kind: "scalar", T: 5 /*ScalarType.INT32*/ }
]); ]);
} }
create(value?: PartialMessage<DocumentTextSearchFromLibraryResponse>): DocumentTextSearchFromLibraryResponse { create(value?: PartialMessage<DocumentTextSearchFromLibraryResponse>): DocumentTextSearchFromLibraryResponse {
const message = globalThis.Object.create((this.messagePrototype!)); const message = globalThis.Object.create((this.messagePrototype!));
message.total = 0n; message.total = 0;
if (value !== undefined) if (value !== undefined)
reflectionMergePartial<DocumentTextSearchFromLibraryResponse>(this, message, value); reflectionMergePartial<DocumentTextSearchFromLibraryResponse>(this, message, value);
return message; return message;
@ -989,8 +989,8 @@ class DocumentTextSearchFromLibraryResponse$Type extends MessageType<DocumentTex
case /* DocumentService.DocumentList hits */ 1: case /* DocumentService.DocumentList hits */ 1:
message.hits = DocumentList.internalBinaryRead(reader, reader.uint32(), options, message.hits); message.hits = DocumentList.internalBinaryRead(reader, reader.uint32(), options, message.hits);
break; break;
case /* int64 total */ 2: case /* int32 total */ 2:
message.total = reader.int64().toBigInt(); message.total = reader.int32();
break; break;
default: default:
let u = options.readUnknownField; let u = options.readUnknownField;
@ -1007,9 +1007,9 @@ class DocumentTextSearchFromLibraryResponse$Type extends MessageType<DocumentTex
/* DocumentService.DocumentList hits = 1; */ /* DocumentService.DocumentList hits = 1; */
if (message.hits) if (message.hits)
DocumentList.internalBinaryWrite(message.hits, writer.tag(1, WireType.LengthDelimited).fork(), options).join(); DocumentList.internalBinaryWrite(message.hits, writer.tag(1, WireType.LengthDelimited).fork(), options).join();
/* int64 total = 2; */ /* int32 total = 2; */
if (message.total !== 0n) if (message.total !== 0)
writer.tag(2, WireType.Varint).int64(message.total); writer.tag(2, WireType.Varint).int32(message.total);
let u = options.writeUnknownFields; let u = options.writeUnknownFields;
if (u !== false) if (u !== false)
(u == true ? UnknownFieldHandler.onWrite : u)(this.typeName, message, writer); (u == true ? UnknownFieldHandler.onWrite : u)(this.typeName, message, writer);
@ -1025,7 +1025,7 @@ class VectorSearchByTextFromLibraryRequest$Type extends MessageType<VectorSearch
constructor() { constructor() {
super("LibraryService.VectorSearchByTextFromLibraryRequest", [ super("LibraryService.VectorSearchByTextFromLibraryRequest", [
{ no: 1, name: "query", kind: "scalar", T: 9 /*ScalarType.STRING*/ }, { no: 1, name: "query", kind: "scalar", T: 9 /*ScalarType.STRING*/ },
{ no: 2, name: "library_id", kind: "scalar", T: 13 /*ScalarType.UINT32*/ } { no: 2, name: "library_id", kind: "scalar", T: 5 /*ScalarType.INT32*/ }
]); ]);
} }
create(value?: PartialMessage<VectorSearchByTextFromLibraryRequest>): VectorSearchByTextFromLibraryRequest { create(value?: PartialMessage<VectorSearchByTextFromLibraryRequest>): VectorSearchByTextFromLibraryRequest {
@ -1044,8 +1044,8 @@ class VectorSearchByTextFromLibraryRequest$Type extends MessageType<VectorSearch
case /* string query */ 1: case /* string query */ 1:
message.query = reader.string(); message.query = reader.string();
break; break;
case /* uint32 library_id */ 2: case /* int32 library_id */ 2:
message.libraryId = reader.uint32(); message.libraryId = reader.int32();
break; break;
default: default:
let u = options.readUnknownField; let u = options.readUnknownField;
@ -1062,9 +1062,9 @@ class VectorSearchByTextFromLibraryRequest$Type extends MessageType<VectorSearch
/* string query = 1; */ /* string query = 1; */
if (message.query !== "") if (message.query !== "")
writer.tag(1, WireType.LengthDelimited).string(message.query); writer.tag(1, WireType.LengthDelimited).string(message.query);
/* uint32 library_id = 2; */ /* int32 library_id = 2; */
if (message.libraryId !== 0) if (message.libraryId !== 0)
writer.tag(2, WireType.Varint).uint32(message.libraryId); writer.tag(2, WireType.Varint).int32(message.libraryId);
let u = options.writeUnknownFields; let u = options.writeUnknownFields;
if (u !== false) if (u !== false)
(u == true ? UnknownFieldHandler.onWrite : u)(this.typeName, message, writer); (u == true ? UnknownFieldHandler.onWrite : u)(this.typeName, message, writer);
@ -1127,9 +1127,9 @@ class DocumentBlockList$Type extends MessageType<DocumentBlockList> {
constructor() { constructor() {
super("LibraryService.DocumentBlockList", [ super("LibraryService.DocumentBlockList", [
{ no: 1, name: "content", kind: "scalar", T: 9 /*ScalarType.STRING*/ }, { no: 1, name: "content", kind: "scalar", T: 9 /*ScalarType.STRING*/ },
{ no: 2, name: "document_id", kind: "scalar", T: 13 /*ScalarType.UINT32*/ }, { no: 2, name: "document_id", kind: "scalar", T: 5 /*ScalarType.INT32*/ },
{ no: 3, name: "library_id", kind: "scalar", T: 13 /*ScalarType.UINT32*/ }, { no: 3, name: "library_id", kind: "scalar", T: 5 /*ScalarType.INT32*/ },
{ no: 4, name: "block_id", kind: "scalar", T: 13 /*ScalarType.UINT32*/ } { no: 4, name: "block_id", kind: "scalar", T: 5 /*ScalarType.INT32*/ }
]); ]);
} }
create(value?: PartialMessage<DocumentBlockList>): DocumentBlockList { create(value?: PartialMessage<DocumentBlockList>): DocumentBlockList {
@ -1150,14 +1150,14 @@ class DocumentBlockList$Type extends MessageType<DocumentBlockList> {
case /* string content */ 1: case /* string content */ 1:
message.content = reader.string(); message.content = reader.string();
break; break;
case /* uint32 document_id */ 2: case /* int32 document_id */ 2:
message.documentId = reader.uint32(); message.documentId = reader.int32();
break; break;
case /* uint32 library_id */ 3: case /* int32 library_id */ 3:
message.libraryId = reader.uint32(); message.libraryId = reader.int32();
break; break;
case /* uint32 block_id */ 4: case /* int32 block_id */ 4:
message.blockId = reader.uint32(); message.blockId = reader.int32();
break; break;
default: default:
let u = options.readUnknownField; let u = options.readUnknownField;
@ -1174,15 +1174,15 @@ class DocumentBlockList$Type extends MessageType<DocumentBlockList> {
/* string content = 1; */ /* string content = 1; */
if (message.content !== "") if (message.content !== "")
writer.tag(1, WireType.LengthDelimited).string(message.content); writer.tag(1, WireType.LengthDelimited).string(message.content);
/* uint32 document_id = 2; */ /* int32 document_id = 2; */
if (message.documentId !== 0) if (message.documentId !== 0)
writer.tag(2, WireType.Varint).uint32(message.documentId); writer.tag(2, WireType.Varint).int32(message.documentId);
/* uint32 library_id = 3; */ /* int32 library_id = 3; */
if (message.libraryId !== 0) if (message.libraryId !== 0)
writer.tag(3, WireType.Varint).uint32(message.libraryId); writer.tag(3, WireType.Varint).int32(message.libraryId);
/* uint32 block_id = 4; */ /* int32 block_id = 4; */
if (message.blockId !== 0) if (message.blockId !== 0)
writer.tag(4, WireType.Varint).uint32(message.blockId); writer.tag(4, WireType.Varint).int32(message.blockId);
let u = options.writeUnknownFields; let u = options.writeUnknownFields;
if (u !== false) if (u !== false)
(u == true ? UnknownFieldHandler.onWrite : u)(this.typeName, message, writer); (u == true ? UnknownFieldHandler.onWrite : u)(this.typeName, message, writer);

View File

@ -3,6 +3,7 @@ import { createRouter, createWebHistory } from "vue-router";
import { useConfigStore } from "@/store/config"; import { useConfigStore } from "@/store/config";
import keycloak from "@/plugins/keycloak" import keycloak from "@/plugins/keycloak"
import { useLoginUrlStore } from "@/store/login_url"; import { useLoginUrlStore } from "@/store/login_url";
import staticConfig from "@/plugins/config"
const routes = [ const routes = [
{ {
@ -14,7 +15,7 @@ const routes = [
// route level code-splitting // route level code-splitting
// this generates a separate chunk (Home-[hash].js) for this route // this generates a separate chunk (Home-[hash].js) for this route
// which is lazy-loaded when the route is visited. // which is lazy-loaded when the route is visited.
component: () => import("@/views/Home.vue"), component: () => import("@/views/libraries/List.vue"),
}, },
{ {
path: "/editor", path: "/editor",
@ -43,31 +44,10 @@ const routes = [
component: () => import("@/views/libraries/Create.vue"), component: () => import("@/views/libraries/Create.vue"),
}, },
{ {
path: "/library/:LibraryId/documents", path: "/documents/:LibraryId/",
name: "library.documents", name: "documents.list",
component: () => import("@/views/documents/List.vue"), component: () => import("@/views/documents/List.vue"),
}, },
{
path: "/library/:LibraryId/query",
name: "library.query",
component: () => import("@/views/libraries/Query.vue"),
},
{
path: "/library/:LibraryId/documents/create",
name: "library.documents.create",
component: () => import("@/views/documents/Create.vue"),
},
{
path: "/library/:LibraryId/documents/:DocumentId/edit",
name: "library.documents.edit",
component: () => import("@/views/documents/Edit.vue"),
},
{
path: "/library/:LibraryId/documents/:DocumentId",
name: "library.documents.view",
component: () => import("@/views/documents/View.vue"),
},
]; ];
const router = createRouter({ const router = createRouter({
@ -112,7 +92,7 @@ router.beforeEach((to, from) => {
} }
if (to.meta.auth) { if (to.meta.auth) {
if (!keycloak.authenticated) { if (!keycloak.authenticated && !staticConfig.devMode) {
router.push({ name: "login" }); router.push({ name: "login" });
} }
} else { } else {

View File

@ -0,0 +1,31 @@
<template>
<h2>文档</h2>
<v-card class="mx-auto" max-width="300">
<v-list :items="documents?.documents"></v-list>
</v-card>
</template>
<script setup lang="ts">
import { ref } from 'vue'
import { VList, VCard } from 'vuetify/lib/components/index.mjs'
import rpc from '@/plugins/rpc'
import { DocumentList, ListDocumentsRequest } from '@/proto/document/document'
const useRpc = rpc()
const documents = ref<DocumentList>()
const listDocumentRequest: ListDocumentsRequest = {
page: 1
}
useRpc.documentClient.listDocuments(listDocumentRequest).then(r => {
documents.value = r.response
})
</script>

View File

@ -11,6 +11,8 @@
></v-text-field> ></v-text-field>
</div> </div>
<p v-if="success" class="text-success">成功</p>
<div class="mt-3"> <div class="mt-3">
<v-btn @click="create">新建</v-btn> <v-btn @click="create">新建</v-btn>
</div> </div>
@ -24,6 +26,7 @@ import * as libraryPb from "@/proto/library/library";
const libraryName = ref("") const libraryName = ref("")
const useRpc = rpc() const useRpc = rpc()
const success = ref(false)
function create() { function create() {
let createLibrary: libraryPb.CreateLibraryRequest = { let createLibrary: libraryPb.CreateLibraryRequest = {
@ -36,6 +39,10 @@ function create() {
useRpc.libraryServiceClient.createLibrary(createLibrary).then((res) => { useRpc.libraryServiceClient.createLibrary(createLibrary).then((res) => {
console.log(res); console.log(res);
if (res.status.code == "OK") {
success.value = true
}
}); });

View File

@ -1,6 +1,6 @@
<template> <template>
<div> <div>
<p>资料库</p> <p>选择一个资料库以开始</p>
</div> </div>
</template> </template>
@ -12,14 +12,17 @@ import router from "@/router";
import * as libraryProto from "@/proto/library/library"; import * as libraryProto from "@/proto/library/library";
import * as documentProto from "@/proto/document/document"; import * as documentProto from "@/proto/document/document";
import keycloak from "@/plugins/keycloak" import keycloak from "@/plugins/keycloak"
import {libraryServiceClient} from "@/plugins/rpc" import rpc from "@/plugins/rpc"
const useRpc = rpc()
let listLibrary = { let listLibrary = {
page: 1 page: 1
} }
libraryServiceClient.listLibraries(listLibrary).then(res => { useRpc.libraryServiceClient.listLibraries(listLibrary).then(res => {
console.log(res) console.log(res)
}) })