@yl_lowcode/docs-theme 0.0.8 → 0.0.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/color/index.ts +1 -1
- package/demo.vue +2 -1
- package/drop-down.vue +3 -3
- package/editor.ts +1 -0
- package/index.ts +5 -0
- package/layout.vue +20 -6
- package/package.json +4 -2
- package/playground.vue +1 -3
- package/sucrase.ts +2 -0
package/color/index.ts
CHANGED
|
@@ -22,8 +22,8 @@ export default (
|
|
|
22
22
|
theme: "dark" | "light",
|
|
23
23
|
color: "red" | "pink" | "blue" | "green" | "orange" | "purple" = "blue"
|
|
24
24
|
) => {
|
|
25
|
-
console.log(theme, color);
|
|
26
25
|
const themeColor = themeColors[color];
|
|
26
|
+
document.documentElement.style.setProperty("--soui-brand-6", themeColor['Brand-6']);
|
|
27
27
|
(window as any).Shineout?.setToken?.({
|
|
28
28
|
selector: "html",
|
|
29
29
|
token: {
|
package/demo.vue
CHANGED
package/drop-down.vue
CHANGED
|
@@ -128,10 +128,10 @@ onUnmounted(() => document.removeEventListener("click", handleClickOutside));
|
|
|
128
128
|
top: calc(100% + 8px); /* 距离触发器下方 8px */
|
|
129
129
|
right: -20px;
|
|
130
130
|
/* 如果需要居右对齐,把 left:0 改为 right:0 */
|
|
131
|
-
background-color: var(--
|
|
131
|
+
background-color: var(--vp-c-bg);
|
|
132
132
|
border-radius: 8px;
|
|
133
133
|
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
|
|
134
|
-
border: 1px solid var(--
|
|
134
|
+
border: 1px solid var(--vp-c-gutter);
|
|
135
135
|
padding: 6px 0;
|
|
136
136
|
z-index: 2000;
|
|
137
137
|
overflow: hidden;
|
|
@@ -156,7 +156,7 @@ onUnmounted(() => document.removeEventListener("click", handleClickOutside));
|
|
|
156
156
|
}
|
|
157
157
|
|
|
158
158
|
.menu-item:hover {
|
|
159
|
-
background-color: var(--
|
|
159
|
+
background-color: var(--vp-c-bg-soft); /* 浅灰色 hover 背景 */
|
|
160
160
|
}
|
|
161
161
|
|
|
162
162
|
/* Label 样式 */
|
package/editor.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "@yl_lowcode/editor";
|
package/index.ts
CHANGED
|
@@ -4,6 +4,11 @@ import Layout from "./layout.vue";
|
|
|
4
4
|
import Demo from "./demo.vue";
|
|
5
5
|
import "./theme.css";
|
|
6
6
|
|
|
7
|
+
export interface ThemeHooks {
|
|
8
|
+
/** 主题或颜色变更时触发(dark/light 切换、颜色切换都会调用) */
|
|
9
|
+
onThemeChange?: (info: { theme: "dark" | "light"; color: string }) => void;
|
|
10
|
+
}
|
|
11
|
+
|
|
7
12
|
export default {
|
|
8
13
|
extends: DefaultTheme,
|
|
9
14
|
Layout,
|
package/layout.vue
CHANGED
|
@@ -4,10 +4,13 @@ import { useData } from "vitepress";
|
|
|
4
4
|
import DefaultTheme from "vitepress/theme";
|
|
5
5
|
import Playground from "./playground.vue";
|
|
6
6
|
import setTheme from "./color";
|
|
7
|
-
import { watch, nextTick, provide, onMounted } from "vue";
|
|
7
|
+
import { watch, nextTick, provide, inject, onMounted } from "vue";
|
|
8
|
+
import type { ThemeHooks } from "./index";
|
|
8
9
|
// @ts-ignore
|
|
9
10
|
import NiceDropdown from "./drop-down.vue";
|
|
10
11
|
|
|
12
|
+
const themeHooks = inject<ThemeHooks>("theme-hooks", {});
|
|
13
|
+
|
|
11
14
|
const colorConfig = [
|
|
12
15
|
{
|
|
13
16
|
key: "blue",
|
|
@@ -45,6 +48,10 @@ const colorConfig = [
|
|
|
45
48
|
onClick: async () => {
|
|
46
49
|
localStorage?.setItem("color", item.key);
|
|
47
50
|
setTheme(isDark.value ? "dark" : "light", item.key);
|
|
51
|
+
themeHooks.onThemeChange?.({
|
|
52
|
+
theme: isDark.value ? "dark" : "light",
|
|
53
|
+
color: item.key,
|
|
54
|
+
});
|
|
48
55
|
},
|
|
49
56
|
};
|
|
50
57
|
});
|
|
@@ -87,13 +94,20 @@ provide("toggle-appearance", async ({ clientX: x, clientY: y }: MouseEvent) => {
|
|
|
87
94
|
|
|
88
95
|
onMounted(() => {
|
|
89
96
|
watch(isDark, async (dark) => {
|
|
90
|
-
|
|
97
|
+
const color = localStorage?.getItem("color") as any;
|
|
98
|
+
setTheme(dark ? "dark" : "light", color);
|
|
99
|
+
themeHooks.onThemeChange?.({
|
|
100
|
+
theme: dark ? "dark" : "light",
|
|
101
|
+
color: color || "blue",
|
|
102
|
+
});
|
|
91
103
|
});
|
|
92
104
|
setTimeout(async () => {
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
105
|
+
const color = localStorage?.getItem("color") as any;
|
|
106
|
+
setTheme(isDark.value ? "dark" : "light", color);
|
|
107
|
+
themeHooks.onThemeChange?.({
|
|
108
|
+
theme: isDark.value ? "dark" : "light",
|
|
109
|
+
color: color || "blue",
|
|
110
|
+
});
|
|
97
111
|
}, 800);
|
|
98
112
|
});
|
|
99
113
|
</script>
|
package/package.json
CHANGED
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@yl_lowcode/docs-theme",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.10",
|
|
4
4
|
"description": "共享 VitePress 文档主题(React Demo 支持)",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "index.ts",
|
|
7
7
|
"exports": {
|
|
8
8
|
".": "./index.ts",
|
|
9
|
-
"./plugins/shiki-raw": "./plugins/shiki-raw.js"
|
|
9
|
+
"./plugins/shiki-raw": "./plugins/shiki-raw.js",
|
|
10
|
+
"./sucrase": "./sucrase.ts",
|
|
11
|
+
"./editor": "./editor.ts"
|
|
10
12
|
},
|
|
11
13
|
"dependencies": {
|
|
12
14
|
"sucrase": "3.35.1",
|
package/playground.vue
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
import React from "react";
|
|
4
4
|
import * as ReactDOMClient from "react-dom/client";
|
|
5
5
|
import { ref, inject, onMounted, onBeforeUnmount } from "vue";
|
|
6
|
+
import { Monaco as MonacoEditor } from "./editor";
|
|
6
7
|
/**
|
|
7
8
|
* 通用 Playground 组件
|
|
8
9
|
*
|
|
@@ -129,9 +130,6 @@ onMounted(async () => {
|
|
|
129
130
|
setError(err);
|
|
130
131
|
}, []);
|
|
131
132
|
|
|
132
|
-
// 动态获取 Monaco 组件(从 moduleMap 中取)
|
|
133
|
-
const MonacoEditor = userModules["@yl_lowcode/editor"]?.Monaco;
|
|
134
|
-
|
|
135
133
|
return React.createElement(
|
|
136
134
|
"div",
|
|
137
135
|
{ style: { display: "flex", height: "100vh", overflow: "hidden" } },
|
package/sucrase.ts
ADDED