瀏覽代碼

utility functions

Jason Gorst 1 月之前
父節點
當前提交
9743340a6d
共有 4 個文件被更改,包括 26 次插入0 次删除
  1. 4 0
      app/utils/callAfterDelay.js
  2. 1 0
      app/utils/emptyCharacter.js
  3. 3 0
      app/utils/findUpdated.js
  4. 18 0
      app/utils/ptViewMerge.js

+ 4 - 0
app/utils/callAfterDelay.js

@@ -0,0 +1,4 @@
+export default async function callAfterDelay(callback, delay) {
+  await sleep(delay)
+  await callback()
+}

+ 1 - 0
app/utils/emptyCharacter.js

@@ -0,0 +1 @@
+export default _mapValues(characterFields, "initialValue")

+ 3 - 0
app/utils/findUpdated.js

@@ -0,0 +1,3 @@
+export default function findUpdated(source, target) {
+  return _pickBy(target, (value, key) => !_isEqual(value, source?.[key]))
+}

+ 18 - 0
app/utils/ptViewMerge.js

@@ -0,0 +1,18 @@
+import { twMerge } from "tailwind-merge"
+import { mergeProps } from "vue"
+
+export default function ptViewMerge(
+  globalPTProps = {},
+  selfPTProps = {},
+  datasets
+) {
+  const { class: globalClass, ...globalRest } = globalPTProps
+  const { class: selfClass, ...selfRest } = selfPTProps
+
+  return mergeProps(
+    { class: twMerge(globalClass, selfClass) },
+    globalRest,
+    selfRest,
+    datasets
+  )
+}