huangbin 4 年之前
父节点
当前提交
f7336ebea2
共有 2 个文件被更改,包括 104 次插入90 次删除
  1. 15 25
      src/main.ts
  2. 89 65
      src/views/account/login.vue

+ 15 - 25
src/main.ts

@@ -4,37 +4,27 @@ import '@/assets/styles/symbol_color/iconfont.css';
 import '@/assets/styles/symbol_color/iconfont.js';
 import '@/assets/styles/symbol_color/iconfont.js';
 import '@/assets/styles/symbol_no_color/iconfont.css';
 import '@/assets/styles/symbol_no_color/iconfont.css';
 import '@/assets/styles/symbol_no_color/iconfont.js';
 import '@/assets/styles/symbol_no_color/iconfont.js';
-import { QWebChannel } from '@/utils/tool/qwebchannel.js';
 import Antd, { message } from 'ant-design-vue';
 import Antd, { message } from 'ant-design-vue';
 import { createApp } from 'vue';
 import { createApp } from 'vue';
 import App from './App.vue';
 import App from './App.vue';
 import router from './router';
 import router from './router';
 
 
-export let qtWebChannel: any = null;
-declare global {
-    interface Window {
-        qt: {
-            webChannelTransport: {
-                send: (payload: any) => void;
-                onmessage: (payload: any) => void;
-            };
-        };
-    }
-}
-const webChannelTransport = {
-    send() {
-        console.log('QWebChannel simulator activated !');
-    },
-    onmessage() {},
-};
+// export const qtWebChannel: any = null;
 
 
-new QWebChannel(window.qt.webChannelTransport, (channel: any) => {
-    console.log('okoko');
-    // all published objects are available in channel.objects under
-    // the identifier set in their attached WebChannel.id property
-    qtWebChannel = channel.objects.bridge;
-});
-console.log(QWebChannel);
+// const webChannelTransport = {
+//     send() {
+//         console.log('QWebChannel simulator activated !');
+//     },
+//     onmessage() { },
+// };
+
+// new QWebChannel(window.qt.webChannelTransport, (channel: any) => {
+//     console.log('okoko');
+//     // all published objects are available in channel.objects under
+//     // the identifier set in their attached WebChannel.id property
+//     qtWebChannel = channel.objects.bridge;
+// });
+// console.log(QWebChannel);
 
 
 const app = createApp(App);
 const app = createApp(App);
 app.use(router);
 app.use(router);

+ 89 - 65
src/views/account/login.vue

@@ -1,53 +1,67 @@
 <template>
 <template>
-    <div class="login">
-        <a-row type="flex" justify="center" align="middle">
-            <a-col>
-                <div class="login-background">
-                    <div>
-                        <img src="@/assets/images/logo.png" @click="qtAction('ok')" alt="" />
-                    </div>
-                </div>
-                <div class="login-content">
-                    <p>账号登录</p>
-                    <a-form ref="formDom" :model="form" :rules="rules">
-                        <a-form-item name="account">
-                            <a-input placeholder="用户名/账号/手机号" v-model:value="form.account">
-                                <template #prefix>
-                                    <img src="@/assets/images/user.png" alt="" />
-                                </template>
-                            </a-input>
-                        </a-form-item>
-                        <a-form-item name="password">
-                            <a-input @keyup.enter="loginAction" placeholder="请输入您的登录密码" type="password" v-model:value="form.password">
-                                <template #prefix>
-                                    <img src="@/assets/images/password.png" alt="" />
-                                </template>
-                            </a-input>
-                        </a-form-item>
-                        <a-form-item>
-                            <div class="login-remember-password">
-                                <a-checkbox v-model:checked="form.isRemember">
-                                    记住账号
-                                </a-checkbox>
-                                <router-link to="/resetPassword">忘记密码?</router-link>
-                            </div>
-                        </a-form-item>
-                        <a-form-item>
-                            <div style="text-align:left">
-                                <a-checkbox v-model:checked="form.isRead">
-                                    我已阅读并同意
-                                </a-checkbox>
-                                <router-link to="/resetPassword">《用户协议》</router-link>
-                            </div>
-                        </a-form-item>
-                        <a-form-item>
-                            <a-button @click="loginAction" :loading="loading" :disabled="goHomeloading">登录</a-button>
-                        </a-form-item>
-                    </a-form>
-                </div>
-            </a-col>
-        </a-row>
-    </div>
+  <div class="login">
+    <a-row type="flex"
+           justify="center"
+           align="middle">
+      <a-col>
+        <div class="login-background">
+          <div>
+            <img src="@/assets/images/logo.png"
+                 @click="qtAction('ok')"
+                 alt="" />
+          </div>
+        </div>
+        <div class="login-content">
+          <p>账号登录</p>
+          <a-form ref="formDom"
+                  :model="form"
+                  :rules="rules">
+            <a-form-item name="account">
+              <a-input placeholder="用户名/账号/手机号"
+                       v-model:value="form.account">
+                <template #prefix>
+                  <img src="@/assets/images/user.png"
+                       alt="" />
+                </template>
+              </a-input>
+            </a-form-item>
+            <a-form-item name="password">
+              <a-input @keyup.enter="loginAction"
+                       placeholder="请输入您的登录密码"
+                       type="password"
+                       v-model:value="form.password">
+                <template #prefix>
+                  <img src="@/assets/images/password.png"
+                       alt="" />
+                </template>
+              </a-input>
+            </a-form-item>
+            <a-form-item>
+              <div class="login-remember-password">
+                <a-checkbox v-model:checked="form.isRemember">
+                  记住账号
+                </a-checkbox>
+                <router-link to="/resetPassword">忘记密码?</router-link>
+              </div>
+            </a-form-item>
+            <a-form-item>
+              <div style="text-align:left">
+                <a-checkbox v-model:checked="form.isRead">
+                  我已阅读并同意
+                </a-checkbox>
+                <router-link to="/resetPassword">《用户协议》</router-link>
+              </div>
+            </a-form-item>
+            <a-form-item>
+              <a-button @click="loginAction"
+                        :loading="loading"
+                        :disabled="goHomeloading">登录</a-button>
+            </a-form-item>
+          </a-form>
+        </div>
+      </a-col>
+    </a-row>
+  </div>
 </template>
 </template>
 
 
 <script lang="ts">
 <script lang="ts">
@@ -60,7 +74,7 @@ import { localStorageUtil } from '@/utils/tool/storage/index';
 import { setLoadComplete } from '@/setup/methods/index';
 import { setLoadComplete } from '@/setup/methods/index';
 import eventBus from '@/utils/eventBus/index';
 import eventBus from '@/utils/eventBus/index';
 import { QWebChannel } from '@/utils/tool/qwebchannel.js';
 import { QWebChannel } from '@/utils/tool/qwebchannel.js';
-import { qtWebChannel } from '@/main';
+// import { qtWebChannel } from '@/main';
 
 
 interface Form {
 interface Form {
     account: string;
     account: string;
@@ -82,6 +96,16 @@ function setRememberAccount(): void {
         Object.assign(initForm, { account, isRemember: true });
         Object.assign(initForm, { account, isRemember: true });
     }
     }
 }
 }
+declare global {
+    interface Window {
+        qt: {
+            webChannelTransport: {
+                send: (payload: any) => void;
+                onmessage: (payload: any) => void;
+            };
+        };
+    }
+}
 // let qtWebChannel: any = null;
 // let qtWebChannel: any = null;
 
 
 // new QWebChannel(window.qt.webChannelTransport, (channel: any) => {
 // new QWebChannel(window.qt.webChannelTransport, (channel: any) => {
@@ -92,11 +116,11 @@ function setRememberAccount(): void {
 // });
 // });
 
 
 function qtAction(value: any) {
 function qtAction(value: any) {
-    if (qtWebChannel) {
-        qtWebChannel.handleCmd('action');
-    } else {
-        alert('qtWebChannel is null');
-    }
+    // if (qtWebChannel) {
+    //     qtWebChannel.handleCmd('action');
+    // } else {
+    //     alert('qtWebChannel is null');
+    // }
 }
 }
 
 
 export default defineComponent({
 export default defineComponent({
@@ -154,16 +178,16 @@ export default defineComponent({
                 });
                 });
         };
         };
         onMounted(() => {
         onMounted(() => {
-            setTimeout(() => {
-                if (qtWebChannel) {
-                    qtWebChannel.operateResult.connect((response: any) => {
-                        alert(response);
-                        console.log('response', response);
-                    });
-                } else {
-                    alert('qtWebChannel is null!!!!');
-                }
-            });
+            // setTimeout(() => {
+            //     if (qtWebChannel) {
+            //         qtWebChannel.operateResult.connect((response: any) => {
+            //             alert(response);
+            //             console.log('response', response);
+            //         });
+            //     } else {
+            //         alert('qtWebChannel is null!!!!');
+            //     }
+            // });
         });
         });
         return { qtAction, form, loginAction, rules, formDom, loading, goHomeloading, goHome };
         return { qtAction, form, loginAction, rules, formDom, loading, goHomeloading, goHome };
     },
     },