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

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

查看文件

@@ -0,0 +1,155 @@
<template>
<!-- #ifdef APP && !VUE3-VAPOR -->
<scroll-view style="flex: 1">
<!-- #endif -->
<view style="flex-grow: 1;">
<text class="uni-tips">说明:左边是正常版本,右边是拍平版本</text>
<view class="demo-box">
<view class="box">
<text class="common" style="color: rgb(0, 0, 255);">color: rgb(0, 0, 255)</text>
<text class="common" style="color: rgba(0, 0, 255, 0.5);">color: rgba(0, 0, 255, 0.5)</text>
<text class="common" style="color: #0000ff;">color: #0000ff</text>
<text class="common" style="color: #00f;">color: #00f</text>
<text class="common" style="color: #00f8;">color: #00f8</text>
<text class="common" style="color: #0000ff80;">color: #0000ff80</text>
<text class="common" style="color: blue;">color: blue</text>
</view>
<view class="box">
<text class="common" style="color: rgb(0, 0, 255);" flatten>color: rgb(0, 0, 255)</text>
<text class="common" style="color: rgba(0, 0, 255, 0.5);" flatten>color: rgba(0, 0, 255, 0.5)</text>
<text class="common" style="color: #0000ff;" flatten>color: #0000ff</text>
<text class="common" style="color: #00f;" flatten>color: #00f</text>
<text class="common" style="color: #00f8;" flatten>color: #00f8</text>
<text class="common" style="color: #0000ff80;" flatten>color: #0000ff80</text>
<text class="common" style="color: blue;" flatten>color: blue</text>
</view>
</view>
<view class="uni-common-mt">
<text class="uni-title-text">setProperty 设置与 getPropertyValue 获取</text>
</view>
<view class="common-box">
<!-- 普通版本 -->
<view class="uni-common-mt">
<text class="uni-title-text">color</text>
<text class="uni-info">设置值: {{data.color}}</text>
<text class="uni-info">获取值: {{data.colorActual}}</text>
<view class="test-box">
<text ref="textRef" class="common test-text" :style="{ color: data.color }">当前 color: {{data.color}}</text>
</view>
</view>
<!-- 拍平版本 -->
<view class="uni-common-mt">
<text class="uni-title-text">测试拍平</text>
<text class="uni-info">设置值: {{data.color}}</text>
<text class="uni-info">获取值: {{data.colorActualFlat}}</text>
<view class="test-box">
<text ref="textRefFlat" class="common test-text-flatten" :style="{ color: data.color }" flatten>当前 color: {{data.color}}</text>
</view>
</view>
</view>
<view class="uni-common-mt uni-common-mb">
<text class="uni-tips">第一个枚举值,'' (空字符串) - 空值情况</text>
<enum-data :items="colorEnum" title="color 枚举值" @change="radioChangeColor" :compact="true"></enum-data>
<input-data :defaultValue="data.color" title="color 自定义值" type="text" @confirm="inputChangeColor"></input-data>
</view>
</view>
<!-- #ifdef APP && !VUE3-VAPOR -->
</scroll-view>
<!-- #endif -->
</template>
<script setup lang="uts">
import { ItemType } from '@/components/enum-data/enum-data-types'
const colorEnum: ItemType[] = [
{ value: 0, name: '' },
{ value: 1, name: 'green' },
{ value: 2, name: '#942192' },
{ value: 3, name: '#000' },
{ value: 4, name: '#0000ff' },
{ value: 5, name: '#00f8' },
{ value: 6, name: '#0000ff80' },
{ value: 7, name: 'rgb(0, 255, 0)' },
{ value: 8, name: 'rgba(0, 255, 0, 0.5)' }
]
const data = reactive({
color: 'cyan',
colorActual: '',
colorActualFlat: ''
})
const textRef = ref(null as UniTextElement | null)
const textRefFlat = ref(null as UniTextElement | null)
const getPropertyValues = () => {
data.colorActual = textRef.value?.style.getPropertyValue('color') ?? ''
data.colorActualFlat = textRefFlat.value?.style.getPropertyValue('color') ?? ''
}
const changeColor = (value: string) => {
data.color = value
textRef.value?.style.setProperty('color', value)
textRefFlat.value?.style.setProperty('color', value)
// 使用 nextTick 确保样式已应用后再获取值
nextTick(() => {
getPropertyValues()
})
}
const radioChangeColor = (index: number) => {
const selectedItem = colorEnum.find((item): boolean => item.value === index)
if (selectedItem != null) {
changeColor(selectedItem.name)
}
}
const inputChangeColor = (value: string) => {
changeColor(value)
}
onReady(() => {
getPropertyValues()
})
defineExpose({
radioChangeColor,
data
})
</script>
<style>
.common {
font-size: 16px;
}
.demo-box {
flex-direction: row;
margin-top: 10px;
justify-content: space-around;
}
.box{
flex:1;
height: 190px;
background-color: gray;
justify-content: center;
align-items: center;
}
.common-box{
flex-direction: row;
justify-content: space-around;
}
.test-box {
width: 180px;
height: 80px;
background-color: gray;
justify-content: center;
align-items: center;
}
</style>

查看文件

@@ -0,0 +1,34 @@
describe('css-font-family-icon', () => {
const platformInfo = process.env.uniTestPlatformInfo.toLocaleLowerCase();
const isMP = platformInfo.startsWith('mp');
const isWeb = platformInfo.startsWith('web');
const isAppWebView = process.env.UNI_AUTOMATOR_APP_WEBVIEW == 'true';
let page;
if (isWeb || isMP || isAppWebView) {
it('other platform', () => {
expect(1).toBe(1);
});
return;
}
it('screenshot', async () => {
page = await program.reLaunch('/pages/CSS/text/font-family-icon');
await page.waitFor('view');
await page.waitFor(1000);
const image = await program.screenshot({
fullPage: true
});
expect(image).toSaveImageSnapshot();
});
it('screenshot after changeStyle', async () => {
await page.callMethod('changeStyle');
await page.waitFor(500);
const image = await program.screenshot({
fullPage: true
});
expect(image).toSaveImageSnapshot();
});
});

查看文件

@@ -0,0 +1,156 @@
<template>
<!-- #ifdef APP && !VUE3-VAPOR -->
<scroll-view style="flex: 1;">
<!-- #endif -->
<view style="align-items: center;align-self: center;">
<view class="iconContainer">
<view class="iconItem" v-for="item in uniIcons">
<text class="icon" :style="{'font-weight': data.fontWeight, 'font-style': data.fontStyle}">{{String.fromCharCode(parseInt(item.code,16))}}</text>
<text class="code">\u{{item.code}}</text>
<text class="name">{{item.name}}</text>
</view>
</view>
</view>
<!-- #ifdef APP && !VUE3-VAPOR -->
</scroll-view>
<!-- #endif -->
</template>
<script setup lang="uts">
type Icon = {
name : string,
code : string,
}
const uniIcons = ref([ //图标数据
{
'name':'back',
'code':'E601',
},
{
'name':'forward',
'code':'E600',
},
{
'name':'share',
'code':'E602',
},
{
'name':'favorites',
'code':'E604',
},
{
'name':'home',
'code':'E605',
},
{
'name':'more',
'code':'E606',
},
{
'name':'close',
'code':'E650',
},
{
'name':'down',
'code':'E661',
},
{
'name':'circle',
'code':'EA01',
},
{
'name':'warn',
'code':'EA0F',
},
{
'name':'info',
'code':'EA03',
},
{
'name':'info circle',
'code':'EA04',
},
{
'name':'success',
'code':'EA06',
},
{
'name':'success circle',
'code':'EA07',
},
{
'name':'success no circle',
'code':'EA08',
},
{
'name':'cancel circle',
'code':'EA0B',
},
{
'name':'clear',
'code':'EA14',
},
{
'name':'download',
'code':'EA19',
},
{
'name':'waitnig',
'code':'EA1E',
},
{
'name':'search',
'code':'EA23',
}
] as Icon[])
// 自动化测试
const data = reactive({
fontWeight: 'normal',
fontStyle: 'normal'
})
const changeStyle = () => {
data.fontWeight = 'bold'
data.fontStyle = 'italic'
}
defineExpose({
changeStyle,
data
})
</script>
<style>
.iconContainer {
flex-direction: row;
flex-wrap: wrap;
justify-content: center;
}
.iconItem {
width: 100px;
height: 150px;
justify-content: center;
align-items: center;
}
.icon {
width: 48px;
height: 48px;
font-family: uni-icon;
font-size: 42px;
line-height: 48px;
color: #333;
margin-bottom: 8px;
}
.code {
font-size: 14px;
color: #f00;
}
.name {
font-size: 12px;
color: #000;
}
</style>

查看文件

@@ -0,0 +1,25 @@
const platformInfo = process.env.uniTestPlatformInfo.toLocaleLowerCase()
const isMP = platformInfo.startsWith('mp')
describe('css-font-family', () => {
if (isMP) {
it('skip', () => {
expect(1).toBe(1)
})
return
}
let page;
beforeAll(async () => {
page = await program.reLaunch('/pages/CSS/text/font-family');
await page.waitFor('view');
await page.waitFor(3000);
});
it('screenshot', async () => {
const image = await program.screenshot({
fullPage: true
})
expect(image).toSaveImageSnapshot()
});
});

查看文件

@@ -0,0 +1,171 @@
<template>
<!-- #ifdef APP && !VUE3-VAPOR -->
<scroll-view style="flex: 1">
<!-- #endif -->
<view class="uni-padding-wrap">
<text class="common" style="font-family: monospace">font-family: monospace</text>
<text class="common" style="font-family: cursive">font-family: cursive</text>
<text class="common" style="font-family: AlimamaDaoLiTiTTF">font-family: 阿里妈妈刀隶体-ttf(网络字体下载后生效)</text>
<text class="common" style="font-family: AlimamaDaoLiTiOTF">font-family: 阿里妈妈刀隶体-otf</text>
<text class="common" style="font-family: AlimamaDaoLiTiOTF;font-weight: bold;font-style: italic;">font-family: 阿里妈妈刀隶体-otf(粗斜体)</text>
<text style="font-family: UniFontFamily;">style 加载非 static 目录字体文件:{{uniIcon}}</text>
<!-- <text class="common" style="font-family: AlimamaDaoLiTiWOFF">font-family: 阿里妈妈刀隶体-woff</text>
<text class="common" style="font-family: AlimamaDaoLiTiWOFF2">font-family: 阿里妈妈刀隶体-woff2</text> -->
<text class="uni-title-text title-color">【拍平测试】</text>
<text class="common" style="font-family: monospace" flatten>font-family: monospace</text>
<text class="common" style="font-family: cursive" flatten>font-family: cursive</text>
<text class="common" style="font-family: AlimamaDaoLiTiTTF" flatten>font-family: 阿里妈妈刀隶体-ttf(网络字体下载后生效)</text>
<text class="common" style="font-family: AlimamaDaoLiTiOTF" flatten>font-family: 阿里妈妈刀隶体-otf</text>
<text class="common" style="font-family: AlimamaDaoLiTiOTF;font-weight: bold;font-style: italic;" flatten>font-family: 阿里妈妈刀隶体-otf(粗斜体)</text>
<text style="font-family: UniFontFamily;" flatten>style 加载非 static 目录字体文件:{{uniIcon}}</text>
<view class="uni-common-mt">
<text class="uni-title-text title-color">setProperty 设置与 getPropertyValue 获取</text>
<!-- 普通版本 -->
<text class="uni-info">设置值: {{data.fontFamily}}</text>
<text class="uni-info">获取值: {{data.fontFamilyActual}}</text>
<text ref="textRef" class="common" :style="{ fontFamily: data.fontFamily }">当前 font-family: {{data.fontFamily}}</text>
<!-- 拍平版本 -->
<text class="uni-info">设置值: {{data.fontFamily}}</text>
<text class="uni-info">获取值: {{data.fontFamilyActualFlat}}</text>
<text ref="textRefFlat" class="common" :style="{ fontFamily: data.fontFamily }" flatten>当前 font-family: {{data.fontFamily}}</text>
<view class="uni-common-mt uni-common-mb">
<text class="uni-tips">第一个枚举值,'' (空字符串) - 空值情况</text>
<enum-data :items="fontFamilyEnum" title="font-family 枚举值" @change="radioChangeFontFamily" :compact="true"></enum-data>
<input-data :defaultValue="data.fontFamily" title="font-family 自定义值" type="text" @confirm="inputChangeFontFamily"></input-data>
</view>
</view>
</view>
<!-- #ifdef APP -->
<view style="margin: 24px 12px;">
<button type="default" @click="openUniIcon">内置字体图标uni-icon示例</button>
</view>
<!-- #endif -->
<!-- #ifdef APP && !VUE3-VAPOR -->
</scroll-view>
<!-- #endif -->
</template>
<script setup lang="uts">
import { ItemType } from '@/components/enum-data/enum-data-types'
const uniIcon = ref('\ue100')
const openUniIcon = () => {
uni.navigateTo({
url: '/pages/CSS/text/font-family-icon'
})
}
const fontFamilyEnum: ItemType[] = [
{ value: 0, name: '' },
{ value: 1, name: 'monospace' },
{ value: 2, name: 'cursive' },
{ value: 3, name: 'AlimamaDaoLiTiTTF' },
{ value: 4, name: 'AlimamaDaoLiTiOTF' },
{ value: 5, name: 'UniFontFamily' }
]
const data = reactive({
fontFamily: 'monospace',
fontFamilyActual: '',
fontFamilyActualFlat: ''
})
const textRef = ref(null as UniTextElement | null)
const textRefFlat = ref(null as UniTextElement | null)
const getPropertyValues = () => {
data.fontFamilyActual = textRef.value?.style.getPropertyValue('font-family') ?? ''
data.fontFamilyActualFlat = textRefFlat.value?.style.getPropertyValue('font-family') ?? ''
}
const changeFontFamily = (value: string) => {
data.fontFamily = value
textRef.value?.style.setProperty('font-family', value)
textRefFlat.value?.style.setProperty('font-family', value)
// 使用 nextTick 确保样式已应用后再获取值
nextTick(() => {
getPropertyValues()
})
}
const radioChangeFontFamily = (index: number) => {
const selectedItem = fontFamilyEnum.find((item): boolean => item.value === index)
if (selectedItem != null) {
changeFontFamily(selectedItem.name)
}
}
const inputChangeFontFamily = (value: string) => {
changeFontFamily(value)
}
onReady(() => {
getPropertyValues()
})
defineExpose({
data,
radioChangeFontFamily
})
</script>
<style>
.common {
font-size: 20px;
line-height: 40px;
}
.title-color{
color:#007aff;
margin-bottom: 10px;
}
@font-face {
font-family: AlimamaDaoLiTiTTF;
src: url('https://qiniu-web-assets.dcloud.net.cn/uni-app-x/static/font/AlimamaDaoLiTi.ttf');
}
@font-face {
font-family: AlimamaDaoLiTiOTF;
src: url('/static/font/AlimamaDaoLiTi.otf');
}
@font-face {
font-family: UniFontFamily;
src: url('./uni.ttf');
}
/* @font-face {
font-family: AlimamaDaoLiTiWOFF;
src: url('/static/app-ios/AlimamaDaoLiTi.woff');
}
@font-face {
font-family: AlimamaDaoLiTiWOFF2;
src: url('/static/app-ios/AlimamaDaoLiTi.woff2');
} */
.common-box{
flex-direction: row;
justify-content: space-around;
}
.test-box {
width: 180px;
height: 80px;
background-color: gray;
justify-content: center;
align-items: center;
}
</style>

查看文件

@@ -0,0 +1,22 @@
const platformInfo = process.env.uniTestPlatformInfo.toLocaleLowerCase()
const isMP = platformInfo.startsWith('mp')
describe('css-font-size', () => {
if (isMP) {
it('skip', () => {
expect(1).toBe(1)
})
return
}
let page;
beforeAll(async () => {
page = await program.reLaunch('/pages/CSS/text/font-size');
});
it('change font-size screenshot', async () => {
await page.callMethod("setFontSize");
await page.waitFor(100);
const image = await program.screenshot({ fullPage: true });
expect(image).toSaveImageSnapshot();
});
});

查看文件

@@ -0,0 +1,146 @@
<template>
<!-- #ifdef APP && !VUE3-VAPOR -->
<scroll-view style="flex: 1">
<!-- #endif -->
<view style="flex-grow: 1;">
<text class="uni-tips">说明:左边是正常版本,右边是拍平版本</text>
<view class="demo-box">
<view class="common">
<text ref="text" :style="{'font-size': data.fontSize}">font-size: {{data.fontSize}}</text>
<text style="font-size: 30px;">font-size: 30px</text>
<text style="font-size: 20rpx;">font-size: 20rpx</text>
</view>
<view class="common">
<text ref="text" :style="{'font-size': data.fontSize}" flatten>font-size: {{data.fontSize}}</text>
<text style="font-size: 30px;" flatten>font-size: 30px</text>
<text style="font-size: 20rpx;" flatten>font-size: 20rpx</text>
</view>
</view>
<view class="uni-common-mt">
<text class="uni-title-text">setProperty 设置与 getPropertyValue 获取</text>
</view>
<view class="common-box">
<!-- 普通版本 -->
<view class="uni-common-mt">
<text class="uni-title-text">font-size</text>
<text class="uni-info">设置值: {{data.fontSizeProp}}</text>
<text class="uni-info">获取值: {{data.fontSizeActual}}</text>
<view class="test-box">
<text ref="textRef" :style="{ fontSize: data.fontSizeProp }">当前 font-size: {{data.fontSizeProp}}</text>
</view>
</view>
<!-- 拍平版本 -->
<view class="uni-common-mt">
<text class="uni-title-text">测试拍平</text>
<text class="uni-info">设置值: {{data.fontSizeProp}}</text>
<text class="uni-info">获取值: {{data.fontSizeActualFlat}}</text>
<view class="test-box">
<text ref="textRefFlat" :style="{ fontSize: data.fontSizeProp }" flatten>当前 font-size: {{data.fontSizeProp}}</text>
</view>
</view>
</view>
<view class="uni-common-mt uni-common-mb">
<text class="uni-tips">第一个枚举值,'' (空字符串) - 空值情况</text>
<enum-data :items="fontSizeEnum" title="font-size 枚举值" @change="radioChangeFontSize" :compact="true"></enum-data>
<input-data :defaultValue="data.fontSizeProp" title="font-size 自定义值" type="text" @confirm="inputChangeFontSize"></input-data>
</view>
</view>
<!-- #ifdef APP && !VUE3-VAPOR -->
</scroll-view>
<!-- #endif -->
</template>
<script setup lang="uts">
import { ItemType } from '@/components/enum-data/enum-data-types'
const data = reactive({
fontSize: '15px',
fontSizeProp: '15px',
fontSizeActual: '',
fontSizeActualFlat: ''
})
// 自动化测试
const setFontSize = () => {
data.fontSize = '30px'
}
const fontSizeEnum: ItemType[] = [
{ value: 0, name: '' },
{ value: 1, name: '0' },
{ value: 2, name: '0px' },
{ value: 3, name: '10px' },
{ value: 4, name: '20px' },
{ value: 5, name: '0rpx' },
{ value: 6, name: '20rpx' },
]
const textRef = ref(null as UniTextElement | null)
const textRefFlat = ref(null as UniTextElement | null)
const getPropertyValues = () => {
data.fontSizeActual = textRef.value?.style.getPropertyValue('font-size') ?? ''
data.fontSizeActualFlat = textRefFlat.value?.style.getPropertyValue('font-size') ?? ''
}
const changeFontSize = (value: string) => {
data.fontSizeProp = value
textRef.value?.style.setProperty('font-size', value)
textRefFlat.value?.style.setProperty('font-size', value)
// 使用 nextTick 确保样式已应用后再获取值
nextTick(() => {
getPropertyValues()
})
}
const radioChangeFontSize = (index: number) => {
const selectedItem = fontSizeEnum.find((item): boolean => item.value === index)
if (selectedItem != null) {
changeFontSize(selectedItem.name)
}
}
const inputChangeFontSize = (value: string) => {
changeFontSize(value)
}
onReady(() => {
getPropertyValues()
})
defineExpose({
setFontSize,
radioChangeFontSize,
data
})
</script>
<style>
.common{
background-color: gray;
justify-content: center;
height: 100px;
flex:1;
}
.demo-box {
flex-direction: row;
margin-top: 10px;
justify-content: space-around;
}
.common-box{
flex-direction: row;
justify-content: space-around;
}
.test-box {
width: 180px;
height: 80px;
background-color: gray;
justify-content: center;
align-items: center;
}
</style>

查看文件

@@ -0,0 +1,138 @@
<template>
<!-- #ifdef APP && !VUE3-VAPOR -->
<scroll-view style="flex: 1">
<!-- #endif -->
<view style="flex-grow: 1;">
<text class="uni-tips">说明:左边是正常版本,右边是拍平版本</text>
<view class="demo-box">
<view class="common">
<text class="common-size" style="font-style: italic;">font-style: italic</text>
<text class="common-size" style="font-style: normal;">font-style: normal</text>
</view>
<view class="common">
<text class="common-size" style="font-style: italic;" flatten>font-style: italic</text>
<text class="common-size" style="font-style: normal;" flatten>font-style: normal</text>
</view>
</view>
<view class="uni-common-mt">
<text class="uni-title-text">setProperty 设置与 getPropertyValue 获取</text>
</view>
<view class="common-box">
<!-- 普通版本 -->
<view class="uni-common-mt">
<text class="uni-title-text">font-style</text>
<text class="uni-info">设置值: {{data.fontStyle}}</text>
<text class="uni-info">获取值: {{data.fontStyleActual}}</text>
<view class="test-box">
<text ref="textRef" class="common-size test-text" :style="{ fontStyle: data.fontStyle }">当前 font-style: {{data.fontStyle}}</text>
</view>
</view>
<!-- 拍平版本 -->
<view class="uni-common-mt">
<text class="uni-title-text">测试拍平</text>
<text class="uni-info">设置值: {{data.fontStyle}}</text>
<text class="uni-info">获取值: {{data.fontStyleActualFlat}}</text>
<view class="test-box">
<text ref="textRefFlat" class="common-size test-text-flatten" :style="{ fontStyle: data.fontStyle }" flatten>当前 font-style: {{data.fontStyle}}</text>
</view>
</view>
</view>
<view class="uni-common-mt uni-common-mb">
<text class="uni-tips">第一个枚举值,'' (空字符串) - 空值情况</text>
<enum-data :items="fontStyleEnum" title="font-style 枚举值" @change="radioChangeFontStyle" :compact="true"></enum-data>
<input-data :defaultValue="data.fontStyle" title="font-style 自定义值" type="text" @confirm="inputChangeFontStyle"></input-data>
</view>
</view>
<!-- #ifdef APP && !VUE3-VAPOR -->
</scroll-view>
<!-- #endif -->
</template>
<script setup lang="uts">
import { ItemType } from '@/components/enum-data/enum-data-types'
const fontStyleEnum: ItemType[] = [
{ value: 0, name: '' },
{ value: 1, name: 'normal' },
{ value: 2, name: 'italic' }
]
const data = reactive({
fontStyle: 'normal',
fontStyleActual: '',
fontStyleActualFlat: ''
})
const textRef = ref(null as UniTextElement | null)
const textRefFlat = ref(null as UniTextElement | null)
const getPropertyValues = () => {
data.fontStyleActual = textRef.value?.style.getPropertyValue('font-style') ?? ''
data.fontStyleActualFlat = textRefFlat.value?.style.getPropertyValue('font-style') ?? ''
}
const changeFontStyle = (value: string) => {
data.fontStyle = value
textRef.value?.style.setProperty('font-style', value)
textRefFlat.value?.style.setProperty('font-style', value)
// 使用 nextTick 确保样式已应用后再获取值
nextTick(() => {
getPropertyValues()
})
}
const radioChangeFontStyle = (index: number) => {
const selectedItem = fontStyleEnum.find((item): boolean => item.value === index)
if (selectedItem != null) {
changeFontStyle(selectedItem.name)
}
}
const inputChangeFontStyle = (value: string) => {
changeFontStyle(value)
}
onReady(() => {
getPropertyValues()
})
defineExpose({
radioChangeFontStyle,
data
})
</script>
<style>
.common-size {
font-size: 20px;
}
.common{
height: 100px;
background-color: gray;
justify-content: center;
align-items: center;
flex:1;
}
.demo-box {
flex-direction: row;
margin-top: 10px;
justify-content: space-around;
}
.common-box{
flex-direction: row;
justify-content: space-around;
}
.test-box {
width: 180px;
height: 80px;
background-color: gray;
justify-content: center;
align-items: center;
}
</style>

查看文件

@@ -0,0 +1,163 @@
<template>
<!-- #ifdef APP && !VUE3-VAPOR -->
<scroll-view style="flex: 1">
<!-- #endif -->
<view style="flex-grow: 1;">
<text class="uni-tips">说明:左边是正常版本,右边是拍平版本</text>
<view class="demo-box">
<view class="common">
<text class="common-size" style="font-weight: normal;">font-weight: normal</text>
<text class="common-size" style="font-weight: bold;">font-weight: bold</text>
<text class="common-size" style="font-weight: 100;">font-weight: 100</text>
<text class="common-size" style="font-weight: 200;">font-weight: 200</text>
<text class="common-size" style="font-weight: 300;">font-weight: 300</text>
<text class="common-size" style="font-weight: 400;">font-weight: 400</text>
<text class="common-size" style="font-weight: 500;">font-weight: 500</text>
<text class="common-size" style="font-weight: 600;">font-weight: 600</text>
<text class="common-size" style="font-weight: 700;">font-weight: 700</text>
<text class="common-size" style="font-weight: 800;">font-weight: 800</text>
<text class="common-size" style="font-weight: 900;">font-weight: 900</text>
</view>
<view class="common">
<text class="common-size" style="font-weight: normal;" flatten>font-weight: normal</text>
<text class="common-size" style="font-weight: bold;" flatten>font-weight: bold</text>
<text class="common-size" style="font-weight: 100;" flatten>font-weight: 100</text>
<text class="common-size" style="font-weight: 200;" flatten>font-weight: 200</text>
<text class="common-size" style="font-weight: 300;" flatten>font-weight: 300</text>
<text class="common-size" style="font-weight: 400;" flatten>font-weight: 400</text>
<text class="common-size" style="font-weight: 500;" flatten>font-weight: 500</text>
<text class="common-size" style="font-weight: 600;" flatten>font-weight: 600</text>
<text class="common-size" style="font-weight: 700;" flatten>font-weight: 700</text>
<text class="common-size" style="font-weight: 800;" flatten>font-weight: 800</text>
<text class="common-size" style="font-weight: 900;" flatten>font-weight: 900</text>
</view>
</view>
<view class="uni-common-mt">
<text class="uni-title-text">setProperty 设置与 getPropertyValue 获取</text>
</view>
<view class="common-box">
<!-- 普通版本 -->
<view class="uni-common-mt">
<text class="uni-title-text">font-weight</text>
<text class="uni-info">设置值: {{data.fontWeight}}</text>
<text class="uni-info">获取值: {{data.fontWeightActual}}</text>
<view class="test-box">
<text ref="textRef" class="common-size test-text" :style="{ fontWeight: data.fontWeight }">当前 font-weight: {{data.fontWeight}}</text>
</view>
</view>
<!-- 拍平版本 -->
<view class="uni-common-mt">
<text class="uni-title-text">测试拍平</text>
<text class="uni-info">设置值: {{data.fontWeight}}</text>
<text class="uni-info">获取值: {{data.fontWeightActualFlat}}</text>
<view class="test-box">
<text ref="textRefFlat" class="common-size test-text-flatten" :style="{ fontWeight: data.fontWeight }" flatten>当前 font-weight: {{data.fontWeight}}</text>
</view>
</view>
</view>
<view class="uni-common-mt uni-common-mb">
<text class="uni-tips">第一个枚举值,'' (空字符串) - 空值情况</text>
<enum-data :items="fontWeightEnum" title="font-weight 枚举值" @change="radioChangeFontWeight" :compact="true"></enum-data>
<input-data :defaultValue="data.fontWeight" title="font-weight 自定义值" type="text" @confirm="inputChangeFontWeight"></input-data>
</view>
</view>
<!-- #ifdef APP && !VUE3-VAPOR -->
</scroll-view>
<!-- #endif -->
</template>
<script setup lang="uts">
import { ItemType } from '@/components/enum-data/enum-data-types'
const fontWeightEnum: ItemType[] = [
{ value: 0, name: '' },
{ value: 1, name: 'normal' },
{ value: 2, name: 'bold' },
{ value: 3, name: '100' },
{ value: 4, name: '200' },
{ value: 5, name: '300' },
{ value: 6, name: '400' },
{ value: 7, name: '500' },
{ value: 8, name: '600' },
{ value: 9, name: '700' },
{ value: 10, name: '800' },
{ value: 11, name: '900' },
]
const data = reactive({
fontWeight: 'normal',
fontWeightActual: '',
fontWeightActualFlat: ''
})
const textRef = ref(null as UniTextElement | null)
const textRefFlat = ref(null as UniTextElement | null)
const getPropertyValues = () => {
data.fontWeightActual = textRef.value?.style.getPropertyValue('font-weight') ?? ''
data.fontWeightActualFlat = textRefFlat.value?.style.getPropertyValue('font-weight') ?? ''
}
const changeFontWeight = (value: string) => {
data.fontWeight = value
textRef.value?.style.setProperty('font-weight', value)
textRefFlat.value?.style.setProperty('font-weight', value)
// 使用 nextTick 确保样式已应用后再获取值
nextTick(() => {
getPropertyValues()
})
}
const radioChangeFontWeight = (index: number) => {
const selectedItem = fontWeightEnum.find((item): boolean => item.value === index)
if (selectedItem != null) {
changeFontWeight(selectedItem.name)
}
}
const inputChangeFontWeight = (value: string) => {
changeFontWeight(value)
}
onReady(() => {
getPropertyValues()
})
defineExpose({
radioChangeFontWeight,
data
})
</script>
<style>
.common-size {
font-size: 20px;
}
.common{
background-color: gray;
justify-content: center;
align-items: center;
flex:1;
}
.demo-box {
flex-direction: row;
margin-top: 10px;
justify-content: space-around;
}
.common-box{
flex-direction: row;
justify-content: space-around;
}
.test-box {
width: 180px;
height: 80px;
background-color: gray;
justify-content: center;
align-items: center;
}
</style>

查看文件

@@ -0,0 +1,46 @@
const platformInfo = process.env.uniTestPlatformInfo.toLocaleLowerCase()
const isHarmony = platformInfo.startsWith('harmony')
const PAGE_PATH = '/pages/CSS/text/letter-spacing'
describe('text-dynamic-letterSpacing', () => {
if (!isHarmony) {
it('other platform', () => {
expect(1).toBe(1)
})
return
}
let page
// 添加辅助函数来简化数据设置
async function setPageData(newData) {
return await page.setData({ autoTestData: newData });
}
beforeAll(async () => {
page = await program.reLaunch(PAGE_PATH)
await page.waitFor(500);
await setPageData({
begin: true
})
})
it('text-dynamic-letterSpacing', async () => {
let h1 = await page.callMethod('getLetterSpacing')
await page.callMethod('plusLetterSpacing')
await page.callMethod('plusLetterSpacing')
let h2 = await page.callMethod('getLetterSpacing')
expect(h2).toBeGreaterThan(h1)
await setPageData({
begin: false
})
})
it('text-dynamic-letterSpacing-snapshot', async () => {
const image = await program.screenshot({
fullPage: true
});
expect(image).toSaveImageSnapshot();
})
})

查看文件

@@ -0,0 +1,192 @@
<template>
<!-- #ifdef APP && !VUE3-VAPOR -->
<scroll-view style="flex: 1">
<!-- #endif -->
<template v-if="autoTestData.begin">
<view>
<text id="testText"
:style="`letter-spacing:${letterSpacing_mix}px;`">
uni-app 是一个使用 Vue.js
开发所有前端应用的框架,开发者编写一套代码,可发布到iOS、Android、鸿蒙Next、Web(响应式)、以及各种小程序(微信/支付宝/百度/抖音/飞书/QQ/快手/钉钉/淘宝/京东/小红书)、快应用、鸿蒙元服务等多个平台。</text>
<view style="flex-direction: row;">
<button @click="plusLetterSpacing">+字宽</button>
<button @click="minusLetterSpacing">-字宽</button>
</view>
</view>
</template>
<view style="flex-grow: 1;">
<view class="box">
<text class="common">letter-spacing</text>
<text class="common" style="letter-spacing: 5px;">letter-spacing: 5px</text>
<text class="common" style="letter-spacing: -2px;">letter-spacing: -2px</text>
<text class="common" style="letter-spacing: 4rpx;">letter-spacing: 4rpx</text>
</view>
<text class="uni-title-text">拍平</text>
<view class="box">
<text class="common">letter-spacing</text>
<text class="common" style="letter-spacing: 5px;" flatten>letter-spacing: 5px</text>
<text class="common" style="letter-spacing: -2px;" flatten>letter-spacing: -2px</text>
<text class="common" style="letter-spacing: 4rpx;" flatten>letter-spacing: 4rpx</text>
</view>
<view class="uni-common-mt">
<text class="uni-title-text">setProperty 设置与 getPropertyValue 获取</text>
</view>
<view class="common-box">
<!-- 普通版本 -->
<view class="uni-common-mt">
<text class="uni-title-text">letter-spacing</text>
<text class="uni-info">设置值: {{data.letterSpacing}}</text>
<text class="uni-info">获取值: {{data.letterSpacingActual}}</text>
<view class="test-box">
<text ref="textRef" class="common-text" :style="{ letterSpacing: data.letterSpacing }">当前 letter-spacing: {{data.letterSpacing}}</text>
</view>
</view>
<!-- 拍平版本 -->
<view class="uni-common-mt">
<text class="uni-title-text">拍平</text>
<text class="uni-info">设置值: {{data.letterSpacing}}</text>
<text class="uni-info">获取值: {{data.letterSpacingActualFlat}}</text>
<view class="test-box">
<text ref="textRefFlat" class="common-text" :style="{ letterSpacing: data.letterSpacing }" flatten>当前 letter-spacing: {{data.letterSpacing}}</text>
</view>
</view>
</view>
<view class="uni-common-mt uni-common-mb">
<text class="uni-tips">第一个枚举值,'' (空字符串) - 空值情况</text>
<enum-data :items="letterSpacingEnum" title="letter-spacing 枚举值" @change="radioChangeLetterSpacing" :compact="true"></enum-data>
<input-data :defaultValue="data.letterSpacing" title="letter-spacing 自定义值" type="text" @confirm="inputChangeLetterSpacing"></input-data>
</view>
</view>
<!-- #ifdef APP && !VUE3-VAPOR -->
</scroll-view>
<!-- #endif -->
</template>
<script setup lang="uts">
import { ItemType } from '@/components/enum-data/enum-data-types'
const letterSpacingEnum: ItemType[] = [
{ value: 0, name: '' },
{ value: 1, name: '0' },
{ value: 2, name: '0px' },
{ value: 3, name: '-2px' },
{ value: 4, name: '2px' },
{ value: 5, name: '5px' },
{ value: 6, name: '10px' },
{ value: 7, name: '2rpx' },
{ value: 8, name: '10rpx' }
]
const data = reactive({
letterSpacing: '0px',
letterSpacingActual: '',
letterSpacingActualFlat: ''
})
const letterSpacing_mix = ref(1)
const textRef = ref(null as UniTextElement | null)
const textRefFlat = ref(null as UniTextElement | null)
const getPropertyValues = () => {
data.letterSpacingActual = textRef.value?.style.getPropertyValue('letter-spacing') ?? ''
data.letterSpacingActualFlat = textRefFlat.value?.style.getPropertyValue('letter-spacing') ?? ''
}
const changeLetterSpacing = (value: string) => {
data.letterSpacing = value
textRef.value?.style.setProperty('letter-spacing', value)
textRefFlat.value?.style.setProperty('letter-spacing', value)
// 使用 nextTick 确保样式已应用后再获取值
nextTick(() => {
getPropertyValues()
})
}
const radioChangeLetterSpacing = (index: number) => {
const selectedItem = letterSpacingEnum.find((item): boolean => item.value === index)
if (selectedItem != null) {
changeLetterSpacing(selectedItem.name)
}
}
const inputChangeLetterSpacing = (value: string) => {
changeLetterSpacing(value)
}
/**
* * * * * * * * * * * * * *
* 自动化测试
* * * * * * * * * * * * * *
*/
type AutoTextData = {
begin: boolean
}
const autoTestData = reactive<AutoTextData>({
begin: false
} as AutoTextData)
function plusLetterSpacing() {
letterSpacing_mix.value += 0.2
}
function minusLetterSpacing() {
letterSpacing_mix.value -= 0.2
}
function getLetterSpacing() {
const testText = uni.getElementById('testText')
if (testText != null) {
return parseFloat(testText.style.getPropertyValue('letter-spacing'))
}
return 0
}
defineExpose({
autoTestData,
getLetterSpacing,
plusLetterSpacing,
minusLetterSpacing,
radioChangeLetterSpacing,
data
})
/**
* * * * * * * * * * * * * *
* 自动化测试 END
* * * * * * * * * * * * * *
*/
onReady(() => {
getPropertyValues()
})
</script>
<style>
.common {
font-size: 20px;
}
.box{
height: 110px;
background-color: gray;
justify-content: center;
align-items: center;
}
.common-text{
font-size: 14px;
}
.common-box{
flex-direction: row;
justify-content: space-around;
}
.test-box {
width: 180px;
height: 80px;
background-color: gray;
justify-content: center;
align-items: center;
}
</style>

查看文件

@@ -0,0 +1,47 @@
const PAGE_PATH = '/pages/CSS/text/line-height'
describe('text-dynamic-lineHeight', () => {
const platformInfo = process.env.uniTestPlatformInfo.toLocaleLowerCase()
const isHarmony = platformInfo.startsWith('harmony')
if (!isHarmony) {
it('other platform', () => {
expect(1).toBe(1)
})
return
}
let page
// 添加辅助函数来简化数据设置
async function setPageData(newData) {
return await page.setData({ autoTestData: newData });
}
beforeAll(async () => {
page = await program.reLaunch(PAGE_PATH)
await page.waitFor(500);
await setPageData({
begin: true
})
})
it('text-dynamic-lineHeight', async () => {
let h1 = await page.callMethod('getLineHeight')
await page.callMethod('plusLineHeight')
await page.callMethod('plusLineHeight')
let h2 = await page.callMethod('getLineHeight')
expect(h2).toBeGreaterThan(h1)
await setPageData({
begin: false
})
})
it('text-dynamic-lineHeight-snapshot', async () => {
const image = await program.screenshot({
fullPage: true
});
expect(image).toSaveImageSnapshot();
})
})

查看文件

@@ -0,0 +1,207 @@
<template>
<!-- #ifdef APP && !VUE3-VAPOR -->
<scroll-view style="flex: 1">
<!-- #endif -->
<template v-if="autoTestData.begin">
<view>
<text id="testText"
:style="`line-height: ${data.lineHeight_mix};`">
uni-app 是一个使用 Vue.js
开发所有前端应用的框架,开发者编写一套代码,可发布到iOS、Android、鸿蒙Next、Web(响应式)、以及各种小程序(微信/支付宝/百度/抖音/飞书/QQ/快手/钉钉/淘宝/京东/小红书)、快应用、鸿蒙元服务等多个平台。</text>
<view style="flex-direction: row;">
<button @click="plusLineHeight">+行高</button>
<button @click="minusLineHeight">-行高</button>
</view>
</view>
</template>
<text class="uni-tips">说明:左边是正常版本,右边是拍平版本</text>
<view class="demo-box">
<view class="box">
<text class="common" style="line-height: 75px;">line-height: 75px</text>
<text class="line-height-3 common">line-height: 3</text>
<text class="common" style="line-height: 3em;">line-height: 3em</text>
<text class="common" style="line-height: 50rpx;">line-height: 50rpx</text>
<text class="common" style="line-height: 3;">line-height: 3\nline-height: 3\nline-height: 3</text>
</view>
<view class="box">
<text class="common" style="line-height: 75px;" flatten>line-height: 75px</text>
<text class="line-height-3 common" flatten>line-height: 3</text>
<text class="common" style="line-height: 3em;" flatten>line-height: 3em</text>
<text class="common" style="line-height: 50rpx;" flatten>line-height: 50rpx</text>
<text class="common" style="line-height: 3;" flatten>line-height: 3\nline-height: 3\nline-height: 3</text>
</view>
</view>
<view class="uni-common-mt">
<text class="uni-title-text">setProperty 设置与 getPropertyValue 获取</text>
</view>
<view class="common-box">
<!-- 普通版本 -->
<view class="uni-common-mt">
<text class="uni-title-text">line-height</text>
<text class="uni-info">设置值: {{data.lineHeight}}</text>
<text class="uni-info">获取值: {{data.lineHeightActual}}</text>
<view class="test-box">
<text ref="textRef" class="common" :style="{ lineHeight: data.lineHeight }">当前 line-height: {{data.lineHeight}}</text>
</view>
</view>
<!-- 拍平版本 -->
<view class="uni-common-mt">
<text class="uni-title-text">拍平</text>
<text class="uni-info">设置值: {{data.lineHeight}}</text>
<text class="uni-info">获取值: {{data.lineHeightActualFlat}}</text>
<view class="test-box">
<text ref="textRefFlat" class="common" :style="{ lineHeight: data.lineHeight }" flatten>当前 line-height: {{data.lineHeight}}</text>
</view>
</view>
</view>
<view class="uni-common-mt uni-common-mb">
<text class="uni-tips">第一个枚举值,'' (空字符串) - 空值情况</text>
<enum-data :items="lineHeightEnum" title="line-height 枚举值" @change="radioChangeLineHeight" :compact="true"></enum-data>
<input-data :defaultValue="data.lineHeight" title="line-height 自定义值" type="text" @confirm="inputChangeLineHeight"></input-data>
</view>
<!-- #ifdef APP && !VUE3-VAPOR -->
</scroll-view>
<!-- #endif -->
</template>
<script setup lang="uts">
import { ItemType } from '@/components/enum-data/enum-data-types'
const lineHeightEnum: ItemType[] = [
{ value: 0, name: '' },
{ value: 1, name: '1.5' },
{ value: 2, name: '2' },
{ value: 3, name: '25px' },
{ value: 4, name: '50rpx' },
{ value: 5, name: '1.5em' },
{ value: 6, name: '2em' }
]
type LineHeightData = {
lineHeight: string
lineHeightActual: string
lineHeightActualFlat: string
lineHeight_mix: number
}
const data = reactive({
lineHeight: '20px',
lineHeightActual: '',
lineHeightActualFlat: '',
lineHeight_mix: 1.5
} as LineHeightData)
const textRef = ref(null as UniTextElement | null)
const textRefFlat = ref(null as UniTextElement | null)
const getPropertyValues = () => {
data.lineHeightActual = textRef.value?.style.getPropertyValue('line-height') ?? ''
data.lineHeightActualFlat = textRefFlat.value?.style.getPropertyValue('line-height') ?? ''
}
const changeLineHeight = (value: string) => {
data.lineHeight = value
textRef.value?.style.setProperty('line-height', value)
textRefFlat.value?.style.setProperty('line-height', value)
// 使用 nextTick 确保样式已应用后再获取值
nextTick(() => {
getPropertyValues()
})
}
const radioChangeLineHeight = (index: number) => {
const selectedItem = lineHeightEnum.find((item): boolean => item.value === index)
if (selectedItem != null) {
changeLineHeight(selectedItem.name)
}
}
const inputChangeLineHeight = (value: string) => {
changeLineHeight(value)
}
/**
* * * * * * * * * * * * * *
* 自动化测试
* * * * * * * * * * * * * *
*/
type AutoTextData = {
begin: boolean
}
const autoTestData = reactive<AutoTextData>({
begin: false
} as AutoTextData)
function plusLineHeight() {
data.lineHeight_mix = data.lineHeight_mix + 0.2
}
function minusLineHeight() {
data.lineHeight_mix = data.lineHeight_mix - 0.2
}
function getLineHeight() {
const testText = uni.getElementById('testText')
if (testText != null) {
return parseFloat(testText.style.getPropertyValue('line-height'))
}
return 0
}
defineExpose({
autoTestData,
getLineHeight,
plusLineHeight,
minusLineHeight,
radioChangeLineHeight,
data
})
/**
* * * * * * * * * * * * * *
* 自动化测试 END
* * * * * * * * * * * * * *
*/
onReady(() => {
getPropertyValues()
})
</script>
<style>
.common {
font-size: 20px;
border: 1px cyan solid;
margin: 10px 0;
padding: 0 10px;
}
.line-height-3 {
line-height: 3;
}
.box{
height: 500px;
background-color: gray;
justify-content: center;
align-items: center;
flex:1;
}
.demo-box {
flex-direction: row;
margin-top: 10px;
justify-content: space-around;
}
.common-box{
flex-direction: row;
justify-content: space-around;
}
.test-box {
width: 180px;
height: 150px;
background-color: gray;
justify-content: center;
align-items: center;
}
</style>

查看文件

@@ -0,0 +1,142 @@
<template>
<view style="flex-grow: 1;">
<view class="box">
<text class="common" style="text-align: left;">text-align: left</text>
<text class="common" style="text-align: center;">text-align: center</text>
<text class="common2" style="text-align: center;">text-align: center</text>
<text class="common" style="text-align: right;">text-align: right</text>
</view>
<text class="uni-title-text">拍平版本</text>
<view class="box">
<text class="common" style="text-align: left;" flatten>text-align: left</text>
<text class="common" style="text-align: center;" flatten>text-align: center</text>
<text class="common2" style="text-align: center;" flatten>text-align: center</text>
<text class="common" style="text-align: right;" flatten>text-align: right</text>
</view>
<view class="uni-common-mt">
<text class="uni-title-text">setProperty 设置与 getPropertyValue 获取</text>
</view>
<view class="common-box">
<!-- 普通版本 -->
<view class="uni-common-mt">
<text class="uni-title-text">text-align</text>
<text class="uni-info">设置值: {{data.textAlign}}</text>
<text class="uni-info">获取值: {{data.textAlignActual}}</text>
<view class="test-box">
<text ref="textRef" class="common-text test-text" :style="{ textAlign: data.textAlign }">当前 text-align: {{data.textAlign}}</text>
</view>
</view>
<!-- 拍平版本 -->
<view class="uni-common-mt">
<text class="uni-title-text">拍平</text>
<text class="uni-info">设置值: {{data.textAlign}}</text>
<text class="uni-info">获取值: {{data.textAlignActualFlat}}</text>
<view class="test-box">
<text ref="textRefFlat" class="common-text test-text-flatten" :style="{ textAlign: data.textAlign }" flatten>当前 text-align: {{data.textAlign}}</text>
</view>
</view>
</view>
<view class="uni-common-mt uni-common-mb">
<text class="uni-tips">第一个枚举值,'' (空字符串) - 空值情况</text>
<enum-data :items="textAlignEnum" title="text-align 枚举值" @change="radioChangeTextAlign" :compact="true"></enum-data>
<input-data :defaultValue="data.textAlign" title="text-align 自定义值" type="text" @confirm="inputChangeTextAlign"></input-data>
</view>
</view>
</template>
<script setup lang="uts">
import { ItemType } from '@/components/enum-data/enum-data-types'
const textAlignEnum: ItemType[] = [
{ value: 0, name: '' },
{ value: 1, name: 'left' },
{ value: 2, name: 'center' },
{ value: 3, name: 'right' }
]
const data = reactive({
textAlign: 'left',
textAlignActual: '',
textAlignActualFlat: ''
})
const textRef = ref(null as UniTextElement | null)
const textRefFlat = ref(null as UniTextElement | null)
const getPropertyValues = () => {
data.textAlignActual = textRef.value?.style.getPropertyValue('text-align') ?? ''
data.textAlignActualFlat = textRefFlat.value?.style.getPropertyValue('text-align') ?? ''
}
const changeTextAlign = (value: string) => {
data.textAlign = value
textRef.value?.style.setProperty('text-align', value)
textRefFlat.value?.style.setProperty('text-align', value)
// 使用 nextTick 确保样式已应用后再获取值
nextTick(() => {
getPropertyValues()
})
}
const radioChangeTextAlign = (index: number) => {
const selectedItem = textAlignEnum.find((item): boolean => item.value === index)
if (selectedItem != null) {
changeTextAlign(selectedItem.name)
}
}
const inputChangeTextAlign = (value: string) => {
changeTextAlign(value)
}
onReady(() => {
getPropertyValues()
})
defineExpose({
radioChangeTextAlign,
data
})
</script>
<style>
.common {
width: 250px;
font-size: 20px;
}
.common2 {
min-width: 250px;
font-size: 20px;
}
.common-text{
width: 100px;
font-size: 14px;
}
.box{
height: 150px;
background-color: gray;
justify-content: center;
align-items: center;
}
.common-box{
flex-direction: row;
justify-content: space-around;
}
.test-box {
width: 180px;
height: 80px;
background-color: gray;
justify-content: center;
align-items: center;
}
</style>

查看文件

@@ -0,0 +1,146 @@
<template>
<!-- #ifdef APP && !VUE3-VAPOR -->
<scroll-view style="flex: 1">
<!-- #endif -->
<view style="flex-grow: 1;">
<view class="content">
<text style="text-decoration-line: underline;">text-decoration-line: underline 下划线 底部易重叠字符:,.9pQqyzgj;\{}[]</text>
<text style="text-decoration-line: line-through;">text-decoration-line: line-through 删除线 较多文字测试换行和裁剪效果</text>
</view>
<view class="content">
<text style="text-decoration-line: underline;" flatten>text-decoration-line: underline flatten</text>
<text style="text-decoration-line: line-through;" flatten>text-decoration-line: line-through flatten</text>
</view>
<view style="background-color: gray;justify-content: center;align-items: center;margin-bottom: 16px;">
<text class="common" style="text-decoration-line: underline;color: blue;" flatten>text-decoration-line: underline 自适应宽高且拍平</text>
<text class="common" style="text-decoration-line: line-through;color: blue;" flatten>text-decoration-line: line-through 自适应宽高且拍平</text>
</view>
<view class="uni-common-mt">
<text class="uni-title-text">setProperty 设置与 getPropertyValue 获取</text>
</view>
<view class="common-box">
<!-- 普通版本 -->
<view class="uni-common-mt">
<text class="uni-title-text">text-decoration-line</text>
<text class="uni-info">设置值: {{data.textDecorationLine}}</text>
<text class="uni-info">获取值: {{data.textDecorationLineActual}}</text>
<view class="test-box">
<text ref="textRef" class="common test-text" :style="{ textDecorationLine: data.textDecorationLine }">当前 text-decoration-line: {{data.textDecorationLine}}</text>
</view>
</view>
<!-- 拍平版本 -->
<view class="uni-common-mt">
<text class="uni-title-text">拍平</text>
<text class="uni-info">设置值: {{data.textDecorationLine}}</text>
<text class="uni-info">获取值: {{data.textDecorationLineActualFlat}}</text>
<view class="test-box">
<text ref="textRefFlat" class="common test-text-flatten" :style="{ textDecorationLine: data.textDecorationLine }" flatten>当前 text-decoration-line: {{data.textDecorationLine}}</text>
</view>
</view>
</view>
<view class="uni-common-mt uni-common-mb">
<text class="uni-tips">第一个枚举值,'' (空字符串) - 空值情况</text>
<enum-data :items="textDecorationLineEnum" title="text-decoration-line 枚举值" @change="radioChangeTextDecorationLine" :compact="true"></enum-data>
<input-data :defaultValue="data.textDecorationLine" title="text-decoration-line 自定义值" type="text" @confirm="inputChangeTextDecorationLine"></input-data>
</view>
</view>
<!-- #ifndef APP-ANDROID || (APP-HARMONY && !VUE3-VAPOR) || (APP-IOS && !VUE3-VAPOR) -->
<!-- 临时注释,后续App支持再放开 -->
<!-- <view class="content">
<text class="common" style="text-decoration-line: underline;color: blue; text-decoration-color: red; text-overflow: ellipsis;width: 200px;white-space: nowrap;">下划线颜色和ellipsis组合</text>
<text class="common" style="text-decoration-line: line-through;color: blue; text-decoration-color: blue; text-overflow: ellipsis;width: 200px;white-space: nowrap;">删除线颜色和ellipsis组合</text>
</view> -->
<!-- #endif -->
<!-- #ifdef APP && !VUE3-VAPOR -->
</scroll-view>
<!-- #endif -->
</template>
<script setup lang="uts">
import { ItemType } from '@/components/enum-data/enum-data-types'
const textDecorationLineEnum: ItemType[] = [
{ value: 0, name: '' },
{ value: 1, name: 'none' },
{ value: 2, name: 'underline' },
{ value: 3, name: 'line-through' }
]
const data = reactive({
textDecorationLine: 'none',
textDecorationLineActual: '',
textDecorationLineActualFlat: ''
})
const textRef = ref(null as UniTextElement | null)
const textRefFlat = ref(null as UniTextElement | null)
const getPropertyValues = () => {
data.textDecorationLineActual = textRef.value?.style.getPropertyValue('text-decoration-line') ?? ''
data.textDecorationLineActualFlat = textRefFlat.value?.style.getPropertyValue('text-decoration-line') ?? ''
}
const changeTextDecorationLine = (value: string) => {
data.textDecorationLine = value
textRef.value?.style.setProperty('text-decoration-line', value)
textRefFlat.value?.style.setProperty('text-decoration-line', value)
// 使用 nextTick 确保样式已应用后再获取值
nextTick(() => {
getPropertyValues()
})
}
const radioChangeTextDecorationLine = (index: number) => {
const selectedItem = textDecorationLineEnum.find((item): boolean => item.value === index)
if (selectedItem != null) {
changeTextDecorationLine(selectedItem.name)
}
}
const inputChangeTextDecorationLine = (value: string) => {
changeTextDecorationLine(value)
}
onReady(() => {
getPropertyValues()
})
defineExpose({
radioChangeTextDecorationLine,
data
})
</script>
<style>
.common {
font-size: 20px;
}
.content {
width: 200px;
height: 100px;
background-color: gray;
justify-content: center;
align-items: center;
margin-bottom: 16px;
}
.common-box{
flex-direction: row;
justify-content: space-around;
}
.test-box {
width: 180px;
height: 80px;
background-color: gray;
justify-content: center;
align-items: center;
}
</style>

查看文件

@@ -0,0 +1,180 @@
<template>
<!-- #ifdef APP && !VUE3-VAPOR -->
<scroll-view style="flex: 1">
<!-- #endif -->
<view style="flex-grow: 1;">
<view style="padding: 0 10px; background-color: gray;justify-content: center;">
<view class="margin-bottom-10">
<text class="font-weight-bold">text-overflow:clip white-space:nowrap</text>
<text class="font-size-20" style="text-overflow: clip;white-space: nowrap;">{{data.multiLineText}}</text>
<text style="color:#dbd9d9;">拍平版本</text>
<text class="font-size-20" style="text-overflow: clip;white-space: nowrap;" flatten>{{data.multiLineText}}</text>
</view>
<view class="margin-bottom-10">
<text class="font-weight-bold">text-overflow:ellipsis white-space:nowrap</text>
<text class="font-size-20" style="text-overflow: ellipsis;white-space: nowrap;">{{data.singleLineText}}</text>
<text style="color:#dbd9d9;">拍平版本</text>
<text class="font-size-20" style="text-overflow: ellipsis;white-space: nowrap;" flatten>{{data.singleLineText}}</text>
<text class="font-size-20" style="text-overflow: ellipsis;white-space: nowrap;">{{data.multiLineText}}</text>
<text style="color:#dbd9d9;">拍平版本</text>
<text class="font-size-20" style="text-overflow: ellipsis;white-space: nowrap;" flatten>{{data.multiLineText}}</text>
</view>
<view class="margin-bottom-10">
<text class="font-weight-bold">white-space:normal</text>
<text class="font-size-20" style="white-space: normal;">{{data.multiLineText}}</text>
<text style="color:#dbd9d9;">拍平版本</text>
<text class="font-size-20" style="white-space: normal;" flatten>{{data.multiLineText}}</text>
</view>
<view class="margin-bottom-10" style="overflow: visible;">
<text class="font-weight-bold">white-space: nowrap</text>
<text class="font-size-20" style="white-space: nowrap;align-self: flex-start;">{{data.multiLineText}}</text>
<text style="color:#dbd9d9;">拍平版本</text>
<text class="font-size-20" style="white-space: nowrap;align-self: flex-start;" flatten>{{data.multiLineText}}</text>
</view>
<view class="margin-bottom-10">
<text class="font-weight-bold">任意宽度截断(100px、200px、300px)</text>
<text class="font-size-20" style="text-overflow: ellipsis;white-space: nowrap;width: 100px;">{{data.multiLineText}}</text>
<text style="color:#dbd9d9;">拍平版本</text>
<text class="font-size-20" style="text-overflow: ellipsis;white-space: nowrap;width: 100px;" flatten>{{data.multiLineText}}</text>
<text class="font-size-20" style="text-overflow: ellipsis;white-space: nowrap;width: 200px;">{{data.multiLineText}}</text>
<text style="color:#dbd9d9;">拍平版本</text>
<text class="font-size-20" style="text-overflow: ellipsis;white-space: nowrap;width: 200px;" flatten>{{data.multiLineText}}</text>
<text class="font-size-20" style="text-overflow: ellipsis;white-space: nowrap;width: 300px;">{{data.multiLineText}}</text>
<text style="color:#dbd9d9;">拍平版本</text>
<text class="font-size-20" style="text-overflow: ellipsis;white-space: nowrap;width: 300px;" flatten>{{data.multiLineText}}</text>
</view>
<view class="margin-bottom-10">
<text class="font-weight-bold">2行 text-overflow:ellipsis</text>
<!-- #ifdef !VUE3-VAPOR && APP -->
<text class="font-size-20" style="text-overflow: ellipsis; lines: 2;width: 100px;">{{data.multiLineText}}</text>
<!-- #endif -->
<!-- #ifdef VUE3-VAPOR || WEB || MP -->
<text class="font-size-20" style="text-overflow: ellipsis; width: 100px;" :max-lines="2">{{data.multiLineText}}</text>
<!-- #endif -->
</view>
<view class="margin-bottom-10 uni-common-mt">
<text class="uni-title-text">setProperty 设置与 getPropertyValue 获取</text>
</view>
<view class="common-box">
<!-- 普通版本 -->
<view class="uni-common-mt">
<text class="uni-title-text">text-overflow</text>
<text class="uni-info">设置值: {{data.textOverflow}}</text>
<text class="uni-info">获取值: {{data.textOverflowActual}}</text>
<view class="test-box">
<text ref="textRef" class="font-size-14 test-text" :style="{ textOverflow: data.textOverflow, whiteSpace: 'nowrap', width: '150px' }">{{data.multiLineText}}</text>
</view>
</view>
<!-- 拍平版本 -->
<view class="uni-common-mt">
<text class="uni-title-text">拍平</text>
<text class="uni-info">设置值: {{data.textOverflow}}</text>
<text class="uni-info">获取值: {{data.textOverflowActualFlat}}</text>
<view class="test-box">
<text ref="textRefFlat" class="font-size-14 test-text-flatten" :style="{ textOverflow: data.textOverflow, whiteSpace: 'nowrap', width: '150px' }" flatten>{{data.multiLineText}}</text>
</view>
</view>
</view>
<view class="uni-common-mt uni-common-mb">
<text class="uni-tips">第一个枚举值,'' (空字符串) - 空值情况</text>
<enum-data :items="textOverflowEnum" title="text-overflow 枚举值" @change="radioChangeTextOverflow" :compact="true"></enum-data>
<input-data :defaultValue="data.textOverflow" title="text-overflow 自定义值" type="text" @confirm="inputChangeTextOverflow"></input-data>
</view>
</view>
</view>
<!-- #ifdef APP && !VUE3-VAPOR -->
</scroll-view>
<!-- #endif -->
</template>
<script setup lang="uts">
import { ItemType } from '@/components/enum-data/enum-data-types'
const data = reactive({
multiLineText: 'HBuilderX,轻巧、极速,极客编辑器;uni-app x,终极跨平台方案;uts,大一统语言',
singleLineText: 'uts,大一统语言(单行文本)',
textOverflow: 'clip',
textOverflowActual: '',
textOverflowActualFlat: ''
})
const textOverflowEnum: ItemType[] = [
{ value: 0, name: '' },
{ value: 1, name: 'clip' },
{ value: 2, name: 'ellipsis' }
]
const textRef = ref(null as UniTextElement | null)
const textRefFlat = ref(null as UniTextElement | null)
const getPropertyValues = () => {
data.textOverflowActual = textRef.value?.style.getPropertyValue('text-overflow') ?? ''
data.textOverflowActualFlat = textRefFlat.value?.style.getPropertyValue('text-overflow') ?? ''
}
const changeTextOverflow = (value: string) => {
data.textOverflow = value
textRef.value?.style.setProperty('text-overflow', value)
textRefFlat.value?.style.setProperty('text-overflow', value)
// 使用 nextTick 确保样式已应用后再获取值
nextTick(() => {
getPropertyValues()
})
}
const radioChangeTextOverflow = (index: number) => {
const selectedItem = textOverflowEnum.find((item): boolean => item.value === index)
if (selectedItem != null) {
changeTextOverflow(selectedItem.name)
}
}
const inputChangeTextOverflow = (value: string) => {
changeTextOverflow(value)
}
onReady(() => {
getPropertyValues()
})
defineExpose({
radioChangeTextOverflow,
data
})
</script>
<style>
.font-size-20 {
font-size: 20px;
}
.font-size-14{
font-size: 14px;
}
.font-weight-bold {
font-weight: bold;
}
.margin-bottom-10 {
margin-bottom: 10px;
}
.common-box{
flex-direction: row;
justify-content: space-around;
}
.test-box {
width: 160px;
height: 80px;
background-color: #cccccc;
justify-content: center;
align-items: center;
}
</style>

查看文件

@@ -0,0 +1,155 @@
<template>
<!-- #ifdef APP && !VUE3-VAPOR -->
<scroll-view style="flex: 1">
<!-- #endif -->
<view class="container">
<text class="text" style="text-shadow: 1px 1px 2px pink;">text-shadow: 1px 1px 2px pink</text>
<!-- <text class="text" style="text-shadow: #fc0 1px 0 10px;">text-shadow: #fc0 1px 0 10px</text> -->
<text class="text" style="text-shadow: 5px 5px #558abb;">text-shadow: 5px 5px #558abb</text>
<text class="text" style="text-shadow: cyan 2px 5px;">text-shadow: cyan 2px 5px</text>
<text class="text" style="text-shadow: 5px 10px;">text-shadow: 5px 10px</text>
<text class="text" style="text-shadow: 1px 2px 4px rgb(34, 202, 43);">text-shadow: 1px 2px 4px rgb(34, 202, 43)</text>
<text class="text" style="text-shadow: 2px 4px rgba(202, 207, 17, 0.5);">text-shadow: 2px 4px rgba(202, 207, 17, 0.5)</text>
<text class="text" style="text-shadow: 1rpx 2rpx 4rpx #00f8;">text-shadow: 1rpx 2rpx 4rpx #00f8</text>
<text class="text" style="text-shadow: 2px 4px #0000ff80;">text-shadow: 2px 4px #0000ff80</text>
<text class="uni-title-text">【拍平版本】</text>
<text class="text" style="text-shadow: 1px 1px 2px pink;" flatten>text-shadow: 1px 1px 2px pink</text>
<!-- <text class="text" style="text-shadow: #fc0 1px 0 10px;" flatten>text-shadow: #fc0 1px 0 10px</text> -->
<text class="text" style="text-shadow: 5px 5px #558abb;" flatten>text-shadow: 5px 5px #558abb</text>
<text class="text" style="text-shadow: cyan 2px 5px;" flatten>text-shadow: cyan 2px 5px</text>
<text class="text" style="text-shadow: 5px 10px;" flatten>text-shadow: 5px 10px</text>
<text class="text" style="text-shadow: 1px 2px 4px rgb(34, 202, 43);" flatten>text-shadow: 1px 2px 4px rgb(34, 202, 43)</text>
<text class="text" style="text-shadow: 2px 4px rgba(202, 207, 17, 0.5);" flatten>text-shadow: 2px 4px rgba(202, 207, 17, 0.5)</text>
<text class="text" style="text-shadow: 1rpx 2rpx 4rpx #00f8;" flatten>text-shadow: 1rpx 2rpx 4rpx #00f8</text>
<text class="text" style="text-shadow: 2px 4px #0000ff80;" flatten>text-shadow: 2px 4px #0000ff80</text>
<view class="uni-common-mt">
<text class="uni-title-text">setProperty 设置与 getPropertyValue 获取</text>
</view>
<view class="common-box">
<!-- 普通版本 -->
<view class="uni-common-mt">
<text class="uni-title-text">text-shadow</text>
<text class="uni-info">设置值: {{data.textShadow}}</text>
<text class="uni-info info-wrap">获取值: {{data.textShadowActual}}</text>
<view class="test-box">
<text ref="textRef" class="text test-text" :style="{ textShadow: data.textShadow }">当前 text-shadow: {{data.textShadow}}</text>
</view>
</view>
<!-- 拍平版本 -->
<view class="uni-common-mt">
<text class="uni-title-text">拍平</text>
<text class="uni-info">设置值: {{data.textShadow}}</text>
<text class="uni-info info-wrap">获取值: {{data.textShadowActualFlat}}</text>
<view class="test-box">
<text ref="textRefFlat" class="text test-text-flatten" :style="{ textShadow: data.textShadow }" flatten>当前 text-shadow: {{data.textShadow}}</text>
</view>
</view>
</view>
<view class="uni-common-mt uni-common-mb">
<text class="uni-tips">第一个枚举值,'' (空字符串) - 空值情况</text>
<enum-data :items="textShadowEnum" title="text-shadow 枚举值" @change="radioChangeTextShadow" :compact="true"></enum-data>
<input-data :defaultValue="data.textShadow" title="text-shadow 自定义值" type="text" @confirm="inputChangeTextShadow"></input-data>
</view>
</view>
<!-- #ifdef APP && !VUE3-VAPOR -->
</scroll-view>
<!-- #endif -->
</template>
<script setup lang="uts">
import { ItemType } from '@/components/enum-data/enum-data-types'
const textShadowEnum: ItemType[] = [
{ value: 0, name: '' },
{ value: 1, name: '1px 1px 2px pink' },
// { value: 2, name: '#fc0 1px 0 10px' },
{ value: 3, name: '5px 5px #558abb' },
{ value: 4, name: 'cyan 2px 5px' },
{ value: 5, name: '5px 10px' },
{ value: 6, name: '1px 2px 4px rgb(34, 202, 43)' },
{ value: 7, name: '2px 4px rgba(202, 207, 17, 0.5)' },
{ value: 8, name: '4rpx 8rpx #0000ff80' },
{ value: 9, name: '2rpx 4rpx 8rpx #00f8' }
]
const data = reactive({
textShadow: '1px 1px 2px pink',
textShadowActual: '',
textShadowActualFlat: ''
})
const textRef = ref(null as UniTextElement | null)
const textRefFlat = ref(null as UniTextElement | null)
const getPropertyValues = () => {
data.textShadowActual = textRef.value?.style.getPropertyValue('text-shadow') ?? ''
data.textShadowActualFlat = textRefFlat.value?.style.getPropertyValue('text-shadow') ?? ''
}
const changeTextShadow = (value: string) => {
data.textShadow = value
textRef.value?.style.setProperty('text-shadow', value)
textRefFlat.value?.style.setProperty('text-shadow', value)
// 使用 nextTick 确保样式已应用后再获取值
nextTick(() => {
getPropertyValues()
})
}
const radioChangeTextShadow = (index: number) => {
const selectedItem = textShadowEnum.find((item): boolean => item.value === index)
if (selectedItem != null) {
changeTextShadow(selectedItem.name)
}
}
const inputChangeTextShadow = (value: string) => {
changeTextShadow(value)
}
onReady(() => {
getPropertyValues()
})
defineExpose({
radioChangeTextShadow,
data
})
</script>
<style>
.container {
background-color: gray;
justify-content: center;
}
.text {
width: 100%;
height: 50px;
font-size: 20px;
text-align: center;
}
.common-box{
flex-direction: row;
justify-content: space-around;
}
.test-box {
width: 180px;
height: 80px;
background-color: #cccccc;
justify-content: center;
align-items: center;
}
.info-wrap {
width: 200px;
white-space: normal;
}
</style>

二进制
mpuniapp/pages/CSS/text/uni.ttf 普通文件

二进制文件未显示。

查看文件

@@ -0,0 +1,143 @@
<template>
<!-- #ifdef APP && !VUE3-VAPOR -->
<scroll-view style="flex: 1">
<!-- #endif -->
<view style="flex-grow: 1;">
<scroll-view style="padding: 10px 0px; background-color: gray;justify-content: center;" direction="horizontal">
<text class="text" :style="{ whiteSpace: data.whiteSpace }">{{data.multiLineText}}</text>
</scroll-view>
<text>拍平</text>
<scroll-view style="padding: 10px 0px; background-color: gray;justify-content: center;" direction="horizontal">
<text class="text" :style="{ whiteSpace: data.whiteSpace }" flatten>{{data.multiLineText}}</text>
</scroll-view>
<scroll-view style="flex: 1">
<view class="content uni-common-mt">
<text class="uni-title-text">setProperty 设置与 getPropertyValue 获取</text>
</view>
<view class="common-box">
<!-- 普通版本 -->
<view class="uni-common-mt">
<text class="uni-title-text">white-space</text>
<text class="uni-info">设置值: {{data.whiteSpace}}</text>
<text class="uni-info">获取值: {{data.whiteSpaceActual}}</text>
<view class="test-box">
<text ref="textRef" class="text test-text" :style="{ whiteSpace: data.whiteSpace }">{{data.multiLineText}}</text>
</view>
</view>
<!-- 拍平版本 -->
<view class="uni-common-mt">
<text class="uni-title-text">拍平</text>
<text class="uni-info">设置值: {{data.whiteSpace}}</text>
<text class="uni-info">获取值: {{data.whiteSpaceActualFlat}}</text>
<view class="test-box">
<text ref="textRefFlat" class="text test-text-flatten" :style="{ whiteSpace: data.whiteSpace }" flatten>{{data.multiLineText}}</text>
</view>
</view>
</view>
<view class="uni-common-mt uni-common-mb">
<text class="uni-tips">第一个枚举值,'' (空字符串) - 空值情况</text>
<enum-data :items="whiteSpaceEnum" title="white-space 枚举值" @change="radioChangeWhiteSpace" :compact="true"></enum-data>
<input-data :defaultValue="data.whiteSpace" title="white-space 自定义值" type="text" @confirm="inputChangeWhiteSpace"></input-data>
</view>
</scroll-view>
</view>
<!-- #ifdef APP && !VUE3-VAPOR -->
</scroll-view>
<!-- #endif -->
</template>
<script setup lang="uts">
import { ItemType } from '@/components/enum-data/enum-data-types'
const whiteSpaceEnum: ItemType[] = [
{ value: 0, name: '' },
{ value: 1, name: 'normal' },
{ value: 2, name: 'nowrap' },
{ value: 3, name: 'pre' },
{ value: 4, name: 'pre-wrap' },
{ value: 5, name: 'pre-line' },
{ value: 6, name: 'break-spaces' },
{ value: 7, name: 'keep' }
]
const data = reactive({
multiLineText: `HBuilderX,
轻巧、
极速,
极客编辑器;
uni-app x,
终极跨平台方案;
uts,
大一统语言
HBuilderX,轻巧、极速,极客编辑器;uni-app x,终极跨平台方案;uts,大一统语言`,
whiteSpace: 'normal',
whiteSpaceActual: '',
whiteSpaceActualFlat: ''
})
const textRef = ref(null as UniTextElement | null)
const textRefFlat = ref(null as UniTextElement | null)
const getPropertyValues = () => {
data.whiteSpaceActual = textRef.value?.style.getPropertyValue('white-space') ?? ''
data.whiteSpaceActualFlat = textRefFlat.value?.style.getPropertyValue('white-space') ?? ''
}
const changeWhiteSpace = (value: string) => {
data.whiteSpace = value
textRef.value?.style.setProperty('white-space', value)
textRefFlat.value?.style.setProperty('white-space', value)
// 使用 nextTick 确保样式已应用后再获取值
nextTick(() => {
getPropertyValues()
})
}
const radioChangeWhiteSpace = (index: number) => {
const selectedItem = whiteSpaceEnum.find((item): boolean => item.value === index)
if (selectedItem != null) {
changeWhiteSpace(selectedItem.name)
}
}
const inputChangeWhiteSpace = (value: string) => {
changeWhiteSpace(value)
}
onReady(() => {
getPropertyValues()
})
defineExpose({
radioChangeWhiteSpace,
data
})
</script>
<style>
.text {
font-size: 16px;
/* 需要设置 align-self text组件才会自适应宽度 */
align-self: flex-start;
}
.common-box{
flex-direction: row;
justify-content: space-around;
}
.test-box {
width: 180px;
height: 200px;
background-color: gray;
justify-content: center;
align-items: center;
}
</style>