From 80ba38de04d2ff5d93abc99b33910e6e6cbbf12f Mon Sep 17 00:00:00 2001 From: Anthony Fu Date: Tue, 28 Dec 2021 15:11:17 +0800 Subject: [PATCH] fix(ui): init state --- .vscode/tasks.json | 48 ++++++++++++++++++++----- packages/ui/client/composables/state.ts | 8 ++--- 2 files changed, 44 insertions(+), 12 deletions(-) diff --git a/.vscode/tasks.json b/.vscode/tasks.json index fbc18f1f4eb1..9adfcfcb577f 100644 --- a/.vscode/tasks.json +++ b/.vscode/tasks.json @@ -27,23 +27,55 @@ { "type": "npm", "script": "ui:dev", - "problemMatcher": [], "label": "npm: ui", "isBackground": true, - "dependsOn": ["npm: dev"] - }, - { - "type": "npm", - "script": "test", + "dependsOn": ["npm: test"], "group": { "kind": "build", "isDefault": true }, - "problemMatcher": [], + "problemMatcher": { + "owner": "typescript", + "fileLocation": "relative", + "pattern": { + "regexp": "^(.*):(\\d+):(\\d+):\\s+(warning|error):\\s+(.*)$", + "file": 1, + "line": 2, + "column": 3, + "severity": 4, + "message": 5 + }, + "background": { + "activeOnStart": true, + "beginsPattern": "vite", + "endsPattern": "ready in" + } + } + }, + { + "type": "npm", + "script": "test", "label": "npm: test", "isBackground": true, "dependsOn": ["npm: dev"], - "detail": "vitest -r test/core --api" + "detail": "vitest -r test/core --api", + "problemMatcher": { + "owner": "typescript", + "fileLocation": "relative", + "pattern": { + "regexp": "^(.*):(\\d+):(\\d+):\\s+(warning|error):\\s+(.*)$", + "file": 1, + "line": 2, + "column": 3, + "severity": 4, + "message": 5 + }, + "background": { + "activeOnStart": true, + "beginsPattern": "WATCH", + "endsPattern": "Waiting for" + } + } }, { "type": "npm", diff --git a/packages/ui/client/composables/state.ts b/packages/ui/client/composables/state.ts index 4f9a1271b032..3a824a4c5dbd 100644 --- a/packages/ui/client/composables/state.ts +++ b/packages/ui/client/composables/state.ts @@ -3,13 +3,13 @@ import type { WebSocketStatus } from '@vueuse/core' import { reactive } from 'vue' import type { ResolvedConfig } from '#types' -export const { - file: activeFileIdRef, -} = toRefs(useUrlSearchParams<{ file: string }>('hash-params', { +export const params = useUrlSearchParams<{ file: string }>('hash-params', { initialValue: { file: '', }, -})) +}) + +export const activeFileIdRef = toRef(params, 'file') export const ENTRY_URL = 'ws://localhost:51204/__vitest_api__'