first commit

This commit is contained in:
2026-01-18 09:52:48 +08:00
commit 836bdc9409
584 changed files with 40891 additions and 0 deletions

15
resources/mobile/.gitignore vendored Normal file
View File

@@ -0,0 +1,15 @@
node_modules
.DS_Store
dist
*.local
# Editor directories and files
.idea
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw?
package-lock.json
unpackage
.hbuilderx

13
resources/mobile/App.vue Normal file
View File

@@ -0,0 +1,13 @@
<script>
export default {
onLaunch: function() {
console.log('App Launch')
},
onShow: function() {
console.log('App Show')
},
onHide: function() {
console.log('App Hide')
}
}
</script>

View File

@@ -0,0 +1,20 @@
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8" />
<script>
var coverSupport = 'CSS' in window && typeof CSS.supports === 'function' && (CSS.supports('top: env(a)') ||
CSS.supports('top: constant(a)'))
document.write(
'<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0' +
(coverSupport ? ', viewport-fit=cover' : '') + '" />')
</script>
<title></title>
<!--preload-links-->
<!--app-context-->
</head>
<body>
<div id="app"><!--app-html--></div>
<script type="module" src="/main.js"></script>
</body>
</html>

9
resources/mobile/main.js Normal file
View File

@@ -0,0 +1,9 @@
import App from "./App";
import { createSSRApp } from "vue";
export function createApp() {
const app = createSSRApp(App);
return {
app,
};
}

View File

@@ -0,0 +1,72 @@
{
"name" : "mobile",
"appid" : "__UNI__F0A4488",
"description" : "",
"versionName" : "1.0.0",
"versionCode" : "100",
"transformPx" : false,
/* 5+App */
"app-plus" : {
"usingComponents" : true,
"nvueStyleCompiler" : "uni-app",
"compilerVersion" : 3,
"splashscreen" : {
"alwaysShowBeforeRender" : true,
"waiting" : true,
"autoclose" : true,
"delay" : 0
},
/* */
"modules" : {},
/* */
"distribute" : {
/* android */
"android" : {
"permissions" : [
"<uses-permission android:name=\"android.permission.CHANGE_NETWORK_STATE\"/>",
"<uses-permission android:name=\"android.permission.MOUNT_UNMOUNT_FILESYSTEMS\"/>",
"<uses-permission android:name=\"android.permission.VIBRATE\"/>",
"<uses-permission android:name=\"android.permission.READ_LOGS\"/>",
"<uses-permission android:name=\"android.permission.ACCESS_WIFI_STATE\"/>",
"<uses-feature android:name=\"android.hardware.camera.autofocus\"/>",
"<uses-permission android:name=\"android.permission.ACCESS_NETWORK_STATE\"/>",
"<uses-permission android:name=\"android.permission.CAMERA\"/>",
"<uses-permission android:name=\"android.permission.GET_ACCOUNTS\"/>",
"<uses-permission android:name=\"android.permission.READ_PHONE_STATE\"/>",
"<uses-permission android:name=\"android.permission.CHANGE_WIFI_STATE\"/>",
"<uses-permission android:name=\"android.permission.WAKE_LOCK\"/>",
"<uses-permission android:name=\"android.permission.FLASHLIGHT\"/>",
"<uses-feature android:name=\"android.hardware.camera\"/>",
"<uses-permission android:name=\"android.permission.WRITE_SETTINGS\"/>"
]
},
/* ios */
"ios" : {},
/* SDK */
"sdkConfigs" : {}
}
},
/* */
"quickapp" : {},
/* */
"mp-weixin" : {
"appid" : "",
"setting" : {
"urlCheck" : false
},
"usingComponents" : true
},
"mp-alipay" : {
"usingComponents" : true
},
"mp-baidu" : {
"usingComponents" : true
},
"mp-toutiao" : {
"usingComponents" : true
},
"uniStatistics" : {
"enable" : false
},
"vueVersion" : "3"
}

View File

@@ -0,0 +1,15 @@
{
"name": "mobile",
"version": "1.0.0",
"description": "记账APP",
"keywords": [
"记账APP",
"家庭记账"
],
"license": "MIT",
"author": { "name": "molong", "email": "ycgpp@126.com" },
"dependencies": {
"@dcloudio/uni-ui": "^1.5.11",
"luch-request": "^3.1.1"
}
}

View File

@@ -0,0 +1,22 @@
{
"pages": [
{ "path": "pages/index/index" }
],
"globalStyle": {
"navigationBarTextStyle": "black",
"navigationBarTitleText": "家庭记账",
"navigationBarBackgroundColor": "#F8F8F8",
"navigationStyle": "custom",
"backgroundColor": "#F8F8F8",
"app-plus": {
"bounce": "none"
}
},
"easycom": {
"autoscan": true,
"custom": {
"^uni-(.*)": "@dcloudio/uni-ui/lib/uni-$1/uni-$1.vue"
}
},
"uniIdRouter": {}
}

View File

@@ -0,0 +1,52 @@
<template>
<view class="content">
<image class="logo" src="/static/logo.png"></image>
<view class="text-area">
<text class="title">{{title}}</text>
</view>
</view>
</template>
<script>
export default {
data() {
return {
title: 'Hello'
}
},
onLoad() {
},
methods: {
}
}
</script>
<style>
.content {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
}
.logo {
height: 200rpx;
width: 200rpx;
margin-top: 200rpx;
margin-left: auto;
margin-right: auto;
margin-bottom: 50rpx;
}
.text-area {
display: flex;
justify-content: center;
}
.title {
font-size: 36rpx;
color: #8f8f94;
}
</style>

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.9 KiB

View File

@@ -0,0 +1,13 @@
uni.addInterceptor({
returnValue (res) {
if (!(!!res && (typeof res === "object" || typeof res === "function") && typeof res.then === "function")) {
return res;
}
return new Promise((resolve, reject) => {
res.then((res) => {
if (!res) return resolve(res)
return res[0] ? reject(res[0]) : resolve(res[1])
});
});
},
});

76
resources/mobile/uni.scss Normal file
View File

@@ -0,0 +1,76 @@
/**
* 这里是uni-app内置的常用样式变量
*
* uni-app 官方扩展插件及插件市场https://ext.dcloud.net.cn上很多三方插件均使用了这些样式变量
* 如果你是插件开发者建议你使用scss预处理并在插件代码中直接使用这些变量无需 import 这个文件方便用户通过搭积木的方式开发整体风格一致的App
*
*/
/**
* 如果你是App开发者插件使用者你可以通过修改这些变量来定制自己的插件主题实现自定义主题功能
*
* 如果你的项目同样使用了scss预处理你也可以直接在你的 scss 代码中使用如下变量,同时无需 import 这个文件
*/
/* 颜色变量 */
/* 行为相关颜色 */
$uni-color-primary: #007aff;
$uni-color-success: #4cd964;
$uni-color-warning: #f0ad4e;
$uni-color-error: #dd524d;
/* 文字基本颜色 */
$uni-text-color:#333;//基本色
$uni-text-color-inverse:#fff;//反色
$uni-text-color-grey:#999;//辅助灰色,如加载更多的提示信息
$uni-text-color-placeholder: #808080;
$uni-text-color-disable:#c0c0c0;
/* 背景颜色 */
$uni-bg-color:#ffffff;
$uni-bg-color-grey:#f8f8f8;
$uni-bg-color-hover:#f1f1f1;//点击状态颜色
$uni-bg-color-mask:rgba(0, 0, 0, 0.4);//遮罩颜色
/* 边框颜色 */
$uni-border-color:#c8c7cc;
/* 尺寸变量 */
/* 文字尺寸 */
$uni-font-size-sm:12px;
$uni-font-size-base:14px;
$uni-font-size-lg:16px;
/* 图片尺寸 */
$uni-img-size-sm:20px;
$uni-img-size-base:26px;
$uni-img-size-lg:40px;
/* Border Radius */
$uni-border-radius-sm: 2px;
$uni-border-radius-base: 3px;
$uni-border-radius-lg: 6px;
$uni-border-radius-circle: 50%;
/* 水平间距 */
$uni-spacing-row-sm: 5px;
$uni-spacing-row-base: 10px;
$uni-spacing-row-lg: 15px;
/* 垂直间距 */
$uni-spacing-col-sm: 4px;
$uni-spacing-col-base: 8px;
$uni-spacing-col-lg: 12px;
/* 透明度 */
$uni-opacity-disabled: 0.3; // 组件禁用态的透明度
/* 文章场景相关 */
$uni-color-title: #2C405A; // 文章标题颜色
$uni-font-size-title:20px;
$uni-color-subtitle: #555555; // 二级标题颜色
$uni-font-size-subtitle:26px;
$uni-color-paragraph: #3F536E; // 文章段落颜色
$uni-font-size-paragraph:15px;

View File

@@ -0,0 +1,208 @@
import http from 'luch-request'
// 创建实例
const httpInstance = http.create({
baseURL: import.meta.env.VITE_API_BASE_URL || '/api',
timeout: 10000,
header: {
'Content-Type': 'application/json;charset=UTF-8'
}
})
// 请求拦截器
httpInstance.interceptors.request.use(
(config) => {
// 从本地存储获取 token
const token = uni.getStorageSync('token')
if (token) {
config.header = {
...config.header,
'Authorization': `Bearer ${token}`
}
}
// 添加时间戳,防止缓存
if (config.method === 'GET') {
config.params = {
...config.params,
_t: Date.now()
}
}
// 显示加载提示
if (config.loading !== false) {
uni.showLoading({
title: config.loadingText || '加载中...',
mask: true
})
}
return config
},
(config) => {
return Promise.reject(config)
}
)
// 响应拦截器
httpInstance.interceptors.response.use(
(response) => {
// 隐藏加载提示
if (response.config.loading !== false) {
uni.hideLoading()
}
const { statusCode, data } = response
// HTTP 状态码判断
if (statusCode !== 200) {
showError('网络请求失败')
return Promise.reject(response)
}
// 业务状态码判断
if (data.code !== undefined) {
// 成功响应
if (data.code === 0 || data.code === 200 || data.code === 1) {
return data.data !== undefined ? data.data : data
}
// 业务错误处理
if (data.code === 401) {
// token 失效,跳转登录页
uni.removeStorageSync('token')
uni.removeStorageSync('userInfo')
uni.showToast({
title: '登录已过期,请重新登录',
icon: 'none',
duration: 2000
})
setTimeout(() => {
uni.navigateTo({
url: '/pages/login/index'
})
}, 2000)
return Promise.reject(data)
}
// 其他业务错误
showError(data.message || data.msg || '请求失败')
return Promise.reject(data)
}
return data
},
(error) => {
// 隐藏加载提示
if (error.config && error.config.loading !== false) {
uni.hideLoading()
}
let errorMessage = '网络请求失败'
if (error.response) {
const { statusCode, data } = error.response
switch (statusCode) {
case 400:
errorMessage = data?.message || '请求参数错误'
break
case 401:
errorMessage = '登录已过期,请重新登录'
uni.removeStorageSync('token')
uni.removeStorageSync('userInfo')
setTimeout(() => {
uni.navigateTo({
url: '/pages/login/index'
})
}, 2000)
break
case 403:
errorMessage = '没有权限访问'
break
case 404:
errorMessage = '请求的资源不存在'
break
case 500:
errorMessage = '服务器内部错误'
break
case 502:
errorMessage = '网关错误'
break
case 503:
errorMessage = '服务不可用'
break
case 504:
errorMessage = '网关超时'
break
default:
errorMessage = data?.message || `请求失败 (${statusCode})`
}
} else if (error.errMsg) {
// 网络错误
if (error.errMsg.includes('timeout')) {
errorMessage = '请求超时,请检查网络连接'
} else if (error.errMsg.includes('network')) {
errorMessage = '网络连接失败,请检查网络'
}
}
showError(errorMessage)
return Promise.reject(error)
}
)
// 显示错误提示
function showError(message) {
uni.showToast({
title: message,
icon: 'none',
duration: 3000
})
}
// 封装常用请求方法
export default {
// GET 请求
get(url, params = {}, config = {}) {
return httpInstance.get(url, {
params,
...config
})
},
// POST 请求
post(url, data = {}, config = {}) {
return httpInstance.post(url, data, config)
},
// PUT 请求
put(url, data = {}, config = {}) {
return httpInstance.put(url, data, config)
},
// DELETE 请求
delete(url, data = {}, config = {}) {
return httpInstance.delete(url, {
data,
...config
})
},
// 文件上传
upload(url, filePath, formData = {}, config = {}) {
return httpInstance.upload(url, {
filePath,
formData,
name: 'file',
...config
})
},
// 文件下载
download(url, config = {}) {
return httpInstance.download(url, config)
},
// 原始实例,用于特殊场景
instance: httpInstance
}