// Manual browser fixture for the production component, not an offline prototype. import { createApp, h } from 'vue' import ElementPlus from 'element-plus' import 'element-plus/dist/index.css' import Page from '../../src/views/goauto/client-keys/index.vue' import request from '../../src/utils/request' const definitions = [ ['syb_products', 'SYB 商品', true, ['reparse']], ['syb_sync_runs', 'SYB 同步记录', false, ['sync']], ['syb_inner_codes', '档口入库码', false, ['import', 'match', 'writeback', 'delete']], ['shopee_products', '虾皮商品', true, ['match', 'delete']], ['pdd_products', 'PDD 商品', true, []], ['collection_tasks', '采集任务', false, ['collect', 'delete']], ['purchase_tasks', '采购管理', false, ['purchase']], ['syb_shops', 'SYB 店铺', true, ['delete']], ['collection_rules', '采集规则', true, ['delete']], ['purchase_rules', '采购规则', true, ['delete', 'activate']], ['devices', '设备列表', false, []], ['ai_matching', 'AI 规格匹配', false, ['match']] ] const modules = definitions.map(([key, title, writable, actions], index) => ({ key, title, writable, actions, group: index < 7 ? '采集采购' : '采采管理' })) let items = [{ id: 1, name: '商品同步工具(测试)', prefix: 'gak_DEMO', version: 1, enabled: true, updatedBy: 1, updatedAt: '2026-09-07T00:00:00Z', grants: [{ module: 'pdd_products', write: true, actions: [] }] }] request.defaults.adapter = async config => { let data const body = typeof config.data === 'string' ? JSON.parse(config.data) : config.data if (config.url.endsWith('/modules')) data = modules else if (config.method === 'get') data = { items: structuredClone(items), total: items.length } else if (config.url.endsWith('/grants')) { items[0].grants = body.grants; items[0].version++; data = items[0] } else if (config.url.endsWith('/disable')) { items[0].enabled = false; items[0].version++; data = items[0] } else if (config.method === 'post' && config.url === '/api/admin/v1/client-keys') { const key = { id: 2, name: body.name, prefix: 'gak_DEMO_2', enabled: true, version: 1, grants: body.grants } items = [key, ...items]; data = { key, secret: 'DEMO_ONLY_NOT_A_VALID_SECRET' } } else throw new Error('Unexpected fixture request') return { status: 200, statusText: 'OK', headers: {}, config, data: { code: 200, data }} } const app = createApp(Page) app.use(ElementPlus) app.config.globalProperties.$store = { getters: { roles: ['admin'] }} app.component('BasicLayout', { setup(_, { slots }) { return () => h('main', { style: 'padding:24px;background:#f3f6fa;min-height:90vh;font-family:Arial,sans-serif' }, slots.wrapper?.()) } }) app.mount('#app')