fix: vditor cdn use local resources (#6229)

This commit is contained in:
chenos 2025-02-17 20:10:20 +08:00 committed by GitHub
parent e99c1cd9b3
commit e33fc10f00
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 14 additions and 7 deletions

View File

@ -27,12 +27,6 @@ export class PluginFieldMarkdownVditorClient extends Plugin {
}
getCDN() {
if (process.env.NODE_ENV !== 'production') {
// 开发模式下使用远程 cdn
return 'https://unpkg.com/vditor@3.10.4';
}
// 生产环境,使用本地链接,支持内网
// 需要支持子目录,比如应用部署在 /xxx/ 目录下
return this.app.getPublicPath() + 'static/plugins/@nocobase/plugin-field-markdown-vditor/dist/client/vditor';
}

View File

@ -8,13 +8,26 @@
*/
import { Plugin } from '@nocobase/server';
import fs from 'fs-extra';
import path from 'path';
export class PluginFieldMarkdownVditorServer extends Plugin {
async afterAdd() {}
async beforeLoad() {}
async load() {}
async load() {
await this.copyVditorDist();
}
async copyVditorDist() {
const vditor = path.dirname(require.resolve('vditor'));
const dist = path.resolve(__dirname, '../../dist/client/vditor/dist');
if (await fs.exists(dist)) {
return;
}
await fs.copy(vditor, dist);
}
async install() {}