refactor(client): specify global scope

This commit is contained in:
syuilo 2022-01-16 10:14:14 +09:00
parent b312846ff6
commit 8322c90834
30 changed files with 75 additions and 75 deletions

View File

@ -90,7 +90,7 @@ onMounted(() => {
const update = () => {
if (enabled.value) {
tick();
setTimeout(update, 1000);
window.setTimeout(update, 1000);
}
};
update();

View File

@ -90,7 +90,7 @@ function requestRender() {
'error-callback': callback,
});
} else {
setTimeout(requestRender, 1);
window.setTimeout(requestRender, 1);
}
}

View File

@ -167,7 +167,7 @@ export default defineComponent({
//
// 0
const clock = setInterval(() => {
const clock = window.setInterval(() => {
if (prefixEl.value) {
if (prefixEl.value.offsetWidth) {
inputEl.value.style.paddingLeft = prefixEl.value.offsetWidth + 'px';
@ -181,7 +181,7 @@ export default defineComponent({
}, 100);
onUnmounted(() => {
clearInterval(clock);
window.clearInterval(clock);
});
});
});

View File

@ -117,7 +117,7 @@ export default defineComponent({
//
// 0
const clock = setInterval(() => {
const clock = window.setInterval(() => {
if (prefixEl.value) {
if (prefixEl.value.offsetWidth) {
inputEl.value.style.paddingLeft = prefixEl.value.offsetWidth + 'px';
@ -131,7 +131,7 @@ export default defineComponent({
}, 100);
onUnmounted(() => {
clearInterval(clock);
window.clearInterval(clock);
});
});
});

View File

@ -45,7 +45,7 @@ export default defineComponent({
calc();
const observer = new MutationObserver(() => {
setTimeout(() => {
window.setTimeout(() => {
calc();
}, 100);
});

View File

@ -63,10 +63,10 @@ export default defineComponent({
this.draw();
// VueWatch
this.clock = setInterval(this.draw, 1000);
this.clock = window.setInterval(this.draw, 1000);
},
beforeUnmount() {
clearInterval(this.clock);
window.clearInterval(this.clock);
},
methods: {
draw() {

View File

@ -29,7 +29,7 @@ export default defineComponent({
};
},
mounted() {
setTimeout(() => {
window.setTimeout(() => {
this.showing = false;
}, 6000);
}

View File

@ -94,7 +94,7 @@ export default defineComponent({
}
onMounted(() => {
setTimeout(() => {
window.setTimeout(() => {
context.emit('end');
}, 1100);
});

View File

@ -26,7 +26,7 @@ const showing = ref(true);
const zIndex = os.claimZIndex('high');
onMounted(() => {
setTimeout(() => {
window.setTimeout(() => {
showing.value = false;
}, 4000);
});

View File

@ -117,14 +117,14 @@ export default defineComponent({
const scale = calcCircleScale(e.target.clientWidth, e.target.clientHeight, circleCenterX, circleCenterY);
setTimeout(() => {
window.setTimeout(() => {
ripple.style.transform = 'scale(' + (scale / 2) + ')';
}, 1);
setTimeout(() => {
window.setTimeout(() => {
ripple.style.transition = 'all 1s ease';
ripple.style.opacity = '0';
}, 1000);
setTimeout(() => {
window.setTimeout(() => {
if (this.$refs.ripples) this.$refs.ripples.removeChild(ripple);
}, 2000);
}

View File

@ -211,7 +211,7 @@ export default defineComponent({
contentClicking = true;
window.addEventListener('mouseup', e => {
// click mouseup
setTimeout(() => {
window.setTimeout(() => {
contentClicking = false;
}, 100);
}, { passive: true, once: true });

View File

@ -10,7 +10,7 @@ export default {
},
mounted(src, binding, vn) {
setTimeout(() => {
window.setTimeout(() => {
src.style.opacity = '1';
src.style.transform = 'none';
}, 1);

View File

@ -21,7 +21,7 @@ export default {
self.close = () => {
if (self._close) {
clearInterval(self.checkTimer);
window.clearInterval(self.checkTimer);
self._close();
self._close = null;
}
@ -61,19 +61,19 @@ export default {
});
el.addEventListener(start, () => {
clearTimeout(self.showTimer);
clearTimeout(self.hideTimer);
self.showTimer = setTimeout(self.show, delay);
window.clearTimeout(self.showTimer);
window.clearTimeout(self.hideTimer);
self.showTimer = window.setTimeout(self.show, delay);
}, { passive: true });
el.addEventListener(end, () => {
clearTimeout(self.showTimer);
clearTimeout(self.hideTimer);
self.hideTimer = setTimeout(self.close, delay);
window.clearTimeout(self.showTimer);
window.clearTimeout(self.hideTimer);
self.hideTimer = window.setTimeout(self.close, delay);
}, { passive: true });
el.addEventListener('click', () => {
clearTimeout(self.showTimer);
window.clearTimeout(self.showTimer);
self.close();
});
},
@ -85,6 +85,6 @@ export default {
unmounted(el, binding, vn) {
const self = el._tooltipDirective_;
clearInterval(self.checkTimer);
window.clearInterval(self.checkTimer);
},
} as Directive;

View File

@ -30,11 +30,11 @@ export class UserPreview {
source: this.el
}, {
mouseover: () => {
clearTimeout(this.hideTimer);
window.clearTimeout(this.hideTimer);
},
mouseleave: () => {
clearTimeout(this.showTimer);
this.hideTimer = setTimeout(this.close, 500);
window.clearTimeout(this.showTimer);
this.hideTimer = window.setTimeout(this.close, 500);
},
}, 'closed');
@ -44,10 +44,10 @@ export class UserPreview {
}
};
this.checkTimer = setInterval(() => {
this.checkTimer = window.setInterval(() => {
if (!document.body.contains(this.el)) {
clearTimeout(this.showTimer);
clearTimeout(this.hideTimer);
window.clearTimeout(this.showTimer);
window.clearTimeout(this.hideTimer);
this.close();
}
}, 1000);
@ -56,7 +56,7 @@ export class UserPreview {
@autobind
private close() {
if (this.promise) {
clearInterval(this.checkTimer);
window.clearInterval(this.checkTimer);
this.promise.cancel();
this.promise = null;
}
@ -64,21 +64,21 @@ export class UserPreview {
@autobind
private onMouseover() {
clearTimeout(this.showTimer);
clearTimeout(this.hideTimer);
this.showTimer = setTimeout(this.show, 500);
window.clearTimeout(this.showTimer);
window.clearTimeout(this.hideTimer);
this.showTimer = window.setTimeout(this.show, 500);
}
@autobind
private onMouseleave() {
clearTimeout(this.showTimer);
clearTimeout(this.hideTimer);
this.hideTimer = setTimeout(this.close, 500);
window.clearTimeout(this.showTimer);
window.clearTimeout(this.hideTimer);
this.hideTimer = window.setTimeout(this.close, 500);
}
@autobind
private onClick() {
clearTimeout(this.showTimer);
window.clearTimeout(this.showTimer);
this.close();
}
@ -94,7 +94,7 @@ export class UserPreview {
this.el.removeEventListener('mouseover', this.onMouseover);
this.el.removeEventListener('mouseleave', this.onMouseleave);
this.el.removeEventListener('click', this.onClick);
clearInterval(this.checkTimer);
window.clearInterval(this.checkTimer);
}
}

View File

@ -83,7 +83,7 @@ export function promiseDialog<T extends Promise<any>>(
onSuccess(res);
} else {
success.value = true;
setTimeout(() => {
window.setTimeout(() => {
showing.value = false;
}, 1000);
}
@ -139,7 +139,7 @@ export async function popup(component: Component | typeof import('*.vue') | Prom
const id = ++popupIdCount;
const dispose = () => {
// このsetTimeoutが無いと挙動がおかしくなる(autocompleteが閉じなくなる)。Vueのバグ
setTimeout(() => {
window.setTimeout(() => {
popups.value = popups.value.filter(popup => popup.id !== id);
}, 0);
};
@ -329,7 +329,7 @@ export function select(props: {
export function success() {
return new Promise((resolve, reject) => {
const showing = ref(true);
setTimeout(() => {
window.setTimeout(() => {
showing.value = false;
}, 1000);
popup(import('@/components/waiting-dialog.vue'), {

View File

@ -162,7 +162,7 @@ const Component = defineComponent({
// fetch
// false
// scrollendsetTimeout
setTimeout(() => this.fetching = false, 300);
window.setTimeout(() => this.fetching = false, 300);
});
},
@ -300,9 +300,9 @@ const Component = defineComponent({
this.showIndicator = false;
});
if (this.timer) clearTimeout(this.timer);
if (this.timer) window.clearTimeout(this.timer);
this.timer = setTimeout(() => {
this.timer = window.setTimeout(() => {
this.showIndicator = false;
}, 4000);
},

View File

@ -169,7 +169,7 @@ export default defineComponent({
window.close();
// 100ms
setTimeout(() => {
window.setTimeout(() => {
this.$router.push('/');
}, 100);
}

View File

@ -54,7 +54,7 @@ export class Storage<T extends StateDef> {
if ($i) {
// なぜかsetTimeoutしないとapi関数内でエラーになる(おそらく循環参照してることに原因がありそう)
setTimeout(() => {
window.setTimeout(() => {
api('i/registry/get-all', { scope: ['client', this.key] }).then(kvs => {
const cache = {};
for (const [k, v] of Object.entries(def)) {

View File

@ -115,11 +115,11 @@ export const router = createRouter({
window._scroll = () => { // さらにHacky
if (to.name === 'index') {
window.scroll({ top: indexScrollPos, behavior: 'instant' });
const i = setInterval(() => {
const i = window.setInterval(() => {
window.scroll({ top: indexScrollPos, behavior: 'instant' });
}, 10);
setTimeout(() => {
clearInterval(i);
window.setTimeout(() => {
window.clearInterval(i);
}, 500);
} else {
window.scroll({ top: 0, behavior: 'instant' });

View File

@ -136,7 +136,7 @@ export function physics(container: HTMLElement) {
}
// 奈落に落ちたオブジェクトは消す
const intervalId = setInterval(() => {
const intervalId = window.setInterval(() => {
for (const obj of objs) {
if (obj.position.y > (containerHeight + 1024)) Matter.World.remove(world, obj);
}
@ -146,7 +146,7 @@ export function physics(container: HTMLElement) {
stop: () => {
stop = true;
Matter.Runner.stop(runner);
clearInterval(intervalId);
window.clearInterval(intervalId);
}
};
}

View File

@ -34,11 +34,11 @@ export const builtinThemes = [
let timeout = null;
export function applyTheme(theme: Theme, persist = true) {
if (timeout) clearTimeout(timeout);
if (timeout) window.clearTimeout(timeout);
document.documentElement.classList.add('_themeChanging_');
timeout = setTimeout(() => {
timeout = window.setTimeout(() => {
document.documentElement.classList.remove('_themeChanging_');
}, 1000);

View File

@ -224,7 +224,7 @@ export default defineComponent({
// ChromeDragstartDOM(=)Drag
// SEE: https://stackoverflow.com/questions/19639969/html5-dragend-event-firing-immediately
setTimeout(() => {
window.setTimeout(() => {
this.dragging = true;
}, 10);
},

View File

@ -104,9 +104,9 @@ const tick = () => {
tick();
const intervalId = setInterval(tick, 1000);
const intervalId = window.setInterval(tick, 1000);
onUnmounted(() => {
clearInterval(intervalId);
window.clearInterval(intervalId);
});
defineExpose<WidgetComponentExpose>({

View File

@ -67,12 +67,12 @@ const tick = () => {
tick();
watch(() => widgetProps.showMs, () => {
if (intervalId) clearInterval(intervalId);
intervalId = setInterval(tick, widgetProps.showMs ? 10 : 1000);
if (intervalId) window.clearInterval(intervalId);
intervalId = window.setInterval(tick, widgetProps.showMs ? 10 : 1000);
}, { immediate: true });
onUnmounted(() => {
clearInterval(intervalId);
window.clearInterval(intervalId);
});
defineExpose<WidgetComponentExpose>({

View File

@ -66,9 +66,9 @@ const fetch = async () => {
onMounted(() => {
fetch();
const intervalId = setInterval(fetch, 1000 * 60);
const intervalId = window.setInterval(fetch, 1000 * 60);
onUnmounted(() => {
clearInterval(intervalId);
window.clearInterval(intervalId);
});
});

View File

@ -51,8 +51,8 @@ const saveMemo = () => {
const onChange = () => {
changed.value = true;
clearTimeout(timeoutId);
timeoutId = setTimeout(saveMemo, 1000);
window.clearTimeout(timeoutId);
timeoutId = window.setTimeout(saveMemo, 1000);
};
watch(() => defaultStore.reactiveState.memo, newText => {

View File

@ -45,9 +45,9 @@ const tick = () => {
onMounted(() => {
tick();
const intervalId = setInterval(tick, 1000 * 15);
const intervalId = window.setInterval(tick, 1000 * 15);
onUnmounted(() => {
clearInterval(intervalId);
window.clearInterval(intervalId);
});
});

View File

@ -62,9 +62,9 @@ watch(() => widgetProps.url, tick);
onMounted(() => {
tick();
const intervalId = setInterval(tick, 60000);
const intervalId = window.setInterval(tick, 60000);
onUnmounted(() => {
clearInterval(intervalId);
window.clearInterval(intervalId);
});
});

View File

@ -59,7 +59,7 @@ const change = () => {
slideB.value.style.backgroundImage = img;
slideB.value.classList.add('anime');
setTimeout(() => {
window.setTimeout(() => {
// unmount
if (slideA.value == null) return;
@ -101,9 +101,9 @@ onMounted(() => {
fetch();
}
const intervalId = setInterval(change, 10000);
const intervalId = window.setInterval(change, 10000);
onUnmounted(() => {
clearInterval(intervalId);
window.clearInterval(intervalId);
});
});

View File

@ -60,9 +60,9 @@ const fetch = () => {
onMounted(() => {
fetch();
const intervalId = setInterval(fetch, 1000 * 60);
const intervalId = window.setInterval(fetch, 1000 * 60);
onUnmounted(() => {
clearInterval(intervalId);
window.clearInterval(intervalId);
});
});