多语言
This commit is contained in:
parent
81124a6329
commit
2f7a8e90e5
|
|
@ -0,0 +1,9 @@
|
||||||
|
# 页面标题
|
||||||
|
VITE_APP_TITLE=里派基础框架
|
||||||
|
|
||||||
|
# 开发环境配置
|
||||||
|
VITE_APP_ENV='development'
|
||||||
|
|
||||||
|
# 开发环境
|
||||||
|
VITE_API_BASE='https://dev.api.leapy.cn/merchant/'
|
||||||
|
VITE_WS_URL='wss://dev.api.leapy.cn/mms'
|
||||||
|
|
@ -0,0 +1,9 @@
|
||||||
|
# 页面标题
|
||||||
|
VITE_APP_TITLE=里派基础框架
|
||||||
|
|
||||||
|
# 生产环境配置
|
||||||
|
VITE_APP_ENV='production'
|
||||||
|
|
||||||
|
# 生产环境
|
||||||
|
VITE_API_BASE='https://dev.api.leapy.cn/merchant/'
|
||||||
|
VITE_WS_URL='wss://dev.api.leapy.cn/mms'
|
||||||
|
|
@ -19,4 +19,5 @@ dist
|
||||||
*.njsproj
|
*.njsproj
|
||||||
*.sln
|
*.sln
|
||||||
*.sw?
|
*.sw?
|
||||||
yarn.lock
|
yarn.lock
|
||||||
|
package-lock.json
|
||||||
|
|
@ -0,0 +1,21 @@
|
||||||
|
MIT License
|
||||||
|
|
||||||
|
Copyright (c) 2025 leapy
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
in the Software without restriction, including without limitation the rights
|
||||||
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
|
furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in all
|
||||||
|
copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
SOFTWARE.
|
||||||
|
|
@ -50,6 +50,7 @@
|
||||||
"@dcloudio/uni-mp-weixin": "3.0.0-4030620241128001",
|
"@dcloudio/uni-mp-weixin": "3.0.0-4030620241128001",
|
||||||
"@dcloudio/uni-mp-xhs": "3.0.0-4030620241128001",
|
"@dcloudio/uni-mp-xhs": "3.0.0-4030620241128001",
|
||||||
"@dcloudio/uni-quickapp-webview": "3.0.0-4030620241128001",
|
"@dcloudio/uni-quickapp-webview": "3.0.0-4030620241128001",
|
||||||
|
"crypto-js": "^4.2.0",
|
||||||
"pinia": "^3.0.3",
|
"pinia": "^3.0.3",
|
||||||
"pinia-plugin-persistedstate": "^4.3.0",
|
"pinia-plugin-persistedstate": "^4.3.0",
|
||||||
"vue": "^3.4.21",
|
"vue": "^3.4.21",
|
||||||
|
|
@ -61,6 +62,7 @@
|
||||||
"@dcloudio/uni-cli-shared": "3.0.0-4030620241128001",
|
"@dcloudio/uni-cli-shared": "3.0.0-4030620241128001",
|
||||||
"@dcloudio/uni-stacktracey": "3.0.0-4030620241128001",
|
"@dcloudio/uni-stacktracey": "3.0.0-4030620241128001",
|
||||||
"@dcloudio/vite-plugin-uni": "3.0.0-4030620241128001",
|
"@dcloudio/vite-plugin-uni": "3.0.0-4030620241128001",
|
||||||
|
"@types/crypto-js": "^4.2.2",
|
||||||
"@vue/runtime-core": "^3.4.21",
|
"@vue/runtime-core": "^3.4.21",
|
||||||
"@vue/tsconfig": "^0.1.3",
|
"@vue/tsconfig": "^0.1.3",
|
||||||
"typescript": "^4.9.4",
|
"typescript": "^4.9.4",
|
||||||
|
|
|
||||||
11
src/App.vue
11
src/App.vue
|
|
@ -1,13 +1,8 @@
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { onLaunch, onShow, onHide } from "@dcloudio/uni-app";
|
import {onLaunch} from "@dcloudio/uni-app";
|
||||||
|
|
||||||
onLaunch(() => {
|
onLaunch(() => {
|
||||||
console.log("App Launch");
|
console.log('%c PI %c 里派提供技术支持', 'background:#4caf50;color:#fff;border-radius:3px;', '')
|
||||||
});
|
|
||||||
onShow(() => {
|
|
||||||
console.log("App Show");
|
|
||||||
});
|
|
||||||
onHide(() => {
|
|
||||||
console.log("App Hide");
|
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
<style></style>
|
<style></style>
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,6 @@
|
||||||
|
{
|
||||||
|
"system.title": "hello",
|
||||||
|
"index": {
|
||||||
|
"title": "user"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
import {createI18n} from 'vue-i18n'
|
import {createI18n} from 'vue-i18n'
|
||||||
|
|
||||||
import en from './lang/en'
|
import en from './en.json'
|
||||||
import zhHans from './lang/zh-cn'
|
import zhHans from './zh-Hans.json'
|
||||||
|
|
||||||
const messages = {
|
const messages = {
|
||||||
en,
|
en,
|
||||||
|
|
@ -9,9 +9,9 @@ const messages = {
|
||||||
}
|
}
|
||||||
|
|
||||||
const i18n = createI18n({
|
const i18n = createI18n({
|
||||||
|
legacy: false,
|
||||||
locale: uni.getLocale(),
|
locale: uni.getLocale(),
|
||||||
messages,
|
messages
|
||||||
legacy: false
|
|
||||||
})
|
})
|
||||||
|
|
||||||
export default i18n;
|
export default i18n;
|
||||||
|
|
@ -0,0 +1,6 @@
|
||||||
|
{
|
||||||
|
"system.title": "你好",
|
||||||
|
"index": {
|
||||||
|
"title": "用户"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -1,5 +0,0 @@
|
||||||
export default {
|
|
||||||
system: {
|
|
||||||
title: 'hello',
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
@ -1,5 +0,0 @@
|
||||||
export default {
|
|
||||||
system: {
|
|
||||||
title: '你好',
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
@ -1,8 +1,8 @@
|
||||||
import { createSSRApp } from "vue";
|
import { createSSRApp } from "vue";
|
||||||
import App from "./App.vue";
|
import App from "./App.vue";
|
||||||
import pinia from "@/stores";
|
import pinia from "@/store";
|
||||||
import * as Pinia from 'pinia';
|
import * as Pinia from 'pinia';
|
||||||
import i18n from "@/locales";
|
import i18n from "@/locale";
|
||||||
|
|
||||||
export function createApp() {
|
export function createApp() {
|
||||||
const app = createSSRApp(App);
|
const app = createSSRApp(App);
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,12 @@
|
||||||
{
|
{
|
||||||
"name" : "",
|
"name" : "user",
|
||||||
"appid" : "",
|
"appid" : "__UNI__8385663",
|
||||||
"description" : "",
|
"description" : "",
|
||||||
"versionName" : "1.0.0",
|
"versionName" : "1.0.0",
|
||||||
"versionCode" : "100",
|
"versionCode" : "100",
|
||||||
|
"locale": "zh-Hans",
|
||||||
"transformPx" : false,
|
"transformPx" : false,
|
||||||
|
"debug": true,
|
||||||
/* 5+App特有相关 */
|
/* 5+App特有相关 */
|
||||||
"app-plus" : {
|
"app-plus" : {
|
||||||
"usingComponents" : true,
|
"usingComponents" : true,
|
||||||
|
|
@ -50,7 +52,7 @@
|
||||||
"quickapp" : {},
|
"quickapp" : {},
|
||||||
/* 小程序特有相关 */
|
/* 小程序特有相关 */
|
||||||
"mp-weixin" : {
|
"mp-weixin" : {
|
||||||
"appid" : "",
|
"appid" : "wxb6b7d1cc569581b2",
|
||||||
"setting" : {
|
"setting" : {
|
||||||
"urlCheck" : false
|
"urlCheck" : false
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@
|
||||||
{
|
{
|
||||||
"path": "pages/index/index",
|
"path": "pages/index/index",
|
||||||
"style": {
|
"style": {
|
||||||
"navigationBarTitleText": "uni-app"
|
"navigationBarTitleText": "%system.title%"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
|
|
||||||
|
|
@ -12,9 +12,8 @@ import {ref} from 'vue'
|
||||||
import {useI18n} from 'vue-i18n'
|
import {useI18n} from 'vue-i18n'
|
||||||
|
|
||||||
const {t, locale} = useI18n()
|
const {t, locale} = useI18n()
|
||||||
const title = ref(t('system.title'))
|
const title = ref(t('index.title'))
|
||||||
|
|
||||||
console.log(title)
|
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,62 @@
|
||||||
|
import CryptoJS from 'crypto-js'
|
||||||
|
|
||||||
|
const tools = {
|
||||||
|
data: {
|
||||||
|
set(cacheKey: string, data: any, expireIn: number = 0) {
|
||||||
|
let cacheValue = {
|
||||||
|
content: data,
|
||||||
|
expireIn: expireIn === 0 ? 0 : new Date().getTime() + expireIn * 1000
|
||||||
|
}
|
||||||
|
return uni.setStorageSync(cacheKey, tools.base64.encrypt(JSON.stringify(cacheValue)))
|
||||||
|
},
|
||||||
|
get(cacheKey: string) {
|
||||||
|
try {
|
||||||
|
const cacheValue = JSON.parse(tools.base64.decrypt(uni.getStorageSync(cacheKey)))
|
||||||
|
if (cacheValue) {
|
||||||
|
let nowTime = new Date().getTime()
|
||||||
|
if (nowTime > cacheValue.expireIn && cacheValue.expireIn !== 0) {
|
||||||
|
uni.removeStorageSync(cacheKey)
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return cacheValue.content
|
||||||
|
}
|
||||||
|
return null
|
||||||
|
} catch (err) {
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
},
|
||||||
|
remove(cacheKey: string) {
|
||||||
|
return uni.removeStorageSync(cacheKey)
|
||||||
|
},
|
||||||
|
clear() {
|
||||||
|
return uni.clearStorageSync()
|
||||||
|
}
|
||||||
|
},
|
||||||
|
base64: {
|
||||||
|
encrypt(data: string) {
|
||||||
|
return CryptoJS.enc.Base64.stringify(CryptoJS.enc.Utf8.parse(data))
|
||||||
|
},
|
||||||
|
decrypt(cipher: string) {
|
||||||
|
return CryptoJS.enc.Base64.parse(cipher).toString(CryptoJS.enc.Utf8)
|
||||||
|
}
|
||||||
|
},
|
||||||
|
go: async function (fn: Function) {
|
||||||
|
try {
|
||||||
|
let res = await fn
|
||||||
|
return [res, null]
|
||||||
|
} catch (err) {
|
||||||
|
return [null, err]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
crypto: {
|
||||||
|
//MD5加密
|
||||||
|
MD5(data: string) {
|
||||||
|
return CryptoJS.MD5(data).toString()
|
||||||
|
},
|
||||||
|
},
|
||||||
|
objCopy: function (obj: any) {
|
||||||
|
return JSON.parse(JSON.stringify(obj));
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
export default tools
|
||||||
|
|
@ -9,5 +9,5 @@
|
||||||
"lib": ["esnext", "dom"],
|
"lib": ["esnext", "dom"],
|
||||||
"types": ["@dcloudio/types"]
|
"types": ["@dcloudio/types"]
|
||||||
},
|
},
|
||||||
"include": ["src/**/*.ts", "src/**/*.d.ts", "src/**/*.tsx", "src/**/*.vue"]
|
"include": ["src/**/*.ts", "src/**/*.d.ts", "src/**/*.tsx", "src/**/*.vue", "src/**/*.json"]
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue