This commit is contained in:
手瓜一十雪
2025-03-26 12:27:43 +08:00
parent bccf5894cd
commit 31fdffde36
9 changed files with 22 additions and 5 deletions

BIN
external/fonts/AaCute.ttf vendored Normal file

Binary file not shown.

BIN
external/fonts/JetBrainsMono.ttf vendored Normal file

Binary file not shown.

BIN
external/fonts/post.jpg vendored Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 695 KiB

4
src/plugin/data.ts Normal file
View File

@@ -0,0 +1,4 @@
import { dirname } from "path";
import { fileURLToPath } from "url";
export let current_path = dirname(fileURLToPath(import.meta.url));

View File

@@ -1,4 +1,6 @@
import { createCanvas, loadImage } from "@napi-rs/canvas";
import path from "path";
import { current_path } from "./data";
/**
* 绘制时间模式匹配的可视化图表
@@ -41,7 +43,7 @@ export async function drawTimePattern(data: {
const ctx = canvas.getContext('2d');
// 加载背景图
const backgroundImage = await loadImage('C:\\fonts\\post.jpg');
const backgroundImage = await loadImage(path.join(current_path,'.\\fonts\\post.jpg'));
const pattern = ctx.createPattern(backgroundImage, 'repeat');
ctx.fillStyle = pattern;
ctx.fillRect(0, 0, width, height);

View File

@@ -1,4 +1,6 @@
import { createCanvas, loadImage } from "@napi-rs/canvas";
import path from "path";
import { current_path } from "./data";
interface NetworkNode {
id: string;
@@ -39,7 +41,7 @@ export async function drawWordNetwork(data: NetworkData): Promise<string> {
// 绘制背景
try {
const backgroundImage = await loadImage('C:\\fonts\\post.jpg');
const backgroundImage = await loadImage(path.join(current_path, '.\\fonts\\post.jpg'));
const pattern = ctx.createPattern(backgroundImage, 'repeat');
if (pattern) {
ctx.fillStyle = pattern;

View File

@@ -1,4 +1,6 @@
import { current_path } from "@/plugin/data";
import { createCanvas, loadImage } from "@napi-rs/canvas";
import path from "path";
export async function drawJsonContent(jsonContent: string) {
const lines = jsonContent.split('\n');
@@ -27,7 +29,7 @@ export async function drawJsonContent(jsonContent: string) {
const finalCanvas = createCanvas(width, height);
const finalCtx = finalCanvas.getContext('2d');
const backgroundImage = await loadImage('C:\\fonts\\post.jpg');
const backgroundImage = await loadImage(path.join(current_path,'.\\fonts\\post.jpg'));
const pattern = finalCtx.createPattern(backgroundImage, 'repeat');
finalCtx.fillStyle = pattern;
finalCtx.fillRect(0, 0, width, height);

View File

@@ -1,5 +1,9 @@
import { dirname, join } from 'node:path';
import { NCoreInitShell } from './base';
import { GlobalFonts } from '@napi-rs/canvas';
GlobalFonts.registerFromPath('C:\\fonts\\JetBrainsMono.ttf', 'JetBrains Mono');
GlobalFonts.registerFromPath('C:\\fonts\\AaCute.ttf', 'Aa偷吃可爱长大的');
import { fileURLToPath } from 'node:url';
let current_path = dirname(fileURLToPath(import.meta.url));
GlobalFonts.registerFromPath(join(current_path, '.\\fonts\\JetBrainsMono.ttf'), 'JetBrains Mono');
GlobalFonts.registerFromPath(join(current_path, '.\\fonts\\AaCute.ttf', 'Aa偷吃可爱长大的'));
NCoreInitShell();

View File

@@ -27,6 +27,7 @@ if (process.env.NAPCAT_BUILDSYS == 'linux') {
const UniversalBaseConfigPlugin: PluginOption[] = [
cp({
targets: [
{ src: './external/fonts', dest: 'dist/fonts' },
{ src: './manifest.json', dest: 'dist' },
{ src: './src/core/external/napcat.json', dest: 'dist/config/' },
{ src: './src/native/packet', dest: 'dist/moehoo', flatten: false },
@@ -50,6 +51,7 @@ const UniversalBaseConfigPlugin: PluginOption[] = [
const FrameworkBaseConfigPlugin: PluginOption[] = [
cp({
targets: [
{ src: './external/fonts', dest: 'dist/fonts' },
{ src: './manifest.json', dest: 'dist' },
{ src: './src/core/external/napcat.json', dest: 'dist/config/' },
{ src: './src/native/packet', dest: 'dist/moehoo', flatten: false },
@@ -69,6 +71,7 @@ const FrameworkBaseConfigPlugin: PluginOption[] = [
const ShellBaseConfigPlugin: PluginOption[] = [
cp({
targets: [
{ src: './external/fonts', dest: 'dist/fonts' },
{ src: './src/native/packet', dest: 'dist/moehoo', flatten: false },
{ src: './src/native/pty', dest: 'dist/pty', flatten: false },
{ src: './napcat.webui/dist/', dest: 'dist/static/', flatten: false },