From bccdb8f81c07c8a9cdcd6838173dfd1c73c98d90 Mon Sep 17 00:00:00 2001
From: zhou zhou <3272660260@qq.com>
Date: 星期四, 26 二月 2026 16:05:30 +0800
Subject: [PATCH] #
---
main.js | 87 ++++++++++++++++++++++++++-----------------
1 files changed, 53 insertions(+), 34 deletions(-)
diff --git a/main.js b/main.js
index af98bb7..9308a85 100644
--- a/main.js
+++ b/main.js
@@ -1,50 +1,69 @@
import App from './App'
+import messages from './locale/index.js'
+
+let i18nConfig = {
+ locale: uni.getLocale(), // 鑾峰彇宸茶缃殑璇█
+ messages
+}
// #ifndef VUE3
import Vue from 'vue'
+import './uni.promisify.adaptor'
Vue.config.productionTip = false
App.mpType = 'app'
-try {
- function isPromise(obj) {
- return (
- !!obj &&
- (typeof obj === "object" || typeof obj === "function") &&
- typeof obj.then === "function"
- );
- }
+import VueI18n from 'vue-i18n'
+Vue.use(VueI18n)
- // 缁熶竴 vue2 API Promise 鍖栬繑鍥炴牸寮忎笌 vue3 淇濇寔涓�鑷�
- uni.addInterceptor({
- returnValue(res) {
- if (!isPromise(res)) {
- return res;
- }
- return new Promise((resolve, reject) => {
- res.then((res) => {
- if (res[0]) {
- reject(res[0]);
- } else {
- resolve(res[1]);
- }
- });
- });
- },
- });
-} catch (error) { }
+import uView from '@/uni_modules/uview-ui'
+Vue.use(uView)
-const app = new Vue({
- ...App
+Vue.mixin({
+ methods: {
+ $showToast(options) {
+ if (this.$refs.uToast) {
+ this.$refs.uToast.show(options);
+ } else {
+ // Fallback if component not found or loaded yet
+ uni.$u.toast(typeof options === 'string' ? options : (options.message || options.title));
+ }
+ }
+ }
})
+
+const i18n = new VueI18n(i18nConfig)
+const app = new Vue({
+ ...App,
+ i18n
+})
+
+// 寮曞叆璇锋眰灏佽锛屽皢app鍙傛暟浼犻�掑埌閰嶇疆涓�
+require('./config/request.js')(app)
+
app.$mount()
// #endif
// #ifdef VUE3
-import { createSSRApp } from 'vue'
+import {
+ createSSRApp
+} from 'vue'
+import uView from '@/uni_modules/uview-ui'
export function createApp() {
- const app = createSSRApp(App)
- return {
- app
- }
+ const app = createSSRApp(App)
+ app.use(uView)
+ app.mixin({
+ methods: {
+ $showToast(options) {
+ if (this.$refs.uToast) {
+ this.$refs.uToast.show(options);
+ } else {
+ uni.$u.toast(typeof options === 'string' ? options : (options.message || options.title));
+ }
+ }
+ }
+ })
+ return {
+ app
+ }
}
-// #endif
\ No newline at end of file
+// #endif
--
Gitblit v1.9.1