cosey 0.1.1-4 → 0.1.1-5

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.
@@ -2,6 +2,7 @@ import { defineComponent, defineAsyncComponent, h } from 'vue';
2
2
  import { withInstall } from '../utils.js';
3
3
  export { defaultEditorProps } from './editor.js';
4
4
  import { useMounted } from '../../hooks/useMounted.js';
5
+ import { isClient } from '../../utils/env.js';
5
6
 
6
7
  const Editor = defineComponent({
7
8
  name: "Editor",
@@ -9,14 +10,14 @@ const Editor = defineComponent({
9
10
  const AsyncComponent = defineAsyncComponent(() => import('./editor.vue.js'));
10
11
  const isMounted = useMounted();
11
12
  return () => {
12
- if (import.meta.env.SSR) {
13
+ if (!isClient()) {
13
14
  return isMounted.value && h(AsyncComponent, props, slots);
14
15
  }
15
16
  return h(AsyncComponent, props, slots);
16
17
  };
17
18
  }
18
19
  });
19
- if (!import.meta.env.SSR) {
20
+ if (isClient()) {
20
21
  import('./editor.vue.js');
21
22
  }
22
23
  const _Editor = withInstall(Editor);
@@ -4,6 +4,7 @@ import { useToken } from './util/useToken.js';
4
4
  import { tokenValueToCssVar } from './util/tokenValueToCssVar.js';
5
5
  import { useConfig } from '../config-provider/config-provider.js';
6
6
  import { useMounted } from '../../hooks/useMounted.js';
7
+ import { isClient } from '../../utils/env.js';
7
8
 
8
9
  let oldGlobalClass = /* @__PURE__ */ new Set();
9
10
  function getGlobalStyleHook(component, styleFn) {
@@ -29,7 +30,7 @@ function getGlobalStyleHook(component, styleFn) {
29
30
  watch(
30
31
  [hashId, isMounted],
31
32
  () => {
32
- if (!import.meta.env.SSR || isMounted.value) {
33
+ if (isClient() || isMounted.value) {
33
34
  document.documentElement.classList.remove(...oldGlobalClass);
34
35
  if (hashId.value) {
35
36
  document.documentElement.classList.add(hashId.value);
@@ -7,7 +7,7 @@ const viteHMR = ref(false);
7
7
  function useDevHMR() {
8
8
  return viteHMR;
9
9
  }
10
- var stdin_default = import.meta.env.PROD ? useProdHMR : useDevHMR;
10
+ var stdin_default = import.meta.env && import.meta.env.DEV ? useDevHMR : useProdHMR;
11
11
  if (import.meta.hot) {
12
12
  import.meta.hot.on("vite:beforeUpdate", () => {
13
13
  viteHMR.value = true;
package/config/http.js CHANGED
@@ -2,7 +2,7 @@ const defaultHttpConfig = {
2
2
  /**
3
3
  * 基础url
4
4
  */
5
- baseURL: import.meta.env.VITE_BASE_URL,
5
+ baseURL: "",
6
6
  /**
7
7
  * 请求超时时间,单位ms
8
8
  */
package/config/index.js CHANGED
@@ -25,7 +25,6 @@ function provideGlobalConfig(app, options) {
25
25
  slots = {}
26
26
  } = options;
27
27
  const persistConfig = defaultsDeep(persist, defaultPersistConfig);
28
- console.log("app.provide");
29
28
  app.provide(globalConfigContextKey, {
30
29
  persist: createPersist(persistConfig.name, persistConfig.type),
31
30
  router: defaultsDeep(
package/config/site.js CHANGED
@@ -2,15 +2,15 @@ const defaultSiteConfig = {
2
2
  /**
3
3
  * 网站名称,展示在顶部导航、登录页等位置
4
4
  */
5
- name: import.meta.env.VITE_APP_TITLE,
5
+ name: "",
6
6
  /**
7
7
  * 网站logo,展示在浏览器标签页、顶部导航、登录页等位置
8
8
  */
9
- logo: import.meta.env.VITE_APP_LOGO,
9
+ logo: "",
10
10
  /**
11
11
  * 网站描述,用于meta描述、登录页描述等位置
12
12
  */
13
- description: import.meta.env.VITE_APP_DESCRIPTION
13
+ description: ""
14
14
  };
15
15
 
16
16
  export { defaultSiteConfig };
@@ -1,5 +1,6 @@
1
1
  import { inject, ref, computed, onMounted, onBeforeUnmount, watch, provide } from 'vue';
2
2
  import { usePersist } from './usePersist.js';
3
+ import { isClient } from '../utils/env.js';
3
4
 
4
5
  const colorSchemeContextSymbol = Symbol("colorScheme");
5
6
  const colorSchemeKey = "colorScheme";
@@ -48,7 +49,7 @@ function useColorSchemeProvide() {
48
49
  watch(
49
50
  appliedColorScheme,
50
51
  () => {
51
- if (!import.meta.env.SSR) {
52
+ if (isClient()) {
52
53
  if (appliedColorScheme.value === "dark") {
53
54
  document.documentElement.classList.add("dark");
54
55
  } else {
package/layout/utils.js CHANGED
@@ -5,9 +5,7 @@ import { useOptionalComponent } from '../hooks/useOptionalComponent.js';
5
5
  function mergedLayout(name, defaultComponent) {
6
6
  return defineComponent({
7
7
  setup(props, { slots }) {
8
- const globalConfig = useGlobalConfig();
9
8
  const { components } = useGlobalConfig();
10
- console.log(globalConfig, components, name);
11
9
  const component = useOptionalComponent(
12
10
  components?.[name],
13
11
  defaultComponent
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cosey",
3
- "version": "0.1.1-4",
3
+ "version": "0.1.1-5",
4
4
  "description": "cosey核心包,提供路由、认证授权流程、布局、http请求等功能",
5
5
  "type": "module",
6
6
  "main": "index.js",
@@ -1,3 +1,5 @@
1
+ import { isClient } from './env.js';
2
+
1
3
  function insertCSS(styleStr, styleId) {
2
4
  const style = document.createElement("style");
3
5
  style.innerHTML = styleStr;
@@ -11,7 +13,7 @@ function findCSSNode(styleId) {
11
13
  return document.querySelector(`[data-id="${styleId}"]`);
12
14
  }
13
15
  function updateCSS(styleStr, styleId) {
14
- if (!import.meta.env.SSR) {
16
+ if (isClient()) {
15
17
  const style = findCSSNode(styleId);
16
18
  if (style) {
17
19
  style.innerHTML = styleStr;
package/utils/env.js ADDED
@@ -0,0 +1,5 @@
1
+ function isClient() {
2
+ return typeof window !== "undefined";
3
+ }
4
+
5
+ export { isClient };
package/utils/index.js CHANGED
@@ -17,6 +17,7 @@ export { findCSSNode, insertCSS, removeCSS, updateCSS } from './dynamicCSS.js';
17
17
  export { sleep } from './sleep.js';
18
18
  export { arrayToTree, extraTreeToTable, mapTree, mapTreeExtra, walkAncestor, walkTree, walkTreeNode } from './tree.js';
19
19
  export { warningConfirm } from './message-box.js';
20
+ export { isClient } from './env.js';
20
21
  import * as echarts from 'echarts/core';
21
22
  export { echarts };
22
23
  export { bookFormats } from './excel/bookFormats.js';