chore: 配置全局删除依赖命令
This commit is contained in:
@@ -1,31 +0,0 @@
|
||||
{
|
||||
"name": "Test",
|
||||
"locked": false,
|
||||
"inject": [],
|
||||
"state": {},
|
||||
"lifeCycles": {},
|
||||
"methods": {},
|
||||
"computed": {},
|
||||
"watch": [],
|
||||
"css": "",
|
||||
"props": [],
|
||||
"emits": [],
|
||||
"slots": [],
|
||||
"dataSources": {},
|
||||
"__VTJ_BLOCK__": true,
|
||||
"__VERSION__": "1740022802786",
|
||||
"id": "45taigdrw",
|
||||
"nodes": [
|
||||
{
|
||||
"id": "7pf889krf",
|
||||
"name": "span",
|
||||
"from": "",
|
||||
"invisible": false,
|
||||
"locked": false,
|
||||
"children": "内联容器文本内容示例",
|
||||
"props": {},
|
||||
"directives": [],
|
||||
"events": {}
|
||||
}
|
||||
]
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -5,171 +5,11 @@
|
||||
"name": "低代码编辑器",
|
||||
"homepage": "",
|
||||
"description": "低代码编辑器",
|
||||
"dependencies": [
|
||||
{
|
||||
"package": "vue",
|
||||
"version": "latest",
|
||||
"library": "Vue",
|
||||
"urls": [
|
||||
"@vtj/materials/deps/vue/vue.global.prod.js"
|
||||
],
|
||||
"assetsLibrary": "VueMaterial",
|
||||
"required": true,
|
||||
"official": true,
|
||||
"enabled": true
|
||||
},
|
||||
{
|
||||
"package": "vue-router",
|
||||
"version": "latest",
|
||||
"library": "VueRouter",
|
||||
"urls": [
|
||||
"@vtj/materials/deps/vue-router/vue-router.global.prod.js"
|
||||
],
|
||||
"assetsLibrary": "VueRouterMaterial",
|
||||
"required": true,
|
||||
"official": true,
|
||||
"enabled": true
|
||||
},
|
||||
{
|
||||
"package": "@vtj/utils",
|
||||
"version": "latest",
|
||||
"library": "VtjUtils",
|
||||
"urls": [
|
||||
"@vtj/materials/deps/@vtj/utils/index.umd.js"
|
||||
],
|
||||
"required": true,
|
||||
"official": true,
|
||||
"enabled": true
|
||||
},
|
||||
{
|
||||
"package": "@vtj/icons",
|
||||
"version": "latest",
|
||||
"library": "VtjIcons",
|
||||
"urls": [
|
||||
"@vtj/materials/deps/@vtj/icons/style.css",
|
||||
"@vtj/materials/deps/@vtj/icons/index.umd.js"
|
||||
],
|
||||
"required": true,
|
||||
"official": true,
|
||||
"enabled": true
|
||||
},
|
||||
{
|
||||
"package": "@vueuse/core",
|
||||
"version": "latest",
|
||||
"library": "VueUse",
|
||||
"urls": [
|
||||
"@vtj/materials/deps/@vueuse/shared/index.iife.min.js",
|
||||
"@vtj/materials/deps/@vueuse/core/index.iife.min.js"
|
||||
],
|
||||
"required": false,
|
||||
"official": true,
|
||||
"enabled": true,
|
||||
"platform": [
|
||||
"web",
|
||||
"h5"
|
||||
]
|
||||
},
|
||||
{
|
||||
"package": "element-plus",
|
||||
"version": "latest",
|
||||
"library": "ElementPlus",
|
||||
"localeLibrary": "ElementPlusLocaleZhCn",
|
||||
"urls": [
|
||||
"@vtj/materials/deps/element-plus/dark/css-vars.css",
|
||||
"@vtj/materials/deps/element-plus/index.css",
|
||||
"@vtj/materials/deps/element-plus/zh-cn.js",
|
||||
"@vtj/materials/deps/element-plus/index.full.min.js"
|
||||
],
|
||||
"assetsUrl": "@vtj/materials/assets/element/index.umd.js",
|
||||
"assetsLibrary": "ElementPlusMaterial",
|
||||
"required": false,
|
||||
"official": true,
|
||||
"enabled": true,
|
||||
"platform": "web"
|
||||
},
|
||||
{
|
||||
"package": "@vtj/ui",
|
||||
"version": "latest",
|
||||
"library": "VtjUI",
|
||||
"urls": [
|
||||
"@vtj/materials/deps/vxe-table/style.min.css",
|
||||
"@vtj/materials/deps/@vtj/ui/style.css",
|
||||
"@vtj/materials/deps/xe-utils/xe-utils.umd.min.js",
|
||||
"@vtj/materials/deps/vxe-table/index.umd.min.js",
|
||||
"@vtj/materials/deps/@vtj/ui/index.umd.js"
|
||||
],
|
||||
"assetsUrl": "@vtj/materials/assets/ui/index.umd.js",
|
||||
"assetsLibrary": "VtjUIMaterial",
|
||||
"required": false,
|
||||
"official": true,
|
||||
"enabled": true,
|
||||
"platform": "web"
|
||||
},
|
||||
{
|
||||
"package": "ant-design-vue",
|
||||
"version": "latest",
|
||||
"library": "antd",
|
||||
"urls": [
|
||||
"@vtj/materials/deps/ant-design-vue/reset.css",
|
||||
"@vtj/materials/deps/ant-design-vue/dayjs/dayjs.min.js",
|
||||
"@vtj/materials/deps/ant-design-vue/dayjs/plugin/customParseFormat.js",
|
||||
"@vtj/materials/deps/ant-design-vue/dayjs/plugin/weekday.js",
|
||||
"@vtj/materials/deps/ant-design-vue/dayjs/plugin/localeData.js",
|
||||
"@vtj/materials/deps/ant-design-vue/dayjs/plugin/weekOfYear.js",
|
||||
"@vtj/materials/deps/ant-design-vue/dayjs/plugin/weekYear.js",
|
||||
"@vtj/materials/deps/ant-design-vue/dayjs/plugin/advancedFormat.js",
|
||||
"@vtj/materials/deps/ant-design-vue/dayjs/plugin/quarterOfYear.js",
|
||||
"@vtj/materials/deps/ant-design-vue/antd.min.js"
|
||||
],
|
||||
"assetsUrl": "@vtj/materials/assets/antdv/index.umd.js",
|
||||
"assetsLibrary": "AntdvMaterial",
|
||||
"required": false,
|
||||
"official": true,
|
||||
"enabled": true,
|
||||
"platform": [
|
||||
"web"
|
||||
]
|
||||
},
|
||||
{
|
||||
"package": "@vtj/charts",
|
||||
"version": "latest",
|
||||
"library": "VtjCharts",
|
||||
"urls": [
|
||||
"@vtj/materials/deps/echarts/echarts.min.js",
|
||||
"@vtj/materials/deps/@vtj/charts/index.umd.js"
|
||||
],
|
||||
"assetsUrl": "@vtj/materials/assets/charts/index.umd.js",
|
||||
"assetsLibrary": "VtjChartsMaterial",
|
||||
"required": false,
|
||||
"official": true,
|
||||
"enabled": false,
|
||||
"platform": [
|
||||
"web",
|
||||
"h5"
|
||||
]
|
||||
}
|
||||
],
|
||||
"pages": [
|
||||
{
|
||||
"dir": false,
|
||||
"name": "Test",
|
||||
"title": "123",
|
||||
"icon": "",
|
||||
"mask": true,
|
||||
"hidden": false,
|
||||
"raw": false,
|
||||
"pure": false,
|
||||
"meta": "",
|
||||
"cache": false,
|
||||
"id": "45taigdrw",
|
||||
"type": "page"
|
||||
}
|
||||
],
|
||||
"dependencies": [],
|
||||
"pages": [],
|
||||
"blocks": [],
|
||||
"apis": [],
|
||||
"meta": [],
|
||||
"config": {
|
||||
"title": ""
|
||||
},
|
||||
"config": {},
|
||||
"__BASE_PATH__": "/"
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
"build:pre": "vue-tsc && cross-env ENV_TYPE=pre vite build",
|
||||
"build:prod": "vue-tsc && cross-env ENV_TYPE=live vite build",
|
||||
"preview": "vite preview",
|
||||
"clean": "node ./scripts/clean.mjs"
|
||||
"clean": "rimraf node_modules"
|
||||
},
|
||||
"dependencies": {
|
||||
"vue": "~3.5.0",
|
||||
|
||||
@@ -1,51 +1,38 @@
|
||||
<template>
|
||||
<ElConfigProvider :locale="zhCn">
|
||||
<Suspense>
|
||||
<XMask
|
||||
:title="title"
|
||||
:logo="logo || _logo"
|
||||
:menus="menus"
|
||||
:disabled="disabled"
|
||||
:pure="pure"
|
||||
:actions="actions"
|
||||
@action-click="onActionClick"
|
||||
:theme="themeSwitchable"></XMask>
|
||||
</Suspense>
|
||||
</ElConfigProvider>
|
||||
<div class="designer-container" ref="container"></div>
|
||||
</template>
|
||||
<script setup lang="ts">
|
||||
import { Suspense } from 'vue';
|
||||
import { ElConfigProvider, ElMessage } from 'element-plus';
|
||||
import {
|
||||
XMask,
|
||||
useMask,
|
||||
Bell,
|
||||
Lock,
|
||||
SwitchButton,
|
||||
type ActionBarItems,
|
||||
type ActionProps
|
||||
} from '@vtj/web';
|
||||
import zhCn from 'element-plus/es/locale/lang/zh-cn';
|
||||
import _logo from './assets/logo.svg';
|
||||
const { disabled, title, menus, logo, themeSwitchable, pure } = useMask();
|
||||
|
||||
const actions: ActionBarItems = [
|
||||
{
|
||||
name: 'message',
|
||||
icon: Bell,
|
||||
badge: 1
|
||||
},
|
||||
{
|
||||
name: 'lock',
|
||||
icon: Lock
|
||||
},
|
||||
{
|
||||
name: 'logout',
|
||||
icon: SwitchButton
|
||||
<script lang="ts" setup>
|
||||
import { ref } from 'vue';
|
||||
import { Engine, widgetManager, type ProjectModel } from '@vtj/pro';
|
||||
import { ElButton } from 'element-plus';
|
||||
|
||||
import { StorageService } from '@/server';
|
||||
|
||||
const container = ref();
|
||||
const service = new StorageService();
|
||||
const engine = new Engine({
|
||||
container,
|
||||
service,
|
||||
project: {
|
||||
id: 'test',
|
||||
name: '测试'
|
||||
}
|
||||
];
|
||||
});
|
||||
|
||||
const onActionClick = (action: ActionProps) => {
|
||||
ElMessage.success(`click: ${action.name}`);
|
||||
};
|
||||
widgetManager.set('Previewer', {
|
||||
props: {
|
||||
path: (block: any) => {
|
||||
const pathname = location.pathname;
|
||||
return `${pathname}#/preview/${block.id}`;
|
||||
}
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.designer-container {
|
||||
height: 100%;
|
||||
width: 100%;
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -1,53 +1,8 @@
|
||||
import {
|
||||
createProvider,
|
||||
createModules,
|
||||
NodeEnv,
|
||||
autoUpdate,
|
||||
notify,
|
||||
loading,
|
||||
createAdapter,
|
||||
createServiceRequest,
|
||||
IconsPlugin
|
||||
} from '@vtj/web';
|
||||
import { createApp } from 'vue';
|
||||
import router from './router';
|
||||
import App from './App.vue';
|
||||
import { name, description } from '../package.json';
|
||||
import './style/index.scss';
|
||||
import { createMemoryService } from './server';
|
||||
|
||||
const memoryService = createMemoryService();
|
||||
console.log('memoryService', memoryService);
|
||||
|
||||
const app = createApp(App);
|
||||
const adapter = createAdapter({ loading, notify });
|
||||
const request = createServiceRequest(notify);
|
||||
console.log('request', request);
|
||||
// const service = new MemoryService(request);
|
||||
// console.log('service', service);
|
||||
const { provider, onReady } = createProvider({
|
||||
nodeEnv: process.env.NODE_ENV as NodeEnv,
|
||||
modules: createModules(),
|
||||
service: memoryService,
|
||||
adapter,
|
||||
router,
|
||||
dependencies: {
|
||||
Vue: () => import('vue'),
|
||||
VueRouter: () => import('vue-router')
|
||||
},
|
||||
project: {
|
||||
id: name,
|
||||
name: description
|
||||
}
|
||||
});
|
||||
|
||||
onReady(async () => {
|
||||
app.use(router);
|
||||
app.use(provider);
|
||||
app.use(IconsPlugin);
|
||||
app.mount('#app');
|
||||
});
|
||||
|
||||
if (process.env.NODE_ENV === 'production') {
|
||||
autoUpdate();
|
||||
}
|
||||
app.use(router);
|
||||
app.mount('#app');
|
||||
|
||||
@@ -7,32 +7,27 @@ import {
|
||||
ProjectModel,
|
||||
HistoryModel
|
||||
} from '@vtj/core';
|
||||
|
||||
import { mapToObject } from '@vtj/utils';
|
||||
import { Storage, mapToObject } from '@vtj/utils';
|
||||
import { BaseService } from '@vtj/renderer';
|
||||
|
||||
export class MemoryService extends BaseService {
|
||||
private projects: Record<string, ProjectSchema> = {};
|
||||
private materials: Record<string, Record<string, MaterialDescription>> = {};
|
||||
private files: Record<string, BlockSchema> = {};
|
||||
private histories: Record<string, HistorySchema> = {};
|
||||
private historyItems: Record<string, HistoryItem> = {};
|
||||
const storage = new Storage({
|
||||
type: 'local',
|
||||
expired: 0,
|
||||
prefix: '__VTJ_'
|
||||
});
|
||||
|
||||
export class StorageService extends BaseService {
|
||||
public init(project: ProjectSchema): Promise<ProjectSchema> {
|
||||
console.log('MemoryService.init', { project });
|
||||
const model = new ProjectModel(project);
|
||||
const match = this.projects[model.id] || {};
|
||||
const dsl = Object.assign(model.toDsl(), match);
|
||||
this.projects[dsl.id as string] = dsl;
|
||||
console.log('MemoryService.init result', { dsl });
|
||||
const match = storage.get(`project_${model.id}`);
|
||||
const dsl = Object.assign(model.toDsl(), match || {});
|
||||
storage.save(`project_${model.id}`, dsl);
|
||||
return Promise.resolve(dsl);
|
||||
}
|
||||
|
||||
public saveProject(project: ProjectSchema): Promise<boolean> {
|
||||
console.log('MemoryService.saveProject', { project });
|
||||
const model = new ProjectModel(project);
|
||||
this.projects[model.id] = model.toDsl();
|
||||
console.log('MemoryService.saveProject result', { success: true });
|
||||
storage.save(`project_${model.id}`, model.toDsl());
|
||||
return Promise.resolve(true);
|
||||
}
|
||||
|
||||
@@ -40,96 +35,66 @@ export class MemoryService extends BaseService {
|
||||
project: ProjectSchema,
|
||||
materials: Map<string, MaterialDescription>
|
||||
): Promise<boolean> {
|
||||
console.log('MemoryService.saveMaterials', { project, materials });
|
||||
if (project.id) {
|
||||
this.materials[project.id] = mapToObject(materials);
|
||||
}
|
||||
console.log('MemoryService.saveMaterials result', { success: true });
|
||||
storage.save(`materials_${project.id}`, mapToObject(materials));
|
||||
return Promise.resolve(true);
|
||||
}
|
||||
|
||||
public saveFile(file: BlockSchema): Promise<boolean> {
|
||||
console.log('MemoryService.saveFile', { file });
|
||||
this.files[file.id as string] = file;
|
||||
console.log('MemoryService.saveFile result', { success: true });
|
||||
storage.save(`file_${file.id}`, file);
|
||||
return Promise.resolve(true);
|
||||
}
|
||||
|
||||
public getFile(id: string): Promise<BlockSchema> {
|
||||
console.log('MemoryService.getFile', { id });
|
||||
const file = this.files[id];
|
||||
console.log('MemoryService.getFile result', { file });
|
||||
return file ? Promise.resolve(file) : Promise.reject(null);
|
||||
const dsl = storage.get(`file_${id}`);
|
||||
if (dsl) {
|
||||
return Promise.resolve(dsl as BlockSchema);
|
||||
} else {
|
||||
return Promise.reject(null);
|
||||
}
|
||||
}
|
||||
|
||||
public removeFile(id: string): Promise<boolean> {
|
||||
console.log('MemoryService.removeFile', { id });
|
||||
delete this.files[id];
|
||||
console.log('MemoryService.removeFile result', { success: true });
|
||||
storage.remove(`file_${id}`);
|
||||
return Promise.resolve(true);
|
||||
}
|
||||
|
||||
public saveHistory(history: HistorySchema): Promise<boolean> {
|
||||
console.log('MemoryService.saveHistory', { history });
|
||||
this.histories[history.id] = history;
|
||||
console.log('MemoryService.saveHistory result', { success: true });
|
||||
storage.save(`history_${history.id}`, history);
|
||||
return Promise.resolve(true);
|
||||
}
|
||||
|
||||
public removeHistory(id: string): Promise<boolean> {
|
||||
console.log('MemoryService.removeHistory', { id });
|
||||
const history = this.histories[id] as HistorySchema;
|
||||
const history = storage.get(`history_${id}`) as HistorySchema;
|
||||
if (history) {
|
||||
const items = history.items || [];
|
||||
const ids = items.map((item) => item.id);
|
||||
this.removeHistoryItem(id, ids);
|
||||
delete this.historyItems[id];
|
||||
storage.remove(`history_${id}`);
|
||||
}
|
||||
console.log('MemoryService.removeHistory result', { success: true });
|
||||
|
||||
return Promise.resolve(true);
|
||||
}
|
||||
|
||||
public getHistory(id: string): Promise<HistorySchema> {
|
||||
console.log('MemoryService.getHistory', { id });
|
||||
const dsl = this.histories[id];
|
||||
const dsl = storage.get(`history_${id}`);
|
||||
const history = new HistoryModel(dsl || { id });
|
||||
console.log('MemoryService.getHistory result', { history });
|
||||
return Promise.resolve(history);
|
||||
return Promise.resolve(history.toDsl());
|
||||
}
|
||||
|
||||
public getHistoryItem(fId: string, id: string): Promise<HistoryItem> {
|
||||
console.log('MemoryService.getHistoryItem', { fId, id });
|
||||
const key = `${fId}_${id}`;
|
||||
const item = this.historyItems[key] || {};
|
||||
console.log('MemoryService.getHistoryItem result', { item });
|
||||
const item = storage.get(`history_${fId}_${id}`);
|
||||
return Promise.resolve(item);
|
||||
}
|
||||
|
||||
public saveHistoryItem(fId: string, item: HistoryItem): Promise<boolean> {
|
||||
console.log('MemoryService.saveHistoryItem', { fId, item });
|
||||
const key = `${fId}_${item.id}`;
|
||||
this.historyItems[key] = item;
|
||||
console.log('MemoryService.saveHistoryItem result', { success: true });
|
||||
storage.save(`history_${fId}_${item.id}`, item);
|
||||
return Promise.resolve(true);
|
||||
}
|
||||
|
||||
public removeHistoryItem(fId: string, ids: string[]): Promise<boolean> {
|
||||
console.log('MemoryService.removeHistoryItem', { fId, ids });
|
||||
ids.forEach((id) => {
|
||||
const key = `${fId}_${id}`;
|
||||
delete this.historyItems[key];
|
||||
storage.remove(`history_${fId}_${id}`);
|
||||
});
|
||||
console.log('MemoryService.removeHistoryItem result', { success: true });
|
||||
return Promise.resolve(true);
|
||||
}
|
||||
}
|
||||
|
||||
let serviceInstance: MemoryService | null = null;
|
||||
|
||||
export function createMemoryService() {
|
||||
if (serviceInstance) return serviceInstance;
|
||||
{
|
||||
serviceInstance = new MemoryService();
|
||||
return serviceInstance;
|
||||
}
|
||||
}
|
||||
|
||||
24
apps/designer/src/views/draw.vue
Normal file
24
apps/designer/src/views/draw.vue
Normal file
@@ -0,0 +1,24 @@
|
||||
<template>
|
||||
<div ref="container"></div>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { ref } from 'vue';
|
||||
import { Engine } from '@vtj/pro';
|
||||
import { StorageService } from '@/server';
|
||||
|
||||
const container = ref();
|
||||
const service = new StorageService();
|
||||
const engine = new Engine({
|
||||
container,
|
||||
service,
|
||||
project: {
|
||||
id: 'test',
|
||||
name: '测试'
|
||||
}
|
||||
});
|
||||
|
||||
engine.ready(() => {
|
||||
console.log('ready');
|
||||
});
|
||||
</script>
|
||||
Reference in New Issue
Block a user