cosey 0.3.20 → 0.3.21

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.
@@ -25,7 +25,6 @@ var stdin_default = /* @__PURE__ */defineComponent({
25
25
  hashId
26
26
  } = stdin_default$1(prefixCls);
27
27
  const template = defineTemplate(h => {
28
- console.log(props.data);
29
28
  return h("div", {
30
29
  class: [hashId.value, prefixCls.value]
31
30
  }, props.columns.map(column => {
@@ -1,4 +1,4 @@
1
- import { type ShallowRef, type Ref, MaybeRef } from 'vue';
1
+ import { type ShallowRef, type Ref, type ComputedRef, type MaybeRef } from 'vue';
2
2
  export interface UseUpsertExposeOptions {
3
3
  success?: () => any;
4
4
  }
@@ -38,7 +38,9 @@ export interface UseUpsertReturn<Model extends Record<string, any>, Row extends
38
38
  data: Ref<Data | undefined>;
39
39
  expose: UseUpsertExpose<Row, Data>;
40
40
  row: ShallowRef<Row | undefined>;
41
- type: Ref<UpsertType>;
41
+ type: Readonly<Ref<UpsertType>>;
42
+ isEdit: ComputedRef<boolean>;
43
+ isAdd: ComputedRef<boolean>;
42
44
  }
43
45
  export declare function useUpsert<Model extends Record<string, any>, Row extends Record<string, any> = Model, Data = any>(options: MaybeRef<UseUpsertOptions<Model, Row>>): UseUpsertReturn<Model, Row>;
44
46
  export interface UseExternalUpsertOptions {
@@ -1,6 +1,6 @@
1
1
  import { ElMessage } from 'element-plus';
2
2
  import { cloneDeep, pick } from 'lodash-es';
3
- import { useTemplateRef, onMounted, computed, unref, ref, reactive, shallowRef } from 'vue';
3
+ import { useTemplateRef, onMounted, computed, unref, ref, reactive, shallowRef, readonly } from 'vue';
4
4
  import { toRefs } from '@vueuse/core';
5
5
  import { uuid } from '../utils/string.js';
6
6
  import { useLocale } from './useLocale.js';
@@ -27,6 +27,8 @@ function useUpsert(options) {
27
27
  } = toRefs(computed(() => unref(options)));
28
28
  const { t, lang } = useLocale();
29
29
  const type = ref("add");
30
+ const isEdit = computed(() => type.value === "edit");
31
+ const isAdd = computed(() => type.value === "add");
30
32
  const visible = ref(false);
31
33
  const mergedTitle = computed(() => {
32
34
  return unref(title) || t(mapTypeTitle[type.value]) + (lang.value === "zh-cn" ? "" : " ") + (unref(stuffTitle) || "");
@@ -101,7 +103,9 @@ function useUpsert(options) {
101
103
  data,
102
104
  expose,
103
105
  row,
104
- type
106
+ type: readonly(type),
107
+ isEdit,
108
+ isAdd
105
109
  };
106
110
  return result;
107
111
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cosey",
3
- "version": "0.3.20",
3
+ "version": "0.3.21",
4
4
  "description": "基于 Vue3 + vite 的后台管理系统框架",
5
5
  "type": "module",
6
6
  "main": "index.js",