hookehuyr

🎉 init: 项目初始化

1 +# port
2 +VITE_PORT = 8106
3 +
4 +# 反向代理服务器地址
5 +VITE_PROXY_TARGET = https://oa-dev.onwall.cn
6 +# VITE_PROXY_TARGET = https://oa.onwall.cn
7 +
8 +# API请求前缀
9 +VITE_PROXY_PREFIX = /srv/
10 +
11 +# 打包输出文件夹名称
12 +VITE_OUTDIR = hager
13 +
14 +# 是否开启调试
15 +VITE_CONSOLE = 0
16 +
17 +# appID相关
18 +VITE_APPID=微信appID
1 +# 资源公共路径
2 +VITE_BASE = /
3 +
4 +# 测试open-id
5 +# VITE_OPENID = api-test-openid
6 +# VITE_OPENID = o8BRf1gLDWieH3Y3JvbrI_4IjaME
7 +VITE_OPENID = oJLZq5t9PIKLW9tm1oSUNAuPwssA
8 +# VITE_OPENID = oJLZq5uT_6GwIh2tQWh1F9IoHZ3U
9 +
10 +# B端账号
11 +VITE_ID = 13761653761
12 +
13 +# 验证码
14 +VITE_PIN =
1 +###
2 + # @Date: 2024-09-26 13:36:06
3 + # @LastEditors: hookehuyr hookehuyr@gmail.com
4 + # @LastEditTime: 2024-09-26 13:38:31
5 + # @FilePath: /hager/.env.production
6 + # @Description: 文件描述
7 +###
8 +# 资源公共路径
9 +VITE_BASE = /f/hager/
10 +
11 +# 测试open-id
12 +VITE_APP_OPENID =
13 +
14 +# B端账号
15 +VITE_APP_ID =
16 +
17 +# 验证码
18 +VITE_APP_PIN =
1 +# Logs
2 +logs
3 +*.log
4 +npm-debug.log*
5 +yarn-debug.log*
6 +yarn-error.log*
7 +pnpm-debug.log*
8 +lerna-debug.log*
9 +
10 +node_modules
11 +dist
12 +dist-ssr
13 +*.local
14 +
15 +# Editor directories and files
16 +.vscode/*
17 +!.vscode/extensions.json
18 +.idea
19 +.DS_Store
20 +*.suo
21 +*.ntvs*
22 +*.njsproj
23 +*.sln
24 +*.sw?
25 +
26 +.history
27 +.vscode
1 +海格电器自适应网页
......
1 +export function createProxy(prefix, target) {
2 + const ret = {};
3 + ret[prefix] = {
4 + target,
5 + changeOrigin: true,
6 + ws: true,
7 + // rewrite: (path) => path.replace(/^\/api/, '')
8 + // rewrite: (path) => path.replace(new RegExp(`^${prefix}`), ''),
9 + }
10 + return ret
11 +}
1 +<!doctype html>
2 +<html lang="en">
3 + <head>
4 + <meta charset="UTF-8" />
5 + <link rel="icon" type="image/svg+xml" href="/vite.svg" />
6 + <meta name="viewport" content="width=device-width, initial-scale=1.0" />
7 + <title>Vite + Vue</title>
8 + </head>
9 + <body>
10 + <div id="app"></div>
11 + <script type="module" src="/src/main.js"></script>
12 + </body>
13 +</html>
1 +{
2 + "name": "hager-project",
3 + "private": true,
4 + "version": "0.0.0",
5 + "type": "module",
6 + "scripts": {
7 + "dev": "vite",
8 + "build": "vite build",
9 + "preview": "vite preview"
10 + },
11 + "dependencies": {
12 + "@babel/polyfill": "^7.12.1",
13 + "axios": "^1.7.5",
14 + "dayjs": "^1.11.13",
15 + "element-ui": "^2.15.14",
16 + "mui-player": "^1.8.1",
17 + "sass": "1.55.0",
18 + "vue": "2.7.13",
19 + "vue-router": "3.6.5"
20 + },
21 + "devDependencies": {
22 + "@vitejs/plugin-legacy": "^5.4.2",
23 + "@vitejs/plugin-vue": "^5.1.2",
24 + "@vitejs/plugin-vue2": "^2.3.1",
25 + "less": "^4.2.0",
26 + "path-browserify": "^1.0.1",
27 + "qs": "^6.13.0",
28 + "sass-embedded": "1.55.0",
29 + "vite": "^5.4.1",
30 + "vite-plugin-dynamic-import": "^1.5.0"
31 + }
32 +}
1 +<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" class="iconify iconify--logos" width="31.88" height="32" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 257"><defs><linearGradient id="IconifyId1813088fe1fbc01fb466" x1="-.828%" x2="57.636%" y1="7.652%" y2="78.411%"><stop offset="0%" stop-color="#41D1FF"></stop><stop offset="100%" stop-color="#BD34FE"></stop></linearGradient><linearGradient id="IconifyId1813088fe1fbc01fb467" x1="43.376%" x2="50.316%" y1="2.242%" y2="89.03%"><stop offset="0%" stop-color="#FFEA83"></stop><stop offset="8.333%" stop-color="#FFDD35"></stop><stop offset="100%" stop-color="#FFA800"></stop></linearGradient></defs><path fill="url(#IconifyId1813088fe1fbc01fb466)" d="M255.153 37.938L134.897 252.976c-2.483 4.44-8.862 4.466-11.382.048L.875 37.958c-2.746-4.814 1.371-10.646 6.827-9.67l120.385 21.517a6.537 6.537 0 0 0 2.322-.004l117.867-21.483c5.438-.991 9.574 4.796 6.877 9.62Z"></path><path fill="url(#IconifyId1813088fe1fbc01fb467)" d="M185.432.063L96.44 17.501a3.268 3.268 0 0 0-2.634 3.014l-5.474 92.456a3.268 3.268 0 0 0 3.997 3.378l24.777-5.718c2.318-.535 4.413 1.507 3.936 3.838l-7.361 36.047c-.495 2.426 1.782 4.5 4.151 3.78l15.304-4.649c2.372-.72 4.652 1.36 4.15 3.788l-11.698 56.621c-.732 3.542 3.979 5.473 5.943 2.437l1.313-2.028l72.516-144.72c1.215-2.423-.88-5.186-3.54-4.672l-25.505 4.922c-2.396.462-4.435-1.77-3.759-4.114l16.646-57.705c.677-2.35-1.37-4.583-3.769-4.113Z"></path></svg>
...\ No newline at end of file ...\ No newline at end of file
1 +<template>
2 + <div>
3 + <router-view></router-view>
4 + </div>
5 +</template>
6 +
7 +<script setup>
8 +
9 +</script>
10 +
11 +<style lang="less" scoped>
12 +
13 +</style>
1 +import { fn, fetch, uploadFn } from '@/api/fn';
2 +
3 +const Api = {
4 + SMS: '/srv/?a=sms',
5 + TOKEN: '/srv/?a=upload',
6 + SAVE_FILE: '/srv/?a=upload&t=save_file',
7 +}
8 +
9 +/**
10 + * @description: 发送验证码
11 + * @param {*} phone 手机号码
12 + * @returns
13 + */
14 +export const smsAPI = (params) => fn(fetch.post(Api.SMS, params));
15 +
16 +/**
17 + * @description: 获取七牛token
18 + * @param {*} filename 文件名
19 + * @param {*} file 图片base64
20 + * @returns
21 + */
22 +export const qiniuTokenAPI = (params) => fn(fetch.stringifyPost(Api.TOKEN, params));
23 +
24 +/**
25 + * @description: 上传七牛
26 + * @param {*}
27 + * @returns
28 + */
29 +export const qiniuUploadAPI = (url, data, config) => uploadFn(fetch.basePost(url, data, config));
30 +
31 +/**
32 + * @description: 保存图片
33 + * @param {*} format
34 + * @param {*} hash
35 + * @param {*} height
36 + * @param {*} width
37 + * @param {*} filekey
38 + * @returns
39 + */
40 +export const saveFileAPI = (params) => fn(fetch.stringifyPost(Api.SAVE_FILE, params));
1 +/*
2 + * @Date: 2024-08-26 13:51:57
3 + * @LastEditors: hookehuyr hookehuyr@gmail.com
4 + * @LastEditTime: 2024-08-26 13:57:27
5 + * @FilePath: /vite-project/src/api/fn.js
6 + * @Description: 文件描述
7 + */
8 +import axios from '@/utils/axios';
9 +import { Message } from 'element-ui';
10 +import qs from 'Qs'
11 +
12 +/**
13 + * 网络请求功能函数
14 + * @param {*} api 请求axios接口
15 + * @returns 请求成功后,获取数据
16 + */
17 +export const fn = (api) => {
18 + return api
19 + .then(res => {
20 + if (res.data.code === 1) {
21 + return res.data || true;
22 + } else {
23 + // tslint:disable-next-line: no-console
24 + console.warn(res);
25 + if (!res.data.show) return false;
26 + Message({
27 + message: res.data.msg,
28 + type: 'warning'
29 + });
30 + return false;
31 + }
32 + })
33 + .catch(err => {
34 + // tslint:disable-next-line: no-console
35 + console.error(err);
36 + return false;
37 + })
38 + .finally(() => { // 最终执行
39 + })
40 +}
41 +
42 +/**
43 + * 七牛返回格式
44 + * @param {*} api
45 + * @returns
46 + */
47 +export const uploadFn = (api) => {
48 + return api
49 + .then(res => {
50 + if (res.statusText === 'OK') {
51 + return res.data || true;
52 + } else {
53 + // tslint:disable-next-line: no-console
54 + console.warn(res);
55 + if (!res.data.show) return false;
56 + Toast({
57 + icon: 'close',
58 + message: res.data.msg
59 + });
60 + return false;
61 + }
62 + })
63 + .catch(err => {
64 + // tslint:disable-next-line: no-console
65 + console.error(err);
66 + return false;
67 + })
68 +}
69 +
70 +/**
71 + * 统一 GET/POST 不同传参形式
72 + */
73 +export const fetch = {
74 + get: function (api, params) {
75 + return axios.get(api, { params })
76 + },
77 + post: function (api, params) {
78 + return axios.post(api, params)
79 + },
80 + stringifyPost: function (api, params) {
81 + return axios.post(api, qs.stringify(params))
82 + },
83 + basePost: function (url, data, config) {
84 + return axios.post(url, data, config)
85 + }
86 +}
1 +import { fn, fetch } from '@/api/fn';
2 +
3 +const Api = {
4 + MAP: '/srv/?a=map',
5 +};
6 +
7 +export const mapAPI = (params) => fn(fetch.get(Api.MAP, params));
1 +<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" class="iconify iconify--logos" width="37.07" height="36" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 198"><path fill="#41B883" d="M204.8 0H256L128 220.8L0 0h97.92L128 51.2L157.44 0h47.36Z"></path><path fill="#41B883" d="m0 0l128 220.8L256 0h-51.2L128 132.48L50.56 0H0Z"></path><path fill="#35495E" d="M50.56 0L128 133.12L204.8 0h-47.36L128 51.2L97.92 0H50.56Z"></path></svg>
...\ No newline at end of file ...\ No newline at end of file
1 +<!--
2 + * @Date: 2024-08-28 10:17:07
3 + * @LastEditors: hookehuyr hookehuyr@gmail.com
4 + * @LastEditTime: 2024-08-29 16:10:19
5 + * @FilePath: /vue2_vite_web/src/components/navbar.vue
6 + * @Description: 文件描述
7 +-->
8 +<template>
9 + <div class="navbar-container">
10 + <div class="big-navbar" v-if="!isMobile"></div>
11 + <div class="small-navbar" v-else></div>
12 + </div>
13 +</template>
14 +
15 +<script setup>
16 +const isMobile = ref(window.innerWidth < 768)
17 +const updateWindowSize = () => {
18 + isMobile.value = window.innerWidth < 768
19 +}
20 +// 使用watch来监听窗口大小变化(也可以使用其他方式)
21 +watch(
22 + () => window.innerWidth,
23 + (newVal, oldVal) => {
24 + updateWindowSize()
25 + },
26 + { immediate: false },
27 +)
28 +onMounted(() => {
29 + window.addEventListener('resize', updateWindowSize)
30 +})
31 +onBeforeUnmount(() => {
32 + window.removeEventListener('resize', updateWindowSize)
33 +})
34 +</script>
35 +<style lang="scss" scoped>
36 +// 也可以使用媒体查询来设置一些样式
37 +@media (max-width: 768px) {
38 + .navbar {
39 + background: rgb(255, 255, 255);
40 + }
41 +}
42 +</style>
1 +<template>
2 + <div ref="animatedElement" :style="computedStyle">
3 + <slot></slot>
4 + </div>
5 +</template>
6 +
7 +<script>
8 +// 页面滚动时,元素缓慢上升效果, 视觉差效果组件
9 +export default {
10 + name: 'slideIn',
11 + props: {
12 + duration: { // 动画持续时间
13 + type: Number,
14 + default: 1000
15 + },
16 + easing: { // 动画缓动效果
17 + type: String,
18 + default: 'ease'
19 + },
20 + distance: { // 动画距离
21 + type: Number,
22 + default: 100
23 + }
24 + },
25 + data() {
26 + return {
27 + hasAnimated: false // 是否已经动画过
28 + }
29 + },
30 + computed: {
31 + computedStyle() {
32 + return {
33 + opacity: this.hasAnimated ? 1 : 0,
34 + transform: this.hasAnimated ? 'translateY(0)' : `translateY(${this.distance}px)`,
35 + transition: `transform ${this.duration}ms ${this.easing}, opacity ${this.duration}ms ${this.easing}`
36 + }
37 + }
38 + },
39 + mounted() {
40 + if (typeof window !== 'undefined' && 'IntersectionObserver' in window) { // 检测是否支持IntersectionObserver
41 + this.createObserver() // 创建IntersectionObserver
42 + } else {
43 + // 如果不支持IntersectionObserver,则使用scroll事件来实现动画
44 + this.observeScroll()
45 + }
46 + },
47 + methods: {
48 + createObserver() {
49 + const observer = new IntersectionObserver(entries => { // IntersectionObserver回调函数
50 + entries.forEach(entry => { // 遍历每个观察目标
51 + if (entry.isIntersecting && !this.hasAnimated) { // 如果目标进入视口并且没有动画过
52 + this.hasAnimated = true // 标记动画过
53 + observer.unobserve(entry.target) // 停止观察
54 + }
55 + })
56 + }, { threshold: 0.1 }) // 观察阈值,表示目标在视口的百分比
57 + observer.observe(this.$refs.animatedElement) // 观察目标
58 + },
59 + observeScroll() {
60 + const onScroll = () => { // scroll事件回调函数
61 + if (this.isInViewport(this.$refs.animatedElement) && !this.hasAnimated) { // 如果目标在视口并且没有动画过
62 + this.hasAnimated = true // 标记动画过
63 + window.removeEventListener('scroll', onScroll) // 停止监听scroll事件
64 + }
65 + }
66 + window.addEventListener('scroll', onScroll) // 监听scroll事件
67 + },
68 + isInViewport(el) { // 判断目标是否在视口
69 + const rect = el.getBoundingClientRect()
70 + return rect.top < window.innerHeight && rect.bottom > 0
71 + }
72 + }
73 +}
74 +</script>
1 +<!--
2 + * @Date: 2024-09-24 18:06:55
3 + * @LastEditors: hookehuyr hookehuyr@gmail.com
4 + * @LastEditTime: 2024-09-25 09:59:56
5 + * @FilePath: /vue2_vite_web/src/components/videoPlayer.vue
6 + * @Description: 文件描述
7 +-->
8 +<template>
9 + <div class="">
10 + <div id="mui-player">
11 + </div>
12 + <div v-if="status === 'play'" @click="play" style="position: absolute; top: 50%; left: 50%;">play</div>
13 + <div v-if="status === 'pause'" @click="pause" style="position: absolute; top: 50%; left: 50%;">pause</div>
14 + </div>
15 +</template>
16 +
17 +<script>
18 +import 'mui-player/dist/mui-player.min.css'
19 +import MuiPlayer from 'mui-player'
20 +
21 +export default {
22 + data () {
23 + return {
24 + video: null,
25 + status: 'play',
26 + }
27 + },
28 + mounted () {
29 + // 初始化 MuiPlayer 插件,MuiPlayer 方法传递一个对象,该对象包括所有插件的配置
30 + var mp = new MuiPlayer({
31 + container:'#mui-player',
32 + title: '',
33 + pageHead: false,
34 + src:'https://gd-pri.jinshujufiles.com/en/g7D0MT/ltkASOw4yq0lJI0b-VH00VNz7zCs_field_20_1657944201.MOV?token=7NK_Z1IEoKaIY6I9RXzO4b9uQPwuwdvnlGbzHZmF:iYFNizzrqTFRuDPzUdtWDSrUOtA=:eyJTIjoiZ2QtcHJpLmppbnNodWp1ZmlsZXMuY29tL2VuL2c3RDBNVC9sdGtBU093NHlxMGxKSTBiLVZIMDBWTno3ekNzX2ZpZWxkXzIwXzE2NTc5NDQyMDEuTU9WKiIsIkUiOjE5NzM1MTM3NTh9',
35 + poster: 'https://gd-pri.jinshujufiles.com/en/g7D0MT/FqGDEvU9encwLEBGGj5y3_9fZ5VR_field_74_1657944218.jpeg?token=7NK_Z1IEoKaIY6I9RXzO4b9uQPwuwdvnlGbzHZmF:5dtH0Gbayh4jNtDMHK4o0D7X5Vs=:eyJTIjoiZ2QtcHJpLmppbnNodWp1ZmlsZXMuY29tL2VuL2c3RDBNVC9GcUdERXZVOWVuY3dMRUJHR2o1eTNfOWZaNVZSX2ZpZWxkXzc0XzE2NTc5NDQyMTguanBlZyoiLCJFIjoxOTczNTEzNzU4fQ==',
36 + videoAttribute: [
37 + // 声明启用同层播放, 不让会自动全屏播放
38 + { attrKey: 'webkit-playsinline', attrValue: 'webkit-playsinline' },
39 + { attrKey: 'playsinline', attrValue: 'playsinline' },
40 + { attrKey: 'x5-video-player-type', attrValue: 'h5-page' },
41 + ],
42 + });
43 + const video = mp.video();
44 + mp.on('ready',() => {
45 + this.video = video;
46 + });
47 + },
48 + methods: {
49 + play () {
50 + this.video.play();
51 + this.status = 'pause';
52 + },
53 + pause () {
54 + this.video.pause();
55 + this.status = 'play';
56 + }
57 + }
58 +}
59 +</script>
60 +
61 +<style lang="less" scoped>
62 +
63 +</style>
1 +/*
2 + * @Date: 2024-08-26 10:12:56
3 + * @LastEditors: hookehuyr hookehuyr@gmail.com
4 + * @LastEditTime: 2024-09-24 18:05:09
5 + * @FilePath: /vue2_vite_web/src/main.js
6 + * @Description: 文件描述
7 + */
8 +import "@babel/polyfill";
9 +import Vue from "vue";
10 +import App from './App.vue'
11 +import VueRouter from 'vue-router'
12 +import router from './router'
13 +import ElementUI from 'element-ui';
14 +import 'element-ui/lib/theme-chalk/index.css';
15 +import 'element-ui/lib/theme-chalk/display.css'; // 基于断点的隐藏类,用于在某些条件下隐藏元素
16 +import '@/styles/element-ui/element-variables.scss' // 自定义主题, 不需要展示屏蔽
17 +
18 +Vue.use(VueRouter);
19 +Vue.use(ElementUI);
20 +
21 +new Vue({
22 + router,
23 + render: (h) => h(App),
24 +})
25 +.$mount("#app");
1 +/*
2 + * @Date: 2024-08-26 10:42:15
3 + * @LastEditors: hookehuyr hookehuyr@gmail.com
4 + * @LastEditTime: 2024-08-26 10:53:44
5 + * @FilePath: /vite-project/src/route.js
6 + * @Description: 文件描述
7 + */
8 +export default [{
9 + path: '/',
10 + name: '首页',
11 + component: () => import('@/views/index'),
12 + meta: {
13 + },
14 + children: []
15 +}]
1 +/*
2 + * @Date: 2024-08-26 10:42:15
3 + * @LastEditors: hookehuyr hookehuyr@gmail.com
4 + * @LastEditTime: 2024-08-26 10:46:21
5 + * @FilePath: /vite-project/src/router.js
6 + * @Description: 文件描述
7 + */
8 +import Vue from 'vue'
9 +import VueRouter from 'vue-router'
10 +import ConfigRouter from './route.js'
11 +
12 +Vue.use(VueRouter)
13 +
14 +const router = new VueRouter({
15 + history: false,
16 + hashbang: true,
17 + base: '/',
18 + routes: ConfigRouter
19 +})
20 +
21 +router.beforeEach((to, from, next) => {
22 + next()
23 +})
24 +
25 +router.afterEach((to, from, next) => {
26 + // store.commit('updateLoadingStatus', false)
27 +})
28 +
29 +export default router
1 +@import "../variables.scss";
2 +/* 改变主题色变量 */
3 +$--color-primary: $style-el--color-primary;
4 +$--color-white: $style-el--color-white;
5 +
6 +/* 改变 icon 字体路径变量,必需 */
7 +$--font-path: 'element-ui/lib/theme-chalk/fonts';
8 +@import "element-ui/packages/theme-chalk/src/index";
This diff is collapsed. Click to expand it.
1 +/*需要切换的颜色变量*/
2 +$style-el--color-demo: transparent;
3 +$style-el--color-demo1:red;
4 +
5 +/* element颜色值声明
6 +* 统一前缀 $style-el
7 +* 后接element中变量值
8 +*/
9 +$style-el--color-primary: #C2915F;
10 +$style-el--color-white: #ffffff;
11 +
12 +/*定义方法*/
13 +@mixin color_primary() {
14 +
15 + /*判断匹配*/
16 + [data-theme="theme0"] & {
17 + background-color: $style-el--color-demo;
18 + }
19 +
20 + [data-theme="theme1"] & {
21 + background-color: $style-el--color-demo1;
22 + }
23 +}
24 +
25 +// tab组件
26 +@mixin tabs_color() {
27 + [data-theme="theme0"] & {
28 + color: #fff;
29 + text-shadow: 0 1px 2px rgb(0 0 0 / 50%);
30 + }
31 +}
32 +
33 +// dialog组件
34 +@mixin dialog_color() {
35 + [data-theme="theme0"] & {
36 + background: linear-gradient(218deg, #0c386b 0%, #051934 100%);
37 + color: #fff;
38 + }
39 +}
This diff is collapsed. Click to expand it.
File mode changed
1 +/*
2 + * @Date: 2022-06-20 01:22:50
3 + * @LastEditors: hookehuyr hookehuyr@gmail.com
4 + * @LastEditTime: 2022-06-20 01:23:18
5 + * @FilePath: /tswj/src/composables/useMonitorKeyboard.js
6 + * @Description: 文件描述
7 + */
8 +/**
9 + * @class 监听虚拟键盘
10 + * @classdesc 监听虚拟键盘弹出隐藏
11 + * @public onEnd 结束监听虚拟键盘
12 + * @public onShow 传递一个回调 监听虚拟键盘弹出
13 + * @public onHidden 传递一个回调 监听虚拟键盘隐藏
14 + */
15 +class MonitorKeyboard {
16 + constructor() {
17 + this.type = this.IsIA();
18 + this.originalHeight = window.innerHeight;
19 + }
20 +
21 + /**
22 + * @function IsIA 获取设备类型
23 + * @param 1 Android 2 iOS
24 + */
25 + IsIA = () => {
26 + const userAgent = typeof window === 'object' ? window.navigator.userAgent : '';
27 + if (/android/i.test(userAgent)) {
28 + return 1;
29 + } else if (/iPhone|iPod|iPad/i.test(userAgent)) {
30 + return 2;
31 + }
32 + }
33 +
34 + // Android系统
35 + onResize = () => {
36 + //键盘弹起与隐藏都会引起窗口的高度发生变化
37 + const resizeHeight = window.innerHeight;
38 +
39 + if (this.originalHeight - resizeHeight > 50) {
40 + this.show('Android系统: 软键盘弹出');
41 + } else {
42 + this.hidden('Android系统: 软键盘收起');
43 + }
44 + }
45 +
46 + // iOS获取焦点
47 + onFocusin = () => {
48 + this.show('iOS系统:软键盘弹出');
49 + }
50 +
51 + // iOS失去焦点
52 + onFocusout = () => {
53 + this.hidden('iOS系统:软键盘收起');
54 + }
55 +
56 + /**
57 + * @function onStart 开始监听虚拟键盘
58 + */
59 + onStart = () => {
60 + if (this.type == 1) {
61 + // 获取窗口的高度
62 + window.addEventListener('resize', this.onResize);
63 + }
64 + if (this.type == 2) {
65 + // iOS系统
66 + window.addEventListener('focusin', this.onFocusin);
67 + window.addEventListener('focusout', this.onFocusout);
68 + }
69 + }
70 +
71 + /**
72 + * @function onEnd 结束监听虚拟键盘
73 + */
74 + onEnd = () => {
75 + if (this.type == 1) {
76 + //获取窗口的高度
77 + window.removeEventListener('resize', this.onResize);
78 + }
79 + if (this.type == 2) {
80 + window.removeEventListener('focusin', this.onFocusin);
81 + window.removeEventListener('focusout', this.onFocusout);
82 + }
83 + }
84 +
85 + /**
86 + * @function onShow 传递一个回调函数
87 + * @param 虚拟键盘弹出时触发
88 + */
89 + onShow = (fn) => {
90 + this.show = fn;
91 + }
92 +
93 + /**
94 + * @function onHidden 传递一个回调函数
95 + * @param 虚拟键盘隐藏时触发
96 + */
97 + onHidden = (fn) => {
98 + this.hidden = fn;
99 + }
100 +}
101 +
102 +export default MonitorKeyboard
1 +/*
2 + * @Author: hookehuyr hookehuyr@gmail.com
3 + * @Date: 2022-05-28 10:17:40
4 + * @LastEditors: hookehuyr hookehuyr@gmail.com
5 + * @LastEditTime: 2024-09-03 16:01:59
6 + * @FilePath: /vue2_vite_web/src/utils/axios.js
7 + * @Description:
8 + */
9 +import axios from 'axios';
10 +import router from '@/router';
11 +import qs from 'Qs'
12 +import { strExist } from '@/utils/tools'
13 +// import { parseQueryString } from '@/utils/tools'
14 +
15 +axios.defaults.params = {
16 + f: 'tools',
17 +};
18 +
19 +/**
20 + * @description 请求拦截器
21 + */
22 +axios.interceptors.request.use(
23 + config => {
24 + // const url_params = parseQueryString(location.href);
25 + // GET请求默认打上时间戳,避免从缓存中拿数据。
26 + const timestamp = config.method === 'get' ? (new Date()).valueOf() : '';
27 + /**
28 + * POST PHP需要修改数据格式
29 + * 序列化POST请求时需要屏蔽上传相关接口,上传相关接口序列化后报错
30 + */
31 + config.data = config.method === 'post' && !strExist(['a=upload', 'upload.qiniup.com'], config.url) ? qs.stringify(config.data) : config.data;
32 + // 绑定默认请求头
33 + config.params = { ...config.params, timestamp }
34 + return config;
35 + },
36 + error => {
37 + // 请求错误处理
38 + return Promise.reject(error);
39 + });
40 +
41 +/**
42 + * @description 响应拦截器
43 + */
44 +axios.interceptors.response.use(
45 + response => {
46 + // 默认显示错误提示
47 + response.data.show = true;
48 + if (response.data.code === 401) {
49 + // 特殊标识-带此标识报错不显示
50 + response.data.show = false;
51 + /**
52 + * 未授权跳转登录页
53 + * 带着上一个页面的信息, 授权完成后 返回当前页面
54 + */
55 + router.replace({ path: '/auth', query: { href: location.hash, prefixAPI } });
56 + }
57 + return response;
58 + },
59 + error => {
60 + return Promise.reject(error);
61 + });
62 +
63 +export default axios;
1 +/*
2 + * @Date: 2022-05-16 17:21:45
3 + * @LastEditors: hookehuyr hookehuyr@gmail.com
4 + * @LastEditTime: 2022-06-29 17:00:15
5 + * @FilePath: /tswj/src/utils/generateRoute.js
6 + * @Description: 文件描述
7 + */
8 +
9 +/**
10 + * 根据后台返回的路径,生成页面的组件模版
11 + * @param {*} component
12 + * @returns 模版地址
13 + */
14 +function loadView(component) {
15 + return () => import(`../views/${component}.vue`)
16 +}
17 +
18 +/**
19 + * 生成路由结构
20 + * @param {*} routes
21 + */
22 +const generateRoutes = (routes) => {
23 + const arr = []
24 + routes.forEach(route => {
25 + const router = {}
26 + const {
27 + path,
28 + redirect,
29 + name,
30 + component,
31 + keepAlive,
32 + meta,
33 + children
34 + } = route
35 +
36 + router.path = path
37 + redirect && (router.redirect = redirect)
38 + name && (router.name = name)
39 + router.component = loadView(component)
40 + keepAlive && (router.keepAlive = keepAlive)
41 + meta && (router.meta = meta)
42 + router.children = !Array.isArray(children) || generateRoutes(children);
43 + arr.push(router)
44 + })
45 + return arr
46 +}
47 +
48 +export default generateRoutes;
1 +import wx from 'weixin-js-sdk'
2 +import axios from '@/utils/axios';
3 +
4 +const fn = (to) => {
5 + // 路由名
6 + let ruleName = location.href.split('#/')[1].split('?')[0];
7 +
8 + const icon = 'https://cdn.lifeat.cn/webappgroup/betterLifelogo.png'
9 +
10 + const shareInfoMap = {
11 + 'client/index': {
12 + title: '童声无界',
13 + desc: '引导页',
14 + icon
15 + },
16 + 'client/chooseSchool': {
17 + title: '选择幼儿园',
18 + desc: '引导页',
19 + icon
20 + },
21 + default: {
22 + title: to.name,
23 + desc: window.location.href,
24 + icon
25 + },
26 + }
27 + let infoMap = shareInfoMap[ruleName] ? shareInfoMap[ruleName] : shareInfoMap['default'];
28 + // console.warn(ruleName);
29 + console.warn(infoMap);
30 + console.warn(wx);
31 + console.warn(axios);
32 +}
33 +export default fn
34 +// 这个判断后加的为了减少请求次数,据后端说有次数限制,当需要分享的页面才去请求接口。
35 +// if (shareInfoMap[ruleName]) {
36 +// // request 是封装的请求
37 +// request.post('/wxmp/sign/jsSdk', {
38 +// url: location.href,
39 +// }).then(res => {
40 +// let { timestamp, nonceStr, signature, appId } = res;
41 +// wx.config({
42 +// debug: false,
43 +// appId,
44 +// timestamp,
45 +// nonceStr,
46 +// signature,
47 +// jsApiList: ['updateAppMessageShareData', 'updateTimelineShareData']
48 +// });
49 +// wx.error(function (errres) {
50 +// console.info(errres)
51 +// })
52 +// wx.ready(() => { //需在用户可能点击分享按钮前就先调用
53 +// console.info('ready')
54 +// //分享朋友
55 +// wx.updateAppMessageShareData({
56 +// title: infoMap.title, // 分享标题
57 +// desc: infoMap.desc, // 分享描述
58 +// link: location.href, // 分享链接,该链接域名或路径必须与当前页面对应的公众号JS安全域名一致
59 +// imgUrl: infoMap.icon, // 分享图标
60 +// success: function () {
61 +// console.info("成功")
62 +// // 设置成功
63 +// },
64 +// fail: function (erres) {
65 +// console.info('失败:', erres)
66 +// }
67 +// })
68 +// //分享到 朋友圈
69 +// wx.updateTimelineShareData({
70 +// title: infoMap.title, // 分享标题
71 +// link: location.href, // 分享链接,该链接域名或路径必须与当前页面对应的公众号JS安全域名一致
72 +// imgUrl: infoMap.icon, // 分享图标
73 +// success: function () {
74 +// console.info("成功")
75 +// // 设置成功
76 +// },
77 +// fail: function (erres) {
78 +// console.info('失败:', erres)
79 +// }
80 +// })
81 +// });
82 +// }).catch(err => {
83 +// console.info('err:', err)
84 +// })
85 +// }
...\ No newline at end of file ...\ No newline at end of file
1 +/*
2 + * @Date: 2022-04-18 15:59:42
3 + * @LastEditors: hookehuyr hookehuyr@gmail.com
4 + * @LastEditTime: 2023-08-07 13:31:59
5 + * @FilePath: /map-demo/src/utils/tools.js
6 + * @Description: 文件描述
7 + */
8 +import dayjs from 'dayjs';
9 +
10 +// 格式化时间
11 +const formatDate = (date) => {
12 + return dayjs(date).format('YYYY-MM-DD HH:mm');
13 +};
14 +
15 +/**
16 + * @description 判断浏览器属于平台
17 + * @returns
18 + */
19 +const wxInfo = () => {
20 + let u = navigator.userAgent;
21 + let isAndroid = u.indexOf('Android') > -1 || u.indexOf('Linux') > -1; //android终端或者uc浏览器
22 + let isiOS = !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/); //ios终端
23 + let uAgent = navigator.userAgent.toLowerCase();
24 + let isTable = (uAgent.match(/MicroMessenger/i) == 'micromessenger') ? true : false;
25 + let isPC = uAgent.match(
26 + /(phone|pad|pod|iPhone|iPod|ios|iPad|Android|Mobile|BlackBerry|IEMobile|MQQBrowser|JUC|Fennec|wOSBrowser|BrowserNG|WebOS|Symbian|Windows Phone|micromessenger)/i,
27 + )
28 + ? false
29 + : true;
30 + return {
31 + isAndroid,
32 + isiOS,
33 + isTable,
34 + isPC,
35 + };
36 +};
37 +
38 +/**
39 + * @description 判断多行省略文本
40 + * @param {*} id 目标dom标签
41 + * @returns
42 + */
43 +const hasEllipsis = (id) => {
44 + let oDiv = document.getElementById(id);
45 + let flag = false;
46 + if (oDiv.scrollHeight > oDiv.clientHeight) {
47 + flag = true
48 + }
49 + return flag
50 +}
51 +
52 +/**
53 + * @description 解析URL参数
54 + * @param {*} url
55 + * @returns
56 + */
57 +const parseQueryString = url => {
58 + var json = {};
59 + var arr = url.indexOf('?') >= 0 ? url.substr(url.indexOf('?') + 1).split('&') : [];
60 + arr.forEach(item => {
61 + var tmp = item.split('=');
62 + json[tmp[0]] = tmp[1];
63 + });
64 + return json;
65 +}
66 +
67 +/**
68 + * 字符串包含字符数组中字符的状态
69 + * @param {*} array 字符数组
70 + * @param {*} str 字符串
71 + * @returns 包含状态
72 + */
73 +const strExist = (array, str) => {
74 + const exist = array.filter(arr => {
75 + if (str.indexOf(arr) >= 0) return str;
76 + })
77 + return exist.length > 0
78 +}
79 +
80 +export { formatDate, wxInfo, hasEllipsis, parseQueryString, strExist };
1 +import VConsole from 'vconsole';
2 +
3 +// const vConsole = new VConsole();
4 +let vConsole = '';
5 +// 或者使用配置参数来初始化,详情见文档
6 +if (+import.meta.env.VITE_CONSOLE) {
7 + vConsole = new VConsole({ theme: 'dark' });
8 +}
9 +
10 +export default vConsole
1 +<!--
2 + * @Date: 2024-08-27 10:06:30
3 + * @LastEditors: hookehuyr hookehuyr@gmail.com
4 + * @LastEditTime: 2024-09-26 13:37:46
5 + * @FilePath: /hager/src/views/index.vue
6 + * @Description: 文件描述
7 +-->
8 +<template>
9 + <div></div>
10 +</template>
11 +
12 +<script>
13 +
14 +export default {
15 + components: {},
16 + data () {
17 + return {
18 + }
19 + },
20 + async mounted () {
21 + },
22 + methods: {
23 +
24 + }
25 +}
26 +</script>
27 +
28 +<style lang="less" scoped>
29 +</style>
1 +{
2 + "compilerOptions": {
3 + /* 基本选项 */
4 + "target": "esnext", // 指定 ECMAScript 目标版本: 'ES3' (default), 'ES5', 'ES6'/'ES2015', 'ES2016', 'ES2017', or 'ESNEXT'
5 + "module": "CommonJS", // 指定使用模块: 'commonjs', 'amd', 'system', 'umd' or 'es2015'
6 + "lib": [ // 指定要包含在编译中的库文件
7 + "esnext",
8 + "dom",
9 + "dom.iterable",
10 + "scripthost"
11 + ],
12 + "allowJs": true, // 允许编译 javascript 文件
13 + // "checkJs": true, // 报告 javascript 文件中的错误
14 + "jsx": "preserve", // 指定 jsx 代码的生成: 'preserve', 'react-native', or 'react'
15 + // "declaration": true, // 生成相应的 '.d.ts' 文件
16 + // "sourceMap": true, // 生成相应的 '.map' 文件
17 + // "outFile": "./", // 将输出文件合并为一个文件
18 + "outDir": "./", // 指定输出目录
19 + // "rootDir": "./", // 用来控制输出目录结构 --outDir.
20 + "removeComments": true, // 删除编译后的所有的注释
21 + // "noEmit": true, // 不生成输出文件
22 + "importHelpers": true, // tslib 导入辅助工具函数
23 + "isolatedModules": false, // 将每个文件做为单独的模块 (与 'ts.transpileModule' 类似)
24 +
25 + /* 严格的类型检查选项 */
26 + "strict": true, // 启用所有严格类型检查选项
27 + // "noImplicitAny": true, // 在表达式和声明上有隐含的 any类型时报错
28 + // "strictNullChecks": true, // 启用严格的 null 检查
29 + // "noImplicitThis": true, // this 表达式值为 any 类型的时候,生成一个错误
30 + // "alwaysStrict": true, // 以严格模式检查每个模块,并在每个文件里加入 'use strict'
31 +
32 + /* 额外的检查 */
33 + "noUnusedLocals": true, // 有未使用的变量时,抛出错误
34 + "noUnusedParameters": true, // 有未使用的参数时,抛出错误
35 + "noImplicitReturns": true, // 并不是所有函数里的代码都有返回值时,抛出错误
36 + "noFallthroughCasesInSwitch": true, // 报告 switch 语句的 fallthrough 错误。(即,不允许 switch case 语句贯穿)
37 +
38 + /* 模块解析选项 */
39 + "moduleResolution": "node", // 选择模块解析策略: 'node' (Node.js) or 'classic' (TypeScript pre-1.6)
40 + "baseUrl": ".", // 用于解析非相对模块名称的基目录
41 + "paths": { // 模块名到基于 baseUrl 的路径映射的列表
42 + "@/*": [
43 + "src/*"
44 + ]
45 + },
46 + // "rootDirs": [], // 根文件夹列表,其组合内容表示项目运行时的结构内容
47 + // "typeRoots": [], // 包含类型声明的文件列表
48 + "types": [ // 需要包含的类型声明文件名列表
49 + // "webpack-env",
50 + "vite/client",
51 + "lodash",
52 + "moment",
53 + "node",
54 + "jquery",
55 + ],
56 + "allowSyntheticDefaultImports": true, // 允许从没有设置默认导出的模块中默认导入。
57 +
58 + /* Source Map Options */
59 + // "sourceRoot": "./", // 指定调试器应该找到 TypeScript 文件而不是源文件的位置
60 + // "mapRoot": "./", // 指定调试器应该找到映射文件而不是生成文件的位置
61 + // "inlineSourceMap": true, // 生成单个 sourcemaps 文件,而不是将 sourcemaps 生成不同的文件
62 + // "inlineSources": true, // 将代码与 sourcemaps 生成到一个文件中,要求同时设置了 --inlineSourceMap --sourceMap 属性
63 +
64 + /* 其他选项 */
65 + // "experimentalDecorators": true, // 启用装饰器
66 + // "emitDecoratorMetadata": true, // 为装饰器提供元数据的支持
67 +
68 + "esModuleInterop": true, // 可以在es6中导入commonjs
69 + },
70 + "include": [
71 + "src/**/*"
72 + ],
73 + "exclude": [
74 + "node_modules",
75 + "dist"
76 + ],
77 + "vueCompilerOptions": {
78 + "target": 2,
79 + "experimentalSuppressInvalidJsxElementTypeErrors": true
80 + }
81 +}
1 +/*
2 + * @Date: 2024-08-26 10:12:56
3 + * @LastEditors: hookehuyr hookehuyr@gmail.com
4 + * @LastEditTime: 2024-08-29 17:50:26
5 + * @FilePath: /vue2_vite_web/vite.config.js
6 + * @Description: 文件描述
7 + */
8 +// import vue from '@vitejs/plugin-vue'
9 +import vue from "@vitejs/plugin-vue2";
10 +import legacy from "@vitejs/plugin-legacy";
11 +import dynamicImport from 'vite-plugin-dynamic-import';
12 +import { defineConfig, loadEnv } from 'vite';
13 +import { createProxy } from './build/proxy'
14 +
15 +// var path = require('path');
16 +import path from 'path-browserify';
17 +// const fs = require('fs');
18 +
19 +// https://vitejs.dev/config/
20 +export default ({ command, mode }) => {
21 +const root = process.cwd();
22 +
23 +const viteEnv = loadEnv(mode, root);
24 +// let isProd = (command === 'serve'); // 情景配置是否为开发模式 serve 或 build
25 +
26 +return defineConfig({
27 + base: viteEnv.VITE_BASE, // 开发或生产环境服务的公共基础路径。
28 + plugins: [
29 + vue(),
30 + legacy({
31 + targets: ["android 4", "ios 8", "chrome 52", "ie 11"],
32 + additionalLegacyPolyfills: ["regenerator-runtime/runtime"],
33 + renderLegacyChunks: true,
34 + polyfills: [
35 + "es.symbol",
36 + "es.array.filter",
37 + "es.promise",
38 + "es.promise.finally",
39 + "es/map",
40 + "es/set",
41 + "es.array.for-each",
42 + "es.object.define-properties",
43 + "es.object.define-property",
44 + "es.object.get-own-property-descriptor",
45 + "es.object.get-own-property-descriptors",
46 + "es.object.keys",
47 + "es.object.to-string",
48 + "web.dom-collections.for-each",
49 + "esnext.global-this",
50 + "esnext.string.match-all",
51 + ],
52 + }),
53 + dynamicImport(),
54 + ],
55 + publicDir: 'public', // 作为静态资源服务的文件夹。这个目录中的文件会在开发中被服务于 /,在开发模式时,会被拷贝到 outDir 的根目录,并没有转换,永远只是复制到这里。该值可以是文件系统的绝对路径,也可以是相对于项目的根目录路径。
56 + // cacheDir: '', // 存储缓存文件的目录。此目录下会存储预打包的依赖项或 vite 生成的某些缓存文件,使用缓存可以提高性能。如需重新生成缓存文件,你可以使用 --force 命令行选项或手动删除目录。此选项的值可以是文件的绝对路径,也可以是以项目根目录为基准的相对路径。
57 + resolve: {
58 + alias: {
59 + // 将会被传递到 @rollup/plugin-alias 作为 entries 的选项。也可以是一个对象,或一个 { find, replacement } 的数组. 当使用文件系统路径的别名时,请始终使用绝对路径。相对路径的别名值会被原封不动地使用,因此无法被正常解析。 更高级的自定义解析方法可以通过 插件 实现。
60 + '@': path.resolve(__dirname, 'src'),
61 + '@components': path.resolve(__dirname, 'src/components'),
62 + '@composables': path.resolve(__dirname, 'src/composables'),
63 + '@utils': path.resolve(__dirname, 'src/utils'),
64 + '@images': path.resolve(__dirname, 'src/assets/images'),
65 + '@css': path.resolve(__dirname, 'src/assets/css'),
66 + '@mock': path.resolve(__dirname, 'src/assets/mock'),
67 + common: path.resolve(__dirname, 'src/common'),
68 + },
69 + // dedupe: [''], // 如果你在你的应用程序中有相同依赖的副本(比如 monorepos),使用这个选项来强制 Vite 总是将列出的依赖关系解析到相同的副本(从项目根目录)。
70 + // conditions: [''], // 在解析包的 情景导出 时允许的附加条件。
71 + // mainFields: [''], // package.json 中,在解析包的入口点时尝试的字段列表。注意,这比从 exports 字段解析的情景导出优先级低:如果一个入口点从 exports 成功解析,主字段将被忽略。
72 + extensions: ['.mjs', '.js', '.ts', '.jsx', '.tsx', '.json', '.vue'], // 导入时想要省略的扩展名列表。注意,不 建议忽略自定义导入类型的扩展名(例如:.vue),因为它会干扰 IDE 和类型支持。
73 + },
74 + logLevel: 'info', // 调整控制台输出的级别,默认为 'info'。
75 + // clearScreen: true, // 设为 false 可以避免 Vite 清屏而错过在终端中打印某些关键信息。命令行模式下请通过 --clearScreen false 设置。
76 + server: {
77 + host: '0.0.0.0',
78 + port: viteEnv.VITE_PORT, // 本地服务端口
79 + // strictPort: true, // 设为true时若端口已被占用则会直接退出, 而不是尝试下一个可用端口
80 + // https: {
81 + // key: fs.readFileSync(path.resolve(__dirname, 'keys/localhost+2-key.pem')),
82 + // cert: fs.readFileSync(path.resolve(__dirname, 'keys/localhost+2.pem')),
83 + // },
84 + // open: false, // 在服务器启动时自动在浏览器中打开应用程序. 当此值为字符串时, 会被当作URL的路径名.
85 + // proxy: { // 代理
86 + // '/srv/': {
87 + // // target: 'http://voice.onwall.cn',
88 + // target: viteEnv.VITE_PROXY_TARGET,
89 + // changeOrigin: true,
90 + // // rewrite: (path) => path.replace(/^\/api/, '')
91 + // },
92 + // },
93 + proxy: createProxy(viteEnv.VITE_PROXY_PREFIX, viteEnv.VITE_PROXY_TARGET),
94 + // cors: '', // 为开发服务器配置 CORS。默认启用并允许任何源,传递一个 选项对象 来调整行为或设为 false 表示禁用。
95 + // force: '', // 设置为 true 强制使依赖预构建。
96 + // hmr: '', // 禁用或配置 HMR 连接(用于 HMR websocket 必须使用不同的 http 服务器地址的情况)。 设置 server.hmr.overlay 为 false 可以禁用服务器错误遮罩层。
97 + // watch: '', // 传递给 chokidar 的文件系统监视器选项。
98 + },
99 + build: {
100 + // outDir: 'voice', // 指定输出路径(相对于项目根目录).
101 + outDir: viteEnv.VITE_OUTDIR, // 指定输出路径(相对于项目根目录).
102 + assetsDir: 'static',
103 + rollupOptions: {
104 + output: {
105 + chunkFileNames: 'static/js/[name]-[hash].js',
106 + entryFileNames: 'static/js/[name]-[hash].js',
107 + assetFileNames: 'static/[ext]/[name]-[hash].[ext]',
108 + },
109 + input: {
110 + // 多页面应用模式, 打包时配置,运行配置要处理root
111 + main: path.resolve(__dirname, 'index.html'),
112 + // mono1: path.resolve(__dirname, 'src/packages/mono1/index.html'),
113 + // mono2: path.resolve(__dirname, 'src/packages/mono2/index.html'),
114 + },
115 + },
116 + target: 'es2015'
117 + },
118 +});
119 +};
This diff could not be displayed because it is too large.