From 89ac58381dd016d780361ee9eb2edd95ee06f398 Mon Sep 17 00:00:00 2001
From: NoTwoBoy <1244476905@qq.com>
Date: Fri, 13 Dec 2024 19:06:01 +0800
Subject: [PATCH] fix(devtools): setup the settings panel immediately

---
 packages/pinia/src/devtools/plugin.ts | 47 +++++++++++++--------------
 1 file changed, 23 insertions(+), 24 deletions(-)

diff --git a/packages/pinia/src/devtools/plugin.ts b/packages/pinia/src/devtools/plugin.ts
index 2c9fdd5c70..0638f2f2b7 100644
--- a/packages/pinia/src/devtools/plugin.ts
+++ b/packages/pinia/src/devtools/plugin.ts
@@ -37,6 +37,27 @@ const MUTATIONS_LAYER_ID = 'pinia:mutations'
 const INSPECTOR_ID = 'pinia'
 const { assign } = Object
 
+const pluginDescriptor = {
+  id: 'dev.esm.pinia',
+  label: 'Pinia 🍍',
+  logo: 'https://pinia.vuejs.org/logo.svg',
+  packageName: 'pinia',
+  homepage: 'https://pinia.vuejs.org',
+  componentStateTypes,
+  settings: {
+    logStoreChanges: {
+      label: 'Notify about new/deleted stores',
+      type: 'boolean',
+      defaultValue: true,
+    },
+    // useEmojis: {
+    //   label: 'Use emojis in messages ⚡️',
+    //   type: 'boolean',
+    //   defaultValue: true,
+    // },
+  },
+} as const
+
 /**
  * Gets the displayed name of a store in devtools
  *
@@ -55,12 +76,7 @@ const getStoreType = (id: string) => '🍍 ' + id
 export function registerPiniaDevtools(app: DevtoolsApp, pinia: Pinia) {
   setupDevtoolsPlugin(
     {
-      id: 'dev.esm.pinia',
-      label: 'Pinia 🍍',
-      logo: 'https://pinia.vuejs.org/logo.svg',
-      packageName: 'pinia',
-      homepage: 'https://pinia.vuejs.org',
-      componentStateTypes,
+      ...pluginDescriptor,
       app,
     },
     (api) => {
@@ -308,25 +324,8 @@ function addStoreToDevtools(app: DevtoolsApp, store: StoreGeneric) {
 
   setupDevtoolsPlugin(
     {
-      id: 'dev.esm.pinia',
-      label: 'Pinia 🍍',
-      logo: 'https://pinia.vuejs.org/logo.svg',
-      packageName: 'pinia',
-      homepage: 'https://pinia.vuejs.org',
-      componentStateTypes,
+      ...pluginDescriptor,
       app,
-      settings: {
-        logStoreChanges: {
-          label: 'Notify about new/deleted stores',
-          type: 'boolean',
-          defaultValue: true,
-        },
-        // useEmojis: {
-        //   label: 'Use emojis in messages ⚡️',
-        //   type: 'boolean',
-        //   defaultValue: true,
-        // },
-      },
     },
     (api) => {
       // gracefully handle errors