Initial commit of akmon project

This commit is contained in:
2026-01-20 08:04:15 +08:00
commit 77a2bab985
1309 changed files with 343305 additions and 0 deletions

View File

@@ -0,0 +1,18 @@
## 0.1.02025-04-22
- feat: 兼容uniappx 鸿蒙next
## 0.0.82025-01-13
- feat: 增加阻止事件冒泡
## 0.0.72025-01-13
- fix: uniapp x ios 不显示问题
## 0.0.62024-11-26
- feat: z-index改到998
## 0.0.52024-11-14
- fix: css transition-duration问题
## 0.0.42024-11-13
- chore: 更新文档
## 0.0.32024-11-03
- feat: z-index降到887
## 0.0.22024-10-24
- chore: 兼容vue2
## 0.0.12024-10-24
- init

View File

@@ -0,0 +1,36 @@
@import '~@/uni_modules/lime-style/index.scss';
$prefix: l !default;
$overlay: #{$prefix}-overlay;
$overlay-bg-color: create-var(overlay-bg-color, rgba(0, 0, 0, 0.6));
$overlay-z-index: create-var(overlay-z-index, 998);
$overlay-transition-duration: create-var(overlay-transition-duration, 300ms);
/* #ifndef APP-ANDROID || APP-IOS || APP-NVUE || APP-HARMONY */
$overlay-blur: blur(create-var(overlay-blur, 4px));
/* #endif */
.#{$overlay}{
position: fixed;
top: 0;
left: 0;
width: 100%;
bottom: 0;
background-color: $overlay-bg-color;
transition-duration: $overlay-transition-duration;
transition-property: opacity;
transition-timing-function: ease;
z-index: $overlay-z-index;
opacity: 1; // uniapp x ios 必须要设置
/* #ifndef APP-ANDROID || APP-IOS || APP-NVUE || APP-HARMONY */
backdrop-filter: $overlay-blur;
/* #endif */
}
.l-fade-enter {
opacity: 0;
}
.l-fade-leave-to {
opacity: 0;
}

View File

@@ -0,0 +1,80 @@
<template>
<view v-if="inited"
class="l-overlay"
ref="overlayRef"
:class="[lClass, classes]"
:style="[styles, lStyle]"
@click.stop="onClick"
@touchmove.stop="noop"
@transitionend="finished"
:aria-role="ariaRole"
:aria-label="ariaLabel">
<slot></slot>
</view>
</template>
<script lang="uts" setup>
import { useTransition, UseTransitionOptions, TransitionEmitStatus } from '@/uni_modules/lime-transition';
import { OverlayProps } from './type';
defineOptions({
name:'l-overlay'
})
const props = withDefaults(defineProps<OverlayProps>(), {
ariaLabel: '关闭',
ariaRole: 'button',
preventScrollThrough: true,
zIndex: 998,
visible: false,
duration: 300,
})
const emit = defineEmits(['click', 'before-enter', 'enter', 'after-enter', 'before-leave', 'leave', 'after-leave'])
const {inited, display, classes, finished} = useTransition({
defaultName: 'fade',
appear: props.visible,
emits: (name:TransitionEmitStatus) => { emit(name) },
visible: (): boolean => props.visible,
duration: props.duration,
} as UseTransitionOptions)
const styles = computed<Map<string,any>>(():Map<string,any> => {
const style = new Map<string,any>();
if (props.bgColor != null) {
style.set("background", props.bgColor!)
}
if (props.zIndex > 0) {
style.set("z-index", props.zIndex)
}
// #ifndef APP || WEB
style.set('transition-duration', props.duration + 'ms')
if (!display.value) {
style.set("display", "none")
}
// #endif
return style
})
const noop = () => {}
const onClick = (event: UniPointerEvent) =>{
// event.stopPropagation()
emit('click', !props.visible)
}
// #ifdef APP || WEB
const overlayRef = ref<UniElement|null>(null)
watchEffect(()=>{
overlayRef.value?.style.setProperty('transition-duration', `${props.duration}ms`)
if(!display.value){
overlayRef.value?.style.setProperty('display', "none")
} else {
overlayRef.value?.style.setProperty('display', "flex")
}
})
// #endif
</script>
<style lang="scss">
@import './index';
</style>

View File

@@ -0,0 +1,70 @@
<template>
<view
v-if="inited"
class="l-overlay"
:class="[lClass, classes]"
:style="[styles, lStyle]"
@click.stop="onClick"
@touchmove.stop="noop"
@transitionend="finished"
:aria-role="ariaRole || 'button'"
:aria-label="ariaLabel || '关闭'">
<slot></slot>
</view>
</template>
<script lang="ts">
// @ts-nocheck
import { computed, defineComponent } from '@/uni_modules/lime-shared/vue';
import { useTransition, UseTransitionOptions, TransitionEmitStatus } from '@/uni_modules/lime-transition';
import overlayProps from './props';
export default defineComponent({
props: overlayProps,
emits: ['click', 'before-enter', 'enter', 'after-enter', 'before-leave', 'leave', 'after-leave'],
options: {
addGlobalClass: true,
virtualHost: true,
externalClasses: true,
},
externalClasses: ['l-class'],
setup(props, { emit }) {
const {inited, display, classes, finished} = useTransition({
defaultName: 'fade',
appear: props.visible,
emits: (name:TransitionEmitStatus) => { emit(name) },
visible: (): boolean => props.visible,
duration: props.duration,
} as UseTransitionOptions)
const styles = computed(() => ({
'transition-duration': props.duration + 'ms',
'background': props.bgColor,
'z-index': props.zIndex,
'display': !display.value ? 'none' : '',
}))
const onClick = () => {
emit('click', !props.visible)
}
const noop = (e) => {
e?.preventDefault();
return
}
return {
inited,
styles,
classes,
noop,
onClick,
finished
}
}
})
</script>
<style lang="scss">
@import './index';
</style>

View File

@@ -0,0 +1,20 @@
export default {
visible: Boolean,
zIndex: {
type: Number,
default: 998,
},
duration: {
type: Number,
default: 300
},
preventScrollThrough: {
type: Boolean,
default: true
},
bgColor: String,
lStyle: String,
lClass: String,
ariaLabel: String,
ariaRole: String,
}

View File

@@ -0,0 +1,30 @@
// @ts-nocheck
export interface OverlayProps {
ariaLabel: string;
ariaRole: string;
lClass?: string;
/**
* 遮罩层的背景色
*/
bgColor ?: string;
/**
* 遮罩层自定义样式。优先级低于其他属性
*/
lStyle ?: string;
/**
* 背景色过渡时间,单位毫秒
*/
duration : number;
/**
* 防止滚动穿透,即不允许点击和滚动
*/
preventScrollThrough : boolean;
/**
* 是否展示
*/
visible : boolean;
/**
* 遮罩的层级
*/
zIndex : number;
}

View File

@@ -0,0 +1,88 @@
<template>
<view class="demo-block">
<text class="demo-block__title-text ultra">遮罩层</text>
<text class="demo-block__desc-text">通过遮罩层,可以强调部分内容</text>
<view class="demo-block__body">
<view class="demo-block">
<text class="demo-block__title-text">基础使用</text>
<view class="demo-block__body">
<button @click="onClick">显示</button>
<l-overlay :visible="show" @click="onClick"></l-overlay>
</view>
</view>
<view class="demo-block">
<text class="demo-block__title-text">嵌入内容</text>
<view class="demo-block__body">
<button @click="show2 = true">显示</button>
<l-overlay :visible="show2" @click="show2 = !show2">
<view class="wrapper">
<view class="block" />
</view>
</l-overlay>
</view>
</view>
</view>
</view>
</template>
<script lang="uts" setup>
const show = ref(false);
const show2 = ref(false);
const onClick = () => {
show.value = !show.value
}
</script>
<style lang="scss">
.wrapper {
display: flex;
align-items: center;
justify-content: center;
height: 100%;
}
.block {
width: 120px;
height: 120px;
background-color: #fff;
}
.demo-block {
margin: 32px 20px 0;
overflow: visible;
&__title {
margin: 0;
margin-top: 8px;
&-text {
color: rgba(0, 0, 0, 0.6);
font-weight: 400;
font-size: 14px;
line-height: 16px;
&.large {
color: rgba(0, 0, 0, 0.9);
font-size: 18px;
font-weight: 700;
line-height: 26px;
}
&.ultra {
color: rgba(0, 0, 0, 0.9);
font-size: 24px;
font-weight: 700;
line-height: 32px;
}
}
}
&__desc-text {
color: rgba(0, 0, 0, 0.6);
margin: 8px 16px 0 0;
font-size: 14px;
line-height: 22px;
}
&__body {
margin: 16px 0;
overflow: visible;
.demo-block {
// margin-top: 0px;
margin: 0;
}
}
}
</style>

View File

@@ -0,0 +1,98 @@
<template>
<view class="demo-block">
<text class="demo-block__title-text ultra">遮罩层</text>
<text class="demo-block__desc-text">通过遮罩层可以强调部分内容</text>
<view class="demo-block__body">
<view class="demo-block">
<text class="demo-block__title-text">基础使用</text>
<view class="demo-block__body">
<button @click="onClick">显示</button>
<l-overlay :visible="show" @click="onClick"></l-overlay>
</view>
</view>
<view class="demo-block">
<text class="demo-block__title-text">嵌入内容</text>
<view class="demo-block__body">
<button @click="show2 = true">显示</button>
<l-overlay :visible="show2" @click="show2 = !show2">
<view class="wrapper">
<view class="block" />
</view>
</l-overlay>
</view>
</view>
</view>
</view>
</template>
<script>
export default {
data() {
return {
show: false,
show2: false,
}
},
methods:{
onClick(){
this.show = !this.show
console.log(`show`, this.show)
}
}
}
</script>
<style lang="scss">
.wrapper {
display: flex;
align-items: center;
justify-content: center;
height: 100%;
}
.block {
width: 120px;
height: 120px;
background-color: #fff;
}
.demo-block {
margin: 32px 20px 0;
overflow: visible;
&__title {
margin: 0;
margin-top: 8px;
&-text {
color: rgba(0, 0, 0, 0.6);
font-weight: 400;
font-size: 14px;
line-height: 16px;
&.large {
color: rgba(0, 0, 0, 0.9);
font-size: 18px;
font-weight: 700;
line-height: 26px;
}
&.ultra {
color: rgba(0, 0, 0, 0.9);
font-size: 24px;
font-weight: 700;
line-height: 32px;
}
}
}
&__desc-text {
color: rgba(0, 0, 0, 0.6);
margin: 8px 16px 0 0;
font-size: 14px;
line-height: 22px;
}
&__body {
margin: 16px 0;
overflow: visible;
.demo-block {
// margin-top: 0px;
margin: 0;
}
}
}
</style>

View File

@@ -0,0 +1,90 @@
{
"id": "lime-overlay",
"displayName": "lime-overlay 遮罩层",
"version": "0.1.0",
"description": "lime-overlay 通过遮罩层,可以强调部分内容,兼容uniapp/uniappx",
"keywords": [
"lime-overlay",
"overlay",
"遮罩层"
],
"repository": "",
"engines": {
"HBuilderX": "^4.28"
},
"dcloudext": {
"type": "component-vue",
"sale": {
"regular": {
"price": "0.00"
},
"sourcecode": {
"price": "0.00"
}
},
"contact": {
"qq": ""
},
"declaration": {
"ads": "无",
"data": "无",
"permissions": "无"
},
"npmurl": ""
},
"uni_modules": {
"dependencies": [
"lime-style",
"lime-shared",
"lime-transition"
],
"encrypt": [],
"platforms": {
"cloud": {
"tcb": "y",
"aliyun": "y",
"alipay": "y"
},
"client": {
"Vue": {
"vue2": "u",
"vue3": "y"
},
"App": {
"app-vue": "y",
"app-uvue": "y",
"app-nvue": "u",
"app-harmony": "u"
},
"H5-mobile": {
"Safari": "y",
"Android Browser": "y",
"微信浏览器(Android)": "y",
"QQ浏览器(Android)": "y"
},
"H5-pc": {
"Chrome": "u",
"IE": "u",
"Edge": "u",
"Firefox": "u",
"Safari": "u"
},
"小程序": {
"微信": "y",
"阿里": "u",
"百度": "u",
"字节跳动": "u",
"QQ": "u",
"钉钉": "u",
"快手": "u",
"飞书": "u",
"京东": "u"
},
"快应用": {
"华为": "u",
"联盟": "u"
}
}
}
}
}

View File

@@ -0,0 +1,102 @@
# lime-overlay 遮罩层
- 通过遮罩层,可以强调部分内容
- 插件依赖`lime-style`,`lime-shared`,`lime-transition`,不喜勿下
## 安装
在插件市场导入即可,首次安装可能需要重新编译
## 代码演示
### 基础用法
```html
<button @click="onClick">显示</button>
<l-overlay :visible="show" @click="onClick"></l-overlay>
```
```js
const show = ref(false);
const onClick = () => {
show.value = !show.value
}
```
### 嵌入内容
通过默认插槽可以在遮罩层上嵌入任意内容。
```html
<button @click="onClick">显示</button>
<l-overlay :visible="show" @click="onClick">
<view class="wrapper">
<view class="block" />
</view>
</l-overlay>
```
```js
const show = ref(false);
const onClick = () => {
show.value = !show.value
}
```
### 查看示例
- 导入后直接使用这个标签查看演示效果
```html
<!-- // 代码位于 uni_modules/lime-overlay/compoents/lime-overlay -->
<lime-overlay />
```
### 插件标签
- 默认 l-overlay 为 component
- 默认 lime-overlay 为 demo
### 关于vue2的使用方式
- 插件使用了`composition-api`, 如果你希望在vue2中使用请按官方的教程[vue-composition-api](https://uniapp.dcloud.net.cn/tutorial/vue-composition-api.html)配置
- 关键代码是: 在main.js中 在vue2部分加上这一段即可
```js
// vue2
import Vue from 'vue'
import VueCompositionAPI from '@vue/composition-api'
Vue.use(VueCompositionAPI)
```
## API
### Props
| 参数 | 说明 | 类型 | 默认值 |
| --- | --- | --- | --- |
| visible | 是否展示遮罩层 | _boolean_ | `false` |
| z-index | z-index 层级 | _number_ | `1000` |
| duration | 动画时长单位ms设置为 0 可以禁用动画 | _number_ | `300` |
| lStyle | 样式 | _string_ | `` |
| destoryOnClose | 隐藏时是否销毁 | _boolean_ | `false` |
### Events
| 事件名 | 说明 | 回调参数 |
| ------ | ---------- | ------------------- |
| click | 点击时触发 | _-_ |
### Slots
| 名称 | 说明 |
| ------- | ---------------------------------- |
| default | 默认插槽,用于在遮罩层上方嵌入内容 |
## 主题定制
### 样式变量
组件提供了下列 CSS 变量可用于自定义样式uvue app无效。
| 名称 | 默认值 | 描述 |
| ------------------------ | -------------------- | ---- |
| --l-overlay-z-index | _1000_ | - |
| --l-overlay-background | _rgba(0, 0, 0, 0.6)_ | - |
## 打赏
如果你觉得本插件,解决了你的问题,赠人玫瑰,手留余香。
![](https://testingcf.jsdelivr.net/gh/liangei/image@1.9/alipay.png)
![](https://testingcf.jsdelivr.net/gh/liangei/image@1.9/wpay.png)