mirror of
https://github.com/xinnan-tech/xiaozhi-esp32-server.git
synced 2026-07-26 17:13:54 +08:00
使用uuid包来生成uuidv4
This commit is contained in:
@@ -11,6 +11,7 @@
|
|||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { computed, onMounted, ref } from "vue";
|
import { computed, onMounted, ref } from "vue";
|
||||||
import { onLoad } from "@dcloudio/uni-app";
|
import { onLoad } from "@dcloudio/uni-app";
|
||||||
|
import { v4 as uuidv4 } from 'uuid';
|
||||||
import { useConfigStore } from "@/store";
|
import { useConfigStore } from "@/store";
|
||||||
import { getEnvBaseUrl, sm2Encrypt } from "@/utils";
|
import { getEnvBaseUrl, sm2Encrypt } from "@/utils";
|
||||||
import { toast } from "@/utils/toast";
|
import { toast } from "@/utils/toast";
|
||||||
@@ -114,18 +115,9 @@ function closeAreaCodeSheet() {
|
|||||||
showAreaCodeSheet.value = false;
|
showAreaCodeSheet.value = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 生成UUID
|
|
||||||
function generateUUID() {
|
|
||||||
return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, (c) => {
|
|
||||||
const r = (Math.random() * 16) | 0;
|
|
||||||
const v = c === "x" ? r : (r & 0x3) | 0x8;
|
|
||||||
return v.toString(16);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
// 获取图形验证码
|
// 获取图形验证码
|
||||||
async function refreshCaptcha() {
|
async function refreshCaptcha() {
|
||||||
const uuid = generateUUID();
|
const uuid = uuidv4();
|
||||||
formData.value.captchaId = uuid;
|
formData.value.captchaId = uuid;
|
||||||
captchaImage.value = `${getEnvBaseUrl()}/user/captcha?uuid=${uuid}&t=${Date.now()}`;
|
captchaImage.value = `${getEnvBaseUrl()}/user/captcha?uuid=${uuid}&t=${Date.now()}`;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,15 +9,16 @@
|
|||||||
</route>
|
</route>
|
||||||
|
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import type { LoginData } from '@/api/auth'
|
import type { LoginData } from '@/api/auth';
|
||||||
import { computed, onMounted, ref } from 'vue'
|
import { computed, onMounted, ref } from 'vue';
|
||||||
import { login } from '@/api/auth'
|
import { v4 as uuidv4 } from 'uuid';
|
||||||
import { useConfigStore } from '@/store'
|
import { login } from '@/api/auth';
|
||||||
import { getEnvBaseUrl } from '@/utils'
|
import { useConfigStore } from '@/store';
|
||||||
import { toast } from '@/utils/toast'
|
import { getEnvBaseUrl } from '@/utils';
|
||||||
|
import { toast } from '@/utils/toast';
|
||||||
// 导入国际化相关功能
|
// 导入国际化相关功能
|
||||||
import { t, changeLanguage, getSupportedLanguages, initI18n } from '@/i18n'
|
import { t, changeLanguage, getSupportedLanguages, initI18n } from '@/i18n';
|
||||||
import type { Language } from '@/store/lang'
|
import type { Language } from '@/store/lang';
|
||||||
// 导入SM2加密工具
|
// 导入SM2加密工具
|
||||||
import { sm2Encrypt } from '@/utils'
|
import { sm2Encrypt } from '@/utils'
|
||||||
|
|
||||||
@@ -123,15 +124,6 @@ function goToForgotPassword() {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// 生成UUID
|
|
||||||
function generateUUID() {
|
|
||||||
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, (c) => {
|
|
||||||
const r = Math.random() * 16 | 0
|
|
||||||
const v = c === 'x' ? r : (r & 0x3 | 0x8)
|
|
||||||
return v.toString(16)
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
let skipReLaunch = false // 全局或组件作用域
|
let skipReLaunch = false // 全局或组件作用域
|
||||||
|
|
||||||
//跳转至服务端设置页面
|
//跳转至服务端设置页面
|
||||||
@@ -143,7 +135,7 @@ function goToServerSetting() {
|
|||||||
|
|
||||||
// 获取验证码
|
// 获取验证码
|
||||||
async function refreshCaptcha() {
|
async function refreshCaptcha() {
|
||||||
const uuid = generateUUID()
|
const uuid = uuidv4();
|
||||||
formData.value.captchaId = uuid
|
formData.value.captchaId = uuid
|
||||||
captchaImage.value = `${getEnvBaseUrl()}/user/captcha?uuid=${uuid}&t=${Date.now()}`
|
captchaImage.value = `${getEnvBaseUrl()}/user/captcha?uuid=${uuid}&t=${Date.now()}`
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,15 +9,16 @@
|
|||||||
</route>
|
</route>
|
||||||
|
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { computed, onMounted, ref } from 'vue'
|
import { computed, onMounted, ref } from 'vue';
|
||||||
import { register, sendSmsCode } from '@/api/auth'
|
import { register, sendSmsCode } from '@/api/auth';
|
||||||
import { useConfigStore } from '@/store'
|
import { v4 as uuidv4 } from 'uuid';
|
||||||
import { getEnvBaseUrl } from '@/utils'
|
import { useConfigStore } from '@/store';
|
||||||
import { toast } from '@/utils/toast'
|
import { getEnvBaseUrl } from '@/utils';
|
||||||
|
import { toast } from '@/utils/toast';
|
||||||
// 导入国际化相关功能
|
// 导入国际化相关功能
|
||||||
import { t, initI18n } from '@/i18n'
|
import { t, initI18n } from '@/i18n';
|
||||||
// 导入SM2加密工具
|
// 导入SM2加密工具
|
||||||
import { sm2Encrypt } from '@/utils'
|
import { sm2Encrypt } from '@/utils';
|
||||||
|
|
||||||
// 获取屏幕边界到安全区域距离
|
// 获取屏幕边界到安全区域距离
|
||||||
let safeAreaInsets
|
let safeAreaInsets
|
||||||
@@ -124,20 +125,11 @@ function closeAreaCodeSheet() {
|
|||||||
showAreaCodeSheet.value = false
|
showAreaCodeSheet.value = false
|
||||||
}
|
}
|
||||||
|
|
||||||
// 生成UUID
|
|
||||||
function generateUUID() {
|
|
||||||
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, (c) => {
|
|
||||||
const r = (Math.random() * 16) | 0
|
|
||||||
const v = c === 'x' ? r : (r & 0x3) | 0x8
|
|
||||||
return v.toString(16)
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
// 获取验证码
|
// 获取验证码
|
||||||
async function refreshCaptcha() {
|
async function refreshCaptcha() {
|
||||||
const uuid = generateUUID()
|
const uuid = uuidv4();
|
||||||
formData.value.captchaId = uuid
|
formData.value.captchaId = uuid;
|
||||||
captchaImage.value = `${getEnvBaseUrl()}/user/captcha?uuid=${uuid}&t=${Date.now()}`
|
captchaImage.value = `${getEnvBaseUrl()}/user/captcha?uuid=${uuid}&t=${Date.now()}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 发送短信验证码
|
// 发送短信验证码
|
||||||
|
|||||||
Generated
+20
-5
@@ -17,6 +17,7 @@
|
|||||||
"opus-decoder": "^0.7.7",
|
"opus-decoder": "^0.7.7",
|
||||||
"opus-recorder": "^8.0.5",
|
"opus-recorder": "^8.0.5",
|
||||||
"sm-crypto": "^0.3.13",
|
"sm-crypto": "^0.3.13",
|
||||||
|
"uuid": "^13.0.0",
|
||||||
"vue": "^2.6.14",
|
"vue": "^2.6.14",
|
||||||
"vue-axios": "^3.5.2",
|
"vue-axios": "^3.5.2",
|
||||||
"vue-i18n": "^8.28.2",
|
"vue-i18n": "^8.28.2",
|
||||||
@@ -9404,6 +9405,16 @@
|
|||||||
"node": ">= 0.12"
|
"node": ">= 0.12"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/request/node_modules/uuid": {
|
||||||
|
"version": "3.4.0",
|
||||||
|
"resolved": "https://registry.npmmirror.com/uuid/-/uuid-3.4.0.tgz",
|
||||||
|
"integrity": "sha512-HjSDRw6gZE5JMggctHBcjVak08+KEVhSIiDzFnT9S9aegmp85S/bReBVTb4QTFaRNptJ9kuYaNhnbNEOkbKb/A==",
|
||||||
|
"deprecated": "Please upgrade to version 7 or higher. Older versions may use Math.random() in certain circumstances, which is known to be problematic. See https://v8.dev/blog/math-random for details.",
|
||||||
|
"license": "MIT",
|
||||||
|
"bin": {
|
||||||
|
"uuid": "bin/uuid"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/require-directory": {
|
"node_modules/require-directory": {
|
||||||
"version": "2.1.1",
|
"version": "2.1.1",
|
||||||
"resolved": "https://registry.npmmirror.com/require-directory/-/require-directory-2.1.1.tgz",
|
"resolved": "https://registry.npmmirror.com/require-directory/-/require-directory-2.1.1.tgz",
|
||||||
@@ -11097,12 +11108,16 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/uuid": {
|
"node_modules/uuid": {
|
||||||
"version": "3.4.0",
|
"version": "13.0.0",
|
||||||
"resolved": "https://registry.npmmirror.com/uuid/-/uuid-3.4.0.tgz",
|
"resolved": "https://registry.npmmirror.com/uuid/-/uuid-13.0.0.tgz",
|
||||||
"integrity": "sha512-HjSDRw6gZE5JMggctHBcjVak08+KEVhSIiDzFnT9S9aegmp85S/bReBVTb4QTFaRNptJ9kuYaNhnbNEOkbKb/A==",
|
"integrity": "sha512-XQegIaBTVUjSHliKqcnFqYypAd4S+WCYt5NIeRs6w/UAry7z8Y9j5ZwRRL4kzq9U3sD6v+85er9FvkEaBpji2w==",
|
||||||
"deprecated": "Please upgrade to version 7 or higher. Older versions may use Math.random() in certain circumstances, which is known to be problematic. See https://v8.dev/blog/math-random for details.",
|
"funding": [
|
||||||
|
"https://github.com/sponsors/broofa",
|
||||||
|
"https://github.com/sponsors/ctavan"
|
||||||
|
],
|
||||||
|
"license": "MIT",
|
||||||
"bin": {
|
"bin": {
|
||||||
"uuid": "bin/uuid"
|
"uuid": "dist-node/bin/uuid"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/validate-npm-package-license": {
|
"node_modules/validate-npm-package-license": {
|
||||||
|
|||||||
@@ -17,6 +17,7 @@
|
|||||||
"opus-decoder": "^0.7.7",
|
"opus-decoder": "^0.7.7",
|
||||||
"opus-recorder": "^8.0.5",
|
"opus-recorder": "^8.0.5",
|
||||||
"sm-crypto": "^0.3.13",
|
"sm-crypto": "^0.3.13",
|
||||||
|
"uuid": "^13.0.0",
|
||||||
"vue": "^2.6.14",
|
"vue": "^2.6.14",
|
||||||
"vue-axios": "^3.5.2",
|
"vue-axios": "^3.5.2",
|
||||||
"vue-i18n": "^8.28.2",
|
"vue-i18n": "^8.28.2",
|
||||||
|
|||||||
Reference in New Issue
Block a user