MCPcopy Index your code
hub / github.com/ZToolsCenter/ZTools / applyWindowMaterial

Function applyWindowMaterial

src/main/utils/windowUtils.ts:42–86  ·  view source on GitHub ↗
(
  win: BrowserWindow,
  material: 'mica' | 'acrylic' | 'none'
)

Source from the content-addressed store, hash-verified

40 * @param material 材质类型 'mica' | 'acrylic' | 'none'
41 */
42export function applyWindowMaterial(
43 win: BrowserWindow,
44 material: 'mica' | 'acrylic' | 'none'
45): void {
46 if (!win || win.isDestroyed()) return
47
48 const isWindows = process.platform === 'win32'
49
50 switch (material) {
51 case 'mica':
52 try {
53 if (isWindows) {
54 win.setBackgroundColor('#00000000') // 先设置透明背景
55 }
56 win.setBackgroundMaterial('mica')
57 // console.log(`✅ 窗口 ${win.id} Mica 材质已启用`)
58 } catch (error) {
59 console.error(`[WindowUtils] 窗口 ${win.id} 设置 Mica 失败:`, error)
60 win.setBackgroundColor('#f4f4f4')
61 }
62 break
63 case 'acrylic':
64 try {
65 if (isWindows) {
66 win.setBackgroundColor('#00000000') // 先设置透明背景
67 }
68 win.setBackgroundMaterial('acrylic')
69 // console.log(`✅ 窗口 ${win.id} Acrylic 材质已启用`)
70 } catch (error) {
71 console.error(`[WindowUtils] 窗口 ${win.id} 设置 Acrylic 失败:`, error)
72 win.setBackgroundColor('#f4f4f4')
73 }
74 break
75 case 'none':
76 default:
77 try {
78 win.setBackgroundMaterial('none')
79 win.setBackgroundColor('#f4f4f4')
80 // console.log(`✅ 窗口 ${win.id} 已禁用窗口材质`)
81 } catch (error) {
82 console.error(`[WindowUtils] 窗口 ${win.id} 设置背景失败:`, error)
83 }
84 break
85 }
86}
87/**
88 * 打开文件选择窗口
89 *

Callers 6

applyWindowMaterialMethod · 0.90
applyMaterialMethod · 0.90
applyMaterialToWindowMethod · 0.85
updateWindowMaterialMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected