feat: 预设 pinia 相关文件
This commit is contained in:
parent
797cc7461b
commit
b6e5c59a9c
|
@ -23,6 +23,7 @@
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"naive-ui": "^2.34.3",
|
"naive-ui": "^2.34.3",
|
||||||
|
"pinia": "^2.0.30",
|
||||||
"vue": "^3.2.47",
|
"vue": "^3.2.47",
|
||||||
"vue-router": "^4.1.6"
|
"vue-router": "^4.1.6"
|
||||||
},
|
},
|
||||||
|
|
|
@ -14,6 +14,7 @@ specifiers:
|
||||||
lint-staged: ^13.1.1
|
lint-staged: ^13.1.1
|
||||||
naive-ui: ^2.34.3
|
naive-ui: ^2.34.3
|
||||||
npm-run-all: ^4.1.5
|
npm-run-all: ^4.1.5
|
||||||
|
pinia: ^2.0.30
|
||||||
postcss: ^8.4.21
|
postcss: ^8.4.21
|
||||||
rimraf: ^4.1.2
|
rimraf: ^4.1.2
|
||||||
tailwindcss: ^3.2.6
|
tailwindcss: ^3.2.6
|
||||||
|
@ -25,6 +26,7 @@ specifiers:
|
||||||
|
|
||||||
dependencies:
|
dependencies:
|
||||||
naive-ui: 2.34.3_vue@3.2.47
|
naive-ui: 2.34.3_vue@3.2.47
|
||||||
|
pinia: 2.0.30_hmuptsblhheur2tugfgucj7gc4
|
||||||
vue: 3.2.47
|
vue: 3.2.47
|
||||||
vue-router: 4.1.6_vue@3.2.47
|
vue-router: 4.1.6_vue@3.2.47
|
||||||
|
|
||||||
|
@ -3567,6 +3569,24 @@ packages:
|
||||||
engines: {node: '>=4'}
|
engines: {node: '>=4'}
|
||||||
dev: true
|
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:
|
/pluralize/8.0.0:
|
||||||
resolution: {integrity: sha512-Nc3IT5yHzflTfbjgqWcCPpo7DaKy4FnpB0l/zCAW0Tc7jxAiuqSxHasntB3D7887LSrA93kDJ9IXovxJYxyLCA==}
|
resolution: {integrity: sha512-Nc3IT5yHzflTfbjgqWcCPpo7DaKy4FnpB0l/zCAW0Tc7jxAiuqSxHasntB3D7887LSrA93kDJ9IXovxJYxyLCA==}
|
||||||
engines: {node: '>=4'}
|
engines: {node: '>=4'}
|
||||||
|
@ -4284,7 +4304,6 @@ packages:
|
||||||
resolution: {integrity: sha512-1FXk9E2Hm+QzZQ7z+McJiHL4NW1F2EzMu9Nq9i3zAaGqibafqYwCVU6WyWAuyQRRzOlxou8xZSyXLEN8oKj24g==}
|
resolution: {integrity: sha512-1FXk9E2Hm+QzZQ7z+McJiHL4NW1F2EzMu9Nq9i3zAaGqibafqYwCVU6WyWAuyQRRzOlxou8xZSyXLEN8oKj24g==}
|
||||||
engines: {node: '>=4.2.0'}
|
engines: {node: '>=4.2.0'}
|
||||||
hasBin: true
|
hasBin: true
|
||||||
dev: true
|
|
||||||
|
|
||||||
/unbox-primitive/1.0.2:
|
/unbox-primitive/1.0.2:
|
||||||
resolution: {integrity: sha512-61pPlCD9h51VoreyJ0BReideM3MDKMKnh6+V9L08331ipq6Q8OFXZYiqP6n/tbHx4s5I9uRhcye6BrbkizkBDw==}
|
resolution: {integrity: sha512-61pPlCD9h51VoreyJ0BReideM3MDKMKnh6+V9L08331ipq6Q8OFXZYiqP6n/tbHx4s5I9uRhcye6BrbkizkBDw==}
|
||||||
|
@ -4390,6 +4409,21 @@ packages:
|
||||||
vue: 3.2.47
|
vue: 3.2.47
|
||||||
dev: false
|
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:
|
/vue-eslint-parser/9.1.0_eslint@8.34.0:
|
||||||
resolution: {integrity: sha512-NGn/iQy8/Wb7RrRa4aRkokyCZfOUWk19OP5HP6JEozQFX5AoS/t+Z0ZN7FY4LlmWc4FNI922V7cvX28zctN8dQ==}
|
resolution: {integrity: sha512-NGn/iQy8/Wb7RrRa4aRkokyCZfOUWk19OP5HP6JEozQFX5AoS/t+Z0ZN7FY4LlmWc4FNI922V7cvX28zctN8dQ==}
|
||||||
engines: {node: ^14.17.0 || >=16.0.0}
|
engines: {node: ^14.17.0 || >=16.0.0}
|
||||||
|
|
18
src/main.ts
18
src/main.ts
|
@ -1,21 +1,17 @@
|
||||||
import './styles/global.css'
|
|
||||||
|
|
||||||
import { createApp } from 'vue'
|
import { createApp } from 'vue'
|
||||||
import App from './App.vue'
|
import App from './App.vue'
|
||||||
|
import { setupAssets } from '@/plugins'
|
||||||
|
import { setupStore } from '@/store'
|
||||||
import { setupRouter } from '@/router'
|
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() {
|
async function bootstrap() {
|
||||||
const app = createApp(App)
|
const app = createApp(App)
|
||||||
naiveStyleOverride()
|
setupAssets()
|
||||||
|
|
||||||
|
setupStore(app)
|
||||||
|
|
||||||
await setupRouter(app)
|
await setupRouter(app)
|
||||||
|
|
||||||
app.mount('#app')
|
app.mount('#app')
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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
|
|
@ -0,0 +1,3 @@
|
||||||
|
import setupAssets from './assets'
|
||||||
|
|
||||||
|
export { setupAssets }
|
|
@ -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'
|
|
@ -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
|
||||||
|
},
|
||||||
|
},
|
||||||
|
})
|
|
@ -0,0 +1,12 @@
|
||||||
|
import { defineStore } from 'pinia'
|
||||||
|
|
||||||
|
interface HistoryState {
|
||||||
|
list: any[]
|
||||||
|
}
|
||||||
|
|
||||||
|
export const useHistoryStore = defineStore('history-store', {
|
||||||
|
state: (): HistoryState => ({
|
||||||
|
list: [],
|
||||||
|
}),
|
||||||
|
actions: {},
|
||||||
|
})
|
|
@ -0,0 +1,2 @@
|
||||||
|
export * from './app'
|
||||||
|
export * from './history'
|
Loading…
Reference in New Issue