feat: introduce WeKnora Lite edition with lightweight configuration and deployment
- Added a new `.env.lite.example` file for the Lite version, providing a minimal configuration template. - Updated `.env.example` to remove deprecated variables and include new Docreader settings. - Enhanced Docker configurations to support the Lite version, including a new Dockerfile for the Docreader service. - Introduced a Makefile target for building and running the Lite version, along with packaging capabilities. - Created GitHub workflows for building and releasing Lite binaries, including Homebrew formula support. - Implemented a new service file for managing the Lite version as a system service. This update enables a streamlined, single-binary deployment of WeKnora, reducing external dependencies and simplifying setup.
This commit is contained in:
+17
-17
@@ -39,29 +39,29 @@ export function formatStringDate(date: any) {
|
||||
year + "-" + month + "-" + day + " " + hour + ":" + minute + ":" + second
|
||||
);
|
||||
}
|
||||
export function kbFileTypeVerification(file: any, silent = false) {
|
||||
let validTypes = ["pdf", "txt", "md", "docx", "doc", "jpg", "jpeg", "png", "csv", "xlsx", "xls"];
|
||||
let type = file.name.substring(file.name.lastIndexOf(".") + 1);
|
||||
if (!validTypes.includes(type)) {
|
||||
const DEFAULT_VALID_TYPES = new Set(["pdf", "txt", "md", "docx", "doc", "pptx", "ppt", "jpg", "jpeg", "png", "csv", "xlsx", "xls"]);
|
||||
|
||||
/**
|
||||
* Returns true when the file should be **rejected**.
|
||||
* @param validTypes - override the default extension whitelist with a dynamic set (e.g. from engine registry).
|
||||
*/
|
||||
export function kbFileTypeVerification(file: any, silent = false, validTypes?: Set<string> | string[]) {
|
||||
const allowed = validTypes
|
||||
? (validTypes instanceof Set ? validTypes : new Set(validTypes))
|
||||
: DEFAULT_VALID_TYPES;
|
||||
|
||||
const type = file.name.substring(file.name.lastIndexOf(".") + 1).toLowerCase();
|
||||
if (!allowed.has(type)) {
|
||||
if (!silent) {
|
||||
MessagePlugin.error("文件类型错误!");
|
||||
MessagePlugin.error("不支持的文件类型!");
|
||||
}
|
||||
return true;
|
||||
}
|
||||
if (
|
||||
(type == "pdf" || type == "docx" || type == "doc") &&
|
||||
file.size > MAX_FILE_SIZE_BYTES
|
||||
) {
|
||||
if (file.size > MAX_FILE_SIZE_BYTES) {
|
||||
if (!silent) {
|
||||
MessagePlugin.error(`pdf/doc文件不能超过${MAX_FILE_SIZE_MB}M!`);
|
||||
MessagePlugin.error(`文件大小不能超过 ${MAX_FILE_SIZE_MB}M!`);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
if ((type == "txt" || type == "md") && file.size > MAX_FILE_SIZE_BYTES) {
|
||||
if (!silent) {
|
||||
MessagePlugin.error(`txt/md文件不能超过${MAX_FILE_SIZE_MB}M!`);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -140,10 +140,14 @@ export function isValidURL(url: string): boolean {
|
||||
if (!url || typeof url !== 'string') {
|
||||
return false;
|
||||
}
|
||||
|
||||
// 允许以 / 开头的站内相对路径(如本地存储 /files/images/xxx.jpg)
|
||||
if (url.startsWith('/') && !url.startsWith('//')) {
|
||||
return true;
|
||||
}
|
||||
|
||||
try {
|
||||
const urlObj = new URL(url);
|
||||
// 只允许 http 和 https 协议
|
||||
return ['http:', 'https:'].includes(urlObj.protocol);
|
||||
} catch {
|
||||
return false;
|
||||
|
||||
Reference in New Issue
Block a user