This commit is contained in:
2026-09-24 16:25:22 +08:00
commit 7428184f01
1198 changed files with 314515 additions and 0 deletions
+2
View File
@@ -0,0 +1,2 @@
## 1.0.02024-08-31
首次发布
+82
View File
@@ -0,0 +1,82 @@
{
"id": "x-window-grey",
"displayName": "x-window-grey",
"version": "1.0.0",
"description": "x-window-grey",
"keywords": [
"x-window-grey"
],
"repository": "",
"engines": {
"HBuilderX": "^3.6.8"
},
"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": "u",
"aliyun": "u",
"alipay": "u"
},
"client": {
"Vue": {
"vue2": "u",
"vue3": "u"
},
"App": {
"app-android": "u",
"app-ios": "u"
},
"H5-mobile": {
"Safari": "u",
"Android Browser": "u",
"微信浏览器(Android)": "u",
"QQ浏览器(Android)": "u"
},
"H5-pc": {
"Chrome": "u",
"IE": "u",
"Edge": "u",
"Firefox": "u",
"Safari": "u"
},
"小程序": {
"微信": "u",
"阿里": "u",
"百度": "u",
"字节跳动": "u",
"QQ": "u",
"钉钉": "u",
"快手": "u",
"飞书": "u",
"京东": "u"
},
"快应用": {
"华为": "u",
"联盟": "u"
}
}
}
}
}
+36
View File
@@ -0,0 +1,36 @@
# x-window-grey
### 开发文档
[TMUI4.0文档](https://xui.tmui.design/)
[TMUI4.0组件库](https://ext.dcloud.net.cn/plugin?id=16369)
主要用于特殊时间时的整体app变灰,比如国家哀悼日,让页面变灰色.
理论上uniapp也支持,uniappx也支持.
### 说明
这是tmui4.0|XUI的原生插件附赠插件
### 兼容性
| Harmony | IOS | Android | WEB | 小程序 |
| --- | --- | --- | --- | --- |
| x | 支持 | 支持 | 支持 | - |
### 使用
如果是安卓请务必打自定义基座,如果ios:你在mac环境下配置好了环境无需打包本地编译,如果win开发ios需要打包基座。
**需要注意的是**
变灰只针对当前窗口所有内容,如果你想任何页面,自动变灰,你可能需要自行封装,然后在onShow中执行变灰操作.
```ts
import { setWindowGrey,removeWindowGrey } from "@/uni_modules/x-window-grey";
// 让页面变灰
setWindowGrey()
// 恢复页面
removeWindowGrey()
```
@@ -0,0 +1,3 @@
{
"minSdkVersion": "21"
}
@@ -0,0 +1,27 @@
import Paint from 'android.graphics.Paint';
import ColorMatrix from 'android.graphics.ColorMatrix';
import ColorMatrixColorFilter from 'android.graphics.ColorMatrixColorFilter';
import View from 'android.view.View';
import ViewGroup from 'android.view.ViewGroup';
export function setWindowGrey(ele:any|null=null) {
let paint = new Paint()
let colorMatrix = new ColorMatrix()
colorMatrix.setSaturation((0).toFloat())
let decorView = UTSAndroid.getUniActivity()!.window.decorView as ViewGroup
paint.setColorFilter(new ColorMatrixColorFilter(colorMatrix))
decorView.setLayerType(View.LAYER_TYPE_HARDWARE,paint)
}
export function removeWindowGrey(ele:any|null=null) {
let paint = new Paint()
let colorMatrix = new ColorMatrix()
colorMatrix.setSaturation((1).toFloat())
let decorView = UTSAndroid.getUniActivity()!.window.decorView as ViewGroup
paint.setColorFilter(new ColorMatrixColorFilter(colorMatrix))
decorView.setLayerType(View.LAYER_TYPE_HARDWARE,paint)
}
@@ -0,0 +1,14 @@
import window from '@ohos.window';
// window.getLastWindow(UTSHarmony.getUIAbilityContext()).then((win:window.Window)=>{
// win.setWindowColorSpace(window.ColorSpace.WIDE_GAMUT)
// })
export function setWindowGrey(ele:any|null=null) {
}
export function removeWindowGrey(ele:any|null=null) {
}
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>NSPrivacyAccessedAPITypes</key>
<array/>
<key>NSPrivacyCollectedDataTypes</key>
<array/>
<key>NSPrivacyTracking</key>
<false/>
<key>NSPrivacyTrackingDomains</key>
<array/>
</dict>
</plist>
@@ -0,0 +1,3 @@
{
"deploymentTarget": "12"
}
@@ -0,0 +1,30 @@
import { UIViewController, UIView, UIWindow, UIScreen, UIColor } from 'UIKit';
import { CIFilter } from 'CoreImage';
let greayUview : UIView | null = null;
export function setWindowGrey(ele:any|null=null) {
if (UTSiOS.available("iOS 13.0, *")) {
let winsize = UIScreen.main.bounds as CGRect;
let view = new UIView();
view.backgroundColor = UIColor.lightGray
view.frame = winsize;
view.isUserInteractionEnabled = false;
view.layer.compositingFilter = "saturationBlendMode"
let paret = UTSiOS.getCurrentViewController()
greayUview = view;
DispatchQueue.main.async(execute = () : void => {
paret.view.addSubview(greayUview!)
})
}
}
export function removeWindowGrey(ele:any|null=null) {
DispatchQueue.main.async(execute = () : void => {
if (greayUview != null) {
greayUview!.removeFromSuperview();
}
})
}
@@ -0,0 +1,8 @@
export function setWindowGrey(ele:UniElement) {
ele.style.setProperty('filter', 'grayscale(1)')
}
export function removeWindowGrey(ele:UniElement) {
// ele.style.removeProperty('filter')
ele.style.setProperty('filter', 'none')
}
@@ -0,0 +1,8 @@
export function setWindowGrey(ele:any|null=null) {
let dom = document.body;
dom.style.setProperty('filter', 'grayscale(1)')
}
export function removeWindowGrey(ele:any|null=null) {
let dom = document.body;
dom.style.removeProperty('filter')
}