Harin桑麻
Harin桑麻
  • 发布:2025-03-14 14:53
  • 更新:2025-03-14 14:56
  • 阅读:54

uniapp cli项目,需要访问wifi名称,使用uni-app,但是需要有uts扩展,cli项目应该怎么处理

分类:uni-app

使用uni-wifi,需要有uts扩展。
在打包app时候,报错。
错误信息:
Could not load /l-aicam/src/uni_modules/uni-wifi?uts-proxy (imported by src/App.vue?vue&type=script&setup=true&lang.ts): ENOENT: no such file or directory, open '/l-aicam/src/uni_modules/uni-wifi?uts-proxy'

----package.json

{  
    "name": "tmui",  
    "version": "3.0.0",  
    "scripts": {  
        "buildIndex": "node vue-sfc-doc/autobuildIndex.js",  
        "buildDoc": "node vue-sfc-doc/index.js",  
        "dabao": "node buildTmui/build.js 3.2.0",  
        "dev:app": "uni -p app",  
        "dev:custom": "uni -p",  
        "dev:h5": "uni",  
        "dev:h5:ssr": "uni --ssr",  
        "dev:mp-alipay": "uni -p mp-alipay",  
        "dev:mp-baidu": "uni -p mp-baidu",  
        "dev:mp-kuaishou": "uni -p mp-kuaishou",  
        "dev:mp-lark": "uni -p mp-lark",  
        "dev:mp-qq": "uni -p mp-qq",  
        "dev:mp-toutiao": "uni -p mp-toutiao",  
        "dev:mp-weixin": "uni -p mp-weixin",  
        "dev:quickapp-webview": "uni -p quickapp-webview",  
        "dev:quickapp-webview-huawei": "uni -p quickapp-webview-huawei",  
        "dev:quickapp-webview-union": "uni -p quickapp-webview-union",  
        "build:app": "uni build -p app",  
        "build:custom": "uni build -p",  
        "build:h5": "uni build",  
        "build:h5:ssr": "uni build --ssr",  
        "build:mp-alipay": "uni build -p mp-alipay",  
        "build:mp-baidu": "uni build -p mp-baidu",  
        "build:mp-kuaishou": "uni build -p mp-kuaishou",  
        "build:mp-lark": "uni build -p mp-lark",  
        "build:mp-qq": "uni build -p mp-qq",  
        "build:mp-toutiao": "uni build -p mp-toutiao",  
        "build:mp-weixin": "uni build -p mp-weixin",  
        "build:quickapp-webview": "uni build -p quickapp-webview",  
        "build:quickapp-webview-huawei": "uni build -p quickapp-webview-huawei",  
        "build:quickapp-webview-union": "uni build -p quickapp-webview-union"  
    },  
    "dependencies": {  
        "@dcloudio/uni-app": "3.0.0-4030620241128001",  
        "@dcloudio/uni-app-plus": "3.0.0-4030620241128001",  
        "@dcloudio/uni-components": "3.0.0-4030620241128001",  
        "@dcloudio/uni-h5": "3.0.0-4030620241128001",  
        "@dcloudio/uni-helper-json": "^1.0.13",  
        "@dcloudio/uni-mp-alipay": "3.0.0-4030620241128001",  
        "@dcloudio/uni-mp-baidu": "3.0.0-4030620241128001",  
        "@dcloudio/uni-mp-kuaishou": "3.0.0-4030620241128001",  
        "@dcloudio/uni-mp-lark": "3.0.0-4030620241128001",  
        "@dcloudio/uni-mp-qq": "3.0.0-4030620241128001",  
        "@dcloudio/uni-mp-toutiao": "3.0.0-4030620241128001",  
        "@dcloudio/uni-mp-weixin": "3.0.0-4030620241128001",  
        "@dcloudio/uni-quickapp-webview": "3.0.0-4030620241128001",  
        "@vue/compiler-core": "^3.5.11",  
        "echarts": "5.4.2",  
        "pinia": "^2.0.33",  
        "sass": "^1.77.5",  
        "vue": "^3.3.11",  
        "vue-docgen-api": "^4.79.2",  
        "vue-i18n": "9.2.2"  
    },  
    "devDependencies": {  
        "@dcloudio/types": "^3.4.12",  
        "@dcloudio/uni-automator": "3.0.0-4030620241128001",  
        "@dcloudio/uni-cli-shared": "3.0.0-4030620241128001",  
        "@dcloudio/vite-plugin-uni": "3.0.0-4030620241128001",  
        "@types/node": "^18.0.0",  
        "@vue/runtime-core": "^3.3.11",  
        "@vue/tsconfig": "^0.1.3",  
        "autoprefixer": "10.4.14",  
        "typescript": "^5.4.5",  
        "unplugin-vue-components": "^0.27.4",  
        "vite": "^5.2.8",  
        "vue-tsc": "^1.0.24"  
    }  
}

---vite.config.ts

import { defineConfig } from "vite";  
import uni from "@dcloudio/vite-plugin-uni";  
import vueJsx from "@vitejs/plugin-vue-jsx";  
import { resolve } from "path"  
import Components from "unplugin-vue-components/vite"  
export default defineConfig({  
    define: {  
        __VUE_I18N_FULL_INSTALL__: true,  
        __VUE_I18N_LEGACY_API__: true,  
        __VUE_I18N_PROD_DEVTOOLS__: false,  
    },  
    build: {  
        target: ["es2015", "chrome100", "safari15"],  
        minify: 'terser',  
        terserOptions: {  
            compress: {  
                drop_console: true,  
                drop_debugger: true  
            }  
        }  
    },  
    css: {  
        preprocessorOptions: {  
            scss: {  
                api: 'modern-compiler',  
                silenceDeprecations: ['legacy-js-api']  
            }  
        }  
    },  
    resolve: {  
        alias: [  
            {  
                find: "@",  
                replacement: resolve(__dirname, 'src')  
            }  
        ]  
    },  
    server: {  
        port: 1314,  
        // 选项写法  
        proxy: {  
            '/pag': {  
                target: 'https://cdn.tmui.design',  
                changeOrigin: true,  
                rewrite: (path) => path.replace(/^\/api/, '/api')  
            },  
        }  
    },  
    plugins: [  
        uni(),  
        vueJsx(),  
        Components({  
            dts: true,  
            resolvers: [  
                // example of importing Vant  
                (componentName) => {  
                    if (componentName.startsWith('tm')) {  
                        return { name: componentName.slice(2), from: 'tm' }  
                    }  
                },  
            ],  
            dirs: ['./src/uni_modules/tm-ui/components'],  
            include: [/\.vue$/, /\.uvue$/]  
        }),  
        {  
            name: 'build-optimize',  
            enforce: 'post',  
            apply: 'build'  
        }  
    ]  
});
2025-03-14 14:53 负责人:无 分享
已邀请:
DCloud_UNI_FengXY

DCloud_UNI_FengXY

手动安装依赖:
"@dcloudio/uni-uts-v1": "3.0.0-4030620241128001"

在HBuilderX中运行,打包。

要回复问题请先登录注册