初始化移动端提交

This commit is contained in:
chenbowen
2025-09-30 00:08:23 +08:00
parent 08784ca8f3
commit f2ffc65094
406 changed files with 55626 additions and 93 deletions

257
sheep/store/app.js Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,66 @@
import { defineStore } from 'pinia';
const defaultState = () => ({
show: false,
title: '请选择当前业务办理归属的公司部门信息',
companyList: [],
selectedCompanyId: null,
selectedDeptId: null,
onConfirm: null,
onCancel: null,
});
const companyDeptStore = defineStore({
id: 'company-dept',
state: defaultState,
actions: {
open({ companyList = [], onConfirm = null, onCancel = null, defaultCompanyId = null, defaultDeptId = null, title = null }) {
this.companyList = companyList;
this.onConfirm = onConfirm;
this.onCancel = onCancel;
this.title = title || '请选择当前业务办理归属的公司部门信息';
this.show = true;
this.selectedCompanyId = defaultCompanyId;
this.selectedDeptId = defaultDeptId;
if (!this.selectedCompanyId && this.companyList.length > 0) {
this.selectedCompanyId = this.companyList[0].companyId;
}
if (!this.selectedDeptId) {
const depts = this.getDeptsByCompanyId(this.selectedCompanyId);
this.selectedDeptId = depts.length > 0 ? depts[0].deptId : null;
}
},
close() {
Object.assign(this, defaultState());
},
getDeptsByCompanyId(companyId) {
const company = this.companyList.find((item) => item.companyId === companyId);
return company?.depts || [];
},
setSelectedCompany(companyId) {
this.selectedCompanyId = companyId;
const depts = this.getDeptsByCompanyId(companyId);
const currentDeptIds = depts.map((dept) => dept.deptId);
if (!currentDeptIds.includes(this.selectedDeptId)) {
this.selectedDeptId = depts.length > 0 ? depts[0].deptId : null;
}
},
setSelectedDept(deptId) {
this.selectedDeptId = deptId;
},
confirm() {
if (this.onConfirm) {
this.onConfirm({ companyId: this.selectedCompanyId, deptId: this.selectedDeptId });
}
this.close();
},
cancel() {
if (this.onCancel) {
this.onCancel();
}
this.close();
},
},
});
export default companyDeptStore;

20
sheep/store/index.js Normal file
View File

@@ -0,0 +1,20 @@
import { createPinia } from 'pinia';
import piniaPersist from 'pinia-plugin-persist-uni';
// 自动注入所有pinia模块
const files = import.meta.glob('./*.js', { eager: true });
const modules = {};
Object.keys(files).forEach((key) => {
modules[key.replace(/(.*\/)*([^.]+).*/gi, '$2')] = files[key].default;
});
export const setupPinia = (app) => {
const pinia = createPinia();
pinia.use(piniaPersist);
app.use(pinia);
};
export default (name) => {
return modules[name]();
};

29
sheep/store/modal.js Normal file
View File

@@ -0,0 +1,29 @@
import { defineStore } from 'pinia';
const modal = defineStore({
id: 'modal',
state: () => ({
auth: '', // 授权弹框 accountLogin|smsLogin|resetPassword|changeMobile|changePassword|changeUsername
share: false, // 分享弹框
menu: false, // 快捷菜单弹框
advHistory: [], // 广告弹框记录
lastTimer: {
// 短信验证码计时器,为了防止刷新请求做了持久化
smsLogin: 0,
changeMobile: 0,
resetPassword: 0,
changePassword: 0,
}
}),
persist: {
enabled: true,
strategies: [
{
key: 'modal-store',
paths: ['lastTimer', 'advHistory'],
},
],
},
});
export default modal;

32
sheep/store/sys.js Normal file
View File

@@ -0,0 +1,32 @@
import { defineStore } from 'pinia';
import app from './app';
const sys = defineStore({
id: 'sys',
state: () => ({
theme: '', // 主题,
mode: 'light', // 明亮模式、暗黑模式(暂未支持)
modeAuto: false, // 跟随系统
fontSize: 1, // 设置默认字号等级(0-4)
}),
getters: {},
actions: {
setTheme(theme = '') {
if (theme === '') {
this.theme = app().template?.basic.theme || 'primary';
} else {
this.theme = theme;
}
},
},
persist: {
enabled: true,
strategies: [
{
key: 'sys-store',
},
],
},
});
export default sys;

127
sheep/store/user.js Normal file

File diff suppressed because it is too large Load Diff