@arronqzy/abuilder-vue 0.1.0 → 0.1.2

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/README.md CHANGED
@@ -22,7 +22,12 @@ createApp(App).use(Antd).mount("#app");
22
22
  ### 可选配置
23
23
 
24
24
  ```vue
25
- <App class="h-screen" :initial-zoom="1" default-theme="dark" />
25
+ <App
26
+ class="h-screen"
27
+ :initial-zoom="1"
28
+ default-theme="dark"
29
+ locale="zh-CN"
30
+ />
26
31
  ```
27
32
 
28
33
  | Prop | 说明 | 默认 |
@@ -30,15 +35,19 @@ createApp(App).use(Antd).mount("#app");
30
35
  | `class` | 根容器 class | — |
31
36
  | `initialZoom` | 画布初始缩放 | `1` |
32
37
  | `defaultTheme` | `light` / `dark` | `dark` |
38
+ | `locale` | `zh-CN` / `en-US`;省略则按 localStorage → 浏览器 → zh-CN | `null` |
33
39
  | `previewSearch` | 覆盖预览 URL 查询串 | 当前 `location.search` |
34
40
 
41
+ 顶栏「语言」可运行时切换中文 / English(写入 `abuilder.locale`)。Ant Design Vue 的 `ConfigProvider.locale` 会随语言同步。
42
+
35
43
  ### 在线预览 URL
36
44
 
37
- 当 URL 含 `?preview=online&projectId=<id>` 时,自动渲染 `VueViewOnlinePreview`(从 IndexedDB 加载工作区并执行蓝图生命周期)。
45
+ 当 URL 含 `?preview=online&projectId=<id>` 时,自动渲染 `VueViewOnlinePreview`。
38
46
 
39
47
  ## 依赖包
40
48
 
41
- - `@arronqzy/vue-view` — 视图编辑器(画布、工作区、配置侧栏)
49
+ - `@arronqzy/vue-view` — 视图编辑器
50
+ - `@arronqzy/i18n` — 共享中英文本
42
51
  - `ant-design-vue` — UI 组件
43
52
  - `vue` — peer dependency
44
53
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@arronqzy/abuilder-vue",
3
- "version": "0.1.0",
3
+ "version": "0.1.2",
4
4
  "description": "Abuilder Vue 3 可视化编辑器入口包",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -14,7 +14,8 @@
14
14
  "dependencies": {
15
15
  "ant-design-vue": "^4.2.6",
16
16
  "vue": "^3.5.13",
17
- "@arronqzy/vue-view": "0.1.0"
17
+ "@arronqzy/i18n": "0.1.2",
18
+ "@arronqzy/vue-view": "0.1.3"
18
19
  },
19
20
  "peerDependencies": {
20
21
  "vue": "^3.4.0"
@@ -24,8 +25,8 @@
24
25
  "eslint": "^8.57.0",
25
26
  "typescript": "^5.5.4",
26
27
  "vue-tsc": "^2.2.0",
27
- "@arronqzy/typescript-config": "1.0.0",
28
- "@arronqzy/eslint-config": "0.0.0"
28
+ "@arronqzy/eslint-config": "0.0.0",
29
+ "@arronqzy/typescript-config": "1.0.0"
29
30
  },
30
31
  "publishConfig": {
31
32
  "access": "public"
package/src/App.vue CHANGED
@@ -1,18 +1,32 @@
1
1
  <script setup lang="ts">
2
- import { computed } from "vue";
2
+ import { computed, watch } from "vue";
3
3
  import { ConfigProvider, theme } from "ant-design-vue";
4
+ import zhCN from "ant-design-vue/es/locale/zh_CN";
5
+ import enUS from "ant-design-vue/es/locale/en_US";
4
6
  import {
5
7
  VueViewPanel,
6
8
  VueViewOnlinePreview,
7
9
  parseOnlinePreviewSearchParams,
8
10
  } from "@arronqzy/vue-view";
11
+ import { provideI18n } from "@arronqzy/i18n/vue";
12
+ import { isLocale } from "@arronqzy/i18n";
9
13
  import type { AbuilderVueAppProps } from "./types";
10
14
 
11
15
  const props = withDefaults(defineProps<AbuilderVueAppProps>(), {
12
16
  initialZoom: 1,
13
17
  defaultTheme: "dark",
18
+ locale: null,
14
19
  });
15
20
 
21
+ const i18n = provideI18n({ locale: props.locale });
22
+
23
+ watch(
24
+ () => props.locale,
25
+ (next) => {
26
+ if (isLocale(next)) i18n.setLocale(next);
27
+ }
28
+ );
29
+
16
30
  const search =
17
31
  props.previewSearch ??
18
32
  (typeof window !== "undefined" ? window.location.search : "");
@@ -20,10 +34,15 @@ const search =
20
34
  const previewParams = computed(() => parseOnlinePreviewSearchParams(search));
21
35
 
22
36
  const isDark = computed(() => props.defaultTheme === "dark");
37
+
38
+ const antdLocale = computed(() =>
39
+ i18n.locale.value === "en-US" ? enUS : zhCN
40
+ );
23
41
  </script>
24
42
 
25
43
  <template>
26
44
  <ConfigProvider
45
+ :locale="antdLocale"
27
46
  :theme="{
28
47
  algorithm: isDark ? theme.darkAlgorithm : theme.defaultAlgorithm,
29
48
  }"
package/src/index.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  export { default as App } from "./App.vue";
2
2
  export type { AbuilderVueAppProps } from "./types";
3
+ export type { Locale } from "@arronqzy/i18n";
3
4
 
4
5
  export {
5
6
  VueViewPanel,
package/src/types.ts CHANGED
@@ -3,4 +3,7 @@ export type AbuilderVueAppProps = {
3
3
  initialZoom?: number;
4
4
  defaultTheme?: "dark" | "light";
5
5
  previewSearch?: string;
6
+ /** 界面语言。省略时按 localStorage → 浏览器语言 → zh-CN 解析。 */
7
+ locale?: "zh-CN" | "en-US" | null;
6
8
  };
9
+