chore:平台容器框架升级,修复命令行环境丢失的问题
This commit is contained in:
@@ -1,12 +1,12 @@
|
||||
<template>
|
||||
<el-config-provider :locale="zhCn">
|
||||
<Suspense>
|
||||
<router-view></router-view>
|
||||
</Suspense>
|
||||
</el-config-provider>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { ElConfigProvider } from 'element-plus';
|
||||
import zhCn from 'element-plus/es/locale/lang/zh-cn';
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<ElConfigProvider :locale="zhCn">
|
||||
<Suspense>
|
||||
<router-view />
|
||||
</Suspense>
|
||||
</ElConfigProvider>
|
||||
</template>
|
||||
|
||||
165
apps/designer/src/auto-imports.d.ts
vendored
165
apps/designer/src/auto-imports.d.ts
vendored
@@ -6,83 +6,98 @@
|
||||
// biome-ignore lint: disable
|
||||
export {}
|
||||
declare global {
|
||||
const EffectScope: typeof import('vue')['EffectScope']
|
||||
const acceptHMRUpdate: typeof import('pinia')['acceptHMRUpdate']
|
||||
const computed: typeof import('vue')['computed']
|
||||
const createApp: typeof import('vue')['createApp']
|
||||
const createPinia: typeof import('pinia')['createPinia']
|
||||
const customRef: typeof import('vue')['customRef']
|
||||
const defineAsyncComponent: typeof import('vue')['defineAsyncComponent']
|
||||
const defineComponent: typeof import('vue')['defineComponent']
|
||||
const defineStore: typeof import('pinia')['defineStore']
|
||||
const effectScope: typeof import('vue')['effectScope']
|
||||
const getActivePinia: typeof import('pinia')['getActivePinia']
|
||||
const getCurrentInstance: typeof import('vue')['getCurrentInstance']
|
||||
const getCurrentScope: typeof import('vue')['getCurrentScope']
|
||||
const h: typeof import('vue')['h']
|
||||
const inject: typeof import('vue')['inject']
|
||||
const isProxy: typeof import('vue')['isProxy']
|
||||
const isReactive: typeof import('vue')['isReactive']
|
||||
const isReadonly: typeof import('vue')['isReadonly']
|
||||
const isRef: typeof import('vue')['isRef']
|
||||
const mapActions: typeof import('pinia')['mapActions']
|
||||
const mapGetters: typeof import('pinia')['mapGetters']
|
||||
const mapState: typeof import('pinia')['mapState']
|
||||
const mapStores: typeof import('pinia')['mapStores']
|
||||
const mapWritableState: typeof import('pinia')['mapWritableState']
|
||||
const markRaw: typeof import('vue')['markRaw']
|
||||
const nextTick: typeof import('vue')['nextTick']
|
||||
const onActivated: typeof import('vue')['onActivated']
|
||||
const onBeforeMount: typeof import('vue')['onBeforeMount']
|
||||
const onBeforeRouteLeave: typeof import('vue-router')['onBeforeRouteLeave']
|
||||
const onBeforeRouteUpdate: typeof import('vue-router')['onBeforeRouteUpdate']
|
||||
const onBeforeUnmount: typeof import('vue')['onBeforeUnmount']
|
||||
const onBeforeUpdate: typeof import('vue')['onBeforeUpdate']
|
||||
const onDeactivated: typeof import('vue')['onDeactivated']
|
||||
const onErrorCaptured: typeof import('vue')['onErrorCaptured']
|
||||
const onMounted: typeof import('vue')['onMounted']
|
||||
const onRenderTracked: typeof import('vue')['onRenderTracked']
|
||||
const onRenderTriggered: typeof import('vue')['onRenderTriggered']
|
||||
const onScopeDispose: typeof import('vue')['onScopeDispose']
|
||||
const onServerPrefetch: typeof import('vue')['onServerPrefetch']
|
||||
const onUnmounted: typeof import('vue')['onUnmounted']
|
||||
const onUpdated: typeof import('vue')['onUpdated']
|
||||
const onWatcherCleanup: typeof import('vue')['onWatcherCleanup']
|
||||
const provide: typeof import('vue')['provide']
|
||||
const reactive: typeof import('vue')['reactive']
|
||||
const readonly: typeof import('vue')['readonly']
|
||||
const ref: typeof import('vue')['ref']
|
||||
const resolveComponent: typeof import('vue')['resolveComponent']
|
||||
const setActivePinia: typeof import('pinia')['setActivePinia']
|
||||
const setMapStoreSuffix: typeof import('pinia')['setMapStoreSuffix']
|
||||
const shallowReactive: typeof import('vue')['shallowReactive']
|
||||
const shallowReadonly: typeof import('vue')['shallowReadonly']
|
||||
const shallowRef: typeof import('vue')['shallowRef']
|
||||
const storeToRefs: typeof import('pinia')['storeToRefs']
|
||||
const toRaw: typeof import('vue')['toRaw']
|
||||
const toRef: typeof import('vue')['toRef']
|
||||
const toRefs: typeof import('vue')['toRefs']
|
||||
const toValue: typeof import('vue')['toValue']
|
||||
const triggerRef: typeof import('vue')['triggerRef']
|
||||
const unref: typeof import('vue')['unref']
|
||||
const useAttrs: typeof import('vue')['useAttrs']
|
||||
const useCssModule: typeof import('vue')['useCssModule']
|
||||
const useCssVars: typeof import('vue')['useCssVars']
|
||||
const useId: typeof import('vue')['useId']
|
||||
const useLink: typeof import('vue-router')['useLink']
|
||||
const useModel: typeof import('vue')['useModel']
|
||||
const useRoute: typeof import('vue-router')['useRoute']
|
||||
const useRouter: typeof import('vue-router')['useRouter']
|
||||
const useSlots: typeof import('vue')['useSlots']
|
||||
const useTemplateRef: typeof import('vue')['useTemplateRef']
|
||||
const watch: typeof import('vue')['watch']
|
||||
const watchEffect: typeof import('vue')['watchEffect']
|
||||
const watchPostEffect: typeof import('vue')['watchPostEffect']
|
||||
const watchSyncEffect: typeof import('vue')['watchSyncEffect']
|
||||
const EffectScope: (typeof import('vue'))['EffectScope'];
|
||||
const acceptHMRUpdate: (typeof import('pinia'))['acceptHMRUpdate'];
|
||||
const computed: (typeof import('vue'))['computed'];
|
||||
const createApp: (typeof import('vue'))['createApp'];
|
||||
const createPinia: (typeof import('pinia'))['createPinia'];
|
||||
const customRef: (typeof import('vue'))['customRef'];
|
||||
const defineAsyncComponent: (typeof import('vue'))['defineAsyncComponent'];
|
||||
const defineComponent: (typeof import('vue'))['defineComponent'];
|
||||
const defineStore: (typeof import('pinia'))['defineStore'];
|
||||
const effectScope: (typeof import('vue'))['effectScope'];
|
||||
const getActivePinia: (typeof import('pinia'))['getActivePinia'];
|
||||
const getCurrentInstance: (typeof import('vue'))['getCurrentInstance'];
|
||||
const getCurrentScope: (typeof import('vue'))['getCurrentScope'];
|
||||
const h: (typeof import('vue'))['h'];
|
||||
const inject: (typeof import('vue'))['inject'];
|
||||
const isProxy: (typeof import('vue'))['isProxy'];
|
||||
const isReactive: (typeof import('vue'))['isReactive'];
|
||||
const isReadonly: (typeof import('vue'))['isReadonly'];
|
||||
const isRef: (typeof import('vue'))['isRef'];
|
||||
const mapActions: (typeof import('pinia'))['mapActions'];
|
||||
const mapGetters: (typeof import('pinia'))['mapGetters'];
|
||||
const mapState: (typeof import('pinia'))['mapState'];
|
||||
const mapStores: (typeof import('pinia'))['mapStores'];
|
||||
const mapWritableState: (typeof import('pinia'))['mapWritableState'];
|
||||
const markRaw: (typeof import('vue'))['markRaw'];
|
||||
const nextTick: (typeof import('vue'))['nextTick'];
|
||||
const onActivated: (typeof import('vue'))['onActivated'];
|
||||
const onBeforeMount: (typeof import('vue'))['onBeforeMount'];
|
||||
const onBeforeRouteLeave: (typeof import('vue-router'))['onBeforeRouteLeave'];
|
||||
const onBeforeRouteUpdate: (typeof import('vue-router'))['onBeforeRouteUpdate'];
|
||||
const onBeforeUnmount: (typeof import('vue'))['onBeforeUnmount'];
|
||||
const onBeforeUpdate: (typeof import('vue'))['onBeforeUpdate'];
|
||||
const onDeactivated: (typeof import('vue'))['onDeactivated'];
|
||||
const onErrorCaptured: (typeof import('vue'))['onErrorCaptured'];
|
||||
const onMounted: (typeof import('vue'))['onMounted'];
|
||||
const onRenderTracked: (typeof import('vue'))['onRenderTracked'];
|
||||
const onRenderTriggered: (typeof import('vue'))['onRenderTriggered'];
|
||||
const onScopeDispose: (typeof import('vue'))['onScopeDispose'];
|
||||
const onServerPrefetch: (typeof import('vue'))['onServerPrefetch'];
|
||||
const onUnmounted: (typeof import('vue'))['onUnmounted'];
|
||||
const onUpdated: (typeof import('vue'))['onUpdated'];
|
||||
const onWatcherCleanup: (typeof import('vue'))['onWatcherCleanup'];
|
||||
const provide: (typeof import('vue'))['provide'];
|
||||
const reactive: (typeof import('vue'))['reactive'];
|
||||
const readonly: (typeof import('vue'))['readonly'];
|
||||
const ref: (typeof import('vue'))['ref'];
|
||||
const resolveComponent: (typeof import('vue'))['resolveComponent'];
|
||||
const setActivePinia: (typeof import('pinia'))['setActivePinia'];
|
||||
const setMapStoreSuffix: (typeof import('pinia'))['setMapStoreSuffix'];
|
||||
const shallowReactive: (typeof import('vue'))['shallowReactive'];
|
||||
const shallowReadonly: (typeof import('vue'))['shallowReadonly'];
|
||||
const shallowRef: (typeof import('vue'))['shallowRef'];
|
||||
const storeToRefs: (typeof import('pinia'))['storeToRefs'];
|
||||
const toRaw: (typeof import('vue'))['toRaw'];
|
||||
const toRef: (typeof import('vue'))['toRef'];
|
||||
const toRefs: (typeof import('vue'))['toRefs'];
|
||||
const toValue: (typeof import('vue'))['toValue'];
|
||||
const triggerRef: (typeof import('vue'))['triggerRef'];
|
||||
const unref: (typeof import('vue'))['unref'];
|
||||
const useAttrs: (typeof import('vue'))['useAttrs'];
|
||||
const useCssModule: (typeof import('vue'))['useCssModule'];
|
||||
const useCssVars: (typeof import('vue'))['useCssVars'];
|
||||
const useId: (typeof import('vue'))['useId'];
|
||||
const useLink: (typeof import('vue-router'))['useLink'];
|
||||
const useModel: (typeof import('vue'))['useModel'];
|
||||
const useRoute: (typeof import('vue-router'))['useRoute'];
|
||||
const useRouter: (typeof import('vue-router'))['useRouter'];
|
||||
const useSlots: (typeof import('vue'))['useSlots'];
|
||||
const useTemplateRef: (typeof import('vue'))['useTemplateRef'];
|
||||
const watch: (typeof import('vue'))['watch'];
|
||||
const watchEffect: (typeof import('vue'))['watchEffect'];
|
||||
const watchPostEffect: (typeof import('vue'))['watchPostEffect'];
|
||||
const watchSyncEffect: (typeof import('vue'))['watchSyncEffect'];
|
||||
}
|
||||
// for type re-export
|
||||
declare global {
|
||||
// @ts-ignore
|
||||
export type { Component, ComponentPublicInstance, ComputedRef, DirectiveBinding, ExtractDefaultPropTypes, ExtractPropTypes, ExtractPublicPropTypes, InjectionKey, PropType, Ref, MaybeRef, MaybeRefOrGetter, VNode, WritableComputedRef } from 'vue'
|
||||
import('vue')
|
||||
export type {
|
||||
Component,
|
||||
ComponentPublicInstance,
|
||||
ComputedRef,
|
||||
DirectiveBinding,
|
||||
ExtractDefaultPropTypes,
|
||||
ExtractPropTypes,
|
||||
ExtractPublicPropTypes,
|
||||
InjectionKey,
|
||||
PropType,
|
||||
Ref,
|
||||
MaybeRef,
|
||||
MaybeRefOrGetter,
|
||||
VNode,
|
||||
WritableComputedRef
|
||||
} from 'vue';
|
||||
import('vue');
|
||||
}
|
||||
|
||||
5
apps/designer/src/env.d.ts
vendored
5
apps/designer/src/env.d.ts
vendored
@@ -1,7 +1,8 @@
|
||||
/// <reference types="vite/client" />
|
||||
// / <reference types="vite/client" />
|
||||
|
||||
declare module '*.vue' {
|
||||
import type { DefineComponent } from 'vue';
|
||||
|
||||
const component: DefineComponent<{}, {}, any>;
|
||||
export default component;
|
||||
}
|
||||
@@ -12,7 +13,7 @@ declare namespace NodeJS {
|
||||
}
|
||||
}
|
||||
|
||||
declare module global {
|
||||
declare namespace global {
|
||||
interface Window {}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
import { type BlockSchema } from '@vtj/core';
|
||||
import type { BlockSchema } from '@vtj/core';
|
||||
|
||||
import instance from './instance';
|
||||
import { fi } from 'element-plus/es/locale/index.mjs';
|
||||
|
||||
export type LowCodeFileSchema = {
|
||||
project_id: number;
|
||||
publish: boolean;
|
||||
active: boolean;
|
||||
dsl: BlockSchema;
|
||||
file_path?: string;
|
||||
file_id?: string;
|
||||
file_path?: string;
|
||||
project_id: number;
|
||||
publish: boolean;
|
||||
};
|
||||
|
||||
function transformFile(file: LowCodeFileSchema): LowCodeFileSchema {
|
||||
|
||||
@@ -1,12 +1,13 @@
|
||||
import type { HistorySchema } from '@vtj/core';
|
||||
|
||||
import instance from './instance';
|
||||
import { type HistorySchema } from '@vtj/core';
|
||||
|
||||
export type LowCodeHistorySchema = {
|
||||
project_id: number;
|
||||
dsl?: HistorySchema;
|
||||
file_id: string;
|
||||
history_id: string;
|
||||
id?: string;
|
||||
dsl?: HistorySchema;
|
||||
project_id: number;
|
||||
};
|
||||
|
||||
function transformHistoryData(data: LowCodeHistorySchema) {
|
||||
@@ -20,12 +21,12 @@ export type HistoriesResponse = {
|
||||
code: number;
|
||||
data: {
|
||||
list: Array<{
|
||||
id: number;
|
||||
project_id: number;
|
||||
created_at: string;
|
||||
dsl: Record<string, any>;
|
||||
file_id: string;
|
||||
history_id: string;
|
||||
dsl: Record<string, any>;
|
||||
created_at: string;
|
||||
id: number;
|
||||
project_id: number;
|
||||
updated_at: string;
|
||||
}>;
|
||||
total: number;
|
||||
@@ -34,10 +35,10 @@ export type HistoriesResponse = {
|
||||
};
|
||||
|
||||
export type GetHistoriesParams = {
|
||||
project_id: number;
|
||||
file_id: string;
|
||||
page?: number;
|
||||
per_page?: number;
|
||||
project_id: number;
|
||||
};
|
||||
|
||||
export const getHistories = async (params: GetHistoriesParams) => {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
export * from './api';
|
||||
export * from './application';
|
||||
export * from './block';
|
||||
export * from './file';
|
||||
export * from './history';
|
||||
export * from './materials';
|
||||
export * from './project';
|
||||
export * from './application';
|
||||
export * from './history';
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { type MaterialDescription } from '@vtj/core';
|
||||
import type { MaterialDescription } from '@vtj/core';
|
||||
|
||||
import instance from './instance';
|
||||
|
||||
@@ -52,13 +52,13 @@ export const getMaterials = async (id: number): Promise<MaterialResponse> => {
|
||||
};
|
||||
|
||||
type MaterialData = {
|
||||
project_id: number;
|
||||
value: Record<string, MaterialDescription>;
|
||||
created_at?: string;
|
||||
// 从原interface合并的字段
|
||||
id?: number;
|
||||
name?: string;
|
||||
created_at?: string;
|
||||
project_id: number;
|
||||
updated_at?: string;
|
||||
value: Record<string, MaterialDescription>;
|
||||
};
|
||||
|
||||
function transformMaterialData(data: MaterialData) {
|
||||
|
||||
@@ -1,11 +1,13 @@
|
||||
import { createApp } from 'vue';
|
||||
|
||||
import { createPersistedState } from 'pinia-plugin-persistedstate';
|
||||
|
||||
import router from './router';
|
||||
import App from './App.vue';
|
||||
import './style/index.scss';
|
||||
import router from './router';
|
||||
import { pinia } from './store';
|
||||
|
||||
import './style/index.scss';
|
||||
|
||||
// 添加持久化插件
|
||||
pinia.use(
|
||||
createPersistedState({
|
||||
|
||||
@@ -1,55 +1,105 @@
|
||||
// @ts-nocheck
|
||||
import {
|
||||
type ProjectSchema,
|
||||
type BlockSchema,
|
||||
type HistorySchema,
|
||||
type HistoryItem,
|
||||
type MaterialDescription,
|
||||
type ExtensionConfig,
|
||||
type PageFile,
|
||||
type BlockFile,
|
||||
type NodeFromPlugin,
|
||||
ProjectModel,
|
||||
HistoryModel
|
||||
import type {
|
||||
BlockFile,
|
||||
BlockSchema,
|
||||
ExtensionConfig,
|
||||
HistoryItem,
|
||||
HistorySchema,
|
||||
MaterialDescription,
|
||||
NodeFromPlugin,
|
||||
PageFile,
|
||||
ProjectSchema
|
||||
} from '@vtj/core';
|
||||
import { mapToObject, Storage } from '@vtj/utils';
|
||||
import { BaseService } from '@vtj/renderer';
|
||||
import { isEmpty } from 'licia-es';
|
||||
|
||||
import {
|
||||
getProject,
|
||||
updateProject,
|
||||
createFile,
|
||||
updateFile as updateLowCodeFile,
|
||||
getFile as getLowCodeFile,
|
||||
deleteFile as deleteLowCodeFile,
|
||||
getHistory as getLowCodeHistory,
|
||||
deleteHistory as deleteLowCodeHistory,
|
||||
createHistory as createLowCodeHistory,
|
||||
deleteFile as deleteLowCodeFile,
|
||||
deleteHistory as deleteLowCodeHistory,
|
||||
getFile as getLowCodeFile,
|
||||
getHistories as getLowCodeHistories,
|
||||
publishFile as publishLowCodeFile,
|
||||
publishAllFile as publishLowCodeAllFile,
|
||||
getHistory as getLowCodeHistory,
|
||||
getMaterials as getLowCodeMaterials,
|
||||
getProject,
|
||||
postMaterials as postLowCodeMaterials,
|
||||
publishAllFile as publishLowCodeAllFile,
|
||||
publishFile as publishLowCodeFile,
|
||||
updateFile as updateLowCodeFile,
|
||||
updateMaterials as updateLowCodeMaterials,
|
||||
deleteMaterials as deleteLowCodeMaterials
|
||||
updateProject
|
||||
} from '@/io';
|
||||
// @ts-nocheck
|
||||
import { HistoryModel, ProjectModel } from '@vtj/core';
|
||||
import { BaseService } from '@vtj/renderer';
|
||||
import { mapToObject, Storage } from '@vtj/utils';
|
||||
import { isEmpty } from 'licia-es';
|
||||
|
||||
const storage = new Storage({
|
||||
type: 'local',
|
||||
expired: 0
|
||||
});
|
||||
|
||||
const stringifyFields = [
|
||||
'config',
|
||||
'pages',
|
||||
'dependencies',
|
||||
'blocks',
|
||||
const stringifyFields = new Set([
|
||||
'apis',
|
||||
'meta'
|
||||
];
|
||||
'blocks',
|
||||
'config',
|
||||
'dependencies',
|
||||
'meta',
|
||||
'pages'
|
||||
]);
|
||||
|
||||
let initProject: ProjectSchema;
|
||||
|
||||
export class LowCodeService extends BaseService {
|
||||
public api = (type: string, data: any): Promise<any> => {
|
||||
// console.log('api', type, data);
|
||||
return Promise.resolve(true);
|
||||
};
|
||||
|
||||
public getExtension(): Promise<ExtensionConfig | undefined> {
|
||||
const extension = storage.get('extension');
|
||||
console.log('ExtensionConfig', extension);
|
||||
return Promise.resolve(extension as ExtensionConfig | undefined);
|
||||
}
|
||||
|
||||
public async getFile(id: string): Promise<BlockSchema> {
|
||||
return getLowCodeFile(id).then((lowCodeFile) => {
|
||||
return lowCodeFile.dsl
|
||||
? Promise.resolve(lowCodeFile.dsl as BlockSchema)
|
||||
: Promise.reject(null);
|
||||
});
|
||||
}
|
||||
|
||||
public async getHistory(fileId: string): Promise<HistorySchema> {
|
||||
const histories = await getLowCodeHistories({
|
||||
project_id: initProject.id,
|
||||
file_id: fileId,
|
||||
per_page: 50
|
||||
});
|
||||
const formatDsl = {
|
||||
id: histories.list[0].file_id,
|
||||
items: histories.list.map((item) => {
|
||||
return {
|
||||
...item,
|
||||
id: item.history_id,
|
||||
label: item.created_at
|
||||
};
|
||||
})
|
||||
};
|
||||
const history = new HistoryModel(formatDsl);
|
||||
return history.toDsl();
|
||||
}
|
||||
|
||||
public async getHistoryItem(fId: string, id: string): Promise<HistoryItem> {
|
||||
const history = await getLowCodeHistory(id);
|
||||
return history;
|
||||
}
|
||||
|
||||
public getPluginMaterial(
|
||||
from: NodeFromPlugin
|
||||
): Promise<MaterialDescription | null> {
|
||||
return Promise.resolve(null);
|
||||
}
|
||||
|
||||
public async init(project: ProjectSchema): Promise<ProjectSchema> {
|
||||
console.log('init', project);
|
||||
initProject = project;
|
||||
@@ -64,34 +114,85 @@ export class LowCodeService extends BaseService {
|
||||
const model = new ProjectModel(remoteProject);
|
||||
console.log('model', model || { id: initProject.id });
|
||||
const dsl = model.toDsl();
|
||||
return Promise.resolve(dsl);
|
||||
return dsl;
|
||||
}
|
||||
|
||||
public getExtension(): Promise<ExtensionConfig | undefined> {
|
||||
const extension = storage.get('extension');
|
||||
console.log('ExtensionConfig', extension);
|
||||
return Promise.resolve(extension as ExtensionConfig | undefined);
|
||||
public publish(project: ProjectSchema): Promise<boolean> {
|
||||
return publishLowCodeAllFile(Number(project.id)).then((res) => {
|
||||
return true;
|
||||
});
|
||||
}
|
||||
|
||||
public async saveProject(project: ProjectSchema): Promise<boolean> {
|
||||
const newProject = {
|
||||
...project,
|
||||
...Object.fromEntries(
|
||||
Object.entries(project)
|
||||
.filter(([key]) => stringifyFields.includes(key))
|
||||
.map(([key, value]) => [key, JSON.stringify(value)])
|
||||
)
|
||||
};
|
||||
// 剔除引擎自行添加的 id,避免接口更新冲突报错
|
||||
Reflect.deleteProperty(newProject, 'id');
|
||||
await updateProject(initProject.id, newProject);
|
||||
public publishFile(
|
||||
project: ProjectSchema,
|
||||
file: BlockFile | PageFile
|
||||
): Promise<boolean> {
|
||||
return publishLowCodeFile(file.id).then((res) => {
|
||||
return true;
|
||||
});
|
||||
}
|
||||
|
||||
public async removeFile(id: string): Promise<boolean> {
|
||||
return deleteLowCodeFile(id).then(() => true);
|
||||
}
|
||||
|
||||
// TODO: 做成数据库存储后没啥用,保留就行
|
||||
public removeHistory(id: string): Promise<boolean> {
|
||||
// console.log('removeHistory', id);
|
||||
return Promise.resolve(true);
|
||||
}
|
||||
public async removeHistoryItem(fId: string, ids: string[]): Promise<boolean> {
|
||||
await Promise.all(ids.map((id) => deleteLowCodeHistory(id)));
|
||||
return true;
|
||||
}
|
||||
|
||||
public getPluginMaterial(
|
||||
from: NodeFromPlugin
|
||||
): Promise<MaterialDescription | null> {
|
||||
return Promise.resolve(null);
|
||||
public async saveFile(file: BlockSchema): Promise<boolean> {
|
||||
console.log('saveFile', file);
|
||||
if (file.id) {
|
||||
const existFile = await getLowCodeFile(file.id);
|
||||
return existFile.file_id
|
||||
? updateLowCodeFile(file.id, {
|
||||
...existFile,
|
||||
dsl: file
|
||||
})
|
||||
.then(() => {
|
||||
return true;
|
||||
})
|
||||
.catch((error) => {
|
||||
throw error;
|
||||
})
|
||||
: createFile({
|
||||
project_id: initProject.id,
|
||||
publish: false,
|
||||
active: true,
|
||||
dsl: file,
|
||||
file_id: file.id
|
||||
})
|
||||
.then(() => {
|
||||
return true;
|
||||
})
|
||||
.catch((error) => {
|
||||
throw error;
|
||||
});
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public async saveHistory(history: HistorySchema): Promise<boolean> {
|
||||
return true;
|
||||
}
|
||||
|
||||
public async saveHistoryItem(
|
||||
fileId: string,
|
||||
historyItem: HistoryItem
|
||||
): Promise<boolean> {
|
||||
await createLowCodeHistory({
|
||||
project_id: initProject.id,
|
||||
file_id: fileId,
|
||||
history_id: historyItem.id,
|
||||
dsl: historyItem.dsl as HistorySchema
|
||||
});
|
||||
return true;
|
||||
}
|
||||
|
||||
// TODO: 物料存储只有在发布为其他端 (比如 uinapp) 时才有用,当前版本时不需要的,暂且保留
|
||||
@@ -120,130 +221,25 @@ export class LowCodeService extends BaseService {
|
||||
|
||||
// @ts-ignore
|
||||
// await deleteLowCodeMaterials(project.id);
|
||||
return Promise.resolve(true);
|
||||
return true;
|
||||
}
|
||||
|
||||
public async saveFile(file: BlockSchema): Promise<boolean> {
|
||||
console.log('saveFile', file);
|
||||
if (file.id) {
|
||||
const existFile = await getLowCodeFile(file.id);
|
||||
if (existFile.file_id) {
|
||||
return updateLowCodeFile(file.id, {
|
||||
...existFile,
|
||||
dsl: file
|
||||
})
|
||||
.then(() => {
|
||||
return Promise.resolve(true);
|
||||
})
|
||||
.catch((err) => {
|
||||
return Promise.reject(err);
|
||||
});
|
||||
} else {
|
||||
return createFile({
|
||||
project_id: initProject.id,
|
||||
publish: false,
|
||||
active: true,
|
||||
dsl: file,
|
||||
file_id: file.id
|
||||
})
|
||||
.then(() => {
|
||||
return Promise.resolve(true);
|
||||
})
|
||||
.catch((err) => {
|
||||
return Promise.reject(err);
|
||||
});
|
||||
}
|
||||
}
|
||||
return Promise.resolve(false);
|
||||
public async saveProject(project: ProjectSchema): Promise<boolean> {
|
||||
const newProject = {
|
||||
...project,
|
||||
...Object.fromEntries(
|
||||
Object.entries(project)
|
||||
.filter(([key]) => stringifyFields.has(key))
|
||||
.map(([key, value]) => [key, JSON.stringify(value)])
|
||||
)
|
||||
};
|
||||
// 剔除引擎自行添加的 id,避免接口更新冲突报错
|
||||
Reflect.deleteProperty(newProject, 'id');
|
||||
await updateProject(initProject.id, newProject);
|
||||
return true;
|
||||
}
|
||||
|
||||
public async getFile(id: string): Promise<BlockSchema> {
|
||||
return getLowCodeFile(id).then((lowCodeFile) => {
|
||||
if (lowCodeFile.dsl) {
|
||||
return Promise.resolve(lowCodeFile.dsl as BlockSchema);
|
||||
} else {
|
||||
return Promise.reject(null);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public async removeFile(id: string): Promise<boolean> {
|
||||
return deleteLowCodeFile(id).then(() => Promise.resolve(true));
|
||||
}
|
||||
|
||||
public async saveHistory(history: HistorySchema): Promise<boolean> {
|
||||
return Promise.resolve(true);
|
||||
}
|
||||
|
||||
public api = (type: string, data: any): Promise<any> => {
|
||||
// console.log('api', type, data);
|
||||
return Promise.resolve(true);
|
||||
};
|
||||
|
||||
protected uploader = (file: File, projectId: string): Promise<any> => {
|
||||
// console.log('uploader', file, projectId);
|
||||
return Promise.resolve(true);
|
||||
};
|
||||
// TODO: 做成数据库存储后没啥用,保留就行
|
||||
public removeHistory(id: string): Promise<boolean> {
|
||||
// console.log('removeHistory', id);
|
||||
return Promise.resolve(true);
|
||||
}
|
||||
|
||||
public async getHistory(fileId: string): Promise<HistorySchema> {
|
||||
const histories = await getLowCodeHistories({
|
||||
project_id: initProject.id,
|
||||
file_id: fileId,
|
||||
per_page: 50
|
||||
});
|
||||
const formatDsl = {
|
||||
id: histories.list[0].file_id,
|
||||
items: histories.list.map((item) => {
|
||||
return {
|
||||
...item,
|
||||
id: item.history_id,
|
||||
label: item.created_at
|
||||
};
|
||||
})
|
||||
};
|
||||
const history = new HistoryModel(formatDsl);
|
||||
return Promise.resolve(history.toDsl());
|
||||
}
|
||||
|
||||
public async getHistoryItem(fId: string, id: string): Promise<HistoryItem> {
|
||||
const history = await getLowCodeHistory(id);
|
||||
return Promise.resolve(history);
|
||||
}
|
||||
|
||||
public async saveHistoryItem(
|
||||
fileId: string,
|
||||
historyItem: HistoryItem
|
||||
): Promise<boolean> {
|
||||
await createLowCodeHistory({
|
||||
project_id: initProject.id,
|
||||
file_id: fileId,
|
||||
history_id: historyItem.id,
|
||||
dsl: historyItem.dsl as HistorySchema
|
||||
});
|
||||
return Promise.resolve(true);
|
||||
}
|
||||
|
||||
public async removeHistoryItem(fId: string, ids: string[]): Promise<boolean> {
|
||||
await Promise.all(ids.map((id) => deleteLowCodeHistory(id)));
|
||||
return Promise.resolve(true);
|
||||
}
|
||||
public publish(project: ProjectSchema): Promise<boolean> {
|
||||
return publishLowCodeAllFile(Number(project.id)).then((res) => {
|
||||
return Promise.resolve(true);
|
||||
});
|
||||
}
|
||||
|
||||
public publishFile(
|
||||
project: ProjectSchema,
|
||||
file: PageFile | BlockFile
|
||||
): Promise<boolean> {
|
||||
return publishLowCodeFile(file.id).then((res) => {
|
||||
return Promise.resolve(true);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { ref, computed } from 'vue';
|
||||
import axios from 'axios';
|
||||
import { computed, ref } from 'vue';
|
||||
|
||||
import { createPinia, defineStore } from 'pinia';
|
||||
|
||||
// 创建 pinia 实例
|
||||
@@ -38,7 +38,7 @@ export const useUserStore = defineStore('user', () => {
|
||||
|
||||
// 应用配置 store
|
||||
export const useAppStore = defineStore('app', () => {
|
||||
const theme = ref<'light' | 'dark'>('light');
|
||||
const theme = ref<'dark' | 'light'>('light');
|
||||
const sidebarCollapsed = ref(false);
|
||||
|
||||
// 持久化配置
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
@use '@vtj/web/src/index.scss';
|
||||
@use '@vtj/web/src/index';
|
||||
|
||||
html,
|
||||
body,
|
||||
#app {
|
||||
height: 100%;
|
||||
padding: 0;
|
||||
margin: 0;
|
||||
font-size: 14px;
|
||||
height: 100%;
|
||||
overflow: hidden;
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
#vtjLink {
|
||||
|
||||
@@ -1,14 +1,16 @@
|
||||
import * as Vue from 'vue';
|
||||
import * as core from '@vtj/core';
|
||||
import * as VtjUtils from '@vtj/utils';
|
||||
import * as VtjUI from '@vtj/ui';
|
||||
import * as designer from '@vtj/designer';
|
||||
import * as renderer from '@vtj/renderer';
|
||||
import * as VtjIcons from '@vtj/icons';
|
||||
import * as ElementPlus from 'element-plus';
|
||||
import type { ExtensionConfig } from '@vtj/core';
|
||||
import type { EngineOptions } from '@vtj/designer';
|
||||
|
||||
import * as Vue from 'vue';
|
||||
|
||||
import * as core from '@vtj/core';
|
||||
import * as designer from '@vtj/designer';
|
||||
import * as VtjIcons from '@vtj/icons';
|
||||
import * as renderer from '@vtj/renderer';
|
||||
import * as VtjUI from '@vtj/ui';
|
||||
import * as VtjUtils from '@vtj/utils';
|
||||
import * as ElementPlus from 'element-plus';
|
||||
|
||||
export type ExtensionOptions = ExtensionConfig;
|
||||
export type ExtensionFactory = (
|
||||
config: ExtensionConfig
|
||||
@@ -20,11 +22,11 @@ export interface ExtensionOutput {
|
||||
}
|
||||
|
||||
export class Extension {
|
||||
private urls: string[] = [];
|
||||
private __adapters__: Record<string, any> = {};
|
||||
private __BASE_PATH__: string = '/';
|
||||
private library: string = '';
|
||||
private params: any[] = [];
|
||||
private __BASE_PATH__: string = '/';
|
||||
private __adapters__: Record<string, any> = {};
|
||||
private urls: string[] = [];
|
||||
constructor(private options: ExtensionOptions) {
|
||||
const __VTJ_PRO__ = {
|
||||
...core,
|
||||
@@ -62,15 +64,14 @@ export class Extension {
|
||||
.filter((n) => renderer.isJSUrl(n))
|
||||
.map((n) => `${base}${n}`);
|
||||
renderer.loadCssUrl(css);
|
||||
if (scripts.length) {
|
||||
if (scripts.length > 0) {
|
||||
const output = await renderer
|
||||
.loadScriptUrl(scripts, this.library)
|
||||
.catch(() => null);
|
||||
if (output && typeof output === 'function') {
|
||||
options = output.call(output, this.options, this.params);
|
||||
} else {
|
||||
options = output || {};
|
||||
}
|
||||
options =
|
||||
output && typeof output === 'function'
|
||||
? output.call(output, this.options, this.params)
|
||||
: output || {};
|
||||
}
|
||||
}
|
||||
return {
|
||||
|
||||
@@ -4,7 +4,7 @@ import 'element-plus/theme-chalk/index.css';
|
||||
import '@vtj/ui/dist/style.css';
|
||||
import '@vtj/icons/dist/style.css';
|
||||
|
||||
export * from './extension';
|
||||
export * from '@vtj/core';
|
||||
export * from '@vtj/designer';
|
||||
export * from '@vtj/renderer';
|
||||
export * from './extension';
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
<script lang="ts" setup>
|
||||
import { ref } from 'vue';
|
||||
import Postmate from 'postmate';
|
||||
import { Engine, widgetManager } from '@vtj/pro';
|
||||
import { request, jsonp } from '@vtj/utils';
|
||||
import { useUserStore } from '@/store';
|
||||
|
||||
import { LowCodeService } from '@/service';
|
||||
import { useUserStore } from '@/store';
|
||||
import { Engine, widgetManager } from '@vtj/pro';
|
||||
import { jsonp, request } from '@vtj/utils';
|
||||
import Postmate from 'postmate';
|
||||
|
||||
const container = ref();
|
||||
const service = new LowCodeService();
|
||||
@@ -68,7 +69,7 @@ onMounted(async () => {
|
||||
|
||||
<style scoped>
|
||||
.designer-container {
|
||||
height: 100%;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
<script lang="ts" setup>
|
||||
import { XContainer } from '@vtj/web';
|
||||
import { ElEmpty } from 'element-plus';
|
||||
</script>
|
||||
<template>
|
||||
<XContainer class="not-found" fit justify="center">
|
||||
<ElEmpty description="找不到页面【404】"></ElEmpty>
|
||||
<ElEmpty description="找不到页面【404】" />
|
||||
</XContainer>
|
||||
</template>
|
||||
<script lang="ts" setup>
|
||||
import { XContainer } from '@vtj/web';
|
||||
import { ElEmpty } from 'element-plus';
|
||||
</script>
|
||||
<style lang="scss" scoped></style>
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
<template>
|
||||
<XContainer class="unauthorized" fit justify="center">
|
||||
<ElEmpty description="无权限访问该页面"></ElEmpty>
|
||||
</XContainer>
|
||||
</template>
|
||||
<script lang="ts" setup>
|
||||
import { XContainer } from '@vtj/ui';
|
||||
import { ElEmpty } from 'element-plus';
|
||||
</script>
|
||||
<template>
|
||||
<XContainer class="unauthorized" fit justify="center">
|
||||
<ElEmpty description="无权限访问该页面" />
|
||||
</XContainer>
|
||||
</template>
|
||||
<style lang="scss" scoped></style>
|
||||
|
||||
Reference in New Issue
Block a user