Skip to content

Commit 723e64c

Browse files
authored
🐛 UnoCSS 加 prefix 解决 CSS冲突、CSS 布局修正 (#1013)
* [v1.3] UnoCSS 加 prefix 解决 CSS冲突 * CSS 布局修正 * inset 兼容修正 * `uno-` -> `tw-` ;符合平常的写法 * presetUno -> presetWind3, 加 extractors 让 vscode 能配对 * Install 頁面 CSS 布局修正 * rspack/postcss/unocss 语法修改
1 parent c78b64b commit 723e64c

File tree

33 files changed

+278
-262
lines changed

33 files changed

+278
-262
lines changed

postcss.config.mjs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import UnoCSS from "@unocss/postcss";
2+
import autoprefixer from "autoprefixer";
23

34
export default {
4-
plugins: [UnoCSS()],
5+
plugins: [UnoCSS(), autoprefixer()],
56
};

rspack.config.ts

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -66,20 +66,9 @@ export default defineConfig({
6666
module: {
6767
rules: [
6868
{
69-
test: /\.css$/,
70-
use: [
71-
{
72-
loader: "postcss-loader",
73-
options: {
74-
postcssOptions: {
75-
plugins: {
76-
autoprefixer: {},
77-
},
78-
},
79-
},
80-
},
81-
],
82-
type: "css",
69+
test: /\.css$/i,
70+
type: "css/auto",
71+
use: ["postcss-loader"],
8372
},
8473
{
8574
test: /\.(svg|png)$/,

src/index.css

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
@unocss preflights;
22
@unocss default;
3+
@unocss;
34

45
body {
56
scrollbar-color: var(--color-scrollbar-thumb) var(--color-scrollbar-track);
@@ -17,4 +18,19 @@ body[arco-theme='light'] {
1718
--color-scrollbar-thumb: #6b6b6b;
1819
--color-scrollbar-track: #f0f0f0;
1920
--color-scrollbar-thumb-hover: #8c8c8c;
20-
}
21+
}
22+
23+
:root {
24+
--sc-zero-1: 0;
25+
--sc-zero-2: 0;
26+
--sc-zero-3: 0;
27+
--sc-zero-4: 0;
28+
}
29+
30+
/* 自定义 .sc-inset-0 避免打包成 inset: 0 使旧浏览器布局错位 */
31+
.sc-inset-0 {
32+
top: var(--sc-zero-1);
33+
left: var(--sc-zero-2);
34+
right: var(--sc-zero-3);
35+
bottom: var(--sc-zero-4);
36+
}

src/pages/batchupdate/App.tsx

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,7 @@ function App() {
256256
title={
257257
<span
258258
onClick={() => openUpdatePage(item.uuid)}
259-
className="text-clickable text-gray-900 dark:text-gray-100 !hover:text-blue-600 dark:hover:text-blue-400"
259+
className="tw-text-clickable tw-text-gray-900 dark:tw-text-gray-100 !hover:tw-text-blue-600 dark:hover:tw-text-blue-400"
260260
>
261261
<Typography.Ellipsis rows={1} expandable={false} showTooltip={{ mini: true }}>
262262
{item.script?.name}
@@ -285,7 +285,7 @@ function App() {
285285
</>
286286
}
287287
>
288-
<Space className="pb-2">
288+
<Space className="tw-pb-2">
289289
<Space direction="vertical">
290290
<Text>{t("updatepage.old_version_")}</Text>
291291
<Text>{t("updatepage.new_version_")}</Text>
@@ -377,31 +377,31 @@ function App() {
377377
return (
378378
<>
379379
{
380-
<div className="mb-2 text-gray-800 dark:text-gray-200">
381-
<div className="flex flex-row items-center gap-2">
382-
<Typography.Title heading={6} className="!m-0 text-gray-900 dark:text-gray-100">
380+
<div className="tw-mb-2 tw-text-gray-800 dark:tw-text-gray-200">
381+
<div className="tw-flex tw-flex-row tw-items-center tw-gap-2">
382+
<Typography.Title heading={6} className="!tw-m-0 tw-text-gray-900 dark:tw-text-gray-100">
383383
{t("updatepage.main_header")}
384384
</Typography.Title>
385385
<IconSync
386386
spin={checkUpdateSpin}
387387
onClick={() => onCheckUpdateClick()}
388-
className="cursor-pointer text-gray-700 dark:text-gray-300"
388+
className="tw-cursor-pointer tw-text-gray-700 dark:tw-text-gray-300"
389389
/>
390390
</div>
391-
<div className="flex flex-row indent-4">
392-
<Typography.Text className="text-gray-700 dark:text-gray-300">{mStatusText}</Typography.Text>
391+
<div className="tw-flex tw-flex-row tw-indent-4">
392+
<Typography.Text className="tw-text-gray-700 dark:tw-text-gray-300">{mStatusText}</Typography.Text>
393393
</div>
394394
{mRecords === null ? (
395395
<></>
396396
) : (
397397
<>
398398
{mRecords.site.length === 0 && mRecords.other.length === 0 ? (
399-
<div className="flex flex-row indent-4">
400-
<Text className="text-gray-700 dark:text-gray-300">{t("updatepage.status_no_update")}</Text>
399+
<div className="tw-flex tw-flex-row tw-indent-4">
400+
<Text className="tw-text-gray-700 dark:tw-text-gray-300">{t("updatepage.status_no_update")}</Text>
401401
</div>
402402
) : (
403-
<div className="flex flex-row indent-4">
404-
<Text className="text-gray-700 dark:text-gray-300">
403+
<div className="tw-flex tw-flex-row tw-indent-4">
404+
<Text className="tw-text-gray-700 dark:tw-text-gray-300">
405405
{t("updatepage.status_n_update").replace("$0", `${mRecords.site.length + mRecords.other.length}`)}
406406
</Text>
407407
</div>
@@ -410,15 +410,15 @@ function App() {
410410
// <div><Text>{"没有已忽略的更新"}</Text></div>
411411
<></>
412412
) : (
413-
<div className="flex flex-row indent-4">
414-
<Text className="text-gray-700 dark:text-gray-300">
413+
<div className="tw-flex tw-flex-row tw-indent-4">
414+
<Text className="tw-text-gray-700 dark:tw-text-gray-300">
415415
{t("updatepage.status_n_ignored").replace("$0", `${mRecords.ignored.length}`)}
416416
</Text>
417417
</div>
418418
)}
419419
{mTimeClose >= 0 ? (
420-
<div className="flex flex-row indent-4">
421-
<Text className="text-gray-700 dark:text-gray-300">
420+
<div className="tw-flex tw-flex-row tw-indent-4">
421+
<Text className="tw-text-gray-700 dark:tw-text-gray-300">
422422
{t("updatepage.status_autoclose").replace("$0", `${mTimeClose}`)}
423423
</Text>
424424
</div>
@@ -439,9 +439,9 @@ function App() {
439439
<Collapse
440440
defaultActiveKey={[]}
441441
className={[
442-
"justify-self-center",
442+
"tw-justify-self-center",
443443
mRecords.site.length === 0 && mRecords.other.length === 0 && mRecords.ignored.length === 0
444-
? "hidden"
444+
? "tw-hidden"
445445
: "",
446446
]}
447447
style={{ width: "calc(100vw - 64px)" }}
@@ -481,7 +481,7 @@ function App() {
481481
<CollapseItem
482482
header={`${t("updatepage.header_other_update")}`}
483483
name="list-other"
484-
className={[paramSite ? "" : "hidden"]}
484+
className={[paramSite ? "" : "tw-hidden"]}
485485
disabled={!mRecords?.other?.length || isDoingTask}
486486
extra={
487487
mRecords?.other?.length ? (

src/pages/batchupdate/main.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ loggerCore.logger().debug("batchupdate page start");
2121

2222
const Root = (
2323
<AppProvider>
24-
<MainLayout className="!flex-col !px-4 box-border batchupdate-mainlayout">
24+
<MainLayout className="!tw-flex-col !tw-px-4 tw-box-border batchupdate-mainlayout">
2525
<App />
2626
</MainLayout>
2727
</AppProvider>

src/pages/components/ScriptMenuList/index.tsx

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ const MenuItem = React.memo(({ menuItems, uuid }: MenuItemProps) => {
8989
}}
9090
>
9191
<Button
92-
className="text-left"
92+
className="tw-text-left"
9393
type="secondary"
9494
htmlType="submit"
9595
icon={<IconMenu />}
@@ -219,10 +219,10 @@ const ListMenuItem = React.memo(
219219
name={item.uuid}
220220
contentStyle={{ padding: "0 0 0 40px" }}
221221
>
222-
<div className="flex flex-col">
222+
<div className="tw-flex tw-flex-col">
223223
{isBackscript && (
224224
<Button
225-
className="text-left"
225+
className="tw-text-left"
226226
type="secondary"
227227
icon={item.runStatus !== SCRIPT_RUN_STATUS_RUNNING ? <RiPlayFill /> : <RiStopFill />}
228228
onClick={() => {
@@ -238,7 +238,7 @@ const ListMenuItem = React.memo(
238238
</Button>
239239
)}
240240
<Button
241-
className="text-left"
241+
className="tw-text-left"
242242
type="secondary"
243243
icon={<IconEdit />}
244244
onClick={() => {
@@ -250,7 +250,7 @@ const ListMenuItem = React.memo(
250250
</Button>
251251
{url && isEffective !== null && (
252252
<Button
253-
className="text-left"
253+
className="tw-text-left"
254254
status="warning"
255255
type="secondary"
256256
icon={!isEffective ? <IconPlus /> : <IconMinus />}
@@ -264,21 +264,21 @@ const ListMenuItem = React.memo(
264264
icon={<IconDelete />}
265265
onOk={() => handleDeleteScript(item.uuid)}
266266
>
267-
<Button className="text-left" status="danger" type="secondary" icon={<IconDelete />}>
267+
<Button className="tw-text-left" status="danger" type="secondary" icon={<IconDelete />}>
268268
{t("delete")}
269269
</Button>
270270
</Popconfirm>
271271
</div>
272272
</CollapseItem>
273-
<div className="arco-collapse-item-content-box flex flex-col" style={{ padding: "0 0 0 40px" }}>
273+
<div className="arco-collapse-item-content-box tw-flex tw-flex-col" style={{ padding: "0 0 0 40px" }}>
274274
{/* 依数量与展开状态决定要显示的分组项(收合时只显示前 menuExpandNum 笔) */}
275275
{visibleMenus.map(({ uuid, groupKey, menus }) => {
276276
// 不同脚本之间可能出现相同的 groupKey;为避免 React key 冲突,需加上 uuid 做区分。
277277
return <MenuItem key={`${uuid}:${groupKey}`} menuItems={menus} uuid={uuid} />;
278278
})}
279279
{shouldShowMore && (
280280
<Button
281-
className="text-left"
281+
className="tw-text-left"
282282
key="expand"
283283
type="secondary"
284284
icon={isExpand ? <IconCaretUp /> : <IconCaretDown />}
@@ -289,7 +289,7 @@ const ListMenuItem = React.memo(
289289
)}
290290
{item.hasUserConfig && (
291291
<Button
292-
className="text-left"
292+
className="tw-text-left"
293293
key="config"
294294
type="secondary"
295295
icon={<IconSettings />}

src/pages/components/ScriptResource/index.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -143,8 +143,8 @@ const ScriptResource: React.FC<{
143143
onOk={onOk}
144144
onCancel={onCancel}
145145
>
146-
<Space className="w-full" direction="vertical">
147-
<Space className="!flex justify-end">
146+
<Space className="tw-w-full" direction="vertical">
147+
<Space className="!tw-flex tw-justify-end">
148148
<Popconfirm
149149
focusLock
150150
title={t("confirm_clear_resource")}

src/pages/components/ScriptSetting/Match.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,7 @@ const Match: React.FC<{
248248
}}
249249
/>
250250
</Modal>
251-
<div className="flex flex-row justify-between pb-2">
251+
<div className="tw-flex tw-flex-row tw-justify-between tw-pb-2">
252252
<Typography.Title heading={6}>{t("website_match")}</Typography.Title>
253253
<Space>
254254
<Button
@@ -277,7 +277,7 @@ const Match: React.FC<{
277277
</div>
278278
<Table columns={columns} data={match} rowKey="id" pagination={false} />
279279
<Divider />
280-
<div className="flex flex-row justify-between pb-2">
280+
<div className="tw-flex tw-flex-row tw-justify-between tw-pb-2">
281281
<Typography.Title heading={6}>{t("website_exclude")}</Typography.Title>
282282
<Space>
283283
<Button

src/pages/components/ScriptSetting/Permission.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ const PermissionManager: React.FC<{
130130
}
131131
}}
132132
>
133-
<Space className="w-full" direction="vertical">
133+
<Space className="tw-w-full" direction="vertical">
134134
<Select
135135
value={permissionValue?.permission}
136136
onChange={(e) => {
@@ -156,7 +156,7 @@ const PermissionManager: React.FC<{
156156
</Checkbox>
157157
</Space>
158158
</Modal>
159-
<div className="flex flex-row justify-between pb-2">
159+
<div className="tw-flex tw-flex-row tw-justify-between tw-pb-2">
160160
<Typography.Title heading={6}>{t("permission_management")}</Typography.Title>
161161
<Space>
162162
<Button

src/pages/components/ScriptStorage/index.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -248,8 +248,8 @@ const ScriptStorage: React.FC<{
248248
</Form>
249249
)}
250250
</Modal>
251-
<Space className="w-full" direction="vertical">
252-
<Space className="!flex justify-end">
251+
<Space className="tw-w-full" direction="vertical">
252+
<Space className="!tw-flex tw-justify-end">
253253
{isEdit ? (
254254
<>
255255
<Button

0 commit comments

Comments
 (0)