Skip to content

Commit 54549b4

Browse files
committed
🐛 fix MSW starting issue
1 parent 42f245c commit 54549b4

File tree

7 files changed

+31
-11
lines changed

7 files changed

+31
-11
lines changed

src/components.d.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ declare module 'vue' {
3434
NBreadcrumb: typeof import('naive-ui')['NBreadcrumb']
3535
NBreadcrumbItem: typeof import('naive-ui')['NBreadcrumbItem']
3636
NButton: typeof import('naive-ui')['NButton']
37-
NColorPicker: typeof import('naive-ui')['NColorPicker']
3837
NConfigProvider: typeof import('naive-ui')['NConfigProvider']
3938
NDataTable: typeof import('naive-ui')['NDataTable']
4039
NDialogProvider: typeof import('naive-ui')['NDialogProvider']
@@ -44,22 +43,19 @@ declare module 'vue' {
4443
NForm: typeof import('naive-ui')['NForm']
4544
NFormItem: typeof import('naive-ui')['NFormItem']
4645
NIcon: typeof import('naive-ui')['NIcon']
47-
NICon: typeof import('naive-ui')['NICon']
4846
NInput: typeof import('naive-ui')['NInput']
4947
NLayout: typeof import('naive-ui')['NLayout']
5048
NLayoutContent: typeof import('naive-ui')['NLayoutContent']
5149
NLayoutSider: typeof import('naive-ui')['NLayoutSider']
5250
NMenu: typeof import('naive-ui')['NMenu']
5351
NMessageProvider: typeof import('naive-ui')['NMessageProvider']
54-
NModal: typeof import('naive-ui')['NModal']
5552
NNotificationProvider: typeof import('naive-ui')['NNotificationProvider']
5653
Notifications: typeof import('./components/Notifications.vue')['default']
5754
NPageHeader: typeof import('naive-ui')['NPageHeader']
5855
NPopselect: typeof import('naive-ui')['NPopselect']
5956
NSpace: typeof import('naive-ui')['NSpace']
6057
NTooltip: typeof import('naive-ui')['NTooltip']
6158
NTreeSelect: typeof import('naive-ui')['NTreeSelect']
62-
NUpload: typeof import('naive-ui')['NUpload']
6359
OrderManagement: typeof import('./components/Orders/OrderManagement.vue')['default']
6460
PersianIcon: typeof import('./components/CountryIcons/PersianIcon.vue')['default']
6561
ProductsManagement: typeof import('./components/Products/ProductsManagement.vue')['default']

src/main.ts

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,23 @@ declare module '@vue/runtime-core' {
1616
}
1717
}
1818

19-
async function enableMocking() {
19+
async function initializeMocking() {
2020
const { worker } = await import('~/mocks/browser')
2121
return worker.start({
2222
onUnhandledRequest: 'bypass',
23+
serviceWorker: {
24+
url: '/mockServiceWorker.js',
25+
options: {
26+
// Add more reliable service worker options
27+
scope: '/',
28+
},
29+
},
30+
quiet: true,
31+
waitUntilReady: false,
32+
}).catch((error) => {
33+
console.warn('MSW initialization failed:', error)
34+
// Continue app execution even if mocking fails
35+
return Promise.resolve()
2336
})
2437
}
2538

@@ -48,4 +61,15 @@ router.beforeEach((to, from, next) => {
4861

4962
next()
5063
})
51-
app.mount('#app')
64+
65+
async function startApp() {
66+
try {
67+
await initializeMocking()
68+
}
69+
catch (error) {
70+
console.warn('Mock service initialization failed:', error)
71+
}
72+
app.mount('#app')
73+
}
74+
75+
startApp()

src/pages/Brands/index.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
meta:
77
title: Brands
88
breadcrumb:
9-
- productsManagement
9+
- productManagement
1010
- brands
1111
</route>
1212

src/pages/Categories/index.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
meta:
77
title: Category Management
88
breadcrumb:
9-
- productsManagement
9+
- productManagement
1010
- categories
1111
</route>
1212

src/pages/Colors/index.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
meta:
77
title: Color Management
88
breadcrumb:
9-
- productsManagement
9+
- productManagement
1010
- colors
1111
</route>
1212

src/pages/Products/Create.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
meta:
77
title: Create Product
88
breadcrumb:
9-
- productsManagement
9+
- productManagement
1010
- products
1111
- create
1212
</route>

src/pages/Products/index.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
meta:
77
title: Products Management
88
breadcrumb:
9-
- productsManagement
9+
- productManagement
1010
- products
1111
</route>
1212

0 commit comments

Comments
 (0)