Commit ae74ab29 by cen

feat: 登录

1 parent dfaf5daf
Showing 83 changed files with 2534 additions and 1033 deletions
<script lang="uts">
let firstBackTime = 0;
export default {
onLaunch () {
onLaunch: function () {
console.log("App Launch");
},
onShow () {
onShow: function () {
console.log("App Show");
},
onHide () {
onHide: function () {
console.log("App Hide");
},
// #ifdef APP-ANDROID
onLastPageBackPress () {
onLastPageBackPress: function () {
console.log("App LastPageBackPress");
if (firstBackTime == 0) {
uni.showToast({
......@@ -28,7 +28,7 @@ export default {
}
},
// #endif
onExit () {
onExit: function () {
console.log("App Exit");
}
};
......@@ -43,10 +43,23 @@ export default {
/* @tailwind components; */
/* @tailwind utilities; */
/* 全局默认样式 */
uni-page-body {
font-size: 14px;
height: 100%;
min-height: 100%;
}
/* #ifdef H5 */
svg {
display: initial;
}
/* H5 端统一 flex 默认行为,与 App 端保持一致 */
uni-app uni-page-body, uni-app uni-left-window .uni-left-window, uni-app uni-right-window .uni-right-window, uni-app uni-top-window .uni-top-window, uni-app uni-view, uni-app uni-match-media, uni-app uni-label, uni-app uni-swiper, uni-app uni-swiper-item, uni-app uni-movable-area, uni-app uni-movable-view, uni-app uni-cover-view, uni-app uni-list-item, uni-app uni-navigator, uni-app uni-radio-group, uni-app uni-checkbox-group, uni-app uni-scroll-view, uni-app uni-list-view, uni-app uni-unicloud-db, uni-app uni-sticky-section, uni-app uni-sticky-header {
display: flex ;
flex-direction: row ;
}
/* #endif */
.safe-area-top {
......
......@@ -163,4 +163,4 @@ export const signSecretKey: SignSecretKeyItem = signSecretKeyMap[currentTarget]
export const pathEnum: UTSJSONObject = PATH_ENUM;
export const pathEnumExport: UTSJSONObject = PATH_ENUM;
// env 仅用于区分当前环境标签,这里直接按 TARGET_INDEX 映射为字符串
export const env: string = TARGET_INDEX == 3 ? "production" : (TARGET_INDEX == 1 ? "develop" : "test");
export const env: string = TARGET_INDEX == 3 ? "production" : TARGET_INDEX == 1 ? "develop" : "test";
/**
* 简化版 qs.stringify(从 gl_tape/lib/qs.js 核心逻辑提取)
* 仅支持简单对象序列化,不处理复杂嵌套
*/
function encodeValue(val: any): string {
if (val == null) {
return '';
}
const str = `${val}`;
const encoded = encodeURIComponent(str);
return encoded != null ? encoded : '';
}
/**
* 将对象序列化为 query string
* @param obj 要序列化的对象
* @param encodeValuesOnly 是否只编码值(key 不编码)
* @returns 序列化后的字符串,如 "key1=val1&key2=val2"
*/
export function stringify(obj: UTSJSONObject, encodeValuesOnly: boolean = true): string {
const pairs: string[] = [];
for (const key in obj) {
const val = obj[key];
if (val == null) {
continue;
}
const keyStr = encodeValuesOnly ? key : encodeURIComponent(key);
const valStr = encodeValue(val);
pairs.push(`${keyStr}=${valStr}`);
}
return pairs.join('&');
}
......@@ -6,22 +6,22 @@ function encodeUTF8(s: string): number[] {
const r: number[] = [];
let i = 0;
while (i < s.length) {
const c = s.charCodeAt(i);
const c = s.charCodeAt(i) as number;
if (c < 0x80) {
r.push(c);
} else if (c < 0x8_00) {
r.push(0xC0 + ((c >> 6) & 0x1F), 0x80 + (c & 0x3F));
} else if (c < 0x800) {
r.push(0xc0 + ((c >> 6) & 0x1f), 0x80 + (c & 0x3f));
} else {
const x = c ^ 0xD8_00;
const x = c ^ 0xd800;
if (x >> 10 == 0) {
const next = s.charCodeAt(i + 1) ^ 0xDC_00;
const code = (x << 10) + next + 0x1_00_00;
r.push(0xF0 + ((code >> 18) & 0x7), 0x80 + ((code >> 12) & 0x3F));
const next = (s.charCodeAt(i + 1) as number) ^ 0xdc00;
const code = (x << 10) + next + 0x10000;
r.push(0xf0 + ((code >> 18) & 0x7), 0x80 + ((code >> 12) & 0x3f));
i++;
} else {
r.push(0xE0 + (c >> 12));
r.push(0xe0 + ((c >> 12) & 0xf));
}
r.push(0x80 + ((c >> 6) & 0x3F), 0x80 + (c & 0x3F));
r.push(0x80 + ((c >> 6) & 0x3f), 0x80 + (c & 0x3f));
}
i++;
}
......@@ -38,19 +38,27 @@ export function sha1(s: string): string {
const t = new DataView(sBuf);
let i = 0;
while (i < l) {
s32[i] = t.getUint32(i << 2);
s32[i] = t.getUint32(i << 2, false);
i++;
}
s32[data.length >> 2] |= 0x80 << (24 - (data.length & 3) * 8);
s32[l - 1] = data.length << 3;
const w: number[] = [];
const k = [1_518_500_249, 1_859_775_393, -1_894_007_588, -899_497_514];
let m0 = 1_732_584_193;
let m1 = -271_733_879;
let m2 = ~1_732_584_193;
let m3 = ~(-271_733_879);
let m4 = -1_009_589_776;
// 预先初始化 w 数组为 80 个元素,避免 UTS 下标越界
let wInit = 0;
while (wInit < 80) {
w.push(0);
wInit++;
}
const k = [1518500249, 1859775393, -1894007588, -899497514];
let m0 = 1732584193;
let m1 = -271733879;
let m2 = 0;
let m3 = 0;
let m4 = -1009589776;
m2 = ~m0;
m3 = ~m1;
const rol = (n: number, c: number): number => (n << c) | (n >>> (32 - c));
const f0 = (): number => (m1 & m2) | (~m1 & m3);
......
import { get, keys, set } from "../../utils/common.uts";
import { sha1 } from "./sha1.uts";
import { stringify as qsStringify } from "./qs.uts";
/**
* 参数签名方法(从 gl_tape/api/request/sign.js 迁移)
* - 删除原始参数中的 sign 字段
* 参数签名方法(完全对齐 gl_tape/api/request/sign.js)
* - 先用 qs.stringify 序列化参数
* - split('&') 拆开后 decodeURIComponent 解码
* - 按 key 字典序排序
* - 将 null 转为空字符串,对对象使用 JSON.stringify
* - 拼接为 key + value 字符串,首尾加密钥后做 SHA1,再转大写
* - 最后把 sign 挂到原始参数对象上(保留原始类型)
*
* @param params 原始参数对象(会被浅拷贝,不直接修改入参)
* @param params 原始参数对象(会被修改,添加 sign 字段)
* @param secret 签名密钥
* @param noSignAttr 不参与签名的字段列表
*/
export function sign(params: UTSJSONObject, secret: string, noSignAttr: string[] = []): UTSJSONObject {
// 使用 UTSJSONObject 做一份浅拷贝,避免直接修改原始对象
const realObj = {} as UTSJSONObject;
// 先将入参拷贝到 realObj 中,并清理 sign 字段
const rawKeys = keys(params);
for (const key of rawKeys) {
if (key == "sign") {
// 1. 用 qs.stringify 序列化(encodeValuesOnly: true)
const objStr = qsStringify(params, true);
// 2. split('&') 拆开
const objVal = objStr.split('&');
// 3. 解码并重建对象(用于签名计算)
const realObj: UTSJSONObject = {};
for (let i = 0; i < objVal.length; i++) {
const item = objVal[i];
const idx = item.indexOf('=');
if (idx < 0) {
continue;
}
const value = get(params, key);
set(realObj, key, value);
const key = item.substring(0, idx);
const val = decodeURIComponent(item.substring(idx + 1));
realObj[key] = val;
}
// 再次获取 key 列表并排序,确保签名字段顺序稳定
const sortedKeys = keys(realObj);
sortedKeys.sort((a, b) => a.localeCompare(b));
// 4. 获取 key 列表并排序
const sortedKeys: string[] = [];
for (const key in realObj) {
if (key == "sign") {
continue;
}
sortedKeys.push(key);
}
sortedKeys.sort();
// 归一化 value:null -> "",对象 -> JSON 字符串
for (const key of sortedKeys) {
let obj: any | null = get(realObj, key);
// 5. 归一化 value:null -> "",对象 -> JSON 字符串
for (let i = 0; i < sortedKeys.length; i++) {
const key = sortedKeys[i];
let obj: any | null = realObj[key];
if (obj == null) {
obj = "";
} else if (typeof obj === "object") {
} else if (typeof obj == "object") {
obj = JSON.stringify(obj);
}
set(realObj, key, obj);
realObj[key] = obj;
}
// 组装待签名字符串(排除 noSignAttr 指定的字段)
// 6. 组装待签名字符串(排除 noSignAttr 指定的字段)
const segments: string[] = [];
for (const key of sortedKeys) {
for (let i = 0; i < sortedKeys.length; i++) {
const key = sortedKeys[i];
if (noSignAttr.indexOf(key) >= 0) {
continue;
}
const val = get(realObj, key, "") as string;
const val = realObj[key];
segments.push(key + val);
}
// 计算签名:secret + 拼接字符串 + secret
// 7. 计算签名:secret + 拼接字符串 + secret
const signSrc = secret + segments.join("") + secret;
const signVal = sha1(signSrc).toUpperCase();
set(realObj, "sign", signVal);
// 8. 把 sign 挂到 realObj 上,返回全字符串的对象(和老项目保持一致)
realObj["sign"] = signVal;
return realObj;
}
import { storage } from "../../utils/storage.uts";
import { evaluationDomain, pathEnum, signSecretKey } from "../env.uts";
import { storage } from "../../utils/storage.uts";
type GscPostConfig = {
duplicatePrevention?: boolean;
returnAll?: boolean;
timeout?: number;
duplicatePrevention?: boolean;
};
/**
......@@ -35,29 +35,30 @@ export function gscPost(url: string, data: UTSJSONObject, config: GscPostConfig
return;
}
const baseURL = `${evaluationDomain}${pathEnum.evaluation}`;
const baseURL = `${evaluationDomain}${pathEnum["evaluation"]}`;
const fullUrl = `${baseURL}${url}`;
// 组装请求体,自动注入 sessionId
const payload = {} as UTSJSONObject;
const dataKeys = Object.keys(data as any) as string[];
for (const key of dataKeys) {
for (let i = 0; i < dataKeys.length; i++) {
const key = dataKeys[i];
// @ts-ignore
payload[key] = (data as UTSJSONObject)[key];
}
// sessionId 自动注入
const sessionId = storage.get("sessionId") as null | string;
if (sessionId != null && sessionId != "" && payload.sessionId == null) {
payload.sessionId = sessionId;
const sessionId = storage.get("sessionId") as string | null;
if (sessionId != null && sessionId != "" && payload["sessionId"] == null) {
payload["sessionId"] = sessionId;
}
// 简单的重复提交防护:可选地附加一次性请求标识(仅客户端语义)
if (finalConfig.duplicatePrevention == true) {
payload.__duplicateKey = `${Date.now()}_${Math.random()}`;
payload["__duplicateKey"] = `${Date.now()}_${Math.random()}`;
}
const timeout = finalConfig.timeout ?? 300_000;
const timeout = finalConfig.timeout ?? 300000;
// 将 appId / appSecret 通过 header 传递给后端(近似旧项目 glsk-toolkit 行为)
const header = {
......@@ -113,7 +114,7 @@ export function gscPost(url: string, data: UTSJSONObject, config: GscPostConfig
fail: (error) => {
let title = "业务异常";
// @ts-ignore
const errMsg = (error as any).errMsg as null | string;
const errMsg = (error as any).errMsg as string | null;
if (errMsg == "request:fail") {
title = "网络异常";
} else if (errMsg != null && errMsg != "") {
......
// 登录相关接口封装,对齐 gl_tape 中的 ROP 网关调用(http.fetch)
// 登录相关接口封装,直接使用项目现成的 http.uts(已包含签名逻辑)
import { djDomain, djSecretKey, pathEnum } from "@/api/env.uts";
import { storage } from "@/utils/storage.uts";
const BOUTIQUE_PATH = pathEnum.boutique as string;
// 简化版 SHA1,实现同 lib/sha1.js,用于生成 sign
function encodeUTF8(input: string): number[] {
const result: number[] = [];
let i = 0;
while (i < input.length) {
const cNum = input.charCodeAt(i) as number;
if (cNum < 0x80) {
result.push(cNum);
} else if (cNum < 0x8_00) {
result.push(0xC0 + ((cNum >> 6) & 0x1F), 0x80 + (cNum & 0x3F));
} else {
const x = cNum ^ 0xD8_00;
if (x >> 10 == 0) {
i++;
const c2 = input.charCodeAt(i) as number;
const uni = (x << 10) + (c2 ^ 0xDC_00) + 0x1_00_00;
result.push(
0xF0 + ((uni >> 18) & 0x7),
0x80 + ((uni >> 12) & 0x3F),
0x80 + ((uni >> 6) & 0x3F),
0x80 + (uni & 0x3F)
);
} else {
result.push(
0xE0 + ((cNum >> 12) & 0x0F),
0x80 + ((cNum >> 6) & 0x3F),
0x80 + (cNum & 0x3F)
);
}
}
i++;
}
return result;
}
function sha1Hex(input: string): string {
const dataArr = encodeUTF8(input);
const data = new Uint8Array(dataArr);
const l = (((data.length + 8) >>> 6) << 4) + 16;
const buffer = new Uint8Array(l << 2);
const dataBuf: ArrayBuffer = data.buffer as ArrayBuffer;
buffer.set(new Uint8Array(dataBuf));
const buf: ArrayBuffer = buffer.buffer as ArrayBuffer;
const s = new Uint32Array(buf);
const sBuf: ArrayBuffer = s.buffer as ArrayBuffer;
const dv = new DataView(sBuf);
let i = 0;
while (i < l) {
s[i] = dv.getUint32(i << 2);
i++;
}
const idx = data.length >> 2;
s[idx] = s[idx] | (0x80 << (24 - ((data.length & 3) * 8)));
s[l - 1] = data.length << 3;
const w: number[] = [];
const f = [
(m: number[]): number => (m[1] & m[2]) | (~m[1] & m[3]),
(m: number[]): number => m[1] ^ m[2] ^ m[3],
(m: number[]): number => (m[1] & m[2]) | (m[1] & m[3]) | (m[2] & m[3]),
(m: number[]): number => m[1] ^ m[2] ^ m[3]
];
const k = [1_518_500_249, 1_859_775_393, -1_894_007_588, -899_497_514];
const rol = (n: number, c: number): number => (n << c) | (n >>> (32 - c));
const m: number[] = [1_732_584_193, -271_733_879, 0, 0, -1_009_589_776];
m[2] = ~m[0];
m[3] = ~m[1];
let j = 0;
for (i = 0; i < s.length; i += 16) {
const o = [m[0], m[1], m[2], m[3], m[4]];
for (j = 0; j < 80; j++) {
if (j < 16) {
w[j] = s[i + j];
} else {
w[j] = rol(w[j - 3] ^ w[j - 8] ^ w[j - 14] ^ w[j - 16], 1);
}
const t = (rol(m[0], 5) + f[(j / 20) | 0](m) + m[4] + w[j] + k[(j / 20) | 0]) | 0;
m[4] = m[3];
m[3] = m[2];
m[2] = rol(m[1], 30);
m[1] = m[0];
m[0] = t;
}
for (j = 0; j < 5; j++) {
m[j] = (m[j] + o[j]) | 0;
}
}
const mArr = new Uint32Array(m);
const mBuf: ArrayBuffer = mArr.buffer as ArrayBuffer;
const out = new Uint8Array(mBuf);
let hex = "";
for (i = 0; i < out.length; i++) {
const v = out[i];
hex += (v < 16 ? "0" : "") + v.toString(16);
}
return hex;
}
// 按老项目 http.getData + sign.js 逻辑生成最终请求参数
function buildSignedParams(method: string, payload: UTSJSONObject): UTSJSONObject {
const params: UTSJSONObject = {};
// 复制调用参数
for (const key in payload) {
params[key] = payload[key];
}
// 基础字段
params.method = method;
params.v = "1.0.0";
params.format = "json";
params.locale = "zh_CN";
params.source = "app";
// appKey / secret
const appKey = djSecretKey.appKey as string;
const secret = djSecretKey.secret as string;
params.appKey = appKey;
// sessionId(如果存在)
const sessionId = storage.get("sessionId") as null | string;
if (sessionId != null && sessionId != "") {
params.sessionId = sessionId;
}
// sign 计算:按照 key 排序、拼接 key+value
const realObj: UTSJSONObject = {};
for (const k in params) {
const v = params[k];
if (v == null) {
realObj[k] = "";
} else if (typeof v === "object") {
realObj[k] = JSON.stringify(v);
} else {
realObj[k] = v;
}
}
const keys: string[] = [];
for (const k in realObj) {
keys.push(k);
}
keys.sort();
const parts: string[] = [];
for (const k of keys) {
const vAny = realObj[k];
const vStr = `${vAny}`;
parts.push(k + vStr);
}
const signStr = secret + parts.join("") + secret;
// 目前关闭本地 SHA1 计算,直接透传待签名串,方便后端放宽或调试
console.log("rop signStr (sha disabled)", signStr);
params.sign = signStr;
return params;
}
// 统一 ROP 请求封装:/router?method=xxx
async function postRop(method: string, payload: UTSJSONObject): Promise<UTSJSONObject> {
const url = `${djDomain}${BOUTIQUE_PATH}router?method=${method}`;
const data = buildSignedParams(method, payload);
console.log("rop request", url, data);
return await new Promise((resolve, reject) => {
uni.request({
url,
data,
method: "POST",
header: {
"content-type": "application/x-www-form-urlencoded"
},
dataType: "json",
success: (res) => {
console.log("rop response", res.data);
resolve(res.data as UTSJSONObject);
},
fail: (err) => {
console.log("rop error", err);
reject(err);
}
});
});
}
import http from '@/api/request/http.uts'
// 获取短信验证码:dj.api.smartcarlife.sms.get.code
export async function apiGetSmsCode(params: UTSJSONObject): Promise<UTSJSONObject> {
const data: UTSJSONObject = {
...params
};
return await postRop("dj.api.smartcarlife.sms.get.code", data);
const data: UTSJSONObject = {
projectName: 'boutique',
...params
}
return await http.fetch('dj.api.smartcarlife.sms.get.code', data, true, 'dj')
}
// 手机验证码登录:dj.api.smartcarlife.sms.applogin
export async function apiSmsLogin(params: UTSJSONObject): Promise<UTSJSONObject> {
const data: UTSJSONObject = {
...params
};
// 与旧项目保持一致的固定参数
data.source = "MINIAPP";
data.productCode = "PC00c2";
return await postRop("dj.api.smartcarlife.sms.applogin", data);
const data: UTSJSONObject = {
projectName: 'boutique',
source: 'MINIAPP',
productCode: 'PC00c2',
...params
}
return await http.fetch('dj.api.smartcarlife.sms.applogin', data, true, 'dj')
}
// 免登:dj.api.smartcarlife.sms.noSignIn.login
export async function apiAutoLogin(params: UTSJSONObject): Promise<UTSJSONObject> {
const data: UTSJSONObject = {
...params
};
return await postRop("dj.api.smartcarlife.sms.noSignIn.login", data);
const data: UTSJSONObject = {
projectName: 'boutique',
...params
}
return await http.fetch('dj.api.smartcarlife.sms.noSignIn.login', data, true, 'dj')
}
// 获取账号列表:dj.api.smartcarlife.workWechat.listSelectAccount
export async function apiGetListSelectAccount(params: UTSJSONObject): Promise<UTSJSONObject> {
const data: UTSJSONObject = {
projectName: 'boutique',
...params
}
return await http.fetch('dj.api.smartcarlife.workWechat.listSelectAccount', data, true, 'dj')
}
// 选择账号登录:dj.api.smartcarlife.workWechat.selectAccountLogin
export async function apiSelectAccountLogin(params: UTSJSONObject): Promise<UTSJSONObject> {
const data: UTSJSONObject = {
projectName: 'boutique',
method: 'dj.api.smartcarlife.workWechat.selectAccountLogin',
...params
}
return await http.post(data, true, 'dj', null)
}
// 获取园区店下的4S店:dj.api.scenemerchantref.query4SRefByYqShopByLogin
export async function apiGetSceneMerchantRefStoreList(params: UTSJSONObject): Promise<any[] | null> {
const data: UTSJSONObject = {
projectName: 'boutique',
method: 'dj.api.scenemerchantref.query4SRefByYqShopByLogin',
...params
}
return await http.post(data, true, 'dj', null)
}
<template>
<view v-if="isShow"
class="publish-popup-mask"
@click="closePopup">
<view class="publish-popup-container" @click.stop>
<slot name="content"></slot>
</view>
</view>
<view v-if="isShow" class="publish-popup-mask" @click="closePopup">
<view class="publish-popup-container" @click.stop>
<slot name="content"></slot>
</view>
</view>
</template>
<script setup lang="uts">
import { ref } from "vue";
import { ref } from 'vue';
// Props
const props = defineProps<{
type?: string;
isShowFooter?: boolean;
showTitle?: boolean;
type?: string;
}>();
// 响应式数据
......
<template>
<view class="type-tab">
<scroll-view class="type-box"
scroll-with-animation
scroll-x="true"
:show-scrollbar="false">
<view class="type-scroll-content">
<view v-for="(i, index) in typeList"
:key="index"
class="tab-item"
:class="[tabClass(index)]"
@click.stop="tabClick(index, i)">
<view class="text flex justify-center align-center" :class="[tabIndex == index ? 'active' : '']">
<text class="tab-name">{{ getTabName(i) }}</text>
<text v-if="isShowCount" class="count ml-8">{{ (getTabCount(i) > 99) ? '99+' : getTabCount(i).toString() }}</text>
</view>
</view>
</view>
</scroll-view>
</view>
<view class="type-tab">
<scroll-view class="type-box" scroll-x="true" :show-scrollbar="false" scroll-with-animation>
<view class="type-scroll-content">
<view
class="tab-item"
:class="[tabClass(index)]"
v-for="(i, index) in typeList"
:key="index"
@click.stop="tabClick(index, i)"
>
<view class="text flex justify-center align-center" :class="[tabIndex == index ? 'active' : '']">
<text class="tab-name">{{ getTabName(i) }}</text>
<text v-if="isShowCount" class="count ml-8">{{ (getTabCount(i) > 99) ? '99+' : getTabCount(i).toString() }}</text>
</view>
</view>
</view>
</scroll-view>
</view>
</template>
<script setup lang="uts">
import { get } from "@/utils/common.uts";
import { ref, computed } from 'vue';
import { get } from '@/utils/common.uts';
// Props 类型:使用 any[] 避免响应式对象类型转换问题
const props = withDefaults(defineProps<{
isShowCount?: boolean;
nameKey?: string;
tabIndex: number;
typeList: any[];
tabIndex: number;
nameKey?: string;
isShowCount?: boolean;
}>(), {
nameKey: "tabName",
nameKey: 'tabName',
isShowCount: false
});
// Emits
const emit = defineEmits<{
(e: "tabClick", index: number, item: any): void;
(e: 'tabClick', index: number, item: any): void;
}>();
......@@ -45,11 +44,11 @@ const emit = defineEmits<{
// 响应式对象在 app 端无法通过 get() 访问,使用 JSON 序列化/反序列化解包
const getTabName = (item: any): string => {
// 先尝试 get()
const name = get(item, props.nameKey);
let name = get(item, props.nameKey);
if (name != null) {
return name as string;
}
// get() 失败,尝试 JSON 序列化/反序列化解包响应式对象
try {
const jsonStr = JSON.stringify(item);
......@@ -59,55 +58,55 @@ const getTabName = (item: any): string => {
if (name1 != null) {
return name1 as string;
}
const name2 = get(parsed, "tabName");
const name2 = get(parsed, 'tabName');
if (name2 != null) {
return name2 as string;
}
}
} catch {
} catch (e: any) {
// 静默失败
}
return "未知";
return '未知';
};
const getTabCount = (item: any): number => {
// 先尝试 get()
const count = get(item, "count");
let count = get(item, 'count');
if (count != null) {
return count as number;
}
// get() 失败,尝试 JSON 序列化/反序列化解包响应式对象
try {
const jsonStr = JSON.stringify(item);
const parsed = JSON.parse(jsonStr) as any;
if (parsed != null) {
const countValue = get(parsed, "count");
const countValue = get(parsed, 'count');
if (countValue != null) {
return countValue as number;
}
}
} catch {
} catch (e: any) {
// 静默失败
}
return 0;
};
// 方法
const tabClass = (index: number): string => {
let className = "";
let className = '';
if (props.tabIndex == index) {
className = "active ";
if (index == 0) className += "first-nav";
else className += "second-nav";
className = 'active ';
if (index == 0) className += 'first-nav';
else className += 'second-nav';
}
return className;
};
const tabClick = (index: number, item: any) => {
emit("tabClick", index, item);
emit('tabClick', index, item);
};
</script>
......
// composables/useTheme.uts
// 主题 Composable - 提供响应式主题变量和切换接口
import { computed, onMounted, ref } from "vue";
import { getThemeManager, ThemeName, ThemeVariables } from "@/utils/theme-manager.uts";
import { ref, computed, onMounted } from 'vue'
import { getThemeManager, ThemeName, ThemeVariables } from '@/utils/theme-manager.uts'
import { getScreenSize } from '@/utils/screen-adapt.uts'
/**
* 主题 Composable
* 类似 i18n 的使用方式,提供主题变量和切换接口
*/
export function useTheme() {
const themeManager = getThemeManager();
const currentThemeName = ref<ThemeName>(themeManager.getCurrentThemeName());
const theme = ref<null | ThemeVariables>(themeManager.getCurrentTheme());
const themeManager = getThemeManager()
const currentThemeName = ref<ThemeName>(themeManager.getCurrentThemeName())
const theme = ref<ThemeVariables | null>(themeManager.getCurrentTheme())
/**
* 设置主题
*/
function setTheme(themeName: ThemeName): boolean {
const success = themeManager.setTheme(themeName);
const success = themeManager.setTheme(themeName)
if (success) {
currentThemeName.value = themeName;
theme.value = themeManager.getCurrentTheme();
currentThemeName.value = themeName
theme.value = themeManager.getCurrentTheme()
}
return success;
return success
}
/**
* 自动选择主题(根据屏幕尺寸)
*/
function autoSelectTheme(): void {
themeManager.autoSelectTheme();
currentThemeName.value = themeManager.getCurrentThemeName();
theme.value = themeManager.getCurrentTheme();
themeManager.autoSelectTheme()
currentThemeName.value = themeManager.getCurrentThemeName()
theme.value = themeManager.getCurrentTheme()
}
/**
......@@ -40,50 +40,50 @@ export function useTheme() {
*/
const spacing = computed(() => {
return (key: string): number => {
return themeManager.getSpacing(key);
};
});
return themeManager.getSpacing(key)
}
})
/**
* 获取圆角值
*/
const borderRadius = computed(() => {
return (key: string): number => {
return themeManager.getBorderRadius(key);
};
});
return themeManager.getBorderRadius(key)
}
})
/**
* 获取字体大小
*/
const fontSize = computed(() => {
return (key: string): number => {
return themeManager.getFontSize(key);
};
});
return themeManager.getFontSize(key)
}
})
/**
* 获取尺寸值
*/
const size = computed(() => {
return (key: string): number => {
return themeManager.getSize(key);
};
});
return themeManager.getSize(key)
}
})
/**
* 获取行高值
*/
const lineHeight = computed(() => {
return (key: string): number => {
return themeManager.getLineHeight(key);
};
});
return themeManager.getLineHeight(key)
}
})
// 初始化时自动选择主题
onMounted(() => {
autoSelectTheme();
});
autoSelectTheme()
})
return {
// 当前主题名称
......@@ -104,5 +104,5 @@ export function useTheme() {
size,
// 获取行高值
lineHeight
};
}
}
// composables/useThemeVariables.uts
// CSS 变量主题 Composable
import { computed, onMounted, ref } from "vue";
import { getThemeVariablesStyle } from "@/utils/theme-variables.uts";
import { useTheme } from "./useTheme.uts";
import { ref, computed, onMounted } from 'vue'
import { getThemeVariablesStyle } from '@/utils/theme-variables.uts'
import { useTheme } from './useTheme.uts'
/**
* CSS 变量主题 Composable
* 提供响应式的 CSS 变量样式对象
*/
export function useThemeVariables() {
const { currentThemeName, autoSelectTheme } = useTheme();
const themeVars = ref<Record<string, string>>({});
const { currentThemeName, autoSelectTheme } = useTheme()
const themeVars = ref<Record<string, string>>({})
/**
* 更新 CSS 变量
*/
function updateThemeVariables(): void {
themeVars.value = getThemeVariablesStyle();
themeVars.value = getThemeVariablesStyle()
}
// 初始化时设置 CSS 变量
onMounted(() => {
updateThemeVariables();
});
updateThemeVariables()
})
// 监听主题变化,自动更新 CSS 变量
const themeVarsComputed = computed(() => {
// 当主题名称变化时,重新计算 CSS 变量
return getThemeVariablesStyle();
});
return getThemeVariablesStyle()
})
return {
// CSS 变量样式对象(用于 :style 绑定)
themeVars: themeVarsComputed,
// 手动更新 CSS 变量
updateThemeVariables
};
}
}
export const proxy = {
dev: {
// 本地地址
target: "http://127.0.0.1:8001",
changeOrigin: true,
rewrite: (path: string) => path.replace("/dev", ""),
},
dev: {
// 本地地址
target: "http://127.0.0.1:8001",
changeOrigin: true,
rewrite: (path: string) => path.replace("/dev", ""),
},
};
export const value = "dev";
// / <reference types="vite/client" />
declare module "*.uvue" {
import { DefineComponent } from "vue";
/// <reference types="vite/client" />
declare module '*.uvue' {
import { DefineComponent } from 'vue';
const component: DefineComponent<{}, {}, any>;
export default component;
}
declare module "*.vue" {
import { DefineComponent } from "vue";
declare module '*.vue' {
import { DefineComponent } from 'vue';
const component: DefineComponent<{}, {}, any>;
export default component;
}
......
import { createSSRApp } from "vue";
import App from "./App.uvue";
import { appMixin } from "./utilsApi";
import App from "./App.uvue";
export function createApp() {
const app = createSSRApp(App);
......
......@@ -3,7 +3,7 @@
"appid": "__UNI__B602BFA",
"description": "",
"versionName": "1.0.0",
"versionCode": "108",
"versionCode": "109",
"uni-app-x": {
"flex-direction": "row"
},
......
{
"name": "uniapp-x-tape",
"name": "uniappx-cli",
"version": "1.0.1",
"scripts": {
"postinstall": "weapp-tw patch"
......@@ -25,6 +25,7 @@
"adm-zip": "^0.5.16",
"autoprefixer": "^10.4.21",
"postcss": "^8.5.6",
"prettier": "^3.5.3",
"tailwindcss": "3",
"tailwindcss-rem2px-preset": "^1.0.3",
"vite": "^6.3.5",
......
......@@ -4,7 +4,13 @@
{
"path": "pages/common/login/index",
"style": {
"navigationBarTitleText": "登录"
"navigationStyle": "custom"
}
},
{
"path": "pages/common/accountItems/index",
"style": {
"navigationStyle": "custom"
}
},
{
......@@ -62,6 +68,14 @@
}
}
],
"easycom": {
"autoscan": true,
"custom": {
"^uni-(.*)": "@/uni_modules/uni-$1/components/uni-$1/uni-$1.uvue",
"^account-list$": "@/pages/common/components/AccountList.uvue",
"^no-data$": "@/pages/common/components/NoData.uvue"
}
},
"globalStyle": {
"navigationBarTextStyle": "black",
"navigationBarTitleText": "uni-app x",
......
<template>
<view class="page-container">
<view class="bg">
<image class="bg-image" src="/static/images/login/account-bg.webp" mode="aspectFill"></image>
</view>
<view class="layout">
<view class="nav-bar">
<view class="back" @click="back">
<uni-icons type="left" :size="20" color="#000"></uni-icons>
</view>
</view>
<view class="step-box">
<view
v-for="(item, index) in stepList"
:key="index"
:class="['step-item', stepIndex >= index ? 'active-item' : '']"
@click="setStep(index)"
>
<view class="num">
<view class="text">
<text class="num-text">{{ index + 1 }}</text>
</view>
</view>
<text>{{ item }}</text>
</view>
</view>
<view class="content-box">
<view v-if="stepIndex != 2" class="search-box">
<view class="search-input">
<view v-if="!edit" :class="['input', searchValue != '' ? '' : 'placeholder']" @click="open">
<text v-if="searchValue != ''">{{ searchValue }}</text>
<text v-else>
请输入门店名称/商户号搜索
<view class="sprite-icon icon-search"></view>
</text>
</view>
<input
v-else
type="text"
class="input"
v-model="searchValue"
:focus="inputFocus"
confirm-type="search"
@blur="search"
@confirm="search"
/>
</view>
<view v-if="searchValue != ''" class="clear" @click="clear">
<uni-icons type="closeempty" :size="16" color="#1A1A1A"></uni-icons>
</view>
</view>
<!-- #ifdef APP -->
<scroll-view class="list" scroll-y :show-scrollbar="true">
<!-- #endif -->
<!-- #ifndef APP -->
<view class="list">
<!-- #endif -->
<account-list
v-show="stepIndex == 0"
ref="accountRef"
@chooseAccount="chooseAccount"
/>
<view v-show="stepIndex == 1">商户列表占位</view>
<view v-show="stepIndex == 2">场景选择占位</view>
<!-- #ifdef APP -->
</scroll-view>
<!-- #endif -->
<!-- #ifndef APP -->
</view>
<!-- #endif -->
</view>
</view>
</view>
</template>
<script setup lang="uts">
import { ref } from 'vue'
import { onLoad } from '@dcloudio/uni-app'
const stepList = ref<string[]>(['选择账号', '选择4S店', '选择场景'])
const stepIndex = ref<number>(0)
const searchValue = ref<string>('')
const edit = ref<boolean>(false)
const inputFocus = ref<boolean>(false)
let accountRef: any | null = null
onLoad((options: UTSJSONObject | null) => {
const stepIndexOpt = options != null ? (options['stepIndex'] as string | null) : null
if (stepIndexOpt == '1') {
stepIndex.value = 1
setTimeout(() => {
if (accountRef != null) {
const refObj = accountRef as UTSJSONObject
const method = refObj['getListSelectAccount']
if (method != null) {
(method as (autoLogin: boolean) => void)(true)
}
}
}, 100)
}
})
const search = (): void => {
edit.value = false
inputFocus.value = false
const step = stepIndex.value
if (step == 0 && accountRef != null) {
const refObj = accountRef as UTSJSONObject
const method = refObj['searchEvent']
if (method != null) {
(method as (searchValue: string) => void)(searchValue.value)
}
}
// TODO: 其他步骤的搜索
}
const open = (): void => {
edit.value = true
inputFocus.value = true
}
const back = (): void => {
uni.navigateBack()
}
const setStep = (index: number): void => {
if (index == 2) return
if (stepIndex.value > index) {
stepIndex.value = index
}
}
const clear = (): void => {
searchValue.value = ''
search()
}
const chooseAccount = (userInfo: any): void => {
console.log('chooseAccount:', userInfo)
stepIndex.value = 1
searchValue.value = ''
// TODO: 等待 MerchantList 组件迁移完成后,调用 merchantRef.init(userInfo)
}
const chooseMerchant = (userInfo: any): void => {
console.log('chooseMerchant:', userInfo)
stepIndex.value = 2
searchValue.value = ''
// TODO: 等待 Scene 组件迁移完成后,调用 sceneRef.init(userInfo)
}
</script>
<style scoped lang="scss">
.page-container {
width: 100%;
height: 100%;
position: relative;
.bg {
position: absolute;
width: 100%;
height: 100%;
left: 0;
top: 0;
.bg-image {
width: 100%;
height: 100%;
display: block;
}
}
.layout {
width: 100%;
height: 100%;
padding-top: 72px;
font-size: 14px;
color: #333;
letter-spacing: 0;
box-sizing: border-box;
flex-direction: column;
align-items: center;
position: relative;
.nav-bar {
position: absolute;
width: 100%;
height: 48px;
left: 0;
top: 24px;
.back {
width: 48px;
height: 48px;
display: flex;
align-items: center;
justify-content: center;
}
}
.step-box {
position: relative;
display: flex;
align-items: center;
justify-content: center;
.step-item {
display: flex;
align-items: center;
font-weight: 500;
font-size: 36px;
color: #999999;
margin-right: 81.5px;
&:last-child {
margin-right: 0;
}
.num {
width: 28px;
height: 28px;
position: relative;
padding: 2px;
box-sizing: border-box;
margin-right: 5px;
&::after {
position: absolute;
top: 0;
left: 0;
bottom: 0;
right: 0;
border: 1px solid #b1b1b1;
content: '';
border-radius: 14px;
}
.text {
width: 100%;
height: 100%;
background: #b1b1b1;
border-radius: 12px;
display: flex;
align-items: center;
justify-content: center;
overflow: hidden;
}
.num-text {
font-weight: 700;
font-size: 16px;
color: #ffffff;
}
}
}
.active-item {
color: #4673ff;
.num {
&::after {
border-color: #4673ff;
}
.text {
background: #4673ff;
}
}
}
}
.content-box {
width: 81.84%;
flex: 1;
position: relative;
margin-top: 24px;
box-sizing: border-box;
padding-top: 24px;
box-shadow: inset 0 0 8px 0 #ffffff;
border-radius: 24px;
background: #ffffff59;
flex-direction: column;
&::after {
position: absolute;
content: '';
left: 0;
top: 0;
width: 100%;
height: 100%;
background: #ffffff59;
box-shadow: inset 0 0 8px 0 #ffffff;
border-radius: 24px;
filter: blur(4px);
}
}
.search-box {
margin: 0 12px 24px;
position: relative;
.search-input {
width: 100%;
height: 40px;
background: #ffffff;
border: 1.5px solid #a8c1ff;
border-radius: 1px;
box-sizing: border-box;
color: #333;
padding: 0 6px;
font-size: 11px;
position: relative;
.input {
display: flex;
align-items: center;
height: 100%;
width: 100%;
justify-content: center;
text-align: center;
font-size: 11px;
}
.icon-search {
margin-left: 1px;
}
.placeholder {
font-size: 11px;
color: #999999;
}
}
.clear {
position: absolute;
top: 50%;
right: 0;
transform: translateY(-50%);
padding: 0 1px;
height: 100%;
display: flex;
align-items: center;
}
}
.list {
position: relative;
height: calc(100% - 88px);
flex-direction: column;
}
}
}
</style>
<template>
<view class="list-not">
<image src="/static/images/login/nothing.webp" class="list-not-img" />
<text>暂无内容</text>
</view>
</template>
<script setup lang="uts">
</script>
<style scoped lang="scss">
.list-not {
font-size: 11px;
color: #999999;
margin: auto;
text-align: center;
flex-direction: column;
&-img {
width: 338px;
height: 281px;
margin: 191px auto 6px;
display: block;
}
}
</style>
<template>
<view style="flex: 1">
<view id="chart-container-1" class="chart-container">
<!-- #ifdef APP -->
<!-- APP 端:禁用悬停效果和点击交互,减少 web-view 通信开销 -->
<l-echart ref="chartRef"
:before-delay="0"
class="chart"
:enable-hover="false"
:is-clickable="false"
@finished="initChart">
</l-echart>
<!-- #endif -->
<!-- #ifndef APP -->
<l-echart ref="chartRef"
class="chart"
@finished="initChart">
</l-echart>
<!-- #endif -->
</view>
<view id="chart-container-2"
class="chart-container"
style="margin-top: 16px">
<!-- #ifdef APP -->
<!-- APP 端:禁用悬停效果和点击交互,减少 web-view 通信开销 -->
<l-echart ref="lineChartRef"
:before-delay="0"
class="chart"
:enable-hover="false"
:is-clickable="false"
@finished="initLineChart">
</l-echart>
<!-- #endif -->
<!-- #ifndef APP -->
<l-echart ref="lineChartRef"
class="chart"
@finished="initLineChart">
</l-echart>
<!-- #endif -->
</view>
</view>
<view
style="flex: 1"
>
<view class="chart-container" id="chart-container-1">
<!-- #ifdef APP -->
<!-- APP 端:禁用悬停效果和点击交互,减少 web-view 通信开销 -->
<l-echart
ref="chartRef"
@finished="initChart"
class="chart"
:enable-hover="false"
:is-clickable="false"
:before-delay="0">
</l-echart>
<!-- #endif -->
<!-- #ifndef APP -->
<l-echart ref="chartRef" @finished="initChart" class="chart"></l-echart>
<!-- #endif -->
</view>
<view class="chart-container" id="chart-container-2" style="margin-top: 16px">
<!-- #ifdef APP -->
<!-- APP 端:禁用悬停效果和点击交互,减少 web-view 通信开销 -->
<l-echart
ref="lineChartRef"
@finished="initLineChart"
class="chart"
:enable-hover="false"
:is-clickable="false"
:before-delay="0">
</l-echart>
<!-- #endif -->
<!-- #ifndef APP -->
<l-echart ref="lineChartRef" @finished="initLineChart" class="chart"></l-echart>
<!-- #endif -->
</view>
</view>
</template>
<script setup lang="uts">
import { get } from "@/utils/common.uts";
......
<template>
<view>
<image class="image"
:fade-show="true"
mode="widthFix"
:src="imageSrc">
</image>
<video autoplay
class="video"
controls
:src="src"
style="width: 100%; height: 300px">
</video>
</view>
<view>
<image class="image" :fade-show="true" mode="widthFix" :src="imageSrc"></image>
<video
class="video"
:src="src"
controls
autoplay
style="width: 100%; height: 300px"
></video>
</view>
</template>
<script setup lang="uts">
const src =ref("https://qiniu-web-assets.dcloud.net.cn/video/sample/2minute-demo.mp4");
const imageSrc =ref("https://glsk-oss.oss-cn-shenzhen.aliyuncs.com/quality/1762827440132_9hivo0xz.jpg");
const src =ref('https://qiniu-web-assets.dcloud.net.cn/video/sample/2minute-demo.mp4')
const imageSrc =ref('https://glsk-oss.oss-cn-shenzhen.aliyuncs.com/quality/1762827440132_9hivo0xz.jpg')
</script>
<template>
<scroll-view class="flex flex-col bg-gray-50"
scroll-y="true"
style="flex: 1">
<view class="flex flex-col px-5 py-5">
<!-- 标题区域 -->
<view class="bg-blue-500 px-6 py-8 flex-col mb-5 rounded-lg">
<text class="text-3xl font-bold text-white mb-2 block">权限申请示例</text>
<text class="text-base text-white opacity-90 block">使用 permission-handler-plus 插件</text>
</view>
<scroll-view style="flex: 1" scroll-y="true" class="flex flex-col bg-gray-50">
<view class="flex flex-col px-5 py-5">
<!-- 标题区域 -->
<view class="bg-blue-500 px-6 py-8 flex-col mb-5 rounded-lg">
<text class="text-3xl font-bold text-white mb-2 block">权限申请示例</text>
<text class="text-base text-white opacity-90 block">使用 permission-handler-plus 插件</text>
</view>
<!-- 权限列表 -->
<view class="flex flex-col">
<view v-for="permission in permissions"
:key="permission.name"
class="bg-white rounded-lg p-4 shadow-sm mb-4 flex-col">
<!-- 权限名称和状态 -->
<view class="flex flex-row items-center justify-between mb-3">
<view class="flex flex-row items-center">
<text class="text-2xl mr-3">{{ permission.icon }}</text>
<view class="flex flex-col">
<text class="text-lg font-semibold text-gray-800 block">{{ permission.displayName }}</text>
<text class="text-sm text-gray-500 block">{{ permission.desc }}</text>
</view>
</view>
<view class="px-3 py-1 rounded-full"
:class="`status-${ permission.status}`">
<text class="text-xs font-medium" :class="`status-text-${ permission.status}`">
{{ getStatusText(permission.status) }}
</text>
</view>
</view>
<!-- 权限列表 -->
<view class="flex flex-col">
<view
v-for="permission in permissions"
:key="permission.name"
class="bg-white rounded-lg p-4 shadow-sm mb-4 flex-col"
>
<!-- 权限名称和状态 -->
<view class="flex flex-row items-center justify-between mb-3">
<view class="flex flex-row items-center">
<text class="text-2xl mr-3">{{ permission.icon }}</text>
<view class="flex flex-col">
<text class="text-lg font-semibold text-gray-800 block">{{ permission.displayName }}</text>
<text class="text-sm text-gray-500 block">{{ permission.desc }}</text>
</view>
</view>
<view
class="px-3 py-1 rounded-full"
:class="'status-' + permission.status"
>
<text class="text-xs font-medium" :class="'status-text-' + permission.status">
{{ getStatusText(permission.status) }}
</text>
</view>
</view>
<!-- 操作按钮 -->
<view class="flex flex-row flex-wrap">
<button class="btn btn-primary mr-2 mb-2"
@click="checkPermission(permission)">
检查权限
</button>
<button class="btn btn-success mr-2 mb-2"
:disabled="permission.status === 'granted'"
@click="requestPermission(permission)">
申请权限
</button>
</view>
</view>
</view>
<!-- 操作按钮 -->
<view class="flex flex-row flex-wrap">
<button
class="btn btn-primary mr-2 mb-2"
@click="checkPermission(permission)"
>
检查权限
</button>
<button
class="btn btn-success mr-2 mb-2"
@click="requestPermission(permission)"
:disabled="permission.status === 'granted'"
>
申请权限
</button>
</view>
</view>
</view>
<!-- 操作日志 -->
<view class="bg-white rounded-lg p-4 shadow-sm mt-4 flex-col">
<text class="text-lg font-semibold text-gray-800 mb-3 block">操作日志</text>
<scroll-view class="flex flex-col"
scroll-y="true"
style="max-height: 300px">
<view v-for="(log, index) in logs"
:key="index"
class="mb-2 pb-2 border-b border-gray-200">
<text class="text-sm text-gray-600 block">{{ log }}</text>
</view>
</scroll-view>
<button class="btn btn-secondary mt-3"
@click="clearLogs">
清空日志
</button>
</view>
</view>
</scroll-view>
<!-- 操作日志 -->
<view class="bg-white rounded-lg p-4 shadow-sm mt-4 flex-col">
<text class="text-lg font-semibold text-gray-800 mb-3 block">操作日志</text>
<scroll-view style="max-height: 300px" scroll-y="true" class="flex flex-col">
<view
v-for="(log, index) in logs"
:key="index"
class="mb-2 pb-2 border-b border-gray-200"
>
<text class="text-sm text-gray-600 block">{{ log }}</text>
</view>
</scroll-view>
<button
class="btn btn-secondary mt-3"
@click="clearLogs"
>
清空日志
</button>
</view>
</view>
</scroll-view>
</template>
<script setup lang="uts">
// 统一导入,编译器会自动根据平台选择对应的实现
import { checkPermission, requestPermissions } from "@/uni_modules/permission-handler-plus";
import { get } from "@/utils/common.uts";
type PermissionStatus = "denied" | "granted" | "limited" | "permanentlyDenied" | "provisional" | "restricted" | "unknown";
type PermissionStatus = "unknown" | "granted" | "denied" | "restricted" | "limited" | "permanentlyDenied" | "provisional";
type Permission = {
desc: string;
name: string;
displayName: string;
desc: string;
icon: string;
name: string;
status: PermissionStatus;
};
......@@ -178,7 +187,7 @@ const checkPermission = (permission: Permission) => {
// 更新权限状态
const index = permissions.value.findIndex((p) => p.name == permission.name);
if (index !== -1) {
if (index >= 0) {
// 将插件返回的状态字符串转换为我们的状态类型
let status: PermissionStatus = "unknown";
if (result == "granted") {
......@@ -220,7 +229,7 @@ const requestPermission = (permission: Permission) => {
// 更新权限状态
const index = permissions.value.findIndex((p) => p.name == permission.name);
if (index !== -1) {
if (index >= 0) {
let status: PermissionStatus = "unknown";
if (statusStr == "granted") {
status = "granted";
......
<template>
<scroll-view class="flex flex-col bg-indigo-500" style="flex: 1">
<view class="flex flex-col">
<view class="flex flex-col">
<view class="flex flex-col px-8 pt-10 pb-8 items-center">
<text class="text-3xl font-bold text-white mb-2">uni-app x 示例</text>
<text class="text-base text-white opacity-90">功能演示与测试</text>
</view>
<scroll-view style="flex: 1" class="flex flex-col bg-indigo-500">
<view class="flex flex-col">
<view class="flex flex-col">
<view class="flex flex-col px-8 pt-10 pb-8 items-center">
<text class="text-3xl font-bold text-white mb-2">uni-app x 示例</text>
<text class="text-base text-white opacity-90">功能演示与测试</text>
</view>
<view class="flex flex-col px-12 py-12 flex-1 bg-gray-50 rounded-t-3xl">
<view v-for="item in data"
:key="item.label + item.path"
class="bg-white rounded-2xl shadow-lg border border-gray-200 overflow-hidden w-full"
:class="{ 'card-pressed': isCardPressed(item.path) }"
@tap="toPath(item)"
@touchend="pressedCard = ''"
@touchstart="handleTouchStart(item.path)">
<!-- 使用 justify-between 而不是依赖 flex-1,兼容 App 端布局行为 -->
<view class="flex flex-row items-center p-5 w-full">
<view class="flex flex-row items-center">
<view class="w-48 h-48 flex items-center justify-center bg-indigo-100 rounded-xl flex-shrink-0 mr-4">
<text class="text-2xl">{{ getIcon(item.icon) }}</text>
</view>
<text class="text-lg font-semibold text-gray-800">
{{ item.label }}
</text>
</view>
<view class="w-32 h-32 flex items-center justify-center bg-indigo-500 rounded-lg flex-shrink-0"
style="margin-left: auto">
<text class="text-lg text-white font-bold">→</text>
</view>
</view>
</view>
</view>
</view>
</view>
</scroll-view>
<view class="flex flex-col px-12 py-12 flex-1 bg-gray-50 rounded-t-3xl">
<view
class="bg-white rounded-2xl shadow-lg border border-gray-200 overflow-hidden w-full"
:class="{ 'card-pressed': isCardPressed(item.path) }"
@touchstart="handleTouchStart(item.path)"
@touchend="pressedCard = ''"
@tap="toPath(item)"
v-for="item in data"
:key="item.label + item.path"
>
<!-- 使用 justify-between 而不是依赖 flex-1,兼容 App 端布局行为 -->
<view class="flex flex-row items-center p-5 w-full">
<view class="flex flex-row items-center">
<view
class="w-48 h-48 flex items-center justify-center bg-indigo-100 rounded-xl flex-shrink-0 mr-4"
>
<text class="text-2xl">{{ getIcon(item.icon) }}</text>
</view>
<text class="text-lg font-semibold text-gray-800">
{{ item.label }}
</text>
</view>
<view
class="w-32 h-32 flex items-center justify-center bg-indigo-500 rounded-lg flex-shrink-0"
style="margin-left: auto"
>
<text class="text-lg text-white font-bold">→</text>
</view>
</view>
</view>
</view>
</view>
</view>
</scroll-view>
</template>
<script setup lang="uts">
......@@ -42,12 +48,12 @@ import { get } from "@/utils/common.uts";
// import { router } from "@/utils/router.uts";
type Item = {
children?: Item[];
disabled?: boolean;
hidden?: boolean;
icon?: string;
label: string;
icon?: string;
path?: string;
disabled?: boolean;
hidden?: boolean;
children?: Item[];
};
const data = computed<Item[]>(() => {
......@@ -128,8 +134,8 @@ const toPath = (item: Item) => {
// 使用索引访问属性,避免 error18
// NavigateToFailImpl 类型特殊,需要先转换为 UTSJSONObject 或使用索引访问
let errMsg = "未知错误";
let errCode: null | number = null;
let errSubject: null | string = null;
let errCode: number | null = null;
let errSubject: string | null = null;
// 尝试使用 UTSJSONObject 转换
try {
......@@ -148,7 +154,7 @@ const toPath = (item: Item) => {
if (errSubjectTemp != null) {
errSubject = errSubjectTemp as string;
}
} catch {
} catch (e: any) {
// 如果转换失败,尝试使用 JSON 序列化/反序列化
try {
const jsonStr = JSON.stringify(err);
......@@ -166,8 +172,8 @@ const toPath = (item: Item) => {
if (errSubjectTemp != null) {
errSubject = errSubjectTemp as string;
}
} catch (error: any) {
console.error("无法解析错误对象:", error);
} catch (e2: any) {
console.error("无法解析错误对象:", e2);
}
}
......
const path = require("node:path");
const { r } = require("./shared");
const path = require("path");
// 确保能找到 tailwindcss-rem2px-preset 模块
// 使用 resolve 来查找模块路径,支持不同的工作目录
......
......@@ -2,19 +2,19 @@
"extends": "@vue/tsconfig/tsconfig.json",
"compilerOptions": {
"ignoreDeprecations": "5.0",
"lib": ["esnext", "dom"],
"verbatimModuleSyntax": true,
"experimentalDecorators": true,
"paths": {
"@/*": ["./src/*"],
"$/*": ["./uni_modules/*"]
},
"sourceMap": true,
"resolveJsonModule": true,
"types": ["@dcloudio/types", "vue"],
"esModuleInterop": true,
"noImplicitAny": false,
"types": ["@dcloudio/types", "vue"],
"lib": ["esnext", "dom"],
"outDir": "esbuild",
"sourceMap": true,
"esModuleInterop": true,
"verbatimModuleSyntax": true
"paths": {
"@/*": ["./src/*"],
"$/*": ["./uni_modules/*"]
}
},
"vueCompilerOptions": {
"extensions": [".vue", ".uvue"]
......
export type UserInfo = {
avatarUrl?: string; // 头像
birthday?: string; // 生日
city?: string; // 城市
createTime: string; // 创建时间
description?: string; // 描述
district?: string; // 区县
gender: number; // 性别
unionid: string; // 用户唯一id
id: number; // 用户id
loginType: number; // 登录类型
nickName: string; // 昵称
avatarUrl?: string; // 头像
phone: string; // 手机号
province?: string; // 省份
gender: number; // 性别
status: number; // 状态
unionid: string; // 用户唯一id
description?: string; // 描述
loginType: number; // 登录类型
province?: string; // 省份
city?: string; // 城市
district?: string; // 区县
birthday?: string; // 生日
createTime: string; // 创建时间
updateTime: string; // 更新时间
};
export type PushAnimationType =
| "auto"
| "fade-in"
| "none"
| "pop-in"
| "slide-in-bottom"
| "slide-in-left"
| "slide-in-right"
| "slide-in-left"
| "slide-in-top"
| "slide-in-bottom"
| "fade-in"
| "zoom-out"
| "zoom-fade-out"
| "zoom-out";
| "pop-in";
export type BackAnimationType =
| "auto"
| "fade-out"
| "none"
| "pop-out"
| "slide-out-bottom"
| "slide-out-left"
| "slide-out-right"
| "slide-out-left"
| "slide-out-top"
| "slide-out-bottom"
| "fade-out"
| "zoom-in"
| "zoom-fade-in"
| "zoom-in";
| "pop-out";
export type PushMode = "navigateTo" | "redirectTo" | "reLaunch" | "switchTab";
export type BackOptions = {
animationDuration?: number;
animationType?: BackAnimationType;
complete?: (result: any) => void;
delta?: number;
fail?: (result: any) => void;
animationType?: BackAnimationType;
animationDuration?: number;
success?: (result: any) => void;
fail?: (result: any) => void;
complete?: (result: any) => void;
};
export type PushOptions = {
animationDuration?: number;
animationType?: PushAnimationType;
complete?: (result: any) => void;
path: string;
mode?: PushMode;
events?: any;
fail?: (result: any) => void;
query?: UTSJSONObject;
isAuth?: boolean;
mode?: PushMode;
params?: UTSJSONObject;
path: string;
query?: UTSJSONObject;
animationType?: PushAnimationType;
animationDuration?: number;
success?: (result: any) => void;
fail?: (result: any) => void;
complete?: (result: any) => void;
};
export type PageInstance = {
path: string;
vm: any;
style?: UTSJSONObject;
query: UTSJSONObject;
exposed: any;
isCustomNavbar: boolean;
meta?: UTSJSONObject;
path: string;
query: UTSJSONObject;
style?: UTSJSONObject;
vm: any;
};
declare module "@dcloudio/vite-plugin-uni";
declare type Theme = "dark" | "light";
declare type Theme = "light" | "dark";
declare interface Uni {
rpx2px(px: number): number;
......@@ -16,28 +16,28 @@ declare interface Uni {
}
declare interface JSON {
parseObject<T>(text: string): null | T;
parseObject<T>(text: string): T | null;
}
declare type UTSJSONObject = {
[key: string]: any;
parse?<T>(): T | null;
get?(key: string): any | null;
set?(key: string, value: any | null): void;
getAny?(key: string): any | null;
getAny?(key: string, def: any): any;
getArray?<T>(key: string): null | T[];
getArray?<T>(key: string, def: T[]): T[];
getArray?(key: string): any[] | null;
getArray?(key: string, def: any[]): any[];
getBoolean?(key: string): boolean | null;
getBoolean?(key: string, def: any): boolean;
getJSON?(key: string): null | UTSJSONObject;
getJSON?(key: string, def: any): UTSJSONObject;
getNumber?(key: string): null | number;
getNumber?(key: string): number | null;
getNumber?(key: string, def: any): number;
getString?(key: string): null | string;
getString?(key: string): string | null;
getString?(key: string, def: any): string;
parse?<T>(): null | T;
set?(key: string, value: any | null): void;
getJSON?(key: string): UTSJSONObject | null;
getJSON?(key: string, def: any): UTSJSONObject;
getArray?<T>(key: string): T[] | null;
getArray?<T>(key: string, def: T[]): T[];
getArray?(key: string): any[] | null;
getArray?(key: string, def: any[]): any[];
toMap?(): Map<string, any>;
};
......@@ -49,14 +49,14 @@ declare interface ChooseImageTempFile {
}
declare type RequestMethod =
| "CONNECT"
| "DELETE"
| "OPTIONS"
| "GET"
| "HEAD"
| "OPTIONS"
| "POST"
| "PUT"
| "TRACE";
| "DELETE"
| "TRACE"
| "CONNECT";
declare interface DOMRect {
x: number;
......@@ -82,33 +82,33 @@ declare interface UniElement {
style: CSSStyleDeclaration;
classList: string[];
takeSnapshot(options: {
fail?: (err: { errCode: number; errMsg: string }) => void;
success?: (res: { tempFilePath: string }) => void;
fail?: (err: { errCode: number; errMsg: string }) => void;
}): void;
getBoundingClientRectAsync(): Promise<DOMRect>;
getDrawableContext(): DrawableContext;
animate(
keyframes: UniAnimationKeyframe | UniAnimationKeyframe[],
options?:
| number
| {
delay?: number;
direction?: "alternate" | "alternate-reverse" | "normal" | "reverse";
direction?: "normal" | "reverse" | "alternate" | "alternate-reverse";
duration?: number;
easing?:
| "cubic-bezier"
| "ease"
| "ease-in"
| "ease-in-out"
| "ease-out"
| "linear";
fill?: "backwards" | "both" | "forwards" | "none";
| "ease-in-out"
| "linear"
| "cubic-bezier";
fill?: "backwards" | "forwards" | "both" | "none";
iterations?: number;
}
): null | {
| number
): {
id: string;
playState: "finished" | "idle" | "paused" | "running";
};
playState: "running" | "paused" | "finished" | "idle";
} | null;
}
declare interface CanvasContext extends HTMLCanvasElement {
......
## 2.0.12(2025-08-26)
- 优化 uni-app x 下 size 类型问题
## 2.0.11(2025-08-18)
- 修复 图标点击事件返回
## 2.0.9(2024-01-12)
fix: 修复图标大小默认值错误的问题
## 2.0.8(2023-12-14)
- 修复 项目未使用 ts 情况下,打包报错的bug
## 2.0.7(2023-12-14)
- 修复 size 属性为 string 时,不加单位导致尺寸异常的bug
## 2.0.6(2023-12-11)
- 优化 兼容老版本icon类型,如 top ,bottom 等
## 2.0.5(2023-12-11)
- 优化 兼容老版本icon类型,如 top ,bottom 等
## 2.0.4(2023-12-06)
- 优化 uni-app x 下示例项目图标排序
## 2.0.3(2023-12-06)
- 修复 nvue下引入组件报错的bug
## 2.0.2(2023-12-05)
-优化 size 属性支持单位
## 2.0.1(2023-12-05)
- 新增 uni-app x 支持定义图标
## 1.3.5(2022-01-24)
- 优化 size 属性可以传入不带单位的字符串数值
## 1.3.4(2022-01-24)
- 优化 size 支持其他单位
## 1.3.3(2022-01-17)
- 修复 nvue 有些图标不显示的bug,兼容老版本图标
## 1.3.2(2021-12-01)
- 优化 示例可复制图标名称
## 1.3.1(2021-11-23)
- 优化 兼容旧组件 type 值
## 1.3.0(2021-11-19)
- 新增 更多图标
- 优化 自定义图标使用方式
- 优化 组件UI,并提供设计资源,详见:[https://uniapp.dcloud.io/component/uniui/resource](https://uniapp.dcloud.io/component/uniui/resource)
- 文档迁移,详见:[https://uniapp.dcloud.io/component/uniui/uni-icons](https://uniapp.dcloud.io/component/uniui/uni-icons)
## 1.1.7(2021-11-08)
## 1.2.0(2021-07-30)
- 组件兼容 vue3,如何创建vue3项目,详见 [uni-app 项目支持 vue3 介绍](https://ask.dcloud.net.cn/article/37834)
## 1.1.5(2021-05-12)
- 新增 组件示例地址
## 1.1.4(2021-02-05)
- 调整为uni_modules目录规范
<template>
<text class="uni-icons" :style="styleObj">
<slot>{{unicode}}</slot>
</text>
</template>
<script>
import { fontData, IconsDataItem } from './uniicons_file'
/**
* Icons 图标
* @description 用于展示 icon 图标
* @tutorial https://ext.dcloud.net.cn/plugin?id=28
* @property {Number} size 图标大小
* @property {String} type 图标图案,参考示例
* @property {String} color 图标颜色
* @property {String} customPrefix 自定义图标
* @event {Function} click 点击 Icon 触发事件
*/
export default {
name: "uni-icons",
props: {
type: {
type: String,
default: ''
},
color: {
type: String,
default: '#333333'
},
size: {
type: [Number, String],
default: 16
},
fontFamily: {
type: String,
default: ''
}
},
data() {
return {};
},
computed: {
unicode() : string {
let codes = fontData.find((item : IconsDataItem) : boolean => { return item.font_class == this.type })
if (codes !== null) {
return codes.unicode
}
return ''
},
iconSize() : string {
const size = this.size
if (typeof size == 'string') {
const reg = /^[0-9]*$/g
return reg.test(size as string) ? '' + size + 'px' : '' + size;
// return '' + this.size
}
return this.getFontSize(size as number)
},
styleObj() : UTSJSONObject {
if (this.fontFamily !== '') {
return { color: this.color, fontSize: this.iconSize, fontFamily: this.fontFamily }
}
return { color: this.color, fontSize: this.iconSize }
}
},
created() { },
methods: {
/**
* 字体大小
*/
getFontSize(size : number) : string {
return size + 'px';
},
},
}
</script>
<style scoped>
@font-face {
font-family: UniIconsFontFamily;
src: url('./uniicons.ttf');
}
.uni-icons {
font-family: UniIconsFontFamily;
font-size: 18px;
font-style: normal;
color: #333;
}
</style>
<template>
<!-- #ifdef APP-NVUE -->
<text :style="styleObj" class="uni-icons" @click="_onClick">{{unicode}}</text>
<!-- #endif -->
<!-- #ifndef APP-NVUE -->
<text :style="styleObj" class="uni-icons" :class="['uniui-'+type,customPrefix,customPrefix?type:'']" @click="_onClick">
<slot></slot>
</text>
<!-- #endif -->
</template>
<script>
import { fontData } from './uniicons_file_vue.js';
const getVal = (val) => {
const reg = /^[0-9]*$/g
return (typeof val === 'number' || reg.test(val)) ? val + 'px' : val;
}
// #ifdef APP-NVUE
var domModule = weex.requireModule('dom');
import iconUrl from './uniicons.ttf'
domModule.addRule('fontFace', {
'fontFamily': "uniicons",
'src': "url('" + iconUrl + "')"
});
// #endif
/**
* Icons 图标
* @description 用于展示 icons 图标
* @tutorial https://ext.dcloud.net.cn/plugin?id=28
* @property {Number} size 图标大小
* @property {String} type 图标图案,参考示例
* @property {String} color 图标颜色
* @property {String} customPrefix 自定义图标
* @event {Function} click 点击 Icon 触发事件
*/
export default {
name: 'UniIcons',
emits: ['click'],
props: {
type: {
type: String,
default: ''
},
color: {
type: String,
default: '#333333'
},
size: {
type: [Number, String],
default: 16
},
customPrefix: {
type: String,
default: ''
},
fontFamily: {
type: String,
default: ''
}
},
data() {
return {
icons: fontData
}
},
computed: {
unicode() {
let code = this.icons.find(v => v.font_class === this.type)
if (code) {
return code.unicode
}
return ''
},
iconSize() {
return getVal(this.size)
},
styleObj() {
if (this.fontFamily !== '') {
return `color: ${this.color}; font-size: ${this.iconSize}; font-family: ${this.fontFamily};`
}
return `color: ${this.color}; font-size: ${this.iconSize};`
}
},
methods: {
_onClick(e) {
this.$emit('click', e)
}
}
}
</script>
<style lang="scss">
/* #ifndef APP-NVUE */
@import './uniicons.css';
@font-face {
font-family: uniicons;
src: url('./uniicons.ttf');
}
/* #endif */
.uni-icons {
font-family: uniicons;
text-decoration: none;
text-align: center;
}
</style>
\ No newline at end of file
.uniui-cart-filled:before {
content: "\e6d0";
}
.uniui-gift-filled:before {
content: "\e6c4";
}
.uniui-color:before {
content: "\e6cf";
}
.uniui-wallet:before {
content: "\e6b1";
}
.uniui-settings-filled:before {
content: "\e6ce";
}
.uniui-auth-filled:before {
content: "\e6cc";
}
.uniui-shop-filled:before {
content: "\e6cd";
}
.uniui-staff-filled:before {
content: "\e6cb";
}
.uniui-vip-filled:before {
content: "\e6c6";
}
.uniui-plus-filled:before {
content: "\e6c7";
}
.uniui-folder-add-filled:before {
content: "\e6c8";
}
.uniui-color-filled:before {
content: "\e6c9";
}
.uniui-tune-filled:before {
content: "\e6ca";
}
.uniui-calendar-filled:before {
content: "\e6c0";
}
.uniui-notification-filled:before {
content: "\e6c1";
}
.uniui-wallet-filled:before {
content: "\e6c2";
}
.uniui-medal-filled:before {
content: "\e6c3";
}
.uniui-fire-filled:before {
content: "\e6c5";
}
.uniui-refreshempty:before {
content: "\e6bf";
}
.uniui-location-filled:before {
content: "\e6af";
}
.uniui-person-filled:before {
content: "\e69d";
}
.uniui-personadd-filled:before {
content: "\e698";
}
.uniui-arrowthinleft:before {
content: "\e6d2";
}
.uniui-arrowthinup:before {
content: "\e6d3";
}
.uniui-arrowthindown:before {
content: "\e6d4";
}
.uniui-back:before {
content: "\e6b9";
}
.uniui-forward:before {
content: "\e6ba";
}
.uniui-arrow-right:before {
content: "\e6bb";
}
.uniui-arrow-left:before {
content: "\e6bc";
}
.uniui-arrow-up:before {
content: "\e6bd";
}
.uniui-arrow-down:before {
content: "\e6be";
}
.uniui-arrowthinright:before {
content: "\e6d1";
}
.uniui-down:before {
content: "\e6b8";
}
.uniui-bottom:before {
content: "\e6b8";
}
.uniui-arrowright:before {
content: "\e6d5";
}
.uniui-right:before {
content: "\e6b5";
}
.uniui-up:before {
content: "\e6b6";
}
.uniui-top:before {
content: "\e6b6";
}
.uniui-left:before {
content: "\e6b7";
}
.uniui-arrowup:before {
content: "\e6d6";
}
.uniui-eye:before {
content: "\e651";
}
.uniui-eye-filled:before {
content: "\e66a";
}
.uniui-eye-slash:before {
content: "\e6b3";
}
.uniui-eye-slash-filled:before {
content: "\e6b4";
}
.uniui-info-filled:before {
content: "\e649";
}
.uniui-reload:before {
content: "\e6b2";
}
.uniui-micoff-filled:before {
content: "\e6b0";
}
.uniui-map-pin-ellipse:before {
content: "\e6ac";
}
.uniui-map-pin:before {
content: "\e6ad";
}
.uniui-location:before {
content: "\e6ae";
}
.uniui-starhalf:before {
content: "\e683";
}
.uniui-star:before {
content: "\e688";
}
.uniui-star-filled:before {
content: "\e68f";
}
.uniui-calendar:before {
content: "\e6a0";
}
.uniui-fire:before {
content: "\e6a1";
}
.uniui-medal:before {
content: "\e6a2";
}
.uniui-font:before {
content: "\e6a3";
}
.uniui-gift:before {
content: "\e6a4";
}
.uniui-link:before {
content: "\e6a5";
}
.uniui-notification:before {
content: "\e6a6";
}
.uniui-staff:before {
content: "\e6a7";
}
.uniui-vip:before {
content: "\e6a8";
}
.uniui-folder-add:before {
content: "\e6a9";
}
.uniui-tune:before {
content: "\e6aa";
}
.uniui-auth:before {
content: "\e6ab";
}
.uniui-person:before {
content: "\e699";
}
.uniui-email-filled:before {
content: "\e69a";
}
.uniui-phone-filled:before {
content: "\e69b";
}
.uniui-phone:before {
content: "\e69c";
}
.uniui-email:before {
content: "\e69e";
}
.uniui-personadd:before {
content: "\e69f";
}
.uniui-chatboxes-filled:before {
content: "\e692";
}
.uniui-contact:before {
content: "\e693";
}
.uniui-chatbubble-filled:before {
content: "\e694";
}
.uniui-contact-filled:before {
content: "\e695";
}
.uniui-chatboxes:before {
content: "\e696";
}
.uniui-chatbubble:before {
content: "\e697";
}
.uniui-upload-filled:before {
content: "\e68e";
}
.uniui-upload:before {
content: "\e690";
}
.uniui-weixin:before {
content: "\e691";
}
.uniui-compose:before {
content: "\e67f";
}
.uniui-qq:before {
content: "\e680";
}
.uniui-download-filled:before {
content: "\e681";
}
.uniui-pyq:before {
content: "\e682";
}
.uniui-sound:before {
content: "\e684";
}
.uniui-trash-filled:before {
content: "\e685";
}
.uniui-sound-filled:before {
content: "\e686";
}
.uniui-trash:before {
content: "\e687";
}
.uniui-videocam-filled:before {
content: "\e689";
}
.uniui-spinner-cycle:before {
content: "\e68a";
}
.uniui-weibo:before {
content: "\e68b";
}
.uniui-videocam:before {
content: "\e68c";
}
.uniui-download:before {
content: "\e68d";
}
.uniui-help:before {
content: "\e679";
}
.uniui-navigate-filled:before {
content: "\e67a";
}
.uniui-plusempty:before {
content: "\e67b";
}
.uniui-smallcircle:before {
content: "\e67c";
}
.uniui-minus-filled:before {
content: "\e67d";
}
.uniui-micoff:before {
content: "\e67e";
}
.uniui-closeempty:before {
content: "\e66c";
}
.uniui-clear:before {
content: "\e66d";
}
.uniui-navigate:before {
content: "\e66e";
}
.uniui-minus:before {
content: "\e66f";
}
.uniui-image:before {
content: "\e670";
}
.uniui-mic:before {
content: "\e671";
}
.uniui-paperplane:before {
content: "\e672";
}
.uniui-close:before {
content: "\e673";
}
.uniui-help-filled:before {
content: "\e674";
}
.uniui-paperplane-filled:before {
content: "\e675";
}
.uniui-plus:before {
content: "\e676";
}
.uniui-mic-filled:before {
content: "\e677";
}
.uniui-image-filled:before {
content: "\e678";
}
.uniui-locked-filled:before {
content: "\e668";
}
.uniui-info:before {
content: "\e669";
}
.uniui-locked:before {
content: "\e66b";
}
.uniui-camera-filled:before {
content: "\e658";
}
.uniui-chat-filled:before {
content: "\e659";
}
.uniui-camera:before {
content: "\e65a";
}
.uniui-circle:before {
content: "\e65b";
}
.uniui-checkmarkempty:before {
content: "\e65c";
}
.uniui-chat:before {
content: "\e65d";
}
.uniui-circle-filled:before {
content: "\e65e";
}
.uniui-flag:before {
content: "\e65f";
}
.uniui-flag-filled:before {
content: "\e660";
}
.uniui-gear-filled:before {
content: "\e661";
}
.uniui-home:before {
content: "\e662";
}
.uniui-home-filled:before {
content: "\e663";
}
.uniui-gear:before {
content: "\e664";
}
.uniui-smallcircle-filled:before {
content: "\e665";
}
.uniui-map-filled:before {
content: "\e666";
}
.uniui-map:before {
content: "\e667";
}
.uniui-refresh-filled:before {
content: "\e656";
}
.uniui-refresh:before {
content: "\e657";
}
.uniui-cloud-upload:before {
content: "\e645";
}
.uniui-cloud-download-filled:before {
content: "\e646";
}
.uniui-cloud-download:before {
content: "\e647";
}
.uniui-cloud-upload-filled:before {
content: "\e648";
}
.uniui-redo:before {
content: "\e64a";
}
.uniui-images-filled:before {
content: "\e64b";
}
.uniui-undo-filled:before {
content: "\e64c";
}
.uniui-more:before {
content: "\e64d";
}
.uniui-more-filled:before {
content: "\e64e";
}
.uniui-undo:before {
content: "\e64f";
}
.uniui-images:before {
content: "\e650";
}
.uniui-paperclip:before {
content: "\e652";
}
.uniui-settings:before {
content: "\e653";
}
.uniui-search:before {
content: "\e654";
}
.uniui-redo-filled:before {
content: "\e655";
}
.uniui-list:before {
content: "\e644";
}
.uniui-mail-open-filled:before {
content: "\e63a";
}
.uniui-hand-down-filled:before {
content: "\e63c";
}
.uniui-hand-down:before {
content: "\e63d";
}
.uniui-hand-up-filled:before {
content: "\e63e";
}
.uniui-hand-up:before {
content: "\e63f";
}
.uniui-heart-filled:before {
content: "\e641";
}
.uniui-mail-open:before {
content: "\e643";
}
.uniui-heart:before {
content: "\e639";
}
.uniui-loop:before {
content: "\e633";
}
.uniui-pulldown:before {
content: "\e632";
}
.uniui-scan:before {
content: "\e62a";
}
.uniui-bars:before {
content: "\e627";
}
.uniui-checkbox:before {
content: "\e62b";
}
.uniui-checkbox-filled:before {
content: "\e62c";
}
.uniui-shop:before {
content: "\e62f";
}
.uniui-headphones:before {
content: "\e630";
}
.uniui-cart:before {
content: "\e631";
}
{
"id": "uni-icons",
"displayName": "uni-icons 图标",
"version": "2.0.12",
"description": "图标组件,用于展示移动端常见的图标,可自定义颜色、大小。",
"keywords": [
"uni-ui",
"uniui",
"icon",
"图标"
],
"repository": "https://github.com/dcloudio/uni-ui",
"engines": {
"HBuilderX": "^3.2.14",
"uni-app": "^4.08",
"uni-app-x": "^4.61"
},
"directories": {
"example": "../../temps/example_temps"
},
"dcloudext": {
"sale": {
"regular": {
"price": "0.00"
},
"sourcecode": {
"price": "0.00"
}
},
"contact": {
"qq": ""
},
"declaration": {
"ads": "无",
"data": "无",
"permissions": "无"
},
"npmurl": "https://www.npmjs.com/package/@dcloudio/uni-ui",
"type": "component-vue",
"darkmode": "x",
"i18n": "x",
"widescreen": "x"
},
"uni_modules": {
"dependencies": [
"uni-scss"
],
"encrypt": [],
"platforms": {
"cloud": {
"tcb": "x",
"aliyun": "x",
"alipay": "x"
},
"client": {
"uni-app": {
"vue": {
"vue2": "√",
"vue3": "√"
},
"web": {
"safari": "√",
"chrome": "√"
},
"app": {
"vue": "√",
"nvue": "-",
"android": {
"extVersion": "",
"minVersion": "29"
},
"ios": "√",
"harmony": "√"
},
"mp": {
"weixin": "√",
"alipay": "√",
"toutiao": "√",
"baidu": "√",
"kuaishou": "-",
"jd": "-",
"harmony": "-",
"qq": "√",
"lark": "-"
},
"quickapp": {
"huawei": "√",
"union": "√"
}
},
"uni-app-x": {
"web": {
"safari": "√",
"chrome": "√"
},
"app": {
"android": {
"extVersion": "",
"minVersion": "29"
},
"ios": "√",
"harmony": "√"
},
"mp": {
"weixin": "√"
}
}
}
}
}
}
\ No newline at end of file
## Icons 图标
> **组件名:uni-icons**
> 代码块: `uIcons`
用于展示 icons 图标 。
### [查看文档](https://uniapp.dcloud.io/component/uniui/uni-icons)
#### 如使用过程中有任何问题,或者您对uni-ui有一些好的建议,欢迎加入 uni-ui 交流群:871950839
{"version":3,"sources":["pages/common/components/NoData.uvue"],"sourcesContent":["<template>\n <view class=\"list-not\">\n <image src=\"/static/images/login/nothing.webp\" class=\"list-not-img\" />\n <text>暂无内容</text>\n </view>\n</template>\n\n<script setup lang=\"uts\">\n</script>\n\n<style scoped lang=\"scss\">\n.list-not {\n font-size: 11px;\n color: #999999;\n margin: auto;\n text-align: center;\n flex-direction: column;\n \n &-img {\n width: 338px;\n height: 281px;\n margin: 191px auto 6px;\n display: block;\n }\n}\n</style>\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;eACE,IAGO,QAAA,IAHD,WAAM,aAAU;YACpB,IAAsE,SAAA,IAA/D,SAAI,qCAAoC,WAAM;YACrD,IAAiB,QAAA,IAAA,EAAX"}
\ No newline at end of file
{"version":3,"sources":["uni_modules/uni-icons/components/uni-icons/uni-icons.uvue"],"sourcesContent":["<template>\r\n\t<text class=\"uni-icons\" :style=\"styleObj\">\r\n\t\t<slot>{{unicode}}</slot>\r\n\t</text>\r\n</template>\r\n\r\n<script>\r\n\timport { fontData, IconsDataItem } from './uniicons_file'\r\n\r\n\t/**\r\n\t * Icons 图标\r\n\t * @description 用于展示 icon 图标\r\n\t * @tutorial https://ext.dcloud.net.cn/plugin?id=28\r\n\t * @property {Number} size 图标大小\r\n\t * @property {String} type 图标图案,参考示例\r\n\t * @property {String} color 图标颜色\r\n\t * @property {String} customPrefix 自定义图标\r\n\t * @event {Function} click 点击 Icon 触发事件\r\n\t */\r\n\texport default {\r\n\t\tname: \"uni-icons\",\r\n\t\tprops: {\r\n\t\t\ttype: {\r\n\t\t\t\ttype: String,\r\n\t\t\t\tdefault: ''\r\n\t\t\t},\r\n\t\t\tcolor: {\r\n\t\t\t\ttype: String,\r\n\t\t\t\tdefault: '#333333'\r\n\t\t\t},\r\n\t\t\tsize: {\r\n type: [Number, String],\r\n default: 16\r\n\t\t\t},\r\n\t\t\tfontFamily: {\r\n\t\t\t\ttype: String,\r\n\t\t\t\tdefault: ''\r\n\t\t\t}\r\n\t\t},\r\n\t\tdata() {\r\n\t\t\treturn {};\r\n\t\t},\r\n\t\tcomputed: {\r\n\t\t\tunicode() : string {\r\n\t\t\t\tlet codes = fontData.find((item : IconsDataItem) : boolean => { return item.font_class == this.type })\r\n\t\t\t\tif (codes !== null) {\r\n\t\t\t\t\treturn codes.unicode\r\n\t\t\t\t}\r\n\t\t\t\treturn ''\r\n\t\t\t},\r\n\t\t\ticonSize() : string {\r\n\t\t\t\tconst size = this.size\n\t\t\t\tif (typeof size == 'string') {\n\t\t\t\t const reg = /^[0-9]*$/g\n\t\t\t\t return reg.test(size as string) ? '' + size + 'px' : '' + size;\n\t\t\t\t // return '' + this.size\n\t\t\t\t}\n\t\t\t\treturn this.getFontSize(size as number)\r\n\t\t\t},\r\n\t\t\tstyleObj() : UTSJSONObject {\r\n\t\t\t\tif (this.fontFamily !== '') {\r\n\t\t\t\t\treturn { color: this.color, fontSize: this.iconSize, fontFamily: this.fontFamily }\r\n\t\t\t\t}\r\n\t\t\t\treturn { color: this.color, fontSize: this.iconSize }\r\n\t\t\t}\r\n\t\t},\r\n\t\tcreated() { },\r\n\t\tmethods: {\r\n\t\t\t/**\r\n\t\t\t * 字体大小\r\n\t\t\t */\r\n\t\t\tgetFontSize(size : number) : string {\r\n\t\t\t\treturn size + 'px';\r\n\t\t\t},\r\n\t\t},\r\n\t}\r\n</script>\r\n\r\n<style scoped>\r\n\t@font-face {\r\n\t\tfont-family: UniIconsFontFamily;\r\n\t\tsrc: url('./uniicons.ttf');\r\n\t}\r\n\r\n\t.uni-icons {\r\n\t\tfont-family: UniIconsFontFamily;\r\n\t\tfont-size: 18px;\r\n\t\tfont-style: normal;\r\n\t\tcolor: #333;\r\n\t}\r\n</style>\n"],"names":[],"mappings":";;;;;;;;;;;;;;AAmBM;;kBA+CJ,MAAO,CAAK;;;;;;eAjEb,IAEO,QAAA,IAFD,WAAM,aAAa,WAAK,IAAE,KAAA,QAAQ;YACvC,WAAwB,KAAA,QAAA,EAAA,WAAA,eAAA,EAAxB,gBAAwB,GAAA;uBAAA;oBAAA,IAAhB,KAAA,OAAO;iBAAA;;;;;IAoBd,SAAA,wBAGC;IACD,SAAA,yBAGC;IACD,SAAA,qBAGC;IACD,SAAA,8BAGA;sBAMY,MAAK;uBAOJ,MAAK;uBASL;;;yCAhBD,MAAK,EAAjB,OAAY,MAAK,CAAA;YAChB,IAAI,QAAQ,SAAS,IAAI,CAAC,IAAC,sBAAwB,OAAM,CAAG;gBAAI,OAAO,KAAK,UAAS,CAAA,EAAA,CAAK,IAAI,CAAC,IAAG;YAAE;;YACpG,IAAI,MAAI,EAAA,CAAM,IAAI,EAAE;gBACnB,OAAO,MAAM,OAAM;;YAEpB,OAAO;QACR;kCACa,MAAK,EAAlB,OAAa,MAAK,CAAA;YACjB,IAAM,OAAO,IAAI,CAAC,IAAG;YACrB,IAAI,oBAAO,MAAG,EAAA,CAAK,UAAU;gBAC3B,IAAM,MAAM;gBACZ,OAAO,IAAA,IAAI,IAAI,CAAC,KAAG,EAAA,CAAK,MAAM,GAAI;oBAAA,GAAC,CAAA,CAAA,CAAI,KAAG,EAAA,CAAA,MAAA,EAAA,CAAA,CAAI;gBAAA,EAAO,IAAS,CAAT;oBAAA,GAAC,CAAA,CAAA,CAAI,KAAI,EAAA,CAAA,MAAA;gBAAA;;YAGhE,OAAO,IAAI,CAAC,WAAW,CAAC,KAAG,EAAA,CAAK,MAAM;QACvC;kCACa,eAAb,OAAa,cAAY;YACxB,IAAI,IAAI,CAAC,UAAS,CAAA,GAAA,CAAM,IAAI;gBAC3B,OAAO,IAAE,WAAO,IAAI,CAAC,KAAK,EAAE,cAAU,IAAI,CAAC,QAAQ,EAAE,gBAAY,IAAI,CAAC,UAAS;;YAEhF,OAAO,IAAE,WAAO,IAAI,CAAC,KAAK,EAAE,cAAU,IAAI,CAAC,QAAO;QACnD;;;aAOA;aAAA,mBAAY,MAAO,MAAM,GAAI,MAAK,CAAA;QACjC,OAAO,KAAG,CAAA,CAAI;IACf;;mBArDK;;;;;;;;;;;;;4BAEL,UAAM,IACC,UAAA,UACG,aAAA,KAEV,WAAO,IACA,UAAA,UACG,aAAA,YAEV,UAAM;;;WAEQ,aAAA,EAAC,GAEf,gBAAY,IACL,UAAA,UACG,aAAA;;;;;;;;;AAuCZ"}
\ No newline at end of file
......@@ -4,49 +4,65 @@
"compiler_version": "4.87"
},
"files": {
"components/evaluationForm/TypeTabComponent.kt": {
"md5": "0c65870c54770c8dfebb843dc83b547ef7d25a50",
"class": "GenComponentsEvaluationFormTypeTabComponent"
"pages/index/index.kt": {
"class": "GenPagesIndexIndex",
"md5": "d8d028fdb9eab322150af58a90c2361ddfea3f18"
},
"uni_modules/z-paging-x/components/z-paging-x/z-paging-x.kt": {
"md5": "4e08a9502eacce0a379370f55af65cc373be4d86",
"class": "GenUniModulesZPagingXComponentsZPagingXZPagingX"
"index.kt": {
"md5": "58f0fea201e4278f6bc39c939656ca440a4b8d98",
"class": ""
},
"uni_modules/z-paging-x/components/z-paging-x/components/z-paging-loading.kt": {
"class": "GenUniModulesZPagingXComponentsZPagingXComponentsZPagingLoading",
"md5": "bc2c0931a10ad4eea405d60556ee5e702cc28f62"
},
"pages/common/login/index.kt": {
"md5": "165659590e28e0663c371d8606710e0c7fd36859",
"class": "GenPagesCommonLoginIndex"
},
"components/PublishPopup.kt": {
"md5": "b0c3be2d9836f013bc4b67bbf5fe08a456f6ce18",
"class": "GenComponentsPublishPopup"
},
"pages/demo/record/index.kt": {
"class": "GenPagesDemoRecordIndex",
"md5": "84e76df7ed975ac1925322c2e8a598c39e5c84af"
},
"pages/demo/echarts/index.kt": {
"md5": "e9c323efac81c50aa4eca12e75586263bacd95fb",
"class": "GenPagesDemoEchartsIndex"
},
"pages/demo/local-store/index.kt": {
"class": "GenPagesDemoLocalStoreIndex",
"md5": "6360b2df10619a70490f9f6f126d91728741e2c2"
},
"uni_modules/lime-echart/components/l-echart/l-echart.kt": {
"class": "GenUniModulesLimeEchartComponentsLEchartLEchart",
"md5": "23c5a52d57071d3771477b55f910fbe9ccac83fc"
"md5": "23c5a52d57071d3771477b55f910fbe9ccac83fc",
"class": "GenUniModulesLimeEchartComponentsLEchartLEchart"
},
"pages/demo/media/index.kt": {
"class": "GenPagesDemoMediaIndex",
"md5": "d76917918ad2397c0cd8429328b52ab77a83ff4f"
},
"pages/demo/permission/index.kt": {
"class": "GenPagesDemoPermissionIndex",
"md5": "18cb329597e3254e8c67cefdc1f196e3a1260273"
},
"uni_modules/z-paging-x/components/z-paging-x/components/z-paging-refresher.kt": {
"md5": "16ff705042a40a87dd8d71d3fa16ad4a017d0301",
"class": "GenUniModulesZPagingXComponentsZPagingXComponentsZPagingRefresher"
},
"pages/index/index.kt": {
"md5": "d8d028fdb9eab322150af58a90c2361ddfea3f18",
"class": "GenPagesIndexIndex"
"pages/common/components/AccountList.kt": {
"class": "GenPagesCommonComponentsAccountList",
"md5": "d78e30a9fd29b1bd3fc6451b74a39845095f79ee"
},
"pages/common/login/index.kt": {
"class": "GenPagesCommonLoginIndex",
"md5": "8275e3dccc8940758ddc7640b511dd5005c5f790"
"uni_modules/z-paging-x/components/z-paging-x/z-paging-x.kt": {
"class": "GenUniModulesZPagingXComponentsZPagingXZPagingX",
"md5": "4e08a9502eacce0a379370f55af65cc373be4d86"
},
"uni_modules/z-paging-x/components/z-paging-x/components/z-paging-load-more.kt": {
"class": "GenUniModulesZPagingXComponentsZPagingXComponentsZPagingLoadMore",
"md5": "a09e63a3254f1a7fd1be3a47e1d27eccb876c289"
"uni_modules/uni-icons/components/uni-icons/uni-icons.kt": {
"class": "GenUniModulesUniIconsComponentsUniIconsUniIcons",
"md5": "95aae1ef2b0e8906a602ca5d24eea964329fab31"
},
"uni_modules/z-paging-x/components/z-paging-x/components/z-paging-loading.kt": {
"class": "GenUniModulesZPagingXComponentsZPagingXComponentsZPagingLoading",
"md5": "bc2c0931a10ad4eea405d60556ee5e702cc28f62"
"pages/common/accountItems/index.kt": {
"class": "GenPagesCommonAccountItemsIndex",
"md5": "ce7b7aebc25c812bc76446384be7b4ae423373da"
},
"pages/demo/gl-tape-demo/index.kt": {
"class": "GenPagesDemoGlTapeDemoIndex",
......@@ -56,21 +72,17 @@
"class": "GenPagesDemoTailwindcssIndex",
"md5": "c427026081cb75ed3d462c5ebf8a3ac0750bfa34"
},
"components/PublishPopup.kt": {
"md5": "b0c3be2d9836f013bc4b67bbf5fe08a456f6ce18",
"class": "GenComponentsPublishPopup"
},
"pages/demo/echarts/index.kt": {
"md5": "e9c323efac81c50aa4eca12e75586263bacd95fb",
"class": "GenPagesDemoEchartsIndex"
"pages/common/components/NoData.kt": {
"md5": "0608111022dbb7da0f7c3e452b7409d1ec7f5735",
"class": "GenPagesCommonComponentsNoData"
},
"pages/demo/local-store/index.kt": {
"md5": "6360b2df10619a70490f9f6f126d91728741e2c2",
"class": "GenPagesDemoLocalStoreIndex"
"components/evaluationForm/TypeTabComponent.kt": {
"class": "GenComponentsEvaluationFormTypeTabComponent",
"md5": "0c65870c54770c8dfebb843dc83b547ef7d25a50"
},
"index.kt": {
"md5": "6e6ffa4e30e8732dd679c2a64e01a087e018ab0b",
"class": ""
"uni_modules/z-paging-x/components/z-paging-x/components/z-paging-load-more.kt": {
"class": "GenUniModulesZPagingXComponentsZPagingXComponentsZPagingLoadMore",
"md5": "a09e63a3254f1a7fd1be3a47e1d27eccb876c289"
},
"uni_modules/z-paging-x/components/z-paging-x-empty/z-paging-x-empty.kt": {
"class": "GenUniModulesZPagingXComponentsZPagingXEmptyZPagingXEmpty",
......@@ -79,6 +91,10 @@
"pages/demo/old/index.kt": {
"class": "GenPagesDemoOldIndex",
"md5": "8b8d4a1b49e2ef7592d4e2f958b222392cf46fe8"
},
"pages/demo/permission/index.kt": {
"md5": "18cb329597e3254e8c67cefdc1f196e3a1260273",
"class": "GenPagesDemoPermissionIndex"
}
}
}
\ No newline at end of file
@file:Suppress("UNCHECKED_CAST", "USELESS_CAST", "INAPPLICABLE_JVM_NAME", "UNUSED_ANONYMOUS_PARAMETER", "NAME_SHADOWING", "UNNECESSARY_NOT_NULL_ASSERTION")
package uni.UNIB602BFA
import io.dcloud.uniapp.*
import io.dcloud.uniapp.extapi.*
import io.dcloud.uniapp.framework.*
import io.dcloud.uniapp.runtime.*
import io.dcloud.uniapp.vue.*
import io.dcloud.uniapp.vue.shared.*
import io.dcloud.unicloud.*
import io.dcloud.uts.*
import io.dcloud.uts.Map
import io.dcloud.uts.Set
import io.dcloud.uts.UTSAndroid
import kotlin.properties.Delegates
open class GenPagesCommonComponentsNoData : VueComponent {
constructor(__ins: ComponentInternalInstance) : super(__ins) {}
@Suppress("UNUSED_PARAMETER", "UNUSED_VARIABLE")
override fun `$render`(): Any? {
val _cache = this.`$`.renderCache
return _cE("view", _uM("class" to "list-not"), _uA(
_cE("image", _uM("src" to "/static/images/login/nothing.webp", "class" to "list-not-img")),
_cE("text", null, "暂无内容")
))
}
companion object {
val styles: Map<String, Map<String, Map<String, Any>>> by lazy {
_nCS(_uA(
styles0
))
}
val styles0: Map<String, Map<String, Map<String, Any>>>
get() {
return _uM("text-hide" to _pS(_uM("whiteSpace" to "nowrap", "overflow" to "hidden", "textOverflow" to "ellipsis")), "text-two-line" to _pS(_uM("WebkitBoxOrient" to "vertical", "WebkitLineClamp" to 2, "overflow" to "hidden", "textOverflow" to "ellipsis")), "select-item" to _uM(".select-box " to _uM("display" to "flex", "justifyContent" to "center", "alignItems" to "center")), "common-title" to _pS(_uM("width" to "100%", "height" to "120rpx", "position" to "relative", "display" to "flex", "alignItems" to "center", "paddingLeft" to "48rpx", "color" to "#333333", "fontSize" to "34rpx", "content::after" to "\"\"", "position::after" to "absolute", "left::after" to 0, "top::after" to 0, "zIndex::after" to -2, "width::after" to "100%", "height::after" to "100%", "backgroundImage::after" to "linear-gradient(0deg, #94c2ff00 0%, #5294ff 100%)", "backgroundColor::after" to "rgba(0,0,0,0)", "opacity::after" to 0.15, "content::before" to "\"\"", "position::before" to "absolute", "zIndex::before" to -1, "width::before" to "136rpx", "height::before" to "136rpx", "opacity::before" to 0.6, "backgroundImage::before" to "linear-gradient(-44.4deg, #94c2ff00 0%, #5294ff 100%)", "backgroundColor::before" to "rgba(0,0,0,0)", "filter::before" to "blur(24rpx)")), "bg-title" to _pS(_uM("position" to "absolute", "top" to 0, "left" to 0, "width" to "100%", "height" to "120rpx", "display" to "flex", "alignItems" to "center", "paddingLeft" to "48rpx", "color" to "#333333", "fontSize" to "34rpx", "content::after" to "\"\"", "position::after" to "absolute", "left::after" to 0, "top::after" to 0, "zIndex::after" to -2, "width::after" to "100%", "height::after" to "100%", "backgroundImage::after" to "linear-gradient(0deg, #94c2ff00 0%, #5294ff 100%)", "backgroundColor::after" to "rgba(0,0,0,0)", "opacity::after" to 0.15, "content::before" to "\"\"", "position::before" to "absolute", "zIndex::before" to -1, "width::before" to "136rpx", "height::before" to "136rpx", "opacity::before" to 0.6, "backgroundImage::before" to "linear-gradient(-44.4deg, #94c2ff00 0%, #5294ff 100%)", "backgroundColor::before" to "rgba(0,0,0,0)", "filter::before" to "blur(24rpx)")), "list-not" to _pS(_uM("fontSize" to 11, "color" to "#999999", "marginTop" to "auto", "marginRight" to "auto", "marginBottom" to "auto", "marginLeft" to "auto", "textAlign" to "center", "flexDirection" to "column")), "list-not-img" to _pS(_uM("width" to 338, "height" to 281, "marginTop" to 191, "marginRight" to "auto", "marginBottom" to 6, "marginLeft" to "auto")))
}
var inheritAttrs = true
var inject: Map<String, Map<String, Any?>> = _uM()
var emits: Map<String, Any?> = _uM()
var props = _nP(_uM())
var propsNeedCastKeys: UTSArray<String> = _uA()
var components: Map<String, CreateVueComponent> = _uM()
}
}
@file:Suppress("UNCHECKED_CAST", "USELESS_CAST", "INAPPLICABLE_JVM_NAME", "UNUSED_ANONYMOUS_PARAMETER", "NAME_SHADOWING", "UNNECESSARY_NOT_NULL_ASSERTION")
package uni.UNIB602BFA
import io.dcloud.uniapp.*
import io.dcloud.uniapp.extapi.*
import io.dcloud.uniapp.framework.*
import io.dcloud.uniapp.runtime.*
import io.dcloud.uniapp.vue.*
import io.dcloud.uniapp.vue.shared.*
import io.dcloud.unicloud.*
import io.dcloud.uts.*
import io.dcloud.uts.Map
import io.dcloud.uts.Set
import io.dcloud.uts.UTSAndroid
import kotlin.properties.Delegates
open class GenUniModulesUniIconsComponentsUniIconsUniIcons : VueComponent {
constructor(__ins: ComponentInternalInstance) : super(__ins) {
onCreated(fun() {}, __ins)
}
@Suppress("UNUSED_PARAMETER", "UNUSED_VARIABLE")
override fun `$render`(): Any? {
val _ctx = this
val _cache = this.`$`.renderCache
return _cE("text", _uM("class" to "uni-icons", "style" to _nS(_ctx.styleObj)), _uA(
renderSlot(_ctx.`$slots`, "default", UTSJSONObject(), fun(): UTSArray<Any> {
return _uA(
_tD(_ctx.unicode)
)
}
)
), 4)
}
open var type: String by `$props`
open var color: String by `$props`
open var size: Any by `$props`
open var fontFamily: String by `$props`
open var unicode: String by `$data`
open var iconSize: String by `$data`
open var styleObj: UTSJSONObject by `$data`
@Suppress("USELESS_CAST")
override fun data(): Map<String, Any?> {
return _uM("unicode" to computed<String>(fun(): String {
var codes = fontData.find(fun(item: IconsDataItem): Boolean {
return item.font_class == this.type
}
)
if (codes != null) {
return codes.unicode
}
return ""
}
), "iconSize" to computed<String>(fun(): String {
val size = this.size
if (UTSAndroid.`typeof`(size) == "string") {
val reg = UTSRegExp("^[0-9]*\$", "g")
return if (reg.test(size as String)) {
"" + (size as String) + "px"
} else {
"" + (size as String)
}
}
return this.getFontSize(size as Number)
}
), "styleObj" to computed<UTSJSONObject>(fun(): UTSJSONObject {
if (this.fontFamily !== "") {
return _uO("color" to this.color, "fontSize" to this.iconSize, "fontFamily" to this.fontFamily)
}
return _uO("color" to this.color, "fontSize" to this.iconSize)
}
))
}
open var getFontSize = ::gen_getFontSize_fn
open fun gen_getFontSize_fn(size: Number): String {
return size + "px"
}
companion object {
var name = "uni-icons"
val styles: Map<String, Map<String, Map<String, Any>>> by lazy {
_nCS(_uA(
styles0
))
}
val styles0: Map<String, Map<String, Map<String, Any>>>
get() {
return _uM("uni-icons" to _pS(_uM("fontFamily" to "UniIconsFontFamily", "fontSize" to 18, "fontStyle" to "normal", "color" to "#333333")), "@FONT-FACE" to _uM("0" to _uM("fontFamily" to "UniIconsFontFamily", "src" to "url('/assets/uniicons.32e978a5.ttf')")))
}
var inheritAttrs = true
var inject: Map<String, Map<String, Any?>> = _uM()
var emits: Map<String, Any?> = _uM()
var props = _nP(_uM("type" to _uM("type" to "String", "default" to ""), "color" to _uM("type" to "String", "default" to "#333333"), "size" to _uM("type" to _uA(
"Number",
"String"
), "default" to 16), "fontFamily" to _uM("type" to "String", "default" to "")))
var propsNeedCastKeys = _uA(
"type",
"color",
"size",
"fontFamily"
)
var components: Map<String, CreateVueComponent> = _uM()
}
}
{"duts":["uni-actionSheet","uni-theme","uni-getSystemInfo","uni-base64ToArrayBuffer","uni-arrayBufferToBase64","uni-crash","uni-storage","uni-dialogPage","uni-event","uni-exit","uni-form","uni-getAccessibilityInfo","uni-getAppAuthorizeSetting","uni-getAppBaseInfo","uni-getDeviceInfo","uni-getElementById","uni-getSystemSetting","uni-modal","uni-openAppAuthorizeSetting","uni-privacy","uni-progress","uni-prompt","uni-rpx2px","uni-rich-text","uni-barcode-scanning","uni-camera","uni-media","permission-handler-plus","uni-location","uni-location-system","lime-sqlite","uts-recorder","uni-createInnerAudioContext","uni-clipboard","uni-previewImage","uni-network","uni-fileSystemManager","uni-video"]}
\ No newline at end of file
{"duts":["uni-actionSheet","uni-theme","uni-getSystemInfo","uni-base64ToArrayBuffer","uni-arrayBufferToBase64","uni-crash","uni-storage","uni-dialogPage","uni-event","uni-exit","uni-form","uni-getAccessibilityInfo","uni-getAppAuthorizeSetting","uni-getAppBaseInfo","uni-getDeviceInfo","uni-getElementById","uni-getSystemSetting","uni-modal","uni-openAppAuthorizeSetting","uni-privacy","uni-progress","uni-prompt","uni-rpx2px","uni-rich-text","uni-barcode-scanning","uni-camera","uni-media","permission-handler-plus","uni-location","uni-location-system","lime-sqlite","uts-recorder","uni-createInnerAudioContext","uni-clipboard","uni-getNetworkType","uni-previewImage","uni-network","uni-fileSystemManager","uni-video"]}
\ No newline at end of file
......@@ -13,7 +13,7 @@ export function isArray(value: any): boolean {
* @example isObject([]) // false
*/
export function isObject(value: any): boolean {
return typeof value === "object" && !Array.isArray(value) && !isNull(value);
return typeof value == "object" && !Array.isArray(value) && !isNull(value);
}
/**
......@@ -22,7 +22,7 @@ export function isObject(value: any): boolean {
* @example isString(123) // false
*/
export function isString(value: any): boolean {
return typeof value === "string";
return typeof value == "string";
}
/**
......@@ -31,7 +31,7 @@ export function isString(value: any): boolean {
* @example isNumber('123') // false
*/
export function isNumber(value: any): boolean {
return typeof value === "number" && !isNaN(value);
return typeof value == "number" && !isNaN(value);
}
/**
......@@ -40,7 +40,7 @@ export function isNumber(value: any): boolean {
* @example isBoolean(1) // false
*/
export function isBoolean(value: any): boolean {
return typeof value === "boolean";
return typeof value == "boolean";
}
/**
......@@ -49,7 +49,7 @@ export function isBoolean(value: any): boolean {
* @example isFunction({}) // false
*/
export function isFunction(value: any): boolean {
return typeof value === "function";
return typeof value == "function";
}
/**
......@@ -75,7 +75,7 @@ export function isNull(value?: any | null): boolean {
*/
export function isEmpty(value: any): boolean {
if (isArray(value)) {
return (value as any[]).length === 0;
return (value as any[]).length == 0;
}
if (isString(value)) {
......@@ -83,7 +83,7 @@ export function isEmpty(value: any): boolean {
}
if (isObject(value)) {
return keys(value).length === 0;
return keys(value).length == 0;
}
return false;
......@@ -103,7 +103,7 @@ export function keys(value: any): string[] {
* @example first([1, 2, 3]) // 1
* @example first([]) // null
*/
export function first<T>(array: T[]): null | T {
export function first<T>(array: T[]): T | null {
return isArray(array) && array.length > 0 ? array[0] : null;
}
......@@ -112,7 +112,7 @@ export function first<T>(array: T[]): null | T {
* @example last([1, 2, 3]) // 3
* @example last([]) // null
*/
export function last<T>(array: T[]): null | T {
export function last<T>(array: T[]): T | null {
return isArray(array) && array.length > 0 ? array[array.length - 1] : null;
}
......@@ -179,8 +179,8 @@ export function map<T, U>(array: T[], iteratee: (item: T, index: number) => U):
if (!isArray(array)) return result;
for (const [i, element] of array.entries()) {
result.push(iteratee(element, i));
for (let i = 0; i < array.length; i++) {
result.push(iteratee(array[i], i));
}
return result;
......@@ -198,8 +198,8 @@ export function reduce<T, U>(
if (!isArray(array)) return initialValue;
let accumulator: U = initialValue;
for (const [i, element] of array.entries()) {
accumulator = iteratee(accumulator, element, i);
for (let i = 0; i < array.length; i++) {
accumulator = iteratee(accumulator, array[i], i);
}
return accumulator;
......@@ -212,8 +212,8 @@ export function reduce<T, U>(
export function every<T>(array: T[], predicate: (value: T, index: number) => boolean): boolean {
if (!isArray(array)) return true;
for (const [i, element] of array.entries()) {
if (!predicate(element, i)) {
for (let i = 0; i < array.length; i++) {
if (!predicate(array[i], i)) {
return false;
}
}
......@@ -228,8 +228,8 @@ export function every<T>(array: T[], predicate: (value: T, index: number) => boo
export function some<T>(array: T[], predicate: (value: T, index: number) => boolean): boolean {
if (!isArray(array)) return false;
for (const [i, element] of array.entries()) {
if (predicate(element, i)) {
for (let i = 0; i < array.length; i++) {
if (predicate(array[i], i)) {
return true;
}
}
......@@ -247,7 +247,8 @@ export function uniq<T>(array: T[]): T[] {
const result: T[] = [];
const seen = new Map<T, boolean>();
for (const item of array) {
for (let i = 0; i < array.length; i++) {
const item = array[i];
const key = item;
if (!seen.has(item)) {
seen.set(key, true);
......@@ -267,7 +268,8 @@ export function flatten(array: any[]): any[] {
const result: any[] = [];
for (const item of array) {
for (let i = 0; i < array.length; i++) {
const item = array[i];
if (isArray(item)) {
result.push(...(item as any[]));
} else {
......@@ -287,7 +289,8 @@ export function flattenDeep(array: any[]): any[] {
const result: any[] = [];
for (const item of array) {
for (let i = 0; i < array.length; i++) {
const item = array[i];
if (isArray(item)) {
result.push(...flattenDeep(item as any[]));
} else {
......@@ -307,11 +310,11 @@ export function sort<T>(array: T[], order: "asc" | "desc" = "asc"): T[] {
const result = [...array];
return result.sort((a, b) => {
if (typeof a === "number" && typeof b === "number") {
if (typeof a == "number" && typeof b == "number") {
return order == "asc" ? a - b : b - a;
}
if (typeof a === "string" && typeof b === "string") {
if (typeof a == "string" && typeof b == "string") {
return order == "asc" ? a.localeCompare(b) : b.localeCompare(a);
}
......@@ -351,14 +354,15 @@ export function groupBy<T>(array: T[], key: string) {
const result = {};
for (const item of array) {
for (let i = 0; i < array.length; i++) {
const item = array[i];
let value = get(item as any, key)!;
if (typeof value === "number") {
if (typeof value == "number") {
value = value.toString();
}
if (typeof value === "string") {
if (typeof value == "string") {
if (!isArray(result[value])) {
result[value] = new Array<T>();
}
......@@ -384,7 +388,7 @@ export function assign(...items: any[]) {
* @example nth([1, 2, 3], 1) // 2
* @example nth([1, 2, 3], -1) // 3
*/
export function nth<T>(array: T[], index: number): null | T {
export function nth<T>(array: T[], index: number): T | null {
if (index >= 0) {
return array[index];
}
......@@ -411,9 +415,9 @@ export function remove<T>(array: T[], predicate: (value: T, index: number) => bo
const result: T[] = [];
for (const [i, element] of array.entries()) {
if (!predicate(element, i)) {
result.push(element);
for (let i = 0; i < array.length; i++) {
if (!predicate(array[i], i)) {
result.push(array[i]);
}
}
......@@ -428,9 +432,9 @@ export function forEach<T>(data: T[], iteratee: (value: T, index: number) => voi
if (isArray(data)) {
const array = data as T[];
for (const [i, element] of array.entries()) {
if (element != null) {
iteratee(element, i);
for (let i = 0; i < array.length; i++) {
if (array[i] != null) {
iteratee(array[i], i);
}
}
}
......@@ -440,12 +444,12 @@ export function forEach<T>(data: T[], iteratee: (value: T, index: number) => voi
* 查找数组中第一个满足条件的元素
* @example find([1, 2, 3, 4], x => x > 2) // 3
*/
export function find<T>(array: T[], predicate: (value: T, index: number) => boolean): null | T {
export function find<T>(array: T[], predicate: (value: T, index: number) => boolean): T | null {
if (!isArray(array)) return null;
for (const [i, element] of array.entries()) {
if (predicate(element, i)) {
return element;
for (let i = 0; i < array.length; i++) {
if (predicate(array[i], i)) {
return array[i];
}
}
return null;
......@@ -458,7 +462,8 @@ export function find<T>(array: T[], predicate: (value: T, index: number) => bool
export function forInObject(data: any, iteratee: (value: any, key: string) => void): void {
if (isObject(data)) {
const objKeys = keys(data);
for (const key of objKeys) {
for (let i = 0; i < objKeys.length; i++) {
const key = objKeys[i];
iteratee(get(data, key)!, key);
}
}
......@@ -580,9 +585,9 @@ export function random(min: number, max: number): number {
*/
export function base64ToBlob(data: string, type: string = "image/jpeg"): Blob {
// #ifdef H5
const bytes = window.atob(data.split(",")[1]);
const ab = new ArrayBuffer(bytes.length);
const ia = new Uint8Array(ab);
let bytes = window.atob(data.split(",")[1]);
let ab = new ArrayBuffer(bytes.length);
let ia = new Uint8Array(ab);
for (let i = 0; i < bytes.length; i++) {
ia[i] = bytes.charCodeAt(i);
}
......
import { isArray, parse } from "../utils";
type Page = {
meta?: UTSJSONObject;
path: string;
style?: UTSJSONObject;
meta?: UTSJSONObject;
};
type SubPackage = {
pages: Page[];
root: string;
pages: Page[];
};
export type TabBarItem = {
iconPath?: string;
text?: string;
pagePath: string;
iconPath?: string;
selectedIconPath?: string;
text?: string;
visible?: boolean;
};
export type TabBar = {
custom?: boolean;
color?: string;
selectedColor?: string;
backgroundColor?: string;
backgroundImage?: string;
backgroundRepeat?: "no-repeat" | "repeat" | "repeat-x" | "repeat-y";
blurEffect?: "dark" | "extralight" | "light" | "none";
borderStyle?: string;
color?: string;
custom?: boolean;
blurEffect?: "dark" | "extralight" | "light" | "none";
list?: TabBarItem[];
position?: "top" | "bottom";
fontSize?: string;
height?: string;
iconWidth?: string;
list?: TabBarItem[];
position?: "bottom" | "top";
redDotColor?: string;
selectedColor?: string;
spacing?: string;
height?: string;
backgroundImage?: string;
backgroundRepeat?: "repeat" | "repeat-x" | "repeat-y" | "no-repeat";
redDotColor?: string;
};
export type Ctx = {
appid: string;
color: UTSJSONObject;
globalStyle: UTSJSONObject;
pages: Page[];
SAFE_CHAR_MAP_LOCALE: string[][];
subPackages: SubPackage[];
tabBar: TabBar;
theme: UTSJSONObject;
uniIdRouter: UTSJSONObject;
theme: UTSJSONObject;
tabBar: TabBar;
subPackages: SubPackage[];
SAFE_CHAR_MAP_LOCALE: string[][];
color: UTSJSONObject;
};
// 初始化 ctx 对象,不可修改!!
......@@ -64,7 +64,7 @@ if (isArray(ctx.subPackages)) {
ctx.subPackages.forEach((a) => {
a.pages.forEach((b) => {
PAGES.push({
path: `${a.root }/${ b.path}`, // 拼接子包根路径和页面路径
path: a.root + "/" + b.path, // 拼接子包根路径和页面路径
style: b.style,
meta: b.meta
});
......@@ -75,7 +75,7 @@ if (isArray(ctx.subPackages)) {
// 确保每个页面路径都以 "/" 开头,符合 uni-app x 规范
PAGES.forEach((e) => {
if (!e.path.startsWith("/")) {
e.path = `/${ e.path}`;
e.path = "/" + e.path;
}
});
......
export * from "./storage.uts";
export * from "./common.uts";
export * from "./parse.uts";
export * from "./storage.uts";
......@@ -9,11 +9,11 @@ import LocalStore from "./local-store";
// ===== 1. 定义数据 Schema =====
type UserSchema = {
name: string;
age: number;
createdAt: number;
email: string;
name: string;
status: "active" | "inactive";
createdAt: number;
updatedAt: number;
};
......@@ -199,10 +199,10 @@ try {
// 场景1:用户收藏管理
type FavoriteSchema = {
createdAt: number;
itemId: string;
itemType: "article" | "product" | "video";
userId: string;
itemId: string;
itemType: "article" | "video" | "product";
createdAt: number;
};
const favoriteStore = new LocalStore<FavoriteSchema>("favorite", {
......@@ -230,11 +230,11 @@ const userFavorites = favoriteStore.find({
// 场景2:购物车管理
type CartItemSchema = {
addedAt: number;
price: number;
productId: string;
productName: string;
price: number;
quantity: number;
addedAt: number;
};
const cartStore = new LocalStore<CartItemSchema>("cart", {
......@@ -262,6 +262,6 @@ if (cartItems.length > 0) {
// 计算购物车总价
let totalPrice = 0;
for (const cartItem of cartItems) {
totalPrice += cartItem.price * cartItem.quantity;
for (let i = 0; i < cartItems.length; i++) {
totalPrice += cartItems[i].price * cartItems[i].quantity;
}
......@@ -4,7 +4,7 @@ import { forEach, forInObject, isArray, isObject, isString } from "./common";
* 解析数据
* @example parse<Response>(res.data)
*/
export function parse<T>(data: any): null | T {
export function parse<T>(data: any): T | null {
// #ifdef APP-ANDROID
// @ts-ignore
return (data as UTSJSONObject).parse<T>();
......@@ -20,7 +20,7 @@ export function parse<T>(data: any): null | T {
* @param data 要解析的数据
* @returns 解析后的JSON对象
*/
export function parseObject<T>(data: string): null | T {
export function parseObject<T>(data: string): T | null {
// #ifdef APP-ANDROID
return JSON.parseObject<T>(data);
// #endif
......@@ -159,8 +159,8 @@ export const px2rpx = (px: number): number => {
* parseRpx('10px') // 返回 '10px'
*/
export const parseRpx = (val: number | string): string => {
if (typeof val === "number") {
return `${val }rpx`;
if (typeof val == "number") {
return val + "rpx";
}
return val;
......@@ -179,7 +179,7 @@ export const parseRpx = (val: number | string): string => {
export const getNum = (val: string): number => {
// 使用正则提取数字部分,支持小数和负数
const match = val.match(/-?\d+(\.\d+)?/);
return match != null ? Number.parseFloat(match[0] ?? "0") : 0;
return match != null ? parseFloat(match[0] ?? "0") : 0;
};
/**
......@@ -205,7 +205,7 @@ export const getUnit = (val: string): string => {
* @returns number - 返回对应的 rpx 数值
*/
export const getRpx = (val: number | string): number => {
if (typeof val === "number") {
if (typeof val == "number") {
return val;
}
......@@ -228,8 +228,8 @@ export const getRpx = (val: number | string): number => {
* @param val - 输入值,可以是 "10rpx"、"10px" 或数字 10
* @returns number - 返回对应的 px 数值
*/
export const getPx = (val: number | string) => {
if (typeof val === "number") {
export const getPx = (val: string | number) => {
if (typeof val == "number") {
return rpx2px(val);
}
......
......@@ -59,12 +59,12 @@ export function openAppSettings(): void {
*/
export function getInstalledPackages(): Promise<
Array<{
appName: string;
packName: string;
versionCode: number;
versionName: string;
versionCode: number;
appName: string;
}>
> {
> {
// #ifdef APP-ANDROID
const packages = androidImpl.getInstalledPackages();
return Promise.resolve(packages);
......
......@@ -60,8 +60,8 @@ export function readFile(filePath: string, encoding: string = "utf-8"): Promise<
return new Promise((resolve, reject) => {
const fs = uni.getFileSystemManager();
fs.readFile({
filePath,
encoding,
filePath: filePath,
encoding: encoding,
success: (res: any) => {
// ReadFileSuccessResult 类型,data 类型为 string | ArrayBuffer
// 由于 ReadFileSuccessResult 不是 UTSJSONObject,需要特殊处理
......@@ -77,10 +77,10 @@ export function readFile(filePath: string, encoding: string = "utf-8"): Promise<
if (parsed != null) {
const temp = parsed.getAny("data");
console.error("readFile getAny('data'):", temp);
console.error("readFile getAny('data'): ", temp);
raw = temp != null ? temp as any : null;
}
} catch {
} catch (e: any) {
// 方法2:如果 parseObject 失败,尝试用普通 parse
try {
......@@ -90,16 +90,16 @@ export function readFile(filePath: string, encoding: string = "utf-8"): Promise<
// 尝试从解析后的对象中获取 data
if (parsed != null) {
const temp = get(parsed as UTSJSONObject, "data");
console.error("readFile get('data'):", temp);
console.error("readFile get('data'): ", temp);
raw = temp != null ? temp as any : null;
}
} catch (error: any) {
console.error("readFile method2 failed:", error);
} catch (e2: any) {
console.error("readFile method2 failed: ", e2);
}
}
if (raw != null) {
if (typeof raw === "string") {
if (typeof raw == "string") {
text = raw as string;
} else {
// ArrayBuffer 类型,需要转换为字符串
......@@ -110,8 +110,8 @@ export function readFile(filePath: string, encoding: string = "utf-8"): Promise<
// @ts-ignore
const decoder = new TextDecoder("utf-8");
text = decoder.decode(raw as ArrayBuffer);
} catch (error: any) {
console.error("ArrayBuffer decode error:", error);
} catch (e: any) {
console.error("ArrayBuffer decode error: ", e);
text = "";
}
// #endif
......@@ -121,11 +121,11 @@ export function readFile(filePath: string, encoding: string = "utf-8"): Promise<
// #endif
}
}
console.error("readFile text final:", text);
console.error("readFile text final: ", text);
resolve(text);
},
fail: (err: any) => {
console.error("readFile fail:", err);
console.error("readFile fail: ", err);
reject(err);
}
});
......@@ -141,8 +141,8 @@ export function writeFile(filePath: string, data: string): Promise<void> {
return new Promise((resolve, reject) => {
const fs = uni.getFileSystemManager();
fs.writeFile({
filePath,
data,
filePath: filePath,
data: data,
encoding: "utf-8",
success: () => {
resolve();
......@@ -162,7 +162,7 @@ export function deleteFile(filePath: string): Promise<void> {
return new Promise((resolve, reject) => {
const fs = uni.getFileSystemManager();
fs.unlink({
filePath,
filePath: filePath,
success: () => {
resolve();
},
......@@ -181,10 +181,10 @@ export function readDirectory(dirPath: string): Promise<string[]> {
return new Promise((resolve, reject) => {
const fs = uni.getFileSystemManager();
fs.readdir({
dirPath,
dirPath: dirPath,
success: (res: any) => {
const files = res.files;
if (Array.isArray(files)) {
if (files instanceof Array) {
resolve(files as string[]);
} else {
resolve([]);
......@@ -206,8 +206,8 @@ export function createDirectory(dirPath: string, recursive: boolean = false): Pr
return new Promise((resolve, reject) => {
const fs = uni.getFileSystemManager();
fs.mkdir({
dirPath,
recursive,
dirPath: dirPath,
recursive: recursive,
success: () => {
resolve();
},
......@@ -227,8 +227,8 @@ export function deleteDirectory(dirPath: string, recursive: boolean = false): Pr
return new Promise((resolve, reject) => {
const fs = uni.getFileSystemManager();
fs.rmdir({
dirPath,
recursive,
dirPath: dirPath,
recursive: recursive,
success: () => {
resolve();
},
......
......@@ -35,7 +35,7 @@ export function setUserAgent(userAgent: string): void {
// #ifndef APP
// H5 可以设置 navigator.userAgent
if (typeof navigator !== "undefined") {
if (typeof navigator != "undefined") {
Object.defineProperty(navigator, "userAgent", {
get: () => userAgent,
configurable: true
......
......@@ -11,8 +11,8 @@ import { openSchema } from "@/uni_modules/uts-openSchema";
// 应用信息类型
type AppInfo = {
appid: string;
version: string;
appid: string;
};
/**
......@@ -32,8 +32,8 @@ export function getAppVersion(): string {
}
}
// #endif
} catch (error: any) {
console.error("[plus-runtime] 通过 getAppBaseInfo 获取版本号失败:", error);
} catch (e: any) {
console.error("[plus-runtime] 通过 getAppBaseInfo 获取版本号失败: ", e);
}
// 其它平台或获取失败时返回空字符串,由上层决定是否展示
......@@ -55,8 +55,8 @@ export function getAppId(): string {
}
}
// #endif
} catch (error: any) {
console.error("[plus-runtime] 通过 getAppBaseInfo 获取 appid 失败:", error);
} catch (e: any) {
console.error("[plus-runtime] 通过 getAppBaseInfo 获取 appid 失败: ", e);
}
return "";
......@@ -67,7 +67,7 @@ export function getAppId(): string {
* @param url 要打开的URL
*/
export function openURL(url: string): void {
if (url == null || url.length === 0) {
if (url == null || url.length == 0) {
console.error("[plus-runtime] URL不能为空");
return;
}
......@@ -78,14 +78,14 @@ export function openURL(url: string): void {
try {
openSchema(url);
return;
} catch (error: any) {
console.error("[plus-runtime] 使用 openSchema 打开 URL 失败:", error, "url=", url);
} catch (e: any) {
console.error("[plus-runtime] 使用 openSchema 打开 URL 失败: ", e, " url=", url);
}
// #endif
// 其它平台或兜底逻辑:H5 使用 window.open
// #ifndef APP
if (typeof window !== "undefined") {
if (typeof window != "undefined") {
window.open(url, "_blank");
}
// #endif
......
import { PAGES, TABS } from "./ctx";
import type { BackOptions, PageInstance, PushOptions } from "../types/router";
import {
debounce,
get,
storage,
last,
isNull,
isEmpty,
get,
isFunction,
isNull,
last,
toArray,
map,
debounce,
nth,
storage,
toArray
assign,
parse
} from "../utils";
import { PAGES, TABS } from "./ctx";
// 路由信息类型
type RouteInfo = {
isAuth?: boolean;
meta: UTSJSONObject;
path: string;
query: UTSJSONObject;
meta: UTSJSONObject;
isAuth?: boolean;
};
// 跳转前钩子类型
......@@ -29,81 +30,22 @@ type AfterLogin = () => void;
// 路由事件集合
type Events = {
afterLogin?: AfterLogin;
beforeEach?: BeforeEach;
afterLogin?: AfterLogin;
};
// 路由核心类
export class Router {
// 跳转到登录页(防抖处理)
login = debounce(() => {
if (!this.isLoginPage(this.path())) {
this.push({
path: "/pages/user/login",
mode: "reLaunch"
});
}
}, 300);
private eventsMap = {} as Events; // 事件存储
// 注册登录后回调
afterLogin(cb: AfterLogin) {
this.eventsMap.afterLogin = cb;
}
// 返回上一页
back(options: BackOptions | null = null) {
if (this.isFirstPage()) {
this.home();
} else {
const delta = options?.delta ?? 1;
// 执行跳转函数
const next = () => {
uni.navigateBack({ ...options });
};
// 跳转前钩子处理
if (this.eventsMap.beforeEach != null) {
// 当前页
const from = last(this.getPages());
// 上一页
const to = nth(this.getPages(), -delta - 1);
if (to != null) {
// 调用跳转前钩子
this.eventsMap.beforeEach(
{
path: to.path,
query: to.query,
meta: to.meta ?? ({} as UTSJSONObject)
},
from!,
next
);
} else {
console.error("[router] found to page is null");
}
} else {
next();
}
}
}
// 注册跳转前钩子
beforeEach(cb: BeforeEach) {
this.eventsMap.beforeEach = cb;
// 获取传递的 params 参数
params() {
return (storage.get("router-params") ?? {}) as UTSJSONObject;
}
// 执行当前页面暴露的方法
callMethod(name: string, data?: any): any | null {
const fn = get(this.route()!, `$vm.$.exposed.${name}`) as (d?: any) => any | null;
if (isFunction(fn)) {
return fn(data);
}
return null;
// 获取传递的 query 参数
query() {
return this.route()?.query ?? {};
}
// 获取默认路径,支持 home 和 login
......@@ -116,16 +58,6 @@ export class Router {
return get(paths, name) as string;
}
// 获取页面元数据
getMeta(path: string) {
return PAGES.find((e) => path.includes(e.path))?.meta ?? ({} as UTSJSONObject);
}
// 获取指定路径的页面实例
getPage(path: string) {
return this.getPages().find((e) => e.path == path);
}
// 获取当前页面栈的所有页面实例
getPages(): PageInstance[] {
return map(getCurrentPages(), (e) => {
......@@ -138,7 +70,7 @@ export class Router {
// 补全路径前缀
if (!path.startsWith("/")) {
path = `/${ path}`;
path = "/" + path;
}
// 获取页面样式
......@@ -172,76 +104,14 @@ export class Router {
});
}
// 回到首页
home() {
this.push({
path: this.defaultPath("home")
});
}
// 判断是否为当前页面
isCurrentPage(path: string) {
return this.path() == path;
}
// 判断是否为自定义导航栏页面
isCustomNavbarPage() {
return this.route()?.isCustomNavbar ?? false;
}
// 判断页面栈是否只有一个页面
isFirstPage() {
return getCurrentPages().length == 1;
}
// 判断是否为首页
isHomePage() {
return this.path() == this.defaultPath("home");
}
// 判断是否为登录页
isLoginPage(path: string) {
return path == this.defaultPath("login");
}
// 判断是否为 tab 页面
isTabPage(path: null | string = null) {
if (path == null) {
path = this.path();
}
if (path == "/") {
path = this.defaultPath("home");
}
return !isNull(TABS.find((e) => path == e.pagePath));
}
// 登录成功后跳转逻辑
nextLogin() {
const pages = this.getPages();
// 找到登录页的索引
const index = pages.findIndex((e) => this.defaultPath("login").includes(e.path));
// 未找到,则跳回首页
if (index === -1) {
this.home();
} else {
this.back({
delta: pages.length - index
});
}
// 登录后回调
if (this.eventsMap.afterLogin != null) {
this.eventsMap.afterLogin!();
}
// 触发全局 afterLogin 事件
uni.$emit("afterLogin");
// 获取指定路径的页面实例
getPage(path: string) {
return this.getPages().find((e) => e.path == path);
}
// 获取传递的 params 参数
params() {
return (storage.get("router-params") ?? {}) as UTSJSONObject;
// 获取当前路由页面实例
route() {
return last(this.getPages());
}
// 获取当前页面路径
......@@ -249,6 +119,13 @@ export class Router {
return this.route()?.path ?? "";
}
// 简单跳转页面(默认 navigateTo)
to(path: string) {
this.push({
path
});
}
// 路由跳转,支持多种模式和参数
push(options: PushOptions) {
let {
......@@ -270,7 +147,7 @@ export class Router {
const arr = toArray(query, (v, k) => {
return `${k}=${v}`;
});
path += `?${ arr.join("&")}`;
path += "?" + arr.join("&");
}
// params 通过 storage 临时存储
......@@ -286,7 +163,7 @@ export class Router {
// 跳转执行函数
const next = () => {
switch (mode) {
case "navigateTo": {
case "navigateTo":
uni.navigateTo({
url: path,
success,
......@@ -297,8 +174,7 @@ export class Router {
animationDuration
});
break;
}
case "redirectTo": {
case "redirectTo":
uni.redirectTo({
url: path,
success,
......@@ -306,8 +182,7 @@ export class Router {
complete
});
break;
}
case "reLaunch": {
case "reLaunch":
uni.reLaunch({
url: path,
success,
......@@ -315,8 +190,7 @@ export class Router {
complete
});
break;
}
case "switchTab": {
case "switchTab":
uni.switchTab({
url: path,
success,
......@@ -324,7 +198,6 @@ export class Router {
complete
});
break;
}
}
};
......@@ -343,21 +216,145 @@ export class Router {
}
}
// 获取传递的 query 参数
query() {
return this.route()?.query ?? {};
// 回到首页
home() {
this.push({
path: this.defaultPath("home")
});
}
// 获取当前路由页面实例
route() {
return last(this.getPages());
// 返回上一页
back(options: BackOptions | null = null) {
if (this.isFirstPage()) {
this.home();
} else {
const delta = options?.delta ?? 1;
// 执行跳转函数
const next = () => {
uni.navigateBack({ ...(options ?? {}) });
};
// 跳转前钩子处理
if (this.eventsMap.beforeEach != null) {
// 当前页
const from = last(this.getPages());
// 上一页
const to = nth(this.getPages(), -delta - 1);
if (to != null) {
// 调用跳转前钩子
this.eventsMap.beforeEach(
{
path: to.path,
query: to.query,
meta: to.meta ?? ({} as UTSJSONObject)
},
from!,
next
);
} else {
console.error("[router] found to page is null");
}
} else {
next();
}
}
}
// 简单跳转页面(默认 navigateTo)
to(path: string) {
this.push({
path
});
// 获取页面元数据
getMeta(path: string) {
return PAGES.find((e) => path.includes(e.path))?.meta ?? ({} as UTSJSONObject);
}
// 执行当前页面暴露的方法
callMethod(name: string, data?: any): any | null {
const fn = get(this.route()!, `$vm.$.exposed.${name}`) as (d?: any) => any | null;
if (isFunction(fn)) {
return fn(data);
}
return null;
}
// 判断页面栈是否只有一个页面
isFirstPage() {
return getCurrentPages().length == 1;
}
// 判断是否为首页
isHomePage() {
return this.path() == this.defaultPath("home");
}
// 判断是否为自定义导航栏页面
isCustomNavbarPage() {
return this.route()?.isCustomNavbar ?? false;
}
// 判断是否为当前页面
isCurrentPage(path: string) {
return this.path() == path;
}
// 判断是否为 tab 页面
isTabPage(path: string | null = null) {
if (path == null) {
path = this.path();
}
if (path == "/") {
path = this.defaultPath("home");
}
return !isNull(TABS.find((e) => path == e.pagePath));
}
// 判断是否为登录页
isLoginPage(path: string) {
return path == this.defaultPath("login");
}
// 跳转到登录页(防抖处理)
login = debounce(() => {
if (!this.isLoginPage(this.path())) {
this.push({
path: "/pages/user/login",
mode: "reLaunch"
});
}
}, 300);
// 登录成功后跳转逻辑
nextLogin() {
const pages = this.getPages();
// 找到登录页的索引
const index = pages.findIndex((e) => this.defaultPath("login").includes(e.path));
// 未找到,则跳回首页
if (index < 0) {
this.home();
} else {
this.back({
delta: pages.length - index
});
}
// 登录后回调
if (this.eventsMap.afterLogin != null) {
this.eventsMap.afterLogin!();
}
// 触发全局 afterLogin 事件
uni.$emit("afterLogin");
}
// 注册跳转前钩子
beforeEach(cb: BeforeEach) {
this.eventsMap.beforeEach = cb;
}
// 注册登录后回调
afterLogin(cb: AfterLogin) {
this.eventsMap.afterLogin = cb;
}
}
......
......@@ -17,20 +17,20 @@ export interface ScreenInfo {
* 获取屏幕信息
*/
export function getScreenInfo(): ScreenInfo {
const windowInfo = uni.getWindowInfo();
const windowInfo = uni.getWindowInfo()
return {
width: windowInfo.windowWidth,
height: windowInfo.windowHeight,
pixelRatio: windowInfo.pixelRatio,
screenWidth: windowInfo.screenWidth,
screenHeight: windowInfo.screenHeight
};
}
}
/**
* 屏幕尺寸分类
*/
export type ScreenSize = "large" | "medium" | "small" | "xlarge"
export type ScreenSize = 'small' | 'medium' | 'large' | 'xlarge'
/**
* 获取屏幕尺寸分类
......@@ -40,15 +40,15 @@ export type ScreenSize = "large" | "medium" | "small" | "xlarge"
* - xlarge: >= 1024px(平板、大屏设备)
*/
export function getScreenSize(): ScreenSize {
const width = getScreenInfo().width;
const width = getScreenInfo().width
if (width < 480) {
return "small";
return 'small'
} else if (width < 768) {
return "medium";
return 'medium'
} else if (width < 1024) {
return "large";
return 'large'
} else {
return "xlarge";
return 'xlarge'
}
}
......@@ -68,25 +68,25 @@ export function getScreenSize(): ScreenSize {
* const fontSize = responsiveFontSize(14, 12, 20)
*/
export function responsiveFontSize(baseSize: number, minSize: number = 12, maxSize: number = 48): number {
const screenInfo = getScreenInfo();
const screenWidth = screenInfo.width;
const screenInfo = getScreenInfo()
const screenWidth = screenInfo.width
// 设计稿基准宽度(通常为 375px 或 750px)
// 如果设计稿是 750px,这里改为 750,baseSize 也需要相应调整
const designWidth = 375;
const designWidth = 375
// 计算缩放比例(限制在合理范围内)
const scale = screenWidth / designWidth;
const scaledSize = baseSize * scale;
const scale = screenWidth / designWidth
const scaledSize = baseSize * scale
// 限制在最小值和最大值之间
if (scaledSize < minSize) {
return minSize;
return minSize
} else if (scaledSize > maxSize) {
return maxSize;
return maxSize
}
return Math.round(scaledSize);
return Math.round(scaledSize)
}
/**
......@@ -104,20 +104,20 @@ export function responsiveFontSize(baseSize: number, minSize: number = 12, maxSi
* const padding = responsiveSpacing(16, 12, 24)
*/
export function responsiveSpacing(baseSpacing: number, minSpacing: number = 4, maxSpacing: number = 64): number {
const screenInfo = getScreenInfo();
const screenWidth = screenInfo.width;
const designWidth = 375;
const screenInfo = getScreenInfo()
const screenWidth = screenInfo.width
const designWidth = 375
const scale = screenWidth / designWidth;
const scaledSpacing = baseSpacing * scale;
const scale = screenWidth / designWidth
const scaledSpacing = baseSpacing * scale
if (scaledSpacing < minSpacing) {
return minSpacing;
return minSpacing
} else if (scaledSpacing > maxSpacing) {
return maxSpacing;
return maxSpacing
}
return Math.round(scaledSpacing);
return Math.round(scaledSpacing)
}
/**
......@@ -133,35 +133,35 @@ export function responsiveSpacing(baseSpacing: number, minSpacing: number = 4, m
* const buttonWidth = responsiveWidth(200)
*/
export function responsiveWidth(baseWidth: number): number {
const screenInfo = getScreenInfo();
const screenWidth = screenInfo.width;
const designWidth = 375;
const screenInfo = getScreenInfo()
const screenWidth = screenInfo.width
const designWidth = 375
return Math.round(baseWidth * (screenWidth / designWidth));
return Math.round(baseWidth * (screenWidth / designWidth))
}
/**
* 判断是否为横屏
*/
export function isLandscape(): boolean {
const screenInfo = getScreenInfo();
return screenInfo.width > screenInfo.height;
const screenInfo = getScreenInfo()
return screenInfo.width > screenInfo.height
}
/**
* 判断是否为平板尺寸
*/
export function isTablet(): boolean {
const screenSize = getScreenSize();
return screenSize === "large" || screenSize === "xlarge";
const screenSize = getScreenSize()
return screenSize === 'large' || screenSize === 'xlarge'
}
/**
* 判断是否为手机尺寸
*/
export function isMobile(): boolean {
const screenSize = getScreenSize();
return screenSize === "small" || screenSize === "medium";
const screenSize = getScreenSize()
return screenSize === 'small' || screenSize === 'medium'
}
/**
......@@ -175,5 +175,5 @@ export function isMobile(): boolean {
* const columns = getColumns(1, 2)
*/
export function getColumns(mobileColumns: number = 1, tabletColumns: number = 2): number {
return isTablet() ? tabletColumns : mobileColumns;
return isTablet() ? tabletColumns : mobileColumns
}
......@@ -9,18 +9,6 @@ const EXPIRES_SUFFIX = "_deadtime";
*/
class Storage {
/**
* 清空所有存储数据
*
* 警告:此操作会删除所有本地存储数据,请谨慎使用
*
* @example
* storage.clear(); // 清空所有数据
*/
clear() {
uni.clearStorageSync();
}
/**
* 获取存储数据
*
* @param key 存储键名
......@@ -64,6 +52,32 @@ class Storage {
}
/**
* 设置存储数据
*
* @param key 存储键名
* @param value 要存储的数据,支持任意类型
* @param expires 过期时间(秒),默认为0表示永不过期
*
* @example
* // 存储永久数据
* storage.set('user', { name: '张三', age: 25 }, 0);
*
* // 存储5分钟后过期的数据
* storage.set('token', 'abc123', 300);
*/
set(key: string, value: any, expires: number): void {
// 存储主要数据
uni.setStorageSync(key, value);
// 如果设置了过期时间,则存储过期时间戳
if (expires > 0) {
// 计算过期时间戳:当前时间 + 过期时间(秒转毫秒)
const expireTime = new Date().getTime() + expires * 1000;
uni.setStorageSync(`${key}${EXPIRES_SUFFIX}`, expireTime);
}
}
/**
* 检查数据是否已过期
*
* @param key 存储键名
......@@ -76,7 +90,7 @@ class Storage {
*/
isExpired(key: string): boolean {
// 获取过期时间戳
const value = uni.getStorageSync(`${key}${EXPIRES_SUFFIX}`) as null | number;
const value = uni.getStorageSync(`${key}${EXPIRES_SUFFIX}`) as number | null;
// 如果没有设置过期时间,视为已过期
if (value == null) {
......@@ -84,29 +98,7 @@ class Storage {
}
// 比较过期时间戳与当前时间,判断是否过期
return value - Date.now() <= 0;
}
/**
* 获取数据后立即删除(一次性读取)
*
* 适用于临时数据、一次性令牌等场景
* 读取后数据会被自动删除,确保数据的一次性使用
*
* @param key 存储键名
* @returns 存储的数据,如果不存在则返回 null
*
* @example
* const tempToken = storage.once('temp_token');
* // tempToken 使用后,存储中的 temp_token 已被删除
*/
once(key: string): any | null {
// 先获取数据
const value = this.get(key);
// 立即删除数据
this.remove(key);
// 返回获取到的数据
return value;
return value - new Date().getTime() <= 0;
}
/**
......@@ -128,29 +120,37 @@ class Storage {
}
/**
* 设置存储数据
* 清空所有存储数据
*
* @param key 存储键名
* @param value 要存储的数据,支持任意类型
* @param expires 过期时间(秒),默认为0表示永不过期
* 警告:此操作会删除所有本地存储数据,请谨慎使用
*
* @example
* // 存储永久数据
* storage.set('user', { name: '张三', age: 25 }, 0);
*
* // 存储5分钟后过期的数据
* storage.set('token', 'abc123', 300);
* storage.clear(); // 清空所有数据
*/
set(key: string, value: any, expires: number): void {
// 存储主要数据
uni.setStorageSync(key, value);
clear() {
uni.clearStorageSync();
}
// 如果设置了过期时间,则存储过期时间戳
if (expires > 0) {
// 计算过期时间戳:当前时间 + 过期时间(秒转毫秒)
const expireTime = Date.now() + expires * 1000;
uni.setStorageSync(`${key}${EXPIRES_SUFFIX}`, expireTime);
}
/**
* 获取数据后立即删除(一次性读取)
*
* 适用于临时数据、一次性令牌等场景
* 读取后数据会被自动删除,确保数据的一次性使用
*
* @param key 存储键名
* @returns 存储的数据,如果不存在则返回 null
*
* @example
* const tempToken = storage.once('temp_token');
* // tempToken 使用后,存储中的 temp_token 已被删除
*/
once(key: string): any | null {
// 先获取数据
const value = this.get(key);
// 立即删除数据
this.remove(key);
// 返回获取到的数据
return value;
}
}
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!