refactor: define _IS_CHROMATIC_

This commit is contained in:
syuilo 2023-05-16 19:24:10 +09:00
parent 153eed7d71
commit a35f0d43e4
5 changed files with 7 additions and 2 deletions

View file

@ -82,6 +82,7 @@ module.exports = {
'_LANGS_': false,
'_VERSION_': false,
'_ENV_': false,
'_IS_CHROMATIC_': false,
'_PERF_PREFIX_': false,
'_DATA_TRANSFER_DRIVE_FILE_': false,
'_DATA_TRANSFER_DRIVE_FOLDER_': false,

View file

@ -32,6 +32,9 @@ const config = {
rootDir: config.root ?? process.cwd(),
}),
],
define: {
_IS_CHROMATIC_: true,
},
build: {
target: [
'chrome108',

View file

@ -4,6 +4,7 @@ declare const _LANGS_: string[][];
declare const _VERSION_: string;
declare const _ENV_: string;
declare const _DEV_: boolean;
declare const _IS_CHROMATIC_: boolean;
declare const _PERF_PREFIX_: string;
declare const _DATA_TRANSFER_DRIVE_FILE_: string;
declare const _DATA_TRANSFER_DRIVE_FOLDER_: string;

View file

@ -4,7 +4,6 @@
<script lang="ts" setup>
import { onMounted, onUnmounted, shallowRef } from 'vue';
import isChromatic from 'chromatic/isChromatic';
const canvasEl = shallowRef<HTMLCanvasElement>();
@ -204,7 +203,7 @@ onMounted(() => {
const vertices = [1.0, 1.0, -1.0, 1.0, 1.0, -1.0, -1.0, -1.0];
gl.bufferData(gl.ARRAY_BUFFER, new Float32Array(vertices), gl.DYNAMIC_DRAW);
if (isChromatic()) {
if (_IS_CHROMATIC_) {
gl!.uniform1f(u_time, 0);
gl!.drawArrays(gl!.TRIANGLE_STRIP, 0, 4);
} else {

View file

@ -95,6 +95,7 @@ export function getConfig(): UserConfig {
_LANGS_: JSON.stringify(Object.entries(locales).map(([k, v]) => [k, v._lang_])),
_ENV_: JSON.stringify(process.env.NODE_ENV),
_DEV_: process.env.NODE_ENV !== 'production',
_IS_CHROMATIC_: false,
_PERF_PREFIX_: JSON.stringify('Misskey:'),
_DATA_TRANSFER_DRIVE_FILE_: JSON.stringify('mk_drive_file'),
_DATA_TRANSFER_DRIVE_FOLDER_: JSON.stringify('mk_drive_folder'),