提交 514cdb9f 作者: 方治民

合并分支 'main' 到 'main'

Main

查看合并请求 hntq/zjtq-v5!2
import type { Plugin } from 'vite'
// https://github.com/ErKeLost/unplugin-imagemin
import imagemin from 'unplugin-imagemin/vite'
export function configImageminPlugin(): Plugin {
return imagemin({
// https://github.com/ErKeLost/unplugin-imagemin#warning
// mode: 'sharp',
cache: true,
})
}
...@@ -26,9 +26,6 @@ export function createVitePlugins(viteEnv: ViteEnv) { ...@@ -26,9 +26,6 @@ export function createVitePlugins(viteEnv: ViteEnv) {
// unplugin-vue-components // unplugin-vue-components
vitePlugins.push(configImportPlugin()) vitePlugins.push(configImportPlugin())
// unplugin-imagemin
// vitePlugins.push(configImageminPlugin())
// uni-app // uni-app
vitePlugins.push(configUniPlugin()) vitePlugins.push(configUniPlugin())
......
import fs from 'node:fs'
import type { Plugin } from 'vite' import type { Plugin } from 'vite'
import fs from 'fs'
import prettier from 'prettier' import prettier from 'prettier'
// uni-app // uni-app
...@@ -11,12 +11,17 @@ import tags from '@dcloudio/uni-helper-json/dist/tags.json' ...@@ -11,12 +11,17 @@ import tags from '@dcloudio/uni-helper-json/dist/tags.json'
* 根据 @dcloudio/uni-helper-json 生成组件 .d.ts 描述文件,对组件进行高亮展示 * 根据 @dcloudio/uni-helper-json 生成组件 .d.ts 描述文件,对组件进行高亮展示
*/ */
function generateUniComponentsTypes() { function generateUniComponentsTypes() {
const components = Object.keys(tags).map((key) => `'${key}': typeof HTMLElement`) const components = Object.keys(tags).map((key) => `'${key}': UniComponent`)
const content = ` const content = `
// generated by @dcloudio/uni-helper-json/dist/tags.json // generated by @dcloudio/uni-helper-json/dist/tags.json
declare module 'vue' { declare module 'vue' {
// uni-app 内置组件高亮 // shime-uni.d.ts
type Hooks = App.AppInstance & Page.PageInstance;
type ComponentCustomOptions = Hooks
// uni-app components
type UniComponent = HTMLElement
export interface GlobalComponents { export interface GlobalComponents {
${components.join(',\n\t')} ${components.join(',\n\t')}
} }
...@@ -28,7 +33,7 @@ function generateUniComponentsTypes() { ...@@ -28,7 +33,7 @@ function generateUniComponentsTypes() {
parser: 'typescript', parser: 'typescript',
...require('../../prettier.config'), ...require('../../prettier.config'),
}) })
fs.writeFileSync('./types/uni-components.d.ts', formatted, 'utf8') fs.writeFileSync('./types/uni.d.ts', formatted, 'utf8')
} }
/** /**
......
const fs = require('fs') const fs = require('node:fs')
const path = require('path') const path = require('node:path')
const { execSync } = require('child_process') const { execSync } = require('node:child_process')
const scopes = fs const scopes = fs
.readdirSync(path.resolve(__dirname, 'src'), { withFileTypes: true }) .readdirSync(path.resolve(__dirname, 'src'), { withFileTypes: true })
......
...@@ -21,7 +21,7 @@ ...@@ -21,7 +21,7 @@
- [Lodash](https://github.com/lodash/lodash) 函数库 - [Lodash](https://github.com/lodash/lodash) 函数库
- [Dayjs](https://github.com/iamkun/dayjs) 时间库 - [Dayjs](https://github.com/iamkun/dayjs) 时间库
- [@vueuse/core](https://github.com/vueuse/vueuse) Vue2/3 实用工具集 - [@vueuse/core](https://github.com/vueuse/vueuse) Vue2/3 实用工具集
- [mock.js](https://github.com/nuysoft/Mock) 数据模拟 - [faker-js](https://github.com/faker-js/faker) 数据模拟
- [UnoCSS](https://github.com/unocss/unocss) UnoCSS - [UnoCSS](https://github.com/unocss/unocss) UnoCSS
### 网络 ### 网络
...@@ -40,7 +40,7 @@ ...@@ -40,7 +40,7 @@
<!-- prettier-ignore --> <!-- prettier-ignore -->
- [HBuilderX Latest](https://www.dcloud.io/hbuilderx.html) - [HBuilderX Latest](https://www.dcloud.io/hbuilderx.html)
- [Vite v4.x](https://vitejs.dev) - [Vite](https://vitejs.dev)
### 其他插件 ### 其他插件
......
...@@ -3,14 +3,14 @@ ...@@ -3,14 +3,14 @@
<head> <head>
<meta charset="UTF-8" /> <meta charset="UTF-8" />
<script> <script>
var coverSupport = const coverSupport =
'CSS' in window && 'CSS' in window &&
typeof CSS.supports === 'function' && typeof CSS.supports === 'function' &&
(CSS.supports('top: env(a)') || CSS.supports('top: constant(a)')) (CSS.supports('top: env(a)') || CSS.supports('top: constant(a)'))
document.write( document.write(
'<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0' + `<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0${
(coverSupport ? ', viewport-fit=cover' : '') + coverSupport ? ', viewport-fit=cover' : ''
'" />', }" />`,
) )
</script> </script>
<title></title> <title></title>
......
...@@ -57,7 +57,7 @@ ...@@ -57,7 +57,7 @@
"lint:stylelint": "stylelint --cache --fix \"**/*.{vue,less,postcss,css,scss}\" --cache --cache-location node_modules/.cache/stylelint/", "lint:stylelint": "stylelint --cache --fix \"**/*.{vue,less,postcss,css,scss}\" --cache --cache-location node_modules/.cache/stylelint/",
"lint:lint-staged": "lint-staged -c ./.husky/lintstagedrc.js", "lint:lint-staged": "lint-staged -c ./.husky/lintstagedrc.js",
"log": "conventional-changelog -p angular -i CHANGELOG.md -s", "log": "conventional-changelog -p angular -i CHANGELOG.md -s",
"up": "pnpx @dcloudio/uvm alpha", "u": "pnpx @dcloudio/uvm vue3",
"prepare": "husky install" "prepare": "husky install"
}, },
"config": { "config": {
...@@ -66,27 +66,28 @@ ...@@ -66,27 +66,28 @@
} }
}, },
"dependencies": { "dependencies": {
"@dcloudio/uni-app": "3.0.0-3070820230322001", "@dcloudio/uni-app": "3.0.0-alpha-3071220230331002",
"@dcloudio/uni-app-plus": "3.0.0-3070820230322001", "@dcloudio/uni-app-plus": "3.0.0-alpha-3071220230331002",
"@dcloudio/uni-components": "3.0.0-3070820230322001", "@dcloudio/uni-components": "3.0.0-alpha-3071220230331002",
"@dcloudio/uni-h5": "3.0.0-3070820230322001", "@dcloudio/uni-h5": "3.0.0-alpha-3071220230331002",
"@dcloudio/uni-mp-alipay": "3.0.0-3070820230322001", "@dcloudio/uni-mp-alipay": "3.0.0-alpha-3071220230331002",
"@dcloudio/uni-mp-baidu": "3.0.0-3070820230322001", "@dcloudio/uni-mp-baidu": "3.0.0-alpha-3071220230331002",
"@dcloudio/uni-mp-jd": "3.0.0-3070820230322001", "@dcloudio/uni-mp-jd": "3.0.0-alpha-3071220230331002",
"@dcloudio/uni-mp-kuaishou": "3.0.0-3070820230322001", "@dcloudio/uni-mp-kuaishou": "3.0.0-alpha-3071220230331002",
"@dcloudio/uni-mp-lark": "3.0.0-3070820230322001", "@dcloudio/uni-mp-lark": "3.0.0-alpha-3071220230331002",
"@dcloudio/uni-mp-qq": "3.0.0-3070820230322001", "@dcloudio/uni-mp-qq": "3.0.0-alpha-3071220230331002",
"@dcloudio/uni-mp-toutiao": "3.0.0-3070820230322001", "@dcloudio/uni-mp-toutiao": "3.0.0-alpha-3071220230331002",
"@dcloudio/uni-mp-weixin": "3.0.0-3070820230322001", "@dcloudio/uni-mp-weixin": "3.0.0-alpha-3071220230331002",
"@dcloudio/uni-quickapp-webview": "3.0.0-3070820230322001", "@dcloudio/uni-quickapp-webview": "3.0.0-alpha-3071220230331002",
"@dcloudio/uni-ui": "^1.4.26", "@dcloudio/uni-ui": "^1.4.26",
"@faker-js/faker": "^7.6.0",
"@vue/runtime-core": "^3.2.47", "@vue/runtime-core": "^3.2.47",
"@vueuse/core": "^9.13.0", "@vueuse/core": "^9.13.0",
"axios": "^0.26.1", "axios": "^0.26.1",
"crypto-js": "^4.1.1", "crypto-js": "^4.1.1",
"dayjs": "^1.11.7", "dayjs": "^1.11.7",
"lodash-es": "^4.17.21", "lodash-es": "^4.17.21",
"nanoid": "^4.0.1", "nanoid": "^4.0.2",
"pinia": "^2.0.33", "pinia": "^2.0.33",
"qs": "~6.9.7", "qs": "~6.9.7",
"stompjs": "^2.3.3", "stompjs": "^2.3.3",
...@@ -97,25 +98,25 @@ ...@@ -97,25 +98,25 @@
"vue-types": "^5.0.2" "vue-types": "^5.0.2"
}, },
"devDependencies": { "devDependencies": {
"@antfu/eslint-config": "^0.37.0", "@antfu/eslint-config": "^0.38.2",
"@commitlint/cli": "^17.5.0", "@commitlint/cli": "^17.5.1",
"@commitlint/config-conventional": "^17.4.4", "@commitlint/config-conventional": "^17.4.4",
"@dcloudio/types": "^3.3.2", "@dcloudio/types": "^3.3.2",
"@dcloudio/uni-automator": "3.0.0-3070820230322001", "@dcloudio/uni-automator": "3.0.0-alpha-3071220230331002",
"@dcloudio/uni-cli-shared": "3.0.0-3070820230322001", "@dcloudio/uni-cli-shared": "3.0.0-alpha-3071220230331002",
"@dcloudio/uni-helper-json": "^1.0.13", "@dcloudio/uni-helper-json": "^1.0.13",
"@dcloudio/uni-stacktracey": "3.0.0-3070820230322001", "@dcloudio/uni-stacktracey": "3.0.0-alpha-3071220230331002",
"@dcloudio/vite-plugin-uni": "3.0.0-3070820230322001", "@dcloudio/vite-plugin-uni": "3.0.0-alpha-3071220230331002",
"@iconify/json": "^2.2.38", "@iconify/json": "^2.2.43",
"@types/crypto-js": "^4.1.1", "@types/crypto-js": "^4.1.1",
"@types/lodash-es": "^4.17.7", "@types/lodash-es": "^4.17.7",
"@types/node": "^18.15.5", "@types/node": "^18.15.11",
"@types/prettier": "^2.7.2", "@types/prettier": "^2.7.2",
"@types/qs": "^6.9.7", "@types/qs": "^6.9.7",
"@types/stompjs": "^2.3.5", "@types/stompjs": "^2.3.5",
"@types/urijs": "^1.19.19", "@types/urijs": "^1.19.19",
"@typescript-eslint/eslint-plugin": "^5.56.0", "@typescript-eslint/eslint-plugin": "^5.57.0",
"@typescript-eslint/parser": "^5.56.0", "@typescript-eslint/parser": "^5.57.0",
"commitizen": "^4.3.0", "commitizen": "^4.3.0",
"conventional-changelog-cli": "^2.2.2", "conventional-changelog-cli": "^2.2.2",
"cz-conventional-changelog": "^3.3.0", "cz-conventional-changelog": "^3.3.0",
...@@ -123,10 +124,10 @@ ...@@ -123,10 +124,10 @@
"cz-git": "^1.6.1", "cz-git": "^1.6.1",
"czg": "^1.6.1", "czg": "^1.6.1",
"dotenv": "^16.0.3", "dotenv": "^16.0.3",
"eslint": "^8.36.0", "eslint": "^8.37.0",
"eslint-config-prettier": "^8.8.0", "eslint-config-prettier": "^8.8.0",
"eslint-plugin-prettier": "^4.2.1", "eslint-plugin-prettier": "^4.2.1",
"eslint-plugin-vue": "^9.9.0", "eslint-plugin-vue": "^9.10.0",
"husky": "^8.0.3", "husky": "^8.0.3",
"jest": "27.0.4", "jest": "27.0.4",
"jest-environment-node": "27.5.1", "jest-environment-node": "27.5.1",
...@@ -138,28 +139,26 @@ ...@@ -138,28 +139,26 @@
"postcss": "^8.4.21", "postcss": "^8.4.21",
"postcss-html": "^1.5.0", "postcss-html": "^1.5.0",
"postcss-less": "^6.0.0", "postcss-less": "^6.0.0",
"prettier": "^2.8.6", "prettier": "^2.8.7",
"rimraf": "^4.4.1", "rimraf": "^4.4.1",
"sass": "^1.59.3", "sass": "^1.60.0",
"sort-package-json": "^2.4.1", "sort-package-json": "^2.4.1",
"stylelint": "^14.16.1", "stylelint": "^15.4.0",
"stylelint-config-html": "^1.1.0", "stylelint-config-html": "^1.1.0",
"stylelint-config-prettier": "^9.0.5", "stylelint-config-recommended": "^11.0.0",
"stylelint-config-recommended": "^9.0.0", "stylelint-config-standard": "^32.0.0",
"stylelint-config-standard": "^29.0.0", "stylelint-order": "^6.0.3",
"stylelint-order": "^5.0.0", "terser": "^5.16.8",
"stylus": "^0.59.0", "typescript": "^5.0.3",
"terser": "^5.16.6",
"typescript": "^4.9.5",
"unocss": "^0.50.6", "unocss": "^0.50.6",
"unocss-preset-weapp": "^0.5.2", "unocss-preset-weapp": "^0.5.2",
"unplugin-auto-import": "^0.15.1", "unplugin-auto-import": "^0.15.2",
"unplugin-imagemin": "^0.3.11",
"unplugin-vue-components": "^0.24.1", "unplugin-vue-components": "^0.24.1",
"vite": "^4.2.1", "vite": "^4.2.1",
"vue-eslint-parser": "^9.1.0" "vue-eslint-parser": "^9.1.1"
}, },
"engines": { "engines": {
"node": ">=16" "node": ">=16",
"pnpm": ">=8.1.0"
} }
} }
This source diff could not be displayed because it is too large. You can view the blob instead.
// import * as Pont from 'pont-engine' // import * as Pont from 'pont-engine'
import { Interface, BaseClass, Property, CodeGenerator } from 'pont-engine' import type { BaseClass, Interface } from 'pont-engine'
import { CodeGenerator, Property } from 'pont-engine'
// 接口 API 前缀 // 接口 API 前缀
// 通常与项目的 env 配置中的 VITE_GLOB_API_URL_PREFIX 相同 // 通常与项目的 env 配置中的 VITE_GLOB_API_URL_PREFIX 相同
...@@ -44,7 +45,7 @@ export default class BasicGenerator extends CodeGenerator { ...@@ -44,7 +45,7 @@ export default class BasicGenerator extends CodeGenerator {
return `${requestParams.replace( return `${requestParams.replace(
'options?: any', 'options?: any',
`config?: http.RequestConfig<${ `config?: http.RequestConfig<${
bodyTypeDef ? bodyTypeDef : `Params${requestParams.includes('form') ? ' | FormData' : ''}` bodyTypeDef || `Params${requestParams.includes('form') ? ' | FormData' : ''}`
}>`, }>`,
)}, options?: http.RequestOptions` )}, options?: http.RequestOptions`
} }
......
import { StandardDataSource } from 'pont-engine' import type { StandardDataSource } from 'pont-engine'
export default function (dataSource: StandardDataSource): StandardDataSource { export default function (dataSource: StandardDataSource): StandardDataSource {
return dataSource return dataSource
......
...@@ -36,15 +36,15 @@ ...@@ -36,15 +36,15 @@
/* common css */ /* common css */
/* #ifndef APP-PLUS-NVUE */ /* #ifndef APP-PLUS-NVUE */
/* uni.css - 通用组件、模板样式库,可以当作一套ui库应用 */ /* uni.css - 通用组件、模板样式库,可以当作一套ui库应用 */
@import './common/uni.css'; @import url('./common/uni.css');
/* #endif */ /* #endif */
/*每个页面公共css */ /* 每个页面公共css */
@import './common/fui-app.css'; @import url('./common/fui-app.css');
@import './components/firstui/fui-theme/fui-theme.css'; @import url('./components/firstui/fui-theme/fui-theme.css');
// 全局样式 // 全局样式
@import './common/public.less'; @import url('./common/public.less');
/** #ifdef H5 */ /** #ifdef H5 */
uni-page-body, uni-page-body,
......
...@@ -18,6 +18,10 @@ ...@@ -18,6 +18,10 @@
type: String, type: String,
default: 'scaleToFill', default: 'scaleToFill',
}, },
background: {
type: String,
default: '#F7F7F7',
},
src: { src: {
type: String, type: String,
required: true, required: true,
...@@ -38,10 +42,10 @@ ...@@ -38,10 +42,10 @@
const hash = md5(url).toString() const hash = md5(url).toString()
hashCacheKey.value = `G_CACHE_IMAGE_${hash}` hashCacheKey.value = `G_CACHE_IMAGE_${hash}`
if (uni.getStorageSync(hashCacheKey.value)) { if (uni.getStorageSync(hashCacheKey.value)) {
console.log('CacheImage cache hit') console.debug('CacheImage cache hit')
url = uni.getStorageSync(hashCacheKey.value) url = uni.getStorageSync(hashCacheKey.value)
} else { } else {
console.log('CacheImage cache miss') console.debug('CacheImage cache miss')
try { try {
const res = await uni.downloadFile({ url }) const res = await uni.downloadFile({ url })
if (res.statusCode === 200) { if (res.statusCode === 200) {
...@@ -61,7 +65,7 @@ ...@@ -61,7 +65,7 @@
console.error(e) console.error(e)
} }
} }
console.log(props.src, '=>', url, hash, hashCacheKey.value) console.debug(props.src, '=>', url, hash, hashCacheKey.value)
// #endif // #endif
src.value = url src.value = url
...@@ -87,7 +91,10 @@ ...@@ -87,7 +91,10 @@
:width="props.width" :width="props.width"
:height="props.height" :height="props.height"
:radius="props.radius" :radius="props.radius"
:background="props.background"
:src="src" :src="src"
@error="onError" @error="onError"
/> >
<slot></slot>
</fui-lazyload>
</template> </template>
...@@ -26,7 +26,7 @@ ...@@ -26,7 +26,7 @@
</view> </view>
</template> </template>
<style> <style scoped>
.empty { .empty {
width: 100%; width: 100%;
height: 100%; height: 100%;
...@@ -45,6 +45,6 @@ ...@@ -45,6 +45,6 @@
.empty .empty-tips { .empty .empty-tips {
display: flex; display: flex;
font-size: 30rpx; font-size: 30rpx;
color: #999999; color: #999;
} }
</style> </style>
<script lang="ts" setup> <script lang="ts" setup>
import type { PropType } from 'vue' import md5 from 'crypto-js/md5'
import { nanoid } from 'nanoid' import { nanoid } from 'nanoid'
import { getPoster, isImage, isVideo } from './utils' import { getPoster, isImage, isVideo } from './utils'
import CacheImage from '@/components/CacheImage/index.vue'
type Asset = Recordable & { url: string } type Asset = Recordable & { url: string }
const props = defineProps({ const props = defineProps({
...@@ -27,15 +28,25 @@ ...@@ -27,15 +28,25 @@
}) })
// 生成预览容器高度 // 生成预览容器高度
const containerHeight = `${props.height}rpx` const height = computed(() => `${props.height}rpx`)
// 分离图片和视频资源地址 // 分离图片和视频资源地址
const images = computed(() => props.assets.filter((item) => isImage(item.url))) const images = computed(() => props.assets.filter((item) => isImage(item.url)))
const videos = computed(() => props.assets.filter((item) => isVideo(item.url))) const videos = computed(() => props.assets.filter((item) => isVideo(item.url)))
// 预览图片 // 预览图片
const preview = (index: number) => { function preview(index: number) {
uni.previewImage({ uni.previewImage({
urls: images.value.map((item) => item.url), urls: images.value.map((item) => {
// #ifdef APP-PLUS
const hash = md5(item.url).toString()
const key = `G_CACHE_IMAGE_${hash}`
if (uni.getStorageSync(key)) {
return uni.getStorageSync(key)
}
// #endif
return item.url
}),
current: index, current: index,
}) })
} }
...@@ -45,12 +56,12 @@ ...@@ -45,12 +56,12 @@
const videoContext = ref() const videoContext = ref()
const playVideoSrc = ref() const playVideoSrc = ref()
// 播放视频 // 播放视频
const play = (index: number) => { function play(index: number) {
playVideoSrc.value = videos.value[index].url playVideoSrc.value = videos.value[index].url
videoContext.value?.requestFullScreen() videoContext.value?.requestFullScreen()
videoContext.value?.play() videoContext.value?.play()
} }
const videoFullScreenChange = (e: any) => { function videoFullScreenChange(e: any) {
// 非全屏状态下停止播放 // 非全屏状态下停止播放
if (!e.detail.fullScreen) { if (!e.detail.fullScreen) {
videoContext.value.seek(0) videoContext.value.seek(0)
...@@ -67,7 +78,7 @@ ...@@ -67,7 +78,7 @@
<template> <template>
<view class="preview-wrap"> <view class="preview-wrap">
<!-- 视频预览 --> <!-- 视频预览 -->
<fui-lazyload <CacheImage
class="preview-video" class="preview-video"
:background="props.background" :background="props.background"
:mode="props.mode" :mode="props.mode"
...@@ -82,10 +93,10 @@ ...@@ -82,10 +93,10 @@
<view class="icon-wrap" :style="{ width: props.width, height: props.height }"> <view class="icon-wrap" :style="{ width: props.width, height: props.height }">
<fui-icon class="video-play-icon" name="suspend" size="40" color="#fff" /> <fui-icon class="video-play-icon" name="suspend" size="40" color="#fff" />
</view> </view>
</fui-lazyload> </CacheImage>
<!-- 图片预览 --> <!-- 图片预览 -->
<fui-lazyload <CacheImage
class="preview-image" class="preview-image"
:background="props.background" :background="props.background"
:mode="props.mode" :mode="props.mode"
...@@ -122,7 +133,7 @@ ...@@ -122,7 +133,7 @@
position: relative; position: relative;
:deep(.fui-lazyload__img) { :deep(.fui-lazyload__img) {
height: v-bind(containerHeight) !important; height: v-bind(height) !important;
} }
.icon-wrap { .icon-wrap {
...@@ -131,7 +142,7 @@ ...@@ -131,7 +142,7 @@
left: 0; left: 0;
width: 100%; width: 100%;
height: 100%; height: 100%;
background-color: rgba(0, 0, 0, 0.5); background-color: rgb(0 0 0 / 50%);
border-radius: 10rpx; border-radius: 10rpx;
.video-play-icon { .video-play-icon {
......
...@@ -57,4 +57,6 @@ export function useI18n(namespace?: string): { ...@@ -57,4 +57,6 @@ export function useI18n(namespace?: string): {
// 为什么要编写此函数? // 为什么要编写此函数?
// 主要用于配合vscode i18nn ally插件。此功能仅用于路由和菜单。请在其他地方使用useI18n // 主要用于配合vscode i18nn ally插件。此功能仅用于路由和菜单。请在其他地方使用useI18n
export const t = (key: string) => key export function t(key: string) {
return key
}
...@@ -26,7 +26,7 @@ const Message = { ...@@ -26,7 +26,7 @@ const Message = {
}, },
} }
const createErrorModal = (options: { title: string; content: string }) => { function createErrorModal(options: { title: string; content: string }) {
uni.showModal({ uni.showModal({
title: options.title, title: options.title,
content: options.content, content: options.content,
......
...@@ -2,7 +2,7 @@ import type { GlobConfig } from '/#/config' ...@@ -2,7 +2,7 @@ import type { GlobConfig } from '/#/config'
import { getAppEnvConfig } from '/@/utils/env' import { getAppEnvConfig } from '/@/utils/env'
export const useGlobSetting = (): Readonly<GlobConfig> => { export function useGlobSetting(): Readonly<GlobConfig> {
const { const {
VITE_GLOB_APP_NAME, VITE_GLOB_APP_NAME,
VITE_GLOB_APP_DESCRIPTION, VITE_GLOB_APP_DESCRIPTION,
......
...@@ -38,7 +38,7 @@ ...@@ -38,7 +38,7 @@
</view> </view>
</template> </template>
<style> <style scoped>
page { page {
background-color: #fff; background-color: #fff;
font-weight: normal; font-weight: normal;
...@@ -68,7 +68,7 @@ ...@@ -68,7 +68,7 @@
.fui-title { .fui-title {
text-align: center; text-align: center;
font-weight: 500; font-weight: 500;
color: #333333; color: #333;
padding-top: 48rpx; padding-top: 48rpx;
} }
......
...@@ -27,7 +27,7 @@ ...@@ -27,7 +27,7 @@
})) }))
}) })
const preview = (index: number) => { function preview(index: number) {
uni.previewImage({ uni.previewImage({
urls: images.value.map((item: { src: string }) => item.src), urls: images.value.map((item: { src: string }) => item.src),
current: index, current: index,
......
...@@ -18,7 +18,7 @@ ...@@ -18,7 +18,7 @@
}) })
}) })
const surprise = () => { function surprise() {
// #ifdef APP-PLUS // #ifdef APP-PLUS
const orientation = plus.navigator.getOrientation() const orientation = plus.navigator.getOrientation()
if (orientation === 0) { if (orientation === 0) {
...@@ -35,7 +35,7 @@ ...@@ -35,7 +35,7 @@
} }
const animate = ref() const animate = ref()
const handUp = () => { function handUp() {
if (animate.value) { if (animate.value) {
return return
} }
......
...@@ -259,12 +259,18 @@ export class VAxios { ...@@ -259,12 +259,18 @@ export class VAxios {
const { requestOptions } = this.options const { requestOptions } = this.options
const opt: RequestOptions = Object.assign({}, requestOptions, options) let opt: RequestOptions = Object.assign({}, requestOptions, options)
const { beforeRequestHook, requestCatchHook, transformRequestHook } = transform || {} const { beforeRequestHook, requestCatchHook, transformRequestHook, inject } = transform || {}
if (inject && isFunction(inject)) {
const result = inject(conf, opt)
conf = result.config
opt = result.options
}
if (beforeRequestHook && isFunction(beforeRequestHook)) { if (beforeRequestHook && isFunction(beforeRequestHook)) {
conf = beforeRequestHook(conf, opt) conf = beforeRequestHook(conf, opt)
} }
conf.requestOptions = opt conf.requestOptions = opt
conf = this.supportFormData(conf) conf = this.supportFormData(conf)
......
...@@ -5,7 +5,9 @@ import { isFunction } from '/@/utils/is' ...@@ -5,7 +5,9 @@ import { isFunction } from '/@/utils/is'
// Used to store the identification and cancellation function of each request // Used to store the identification and cancellation function of each request
let pendingMap = new Map<string, Canceler>() let pendingMap = new Map<string, Canceler>()
export const getPendingUrl = (config: AxiosRequestConfig) => [config.method, config.url].join('&') export function getPendingUrl(config: AxiosRequestConfig) {
return [config.method, config.url].join('&')
}
export class AxiosCanceler { export class AxiosCanceler {
/** /**
......
...@@ -12,6 +12,15 @@ export interface CreateAxiosOptions extends AxiosRequestConfig { ...@@ -12,6 +12,15 @@ export interface CreateAxiosOptions extends AxiosRequestConfig {
export abstract class AxiosTransform { export abstract class AxiosTransform {
/** /**
* 注入自定义配置,在请求方法调用时
* 允许动态修改本次请求的 config 和 options
*/
inject?: (
config: AxiosRequestConfig,
options: RequestOptions,
) => { config: AxiosRequestConfig; options: RequestOptions }
/**
* @description: Process configuration before request * @description: Process configuration before request
* @description: Process configuration before request * @description: Process configuration before request
*/ */
......
...@@ -267,8 +267,14 @@ export const defHttp = createAxios({ ...@@ -267,8 +267,14 @@ export const defHttp = createAxios({
// other api url // other api url
// export const otherHttp = createAxios({ // export const otherHttp = createAxios({
// requestOptions: { // transform: {
// apiUrl: 'xxx', // inject: (config: AxiosRequestConfig<any>, options: http.RequestOptions) => {
// urlPrefix: 'xxx', // // TODO: 根据实际项目配置
// }, // return { config, options }
// }); // },
// },
// requestOptions: {
// apiUrl: 'xxx',
// urlPrefix: 'xxx',
// },
// })
...@@ -3,7 +3,7 @@ import type { App, Plugin } from 'vue' ...@@ -3,7 +3,7 @@ import type { App, Plugin } from 'vue'
import { unref } from 'vue' import { unref } from 'vue'
import { isObject } from '/@/utils/is' import { isObject } from '/@/utils/is'
export const noop = () => {} export function noop() {}
/** /**
* @description: Set ui mount node * @description: Set ui mount node
...@@ -50,7 +50,7 @@ export function getDynamicProps<T, U>(props: T): Partial<U> { ...@@ -50,7 +50,7 @@ export function getDynamicProps<T, U>(props: T): Partial<U> {
return ret as Partial<U> return ret as Partial<U>
} }
export const withInstall = <T>(component: T, alias?: string) => { export function withInstall<T>(component: T, alias?: string) {
const comp = component as any const comp = component as any
comp.install = (app: App) => { comp.install = (app: App) => {
app.component(comp.name || comp.displayName, component) app.component(comp.name || comp.displayName, component)
......
...@@ -15,7 +15,7 @@ const PROXY_LIST: [[string, string]?] = [ ...@@ -15,7 +15,7 @@ const PROXY_LIST: [[string, string]?] = [
* 将内部地址(内网)转换成代理/预览地址(公网) * 将内部地址(内网)转换成代理/预览地址(公网)
* @param url 内网地址 * @param url 内网地址
*/ */
export const getExtranetUrl = (url: string): string => { export function getExtranetUrl(url: string): string {
let uri = url let uri = url
PROXY_LIST.forEach((proxy) => { PROXY_LIST.forEach((proxy) => {
...@@ -30,7 +30,7 @@ export const getExtranetUrl = (url: string): string => { ...@@ -30,7 +30,7 @@ export const getExtranetUrl = (url: string): string => {
* eg: 主要用于解决内网文件上传后预览,但是实际上传存储时还是内网地址的问题 * eg: 主要用于解决内网文件上传后预览,但是实际上传存储时还是内网地址的问题
* @param url 包含代理/公网地址的内容 * @param url 包含代理/公网地址的内容
*/ */
export const getIntranetUrl = (url: string): string => { export function getIntranetUrl(url: string): string {
let uri = url let uri = url
PROXY_LIST.forEach((proxy) => { PROXY_LIST.forEach((proxy) => {
...@@ -45,7 +45,7 @@ export const getIntranetUrl = (url: string): string => { ...@@ -45,7 +45,7 @@ export const getIntranetUrl = (url: string): string => {
* @param body 接口返回的内容 * @param body 接口返回的内容
* @returns 替换本地链接后的数据结果 * @returns 替换本地链接后的数据结果
*/ */
export const handleResponseResource = <T>(body: T, options: Recordable) => { export function handleResponseResource<T>(body: T, options: Recordable) {
for (const [intranet, extranet] of PROXY_LIST) { for (const [intranet, extranet] of PROXY_LIST) {
// 当需要处理内外网资源地址映射时,进行内容处理 // 当需要处理内外网资源地址映射时,进行内容处理
const isIntranet = options.apiUrl.includes(intranet) const isIntranet = options.apiUrl.includes(intranet)
......
...@@ -2,7 +2,7 @@ module.exports = { ...@@ -2,7 +2,7 @@ module.exports = {
root: true, root: true,
plugins: ['stylelint-order'], plugins: ['stylelint-order'],
customSyntax: 'postcss-less', customSyntax: 'postcss-less',
extends: ['stylelint-config-standard', 'stylelint-config-prettier'], extends: ['stylelint-config-standard'],
rules: { rules: {
'selector-class-pattern': null, 'selector-class-pattern': null,
'selector-pseudo-class-no-unknown': [ 'selector-pseudo-class-no-unknown': [
...@@ -36,12 +36,8 @@ module.exports = { ...@@ -36,12 +36,8 @@ module.exports = {
], ],
'no-empty-source': null, 'no-empty-source': null,
'named-grid-areas-no-invalid': null, 'named-grid-areas-no-invalid': null,
'unicode-bom': 'never',
'no-descending-specificity': null, 'no-descending-specificity': null,
'font-family-no-missing-generic-family-keyword': null, 'font-family-no-missing-generic-family-keyword': null,
'declaration-colon-space-after': 'always-single-line',
'declaration-colon-space-before': 'never',
// 'declaration-block-trailing-semicolon': 'always',
'rule-empty-line-before': [ 'rule-empty-line-before': [
'always', 'always',
{ {
......
// generated by @dcloudio/uni-helper-json/dist/tags.json
declare module 'vue' {
// uni-app 内置组件高亮
export interface GlobalComponents {
block: typeof HTMLElement
view: typeof HTMLElement
'scroll-view': typeof HTMLElement
'match-media': typeof HTMLElement
swiper: typeof HTMLElement
'swiper-item': typeof HTMLElement
'movable-view': typeof HTMLElement
'movable-area': typeof HTMLElement
text: typeof HTMLElement
'rich-text': typeof HTMLElement
progress: typeof HTMLElement
button: typeof HTMLElement
'checkbox-group': typeof HTMLElement
checkbox: typeof HTMLElement
form: typeof HTMLElement
input: typeof HTMLElement
label: typeof HTMLElement
picker: typeof HTMLElement
'picker-view': typeof HTMLElement
'radio-group': typeof HTMLElement
radio: typeof HTMLElement
slider: typeof HTMLElement
switch: typeof HTMLElement
textarea: typeof HTMLElement
navigator: typeof HTMLElement
audio: typeof HTMLElement
image: typeof HTMLElement
video: typeof HTMLElement
map: typeof HTMLElement
canvas: typeof HTMLElement
'web-view': typeof HTMLElement
'cover-view': typeof HTMLElement
'cover-image': typeof HTMLElement
icon: typeof HTMLElement
'picker-view-column': typeof HTMLElement
camera: typeof HTMLElement
'live-player': typeof HTMLElement
'live-pusher': typeof HTMLElement
'open-data': typeof HTMLElement
ad: typeof HTMLElement
'ad-draw': typeof HTMLElement
'navigation-bar': typeof HTMLElement
'custom-tab-bar': typeof HTMLElement
'page-meta': typeof HTMLElement
editor: typeof HTMLElement
'unicloud-db': typeof HTMLElement
}
}
export {}
// generated by @dcloudio/uni-helper-json/dist/tags.json
declare module 'vue' {
// shime-uni.d.ts
type Hooks = App.AppInstance & Page.PageInstance
type ComponentCustomOptions = Hooks
// uni-app components
type UniComponent = HTMLElement
export interface GlobalComponents {
block: UniComponent
view: UniComponent
'scroll-view': UniComponent
'match-media': UniComponent
swiper: UniComponent
'swiper-item': UniComponent
'movable-view': UniComponent
'movable-area': UniComponent
text: UniComponent
'rich-text': UniComponent
progress: UniComponent
button: UniComponent
'checkbox-group': UniComponent
checkbox: UniComponent
form: UniComponent
input: UniComponent
label: UniComponent
picker: UniComponent
'picker-view': UniComponent
'radio-group': UniComponent
radio: UniComponent
slider: UniComponent
switch: UniComponent
textarea: UniComponent
navigator: UniComponent
audio: UniComponent
image: UniComponent
video: UniComponent
map: UniComponent
canvas: UniComponent
'web-view': UniComponent
'cover-view': UniComponent
'cover-image': UniComponent
icon: UniComponent
'picker-view-column': UniComponent
camera: UniComponent
'live-player': UniComponent
'live-pusher': UniComponent
'open-data': UniComponent
ad: UniComponent
'ad-draw': UniComponent
'navigation-bar': UniComponent
'custom-tab-bar': UniComponent
'page-meta': UniComponent
editor: UniComponent
'unicloud-db': UniComponent
}
}
export {}
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论