Kaynağa Gözat

Merge branch 'im' of https://git.nanodreamtech.com/wkw/wallet_app into im

congjiang 1 ay önce
ebeveyn
işleme
17d56518e8

+ 13 - 9
.env

@@ -8,17 +8,21 @@ VITE_DEV_PATH='https://wallet.angeltokens.io'
 VITE_PRO_PATH='https://wallet.angeltokens.io'
 
 
-VITE_IM_PATH_FIlE ='https://nim.angeltokens.io/api/v1/file/'
-VITE_PRO_IM_WSS ='wss://nim.angeltokens.io/api/v1/socket.io'
-VITE_PRO_IM_PATH='https://nim.angeltokens.io' 
+# VITE_IM_PATH_FIlE ='https://nim.angeltokens.io/api/v1/file/'
+# VITE_PRO_IM_WSS ='wss://nim.angeltokens.io/api/v1/socket.io'
+# VITE_PRO_IM_PATH='https://nim.angeltokens.io' 
 
-VITE_DEV_IM_PATH='https://nim.angeltokens.io'
+# VITE_DEV_IM_PATH='https://nim.angeltokens.io'
 
-# VITE_PRO_IM_WSS ='ws://192.168.0.20:8888/api/v1/socket.io'
-# VITE_IM_PATH_FIlE ='http://192.168.0.20:8888/api/v1/file/'
-# VITE_DEV_IM_PATH='http://192.168.0.20:8888'
+VITE_PRO_IM_WSS ='ws://192.168.0.20:8888/api/v1/socket.io'
+VITE_IM_PATH_FIlE ='http://192.168.0.20:8888/api/v1/file/'
+VITE_DEV_IM_PATH='http://192.168.0.20:8888'
 
-# VITE_PRO_IM_PATH='http://192.168.0.20:8888' 
+VITE_PRO_IM_PATH='http://192.168.0.20:8888' 
 
 
-VITE_PRO_BACKEND_PATH='https://backend.angeltoken.net'
+VITE_PRO_BACKEND_PATH='https://backend.angeltoken.net'
+
+
+
+VITE_VITE_DAPP_BUILD='1'

+ 2 - 2
capacitor.config.ts

@@ -5,7 +5,7 @@ import { CapacitorConfig } from '@capacitor/cli';
 
 
 // 获取本地服务
-console.log("import.meta.env=", process.env.DAPP_BUILD)
+console.log("import.meta.env=", process.env.VITE_DAPP_BUILD)
 
 let config: CapacitorConfig = {
   appId: 'com.acc.app',
@@ -51,7 +51,7 @@ let config: CapacitorConfig = {
   }
 };
 // 开发服务器配置(热更新用)
-if (process.env.DAPP_BUILD != "1") {
+if (['1','2'].includes(process.env.VITE_DAPP_BUILD)  ) {
   config.server = {
     url: 'https://192.168.0.70:5173',
     cleartext: false,          // 允许HTTP明文通信(仅开发环境)

+ 7 - 5
package.json

@@ -4,17 +4,19 @@
   "private": true,
   "type": "module",
   "scripts": {
-    "dev": "vite --host",
+    "dev": "cross-env VITE_DAPP_BUILD=1 vite --host",
+    "dev:im": "cross-env VITE_DAPP_BUILD=2 vite --host",
     "updata": "node ./updataSetVersion.js",
-    "s": "cross-env DAPP_BUILD=1 npx cap sync android",
+    "s": "cross-env VITE_DAPP_BUILD=1 npx cap sync android",
     "a": "npx cap run android --live-reload --host=192.168.0.70 --port=5173",
     "app": "npx cap run android --live-reload --host=192.168.0.70 --port=5173",
     "ios": "npx cap run ios --live-reload --host=192.168.0.59 --port=5173",
     "android": "npx cap add android && npm run icon && npx cap sync",
     "android:clean": "(cd android && ./gradlew clean)",
-    "build": "vite build && npm run updata",
-    "build:apk": "npm run s && cross-env DAPP_BUILD=1 npx cap copy  && (cd android && ./gradlew assembleRelease)",
-    "build:apk:windows": "npm run s && cross-env DAPP_BUILD=1 npx cap copy  && (cd android && .\\gradlew assembleRelease)",
+    "build": "cross-env VITE_DAPP_BUILD=1 vite build && npm run updata",
+    "build:im": "cross-env VITE_DAPP_BUILD=2 vite build && npm run updata",
+    "build:apk": "npm run s && cross-env VITE_DAPP_BUILD=1 npx cap copy  && (cd android && ./gradlew assembleRelease)",
+    "build:apk:windows": "npm run s && cross-env VITE_DAPP_BUILD=1 npx cap copy  && (cd android && .\\gradlew assembleRelease)",
     "icon": "npx capacitor-assets generate --android",
     "preview": "vite preview"
   },

+ 8 - 4
src/layout/app/index.vue

@@ -26,7 +26,7 @@ const route = useRoute();
 const mainStyle = ref({});
  
 
-const tabbarOptions = [
+let allTabbarOptions = [
   {
     title: "社交",
     icon: "tabbar-im",
@@ -52,10 +52,14 @@ const tabbarOptions = [
     icon: "tabbar-me",
     to: "/me",
   },
-];
-
-
+]
 
+const tabbarOptions = computed(() => {
+  if (import.meta.env.VITE_DAPP_BUILD === "2") {
+    return allTabbarOptions.filter(item => item.to === "/im")
+  }
+  return allTabbarOptions
+})
 
 onBeforeMount(async () => {
   const height = await getNotchHeight();

+ 208 - 0
src/router/im.js

@@ -0,0 +1,208 @@
+const LAYOUT = () => import("@/layout/app/index.vue");
+export const imRoutes = [
+    {
+        path: "/",
+        name: "main",
+        redirect: "im",
+        component: LAYOUT,
+        children: [
+            {
+                path: "/im",
+                name: "im",
+                meta: {
+                    title: "router.Social",
+                    keepAlive: false,
+                    navbar: false,
+                    tabbar: true,
+                }, // 社交
+                component: () => import("@/views/im/index.vue"),
+            },
+            {
+                path: "/login",
+                name: "login",
+                component: () => import("@/views/login/login.vue"),
+                meta: {
+                    title: "router.Login",   // 登录
+                }
+            },
+            {
+                path: "chat",
+                name: "chat",
+                meta: {
+                    title: "router.Social",
+                    keepAlive: false,
+                    navbar: false,
+                    leftArrow: true,
+                }, //  chat界面
+                component: () => import("@/views/im/chat/index.vue"),
+            },
+            {
+                path: "detail",
+                name: "detail",
+                meta: {
+                    title: "router.ChatMessage",
+                    keepAlive: false,
+                    navbar: true,
+                    leftArrow: true,
+                }, //  chat详情
+                component: () => import("@/views/im/detail/index.vue"),
+            },
+            {
+                path: "qrcode",
+                name: "qrcode",
+                meta: {
+                    title: "router.GroupQRCode",
+                    keepAlive: false,
+                    navbar: true,
+                    leftArrow: true,
+                }, //  二维码详情
+                component: () => import("@/views/im/detail/qrcode/index.vue"),
+            },
+            {
+                path: "chatLog",
+                name: "chatLog",
+                meta: {
+                    title: "router.ChatMessage",
+                    keepAlive: false,
+                    navbar: true,
+                    leftArrow: true,
+                }, //  聊天记录
+                component: () => import("@/views/im/detail/chatLog/index.vue"),
+            },
+            {
+                path: "addMember",
+                name: "addMember",
+                meta: {
+                    title: "router.AddMember",
+                    keepAlive: false,
+                    navbar: true,
+                    leftArrow: true,
+                }, //  添加成员
+                component: () => import("@/views/im/detail/addMember/index.vue"),
+            },
+            {
+                path: "createGroupChat",
+                name: "createGroupChat",
+                meta: {
+                    title: "router.CreateGroupChat",
+                    keepAlive: false,
+                    navbar: true,
+                    leftArrow: true,
+                }, //  创建群聊
+                component: () => import("@/views/im/detail/addMember/index.vue"),
+            },
+            {
+                path: "deleteMember",
+                name: "deleteMember",
+                meta: {
+                    title: "router.SelectMembers",
+                    keepAlive: false,
+                    navbar: true,
+                    leftArrow: true,
+                }, //  移出成员
+                component: () => import("@/views/im/detail/deleteMember/index.vue"),
+            },
+            {
+                path: "checkMember",
+                name: "checkMember",
+                meta: {
+                    title: "router.GroupMembers",
+                    keepAlive: false,
+                    navbar: true,
+                    leftArrow: true,
+                }, //  查看成员
+                component: () => import("@/views/im/detail/checkMember/index.vue"),
+            },
+            {
+                path: "contact",
+                name: "contact",
+                meta: {
+                    title: "router.ContactList",
+                    keepAlive: false,
+                    navbar: true,
+                    leftArrow: true,
+                }, //  通讯录
+                component: () => import("@/views/im/contactList/index.vue"),
+            },
+            {
+                path: "invitation",
+                name: "invitation",
+                meta: {
+                    title: "router.NewInvitation",
+                    keepAlive: false,
+                    navbar: true,
+                    leftArrow: true,
+                }, //  新邀请
+                component: () => import("@/views/im/contactList/invitation/index.vue"),
+            },
+            {
+                path: "group",
+                name: "group",
+                meta: {
+                    title: "router.GroupChatList",
+                    keepAlive: false,
+                    navbar: true,
+                    leftArrow: true,
+                }, //  群聊列表
+                component: () => import("@/views/im/contactList/groupList/index.vue"),
+            },
+            {
+                path: "record",
+                name: "record",
+                meta: {
+                    title: "router.ReleaseRecord",
+                    keepAlive: false,
+                    navbar: true,
+                    leftArrow: true,
+                }, //  发布记录
+                component: () => import("@/views/im/releaseRecord/index.vue"),
+            },
+            {
+                path: "personal",
+                name: "personal",
+                meta: {
+                    title: "router.PersonalInformation",
+                    keepAlive: false,
+                    navbar: true,
+                    leftArrow: true,
+                }, //  个人信息
+                component: () => import("@/views/im/personal/index.vue"),
+            },
+            {
+                path: "search",
+                name: "search",
+                meta: {
+                    title: "router.Search",
+                    keepAlive: false,
+                    navbar: true,
+                    leftArrow: true,
+                }, //  搜索页面
+                component: () => import("@/views/im/search/index.vue"),
+            },
+            {
+                path: "publish",
+                name: "publish",
+                meta: {
+                    title: "router.Publish",
+                    keepAlive: false,
+                    navbar: true,
+                    leftArrow: true,
+                }, //  朋友圈发布页面
+                component: () => import("@/views/im/publish/index.vue"),
+            },
+            {
+                path: "chatSearch",
+                name: "chatSearch",
+                meta: {
+                    title: "router.Search",
+                    keepAlive: false,
+                    navbar: true,
+                    leftArrow: true,
+                }, //  聊天搜索或者朋友圈搜索页面
+                component: () => import("@/views/im/chatSearch/index.vue"),
+            },
+        ]
+    }
+]
+
+

+ 18 - 4
src/router/index.js

@@ -1,18 +1,32 @@
  
 import { createRouter, createWebHistory} from 'vue-router'
 import { systemRoutes } from './system'
+import { imRoutes } from './im'
 import { whitelistRoutes } from './whitelist'
 import { createRouterGuards } from './router.guards.js'
 
 
 
+let routes = []
 
-const router = createRouter({
-  history: createWebHistory(),
-  routes: [ 
+if (import.meta.env.VITE_DAPP_BUILD == "1") {
+  routes = [
     ...systemRoutes,
     ...whitelistRoutes
-  ],
+  ]
+}
+
+if (import.meta.env.VITE_DAPP_BUILD == "2") {
+  routes = [
+    ...imRoutes
+  ]
+}
+
+
+
+const router = createRouter({
+  history: createWebHistory(),
+  routes: routes,
 })
 
 

+ 29 - 16
src/router/router.guards.js

@@ -5,13 +5,13 @@ import { whitelistRoutes } from "@/router/whitelist";
 import { systemRoutes } from "@/router/system";
 
 
-const paths = whitelistRoutes.map(item =>{
+const paths = whitelistRoutes.map(item => {
   return item.path
 });
 
-const mainPath = systemRoutes[0].children.filter(item =>{
+const mainPath = systemRoutes[0].children.filter(item => {
   return item.meta?.tabbar || false
-}).map(cItem =>{
+}).map(cItem => {
   return cItem.path
 });
 
@@ -20,25 +20,38 @@ export function createRouterGuards(router) {
   const systemStore = useSystemStore();
   const walletStore = useWalletStore();
   // 路由拦截
-  router.beforeEach(async (to, from, next) => { 
-    if(mainPath.includes(from.path) && paths.includes(to.path) && to.path != '/login'){
-      // 停止跳转
-      next(false)
-      return
-    }
+  router.beforeEach(async (to, from, next) => {
+
+
+    if (import.meta.env.VITE_DAPP_BUILD == "1") {
+      if (mainPath.includes(from.path) && paths.includes(to.path) && to.path != '/login') {
+        // 停止跳转
+        next(false)
+        return
+      }
 
-    if (paths.includes(to.path)) {
-      return next();
+      if (paths.includes(to.path)) {
+        return next();
+      }
+
+      // 没有钱包,则跳转到login 页
+      if (!walletStore.account || !systemStore.token) {
+        return next("/login");
+      }
     }
-    
-    // 没有钱包,则跳转到login 页
-    if (!walletStore.account || !systemStore.token) {
-      return next("/login");
+
+    if (import.meta.env.VITE_DAPP_BUILD == "2") {
+      if (to.path == '/login') {
+        next()
+      }
+      if (!systemStore.token) {
+        return next("/login");
+      }
     }
     next();
   });
 
-  router.afterEach((to, _, next) => {});
+  router.afterEach((to, _, next) => { });
 
   // 错误
   router.onError((error) => {

+ 1 - 1
src/views/im/components/Discover/Discover.vue

@@ -117,7 +117,7 @@ export default {
           return;
         }
         const decoded = JSON.parse(atob(res.data));
-        // console.log(decoded)
+        console.log(decoded)
         this.total = decoded.total || 0;
 
         const processedList = decoded.list.map(item => ({

+ 2 - 2
src/views/im/index.vue

@@ -52,7 +52,7 @@
                 <!-- 免打扰 -->
                 <svg-icon 
                   v-if="item.uuid === wsStore.toUserInfo?.uuid ? wsStore.toUserInfo?.slience : item.slience" 
-                  style="width: 20px; height: 20px;" 
+                  style="width: 15px; height: 15px;color: #8D8D8D;" 
                   name="disturb"
                 />
                 <div class="notice" v-if="item.unReadNum > 0 && !(item.uuid === wsStore.toUserInfo?.uuid ? wsStore.toUserInfo?.slience : item.slience)">{{item.unReadNum}}</div>
@@ -314,7 +314,7 @@ onMounted(()=>{
       margin-bottom:10px;
       display: flex;
       align-items: center;
-      padding: 16px;
+      padding: 16px 16px 8px;
       .item-img{
         width:42px;
         height:42px;

+ 25 - 2
src/views/login/login.vue

@@ -27,11 +27,34 @@
 
 <script setup>
 import { imLogin } from "@/api/path/im.api";
+import { login } from "@/api/path/login.api";
+import { useWalletStore } from "@/stores/modules/walletStore";
+import { useSystemStore } from "@/stores/modules/systemStore";
+const walletStore = useWalletStore();
+const systemStore = useSystemStore();
+const imgHost = import.meta.env.VITE_IM_PATH_FIlE
+const router = useRouter();
+
 const username = ref('');
 const password = ref('');
 const onSubmit = async (values) => {
     console.log('submit', values);
-    // const res = await imLogin({ uuid: address });
+    const results = await Promise.allSettled([
+        login({ wallet_address: username.value }),
+        imLogin({ uuid: username.value }),
+    ]);
+
+    const loginResult = results[0].value;
+    const imLoginResult = results[1].value;
+
+    systemStore.token = loginResult.data.access_token;
+    systemStore.USERID = loginResult.data.user_id;
+
+    walletStore.avatar = imgHost + imLoginResult.data.avatar;
+    walletStore.username = imLoginResult.data.nickname;
+    router.push({
+        path: "/im",
+    });
 };
 </script>
 
@@ -46,6 +69,6 @@ const onSubmit = async (values) => {
     background: #4765DD !important;
 }
 .login{
-    margin-top: 70px;
+    margin-top: 150px;
 } 
 </style>