diff --git a/package.json b/package.json index a97f802..6a2dd93 100644 --- a/package.json +++ b/package.json @@ -23,6 +23,7 @@ }, "dependencies": { "naive-ui": "^2.34.3", + "pinia": "^2.0.30", "vue": "^3.2.47", "vue-router": "^4.1.6" }, diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index f9fe567..b0b2e76 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -14,6 +14,7 @@ specifiers: lint-staged: ^13.1.1 naive-ui: ^2.34.3 npm-run-all: ^4.1.5 + pinia: ^2.0.30 postcss: ^8.4.21 rimraf: ^4.1.2 tailwindcss: ^3.2.6 @@ -25,6 +26,7 @@ specifiers: dependencies: naive-ui: 2.34.3_vue@3.2.47 + pinia: 2.0.30_hmuptsblhheur2tugfgucj7gc4 vue: 3.2.47 vue-router: 4.1.6_vue@3.2.47 @@ -3567,6 +3569,24 @@ packages: engines: {node: '>=4'} dev: true + /pinia/2.0.30_hmuptsblhheur2tugfgucj7gc4: + resolution: {integrity: sha512-q6DUmxWwe/mQgg+55QQjykpKC+aGeGdaJV3niminl19V08dE+LRTvSEuqi6/NLSGCKHI49KGL6tMNEOssFiMyA==} + peerDependencies: + '@vue/composition-api': ^1.4.0 + typescript: '>=4.4.4' + vue: ^2.6.14 || ^3.2.0 + peerDependenciesMeta: + '@vue/composition-api': + optional: true + typescript: + optional: true + dependencies: + '@vue/devtools-api': 6.5.0 + typescript: 4.9.5 + vue: 3.2.47 + vue-demi: 0.13.11_vue@3.2.47 + dev: false + /pluralize/8.0.0: resolution: {integrity: sha512-Nc3IT5yHzflTfbjgqWcCPpo7DaKy4FnpB0l/zCAW0Tc7jxAiuqSxHasntB3D7887LSrA93kDJ9IXovxJYxyLCA==} engines: {node: '>=4'} @@ -4284,7 +4304,6 @@ packages: resolution: {integrity: sha512-1FXk9E2Hm+QzZQ7z+McJiHL4NW1F2EzMu9Nq9i3zAaGqibafqYwCVU6WyWAuyQRRzOlxou8xZSyXLEN8oKj24g==} engines: {node: '>=4.2.0'} hasBin: true - dev: true /unbox-primitive/1.0.2: resolution: {integrity: sha512-61pPlCD9h51VoreyJ0BReideM3MDKMKnh6+V9L08331ipq6Q8OFXZYiqP6n/tbHx4s5I9uRhcye6BrbkizkBDw==} @@ -4390,6 +4409,21 @@ packages: vue: 3.2.47 dev: false + /vue-demi/0.13.11_vue@3.2.47: + resolution: {integrity: sha512-IR8HoEEGM65YY3ZJYAjMlKygDQn25D5ajNFNoKh9RSDMQtlzCxtfQjdQgv9jjK+m3377SsJXY8ysq8kLCZL25A==} + engines: {node: '>=12'} + hasBin: true + requiresBuild: true + peerDependencies: + '@vue/composition-api': ^1.0.0-rc.1 + vue: ^3.0.0-0 || ^2.6.0 + peerDependenciesMeta: + '@vue/composition-api': + optional: true + dependencies: + vue: 3.2.47 + dev: false + /vue-eslint-parser/9.1.0_eslint@8.34.0: resolution: {integrity: sha512-NGn/iQy8/Wb7RrRa4aRkokyCZfOUWk19OP5HP6JEozQFX5AoS/t+Z0ZN7FY4LlmWc4FNI922V7cvX28zctN8dQ==} engines: {node: ^14.17.0 || >=16.0.0} diff --git a/src/main.ts b/src/main.ts index 19f69e9..acbe522 100644 --- a/src/main.ts +++ b/src/main.ts @@ -1,21 +1,17 @@ -import './styles/global.css' - import { createApp } from 'vue' import App from './App.vue' +import { setupAssets } from '@/plugins' +import { setupStore } from '@/store' import { setupRouter } from '@/router' -/** Tailwind's Preflight Style Override */ -function naiveStyleOverride() { - const meta = document.createElement('meta') - meta.name = 'naive-ui-style' - document.head.appendChild(meta) -} - -/** Setup */ async function bootstrap() { const app = createApp(App) - naiveStyleOverride() + setupAssets() + + setupStore(app) + await setupRouter(app) + app.mount('#app') } diff --git a/src/plugins/assets.ts b/src/plugins/assets.ts new file mode 100644 index 0000000..b6b4cb0 --- /dev/null +++ b/src/plugins/assets.ts @@ -0,0 +1,14 @@ +import '@/styles/global.css' + +/** Tailwind's Preflight Style Override */ +function naiveStyleOverride() { + const meta = document.createElement('meta') + meta.name = 'naive-ui-style' + document.head.appendChild(meta) +} + +function setupAssets() { + naiveStyleOverride() +} + +export default setupAssets diff --git a/src/plugins/index.ts b/src/plugins/index.ts new file mode 100644 index 0000000..ae1ac22 --- /dev/null +++ b/src/plugins/index.ts @@ -0,0 +1,3 @@ +import setupAssets from './assets' + +export { setupAssets } diff --git a/src/store/index.ts b/src/store/index.ts new file mode 100644 index 0000000..5044bb1 --- /dev/null +++ b/src/store/index.ts @@ -0,0 +1,9 @@ +import type { App } from 'vue' +import { createPinia } from 'pinia' + +export function setupStore(app: App) { + const store = createPinia() + app.use(store) +} + +export * from './modules' diff --git a/src/store/modules/app/index.ts b/src/store/modules/app/index.ts new file mode 100644 index 0000000..ca89ec5 --- /dev/null +++ b/src/store/modules/app/index.ts @@ -0,0 +1,19 @@ +import { defineStore } from 'pinia' + +interface AppState { + siderCollapsed: boolean +} + +export const useAppStore = defineStore('app-store', { + state: (): AppState => ({ + siderCollapsed: false, + }), + actions: { + setSiderCollapsed(collapsed: boolean) { + this.siderCollapsed = collapsed + }, + toggleSiderCollapse() { + this.siderCollapsed = !this.siderCollapsed + }, + }, +}) diff --git a/src/store/modules/history/index.ts b/src/store/modules/history/index.ts new file mode 100644 index 0000000..3f1c2dd --- /dev/null +++ b/src/store/modules/history/index.ts @@ -0,0 +1,12 @@ +import { defineStore } from 'pinia' + +interface HistoryState { + list: any[] +} + +export const useHistoryStore = defineStore('history-store', { + state: (): HistoryState => ({ + list: [], + }), + actions: {}, +}) diff --git a/src/store/modules/index.ts b/src/store/modules/index.ts new file mode 100644 index 0000000..4e0ccdc --- /dev/null +++ b/src/store/modules/index.ts @@ -0,0 +1,2 @@ +export * from './app' +export * from './history'