liyongli 15 tuntia sitten
vanhempi
commit
e52c2f03a5

+ 24 - 0
src/view/fenghui/demo.html

@@ -0,0 +1,24 @@
+<!DOCTYPE html>
+<html>
+<head>
+    <meta charset="utf-8">
+    <title>WASM Encryption Demo</title>
+</head>
+<body>
+<script type="module">
+    import init, {encrypt, decrypt} from "./pkg/wasm_encrypt.min.js";
+
+    async function run() {
+        await init();  // 初始化 wasm 模块
+
+        const obj = { foo: 123, bar: "hello" };
+        const token = encrypt(obj);
+        console.log(token);
+        const back  = decrypt(token);
+        console.log(back);
+    }
+
+    run();
+</script>
+</body>
+</html>

+ 38 - 19
src/view/fenghui/introduction.vue

@@ -149,7 +149,8 @@
             </g>
         </svg>
         <h4 class="text" style="font-size: 1.5rem;" v-text="lang[langType].title"></h4>
-        <div style="font-size: 1rem;margin-bottom: 30px;color: rgba(255,255,255,0.9);" class="text" v-html="lang[langType].marstContent"></div>
+        <div style="font-size: 1rem;margin-bottom: 30px;color: rgba(255,255,255,0.9);" class="text"
+            v-html="lang[langType].marstContent"></div>
 
         <h4 class="text" style="font-size: 1.2rem;" v-text="lang[langType].wrestleMania"></h4>
         <p class="text" style="color: rgba(255,255,255,0.9);" v-html="lang[langType].wrestleManiaContent"></p>
@@ -157,7 +158,8 @@
         <h4 class="text" style="font-size: 1.2rem;" v-text="lang[langType].venue"></h4>
         <p class="text" style="color: rgba(255,255,255,0.9);" v-html="lang[langType].venueContent"></p>
         <div class="line"></div>
-        <h4 class="text"  style="font-size: 1.2rem;color: rgba(255,255,255,0.9);" v-text="lang[langType].organization"></h4>
+        <h4 class="text" style="font-size: 1.2rem;color: rgba(255,255,255,0.9);" v-text="lang[langType].organization">
+        </h4>
         <van-row style="color: rgba(255,255,255,0.9);">
             <van-col span="8">
                 <div class="text" v-text="lang[langType].organizationSub1"></div>
@@ -186,9 +188,9 @@
 
         <p class="tologo" v-html="lang[langType].tologoText + '>>'" @click="showLogin = true"></p>
         <p class="tologo" style="margin-top: 1em;margin-bottom: 1em;font-size: 0.9rem;color: rgba(255,255,255,0.8)">
-            {{lang[langType].technicalAdvice}}
+            {{ lang[langType].technicalAdvice }}
         </p>
-        
+
         <!-- 邀请码校验 -->
         <van-dialog destroy-on-close :confirmButtonText="lang[langType].confirm"
             :cancelButtonText="lang[langType].cancel" @confirm="checkVerificationCode" v-model:show="showCheck"
@@ -201,9 +203,9 @@
             <br />
             <van-form @submit="saveLogin">
                 <van-cell-group inset>
-                    <van-field size="large" v-model="form.verificationCode" name="verificationCode" :label="lang[langType].verificationCode"
-                        :placeholder="lang[langType].verificationCodeContent" required
-                        :rules="[{ required: true, message: lang[langType].verificationCodeContent }]" />
+                    <van-field size="large" v-model="form.verificationCode" name="verificationCode"
+                        :label="lang[langType].verificationCode" :placeholder="lang[langType].verificationCodeContent"
+                        required :rules="[{ required: true, message: lang[langType].verificationCodeContent }]" />
                     <van-field size="large" v-model="form.password" name="password" :label="lang[langType].passport"
                         :placeholder="lang[langType].passportContent" required
                         :rules="[{ required: true, message: lang[langType].passportContent }]" />
@@ -218,9 +220,10 @@
     </div>
 </template>
 <script setup>
-import { defineProps, ref, defineEmits, reactive } from 'vue';
+import { defineProps, ref, defineEmits, reactive, onMounted } from 'vue';
 import { checkCode, getUserInfo } from '@/api/2025.js';
 import { showToast } from 'vant';
+import init, { encrypt, decrypt } from "./wasm_encrypt.min.js";
 import lang from './lang.js';
 const showCheck = ref(false);
 const verificationCode = ref('');
@@ -230,40 +233,56 @@ const props = defineProps(['langType']);
 const emits = defineEmits(['saveData']);
 let code = '';
 
+onMounted(async () => {
+    await init();
+})
+
 const checkVerificationCode = () => {
     let userType = lang[props.langType].distinguishedGuest[code];
-    checkCode({
+    const RCode = Math.random().toString(32).substring(2, 15);
+    const data = encrypt({
         code: verificationCode.value.toLowerCase(),
-        userType
+        userType,
+        randomCode: RCode
+    })
+    checkCode({
+        token: data
     }).then((res) => {
-        if (!isNaN(res.code) && res.code !== 0) {
-            showToast(res.msg || lang[props.langType].verificationCodeError);
+        const token = decrypt(res.token).randomCode
+        if (token !== RCode) {
+            showToast(lang[props.langType].verificationCodeError);
             return;
         }
         emits('saveData', code, verificationCode.value.toLowerCase());
     }).catch((res) => {
+        console.log(res);
         showToast(res.msg || lang[props.langType].verificationCodeError);
     })
 }
 
 const saveLogin = () => {
-    getUserInfo({
+    const RCode = Math.random().toString(32).substring(2, 15);
+    const data = encrypt({
         "code": form.verificationCode,
-        "idCard": form.password
+        "idCard": form.password,
+        randomCode: RCode
+    })
+    getUserInfo({
+        token: data
     }).then((res) => {
-        if (!isNaN(res.code) && res.code !== 0) {
-            showToast(res.msg || lang[props.langType].networkError);
+        const token = decrypt(res.token)
+        if (token.randomCode !== RCode) {
+            showToast(lang[props.langType].verificationCodeError);
             return;
         }
-        
-        const userType = res.userType;
+        const userType = token.userType;
         const keysList = Object.keys(lang[props.langType].distinguishedGuest); // 获取对象的所有键名组成的数组
         for (let ii = 0; ii < keysList.length; ii++) {
             const keys = keysList[ii];
             const value = lang[props.langType].distinguishedGuest[keys];  // 获取对象的所有键名组成的数组
             value === userType ? code = keys + 'Recurrence' : '';
         }
-        emits('saveData', code, form.verificationCode.toLowerCase(), res);
+        emits('saveData', code, form.verificationCode.toLowerCase(), token);
     }).catch((res) => {
         showToast(res.msg || lang[props.langType].networkError);
     })

Tiedoston diff-näkymää rajattu, sillä se on liian suuri
+ 0 - 0
src/view/fenghui/wasm_encrypt.min.js


Kaikkia tiedostoja ei voida näyttää, sillä liian monta tiedostoa muuttui tässä diffissä