Skip to content

Commit f97b545

Browse files
committed
改进个性磁贴小部件
1 parent 81947b8 commit f97b545

File tree

2 files changed

+55
-8
lines changed

2 files changed

+55
-8
lines changed

src/scripts/launcher.tsx

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,13 @@ const textColor = getStorage<string>('textColor') || '#ffffff'
2424
const gridColor: string | null = getStorage<string>('gridColor')
2525

2626
/**背景颜色或背景图链接*/
27-
const boxBg = getStorage<string>('boxBg') || '#ffffff'
27+
const boxBg = getStorage<string>('boxBg') || '#222222'
2828

2929
/**透明背景*/
30-
const transparentBg: Image | string = getStorage<Image>('transparentBg') || '#ffffff'
30+
const transparentBg: Image | string = getStorage<Image>('transparentBg') || '#222222'
31+
32+
/**格子间隔*/
33+
const space = getStorage<number>('space') || 1
3134

3235
// 好看的颜色
3336
const colors = {
@@ -68,7 +71,7 @@ const Grid: FC<GridProps> = ({...props}) => {
6871
const bgRandom = Math.floor(Math.random() * bgColors.length)
6972
const bgColor = bgColors[bgRandom]
7073
return (
71-
<wstack background={gridColor || background || bgColor} href={href} borderColor="#00000088" borderWidth={1}>
74+
<wstack background={gridColor || background || bgColor} href={href}>
7275
<Col
7376
background={/^\#[\d\w]+$/.test(String(background)) || gridColor ? '#00000000' : '#00000055'}
7477
alignItems="center"
@@ -86,6 +89,9 @@ const Grid: FC<GridProps> = ({...props}) => {
8689
)
8790
}
8891

92+
/**间隔组件*/
93+
const Space: FC = () => <wspacer length={Number(space)}></wspacer>
94+
8995
class Launcher {
9096
private config: GridProps[]
9197
constructor(config: GridProps[]) {
@@ -139,13 +145,17 @@ class Launcher {
139145
return (
140146
<wstack>
141147
<Grid {...this.config[0]}></Grid>
148+
<Space></Space>
142149
<wstack flexDirection="column">
143150
<wstack>
144151
<Grid {...this.config[1]}></Grid>
152+
<Space></Space>
145153
<Grid {...this.config[2]}></Grid>
146154
</wstack>
155+
<Space></Space>
147156
<wstack>
148157
<Grid {...this.config[3]}></Grid>
158+
<Space></Space>
149159
<Grid {...this.config[4]}></Grid>
150160
</wstack>
151161
</wstack>
@@ -160,30 +170,40 @@ class Launcher {
160170
{/* 上半部分 */}
161171
<wstack>
162172
<Grid {...this.config[0]}></Grid>
173+
<Space></Space>
163174
<wstack flexDirection="column">
164175
<wstack>
165176
<Grid {...this.config[1]}></Grid>
177+
<Space></Space>
166178
<Grid {...this.config[2]}></Grid>
167179
</wstack>
180+
<Space></Space>
168181
<wstack>
169182
<Grid {...this.config[3]}></Grid>
183+
<Space></Space>
170184
<Grid {...this.config[4]}></Grid>
171185
</wstack>
172186
</wstack>
173187
</wstack>
174188
{/* 下半部分 */}
189+
<Space></Space>
175190
<wstack>
176191
<wstack flexDirection="column">
177192
<wstack>
178193
<Grid {...this.config[5]}></Grid>
194+
<Space></Space>
179195
<Grid {...this.config[6]}></Grid>
180196
</wstack>
197+
<Space></Space>
181198
<Grid {...this.config[7]}></Grid>
182199
</wstack>
200+
<Space></Space>
183201
<wstack flexDirection="column">
184202
<Grid {...this.config[8]}></Grid>
203+
<Space></Space>
185204
<wstack>
186205
<Grid {...this.config[9]}></Grid>
206+
<Space></Space>
187207
<Grid {...this.config[10]}></Grid>
188208
</wstack>
189209
</wstack>
@@ -217,12 +237,17 @@ class Launcher {
217237
text: getStorage<string>('textColor') || '',
218238
placeholder: '这里填文字颜色',
219239
},
240+
{
241+
text: String(getStorage<number>('space')) || '',
242+
placeholder: '格子间间隔,默认是1',
243+
},
220244
],
221245
})
222246
if (cancel) return
223247
setStorage('boxBg', texts[0])
224248
setStorage('gridColor', texts[1])
225249
setStorage('textColor', texts[2])
250+
setStorage('space', texts[3])
226251
await showNotification({title: '设置完成', sound: 'default'})
227252
break
228253
case 1:

打包好的成品/个性磁贴启动器.js

Lines changed: 27 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
* github: https://github.com/2214962083/ios-scriptable-tsx
66
*/
77

8-
// @编译时间 1608088591895
8+
// @编译时间 1608093928194
99
const MODULE = module
1010
let __topLevelAwait__ = () => Promise.resolve()
1111
function EndAwait(promiseFunc) {
@@ -896,8 +896,9 @@ var Col = ({children, ...props}) => {
896896
var {setStorage: setStorage2, getStorage: getStorage2} = useStorage('luancher-xiaoming')
897897
var textColor = getStorage2('textColor') || '#ffffff'
898898
var gridColor = getStorage2('gridColor')
899-
var boxBg = getStorage2('boxBg') || '#ffffff'
900-
var transparentBg = getStorage2('transparentBg') || '#ffffff'
899+
var boxBg = getStorage2('boxBg') || '#222222'
900+
var transparentBg = getStorage2('transparentBg') || '#222222'
901+
var space = getStorage2('space') || 1
901902
var colors = {
902903
red: '#e54d42',
903904
orange: '#f37b1d',
@@ -923,8 +924,6 @@ var Grid = ({...props}) => {
923924
{
924925
background: gridColor || background || bgColor,
925926
href,
926-
borderColor: '#00000088',
927-
borderWidth: 1,
928927
},
929928
/* @__PURE__ */ h(
930929
Col,
@@ -955,6 +954,10 @@ var Grid = ({...props}) => {
955954
),
956955
)
957956
}
957+
var Space = () =>
958+
/* @__PURE__ */ h('wspacer', {
959+
length: Number(space),
960+
})
958961
var Launcher = class {
959962
constructor(config2) {
960963
this.config = config2
@@ -1008,6 +1011,7 @@ var Launcher = class {
10081011
/* @__PURE__ */ h(Grid, {
10091012
...this.config[0],
10101013
}),
1014+
/* @__PURE__ */ h(Space, null),
10111015
/* @__PURE__ */ h(
10121016
'wstack',
10131017
{
@@ -1019,16 +1023,19 @@ var Launcher = class {
10191023
/* @__PURE__ */ h(Grid, {
10201024
...this.config[1],
10211025
}),
1026+
/* @__PURE__ */ h(Space, null),
10221027
/* @__PURE__ */ h(Grid, {
10231028
...this.config[2],
10241029
}),
10251030
),
1031+
/* @__PURE__ */ h(Space, null),
10261032
/* @__PURE__ */ h(
10271033
'wstack',
10281034
null,
10291035
/* @__PURE__ */ h(Grid, {
10301036
...this.config[3],
10311037
}),
1038+
/* @__PURE__ */ h(Space, null),
10321039
/* @__PURE__ */ h(Grid, {
10331040
...this.config[4],
10341041
}),
@@ -1048,6 +1055,7 @@ var Launcher = class {
10481055
/* @__PURE__ */ h(Grid, {
10491056
...this.config[0],
10501057
}),
1058+
/* @__PURE__ */ h(Space, null),
10511059
/* @__PURE__ */ h(
10521060
'wstack',
10531061
{
@@ -1059,22 +1067,26 @@ var Launcher = class {
10591067
/* @__PURE__ */ h(Grid, {
10601068
...this.config[1],
10611069
}),
1070+
/* @__PURE__ */ h(Space, null),
10621071
/* @__PURE__ */ h(Grid, {
10631072
...this.config[2],
10641073
}),
10651074
),
1075+
/* @__PURE__ */ h(Space, null),
10661076
/* @__PURE__ */ h(
10671077
'wstack',
10681078
null,
10691079
/* @__PURE__ */ h(Grid, {
10701080
...this.config[3],
10711081
}),
1082+
/* @__PURE__ */ h(Space, null),
10721083
/* @__PURE__ */ h(Grid, {
10731084
...this.config[4],
10741085
}),
10751086
),
10761087
),
10771088
),
1089+
/* @__PURE__ */ h(Space, null),
10781090
/* @__PURE__ */ h(
10791091
'wstack',
10801092
null,
@@ -1089,14 +1101,17 @@ var Launcher = class {
10891101
/* @__PURE__ */ h(Grid, {
10901102
...this.config[5],
10911103
}),
1104+
/* @__PURE__ */ h(Space, null),
10921105
/* @__PURE__ */ h(Grid, {
10931106
...this.config[6],
10941107
}),
10951108
),
1109+
/* @__PURE__ */ h(Space, null),
10961110
/* @__PURE__ */ h(Grid, {
10971111
...this.config[7],
10981112
}),
10991113
),
1114+
/* @__PURE__ */ h(Space, null),
11001115
/* @__PURE__ */ h(
11011116
'wstack',
11021117
{
@@ -1105,12 +1120,14 @@ var Launcher = class {
11051120
/* @__PURE__ */ h(Grid, {
11061121
...this.config[8],
11071122
}),
1123+
/* @__PURE__ */ h(Space, null),
11081124
/* @__PURE__ */ h(
11091125
'wstack',
11101126
null,
11111127
/* @__PURE__ */ h(Grid, {
11121128
...this.config[9],
11131129
}),
1130+
/* @__PURE__ */ h(Space, null),
11141131
/* @__PURE__ */ h(Grid, {
11151132
...this.config[10],
11161133
}),
@@ -1143,12 +1160,17 @@ var Launcher = class {
11431160
text: getStorage2('textColor') || '',
11441161
placeholder: '这里填文字颜色',
11451162
},
1163+
{
1164+
text: String(getStorage2('space')) || '',
1165+
placeholder: '格子间间隔,默认是1',
1166+
},
11461167
],
11471168
})
11481169
if (cancel) return
11491170
setStorage2('boxBg', texts[0])
11501171
setStorage2('gridColor', texts[1])
11511172
setStorage2('textColor', texts[2])
1173+
setStorage2('space', texts[3])
11521174
await showNotification({title: '设置完成', sound: 'default'})
11531175
break
11541176
case 1:

0 commit comments

Comments
 (0)