Skip to content

Commit 6caf778

Browse files
committed
fix vite v5.0.6 building for production...
transforming... ✓ 54 modules transformed. rendering chunks... computing gzip size... dist/index.html 0.83 kB │ gzip: 0.44 kB dist/assets/Patron-PersonalUse-Regular-VRDUqsgA.otf 13.17 kB dist/assets/Exodar-Outline-cczeqCpn.ttf 111.62 kB dist/assets/index-pUH2M1aI.css 20.04 kB │ gzip: 2.28 kB dist/assets/index-7B0PKRlB.js 220.53 kB │ gzip: 81.74 kB ✓ built in 1.03s
1 parent a6e181c commit 6caf778

4 files changed

Lines changed: 22 additions & 27 deletions

File tree

src/App.vue

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<!-- src/App.vue -->
22
<script setup lang="ts">
3-
import { ref, onMounted } from 'vue';
3+
import { onMounted } from 'vue';
44
import CookieBanner from './components/CookieBanner.vue';
55
66
import CommandLineInterface from './components/CommandLineInterface.vue';
@@ -9,8 +9,6 @@ import PromptExecutionLogo from './components/PromptExecutionLogo.vue';
99
import { useMainStore } from './store';
1010
const mainStore = useMainStore();
1111
12-
const showBanner = ref(true); // Or whatever logic you need to show/hide the banner
13-
1412
// Example of how you might control the visibility of the banner
1513
// This is just a placeholder logic, adjust according to your needs
1614
onMounted(() => {
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
</template>
99

1010
<script lang="ts">
11-
import { useCookies } from '../useCookies'
11+
import useCookies from '../useCookies'
1212
export default {
1313
setup() {
1414
const { allowCookies } = useCookies()

src/store.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,18 +13,18 @@ export const useMainStore = defineStore('main', {
1313
increment() {
1414
this.count++
1515
},
16-
setCookieConsent(value) {
16+
setCookieConsent(value: 'accepted' | 'rejected') {
1717
this.cookieConsent = value
1818
localStorage.setItem('cookieConsent', value)
1919
},
2020
resetCookieConsent() {
2121
this.cookieConsent = null;
2222
localStorage.removeItem('cookieConsent');
2323
},
24-
toggleLogin(show) {
24+
toggleLogin() {
2525
this.showLogin = !this.showLogin;
2626
},
27-
toggleDebugPanel(show) {
27+
toggleDebugPanel() {
2828
this.showDebugPanel = !this.showDebugPanel;
2929
}
3030
},

src/useCookies.ts

Lines changed: 17 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,32 @@
11
import { ref, watch, computed } from 'vue';
22
import { useCookie } from 'vue-cookie-next';
33

4-
const allowCookies = ref<boolean>();
54

65
export default function useCookies(gtag: any) {
76
const cookie = useCookie();
7+
const allowCookies = ref<boolean>();
88

9-
if (cookie.isCookieAvailable('cookies_consent')) {
10-
allowCookies.value = cookie.getCookie('cookies_consent') === 'true';
11-
gtag.optIn();
12-
} else {
13-
allowCookies.value = undefined;
14-
}
9+
// Initialize allowCookies based on the existing cookie
10+
const initCookieConsent = () => {
11+
if (cookie.isCookieAvailable('cookies_consent')) {
12+
allowCookies.value = cookie.getCookie('cookies_consent') === 'true';
13+
if (allowCookies.value) gtag.optIn();
14+
}
15+
};
16+
17+
// Call this function on initialization
18+
initCookieConsent();
1519

16-
watch(allowCookies, () => {
17-
if (allowCookies.value != undefined) {
18-
cookie.setCookie('cookies_consent', allowCookies.value.toString(), {
19-
expire: new Date(2022, 1, 1),
20+
watch(allowCookies, (newValue) => {
21+
if (newValue !== undefined) {
22+
cookie.setCookie('cookies_consent', newValue.toString(), {
23+
expire: '1Y' // Expires in 1 year, adjust as needed
2024
});
21-
if (allowCookies.value) {
22-
gtag.optIn();
23-
} else {
24-
gtag.optOut();
25-
}
25+
newValue ? gtag.optIn() : gtag.optOut();
2626
}
2727
});
2828

29-
const showBanner = computed(() => {
30-
return allowCookies.value === undefined;
31-
});
32-
29+
const showBanner = computed(() => allowCookies.value === undefined);
3330
const okClicked = () => (allowCookies.value = true);
3431

3532
return {

0 commit comments

Comments
 (0)