chore: 升级依赖并重构项目配置

- 更新多个依赖到最新版本,包括 uni-app、alova、pinia、tailwindcss 等
- 移除 postcss.config.ts 配置文件
- 调整 vite 配置和 tailwindcss 引入方式
- 更新 App.vue 和 main.ts 中的样式引入
- 优化 stores 中的 defineStore 使用方式
- 新增 src/styles/main.css 文件
This commit is contained in:
h_mo 2025-03-12 15:47:23 +08:00
parent 4aa9201989
commit dce5d85f65
17 changed files with 55 additions and 67 deletions

BIN
.DS_Store vendored Normal file

Binary file not shown.

4
.npmrc
View File

@ -2,5 +2,5 @@
# 提示:如果你不希望pnpm在对等依赖问题上失败在项目根目录下的.npmrc文件中添加"strict-peer-dependencies=false"。 # 提示:如果你不希望pnpm在对等依赖问题上失败在项目根目录下的.npmrc文件中添加"strict-peer-dependencies=false"。
# auto-install-peers=true # auto-install-peers=true
strict-peer-dependencies=false strict-peer-dependencies=false
registry=https://registry.npmmirror.com # registry=https://registry.npmmirror.com
# registry=https://registry.npmjs.org registry=https://registry.npmjs.org

View File

@ -1,5 +1,6 @@
import type { PluginOption } from 'vite'; import type { PluginOption } from 'vite';
import uni from '@dcloudio/vite-plugin-uni'; import uni from '@dcloudio/vite-plugin-uni';
import tailwindcss from '@tailwindcss/vite';
import { visualizer } from 'rollup-plugin-visualizer'; import { visualizer } from 'rollup-plugin-visualizer';
import autoImport from 'unplugin-auto-import/vite'; import autoImport from 'unplugin-auto-import/vite';
import viteRestart from 'vite-plugin-restart'; import viteRestart from 'vite-plugin-restart';
@ -14,6 +15,7 @@ export function createVitePlugins({ isProd }: VitePluginConfig): PluginOption[]
return [ return [
// @ts-expect-error TODO uni() 会报错uni is not a function,暂时使用此方式解决 // @ts-expect-error TODO uni() 会报错uni is not a function,暂时使用此方式解决
uni?.default(), uni?.default(),
tailwindcss(),
uvtw({ uvtw({
rem2rpx: true, rem2rpx: true,
disabled: WeappTailwindcssDisabled, disabled: WeappTailwindcssDisabled,

View File

@ -44,64 +44,64 @@
}, },
"dependencies": { "dependencies": {
"@alova/adapter-uniapp": "^2.0.11", "@alova/adapter-uniapp": "^2.0.11",
"@alova/mock": "^2.0.11", "@alova/mock": "^2.0.12",
"@alova/shared": "^1.1.2", "@alova/shared": "^1.1.2",
"@dcloudio/uni-app": "3.0.0-alpha-4040220241217001", "@dcloudio/uni-app": "3.0.0-alpha-4050320250224001",
"@dcloudio/uni-app-plus": "3.0.0-alpha-4040220241217001", "@dcloudio/uni-app-plus": "3.0.0-alpha-4050320250224001",
"@dcloudio/uni-components": "3.0.0-alpha-4040220241217001", "@dcloudio/uni-components": "3.0.0-alpha-4050320250224001",
"@dcloudio/uni-h5": "3.0.0-alpha-4040220241217001", "@dcloudio/uni-h5": "3.0.0-alpha-4050320250224001",
"@dcloudio/uni-i18n": "3.0.0-alpha-4040220241217001", "@dcloudio/uni-i18n": "3.0.0-alpha-4050320250224001",
"@dcloudio/uni-mp-alipay": "3.0.0-alpha-4040220241217001", "@dcloudio/uni-mp-alipay": "3.0.0-alpha-4050320250224001",
"@dcloudio/uni-mp-baidu": "3.0.0-alpha-4040220241217001", "@dcloudio/uni-mp-baidu": "3.0.0-alpha-4050320250224001",
"@dcloudio/uni-mp-kuaishou": "3.0.0-alpha-4040220241217001", "@dcloudio/uni-mp-kuaishou": "3.0.0-alpha-4050320250224001",
"@dcloudio/uni-mp-lark": "3.0.0-alpha-4040220241217001", "@dcloudio/uni-mp-lark": "3.0.0-alpha-4050320250224001",
"@dcloudio/uni-mp-qq": "3.0.0-alpha-4040220241217001", "@dcloudio/uni-mp-qq": "3.0.0-alpha-4050320250224001",
"@dcloudio/uni-mp-toutiao": "3.0.0-alpha-4040220241217001", "@dcloudio/uni-mp-toutiao": "3.0.0-alpha-4050320250224001",
"@dcloudio/uni-mp-weixin": "3.0.0-alpha-4040220241217001", "@dcloudio/uni-mp-weixin": "3.0.0-alpha-4050320250224001",
"@dcloudio/uni-quickapp-webview": "3.0.0-alpha-4040220241217001", "@dcloudio/uni-quickapp-webview": "3.0.0-alpha-4050320250224001",
"@multiavatar/multiavatar": "^1.0.7", "@multiavatar/multiavatar": "^1.0.7",
"alova": "^3.2.7", "alova": "^3.2.10",
"crypto-js": "^4.2.0", "crypto-js": "^4.2.0",
"lodash-es": "^4.17.21", "lodash-es": "^4.17.21",
"pinia": "^2.3.0", "pinia": "^2.3.1",
"vue": "^3.5.13" "vue": "^3.5.13"
}, },
"devDependencies": { "devDependencies": {
"@antfu/eslint-config": "^3.12.0", "@antfu/eslint-config": "^4.8.1",
"@dcloudio/types": "^3.4.14", "@dcloudio/types": "^3.4.14",
"@dcloudio/uni-automator": "3.0.0-alpha-4040220241217001", "@dcloudio/uni-automator": "3.0.0-alpha-4050320250224001",
"@dcloudio/uni-cli-shared": "3.0.0-alpha-4040220241217001", "@dcloudio/uni-cli-shared": "3.0.0-alpha-4050320250224001",
"@dcloudio/uni-stacktracey": "3.0.0-alpha-4040220241217001", "@dcloudio/uni-stacktracey": "3.0.0-alpha-4050320250224001",
"@dcloudio/uni-uts-v1": "3.0.0-alpha-4040220241217001", "@dcloudio/uni-uts-v1": "3.0.0-alpha-4050320250224001",
"@dcloudio/vite-plugin-uni": "3.0.0-alpha-4040220241217001", "@dcloudio/vite-plugin-uni": "3.0.0-alpha-4050320250224001",
"@egoist/tailwindcss-icons": "^1.8.2", "@egoist/tailwindcss-icons": "^1.9.0",
"@iconify/json": "^2.2.287", "@iconify/json": "^2.2.315",
"@rollup/plugin-node-resolve": "^16.0.0", "@rollup/plugin-node-resolve": "^16.0.0",
"@tailwindcss/vite": "^4.0.12",
"@types/crypto-js": "^4.2.2", "@types/crypto-js": "^4.2.2",
"@types/lodash-es": "^4.17.12", "@types/lodash-es": "^4.17.12",
"@types/node": "^22.10.2", "@types/node": "^22.13.10",
"@vitejs/plugin-vue": "^5.2.1", "@vitejs/plugin-vue": "^5.2.1",
"@vue/runtime-core": "^3.5.13", "@vue/runtime-core": "^3.5.13",
"autoprefixer": "^10.4.20", "autoprefixer": "^10.4.21",
"commit-and-tag-version": "^12.5.0", "commit-and-tag-version": "^12.5.0",
"eslint": "^9.17.0", "eslint": "^9.22.0",
"eslint-plugin-format": "^0.1.3", "eslint-plugin-format": "^1.0.1",
"globals": "^15.14.0", "globals": "^16.0.0",
"lint-staged": "^15.2.11", "lint-staged": "^15.4.3",
"picocolors": "^1.1.1", "picocolors": "^1.1.1",
"postcss": "^8.4.49", "rollup-plugin-visualizer": "^5.14.0",
"rollup-plugin-visualizer": "^5.12.0", "sass": "^1.85.1",
"sass": "^1.83.0",
"simple-git-hooks": "^2.11.1", "simple-git-hooks": "^2.11.1",
"tailwindcss": "^3.4.17", "tailwindcss": "^4.0.12",
"tsx": "^4.19.2", "tsx": "^4.19.3",
"typescript": "^5.7.2", "typescript": "^5.8.2",
"uni-mini-router": "^0.1.6", "uni-mini-router": "^0.1.6",
"uni-read-pages-vite": "^0.0.6", "uni-read-pages-vite": "^0.0.6",
"unplugin-auto-import": "^0.19.0", "unplugin-auto-import": "^19.1.1",
"vite": "^6.0.5", "vite": "^6.2.1",
"vite-plugin-restart": "^0.4.2", "vite-plugin-restart": "^0.4.2",
"weapp-tailwindcss": "^3.7.0" "weapp-tailwindcss": "^4.0.11"
}, },
"simple-git-hooks": { "simple-git-hooks": {
"pre-commit": "npx lint-staged", "pre-commit": "npx lint-staged",

View File

@ -1,12 +0,0 @@
import type { AcceptedPlugin } from 'postcss';
import autoprefixer from 'autoprefixer';
import tailwindcss from 'tailwindcss';
import cssMacro from 'weapp-tailwindcss/css-macro/postcss';
const plugins: AcceptedPlugin[] = [tailwindcss(), autoprefixer()];
// 可以使用 postcss-pxtransform 来进行 px 转 rpx 的功能
plugins.push(cssMacro);
export default plugins;

BIN
src/.DS_Store vendored Normal file

Binary file not shown.

View File

@ -15,8 +15,5 @@ onHide(() => {
}); });
</script> </script>
<style lang="css"> <style>
@import 'tailwindcss/base';
@import 'tailwindcss/utilities';
@import 'tailwindcss/components';
</style> </style>

BIN
src/components/.DS_Store vendored Normal file

Binary file not shown.

View File

@ -2,6 +2,7 @@ import { createSSRApp } from 'vue';
import App from './App.vue'; import App from './App.vue';
import { setupRouter } from './router'; import { setupRouter } from './router';
import { setupStore } from './stores'; import { setupStore } from './stores';
import './styles/main.css';
export function createApp() { export function createApp() {
const app = createSSRApp(App); const app = createSSRApp(App);

BIN
src/pages/.DS_Store vendored Normal file

Binary file not shown.

BIN
src/services/.DS_Store vendored Normal file

Binary file not shown.

BIN
src/static/.DS_Store vendored Normal file

Binary file not shown.

View File

@ -1,11 +1,10 @@
import { defineStore } from 'pinia'; // import { defineStore } from 'pinia';
interface AppState { interface AppState {
sys?: string | number sys?: string | number
} }
export const useAppStore = defineStore({ export const useAppStore = defineStore('app-store', {
id: 'app-store',
state: (): AppState => ({}), state: (): AppState => ({}),
getters: {}, getters: {},
actions: {}, actions: {},

View File

@ -11,10 +11,10 @@ export const useUserStore = defineStore('UserStore', () => {
const userInfo = ref<UserInfoModel | null>(null); const userInfo = ref<UserInfoModel | null>(null);
// 初始化 // 初始化
function initUserInfo() { async function initUserInfo() {
if (isLogin()) { if (isLogin()) {
token.value = getToken(); token.value = getToken();
getUserInfo(); await getUserInfo();
} }
} }
@ -35,7 +35,7 @@ export const useUserStore = defineStore('UserStore', () => {
} }
// 获取用户信息 // 获取用户信息
const { send: _getUserInfo } = useRequest(getUserInfoApi, { initialData: null, immediate: false }); const { send: _getUserInfo } = useRequest(getUserInfoApi, { immediate: false });
async function getUserInfo() { async function getUserInfo() {
try { try {
userInfo.value = await _getUserInfo(); userInfo.value = await _getUserInfo();

View File

@ -0,0 +1 @@
@import 'tailwindcss';

BIN
src/utils/.DS_Store vendored Normal file

Binary file not shown.

View File

@ -9,7 +9,7 @@ import process from 'node:process';
import TransformPages from 'uni-read-pages-vite'; import TransformPages from 'uni-read-pages-vite';
import { defineConfig, loadEnv } from 'vite'; import { defineConfig, loadEnv } from 'vite';
import { createVitePlugins, currentPlatform, resolveProxy } from './build'; import { createVitePlugins, currentPlatform, resolveProxy } from './build';
import postcssPlugins from './postcss.config'; // import postcssPlugins from './postcss.config';
export default defineConfig(async ({ mode }) => { export default defineConfig(async ({ mode }) => {
const root = process.cwd(); const root = process.cwd();
@ -39,9 +39,9 @@ export default defineConfig(async ({ mode }) => {
silenceDeprecations: ['legacy-js-api'], silenceDeprecations: ['legacy-js-api'],
}, },
}, },
postcss: { // postcss: {
plugins: postcssPlugins, // plugins: postcssPlugins,
}, // },
}, },
plugins: createVitePlugins({ isProd }), plugins: createVitePlugins({ isProd }),
// 开发服务器配置 // 开发服务器配置