feat: 初始化前端项目基础结构

- 添加项目配置文件(tsconfig, eslint, prettier等)
- 实现基础路由和页面布局
- 添加全局状态管理和API请求封装
- 集成UI组件库和主题系统
- 添加文档网站和示例页面
- 配置CI/CD和工作流
This commit is contained in:
zhangtao
2026-05-01 00:47:48 +08:00
parent ff738007cd
commit 5c29d22aa5
256 changed files with 45257 additions and 2 deletions
+9
View File
@@ -0,0 +1,9 @@
/**
* 获取当前页面路径
* @returns 当前页面路径
*/
export function getCurrentPath() {
const pages = getCurrentPages()
const currentPage = pages[pages.length - 1]
return currentPage.route || ''
}
+35
View File
@@ -0,0 +1,35 @@
/**
* 存储工具类
* 提供localStorage和sessionStorage操作方法
*/
/**
* localStorage 存储
*/
function set(key: string, value: any): void {
uni.setStorageSync(key, JSON.stringify(value))
}
function get<T>(key: string, defaultValue?: T): T {
const value = uni.getStorageSync(key)
if (!value)
return defaultValue as T
try {
return JSON.parse(value)
}
catch {
// 如果解析失败,返回原始字符串
return value as unknown as T
}
}
function remove(key: string): void {
uni.removeStorageSync(key)
}
export const Storage = {
set,
get,
remove,
}
+17
View File
@@ -0,0 +1,17 @@
// 跳转到登录页
export function toLoginPage(
options: { mode?: 'navigateTo' | 'reLaunch' } = {},
) {
const { mode = 'navigateTo' } = options
if (mode === 'reLaunch') {
uni.reLaunch({
url: '/pages/login/index',
})
}
else {
uni.navigateTo({
url: '/pages/login/index',
})
}
}