refactor: cssinjs
parent
c0d7d041b4
commit
b2841a27ae
|
@ -15,8 +15,8 @@ export default function useClientCache<CacheType>(
|
|||
const fullPath = computed(() => [prefix, ...keyPath.value]);
|
||||
const fullPathStr = eagerComputed(() => fullPath.value.join('_'));
|
||||
const HMRUpdate = useHMR();
|
||||
const clearCache = () => {
|
||||
styleContext.cache.update(fullPath.value, prevCache => {
|
||||
const clearCache = (paths: typeof fullPath.value) => {
|
||||
styleContext.cache.update(paths, prevCache => {
|
||||
const [times = 0, cache] = prevCache || [];
|
||||
const nextCount = times - 1;
|
||||
|
||||
|
@ -28,11 +28,16 @@ export default function useClientCache<CacheType>(
|
|||
return [times - 1, cache];
|
||||
});
|
||||
};
|
||||
watch(
|
||||
() => fullPath.value.slice(),
|
||||
(_, oldValue) => {
|
||||
clearCache(oldValue);
|
||||
},
|
||||
);
|
||||
// Create cache
|
||||
watch(
|
||||
fullPathStr,
|
||||
() => {
|
||||
clearCache();
|
||||
styleContext.cache.update(fullPath.value, prevCache => {
|
||||
const [times = 0, cache] = prevCache || [];
|
||||
|
||||
|
@ -50,9 +55,8 @@ export default function useClientCache<CacheType>(
|
|||
},
|
||||
{ immediate: true },
|
||||
);
|
||||
|
||||
onBeforeUnmount(() => {
|
||||
clearCache();
|
||||
clearCache(fullPath.value);
|
||||
});
|
||||
const val = computed(() => styleContext.cache.get(fullPath.value)![1]);
|
||||
return val;
|
||||
|
|
|
@ -15,10 +15,12 @@ export default process.env.NODE_ENV === 'production' ? useProdHMR : useDevHMR;
|
|||
// We have to hack handler to force mark as HRM
|
||||
if (
|
||||
process.env.NODE_ENV !== 'production' &&
|
||||
typeof module !== 'undefined' &&
|
||||
module &&
|
||||
// @ts-ignore
|
||||
module.hot
|
||||
((typeof module !== 'undefined' &&
|
||||
module &&
|
||||
// @ts-ignore
|
||||
module.hot) ||
|
||||
// @ts-ignore
|
||||
import.meta.hot)
|
||||
) {
|
||||
const win = window as any;
|
||||
|
||||
|
@ -34,12 +36,6 @@ if (
|
|||
};
|
||||
// @ts-ignore
|
||||
} else if (import.meta.hot) {
|
||||
// @ts-ignore
|
||||
import.meta.hot.accept(() => {
|
||||
viteHMR = true;
|
||||
setTimeout(() => {
|
||||
viteHMR = false;
|
||||
}, 0);
|
||||
});
|
||||
viteHMR = true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
import canUseDom from '../../_util/canUseDom';
|
||||
import contains from './contains';
|
||||
|
||||
const APPEND_ORDER = 'data-rc-order';
|
||||
const MARK_KEY = `rc-util-key`;
|
||||
const APPEND_ORDER = 'data-vc-order';
|
||||
const MARK_KEY = `vc-util-key`;
|
||||
|
||||
const containerCache = new Map<ContainerType, Node & ParentNode>();
|
||||
|
||||
|
|
|
@ -1,48 +1,3 @@
|
|||
<template>
|
||||
<div>
|
||||
<a-menu
|
||||
v-model:selected-keys="selectedKeys"
|
||||
:open-keys="openKeys"
|
||||
style="width: 256px"
|
||||
mode="inline"
|
||||
>
|
||||
<a-sub-menu key="sub1">
|
||||
<template #icon>
|
||||
<MailOutlined />
|
||||
</template>
|
||||
<template #title>Navigation One</template>
|
||||
<a-menu-item key="3">Option 3</a-menu-item>
|
||||
<a-menu-item key="4">Option 4</a-menu-item>
|
||||
</a-sub-menu>
|
||||
</a-menu>
|
||||
<a-button @click="open">展开</a-button>
|
||||
</div>
|
||||
<a-alert message="Success Text" prefix-cls="tes" type="success" />
|
||||
</template>
|
||||
<script>
|
||||
import { defineComponent, ref, watchEffect } from 'vue';
|
||||
import { MailOutlined } from '@ant-design/icons-vue';
|
||||
export default defineComponent({
|
||||
components: {
|
||||
MailOutlined,
|
||||
},
|
||||
setup() {
|
||||
const selectedKeys = ref(['1']);
|
||||
const openKeys = ref([]);
|
||||
const open = () => {
|
||||
openKeys.value.push('sub1');
|
||||
// openKeys.value = [...openKeys.value, 'sub1'];
|
||||
};
|
||||
const test = ref([1]);
|
||||
watchEffect(() => {
|
||||
console.log(111, test.value);
|
||||
});
|
||||
window.openKeys = openKeys;
|
||||
window.test = test;
|
||||
return {
|
||||
selectedKeys,
|
||||
openKeys,
|
||||
open,
|
||||
};
|
||||
},
|
||||
});
|
||||
</script>
|
||||
|
|
Loading…
Reference in New Issue