Commit 7efe0ec2 by Jaxon

chore: stylelint 配置支持小程序与uniapp的特殊rpx值与特有的选择器

1 parent a4bc4cbc
Showing 152 changed files with 1768 additions and 1761 deletions
......@@ -3,3 +3,4 @@ public
__tests__
coverage
miniprogram_npm
uni_modules
......@@ -36,33 +36,33 @@
"source.fixAll.stylelint": "explicit",
"source.organizeImports": "never"
},
"editor.defaultFormatter": "esbenp.prettier-vscode",
"editor.defaultFormatter": "dbaeumer.vscode-eslint",
"[html]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
"editor.defaultFormatter": "dbaeumer.vscode-eslint"
},
"[css]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
"editor.defaultFormatter": "dbaeumer.vscode-eslint"
},
"[scss]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
"editor.defaultFormatter": "dbaeumer.vscode-eslint"
},
"[javascript]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
"editor.defaultFormatter": "dbaeumer.vscode-eslint"
},
"[typescript]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
"editor.defaultFormatter": "dbaeumer.vscode-eslint"
},
"[json]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
"editor.defaultFormatter": "dbaeumer.vscode-eslint"
},
"[markdown]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
"editor.defaultFormatter": "dbaeumer.vscode-eslint"
},
"[jsonc]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
"editor.defaultFormatter": "dbaeumer.vscode-eslint"
},
"[vue]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
"editor.defaultFormatter": "dbaeumer.vscode-eslint"
},
// extensions
"extensions.ignoreRecommendations": true,
......@@ -107,19 +107,22 @@
"**/.git/subtree-cache/**": true,
"**/.vscode/**": true,
"**/node_modules/**": true,
"**/uni_modules/**": true,
"**/miniprogram_npm/**": true,
"**/tmp/**": true,
"**/bower_components/**": true,
"**/dist/**": true,
"**/yarn.lock": true
},
"typescript.tsserver.exclude": ["**/node_modules", "**/dist", "**/.turbo"],
"typescript.tsserver.exclude": ["**/node_modules", "**/dist", "**/.turbo","**/uni_modules","**/miniprogram_npm"],
// search
"search.searchEditor.singleClickBehaviour": "peekDefinition",
"search.followSymlinks": false,
// 在使用搜索功能时,将这些文件夹/文件排除在外
"search.exclude": {
"**/uni_modules": true,
"**/miniprogram_npm":true,
"**/node_modules": true,
"**/*.log": true,
......@@ -226,5 +229,15 @@
"vue.server.hybridMode": true,
"typescript.tsdk": "node_modules/typescript/lib",
"oxc.enable": false,
"cSpell.words": ["archiver", "axios", "dotenv", "isequal", "jspm", "napi", "nolebase", "rollup", "vitest"]
"cSpell.words": [
"archiver",
"axios",
"dotenv",
"isequal",
"jspm",
"napi",
"nolebase",
"rollup",
"vitest"
]
}
......@@ -15,14 +15,14 @@
padding-bottom: env(safe-area-inset-bottom);
}
.safeAreaNewPaddingBttom{
padding-bottom: constant(safe-area-inset-bottom);
padding-bottom: constant(safe-area-inset-bottom);
}
.safeAreaOldMarginBttom {
margin-bottom: env(safe-area-inset-bottom);
}
.safeAreaNewMarginBttom{
margin-bottom: constant(safe-area-inset-bottom);
margin-bottom: constant(safe-area-inset-bottom);
}
.no-data {
......@@ -82,4 +82,4 @@ page {
padding: 0 24rpx;
font-size: 24rpx;
color: #999;
}
\ No newline at end of file
}
---
name: Bug report(报告问题)
about: Create a report to help us improve
---
<!--
注意:为更好的解决你的问题,请参考模板提供完整信息,准确描述问题,信息不全的 issue 将被关闭。
Note: In order to better solve your problem, please refer to the template to provide complete information, accurately describe the problem, and the incomplete information issue will be closed.
-->
# Bug report(问题描述)
please write your issue description here
## Steps to reproduce(问题复现步骤)
<!--
1. [xxx]
2. [xxx]
3. [xxxx]
-->
## Screenshot or Gif(截图或动态图)
## minimal reproduction(最小可还原代码)
## System Info
`npx envinfo --system --npmPackages vue --binaries --browsers`
执行上面命令,将结果贴下面
---
name: Feature Request(新功能建议)
about: Suggest an idea for this project
---
# Feature request(新功能建议)
name: Deploy Pages
on:
# Runs on pushes targeting the default branch
push:
branches: ['main']
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
permissions:
contents: read
pages: write
id-token: write
jobs:
# Build job
build:
runs-on: ubuntu-latest
steps:
# 设置服务器时区为东八区
- name: Set time zone
run: sudo timedatectl set-timezone 'Asia/Shanghai'
- uses: actions/checkout@v4
- uses: pnpm/action-setup@v2
with:
version: 8
- uses: actions/setup-node@v4
with:
node-version: '18'
cache: 'pnpm'
- name: Install dependencies
run: pnpm i --no-frozen-lockfile
- name: Build
run: pnpm build:h5
- name: Upload artifact
uses: actions/upload-pages-artifact@v3
with:
path: ./dist/build/h5
# Deployment job
deploy:
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-latest
needs: build
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4
import path from "node:path";
import process from "node:process";
// manifest.config.ts
import { defineManifestConfig } from '@uni-helper/vite-plugin-uni-manifest'
import path from 'node:path'
import { loadEnv } from 'vite'
import { defineManifestConfig } from "@uni-helper/vite-plugin-uni-manifest";
import { loadEnv } from "vite";
// 获取环境变量的范例
const env = loadEnv(process.env.NODE_ENV!, path.resolve(process.cwd(), 'env'))
const env = loadEnv(process.env.NODE_ENV ?? "development", path.resolve(process.cwd(), "env"));
// console.log('manifest.config.ts')
// console.log(env)
const {
VITE_APP_TITLE,
VITE_UNI_APPID,
VITE_WX_APPID,
VITE_APP_PUBLIC_BASE,
VITE_FALLBACK_LOCALE,
} = env
VITE_APP_TITLE,
VITE_UNI_APPID,
VITE_WX_APPID,
VITE_APP_PUBLIC_BASE,
VITE_FALLBACK_LOCALE,
} = env;
export default defineManifestConfig({
name: VITE_APP_TITLE,
appid: VITE_UNI_APPID,
description: '',
versionName: '1.0.0',
versionCode: '100',
transformPx: false,
locale: VITE_FALLBACK_LOCALE, // 'zh-Hans'
h5: {
router: {
base: VITE_APP_PUBLIC_BASE,
name: VITE_APP_TITLE,
appid: VITE_UNI_APPID,
description: "",
versionName: "1.0.0",
versionCode: "100",
transformPx: false,
locale: VITE_FALLBACK_LOCALE, // 'zh-Hans'
h5: {
router: {
base: VITE_APP_PUBLIC_BASE,
},
},
},
/* 5+App特有相关 */
'app-plus': {
usingComponents: true,
nvueStyleCompiler: 'uni-app',
compilerVersion: 3,
splashscreen: {
alwaysShowBeforeRender: true,
waiting: true,
autoclose: true,
delay: 0,
/* 5+App特有相关 */
"app-plus": {
usingComponents: true,
nvueStyleCompiler: "uni-app",
compilerVersion: 3,
splashscreen: {
alwaysShowBeforeRender: true,
waiting: true,
autoclose: true,
delay: 0,
},
/* 模块配置 */
modules: {},
/* 应用发布信息 */
distribute: {
/* android打包配置 */
android: {
minSdkVersion: 30,
targetSdkVersion: 30,
abiFilters: [ "armeabi-v7a", "arm64-v8a" ],
permissions: [
'<uses-permission android:name="android.permission.CHANGE_NETWORK_STATE"/>',
'<uses-permission android:name="android.permission.MOUNT_UNMOUNT_FILESYSTEMS"/>',
'<uses-permission android:name="android.permission.VIBRATE"/>',
'<uses-permission android:name="android.permission.READ_LOGS"/>',
'<uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/>',
'<uses-feature android:name="android.hardware.camera.autofocus"/>',
'<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>',
'<uses-permission android:name="android.permission.CAMERA"/>',
'<uses-permission android:name="android.permission.GET_ACCOUNTS"/>',
'<uses-permission android:name="android.permission.READ_PHONE_STATE"/>',
'<uses-permission android:name="android.permission.CHANGE_WIFI_STATE"/>',
'<uses-permission android:name="android.permission.WAKE_LOCK"/>',
'<uses-permission android:name="android.permission.FLASHLIGHT"/>',
'<uses-feature android:name="android.hardware.camera"/>',
'<uses-permission android:name="android.permission.WRITE_SETTINGS"/>',
],
},
/* ios打包配置 */
ios: {},
/* SDK配置 */
sdkConfigs: {},
/* 图标配置 */
icons: {
android: {},
ios: {},
},
},
},
/* 模块配置 */
modules: {},
/* 应用发布信息 */
distribute: {
/* android打包配置 */
android: {
minSdkVersion: 30,
targetSdkVersion: 30,
abiFilters: ['armeabi-v7a', 'arm64-v8a'],
permissions: [
'<uses-permission android:name="android.permission.CHANGE_NETWORK_STATE"/>',
'<uses-permission android:name="android.permission.MOUNT_UNMOUNT_FILESYSTEMS"/>',
'<uses-permission android:name="android.permission.VIBRATE"/>',
'<uses-permission android:name="android.permission.READ_LOGS"/>',
'<uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/>',
'<uses-feature android:name="android.hardware.camera.autofocus"/>',
'<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>',
'<uses-permission android:name="android.permission.CAMERA"/>',
'<uses-permission android:name="android.permission.GET_ACCOUNTS"/>',
'<uses-permission android:name="android.permission.READ_PHONE_STATE"/>',
'<uses-permission android:name="android.permission.CHANGE_WIFI_STATE"/>',
'<uses-permission android:name="android.permission.WAKE_LOCK"/>',
'<uses-permission android:name="android.permission.FLASHLIGHT"/>',
'<uses-feature android:name="android.hardware.camera"/>',
'<uses-permission android:name="android.permission.WRITE_SETTINGS"/>',
],
},
/* ios打包配置 */
ios: {},
/* SDK配置 */
sdkConfigs: {},
/* 图标配置 */
icons: {
android: {},
ios: {},
},
/* 快应用特有相关 */
quickapp: {},
/* 小程序特有相关 */
"mp-weixin": {
appid: VITE_WX_APPID,
setting: {
urlCheck: false,
},
usingComponents: true,
// __usePrivacyCheck__: true,
},
},
/* 快应用特有相关 */
quickapp: {},
/* 小程序特有相关 */
'mp-weixin': {
appid: VITE_WX_APPID,
setting: {
urlCheck: false,
"mp-alipay": {
usingComponents: true,
},
usingComponents: true,
// __usePrivacyCheck__: true,
},
'mp-alipay': {
usingComponents: true,
},
'mp-baidu': {
usingComponents: true,
},
'mp-toutiao': {
usingComponents: true,
},
uniStatistics: {
enable: false,
},
vueVersion: '3',
})
"mp-baidu": {
usingComponents: true,
},
"mp-toutiao": {
usingComponents: true,
},
uniStatistics: {
enable: false,
},
vueVersion: "3",
});
import { createProdMockServer } from 'vite-plugin-mock/client'
const modules = import.meta.glob('/mock/**/*.ts', { eager: true })
const mockModules: any[] = []
Object.keys(modules).forEach((key) => {
if (key.includes('/_')) {
return
}
mockModules.push(...(modules as Recordable)[key].default)
})
console.log('mockModules -> ', mockModules)
/**
* Used in a production environment. Need to manually import all modules
*/
export function setupProdMockServer() {
createProdMockServer(mockModules)
}
// test.ts
import { MockMethod, MockConfig } from 'vite-plugin-mock'
export default [
{
url: '/api/get',
method: 'get',
response: ({ query }) => {
return {
code: 0,
data: {
name: '菲鸽',
},
}
},
},
{
url: '/api/post',
method: 'post',
timeout: 2000,
response: {
code: 0,
data: {
name: '菲鸽',
},
},
},
{
url: '/api/text',
method: 'post',
rawResponse: async (req, res) => {
let reqbody = ''
await new Promise((resolve) => {
req.on('data', (chunk) => {
reqbody += chunk
})
req.on('end', () => resolve(undefined))
})
res.setHeader('Content-Type', 'text/plain')
res.statusCode = 200
res.end(`hello, ${reqbody}`)
},
},
] as MockMethod[]
{
"name": "unibest",
"type": "commonjs",
"version": "1.5.0",
"description": "unibest - 最好的 uniapp 开发模板",
"homepage": "https://feige996.github.io/hello-unibest/",
"bugs": {
"url": "https://github.com/feige996/unibest/issues"
},
"repository": "https://github.com/feige996/unibest",
"license": "MIT",
"author": {
"name": "feige996",
"zhName": "菲鸽",
......@@ -10,17 +15,8 @@
"github": "https://github.com/feige996",
"gitee": "https://gitee.com/feige996"
},
"license": "MIT",
"repository": "https://github.com/feige996/unibest",
"type": "commonjs",
"repository-gitee": "https://gitee.com/feige996/unibest",
"bugs": {
"url": "https://github.com/feige996/unibest/issues"
},
"homepage": "https://feige996.github.io/hello-unibest/",
"engines": {
"node": ">=18",
"pnpm": ">=7.30"
},
"scripts": {
"dev:app": "uni -p app",
"dev:app-android": "uni -p app-android",
......@@ -66,20 +62,6 @@
"prepare": "node ./shell/postinstall.js & git init && husky install ",
"type-check": "vue-tsc --noEmit"
},
"lint-staged": {
"**/*.{html,vue,ts,cjs,json,md}": [
"prettier --write"
],
"**/*.{vue,js,ts,jsx,tsx}": [
"eslint --fix"
],
"**/*.{vue,css,scss,html}": [
"stylelint --fix --allow-empty-input"
]
},
"resolutions": {
"bin-wrapper": "npm:bin-wrapper-china"
},
"dependencies": {
"@climblee/uv-ui": "^1.1.20",
"@dcloudio/uni-app": "3.0.0-4000820240401001",
......@@ -109,8 +91,6 @@
"z-paging": "^2.7.8"
},
"devDependencies": {
"@commitlint/cli": "^18.4.3",
"@commitlint/config-conventional": "^18.4.3",
"@dcloudio/types": "^3.4.8",
"@dcloudio/uni-automator": "3.0.0-4000820240401001",
"@dcloudio/uni-cli-shared": "3.0.0-4000820240401001",
......@@ -120,8 +100,6 @@
"@ttou/uv-typings": "^1.10.2",
"@types/node": "^20.11.5",
"@types/wechat-miniprogram": "^3.4.7",
"@typescript-eslint/eslint-plugin": "^6.15.0",
"@typescript-eslint/parser": "^6.15.0",
"@uni-helper/uni-ui-types": "^0.5.11",
"@uni-helper/vite-plugin-uni-components": "^0.0.8",
"@uni-helper/vite-plugin-uni-layouts": "^0.1.7",
......@@ -132,16 +110,7 @@
"@vue/runtime-core": "^3.3.13",
"@vue/tsconfig": "^0.1.3",
"autoprefixer": "^10.4.16",
"commitlint": "^18.4.3",
"eslint": "^8.56.0",
"eslint-config-prettier": "^9.1.0",
"eslint-config-standard": "^17.1.0",
"eslint-import-resolver-typescript": "^3.6.1",
"eslint-plugin-import": "^2.29.1",
"eslint-plugin-prettier": "^5.1.0",
"eslint-plugin-vue": "^9.19.2",
"husky": "^8.0.3",
"lint-staged": "^15.2.0",
"postcss": "^8.4.32",
"postcss-html": "^1.5.0",
"postcss-scss": "^4.0.9",
......@@ -155,7 +124,6 @@
"stylelint-config-standard-scss": "^12.0.0",
"stylelint-prettier": "^5.0.0",
"terser": "^5.26.0",
"typescript": "^4.9.4",
"unocss": "^0.58.9",
"unocss-applet": "^0.7.8",
"unplugin-auto-import": "^0.17.2",
......@@ -167,5 +135,14 @@
"vite-plugin-vue-setup-extend": "^0.4.0",
"vite-svg-loader": "^5.1.0",
"vue-tsc": "^1.8.25"
},
"engines": {
"node": ">=18",
"pnpm": ">=7.30"
},
"resolutions": {
"bin-wrapper": "npm:bin-wrapper-china"
},
"lint-staged": {
}
}
import { defineUniPages } from '@uni-helper/vite-plugin-uni-pages'
import { defineUniPages } from "@uni-helper/vite-plugin-uni-pages";
export default defineUniPages({
globalStyle: {
navigationStyle: 'default',
navigationBarTitleText: 'unibest',
navigationBarBackgroundColor: '#f8f8f8',
navigationBarTextStyle: 'black',
backgroundColor: '#FFFFFF',
h5: {
// navigationStyle: 'custom',
globalStyle: {
navigationStyle: "default",
navigationBarTitleText: "unibest",
navigationBarBackgroundColor: "#f8f8f8",
navigationBarTextStyle: "black",
backgroundColor: "#FFFFFF",
h5: {
// navigationStyle: 'custom',
},
},
},
easycom: {
autoscan: true,
custom: {
'^uni-(.*)': '@dcloudio/uni-ui/lib/uni-$1/uni-$1.vue',
'^uv-(.*)': '@climblee/uv-ui/components/uv-$1/uv-$1.vue',
'^wd-(.*)': 'wot-design-uni/components/wd-$1/wd-$1.vue',
'^(?!z-paging-refresh|z-paging-load-more)z-paging(.*)':
'z-paging/components/z-paging$1/z-paging$1.vue',
easycom: {
autoscan: true,
custom: {
"^uni-(.*)": "@dcloudio/uni-ui/lib/uni-$1/uni-$1.vue",
"^uv-(.*)": "@climblee/uv-ui/components/uv-$1/uv-$1.vue",
"^wd-(.*)": "wot-design-uni/components/wd-$1/wd-$1.vue",
"^(?!z-paging-refresh|z-paging-load-more)z-paging(.*)":
"z-paging/components/z-paging$1/z-paging$1.vue",
},
},
},
tabBar: {
color: '#999999',
selectedColor: '#018d71',
backgroundColor: '#F8F8F8',
borderStyle: 'black',
height: '50px',
fontSize: '10px',
iconWidth: '24px',
spacing: '3px',
list: [
{
iconPath: 'static/tabbar/home.png',
selectedIconPath: 'static/tabbar/homeHL.png',
pagePath: 'pages/index/index',
text: '首页',
},
{
iconPath: 'static/tabbar/example.png',
selectedIconPath: 'static/tabbar/exampleHL.png',
pagePath: 'pages/demo/index',
text: '示例',
},
],
},
})
tabBar: {
color: "#999999",
selectedColor: "#018d71",
backgroundColor: "#F8F8F8",
borderStyle: "black",
height: "50px",
fontSize: "10px",
iconWidth: "24px",
spacing: "3px",
list: [
{
iconPath: "static/tabbar/home.png",
selectedIconPath: "static/tabbar/homeHL.png",
pagePath: "pages/index/index",
text: "首页",
},
{
iconPath: "static/tabbar/example.png",
selectedIconPath: "static/tabbar/exampleHL.png",
pagePath: "pages/demo/index",
text: "示例",
},
],
},
});
......@@ -7,15 +7,15 @@
*/
// eslint-disable-next-line @typescript-eslint/no-var-requires
const fs = require('fs')
const fs = require("node:fs");
const filePath = './src/manifest.json'
const filePath = "./src/manifest.json";
if (fs.existsSync(filePath)) {
// console.log(`${filePath}存在`)
// console.log(`${filePath}存在`)
} else {
// console.log(`${filePath}不存在,需要创建`)
fs.writeFile(filePath, '{}\n', {}, () => {
// console.log(`${filePath}不存在,需要创建`)
fs.writeFile(filePath, "{}\n", {}, () => {
// console.log(`${filePath}已经成功创建,并写入{}`)
})
});
}
/// <reference types='@dcloudio/types' />
import 'vue'
// / <reference types='@dcloudio/types' />
import "vue";
declare module '@vue/runtime-core' {
declare module "@vue/runtime-core" {
type Hooks = App.AppInstance & Page.PageInstance
interface ComponentCustomOptions extends Hooks {}
}
<script setup lang="ts">
import { onLaunch, onShow, onHide } from '@dcloudio/uni-app'
import { onHide, onLaunch, onShow } from "@dcloudio/uni-app";
onLaunch(() => {
console.log('App Launch')
})
console.log("App Launch");
});
onShow(() => {
console.log('App Show')
})
console.log("App Show");
});
onHide(() => {
console.log('App Hide')
})
console.log("App Hide");
});
</script>
<style lang="scss">
......
<!-- 本文件会自动导入 -->
<template>
<view>
<view>components 里面的 AppTest.vue 组件</view>
<slot />
</view>
<view>
<view>components 里面的 AppTest.vue 组件</view>
<slot />
</view>
</template>
<template>
<svg aria-hidden="true">
<use :href="symbolId" :fill="color" />
</svg>
<svg aria-hidden="true">
<use :fill="color" :href="symbolId" />
</svg>
</template>
<script lang="ts" setup name="SvgIcon">
const props = withDefaults(
defineProps<{
prefix?: string
name: string
defineProps<{
color?: string
name: string
prefix?: string
}>(),
{
prefix: 'icon',
name: '',
color: '#333',
},
)
const symbolId = computed(() => `#${props.prefix}-${props.name}`)
{
prefix: "icon",
name: "",
color: "#333",
},
);
const symbolId = computed(() => `#${props.prefix}-${props.name}`);
</script>
<template>
<view>
<view>components 里面的 app-test-dir/AppTest.vue 组件</view>
<slot />
</view>
<view>
<view>components 里面的 app-test-dir/AppTest.vue 组件</view>
<slot />
</view>
</template>
<template>
<view class="fly-content">
<view v-for="n in line" :key="n" class="h-10 leading-10 text-center">
很多内容,这里是第{{ n }}行
<view class="fly-content">
<view v-for="n in line"
:key="n"
class="h-10 leading-10 text-center"
title="3">
很多内容,这里是第{{ n }}行
</view>
</view>
</view>
</template>
<script lang="ts" setup>
withDefaults(defineProps<{ line?: number }>(), { line: 10 })
withDefaults(defineProps<{ line?: number }>(), { line: 10 });
</script>
<template>
<view class="text-green-500">header</view>
<view class="text-green-500">
header
</view>
</template>
<template>
<view class="fly-login" v-if="modelValue">
<view class="fly-login-mask" />
<view class="fly-login-content px-4">
<view class="font-bold h-16 leading-16">获取您的昵称、头像</view>
<view
class="rounded-full bg-light-600 w-6 h-6 text-center absolute top-4 right-4"
@click="onClose"
>
<view class="i-carbon-close text-gray-700" />
</view>
<view v-if="modelValue" class="fly-login">
<view class="fly-login-mask" />
<view class="fly-login-content px-4">
<view class="font-bold h-16 leading-16">
获取您的昵称、头像
</view>
<view class="rounded-full bg-light-600 w-6 h-6 text-center absolute top-4 right-4"
@click="onClose">
<view class="i-carbon-close text-gray-700" />
</view>
<view
class="flex items-center h-16 leading-16 border-b-gray-400 border-b-solid border-[1rpx]"
>
<text class="mr-4 flex-shrink-0">头像</text>
<button
class="bg-transparent flex items-center after:b-none w-full h-12 leading-12"
open-type="chooseAvatar"
@chooseavatar="onChooseAvatar"
>
<image class="w-8 h-8 rounded-full" :src="avatarUrl"></image>
<text class="ml-auto i-carbon-chevron-right"></text>
</button>
</view>
<view class="flex items-center h-16 leading-16 border-b-gray-400 border-b-solid border-[1rpx]">
<text class="mr-4 flex-shrink-0">头像</text>
<button class="bg-transparent flex items-center after:b-none w-full h-12 leading-12"
open-type="chooseAvatar"
@chooseavatar="onChooseAvatar">
<image class="w-8 h-8 rounded-full" :src="avatarUrl"></image>
<text class="ml-auto i-carbon-chevron-right"></text>
</button>
</view>
<view
class="flex items-center h-16 leading-16 border-b-gray-400 border-b-solid border-1 mt-4"
>
<text class="mr-4 flex-shrink-0">昵称</text>
<input type="nickname" placeholder="请输入昵称" @change="onChange" @blur="onChange" />
</view>
<view class="flex items-center h-16 leading-16 border-b-gray-400 border-b-solid border-1 mt-4">
<text class="mr-4 flex-shrink-0">昵称</text>
<input placeholder="请输入昵称"
type="nickname"
@blur="onChange"
@change="onChange" />
</view>
<button
size="default"
type="default"
style="color: #fff; background-color: #1aad19; border-color: #1aad19"
class="text-center leading-12 w-40 my-4"
@click="onSubmit"
>
确定
</button>
<button class="text-center leading-12 w-40 my-4"
size="default"
style="color: #fff; background-color: #1aad19; border-color: #1aad19"
type="default"
@click="onSubmit">
确定
</button>
</view>
</view>
</view>
</template>
<script lang="ts" setup>
import { useUserStore } from '@/store'
import defaultAvatarUrl from './defaultAvatar.png'
import { useUserStore } from "@/store";
const emit = defineEmits(['update:modelValue'])
defineProps<{ modelValue: boolean }>()
import defaultAvatarUrl from "./defaultAvatar.png";
const userStore = useUserStore()
defineProps<{ modelValue: boolean }>();
const emit = defineEmits([ "update:modelValue" ]);
const userStore = useUserStore();
const avatarUrl = ref(defaultAvatarUrl)
const nickname = ref('')
const avatarUrl = ref(defaultAvatarUrl);
const nickname = ref("");
const onClose = () => {
emit('update:modelValue', false)
}
emit("update:modelValue", false);
};
const onChooseAvatar = (e) => {
const { avatarUrl: url } = e.detail
avatarUrl.value = url
// 这里就要上传,加快速度,提升体验(用户多次选择头像就多次上传吧,总有取舍)
console.log(url)
}
const { avatarUrl: url } = e.detail;
avatarUrl.value = url;
// 这里就要上传,加快速度,提升体验(用户多次选择头像就多次上传吧,总有取舍)
console.log(url);
};
const onChange = (e) => {
const { value } = e.detail
nickname.value = value
console.log(value)
}
const { value } = e.detail;
nickname.value = value;
console.log(value);
};
const onSubmit = () => {
// 1、上传刚刚的图片,并返回网络地址
// 2、把用户信息存起来
if (avatarUrl.value === defaultAvatarUrl) {
uni.showToast({
title: '请选择头像',
icon: 'none',
})
return
}
if (!nickname.value) {
uni.showToast({
title: '请填写昵称',
icon: 'none',
})
return
}
// 1、上传刚刚的图片,并返回网络地址
// 2、把用户信息存起来
if (avatarUrl.value === defaultAvatarUrl) {
uni.showToast({
title: "请选择头像",
icon: "none",
});
return;
}
if (!nickname.value) {
uni.showToast({
title: "请填写昵称",
icon: "none",
});
return;
}
emit('update:modelValue', false)
console.log('保存用户信息')
userStore.setUserInfo({ nickname: nickname.value, avatar: avatarUrl.value })
}
emit("update:modelValue", false);
console.log("保存用户信息");
userStore.setUserInfo({ nickname: nickname.value, avatar: avatarUrl.value });
};
</script>
<style lang="scss" scoped>
......
<template>
<!-- 自定义导航栏: 默认透明不可见, scroll-view 滚动到 50 时展示 -->
<view class="fly-navbar" :style="{ paddingTop: safeAreaInsets?.top + 'px' }">
<!-- 1/3,多于1个页面,用返回图标 -->
<navigator v-if="pages.length > 1" open-type="navigateBack" class="left-icon">
<view class="bg-gray-500/80 rounded-full w-8 h-8 flex items-center justify-center">
<button class="i-carbon-chevron-left text-white w-7 h-7"></button>
</view>
</navigator>
<!-- 2/3,只有1个页面,如果不是tabbar,需要首页图标 -->
<!-- 这种情况一般出现在用户直接打开分享出去的详情页面,或者使用redirectTo等API -->
<navigator
v-else-if="!isTabbar"
open-type="switchTab"
url="/pages/index/index"
class="left-icon"
>
<view class="bg-gray-500/80 rounded-full w-8 h-8 flex items-center justify-center">
<button class="i-carbon-home text-white w-6 h-6"></button>
</view>
</navigator>
<!-- 3/3,如果当前页就是tabbar页,不用去首页,也就是什么图标都不需要 -->
<view class="title">{{ title || '' }}</view>
</view>
<!-- 自定义导航栏: 默认透明不可见, scroll-view 滚动到 50 时展示 -->
<view class="fly-navbar" :style="{ paddingTop: `${safeAreaInsets?.top }px` }">
<!-- 1/3,多于1个页面,用返回图标 -->
<navigator v-if="pages.length > 1"
class="left-icon"
open-type="navigateBack">
<view class="bg-gray-500/80 rounded-full w-8 h-8 flex items-center justify-center">
<button class="i-carbon-chevron-left text-white w-7 h-7"></button>
</view>
</navigator>
<!-- 2/3,只有1个页面,如果不是tabbar,需要首页图标 -->
<!-- 这种情况一般出现在用户直接打开分享出去的详情页面,或者使用redirectTo等API -->
<navigator v-else-if="!isTabbar"
class="left-icon"
open-type="switchTab"
url="/pages/index/index">
<view class="bg-gray-500/80 rounded-full w-8 h-8 flex items-center justify-center">
<button class="i-carbon-home text-white w-6 h-6"></button>
</view>
</navigator>
<!-- 3/3,如果当前页就是tabbar页,不用去首页,也就是什么图标都不需要 -->
<view class="title">
{{ title || '' }}
</view>
</view>
</template>
<script lang="ts" setup>
import { getIsTabbar } from '@/utils/index'
import { getIsTabbar } from "@/utils/index";
defineProps<{ title?: string }>()
defineProps<{ title?: string }>();
// 获取页面栈
const pages = getCurrentPages()
const isTabbar = getIsTabbar()
console.log({ isTabbar, pagesLen: pages.length })
const pages = getCurrentPages();
const isTabbar = getIsTabbar();
console.log({ isTabbar, pagesLen: pages.length });
// 获取屏幕边界到安全区域距离
const { safeAreaInsets } = uni.getSystemInfoSync()
const { safeAreaInsets } = uni.getSystemInfoSync();
</script>
<style lang="scss" scoped>
......
This diff could not be displayed because it is too large.
<template>
<view class="chartsview">
<view class="charts-error"></view>
<view class="charts-font">{{ errorMessage == null ? '请点击重试' : errorMessage }}</view>
</view>
<view class="chartsview">
<view class="charts-error"></view>
<view class="charts-font">
{{ errorMessage === null ? '请点击重试' : errorMessage }}
</view>
</view>
</template>
<script>
export default {
name: 'qiun-error',
props: {
errorMessage: {
type: String,
default: null,
name: "QiunError",
props: {
errorMessage: {
type: String,
default: null,
},
},
},
data() {
return {}
},
}
data() {
return {};
},
};
</script>
<style>
......
<template>
<view class="container loading1">
<view class="shape shape1"></view>
<view class="shape shape2"></view>
<view class="shape shape3"></view>
<view class="shape shape4"></view>
</view>
<view class="container loading1">
<view class="shape shape1"></view>
<view class="shape shape2"></view>
<view class="shape shape3"></view>
<view class="shape shape4"></view>
</view>
</template>
<script>
export default {
name: 'loading1',
data() {
return {}
},
}
name: "Loading1",
data() {
return {};
},
};
</script>
<style scoped="true">
......
<template>
<view class="container loading2">
<view class="shape shape1"></view>
<view class="shape shape2"></view>
<view class="shape shape3"></view>
<view class="shape shape4"></view>
</view>
<view class="container loading2">
<view class="shape shape1"></view>
<view class="shape shape2"></view>
<view class="shape shape3"></view>
<view class="shape shape4"></view>
</view>
</template>
<script>
export default {
name: 'loading2',
data() {
return {}
},
}
name: "Loading2",
data() {
return {};
},
};
</script>
<style scoped="true">
......@@ -25,18 +25,13 @@ export default {
.container.loading2 {
transform: rotate(10deg);
transform: rotate(10deg);
animation: rotation 1s infinite;
}
.container.loading2 .shape {
border-radius: 5px;
}
.container.loading2 {
animation: rotation 1s infinite;
animation: rotation 1s infinite;
}
.container .shape {
position: absolute;
width: 10px;
......@@ -67,117 +62,97 @@ export default {
.loading2 .shape1 {
animation: animation2shape1 0.5s ease 0s infinite alternate;
animation: animation2shape1 0.5s ease 0s infinite alternate;
}
@keyframes animation2shape1 {
from {
transform: translate(0, 0);
transform: translate(0, 0);
}
to {
transform: translate(20px, 20px);
transform: translate(20px, 20px);
}
}
@keyframes animation2shape1 {
from {
transform: translate(0, 0);
transform: translate(0, 0);
}
to {
transform: translate(20px, 20px);
transform: translate(20px, 20px);
}
}
.loading2 .shape2 {
animation: animation2shape2 0.5s ease 0s infinite alternate;
animation: animation2shape2 0.5s ease 0s infinite alternate;
}
@keyframes animation2shape2 {
from {
transform: translate(0, 0);
transform: translate(0, 0);
}
to {
transform: translate(-20px, 20px);
transform: translate(-20px, 20px);
}
}
@keyframes animation2shape2 {
from {
transform: translate(0, 0);
transform: translate(0, 0);
}
to {
transform: translate(-20px, 20px);
transform: translate(-20px, 20px);
}
}
.loading2 .shape3 {
animation: animation2shape3 0.5s ease 0s infinite alternate;
animation: animation2shape3 0.5s ease 0s infinite alternate;
}
@keyframes animation2shape3 {
from {
transform: translate(0, 0);
transform: translate(0, 0);
}
to {
transform: translate(20px, -20px);
transform: translate(20px, -20px);
}
}
@keyframes animation2shape3 {
from {
transform: translate(0, 0);
transform: translate(0, 0);
}
to {
transform: translate(20px, -20px);
transform: translate(20px, -20px);
}
}
.loading2 .shape4 {
animation: animation2shape4 0.5s ease 0s infinite alternate;
animation: animation2shape4 0.5s ease 0s infinite alternate;
}
@keyframes animation2shape4 {
from {
transform: translate(0, 0);
transform: translate(0, 0);
}
to {
transform: translate(-20px, -20px);
transform: translate(-20px, -20px);
}
}
@keyframes animation2shape4 {
from {
transform: translate(0, 0);
transform: translate(0, 0);
}
to {
transform: translate(-20px, -20px);
transform: translate(-20px, -20px);
}
}
</style>
<template>
<view class="container loading3">
<view class="shape shape1"></view>
<view class="shape shape2"></view>
<view class="shape shape3"></view>
<view class="shape shape4"></view>
</view>
<view class="container loading3">
<view class="shape shape1"></view>
<view class="shape shape2"></view>
<view class="shape shape3"></view>
<view class="shape shape4"></view>
</view>
</template>
<script>
export default {
name: 'loading3',
data() {
return {}
},
}
name: "Loading3",
data() {
return {};
},
};
</script>
<style scoped="true">
......@@ -25,7 +25,6 @@ export default {
.container.loading3 {
animation: rotation 1s infinite;
animation: rotation 1s infinite;
}
.container.loading3 .shape1 {
......@@ -74,117 +73,97 @@ export default {
.loading3 .shape1 {
animation: animation3shape1 0.5s ease 0s infinite alternate;
animation: animation3shape1 0.5s ease 0s infinite alternate;
}
@keyframes animation3shape1 {
from {
transform: translate(0, 0);
transform: translate(0, 0);
}
to {
transform: translate(5px, 5px);
transform: translate(5px, 5px);
}
}
@keyframes animation3shape1 {
from {
transform: translate(0, 0);
transform: translate(0, 0);
}
to {
transform: translate(5px, 5px);
transform: translate(5px, 5px);
}
}
.loading3 .shape2 {
animation: animation3shape2 0.5s ease 0s infinite alternate;
animation: animation3shape2 0.5s ease 0s infinite alternate;
}
@keyframes animation3shape2 {
from {
transform: translate(0, 0);
transform: translate(0, 0);
}
to {
transform: translate(-5px, 5px);
transform: translate(-5px, 5px);
}
}
@keyframes animation3shape2 {
from {
transform: translate(0, 0);
transform: translate(0, 0);
}
to {
transform: translate(-5px, 5px);
transform: translate(-5px, 5px);
}
}
.loading3 .shape3 {
animation: animation3shape3 0.5s ease 0s infinite alternate;
animation: animation3shape3 0.5s ease 0s infinite alternate;
}
@keyframes animation3shape3 {
from {
transform: translate(0, 0);
transform: translate(0, 0);
}
to {
transform: translate(5px, -5px);
transform: translate(5px, -5px);
}
}
@keyframes animation3shape3 {
from {
transform: translate(0, 0);
transform: translate(0, 0);
}
to {
transform: translate(5px, -5px);
transform: translate(5px, -5px);
}
}
.loading3 .shape4 {
animation: animation3shape4 0.5s ease 0s infinite alternate;
animation: animation3shape4 0.5s ease 0s infinite alternate;
}
@keyframes animation3shape4 {
from {
transform: translate(0, 0);
transform: translate(0, 0);
}
to {
transform: translate(-5px, -5px);
transform: translate(-5px, -5px);
}
}
@keyframes animation3shape4 {
from {
transform: translate(0, 0);
transform: translate(0, 0);
}
to {
transform: translate(-5px, -5px);
transform: translate(-5px, -5px);
}
}
</style>
<template>
<view class="container loading5">
<view class="shape shape1"></view>
<view class="shape shape2"></view>
<view class="shape shape3"></view>
<view class="shape shape4"></view>
</view>
<view class="container loading5">
<view class="shape shape1"></view>
<view class="shape shape2"></view>
<view class="shape shape3"></view>
<view class="shape shape4"></view>
</view>
</template>
<script>
export default {
name: 'loading5',
data() {
return {}
},
}
name: "Loading5",
data() {
return {};
},
};
</script>
<style scoped="true">
......@@ -63,44 +63,36 @@ export default {
@keyframes animation5shape1 {
0% {
transform: translate(0, 0);
transform: translate(0, 0);
}
25% {
transform: translate(0, 15px);
transform: translate(0, 15px);
}
50% {
transform: translate(15px, 15px);
transform: translate(15px, 15px);
}
75% {
transform: translate(15px, 0);
transform: translate(15px, 0);
}
}
@keyframes animation5shape1 {
0% {
transform: translate(0, 0);
transform: translate(0, 0);
}
25% {
transform: translate(0, 15px);
transform: translate(0, 15px);
}
50% {
transform: translate(15px, 15px);
transform: translate(15px, 15px);
}
75% {
transform: translate(15px, 0);
transform: translate(15px, 0);
}
}
......@@ -111,44 +103,36 @@ export default {
@keyframes animation5shape2 {
0% {
transform: translate(0, 0);
transform: translate(0, 0);
}
25% {
transform: translate(-15px, 0);
transform: translate(-15px, 0);
}
50% {
transform: translate(-15px, 15px);
transform: translate(-15px, 15px);
}
75% {
transform: translate(0, 15px);
transform: translate(0, 15px);
}
}
@keyframes animation5shape2 {
0% {
transform: translate(0, 0);
transform: translate(0, 0);
}
25% {
transform: translate(-15px, 0);
transform: translate(-15px, 0);
}
50% {
transform: translate(-15px, 15px);
transform: translate(-15px, 15px);
}
75% {
transform: translate(0, 15px);
transform: translate(0, 15px);
}
}
......@@ -159,44 +143,36 @@ export default {
@keyframes animation5shape3 {
0% {
transform: translate(0, 0);
transform: translate(0, 0);
}
25% {
transform: translate(15px, 0);
transform: translate(15px, 0);
}
50% {
transform: translate(15px, -15px);
transform: translate(15px, -15px);
}
75% {
transform: translate(0, -15px);
transform: translate(0, -15px);
}
}
@keyframes animation5shape3 {
0% {
transform: translate(0, 0);
transform: translate(0, 0);
}
25% {
transform: translate(15px, 0);
transform: translate(15px, 0);
}
50% {
transform: translate(15px, -15px);
transform: translate(15px, -15px);
}
75% {
transform: translate(0, -15px);
transform: translate(0, -15px);
}
}
......@@ -207,44 +183,36 @@ export default {
@keyframes animation5shape4 {
0% {
transform: translate(0, 0);
transform: translate(0, 0);
}
25% {
transform: translate(0, -15px);
transform: translate(0, -15px);
}
50% {
transform: translate(-15px, -15px);
transform: translate(-15px, -15px);
}
75% {
transform: translate(-15px, 0);
transform: translate(-15px, 0);
}
}
@keyframes animation5shape4 {
0% {
transform: translate(0, 0);
transform: translate(0, 0);
}
25% {
transform: translate(0, -15px);
transform: translate(0, -15px);
}
50% {
transform: translate(-15px, -15px);
transform: translate(-15px, -15px);
}
75% {
transform: translate(-15px, 0);
transform: translate(-15px, 0);
}
}
</style>
<template>
<view class="container loading6">
<view class="shape shape1"></view>
<view class="shape shape2"></view>
<view class="shape shape3"></view>
<view class="shape shape4"></view>
</view>
<view class="container loading6">
<view class="shape shape1"></view>
<view class="shape shape2"></view>
<view class="shape shape3"></view>
<view class="shape shape4"></view>
</view>
</template>
<script>
export default {
name: 'loading6',
data() {
return {}
},
}
name: "Loading6",
data() {
return {};
},
};
</script>
<style scoped="true">
.container {
......@@ -24,7 +24,6 @@ export default {
.container.loading6 {
animation: rotation 1s infinite;
animation: rotation 1s infinite;
}
.container.loading6 .shape {
......@@ -63,197 +62,161 @@ export default {
.loading6 .shape1 {
animation: animation6shape1 2s linear 0s infinite normal;
animation: animation6shape1 2s linear 0s infinite normal;
}
@keyframes animation6shape1 {
0% {
transform: translate(0, 0);
transform: translate(0, 0);
}
25% {
transform: translate(0, 18px);
transform: translate(0, 18px);
}
50% {
transform: translate(18px, 18px);
transform: translate(18px, 18px);
}
75% {
transform: translate(18px, 0);
transform: translate(18px, 0);
}
}
@keyframes animation6shape1 {
0% {
transform: translate(0, 0);
transform: translate(0, 0);
}
25% {
transform: translate(0, 18px);
transform: translate(0, 18px);
}
50% {
transform: translate(18px, 18px);
transform: translate(18px, 18px);
}
75% {
transform: translate(18px, 0);
transform: translate(18px, 0);
}
}
.loading6 .shape2 {
animation: animation6shape2 2s linear 0s infinite normal;
animation: animation6shape2 2s linear 0s infinite normal;
}
@keyframes animation6shape2 {
0% {
transform: translate(0, 0);
transform: translate(0, 0);
}
25% {
transform: translate(-18px, 0);
transform: translate(-18px, 0);
}
50% {
transform: translate(-18px, 18px);
transform: translate(-18px, 18px);
}
75% {
transform: translate(0, 18px);
transform: translate(0, 18px);
}
}
@keyframes animation6shape2 {
0% {
transform: translate(0, 0);
transform: translate(0, 0);
}
25% {
transform: translate(-18px, 0);
transform: translate(-18px, 0);
}
50% {
transform: translate(-18px, 18px);
transform: translate(-18px, 18px);
}
75% {
transform: translate(0, 18px);
transform: translate(0, 18px);
}
}
.loading6 .shape3 {
animation: animation6shape3 2s linear 0s infinite normal;
animation: animation6shape3 2s linear 0s infinite normal;
}
@keyframes animation6shape3 {
0% {
transform: translate(0, 0);
transform: translate(0, 0);
}
25% {
transform: translate(18px, 0);
transform: translate(18px, 0);
}
50% {
transform: translate(18px, -18px);
transform: translate(18px, -18px);
}
75% {
transform: translate(0, -18px);
transform: translate(0, -18px);
}
}
@keyframes animation6shape3 {
0% {
transform: translate(0, 0);
transform: translate(0, 0);
}
25% {
transform: translate(18px, 0);
transform: translate(18px, 0);
}
50% {
transform: translate(18px, -18px);
transform: translate(18px, -18px);
}
75% {
transform: translate(0, -18px);
transform: translate(0, -18px);
}
}
.loading6 .shape4 {
animation: animation6shape4 2s linear 0s infinite normal;
animation: animation6shape4 2s linear 0s infinite normal;
}
@keyframes animation6shape4 {
0% {
transform: translate(0, 0);
transform: translate(0, 0);
}
25% {
transform: translate(0, -18px);
transform: translate(0, -18px);
}
50% {
transform: translate(-18px, -18px);
transform: translate(-18px, -18px);
}
75% {
transform: translate(-18px, 0);
transform: translate(-18px, 0);
}
}
@keyframes animation6shape4 {
0% {
transform: translate(0, 0);
transform: translate(0, 0);
}
25% {
transform: translate(0, -18px);
transform: translate(0, -18px);
}
50% {
transform: translate(-18px, -18px);
transform: translate(-18px, -18px);
}
75% {
transform: translate(-18px, 0);
transform: translate(-18px, 0);
}
}
</style>
<template>
<view>
<Loading1 v-if="loadingType == 1" />
<Loading2 v-if="loadingType == 2" />
<Loading3 v-if="loadingType == 3" />
<Loading4 v-if="loadingType == 4" />
<Loading5 v-if="loadingType == 5" />
</view>
<view>
<Loading1 v-if="loadingType === 1" />
<Loading2 v-if="loadingType === 2" />
<Loading3 v-if="loadingType === 3" />
<Loading4 v-if="loadingType === 4" />
<Loading5 v-if="loadingType === 5" />
</view>
</template>
<script>
import Loading1 from './loading1.vue'
import Loading2 from './loading2.vue'
import Loading3 from './loading3.vue'
import Loading4 from './loading4.vue'
import Loading5 from './loading5.vue'
import Loading1 from "./loading1.vue";
import Loading2 from "./loading2.vue";
import Loading3 from "./loading3.vue";
import Loading4 from "./loading4.vue";
import Loading5 from "./loading5.vue";
export default {
components: { Loading1, Loading2, Loading3, Loading4, Loading5 },
name: 'qiun-loading',
props: {
loadingType: {
type: Number,
default: 2,
name: "QiunLoading",
components: { Loading1, Loading2, Loading3, Loading4, Loading5 },
props: {
loadingType: {
type: Number,
default: 2,
},
},
},
data() {
return {}
},
}
data() {
return {};
},
};
</script>
<style></style>
<template>
<view class="qiun-title-bar">
<view class="qiun-title-dot"></view>
<view class="qiun-title-text">{{ title }}</view>
</view>
<view class="qiun-title-bar">
<view class="qiun-title-dot"></view>
<view class="qiun-title-text">
{{ title }}
</view>
</view>
</template>
<script>
export default {
name: 'title-bar',
props: {
title: {
type: String,
default: '',
name: "TitleBar",
props: {
title: {
type: String,
default: "",
},
},
},
mounted() {},
methods: {},
}
mounted() {},
methods: {},
};
</script>
<style>
......
/// <reference types="vite/client" />
/// <reference types="vite-svg-loader" />
declare module '*.vue' {
import { DefineComponent } from 'vue'
// eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/ban-types
const component: DefineComponent<{}, {}, any>
export default component
// / <reference types="vite/client" />
// / <reference types="vite-svg-loader" />
/* eslint-disable */
declare module "*.vue" {
import { DefineComponent } from "vue";
const component: DefineComponent<{}, {}, any>;
export default component;
}
interface ImportMetaEnv {
......
/* eslint-disable import/first */
// 小程序中引入 echarts
// #ifndef APP-PLUS || H5
// eslint-disable-next-line @typescript-eslint/no-var-requires
const echarts = require('../uni_modules/lime-echart/static/echarts.min')
/* eslint-disable */
import { ref } from "vue";
// #endif
// APP 与 H5 引入 echarts
// #ifdef APP-PLUS || H5
import * as echartsAppOrH5 from 'echarts'
import * as echartsAppOrH5 from "echarts";
// #endif
import { ref } from 'vue'
// 小程序中引入 echarts
// #ifndef APP-PLUS || H5
const echarts = require("../uni_modules/lime-echart/static/echarts.min");
// echarts 图表 Hooks
export const useEcharts = (options): any => {
// echarts 图实例
const chartRef = ref(null)
// echarts 图绘制函数
const draw = () => {
setTimeout(async () => {
if (!chartRef.value) return
// #ifndef APP-PLUS || H5
const chart = await chartRef.value.init(echarts)
chart.setOption(options.value)
// #endif
// #ifdef APP-PLUS || H5
const chartAPP = await chartRef.value.init(echartsAppOrH5)
chartAPP.setOption(options.value)
// #endif
}, 300)
}
// 这里就封装巧妙之处,如果是对象,那么需要重命名,而是是数组,无需重命名
return [chartRef, options, draw]
}
// echarts 图实例
const chartRef = ref(null);
// echarts 图绘制函数
const draw = () => {
setTimeout(async () => {
if (!chartRef.value) return;
// #ifndef APP-PLUS || H5
const chart = await chartRef.value.init(echarts);
chart.setOption(options.value);
// #endif
// #ifdef APP-PLUS || H5
const chartAPP = await chartRef.value.init(echartsAppOrH5);
chartAPP.setOption(options.value);
// #endif
}, 300);
};
// 这里就封装巧妙之处,如果是对象,那么需要重命名,而是是数组,无需重命名
return [ chartRef, options, draw ];
};
import { onReady } from '@dcloudio/uni-app'
import { getIsTabbar, getLastItem } from '@/utils/index'
import { getIsTabbar, getLastItem } from "@/utils/index";
import { onReady } from "@dcloudio/uni-app";
export default () => {
// 获取页面栈
const pages = getCurrentPages()
const isTabbar = getIsTabbar()
export const useNavbarWeixin = () => {
// 获取页面栈
const pages = getCurrentPages();
const isTabbar = getIsTabbar();
// 页面滚动到底部时的操作,通常用于加载更多数据
const onScrollToLower = () => {}
// 获取屏幕边界到安全区域距离
const { safeAreaInsets } = uni.getSystemInfoSync()
// 页面滚动到底部时的操作,通常用于加载更多数据
const onScrollToLower = () => {};
// 获取屏幕边界到安全区域距离
const { safeAreaInsets } = uni.getSystemInfoSync();
// #ifdef MP-WEIXIN
// 基于小程序的 Page 类型扩展 uni-app 的 Page
type PageInstance = Page.PageInstance & WechatMiniprogram.Page.InstanceMethods<any>
// 获取当前页面实例,数组最后一项
const pageInstance = getLastItem(getCurrentPages()) as PageInstance
const pageInstance = getLastItem(getCurrentPages()) as PageInstance;
// 页面渲染完毕,绑定动画效果
onReady(() => {
// 动画效果,导航栏背景色
pageInstance.animate(
'.fly-navbar',
[{ backgroundColor: 'transparent' }, { backgroundColor: '#f8f8f8' }],
1000,
{
scrollSource: '#scroller',
timeRange: 1000,
startScrollOffset: 0,
endScrollOffset: 50,
},
)
// 动画效果,导航栏标题
pageInstance.animate(
'.fly-navbar .title',
[{ color: 'transparent' }, { color: '#000' }],
1000,
{
scrollSource: '#scroller',
timeRange: 1000,
startScrollOffset: 0,
endScrollOffset: 50,
},
)
// 动画效果,导航栏返回按钮
pageInstance.animate('.fly-navbar .left-icon', [{ color: '#fff' }, { color: '#000' }], 1000, {
scrollSource: '#scroller',
timeRange: 1000,
startScrollOffset: 0,
endScrollOffset: 50,
})
})
// 动画效果,导航栏背景色
pageInstance.animate(
".fly-navbar",
[ { backgroundColor: "transparent" }, { backgroundColor: "#f8f8f8" } ],
1000,
{
scrollSource: "#scroller",
timeRange: 1000,
startScrollOffset: 0,
endScrollOffset: 50,
},
);
// 动画效果,导航栏标题
pageInstance.animate(
".fly-navbar .title",
[ { color: "transparent" }, { color: "#000" } ],
1000,
{
scrollSource: "#scroller",
timeRange: 1000,
startScrollOffset: 0,
endScrollOffset: 50,
},
);
// 动画效果,导航栏返回按钮
pageInstance.animate(".fly-navbar .left-icon", [ { color: "#fff" }, { color: "#000" } ], 1000, {
scrollSource: "#scroller",
timeRange: 1000,
startScrollOffset: 0,
endScrollOffset: 50,
});
});
// #endif
return {
pages,
isTabbar,
onScrollToLower,
safeAreaInsets,
}
}
pages,
isTabbar,
onScrollToLower,
safeAreaInsets,
};
};
export default useNavbarWeixin;
import { UnwrapRef } from 'vue'
type IUseRequestOptions<T> = {
/** 是否立即执行,如果是则在onLoad执行 */
......@@ -16,29 +15,30 @@ type IUseRequestOptions<T> = {
* @returns 返回一个对象{loading, error, data, run},包含请求的加载状态、错误信息、响应数据和手动触发请求的函数。
*/
export default function useRequest<T>(
func: () => Promise<IResData<T>>,
options: IUseRequestOptions<T> = { immediate: true },
func: () => Promise<IResData<T>>,
options: IUseRequestOptions<T>,
) {
const loading = ref(false)
const error = ref(false)
const data = ref<T>(options.initialData)
const run = async () => {
loading.value = true
func()
.then((res) => {
data.value = res.data as UnwrapRef<T>
error.value = false
})
.catch((err) => {
error.value = err
})
.finally(() => {
loading.value = false
})
}
options = options ?? { immediate: true };
const loading = ref(false);
const error = ref(false);
const data = ref<T>(options.initialData);
const run = async () => {
loading.value = true;
func()
.then((res) => {
data.value = res.data as T;
error.value = false;
})
.catch((error_) => {
error.value = error;
})
.finally(() => {
loading.value = false;
});
};
onLoad(() => {
options.immediate && run()
})
return { loading, error, data, run }
onLoad(() => {
options.immediate && run();
});
return { loading, error, data, run };
}
// TODO: 别忘加更改环境变量的 VITE_UPLOAD_BASEURL 地址。
const VITE_UPLOAD_BASEURL = import.meta.env.VITE_UPLOAD_BASEURL
const VITE_UPLOAD_BASEURL = import.meta.env.VITE_UPLOAD_BASEURL;
/**
* useUpload 是一个定制化的请求钩子,用于处理上传图片。
......@@ -7,61 +7,61 @@ const VITE_UPLOAD_BASEURL = import.meta.env.VITE_UPLOAD_BASEURL
* @returns 返回一个对象{loading, error, data, run},包含请求的加载状态、错误信息、响应数据和手动触发请求的函数。
*/
export default function useUpload<T = string>(formData: Record<string, any> = {}) {
const loading = ref(false)
const error = ref(false)
const data = ref<T>()
const run = () => {
const loading = ref(false);
const error = ref(false);
const data = ref<T>();
const run = () => {
// #ifdef MP-WEIXIN
// 微信小程序从基础库 2.21.0 开始, wx.chooseImage 停止维护,请使用 uni.chooseMedia 代替。
// 微信小程序在2023年10月17日之后,使用本API需要配置隐私协议
uni.chooseMedia({
count: 1,
mediaType: ['image'],
success: (res) => {
loading.value = true
const tempFilePath = res.tempFiles[0].tempFilePath
uploadFile<T>({ tempFilePath, formData, data, error, loading })
},
fail: (err) => {
console.log('uni.chooseMedia err->', err)
error.value = true
},
})
uni.chooseMedia({
count: 1,
mediaType: [ "image" ],
success: (res) => {
loading.value = true;
const tempFilePath = res.tempFiles[0].tempFilePath;
uploadFile<T>({ tempFilePath, formData, data, error, loading });
},
fail: (err) => {
console.log("uni.chooseMedia err->", err);
error.value = true;
},
});
// #endif
// #ifndef MP-WEIXIN
uni.chooseImage({
count: 1,
success: (res) => {
loading.value = true;
const tempFilePath = res.tempFilePaths[0];
uploadFile<T>({ tempFilePath, formData, data, error, loading });
},
fail: (err) => {
console.log("uni.chooseImage err->", err);
error.value = true;
},
});
// #endif
// #ifndef MP-WEIXIN
uni.chooseImage({
count: 1,
success: (res) => {
loading.value = true
const tempFilePath = res.tempFilePaths[0]
uploadFile<T>({ tempFilePath, formData, data, error, loading })
},
fail: (err) => {
console.log('uni.chooseImage err->', err)
error.value = true
},
})
// #endif
}
};
return { loading, error, data, run }
return { loading, error, data, run };
}
function uploadFile<T>({ tempFilePath, formData, data, error, loading }) {
uni.uploadFile({
url: VITE_UPLOAD_BASEURL,
filePath: tempFilePath,
name: 'file',
formData,
success: (uploadFileRes) => {
data.value = uploadFileRes.data as T
},
fail: (err) => {
console.log('uni.uploadFile err->', err)
error.value = true
},
complete: () => {
loading.value = false
},
})
uni.uploadFile({
url: VITE_UPLOAD_BASEURL,
filePath: tempFilePath,
name: "file",
formData,
success: (uploadFileRes) => {
data.value = uploadFileRes.data as T;
},
fail: (err) => {
console.log("uni.uploadFile err->", err);
error.value = true;
},
complete: () => {
loading.value = false;
},
});
}
/* eslint-disable no-unused-vars */
export {}
declare module 'vue' {
declare module "vue" {
interface ComponentCustomProperties {
$t: (key: string, opt?: Record<string, any>) => string
$tm: (key: string, opt?: Record<string, any>) => [] | { [p: string]: any }
......
export { routeInterceptor } from './route'
export { requestInterceptor } from './request'
export { requestInterceptor } from "./request";
export { routeInterceptor } from "./route";
/* eslint-disable no-param-reassign */
import qs from 'qs'
import { useUserStore } from '@/store'
import { useUserStore } from "@/store";
import qs from "qs";
export type CustomRequestOptions = UniApp.RequestOptions & {
query?: Record<string, any>
} & IUniUploadFileOptions // 添加uni.uploadFile参数类型
export type CustomRequestOptions = IUniUploadFileOptions;
// 请求基地址
const baseURL = import.meta.env.VITE_SERVER_BASEURL
const baseURL = import.meta.env.VITE_SERVER_BASEURL;
// 拦截器配置
const httpInterceptor = {
// 拦截前触发
invoke(options: CustomRequestOptions) {
// 拦截前触发
invoke(options: CustomRequestOptions) {
// 接口请求支持通过 query 参数配置 queryString
if (options.query) {
const queryStr = qs.stringify(options.query)
if (options.url.includes('?')) {
options.url += `&${queryStr}`
} else {
options.url += `?${queryStr}`
}
}
// api 目前为 mock 接口,所以无需处理
if (!options.url.startsWith('http')) {
// 1. 非 http 开头需拼接地址
options.url = baseURL + options.url
}
// 2. 请求超时
options.timeout = 10000 // 10s
// 3. 添加小程序端请求头标识
options.header = {
platform: 'mp-weixin', // 可选值与 uniapp 定义的平台一致,告诉后台来源
...options.header,
}
// 4. 添加 token 请求头标识
const userStore = useUserStore()
const { token } = userStore.userInfo as unknown as IUserInfo
if (token) {
options.header.Authorization = `Bearer ${token}`
}
},
}
if (options.query) {
const queryStr = qs.stringify(options.query);
if (options.url.includes("?")) {
options.url += `&${queryStr}`;
} else {
options.url += `?${queryStr}`;
}
}
// api 目前为 mock 接口,所以无需处理
if (!options.url.startsWith("http")) {
// 1. 非 http 开头需拼接地址
options.url = baseURL + options.url;
}
// 2. 请求超时
options.timeout = 10_000; // 10s
// 3. 添加小程序端请求头标识
options.header = {
platform: "mp-weixin", // 可选值与 uniapp 定义的平台一致,告诉后台来源
...options.header,
};
// 4. 添加 token 请求头标识
const userStore = useUserStore();
const { token } = userStore.userInfo as unknown as IUserInfo;
if (token) {
options.header.Authorization = `Bearer ${token}`;
}
},
};
export const requestInterceptor = {
install() {
install() {
// 拦截 request 请求
uni.addInterceptor('request', httpInterceptor)
// 拦截 uploadFile 文件上传
uni.addInterceptor('uploadFile', httpInterceptor)
},
}
uni.addInterceptor("request", httpInterceptor);
// 拦截 uploadFile 文件上传
uni.addInterceptor("uploadFile", httpInterceptor);
},
};
......@@ -4,51 +4,51 @@
* 可以设置路由白名单,或者黑名单,看业务需要选哪一个
* 我这里应为大部分都可以随便进入,所以使用黑名单
*/
import { useUserStore } from '@/store'
import { getNeedLoginPages, needLoginPages as _needLoginPages } from '@/utils'
import { useUserStore } from "@/store";
import { needLoginPages as _needLoginPages, getNeedLoginPages } from "@/utils";
// TODO Check
const loginRoute = '/pages/login/index'
const loginRoute = "/pages/login/index";
const isLogined = () => {
const userStore = useUserStore()
return userStore.isLogined
}
const userStore = useUserStore();
return userStore.isLogined;
};
const isDev = import.meta.env.DEV
const isDev = import.meta.env.DEV;
// 黑名单登录拦截器 - (适用于大部分页面不需要登录,少部分页面需要登录)
const navigateToInterceptor = {
// 注意,这里的url是 '/' 开头的,如 '/pages/index/index',跟 'pages.json' 里面的 path 不同
invoke({ url }: { url: string }) {
console.log(url) // /pages/route-interceptor/index?name=feige&age=30
const path = url.split('?')[0]
let needLoginPages: string[] = []
// 为了防止开发时出现BUG,这里每次都获取一下。生产环境可以移到函数外,性能更好
if (isDev) {
needLoginPages = getNeedLoginPages()
} else {
needLoginPages = _needLoginPages
}
console.log(needLoginPages.includes(path))
// 注意,这里的url是 '/' 开头的,如 '/pages/index/index',跟 'pages.json' 里面的 path 不同
invoke({ url }: { url: string }) {
console.log(url); // /pages/route-interceptor/index?name=feige&age=30
const path = url.split("?")[0];
let needLoginPages: string[] = [];
// 为了防止开发时出现BUG,这里每次都获取一下。生产环境可以移到函数外,性能更好
if (isDev) {
needLoginPages = getNeedLoginPages();
} else {
needLoginPages = _needLoginPages;
}
console.log(needLoginPages.includes(path));
if (needLoginPages.includes(path)) {
const isLogin = isLogined()
if (isLogin) {
return true
}
const redirectRoute = `${loginRoute}?redirect=${encodeURIComponent(url)}`
uni.navigateTo({ url: redirectRoute })
return false
}
return true
},
}
if (needLoginPages.includes(path)) {
const isLogin = isLogined();
if (isLogin) {
return true;
}
const redirectRoute = `${loginRoute}?redirect=${encodeURIComponent(url)}`;
uni.navigateTo({ url: redirectRoute });
return false;
}
return true;
},
};
export const routeInterceptor = {
install() {
uni.addInterceptor('navigateTo', navigateToInterceptor)
uni.addInterceptor('reLaunch', navigateToInterceptor)
uni.addInterceptor('redirectTo', navigateToInterceptor)
},
}
install() {
uni.addInterceptor("navigateTo", navigateToInterceptor);
uni.addInterceptor("reLaunch", navigateToInterceptor);
uni.addInterceptor("redirectTo", navigateToInterceptor);
},
};
<template>
<view class="default-layout">
<slot />
<wd-toast />
<wd-message-box />
</view>
<view class="default-layout">
<slot />
<wd-toast />
<wd-message-box />
</view>
</template>
<style lang="scss">
.default-layout {
height: 100vh;
/* #ifdef H5 */
padding-bottom: 50px;
overflow: auto;
/* #endif */
}
</style>
<template>
<view class="text-center p-4">
<slot />
<wd-toast />
<wd-message-box />
</view>
<view class="text-center p-4">
<slot />
<wd-toast />
<wd-message-box />
</view>
</template>
import { createI18n } from 'vue-i18n'
import { createI18n } from "vue-i18n";
import en from './en.json'
import zhHans from './zh-Hans.json' // 简体中文
import en from "./en.json";
import zhHans from "./zh-Hans.json"; // 简体中文
const messages = {
en,
'zh-Hans': zhHans, // key 不能乱写,查看截图 screenshots/i18n.png
}
en,
"zh-Hans": zhHans, // key 不能乱写,查看截图 screenshots/i18n.png
};
const i18n = createI18n({
locale: uni.getLocale(), // 获取已设置的语言,fallback 语言需要再 manifest.config.ts 中设置
messages,
})
locale: uni.getLocale(), // 获取已设置的语言,fallback 语言需要再 manifest.config.ts 中设置
messages,
});
console.log(uni.getLocale())
console.log(i18n.global.locale)
console.log(uni.getLocale());
console.log(i18n.global.locale);
/**
* 非 vue 文件使用这个方法
* @param { string } localeKey 多语言的key,eg: "app.name"
*/
export const translate = (localeKey: string) => {
if (!localeKey) {
console.error(`[i18n] Function translate(), localeKey param is required`)
return ''
}
const locale = uni.getLocale()
console.log('locale:', locale)
if (!localeKey) {
console.error(`[i18n] Function translate(), localeKey param is required`);
return "";
}
const locale = uni.getLocale();
console.log("locale:", locale);
const message = messages[locale]
if (Object.keys(message).includes(localeKey)) {
return message[localeKey]
}
return localeKey
}
export default i18n
const message = messages[locale];
if (Object.keys(message).includes(localeKey)) {
return message[localeKey];
}
return localeKey;
};
export default i18n;
import { createSSRApp } from 'vue'
import uvUI from '@climblee/uv-ui'
import App from './App.vue'
import store from './store'
import { routeInterceptor, requestInterceptor } from './interceptors'
import i18n from './locale/index'
import 'virtual:svg-icons-register'
import 'virtual:uno.css'
import '@/style/index.scss'
import { createSSRApp } from "vue";
import uvUI from "@climblee/uv-ui";
import App from "./App.vue";
import { requestInterceptor, routeInterceptor } from "./interceptors";
import i18n from "./locale/index";
import store from "./store";
import "virtual:svg-icons-register";
import "virtual:uno.css";
import "@/style/index.scss";
// production mock server
// 线上报错,TODO: fix me
......@@ -18,13 +22,13 @@ import '@/style/index.scss'
// }
export function createApp() {
const app = createSSRApp(App)
app.use(store)
app.use(i18n)
app.use(uvUI)
app.use(routeInterceptor)
app.use(requestInterceptor)
return {
app,
}
const app = createSSRApp(App);
app.use(store);
app.use(i18n);
app.use(uvUI);
app.use(routeInterceptor);
app.use(requestInterceptor);
return {
app,
};
}
......@@ -5,10 +5,14 @@
</route>
<template>
<view class="text-center">
<view class="m-8">http://localhost:9000/#/pages-sub/demo/index</view>
<view class="text-green-500">分包页面demo</view>
</view>
<view class="text-center">
<view class="m-8">
http://localhost:9000/#/pages-sub/demo/index
</view>
<view class="text-green-500">
分包页面demo
</view>
</view>
</template>
<script lang="ts" setup>
......
......@@ -5,14 +5,14 @@
}
</route>
<template>
<div>
<h1>欢迎使用 unibest</h1>
<view class="h-10"></view>
<AppTest>这个组件会自动导入</AppTest>
<view class="h-10"></view>
<AppTest2>这个组件会自动导入</AppTest2>
<view class="text-red-700 mt-4">
不可滥用自动导入,不是全局要用的组件不建议放到 `src/components` 里面,会增加包的体积
</view>
</div>
<div>
<h1>欢迎使用 unibest</h1>
<view class="h-10"></view>
<AppTest>这个组件会自动导入</AppTest>
<view class="h-10"></view>
<AppTest2>这个组件会自动导入</AppTest2>
<view class="text-red-700 mt-4">
不可滥用自动导入,不是全局要用的组件不建议放到 `src/components` 里面,会增加包的体积
</view>
</div>
</template>
......@@ -8,48 +8,71 @@
</route>
<template>
<view class="p-6 text-center">
<view class="my-2">使用的是 laf 云后台</view>
<view class="text-green-400">我的推荐码,可以获得佣金</view>
<view class="p-6 text-center">
<view class="my-2">
使用的是 laf 云后台
</view>
<view class="text-green-400">
我的推荐码,可以获得佣金
</view>
<!-- #ifdef H5 -->
<view class="my-2">
<a class="my-2" :href="recommendUrl" target="_blank">{{ recommendUrl }}</a>
</view>
<!-- #endif -->
<!-- #ifdef H5 -->
<view class="my-2">
<a class="my-2"
:href="recommendUrl"
target="_blank">
{{ recommendUrl }}
</a>
</view>
<!-- #endif -->
<!-- #ifndef H5 -->
<view class="my-2 text-left text-sm">{{ recommendUrl }}</view>
<!-- #endif -->
<!-- #ifndef H5 -->
<view class="my-2 text-left text-sm">
{{ recommendUrl }}
</view>
<!-- #endif -->
<!-- http://localhost:9000/#/pages/index/request -->
<wd-button @click="run" class="my-6">发送请求</wd-button>
<view class="h-12">
<view v-if="loading">loading...</view>
<block v-else>
<view class="text-xl">请求数据如下</view>
<view class="text-green leading-8">{{ JSON.stringify(data) }}</view>
</block>
<!-- http://localhost:9000/#/pages/index/request -->
<wd-button class="my-6" @click="run">
发送请求
</wd-button>
<view class="h-12">
<view v-if="loading">
loading...
</view>
<block v-else>
<view class="text-xl">
请求数据如下
</view>
<view class="text-green leading-8">
{{ JSON.stringify(data) }}
</view>
</block>
</view>
<wd-button class="my-6"
:disabled="!data"
type="error"
@click="reset">
重置数据
</wd-button>
</view>
<wd-button type="error" @click="reset" class="my-6" :disabled="!data">重置数据</wd-button>
</view>
</template>
<script lang="ts" setup>
import { getFooAPI, postFooAPI, IFooItem } from '@/service/foo'
import { getFooAPI, IFooItem } from "@/service/foo";
const recommendUrl = ref('http://laf.run/signup?code=ohaOgIX')
const recommendUrl = ref("http://laf.run/signup?code=ohaOgIX");
// const initialData = {
// name: 'initialData',
// id: '1234',
// }
const initialData = undefined
const initialData = undefined;
// 适合少部分全局性的接口————多个页面都需要的请求接口,额外编写一个 Service 层
const { loading, error, data, run } = useRequest<IFooItem>(() => getFooAPI('菲鸽'), {
initialData,
})
const { loading, error, data, run } = useRequest<IFooItem>(() => getFooAPI("菲鸽"), {
initialData,
});
const reset = () => {
data.value = initialData
}
data.value = initialData;
};
</script>
......@@ -8,55 +8,77 @@
</route>
<template>
<view class="p-6 text-center">
<!-- http://localhost:9000/#/pages/index/request -->
<wd-button @click="getFoo" class="my-6">发送请求</wd-button>
<view class="h-12">
<view v-if="loading1">loading...</view>
<block v-else>
<view class="text-xl">请求数据如下</view>
<view class="text-green leading-8">{{ JSON.stringify(data1) }}</view>
</block>
<view class="p-6 text-center">
<!-- http://localhost:9000/#/pages/index/request -->
<wd-button class="my-6" @click="getFoo">
发送请求
</wd-button>
<view class="h-12">
<view v-if="loading1">
loading...
</view>
<block v-else>
<view class="text-xl">
请求数据如下
</view>
<view class="text-green leading-8">
{{ JSON.stringify(data1) }}
</view>
</block>
</view>
<wd-button class="my-6" @click="getBar">
发送请求2
</wd-button>
<view class="h-12">
<view v-if="loading2">
loading...
</view>
<block v-else>
<view class="text-xl">
请求数据如下
</view>
<view class="text-green leading-8">
{{ JSON.stringify(data2) }}
</view>
</block>
</view>
<wd-button class="my-6"
:disabled="!data1 || !data2"
type="error"
@click="reset">
重置数据
</wd-button>
<wd-button class="my-6 ml-2"
:disabled="!!data1 || !!data2"
type="success"
@click="getAllData">
同时发送请求
</wd-button>
</view>
<wd-button @click="getBar" class="my-6">发送请求2</wd-button>
<view class="h-12">
<view v-if="loading2">loading...</view>
<block v-else>
<view class="text-xl">请求数据如下</view>
<view class="text-green leading-8">{{ JSON.stringify(data2) }}</view>
</block>
</view>
<wd-button type="error" @click="reset" class="my-6" :disabled="!data1 || !data2">
重置数据
</wd-button>
<wd-button type="success" @click="getAllData" class="my-6 ml-2" :disabled="!!data1 || !!data2">
同时发送请求
</wd-button>
</view>
</template>
<script lang="ts" setup>
import { getFooAPI, postFooAPI, IFooItem } from '@/service/foo'
import { getFooAPI, IFooItem, postFooAPI } from "@/service/foo";
// 适合少部分全局性的接口————多个页面都需要的请求接口,额外编写一个 Service 层
const {
loading: loading1,
error: err1,
data: data1,
run: getFoo,
} = useRequest<IFooItem>(() => getFooAPI('菲鸽'))
loading: loading1,
error: err1,
data: data1,
run: getFoo,
} = useRequest<IFooItem>(() => getFooAPI("菲鸽"));
const {
loading: loading2,
error: err2,
data: data2,
run: getBar,
} = useRequest<IFooItem>(() => postFooAPI('菲鸽222'))
loading: loading2,
error: err2,
data: data2,
run: getBar,
} = useRequest<IFooItem>(() => postFooAPI("菲鸽222"));
const reset = () => {
data1.value = undefined
data2.value = undefined
}
data1.value = undefined;
data2.value = undefined;
};
const getAllData = () => {
getFoo()
getBar()
}
getFoo();
getBar();
};
</script>
......@@ -8,21 +8,31 @@
</route>
<template>
<view class="p-4 text-center">
<wd-button @click="run">选择图片并上传</wd-button>
<view v-if="loading" class="text-blue h-10">上传...</view>
<template v-else>
<view class="m-2">上传后返回的接口数据:</view>
<view class="m-2">{{ data }}</view>
<view class="h-80 w-full">
<image v-if="data" :src="data || data" mode="scaleToFill" />
</view>
</template>
</view>
<view class="p-4 text-center">
<wd-button @click="run">
选择图片并上传
</wd-button>
<view v-if="loading" class="text-blue h-10">
上传...
</view>
<template v-else>
<view class="m-2">
上传后返回的接口数据:
</view>
<view class="m-2">
{{ data }}
</view>
<view class="h-80 w-full">
<image v-if="data"
mode="scaleToFill"
:src="data || data" />
</view>
</template>
</view>
</template>
<script lang="ts" setup>
const { loading, data, run } = useUpload({ user: '菲鸽' })
const { loading, data, run } = useUpload({ user: "菲鸽" });
</script>
<style lang="scss" scoped>
......
......@@ -8,15 +8,23 @@
</route>
<template>
<view class="mt-4">
进过多次测试发现,粘贴的css代码块在如下情况时会出现格式化问题:
<view class="ml-4">粘贴的css代码块中类名上面不包含空行(与大小写无关)</view>
<view class="ml-4 text-green-600">1. 中间有空行的,正常,不用处理;</view>
<view class="ml-4 text-red-600">
2. 中间没有空行的,格式化异常,通过 ctrl+Z,ctrl+S 可以搞定
<view class="mt-4">
进过多次测试发现,粘贴的css代码块在如下情况时会出现格式化问题:
<view class="ml-4">
粘贴的css代码块中类名上面不包含空行(与大小写无关)
</view>
<view class="ml-4 text-green-600">
1. 中间有空行的,正常,不用处理;
</view>
<view class="ml-4 text-red-600">
2. 中间没有空行的,格式化异常,通过 ctrl+Z,ctrl+S 可以搞定
</view>
<image class="css-img mt-2"
height="885"
mode="scaleToFill"
src="./css.png"
width="688" />
</view>
<image src="./css.png" mode="scaleToFill" class="css-img mt-2" width="688" height="885" />
</view>
</template>
<script lang="ts" setup>
......@@ -25,6 +33,7 @@
<style lang="scss" scoped>
// 最初的代码如下(版本1)
/*
.test{
background: #FFF;
......@@ -35,6 +44,7 @@
*/
// 中间有空行可以正常格式化(版本2)
/*
.test{
background: #FFF;
......
......@@ -6,13 +6,15 @@
</route>
<template>
<view class="center mt-8 text-green-600">enum 使用,script setup 里面这样写不会报错</view>
<view class="center mt-8 text-green-600">
enum 使用,script setup 里面这样写不会报错
</view>
</template>
<script lang="ts" setup>
type T = TestEnum.A
const a = 'a' as T
console.log(a)
const a = "a" as T;
console.log(a);
</script>
<style lang="scss" scoped>
......
......@@ -5,18 +5,20 @@
</route>
<template>
<view class="mt-4 ml-4">
当前环境 import.meta.env.DEV:
<text class="text-red-500 ml-4">{{ isDev }}</text>
</view>
<view class="mt-4 ml-4">
当前环境所使用的环境文件
<text class="text-red-500 ml-4">{{ VITE_ENV_FILE }}</text>
</view>
<view class="text-red-500 mt-8 ml-4">环境变量的使用与 --mode 参数配合使用</view>
<view class="mt-4 ml-4">
当前环境 import.meta.env.DEV:
<text class="text-red-500 ml-4">{{ isDev }}</text>
</view>
<view class="mt-4 ml-4">
当前环境所使用的环境文件
<text class="text-red-500 ml-4">{{ VITE_ENV_FILE }}</text>
</view>
<view class="text-red-500 mt-8 ml-4">
环境变量的使用与 --mode 参数配合使用
</view>
</template>
<script lang="ts" setup>
const isDev = import.meta.env.DEV
const { VITE_ENV_FILE } = import.meta.env
const isDev = import.meta.env.DEV;
const { VITE_ENV_FILE } = import.meta.env;
</script>
......@@ -8,12 +8,12 @@
</route>
<template>
<view class="m-4">
<text mr-2>iconfont:</text>
<i class="iconfont icon-package text-primary"></i>
<i class="iconfont icon-chat text-primary"></i>
<i class="iconfont icon-my text-primary"></i>
</view>
<view class="m-4">
<text mr-2>iconfont:</text>
<i class="iconfont icon-package text-primary"></i>
<i class="iconfont icon-chat text-primary"></i>
<i class="iconfont icon-my text-primary"></i>
</view>
</template>
<script lang="ts" setup>
......
......@@ -8,36 +8,52 @@
</route>
<template>
<view class="mt-6">
<button @click="getFoo" class="my-4" type="primary">测试 GET 请求</button>
<view class="text-xl">请求数据如下</view>
<view class="text-green h-10">{{ JSON.stringify(data) }}</view>
<view class="text-xl">完整数据</view>
<view class="text-green h-20">{{ JSON.stringify(originalData) }}</view>
<button class="my-8" type="warn" @click="reset">一键清空数据</button>
</view>
<view class="mt-6">
<button class="my-4"
type="primary"
@click="getFoo">
测试 GET 请求
</button>
<view class="text-xl">
请求数据如下
</view>
<view class="text-green h-10">
{{ JSON.stringify(data) }}
</view>
<view class="text-xl">
完整数据
</view>
<view class="text-green h-20">
{{ JSON.stringify(originalData) }}
</view>
<button class="my-8"
type="warn"
@click="reset">
一键清空数据
</button>
</view>
</template>
<script lang="ts" setup>
import { getMockAPI } from '@/service/mock'
import { getMockAPI } from "@/service/mock";
onLoad(() => {
getFoo()
})
getFoo();
});
const originalData = ref<IResData<any>>()
const data = ref()
const originalData = ref<IResData<any>>();
const data = ref();
const getFoo = async () => {
const res = await getMockAPI('菲鸽')
data.value = res.data
originalData.value = res
}
const res = await getMockAPI("菲鸽");
data.value = res.data;
originalData.value = res;
};
const reset = () => {
data.value = undefined
originalData.value = undefined
}
data.value = undefined;
originalData.value = undefined;
};
</script>
<style lang="scss" scoped>
......
......@@ -6,36 +6,36 @@
</route>
<template>
<view class="text-green">微信分享页</view>
<view class="text-green-500">请在微信小程序中体验,或者开发者工具</view>
<view>1) 默认是不激活”发送给朋友“和”分享到朋友圈“的,如下图</view>
<image
src="https://oss.laf.run/ukw0y1-site/hello-unibest-images/wx-share-before.png"
mode="widthFix"
/>
<view>2) 增加了onShareAppMessage和onShareTimeline后,就可以微信分享了,如下图</view>
<image
src="https://oss.laf.run/ukw0y1-site/hello-unibest-images/wx-share-after.png"
mode="widthFix"
/>
<view class="text-green">
微信分享页
</view>
<view class="text-green-500">
请在微信小程序中体验,或者开发者工具
</view>
<view>1) 默认是不激活”发送给朋友“和”分享到朋友圈“的,如下图</view>
<image mode="widthFix"
src="https://oss.laf.run/ukw0y1-site/hello-unibest-images/wx-share-before.png" />
<view>2) 增加了onShareAppMessage和onShareTimeline后,就可以微信分享了,如下图</view>
<image mode="widthFix"
src="https://oss.laf.run/ukw0y1-site/hello-unibest-images/wx-share-after.png" />
</template>
<script lang="ts" setup>
import { onShareAppMessage, onShareTimeline } from '@dcloudio/uni-app'
import { onShareAppMessage, onShareTimeline } from "@dcloudio/uni-app";
/** 激活“分享给好友” */
onShareAppMessage((options: Page.ShareAppMessageOption): Page.CustomShareContent => {
console.log('options:', options)
return {
title: '自定义分享标题',
desc: 'unibest 演示示例',
path: '/pages/index/index?id=xxx',
}
})
console.log("options:", options);
return {
title: "自定义分享标题",
desc: "unibest 演示示例",
path: "/pages/index/index?id=xxx",
};
});
/** 激活“分享到朋友圈”, 注意:需要先激活“分享给好友” */
onShareTimeline((): Page.ShareTimelineContent => {
return {
title: '自定义分享标题',
query: 'a=1&b=2',
}
})
return {
title: "自定义分享标题",
query: "a=1&b=2",
};
});
</script>
......@@ -5,24 +5,23 @@
</route>
<template>
<uni-nav-bar
title="自定义导航栏"
left-icon="left"
@clickLeft="goBack"
class="fixed w-full"
:border="false"
:status-bar="true"
></uni-nav-bar>
<view class="h-11" :style="{ paddingTop: safeAreaInsets?.top + 'px' }"></view>
<view>
<fly-content :line="20" />
</view>
<uni-nav-bar :border="false"
class="fixed w-full"
left-icon="left"
:status-bar="true"
title="自定义导航栏"
@click-left="goBack">
</uni-nav-bar>
<view class="h-11" :style="{ paddingTop: `${safeAreaInsets?.top }px` }"></view>
<view>
<fly-content :line="20" />
</view>
</template>
<script lang="ts" setup>
const goBack = () => {
uni.navigateBack()
}
uni.navigateBack();
};
// 获取屏幕边界到安全区域距离
const { safeAreaInsets } = uni.getSystemInfoSync()
const { safeAreaInsets } = uni.getSystemInfoSync();
</script>
......@@ -5,16 +5,22 @@
</route>
<template>
<fly-navbar />
<view class="bg-green-300 min-h-20" :style="{ paddingTop: safeAreaInsets?.top + 'px' }">
<view class="p-4">自定义导航栏,设置"navigationStyle":"custom"</view>
<view class="p-4">通常页面顶部有一个图片或背景色</view>
<view class="p-4">本实例没有导航栏,但是需要返回</view>
</view>
<fly-content :line="20" />
<fly-navbar />
<view class="bg-green-300 min-h-20" :style="{ paddingTop: `${safeAreaInsets?.top }px` }">
<view class="p-4">
自定义导航栏,设置"navigationStyle":"custom"
</view>
<view class="p-4">
通常页面顶部有一个图片或背景色
</view>
<view class="p-4">
本实例没有导航栏,但是需要返回
</view>
</view>
<fly-content :line="20" />
</template>
<script lang="ts" setup>
// 获取屏幕边界到安全区域距离
const { safeAreaInsets } = uni.getSystemInfoSync()
const { safeAreaInsets } = uni.getSystemInfoSync();
</script>
......@@ -6,35 +6,53 @@
</route>
<template>
<view class="flex justify-center items-center text-blue-500 mt-4 mb-4">
<view class="w-20">Count: {{ countStore.count }}</view>
<button class="ml-2 mr-2" @click="countStore.decrement">-1</button>
<button class="ml-2 mr-2" @click="countStore.increment">+1</button>
<button class="ml-2 mr-2" @click="countStore.reset">重置</button>
</view>
<view class="m-8 text-4 leading-8">
<view class="text-center">{{ userStore.userInfo }}</view>
<view class="text-center">请观察小程序的store,可以看到是可以正常设置的</view>
<button @click="setUserInfo">设置UserInfo</button>
<button @click="clearUserInfo" class="mt-4">清除UserInfo</button>
<button @click="resetUserStore" class="mt-4">reset UserStore</button>
</view>
<view class="flex justify-center items-center text-blue-500 mt-4 mb-4">
<view class="w-20">
Count: {{ countStore.count }}
</view>
<button class="ml-2 mr-2" @click="countStore.decrement">
-1
</button>
<button class="ml-2 mr-2" @click="countStore.increment">
+1
</button>
<button class="ml-2 mr-2" @click="countStore.reset">
重置
</button>
</view>
<view class="m-8 text-4 leading-8">
<view class="text-center">
{{ userStore.userInfo }}
</view>
<view class="text-center">
请观察小程序的store,可以看到是可以正常设置的
</view>
<button @click="setUserInfo">
设置UserInfo
</button>
<button class="mt-4" @click="clearUserInfo">
清除UserInfo
</button>
<button class="mt-4" @click="resetUserStore">
reset UserStore
</button>
</view>
</template>
<script lang="ts" setup>
import { useCountStore, useUserStore } from '@/store'
import { useCountStore, useUserStore } from "@/store";
const countStore = useCountStore()
const countStore = useCountStore();
const userStore = useUserStore()
const userStore = useUserStore();
const setUserInfo = () => {
userStore.setUserInfo({ nickname: '菲鸽', avatar: '', token: 'abcdef' })
}
userStore.setUserInfo({ nickname: "菲鸽", avatar: "", token: "abcdef" });
};
const clearUserInfo = () => {
userStore.clearUserInfo()
}
userStore.clearUserInfo();
};
const resetUserStore = () => {
userStore.reset()
}
userStore.reset();
};
</script>
......@@ -8,59 +8,89 @@
</route>
<template>
<view class="mt-6">
<!-- http://localhost:9100/#/pages/index/request -->
<button @click="getFoo" class="my-4">测试 GET 请求</button>
<view class="text-xl">请求数据如下</view>
<view class="text-green h-10">{{ JSON.stringify(data) }}</view>
<view class="text-xl">完整数据</view>
<view class="text-green h-20">{{ JSON.stringify(originalData) }}</view>
<button @click="postFoo" class="my-4">测试 POST 请求</button>
<view class="text-xl">请求数据如下</view>
<view class="text-green h-10">{{ JSON.stringify(data2) }}</view>
<view class="mt-6">
<!-- http://localhost:9100/#/pages/index/request -->
<button class="my-4" @click="getFoo">
测试 GET 请求
</button>
<view class="text-xl">
请求数据如下
</view>
<view class="text-green h-10">
{{ JSON.stringify(data) }}
</view>
<view class="text-xl">
完整数据
</view>
<view class="text-green h-20">
{{ JSON.stringify(originalData) }}
</view>
<button class="my-4" @click="postFoo">
测试 POST 请求
</button>
<view class="text-xl">
请求数据如下
</view>
<view class="text-green h-10">
{{ JSON.stringify(data2) }}
</view>
<button class="my-8" type="warn" @click="reset">一键清空数据</button>
<button class="my-8"
type="warn"
@click="reset">
一键清空数据
</button>
<view class="my-2">使用的是 laf 云后台</view>
<view class="text-green-400">我的推荐码,可以获得佣金</view>
<!-- #ifdef H5 -->
<view class="my-2 text-center">
<a class="my-2 text-center" :href="recommendUrl" target="_blank">{{ recommendUrl }}</a>
</view>
<!-- #endif -->
<view class="my-2">
使用的是 laf 云后台
</view>
<view class="text-green-400">
我的推荐码,可以获得佣金
</view>
<!-- #ifdef H5 -->
<view class="my-2 text-center">
<a class="my-2 text-center"
:href="recommendUrl"
target="_blank">
{{ recommendUrl }}
</a>
</view>
<!-- #endif -->
<!-- #ifndef H5 -->
<view class="my-2 text-left text-sm">{{ recommendUrl }}</view>
<!-- #ifndef H5 -->
<view class="my-2 text-left text-sm">
{{ recommendUrl }}
</view>
<!-- #endif -->
</view>
</view>
</template>
<script lang="ts" setup>
import { getFooAPI, postFooAPI, IFooItem } from '@/service/foo'
import { getFooAPI, IFooItem, postFooAPI } from "@/service/foo";
const recommendUrl = ref('http://laf.run/signup?code=ohaOgIX')
const recommendUrl = ref("http://laf.run/signup?code=ohaOgIX");
onLoad(() => {
getFoo()
postFoo()
})
const originalData = ref<IResData<IFooItem>>()
const data = ref<IFooItem>()
getFoo();
postFoo();
});
const originalData = ref<IResData<IFooItem>>();
const data = ref<IFooItem>();
const getFoo = async () => {
const res = await getFooAPI('菲鸽')
data.value = res.data
originalData.value = res
}
const res = await getFooAPI("菲鸽");
data.value = res.data;
originalData.value = res;
};
const data2 = ref<IFooItem>()
const data2 = ref<IFooItem>();
const postFoo = async () => {
const res = await postFooAPI('菲鸽2')
data2.value = res.data
}
const res = await postFooAPI("菲鸽2");
data2.value = res.data;
};
const reset = () => {
data.value = undefined
data2.value = undefined
originalData.value = undefined
}
data.value = undefined;
data2.value = undefined;
originalData.value = undefined;
};
</script>
......@@ -8,19 +8,25 @@
</route>
<template>
<view class="mt-6">
<view class="text-2xl my-2 text-red-600">1-普通请求</view>
<RequestComp />
<view class="mt-6">
<view class="text-2xl my-2 text-red-600">
1-普通请求
</view>
<RequestComp />
<view class="text-2xl my-2 text-red-600">2-上传图片</view>
<UploadComp />
<view class="text-2xl my-2 text-red-600">3-并发请求</view>
<Request2Comp />
</view>
<view class="text-2xl my-2 text-red-600">
2-上传图片
</view>
<UploadComp />
<view class="text-2xl my-2 text-red-600">
3-并发请求
</view>
<Request2Comp />
</view>
</template>
<script lang="ts" setup>
import RequestComp from './components/request.vue'
import Request2Comp from './components/request2.vue'
import UploadComp from './components/upload.vue'
import Request2Comp from "./components/request2.vue";
import RequestComp from "./components/request.vue";
import UploadComp from "./components/upload.vue";
</script>
......@@ -6,20 +6,24 @@
</route>
<template>
<view class="mt-8 text-center">
<view class="leading-10">
用户是否已登录:
<text>{{ !!userStore?.userInfo?.token }}</text>
<view class="mt-8 text-center">
<view class="leading-10">
用户是否已登录:
<text>{{ !!userStore?.userInfo?.token }}</text>
</view>
<view class="text-gray">
未登录不能来本页面
</view>
<view class="text-gray">
已登录才能来本页面
</view>
</view>
<view class="text-gray">未登录不能来本页面</view>
<view class="text-gray">已登录才能来本页面</view>
</view>
</template>
<script lang="ts" setup>
import { useUserStore } from '@/store'
import { useUserStore } from "@/store";
const userStore = useUserStore()
const userStore = useUserStore();
</script>
<style lang="scss" scoped>
......
......@@ -8,33 +8,41 @@
</route>
<template>
<view class="p-4">
<view class="text-center m-4">svg 多种使用方法</view>
<image src="/static/svg/task.svg" mode="scaleToFill" class="h-20 w-20" />
<image :src="iconUrl" mode="scaleToFill" class="h-20 w-20" />
<image :src="iconUrl2" mode="scaleToFill" class="h-20 w-20" />
<!-- {{ iconRaw }} -->
<view class="text-center m-4 text-blue-500">目前发现,小程序和APP只支持 image 方式</view>
<view class="text-center m-4 text-blue-500">下面的几种方式,都不支持</view>
<!-- #ifdef H5 -->
<TaskComponent class="h-20 w-20" />
<SvgIcon name="task" class="h-20 w-20"></SvgIcon>
<SvgIcon name="dir-task2" class="h-20 w-20"></SvgIcon>
<view class="p-4">
<view class="text-center m-4">
svg 多种使用方法
</view>
<image class="h-20 w-20"
mode="scaleToFill"
src="/static/svg/task.svg" />
<image class="h-20 w-20"
mode="scaleToFill"
:src="iconUrl" />
<image class="h-20 w-20"
mode="scaleToFill"
:src="iconUrl2" />
<!-- {{ iconRaw }} -->
<view class="text-center m-4 text-blue-500">
目前发现,小程序和APP只支持 image 方式
</view>
<view class="text-center m-4 text-blue-500">
下面的几种方式,都不支持
</view>
<!-- #ifdef H5 -->
<TaskComponent class="h-20 w-20" />
<SvgIcon class="h-20 w-20" name="task"></SvgIcon>
<SvgIcon class="h-20 w-20" name="dir-task2"></SvgIcon>
<!-- #endif -->
</view>
</view>
</template>
<script lang="ts" setup>
// eslint-disable-next-line import/no-duplicates
import iconUrl from './task.svg'
// eslint-disable-next-line import/no-duplicates
import iconUrl2 from './task.svg?url'
// eslint-disable-next-line import/no-duplicates
import iconRaw from './task.svg?raw'
import iconUrl from "./task.svg";
import TaskComponent from "./task.svg?component";
// #ifdef H5
// 小程序不支持 component 方式引入,运行会报错,APP不报错,但是不生效
// eslint-disable-next-line import/no-duplicates
import TaskComponent from './task.svg?component'
import iconUrl2 from "./task.svg?url";
// #endif
</script>
......
......@@ -17,80 +17,82 @@
</route>
<template>
<!-- #ifdef MP-WEIXIN -->
<view class="fly-navbar" :style="{ paddingTop: safeAreaInsets?.top + 'px' }">
<!-- 1/3,多于1个页面,用返回图标 -->
<navigator v-if="pages.length > 1" open-type="navigateBack" class="left-icon">
<view class="i-carbon-chevron-left text-current"></view>
</navigator>
<!-- 2/3,只有1个页面,如果不是tabbar,需要首页图标 -->
<!-- 这种情况一般出现在用户直接打开分享出去的详情页面,或者使用redirectTo等API -->
<navigator
v-else-if="!isTabbar"
open-type="switchTab"
url="/pages/index/index"
class="left-icon"
>
<view class="i-carbon-home text-current"></view>
</navigator>
<!-- 3/3,如果当前页就是tabbar页,不用去首页,也就是什么图标都不需要 -->
<view class="title">{{ '我是标题' }}</view>
</view>
<!-- #endif -->
<scroll-view
enable-back-to-top
scroll-y
class="scroll-view-bg flex-1 h-full"
id="scroller"
refresher-enabled
@scrolltolower="onScrollToLower"
@refresherrefresh="onRefresherRefresh"
:refresher-triggered="isTriggered"
>
<view class="top-section" :style="{ paddingTop: safeAreaInsets?.top + 'px' }">
<view class="pt-1">顶部区域</view>
<view>可以是标题,也可以是个人中心头像等</view>
<view>建议本区域高度不低于200rpx</view>
</view>
<view class="p-2 leading-6 bg-white">
注意,上面的导航栏渐变效果仅微信端支持,且上面的导航栏无法抽为组件引入使用,否则滚动效果没有了。如果不只是微信小程序使用,可以
onPageScroll 实现全端效果一样,另外如果是app端,还可以配置 titleNView。参考
https://uniapp.dcloud.net.cn/tutorial/page.html#onpagescroll 。
</view>
<view class="bg-white">
<fly-content :line="30" />
<!-- #ifdef MP-WEIXIN -->
<view class="fly-navbar" :style="{ paddingTop: `${safeAreaInsets?.top }px` }">
<!-- 1/3,多于1个页面,用返回图标 -->
<navigator v-if="pages.length > 1"
class="left-icon"
open-type="navigateBack">
<view class="i-carbon-chevron-left text-current"></view>
</navigator>
<!-- 2/3,只有1个页面,如果不是tabbar,需要首页图标 -->
<!-- 这种情况一般出现在用户直接打开分享出去的详情页面,或者使用redirectTo等API -->
<navigator v-else-if="!isTabbar"
class="left-icon"
open-type="switchTab"
url="/pages/index/index">
<view class="i-carbon-home text-current"></view>
</navigator>
<!-- 3/3,如果当前页就是tabbar页,不用去首页,也就是什么图标都不需要 -->
<view class="title">
{{ '我是标题' }}
</view>
</view>
</scroll-view>
<!-- #endif -->
<scroll-view id="scroller"
class="scroll-view-bg flex-1 h-full"
enable-back-to-top
refresher-enabled
:refresher-triggered="isTriggered"
scroll-y
@refresherrefresh="onRefresherRefresh"
@scrolltolower="onScrollToLower">
<view class="top-section" :style="{ paddingTop: `${safeAreaInsets?.top }px` }">
<view class="pt-1">
顶部区域
</view>
<view>可以是标题,也可以是个人中心头像等</view>
<view>建议本区域高度不低于200rpx</view>
</view>
<view class="p-2 leading-6 bg-white">
注意,上面的导航栏渐变效果仅微信端支持,且上面的导航栏无法抽为组件引入使用,否则滚动效果没有了。如果不只是微信小程序使用,可以
onPageScroll 实现全端效果一样,另外如果是app端,还可以配置 titleNView。参考
https://uniapp.dcloud.net.cn/tutorial/page.html#onpagescroll 。
</view>
<view class="bg-white">
<fly-content :line="30" />
</view>
</scroll-view>
</template>
<script lang="ts" setup>
import { onPullDownRefresh } from '@dcloudio/uni-app'
import useNavbarWeixin from '@/hooks/useNavbarWeixin'
import useNavbarWeixin from "@/hooks/useNavbarWeixin";
import { onPullDownRefresh } from "@dcloudio/uni-app";
const { pages, isTabbar, onScrollToLower, safeAreaInsets } = useNavbarWeixin()
const { pages, isTabbar, onScrollToLower, safeAreaInsets } = useNavbarWeixin();
// 发现原生下拉刷新效果并不好,在微信里面只有顶部导航栏下拉才生效,页面区域下拉不生效,体验不好,结合自定义下拉刷新效果很好
onPullDownRefresh(() => {
setTimeout(function fn() {
console.log('refresh - onPullDownRefresh')
// 关闭动画
uni.stopPullDownRefresh()
}, 1000)
})
setTimeout(() => {
console.log("refresh - onPullDownRefresh");
// 关闭动画
uni.stopPullDownRefresh();
}, 1000);
});
// 当前下拉刷新状态
const isTriggered = ref(false)
const isTriggered = ref(false);
// 自定义下拉刷新被触发
const onRefresherRefresh = async () => {
// 开始动画
isTriggered.value = true
setTimeout(function fn() {
console.log('refresh - onRefresherRefresh')
// 关闭动画
isTriggered.value = false
}, 1000)
}
// 开始动画
isTriggered.value = true;
setTimeout(() => {
console.log("refresh - onRefresherRefresh");
// 关闭动画
isTriggered.value = false;
}, 1000);
};
</script>
<style lang="scss">
......
......@@ -6,24 +6,47 @@
</route>
<template>
<view class="m-4">
<uni-icons type="contact" size="30"></uni-icons>
<uni-icons type="contact" size="30" color="red"></uni-icons>
<uni-icons type="contact" size="30" class="text-green"></uni-icons>
<uni-icons type="contact" size="30" color="red" class="text-green"></uni-icons>
<uni-icons type="contact" size="30" color="red" class="text-green"></uni-icons>
<uni-icons type="contact" color="red" class="text-green w-4"></uni-icons>
<uni-icons type="contact" color="red" class="text-green w-8"></uni-icons>
<uni-icons :type="iconName" :color="colorName" class="text-green w-8"></uni-icons>
</view>
<view class="m-4">
<uni-icons size="30" type="contact"></uni-icons>
<uni-icons color="red"
size="30"
type="contact">
</uni-icons>
<uni-icons class="text-green"
size="30"
type="contact">
</uni-icons>
<uni-icons class="text-green"
color="red"
size="30"
type="contact">
</uni-icons>
<uni-icons class="text-green"
color="red"
size="30"
type="contact">
</uni-icons>
<uni-icons class="text-green w-4"
color="red"
type="contact">
</uni-icons>
<uni-icons class="text-green w-8"
color="red"
type="contact">
</uni-icons>
<uni-icons class="text-green w-8"
:color="colorName"
:type="iconName">
</uni-icons>
</view>
</template>
<script lang="ts" setup>
const iconName = ref<string>('contact')
const colorName = ref<string>('red')
const iconName = ref<string>("contact");
const colorName = ref<string>("red");
onLoad(() => {
setTimeout(() => {
iconName.value = 'chat'
colorName.value = 'green'
}, 1000)
})
setTimeout(() => {
iconName.value = "chat";
colorName.value = "green";
}, 1000);
});
</script>
......@@ -6,22 +6,26 @@
</route>
<template>
<uni-card>
<text>这是一个基础卡片示例,内容较少,此示例展示了一个没有任何属性不带阴影的卡片。</text>
</uni-card>
<uni-badge text="99"></uni-badge>
<uni-rate :value="3" />
<view>
<button @click="open">打开弹窗</button>
<uni-popup ref="popup" type="bottom" border-radius="10px 10px 0 0">
底部弹出 Popup 自定义圆角
</uni-popup>
</view>
<uni-card>
<text>这是一个基础卡片示例,内容较少,此示例展示了一个没有任何属性不带阴影的卡片。</text>
</uni-card>
<uni-badge text="99"></uni-badge>
<uni-rate :value="3" />
<view>
<button @click="open">
打开弹窗
</button>
<uni-popup ref="popup"
border-radius="10px 10px 0 0"
type="bottom">
底部弹出 Popup 自定义圆角
</uni-popup>
</view>
</template>
<script lang="ts" setup>
const popup = ref()
const popup = ref();
const open = () => {
popup.value?.open()
}
popup.value?.open();
};
</script>
export const icon = 'i-carbon-3d-cursor'
export const icon = "i-carbon-3d-cursor";
export const nest = {
nest: {
icon: 'i-carbon-3d-ica',
},
}
nest: {
icon: "i-carbon-3d-ica",
},
};
......@@ -6,58 +6,64 @@
</route>
<template>
<view class="m-4">
<view class="mb-2">
这里只装了carbon的图表库,网址:
<a href="https://icones.js.org/collection/carbon" target="_blank">
https://icones.js.org/collection/carbon
</a>
(非H5环境,请使用浏览器打开)
</view>
<view class="i-carbon-car" />
<view class="i-carbon-car text-red" />
<button class="i-carbon-sun dark:i-carbon-moon" />
<view class="h-10"></view>
<view class="i-carbon-user-avatar text-red" />
<view :class="`i-carbon-user-avatar`" />
<view class="ml-2"></view>
<view :class="iconName" />
<view :class="iconName2" />
<view :class="iconName3" />
<view class="my-4 text-red">经过测试,动态图片从别的文件导入无法生效</view>
<wd-tabbar-item title="首页" icon="home"></wd-tabbar-item>
<wd-tabbar-item :value="2" icon="cart" title="分类">
<template #icon>
<view class="m-4">
<view class="mb-2">
这里只装了carbon的图表库,网址:
<a href="https://icones.js.org/collection/carbon" target="_blank">
https://icones.js.org/collection/carbon
</a>
(非H5环境,请使用浏览器打开)
</view>
<view class="i-carbon-car" />
<view class="i-carbon-car text-red" />
<button class="i-carbon-sun dark:i-carbon-moon" />
<view class="h-10"></view>
<view class="i-carbon-user-avatar text-red" />
<view class="i-carbon-user-avatar" />
<view class="ml-2"></view>
<view :class="iconName" />
<view :class="iconName2" />
</template>
</wd-tabbar-item>
<wd-tabbar-item :value="2" icon="cart" title="分类">
<template #icon>
<view :class="iconName3" />
</template>
</wd-tabbar-item>
</view>
<view class="my-4 text-red">
经过测试,动态图片从别的文件导入无法生效
</view>
<wd-tabbar-item icon="home" title="首页"></wd-tabbar-item>
<wd-tabbar-item icon="cart"
title="分类"
:value="2">
<template #icon>
<view :class="iconName2" />
</template>
</wd-tabbar-item>
<wd-tabbar-item icon="cart"
title="分类"
:value="2">
<template #icon>
<view :class="iconName3" />
</template>
</wd-tabbar-item>
</view>
</template>
<script lang="ts" setup>
import { icon, nest } from './unocss-icon'
import { icon2, nest2 } from './unocss-icon.json'
import { icon, icon2, nest, nest2 } from "./unocss-icon";
// 只需要把外面的在这里写一遍就能生效了!注释掉也是生效的,但是必须要有
// 'i-carbon-3d-cursor-alt'
const iconName = ref<string>('i-carbon-car')
const iconName2 = ref<string>('i-carbon-car')
const iconName3 = ref<string>('i-carbon-car')
const iconName = ref<string>("i-carbon-car");
const iconName2 = ref<string>("i-carbon-car");
const iconName3 = ref<string>("i-carbon-car");
onLoad(() => {
setTimeout(() => {
iconName.value = 'i-carbon-4k'
iconName2.value = icon
iconName3.value = icon2
}, 1000)
setTimeout(() => {
console.log(nest.nest.icon, nest2.nest2.icon)
iconName2.value = nest.nest.icon
iconName3.value = nest2.nest2.icon
}, 2000)
})
setTimeout(() => {
iconName.value = "i-carbon-4k";
iconName2.value = icon;
iconName3.value = icon2;
}, 1000);
setTimeout(() => {
console.log(nest.nest.icon, nest2.nest2.icon);
iconName2.value = nest.nest.icon;
iconName3.value = nest2.nest2.icon;
}, 2000);
});
</script>
......@@ -6,10 +6,18 @@
</route>
<template>
<view class="flex flex-col justify-center items-center text-5 h-12 leading-12 mt-20">
<view class="text-green-500">文字颜色 text-light-50</view>
<view class="text-red-500">文字颜色 text-red-500</view>
<view class="bg-green-500 mt-4">背景色 bg-light-50</view>
<view class="bg-red-500 mt-4">背景色 bg-red-500</view>
</view>
<view class="flex flex-col justify-center items-center text-5 h-12 leading-12 mt-20">
<view class="text-green-500">
文字颜色 text-light-50
</view>
<view class="text-red-500">
文字颜色 text-red-500
</view>
<view class="bg-green-500 mt-4">
背景色 bg-light-50
</view>
<view class="bg-red-500 mt-4">
背景色 bg-red-500
</view>
</view>
</template>
......@@ -8,68 +8,76 @@
</route>
<template>
<view class="p-4 text-center">
<wd-button @click="chooseImage">选择图片并上传</wd-button>
<view class="m-2">上传后返回的图片地址:</view>
<view class="m-2">{{ imgStr }}</view>
<view class="h-80 w-full">
<image v-if="imgStr" :src="imgStr" mode="scaleToFill" />
<view class="p-4 text-center">
<wd-button @click="chooseImage">
选择图片并上传
</wd-button>
<view class="m-2">
上传后返回的图片地址:
</view>
<view class="m-2">
{{ imgStr }}
</view>
<view class="h-80 w-full">
<image v-if="imgStr"
mode="scaleToFill"
:src="imgStr" />
</view>
</view>
</view>
</template>
<script lang="ts" setup>
const imgStr = ref('')
const imgStr = ref("");
const chooseImage = () => {
// #ifdef MP-WEIXIN
// 微信小程序从基础库 2.21.0 开始, wx.chooseImage 停止维护,请使用 uni.chooseMedia 代替。
// 微信小程序在2023年10月17日之后,使用本API需要配置隐私协议
uni.chooseMedia({
count: 1,
mediaType: ['image'],
success: (res) => {
console.log(res)
const tempFilePath = res.tempFiles[0].tempFilePath
uni.uploadFile({
url: 'https://ukw0y1.laf.run/upload',
filePath: tempFilePath,
name: 'file',
formData: {
user: '菲鸽',
// #ifdef MP-WEIXIN
// 微信小程序从基础库 2.21.0 开始, wx.chooseImage 停止维护,请使用 uni.chooseMedia 代替。
// 微信小程序在2023年10月17日之后,使用本API需要配置隐私协议
uni.chooseMedia({
count: 1,
mediaType: [ "image" ],
success: (res) => {
console.log(res);
const tempFilePath = res.tempFiles[0].tempFilePath;
uni.uploadFile({
url: "https://ukw0y1.laf.run/upload",
filePath: tempFilePath,
name: "file",
formData: {
user: "菲鸽",
},
success: (uploadFileRes) => {
console.log(typeof uploadFileRes.data);
const data = JSON.parse(uploadFileRes.data);
imgStr.value = data.data.url;
},
});
},
success: (uploadFileRes) => {
console.log(typeof uploadFileRes.data)
const data = JSON.parse(uploadFileRes.data)
imgStr.value = data.data.url
});
// #endif
// #ifndef MP-WEIXIN
uni.chooseImage({
count: 1,
success: (res) => {
console.log(res);
const tempFilePath = res.tempFilePaths[0];
uni.uploadFile({
url: "https://ukw0y1.laf.run/upload",
filePath: tempFilePath,
name: "file",
formData: {
user: "菲鸽",
},
success: (uploadFileRes) => {
console.log(typeof uploadFileRes.data);
const data = JSON.parse(uploadFileRes.data);
imgStr.value = data.data.url;
},
});
},
})
},
})
// #endif
// #ifndef MP-WEIXIN
uni.chooseImage({
count: 1,
success: (res) => {
console.log(res)
const tempFilePath = res.tempFilePaths[0]
uni.uploadFile({
url: 'https://ukw0y1.laf.run/upload',
filePath: tempFilePath,
name: 'file',
formData: {
user: '菲鸽',
},
success: (uploadFileRes) => {
console.log(typeof uploadFileRes.data)
const data = JSON.parse(uploadFileRes.data)
imgStr.value = data.data.url
},
})
},
})
// #endif
}
});
// #endif
};
</script>
<style lang="scss" scoped>
......
......@@ -8,21 +8,31 @@
</route>
<template>
<view class="p-4 text-center">
<wd-button @click="run">选择图片并上传</wd-button>
<view v-if="loading" class="text-blue h-10">上传...</view>
<template v-else>
<view class="m-2">上传后返回的图片地址:</view>
<view class="m-2">{{ data }}</view>
<view class="h-80 w-full">
<image v-if="data" :src="data" mode="scaleToFill" />
</view>
</template>
</view>
<view class="p-4 text-center">
<wd-button @click="run">
选择图片并上传
</wd-button>
<view v-if="loading" class="text-blue h-10">
上传...
</view>
<template v-else>
<view class="m-2">
上传后返回的图片地址:
</view>
<view class="m-2">
{{ data }}
</view>
<view class="h-80 w-full">
<image v-if="data"
mode="scaleToFill"
:src="data" />
</view>
</template>
</view>
</template>
<script lang="ts" setup>
const { loading, data, run } = useUpload<string>({ user: '菲鸽' })
const { loading, data, run } = useUpload<string>({ user: "菲鸽" });
</script>
<style lang="scss" scoped>
......
......@@ -5,45 +5,66 @@
</route>
<template>
<view class="mt-10">
<uv-button type="primary" @click="remakeQc">重新生成二维码</uv-button>
<view class="center mt-8">
<uv-qrcode
ref="qrcode"
size="200px"
value="https://h5.uvui.cn"
:options="options"
></uv-qrcode>
</view>
<view class="m-4 flex">
<uv-icon name="home"></uv-icon>
<uv-icon name="home" color="red"></uv-icon>
<uv-icon name="home" class="text-green"></uv-icon>
<uv-icon name="home" color="red" class="text-green"></uv-icon>
<uv-icon name="home" color="red" class="text-green" size="20"></uv-icon>
<uv-icon name="home" color="red" class="text-green w-10 h-10" size="20"></uv-icon>
<uv-icon name="home" color="red" class="text-green w-20 h-20"></uv-icon>
<uv-icon name="home" color="red" class="text-green w-10" size="20"></uv-icon>
<view class="mt-10">
<uv-button type="primary" @click="remakeQc">
重新生成二维码
</uv-button>
<view class="center mt-8">
<uv-qrcode ref="qrcode"
:options="options"
size="200px"
value="https://h5.uvui.cn">
</uv-qrcode>
</view>
<view class="m-4 flex">
<uv-icon name="home"></uv-icon>
<uv-icon color="red" name="home"></uv-icon>
<uv-icon class="text-green" name="home"></uv-icon>
<uv-icon class="text-green"
color="red"
name="home">
</uv-icon>
<uv-icon class="text-green"
color="red"
name="home"
size="20">
</uv-icon>
<uv-icon class="text-green w-10 h-10"
color="red"
name="home"
size="20">
</uv-icon>
<uv-icon class="text-green w-20 h-20"
color="red"
name="home">
</uv-icon>
<uv-icon class="text-green w-10"
color="red"
name="home"
size="20">
</uv-icon>
<uv-icon :name="iconName"></uv-icon>
</view>
<view class="m-4">
<view>富文本也是支持的:</view>
<uv-parse :content="content"></uv-parse>
</view>
<uv-icon :name="iconName"></uv-icon>
</view>
<view class="m-4">
<view>富文本也是支持的:</view>
<uv-parse :content="content"></uv-parse>
</view>
<uv-popup ref="popup" @change="change">
<view>
<text>
丙辰中秋,欢饮达旦,大醉,作此篇,兼怀子由。 明月几时有?把酒问青天。
不知天上宫阙,今夕是何年。我欲乘风归去,又恐琼楼玉宇,高处不胜寒。起舞弄清影,何似在人间。
转朱阁,低绮户,照无眠。不应有恨,何事长向别时圆?人有悲欢离合,月有阴晴圆缺,此事古难全。
但愿人长久,千里共婵娟。
</text>
</view>
</uv-popup>
<button @click="open">打开</button>
</view>
<uv-popup ref="popup" @change="change">
<view>
<text>
丙辰中秋,欢饮达旦,大醉,作此篇,兼怀子由。 明月几时有?把酒问青天。
不知天上宫阙,今夕是何年。我欲乘风归去,又恐琼楼玉宇,高处不胜寒。起舞弄清影,何似在人间。
转朱阁,低绮户,照无眠。不应有恨,何事长向别时圆?人有悲欢离合,月有阴晴圆缺,此事古难全。
但愿人长久,千里共婵娟。
</text>
</view>
</uv-popup>
<button @click="open">
打开
</button>
</view>
</template>
<script lang="ts" setup>
......@@ -51,46 +72,46 @@ const content = `<div>
<p style="color:red;" >露从今夜白,月是故乡明</p>
<img src="https://cdn.uviewui.com/uview/swiper/2.jpg" />
</div>
`
`;
console.log(uni.$uv.os())
console.log(uni.$uv.sys())
console.log(uni.$uv.trim(' abc ')) // 去除两端空格
console.log(uni.$uv.random(1, 3)) // 获取随机数
const qrcode = ref(null)
console.log(uni.$uv.os());
console.log(uni.$uv.sys());
console.log(uni.$uv.trim(" abc ")); // 去除两端空格
console.log(uni.$uv.random(1, 3)); // 获取随机数
const qrcode = ref(null);
const options = reactive({
size: 300,
useDynamicSize: false,
margin: 10,
backgroundColor: '#fff',
// 指定二维码前景,一般可在中间放logo
foregroundImageSrc: '/static/logo.svg',
})
size: 300,
useDynamicSize: false,
margin: 10,
backgroundColor: "#fff",
// 指定二维码前景,一般可在中间放logo
foregroundImageSrc: "/static/logo.svg",
});
const remakeQc = () => {
qrcode.value.remake({
success: () => {
console.log('生成成功')
},
fail: (err) => {
console.log(err)
},
})
}
qrcode.value.remake({
success: () => {
console.log("生成成功");
},
fail: (err) => {
console.log(err);
},
});
};
const iconName = ref<string>('level')
const iconName = ref<string>("level");
onLoad(() => {
setTimeout(() => {
iconName.value = 'chat'
}, 1000)
})
setTimeout(() => {
iconName.value = "chat";
}, 1000);
});
const popup = ref()
const popup = ref();
const open = () => {
popup.value?.open()
}
popup.value?.open();
};
const change = (e) => {
console.log('弹窗状态改变:', e)
}
console.log("弹窗状态改变:", e);
};
</script>
<style lang="scss" scoped>
......
......@@ -6,17 +6,19 @@
</route>
<template>
<view class="text-5 h-8 leading-8">
<view class="text-red-500">在非正式版小程序里面已经集成了VConsole</view>
<view class="text-blue-500 mb-2">开启方式如下面</view>
<image
src="https://oss.laf.run/ukw0y1-site/hello-unibest-images/vconsole-1.png"
mode="widthFix"
/>
<view class="text-blue-500 m-2">然后页面上会出现一个 `vConsole` 的调试按钮,如下图</view>
<image
src="https://oss.laf.run/ukw0y1-site/hello-unibest-images/vconsole-2.png"
mode="widthFix"
/>
</view>
<view class="text-5 h-8 leading-8">
<view class="text-red-500">
在非正式版小程序里面已经集成了VConsole
</view>
<view class="text-blue-500 mb-2">
开启方式如下面
</view>
<image mode="widthFix"
src="https://oss.laf.run/ukw0y1-site/hello-unibest-images/vconsole-1.png" />
<view class="text-blue-500 m-2">
然后页面上会出现一个 `vConsole` 的调试按钮,如下图
</view>
<image mode="widthFix"
src="https://oss.laf.run/ukw0y1-site/hello-unibest-images/vconsole-2.png" />
</view>
</template>
......@@ -8,83 +8,104 @@
</route>
<template>
<view class="center pt-4 flex-col">
<wd-button>主要按钮</wd-button>
<wd-button type="success">成功按钮</wd-button>
<wd-button type="info">信息按钮</wd-button>
<wd-button type="warning">警告按钮</wd-button>
<wd-button type="error">危险按钮</wd-button>
<view class="h-10"></view>
<wd-button @click="handleClick">展示幕帘</wd-button>
<wd-curtain
:value="value"
:width="300"
src="https://via.placeholder.com/400x200.png/3c9cff/fff"
@close="handleClose"
></wd-curtain>
<view class="mt-4">
可以通过 unocss class 类改颜色,也可以通过 color 属性修改颜色,同时存在时以 color 为优先
</view>
<view class="mt-4">
可以通过 unocss class 类改颜色,也可以通过 color 属性修改颜色,同时存在时以 color 为优先
</view>
<view class="flex m-4">
<wd-icon name="add-circle"></wd-icon>
<wd-icon name="add-circle" color="red"></wd-icon>
<wd-icon class="text-green" name="add-circle"></wd-icon>
<wd-icon class="text-green" name="add-circle" color="red"></wd-icon>
<wd-icon class="text-green w-10 h-10" name="add-circle" color="red"></wd-icon>
<view class="center pt-4 flex-col">
<wd-button>主要按钮</wd-button>
<wd-button type="success">
成功按钮
</wd-button>
<wd-button type="info">
信息按钮
</wd-button>
<wd-button type="warning">
警告按钮
</wd-button>
<wd-button type="error">
危险按钮
</wd-button>
<view class="h-10"></view>
<wd-button @click="handleClick">
展示幕帘
</wd-button>
<wd-curtain src="https://via.placeholder.com/400x200.png/3c9cff/fff"
:value="value"
:width="300"
@close="handleClose">
</wd-curtain>
<view class="mt-4">
可以通过 unocss class 类改颜色,也可以通过 color 属性修改颜色,同时存在时以 color 为优先
</view>
<view class="mt-4">
可以通过 unocss class 类改颜色,也可以通过 color 属性修改颜色,同时存在时以 color 为优先
</view>
<view class="flex m-4">
<wd-icon name="add-circle"></wd-icon>
<wd-icon color="red" name="add-circle"></wd-icon>
<wd-icon class="text-green" name="add-circle"></wd-icon>
<wd-icon class="text-green"
color="red"
name="add-circle">
</wd-icon>
<wd-icon class="text-green w-10 h-10"
color="red"
name="add-circle">
</wd-icon>
<wd-icon :name="iconName"></wd-icon>
</view>
<wd-icon :name="iconName"></wd-icon>
</view>
<view @click="closeOutside" class="mt-4">
<wd-popover v-model="show" content="popover content" @change="handleChange">
<wd-button>点击展示</wd-button>
</wd-popover>
<view class="mt-4" @click="closeOutside">
<wd-popover v-model="show"
content="popover content"
@change="handleChange">
<wd-button>点击展示</wd-button>
</wd-popover>
</view>
<view class="mt-4">
<wd-button @click="showModal">
点击显示Modal
</wd-button>
<wd-button @click="showToast">
点击显示toast
</wd-button>
</view>
</view>
<view class="mt-4">
<wd-button @click="showModal">点击显示Modal</wd-button>
<wd-button @click="showToast">点击显示toast</wd-button>
</view>
</view>
</template>
<script lang="ts" setup>
import { useQueue, useMessage, useToast } from 'wot-design-uni'
import { useMessage, useQueue, useToast } from "wot-design-uni";
const { closeOutside } = useQueue()
const message = useMessage()
const toast = useToast()
const show = ref<boolean>(false)
const { closeOutside } = useQueue();
const message = useMessage();
const toast = useToast();
const show = ref<boolean>(false);
function handleChange({ show }) {
console.log(show)
console.log(show);
}
const showModal = () => {
// 顺便测试 message 的使用
message.show('显示隐藏切换')
}
// 顺便测试 message 的使用
message.show("显示隐藏切换");
};
const showToast = () => {
// 顺便测试 message 的使用
toast.success('unibest 你值得拥有')
}
const value = ref<boolean>(false)
// 顺便测试 message 的使用
toast.success("unibest 你值得拥有");
};
const value = ref<boolean>(false);
function handleClick() {
value.value = true
value.value = true;
}
function handleClose() {
value.value = false
value.value = false;
}
const iconName = ref<string>('add-circle')
const iconName = ref<string>("add-circle");
onLoad(() => {
setTimeout(() => {
iconName.value = 'check'
}, 1000)
})
setTimeout(() => {
iconName.value = "check";
}, 1000);
});
</script>
<style lang="scss" scoped>
......
......@@ -5,106 +5,106 @@
</route>
<template>
<view class="bg-slate-100 min-h-full box-border pb-1">
<view class="tab-container sticky top-0 bg-white px-4 center h-12 z-1">
<view
class="w-full text-center h-10 leading-10 rounded-md"
:class="{ 'bg-green-300': idx === currIdx }"
v-for="(tab, idx) in tabList"
:key="tab.id"
>
<view class="font-800" @click="currIdx = idx">{{ tab.title }}</view>
</view>
</view>
<view class="bg-slate-100 px-4 pt-3">
<view class="list-container">
<view v-for="item in currContentList" :key="item.path" class="mb-3">
<view
class="flex bg-white items-center justify-between p-3 mb-2"
@click="goDetailPage(item.path)"
>
<text class="flex-1 text-4 text-dark">{{ item.title }}</text>
<text class="i-carbon-chevron-right"></text>
</view>
<view class="bg-slate-100 min-h-full box-border pb-1">
<view class="tab-container sticky top-0 bg-white px-4 center h-12 z-1">
<view v-for="(tab, idx) in tabList"
:key="tab.id"
class="w-full text-center h-10 leading-10 rounded-md"
:class="{ 'bg-green-300': idx === currIdx }">
<view class="font-800" @click="currIdx = idx">
{{ tab.title }}
</view>
</view>
</view>
<view class="bg-slate-100 px-4 pt-3">
<view class="list-container">
<view v-for="item in currContentList"
:key="item.path"
class="mb-3">
<view class="flex bg-white items-center justify-between p-3 mb-2"
@click="goDetailPage(item.path)">
<text class="flex-1 text-4 text-dark">{{ item.title }}</text>
<text class="i-carbon-chevron-right"></text>
</view>
</view>
</view>
</view>
</view>
</view>
</view>
</template>
<script setup lang="ts" name="TestIndex">
import pagesJson from '@/pages.json'
import pagesJson from "@/pages.json";
const handleTitle = (str?: string) => {
if (!str) {
return '标题'
}
if (/%.*%/.test(str)) {
return '多语言'
}
return str
}
if (!str) {
return "标题";
}
if (/%.*%/.test(str)) {
return "多语言";
}
return str;
};
/** 基本功能 */
const baseDemos = pagesJson.pages
.filter((e) => e.path.startsWith('pages/demo/base') && !e.hide)
.map((e) => ({
title: handleTitle(e.style?.navigationBarTitleText),
path: e.path,
}))
.filter((e) => e.path.startsWith("pages/demo/base") && !e.hide)
.map((e) => ({
title: handleTitle(e.style?.navigationBarTitleText),
path: e.path,
}));
/** 页面功能 */
const pageDemos = pagesJson.pages
.filter((e) => e.path.startsWith('pages/demo/page') && !e.hide)
.map((e) => ({
title: handleTitle(e.style?.navigationBarTitleText),
path: e.path,
}))
.filter((e) => e.path.startsWith("pages/demo/page") && !e.hide)
.map((e) => ({
title: handleTitle(e.style?.navigationBarTitleText),
path: e.path,
}));
const routeInterceptionList = [
{
title: '说明页面',
path: 'pages/demo/route-interceptor/index',
},
{
title: '单独登录页面',
path: 'pages/demo/route-interceptor/login-page?name=feige&age=30',
},
{
title: '登录弹窗',
path: 'pages/demo/route-interceptor/login-model?name=feige&age=30',
},
{
title: '静默登录',
path: 'pages/demo/route-interceptor/login-auto?name=feige&age=30',
},
]
{
title: "说明页面",
path: "pages/demo/route-interceptor/index",
},
{
title: "单独登录页面",
path: "pages/demo/route-interceptor/login-page?name=feige&age=30",
},
{
title: "登录弹窗",
path: "pages/demo/route-interceptor/login-model?name=feige&age=30",
},
{
title: "静默登录",
path: "pages/demo/route-interceptor/login-auto?name=feige&age=30",
},
];
const tabList = reactive([
{
id: 1,
title: '基础功能',
list: baseDemos,
},
{
id: 2,
title: '登录拦截',
list: routeInterceptionList,
},
{
id: 3,
title: '页面功能',
list: pageDemos,
},
])
const currIdx = ref(0)
{
id: 1,
title: "基础功能",
list: baseDemos,
},
{
id: 2,
title: "登录拦截",
list: routeInterceptionList,
},
{
id: 3,
title: "页面功能",
list: pageDemos,
},
]);
const currIdx = ref(0);
const currContentList = computed(() => {
return tabList[currIdx.value].list
})
return tabList[currIdx.value].list;
});
const goDetailPage = (path: string) => {
const url = `/${path}`
uni.navigateTo({
url,
})
}
const url = `/${path}`;
uni.navigateTo({
url,
});
};
</script>
<style>
......
......@@ -6,27 +6,34 @@
</route>
<template>
<view class="mt-4 h-10 text-center">动态时钟</view>
<view class="clock-box">
<view class="clock" :style="{ '--ds': ds, '--dm': dm, '--dh': dh }">
<view class="clock-pane">
<text class="clock-num" :style="{ '--i': n }" v-for="n in 12" :key="n">{{ n }}</text>
</view>
<view class="clock-hour"></view>
<view class="clock-min"></view>
<view class="clock-sec"></view>
<view class="mt-4 h-10 text-center">
动态时钟
</view>
<view class="clock-box">
<view class="clock" :style="{ '--ds': ds, '--dm': dm, '--dh': dh }">
<view class="clock-pane">
<text v-for="n in 12"
:key="n"
class="clock-num"
:style="{ '--i': n }">
{{ n }}
</text>
</view>
<view class="clock-hour"></view>
<view class="clock-min"></view>
<view class="clock-sec"></view>
</view>
</view>
</view>
</template>
<script lang="ts" setup>
const d = new Date()
const h = d.getHours()
const m = d.getMinutes()
const s = d.getSeconds()
const ds = ref(s)
const dm = ref(m + s / 60)
const dh = ref(h + m / 60 + s / 3600)
const d = new Date();
const h = d.getHours();
const m = d.getMinutes();
const s = d.getSeconds();
const ds = ref(s);
const dm = ref(m + s / 60);
const dh = ref(h + m / 60 + s / 3600);
</script>
<style lang="scss">
......@@ -37,6 +44,8 @@ const dh = ref(h + m / 60 + s / 3600)
}
.clock {
--step: 60s;
position: relative;
display: flex;
align-items: center;
......@@ -46,7 +55,6 @@ const dh = ref(h + m / 60 + s / 3600)
font-size: 24px;
border-radius: 20px;
box-shadow: 2px 2px 20px #0000001a;
--step: 60s;
}
.clock::before {
......
This diff could not be displayed because it is too large.
This diff could not be displayed because it is too large.
This diff could not be displayed because it is too large.
This diff could not be displayed because it is too large.
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!