refactor: 悦码项目重构

This commit is contained in:
wangxuefeng
2025-02-19 13:42:56 +08:00
parent c8c9406fd5
commit eab709f94f
494 changed files with 50986 additions and 27639 deletions

22
packages/render-adapter/.gitignore vendored Normal file
View File

@@ -0,0 +1,22 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*
lerna-debug.log*
node_modules
dist
dist-ssr
*.local
# Editor directories and files
.vscode/*
!.vscode/extensions.json
.idea
.DS_Store
*.suo
*.sln
*.sw?

View File

@@ -0,0 +1,37 @@
# Farm + Vue
This template should help you start developing using Vue and TypeScript in Farm.
## Setup
Install the dependencies:
```bash
pnpm install
```
## Get Started
Start the dev server:
```bash
pnpm start
```
Build the app for production:
```bash
pnpm build
```
Preview the Production build product:
```bash
pnpm preview
```
Clear persistent cache local files
```bash
pnpm clean
```

View File

@@ -0,0 +1,12 @@
import { defineConfig } from "@farmfe/core";
import vue from "@vitejs/plugin-vue";
export default defineConfig({
compilation: {
// 只构建组件
input: {
index: "./src/components/index.ts",
},
},
vitePlugins: [vue()],
});

View File

@@ -0,0 +1,16 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<link rel="icon" type="image/svg+xml" href="/favicon.ico" />
<title>Farm + Vue3 + TS</title>
</head>
<body>
<div id="app"></div>
<script src="./src/index.ts"></script>
</body>
</html>

View File

@@ -0,0 +1,24 @@
{
"name": "@sy/low-code-render-adapter",
"version": "1.0.0",
"scripts": {
"dev": "farm start",
"start": "farm start",
"build": "farm build",
"preview": "farm preview",
"clean": "farm clean",
"clean:lock": "rimraf pnpm-lock.yaml && rimraf package.lock.json",
"clean:lib": "rimraf node_modules"
},
"dependencies": {
"@sy/low-code-shared": "workspace:*",
"vue": "^3.5.13",
"wujie-vue3": "^1.0.24"
},
"devDependencies": {
"@farmfe/cli": "^1.0.4",
"@farmfe/core": "^1.6.6",
"@vitejs/plugin-vue": "^5.2.1",
"core-js": "^3.40.0"
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.1 KiB

View File

@@ -0,0 +1,8 @@
<!-- 仅用于本地调试时预览 -->
<script setup lang="ts">
import Adapter from './components/adapter.vue'
</script>
<template>
<Adapter url="http://localhost:9000/" name="vue3" :plugins="[]" />
</template>

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

View File

@@ -0,0 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" class="iconify iconify--logos" width="37.07" height="36" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 198"><path fill="#41B883" d="M204.8 0H256L128 220.8L0 0h97.92L128 51.2L157.44 0h47.36Z"></path><path fill="#41B883" d="m0 0l128 220.8L256 0h-51.2L128 132.48L50.56 0H0Z"></path><path fill="#35495E" d="M50.56 0L128 133.12L204.8 0h-47.36L128 51.2L97.92 0H50.56Z"></path></svg>

After

Width:  |  Height:  |  Size: 496 B

View File

@@ -0,0 +1,66 @@
<script setup lang="ts">
import WujieVue from "wujie-vue3";
type lifecycle = (appWindow: Window) => any;
type loadErrorHandler = (url: string, e: Error) => any;
type startOption = {
/** 唯一性用户必须保证 */
name: string;
/** 需要渲染的url */
url: string;
/** 需要渲染的html, 如果用户已有则无需从url请求 */
html?: string;
/** 渲染的容器 */
// el: HTMLElement | string;
/** 子应用加载时loading元素 */
loading?: HTMLElement;
/** 路由同步开关, false刷新无效但是前进后退依然有效 */
sync?: boolean;
/** 子应用短路径替换,路由同步时生效 */
prefix?: { [key: string]: string };
/** 子应用保活模式state不会丢失 */
alive?: boolean;
/** 注入给子应用的数据 */
props?: { [key: string]: any };
/** js采用fiber模式执行 */
fiber?: boolean;
/** 子应用采用降级iframe方案 */
degrade?: boolean;
/** 自定义运行iframe的属性 */
attrs?: { [key: string]: any };
/** 自定义降级渲染iframe的属性 */
degradeAttrs?: { [key: string]: any };
/** 代码替换钩子 */
replace?: (codeText: string) => string;
/** 自定义fetch资源和接口 */
fetch?: (input: RequestInfo, init?: RequestInit) => Promise<Response>;
/** 子应插件 */
plugins: Array<Plugin>;
/** 子应用生命周期 */
beforeLoad?: lifecycle;
/** 没有做生命周期改造的子应用不会调用 */
beforeMount?: lifecycle;
afterMount?: lifecycle;
beforeUnmount?: lifecycle;
afterUnmount?: lifecycle;
/** 非保活应用不会调用 */
activated?: lifecycle;
deactivated?: lifecycle;
/** 子应用资源加载失败后调用 */
loadError?: loadErrorHandler
};
const containerId = "low-code-render-adapter";
const props = defineProps<startOption>();
</script>
<template>
<div :id="containerId">
<WujieVue v-bind="props" :el="containerId" />
</div>
</template>
<style scoped></style>

View File

@@ -0,0 +1 @@
export { default as Adapter } from "./adapter.vue";

2
packages/render-adapter/src/env.d.ts vendored Normal file
View File

@@ -0,0 +1,2 @@
declare module '*.vue';
declare module '*.svg';

View File

@@ -0,0 +1,4 @@
import { createApp } from "vue";
import App from "./App.vue";
createApp(App).mount("#app");

View File

@@ -0,0 +1,31 @@
{
"compilerOptions": {
"target": "ES2020",
"useDefineForClassFields": true,
"module": "ESNext",
"lib": ["ES2020", "DOM", "DOM.Iterable"],
"skipLibCheck": true,
/* Bundler mode */
"moduleResolution": "bundler",
"allowImportingTsExtensions": true,
"resolveJsonModule": true,
"isolatedModules": true,
"noEmit": true,
"jsx": "preserve",
/* Linting */
"strict": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"noFallthroughCasesInSwitch": true
},
"include": [
"src/**/*.ts",
"src/**/*.tsx",
"src/**/*.vue",
"src/index.js",
"src/index.js"
],
"references": [{ "path": "./tsconfig.node.json" }]
}

View File

@@ -0,0 +1,11 @@
{
"compilerOptions": {
"composite": true,
"skipLibCheck": true,
"module": "ESNext",
"moduleResolution": "bundler",
"allowSyntheticDefaultImports": true,
"strict": true
},
"include": ["farm.config.ts"]
}