refactor: 确立独立子工程架构 (backend, admin, mpuniapp) 并同步更新 AGENTS.md 规范

这个提交包含在:
wikiboss
2026-09-20 17:05:22 +08:00
父节点 de3cf8b870
当前提交 9fa1d1fbd0
共有 1679 个文件被更改,包括 204798 次插入 和 16817 次删除

查看文件

@@ -0,0 +1,46 @@
<template>
<!-- #ifdef APP -->
<native-view @init="onviewinit"></native-view>
<!-- #endif -->
<!-- #ifndef APP -->
<view></view>
<!-- #endif -->
</template>
<script setup lang="uts">
// #ifdef APP
import { TestNativeView } from "@/uni_modules/test-native-view";
let view : TestNativeView | null = null
// Style样式监听
const style = useComputedStyle({
properties: ['background-color'],
filterProperties: true
} as UseComputedStyleOptions)
const backgroundColor = computed<string>(() => {
return style.get('background-color')?.toString() ?? '#FFFFFF'
})
/**
* 监听background-color变化
*/
watch([backgroundColor], () => {
view?.updateBackground(backgroundColor.value)
})
/**
* native-view组件初始化时触发
* 用于绑定App平台原生View
*/
function onviewinit(e : UniNativeViewInitEvent) {
view = new TestNativeView(e.detail.element)
view?.updateBackground(backgroundColor.value)
}
/**
* App平台主动释放资源
*/
onUnmounted(() => {
view?.destroy()
})
// #endif
</script>

查看文件

@@ -0,0 +1,82 @@
{
"id": "test-native-view",
"displayName": "test-native-view",
"version": "0.0.1",
"description": "测试native-view组件",
"repository": "",
"engines": {
"HBuilderX": "^4.25"
},
"dcloudext": {
"type": "uts",
"sale": {
"regular": {
"price": "0.00"
},
"sourcecode": {
"price": "0.00"
}
},
"contact": {
"qq": ""
},
"declaration": {
"ads": "无",
"data": "插件不采集任何数据",
"permissions": "无"
},
"npmurl": ""
},
"uni_modules": {
"dependencies": [],
"encrypt": [],
"platforms": {
"cloud": {
"tcb": "y",
"aliyun": "y"
},
"client": {
"Vue": {
"vue2": "n",
"vue3": "y"
},
"App": {
"app-android": {
"minVersion": "21"
},
"app-ios": {
"minVersion": "9"
}
},
"H5-mobile": {
"Safari": "y",
"Android Browser": "y",
"微信浏览器(Android)": "y",
"QQ浏览器(Android)": "y"
},
"H5-pc": {
"Chrome": "y",
"IE": "y",
"Edge": "y",
"Firefox": "y",
"Safari": "y"
},
"小程序": {
"微信": "y",
"阿里": "y",
"百度": "y",
"字节跳动": "u",
"QQ": "y",
"钉钉": "u",
"快手": "u",
"飞书": "u",
"京东": "u"
},
"快应用": {
"华为": "u",
"联盟": "u"
}
}
}
}
}

查看文件

@@ -0,0 +1,3 @@
{
"minSdkVersion": "21"
}

查看文件

@@ -0,0 +1,37 @@
import View from "android.view.View"
import Color from "android.graphics.Color"
export class TestNativeView {
$element : UniNativeViewElement
view : View | null = null
constructor(element : UniNativeViewElement) {
this.$element = element
this.bindView()
}
bindView() {
// 构建原生view
this.view = new View(this.$element.getAndroidActivity()!)
this.view.setBackgroundColor(Color.WHITE)
// 绑定原生view
this.$element.bindAndroidView(this.view!)
}
destroy() {
this.view = null
}
/**
* 更新背景颜色
* 仅支持#RRGGBB格式颜色字符串
*/
updateBackground(color: string) {
try{
this.view?.setBackgroundColor(UTSAndroid.colorWithString(color))
}catch(e){
//Nothing to do
}
}
}

查看文件

@@ -0,0 +1,8 @@
@Builder
export function buildView(params: ESObject) {
Stack({alignContent: Alignment.Center})
.width('100%')
.height('100%')
.backgroundColor(params.backgroundColor)
.attributeModifier(params.attributeUpdater)
}

查看文件

@@ -0,0 +1,61 @@
import { BuilderNode } from "@kit.ArkUI"
// 导入混编实现的声明式UI构建函数
import { buildView } from "./builder.ets"
/**
* 颜色转换,仅支持#开头的格式
* uni-app x 蒸汽模式8位时格式为 #RRGGBBAA
* 鸿蒙平台需要的是 #AARRGGBB
*/
class ColorUtils {
static fromUniColor(color: string): string | null {
if(color.startsWith("#")){
const len = color.length
if(len >= 9){
let rgb = color.substring(1, 7)
let a = color.substring(7, 9)
return `#${a}${rgb}`
}
return color;
}
return null
}
}
// Harmony 侧直接传递颜色字符串,避免依赖当前 SDK 未导出的颜色类型。
type NativeViewOptions = {
backgroundColor: string
}
export class TestNativeView {
private $element : UniNativeViewElement;
private builder : BuilderNode<[NativeViewOptions]> | null = null
// 初始化 buildButton 默认参数
private params : NativeViewOptions = {
backgroundColor: '#FFFFFF'
}
constructor(element : UniNativeViewElement) {
// 绑定 wrapBuilder 函数
this.builder = element.bindHarmonyWrappedBuilder(wrapBuilder<[NativeViewOptions]>(buildView), this.params)
this.$element = element
// 绑定当前实例为自定义的controller,方便其他地方通过 element 获取使用
this.$element.bindHarmonyController(this)
}
/**
* 更新背景颜色
* 仅支持#RRGGBB格式颜色字符串
*/
updateBackground(color : string) {
this.params.backgroundColor = UTSHarmony.colorWithString(color)
this.builder?.update(this.params)
}
/**
* 用于拉齐差异,鸿蒙平台无需实现
*/
destroy() {
}
}

查看文件

@@ -0,0 +1,3 @@
{
"deploymentTarget": "12"
}

查看文件

@@ -0,0 +1,35 @@
import { UIView, UIColor } from "UIKit"
import { CGFloat } from 'CoreFoundation';
export class TestNativeView {
$element : UniNativeViewElement;
view : UIView | null = null;
constructor(element : UniNativeViewElement) {
this.$element = element;
super.init()
this.bindView();
}
bindView() {
// 构建原生view
this.view = new UIView()
this.view!.backgroundColor = UIColor.white
// 绑定原生view
this.$element.bindIOSView(this.view!)
}
destroy() {
// 释放 UTS 实例对象,避免内存泄露
UTSiOS.destroyInstance(this)
}
/**
* 更新背景颜色
* 仅支持#RRGGBB格式颜色字符串
*/
updateBackground(color : string) {
this.view!.backgroundColor = UTSiOS.colorWithString(color)
}
}