diff --git a/src/main.js b/src/main.js index 395a3b9..365cfe3 100644 --- a/src/main.js +++ b/src/main.js @@ -3,6 +3,7 @@ import { createApp } from "vue"; import http from '@/api/index.js'; import icon from "@/icon/index.js"; +import store from "@/stores/index.js"; import "@wangeditor/editor/dist/css/style.css"; // 引入 css import "qweather-icons/font/qweather-icons.css"; import "tailwindcss/tailwind.css"; @@ -24,7 +25,7 @@ document.oncontextmenu = function () { app.use(createPinia()); app.use(router).use(VueWechatTitle); - +window.$store = store window.$http = http // window.$icon = icon for (const key in icon) { diff --git a/src/stores/index.js b/src/stores/index.js new file mode 100644 index 0000000..413979f --- /dev/null +++ b/src/stores/index.js @@ -0,0 +1,12 @@ +const files = import.meta.glob('./*.js', { + eager: true, +}) + +const store = {} +// console.log("stores封装",files); +for (const i in files) { + const t = i.split("/") + const name = t[1].split(".")[0] + store[name] = files[i] +} +export default store \ No newline at end of file diff --git a/src/stores/size.js b/src/stores/size.js index eb6431e..fa5b4ee 100644 --- a/src/stores/size.js +++ b/src/stores/size.js @@ -6,6 +6,7 @@ export const usesizeStore = defineStore("size", { navH: 0, conH: 0, footH:0, + searchH:0, }), actions: { setMenuH(v) { @@ -17,7 +18,10 @@ export const usesizeStore = defineStore("size", { setFootH(v){ this.footH = v; }, - + setSearchH(v){ + this.searchH = v; + }, + setX(v){ this.x = v; } diff --git a/src/views/home/index.vue b/src/views/home/index.vue index abfcbb4..129f613 100644 --- a/src/views/home/index.vue +++ b/src/views/home/index.vue @@ -1,6 +1,6 @@