Browse Source

feat(login): 添加 登录页
feat(store): 引入 pinia 状态管理库

wangpx 1 year ago
parent
commit
7a69871470
5 changed files with 43 additions and 1 deletions
  1. 6 1
      main.js
  2. 8 0
      pages.json
  3. 13 0
      pages/login.vue
  4. 2 0
      pages/message/index.vue
  5. 14 0
      store/counter.js

+ 6 - 1
main.js

@@ -16,11 +16,16 @@ app.$mount()
 // #ifdef VUE3
 import { createSSRApp } from 'vue'
 import App from './App.vue'
+// import store from './store'
+import * as Pinia from 'pinia';
 
 export function createApp() {
   const app = createSSRApp(App)
+	// app.use(store)
+	app.use(Pinia.createPinia());
   return {
-    app
+    app,
+		Pinia, // 此处必须将 Pinia 返回
   }
 }
 // #endif

+ 8 - 0
pages.json

@@ -144,6 +144,14 @@
 			{
 				"navigationBarTitleText" : "AI客服"
 			}
+		},
+		{
+			"path" : "pages/login",
+			"style" : 
+			{
+				"navigationBarTitleText" : "",
+				"enablePullDownRefresh" : false
+			}
 		}
 	],
 	"tabBar": {

+ 13 - 0
pages/login.vue

@@ -0,0 +1,13 @@
+<template>
+	<view>
+		
+	</view>
+</template>
+
+<script setup lang="ts">
+import {ref} from 'vue'
+</script>
+
+<style lang="scss">
+
+</style>

+ 2 - 0
pages/message/index.vue

@@ -1,5 +1,7 @@
 <template>
 	<view class="index_container">
+		<uni-nav-bar dark :border="false" :fixed="true" title="宇光同行">
+		</uni-nav-bar>
 		<!-- <uni-nav-bar :border="false" :fixed="true">
 			<template v-slot:left>研发部</template>
 			<template v-slot:right>用户1</template>

+ 14 - 0
store/counter.js

@@ -0,0 +1,14 @@
+import { defineStore } from 'pinia'
+
+// 你可以任意命名 `defineStore()` 的返回值,但最好使用 store 的名字,同时以 `use` 开头且以 `Store` 结尾。
+// (比如 `useUserStore`,`useCartStore`,`useProductStore`)
+// 第一个参数是你的应用中 Store 的唯一 ID。
+export const useCounterStore = defineStore('counter', () => {
+  const count = ref(0)
+  const doubleCount = computed(() => count.value * 2)
+  function increment() {
+    count.value++
+  }
+
+  return { count, doubleCount, increment }
+})