Compare commits

...

5 Commits

Author SHA1 Message Date
2c43a14e38 1 2025-05-09 11:05:18 +08:00
a7c06b3a0e 1 2025-05-09 09:20:07 +08:00
f4cdf700f2 1 2025-05-09 09:19:39 +08:00
dacfe9a035 1 2025-05-09 09:14:07 +08:00
14bbe24343 1 2025-05-08 18:26:27 +08:00
38 changed files with 2088 additions and 8160 deletions

BIN
pages/.DS_Store vendored

Binary file not shown.

BIN
pages/index/.DS_Store vendored

Binary file not shown.

File diff suppressed because it is too large Load Diff

79
pages/index/utils.js Normal file
View File

@ -0,0 +1,79 @@
import { ref, onMounted, onUnmounted } from 'vue'
export function useElementSize(targetSelector) {
const width = ref(0)
const height = ref(0)
let observer = null
const updateSize = () => {
const query = uni.createSelectorQuery()
query.select(targetSelector).boundingClientRect(rect => {
if (rect) {
width.value = rect.width
height.value = rect.height
}
}).exec()
}
onMounted(() => {
updateSize()
// 尝试使用 ResizeObserver部分小程序基础库支持
if (uni.createIntersectionObserver) {
observer = uni.createIntersectionObserver(this, {
observeAll: true
})
observer.relativeToViewport().observe(targetSelector, updateSize)
}
})
onUnmounted(() => {
observer?.disconnect()
})
return { width, height, updateSize }
}
export function useEventListener(target, event, handler) {
// 组件内事件
if (target.$on) {
target.$on(event, handler)
const stop = () => target.$off(event, handler)
onUnmounted(stop)
return stop
}
// 全局事件(需配合 uni.$emit 使用)
else {
uni.$on(event, handler)
const stop = () => uni.$off(event, handler)
onUnmounted(stop)
return stop
}
}
export function useRafFn(fn, { immediate = true } = {}) {
let isActive = false
let timerId = null
const loop = () => {
if (!isActive) return
fn()
timerId = setTimeout(loop, 16) // 模拟 60fps
}
const start = () => {
if (isActive) return
isActive = true
loop()
}
const stop = () => {
isActive = false
clearTimeout(timerId)
}
onUnmounted(stop)
immediate && start()
return { start, stop }
}

View File

@ -1 +0,0 @@
{"version":3,"names":[],"sources":[],"sourcesContent":[],"mappings":";","ignoreList":[]}

View File

@ -1 +0,0 @@
{"version":3,"names":["wx","createPage","index","MiniProgramPage"],"sources":["cGFnZXMvaW5kZXgvaW5kZXgudnVl"],"sourcesContent":["import MiniProgramPage from 'C:/Users/hp/Desktop/app/canvas/pages/index/index.vue'\nwx.createPage(MiniProgramPage)"],"mappings":";;;;AACAA,EAAA,CAAGC,UAAA,CAAWC,KAAA,CAAeC,eAAA","ignoreList":[]}

View File

@ -1 +0,0 @@
{"version":3,"file":"app.js","sources":["App.vue"],"sourcesContent":["<script>\n\texport default {\n\t\tonLaunch: function() {\n\t\t\tconsole.log('App Launch')\n\t\t},\n\t\tonShow: function() {\n\t\t\tconsole.log('App Show')\n\t\t},\n\t\tonHide: function() {\n\t\t\tconsole.log('App Hide')\n\t\t}\n\t}\n</script>\n\n<style>\n\t/*每个页面公共css */\n</style>\n"],"names":["uni"],"mappings":";;;;;;;;AACC,MAAK,YAAU;AAAA,EACd,UAAU,WAAW;AACpBA,kBAAAA,MAAY,MAAA,OAAA,gBAAA,YAAY;AAAA,EACxB;AAAA,EACD,QAAQ,WAAW;AAClBA,kBAAAA,MAAY,MAAA,OAAA,gBAAA,UAAU;AAAA,EACtB;AAAA,EACD,QAAQ,WAAW;AAClBA,kBAAAA,MAAY,MAAA,OAAA,iBAAA,UAAU;AAAA,EACvB;AACD;;;;;;;;;"}

View File

@ -1 +0,0 @@
{"version":3,"file":"assets.js","sources":["static/logo.png"],"sourcesContent":["export default \"__VITE_ASSET__46719607__\""],"names":[],"mappings":";AAAA,MAAe,aAAA;;"}

File diff suppressed because one or more lines are too long

View File

@ -1 +0,0 @@
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}

View File

@ -1 +0,0 @@
{"version":3,"file":"index.js","sources":["pages/index/index.vue?type=page"],"sourcesContent":["import MiniProgramPage from '/Users/sunmeng/Desktop/canvas/pages/index/index.vue'\nwx.createPage(MiniProgramPage)"],"names":["MiniProgramPage"],"mappings":";;AACA,GAAG,WAAWA,MAAe,eAAA;"}

View File

@ -1 +0,0 @@
{"version":3,"file":"index2.js","sources":["/Users/sunmeng/Desktop/canvas/pages/index/index.vue?type=page"],"sourcesContent":["import MiniProgramPage from '/Users/sunmeng/Desktop/canvas/pages/index/index.vue'\nwx.createPage(MiniProgramPage)"],"names":["MiniProgramPage"],"mappings":";;AACA,GAAG,WAAWA,MAAe,eAAA;"}

View File

@ -1 +0,0 @@
{"version":3,"file":"indexFu.js","sources":["pages/index/indexFu.vue","../../HBuilderX/plugins/uniapp-cli-vite/uniPage:/cGFnZXMvaW5kZXgvaW5kZXhGdS52dWU"],"sourcesContent":["<template>\r\n\t<view>\r\n\t<indexZi></indexZi>\r\n\t</view>\r\n</template>\r\n\r\n<script setup>\r\n\timport indexZi from \"./index.vue\" \r\n\timport {\r\n\t\tref\r\n\t} from 'vue'\r\n\r\n</script>\r\n\r\n<style scoped>\r\n\r\n</style>","import MiniProgramPage from 'C:/Users/hp/Desktop/app/canvas/pages/index/indexFu.vue'\nwx.createPage(MiniProgramPage)"],"names":["MiniProgramPage"],"mappings":";;;;;AAOC,MAAM,UAAU,MAAW;;;;;;;;;ACN5B,GAAG,WAAWA,SAAe;"}

View File

@ -1 +0,0 @@
{"version":3,"file":"index_step4.js","sources":["pages/index/index_step4.vue?type=page"],"sourcesContent":["import MiniProgramPage from '/Users/sunmeng/Desktop/canvas/pages/index/index_step4.vue'\nwx.createPage(MiniProgramPage)"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,GAAG,WAAW,eAAe;"}

View File

@ -1 +0,0 @@
{"version":3,"file":"step2.js","sources":["pages/index/step2.vue?type=page"],"sourcesContent":["import MiniProgramPage from '/Users/sunmeng/Desktop/canvas/pages/index/step2.vue'\nwx.createPage(MiniProgramPage)"],"names":["MiniProgramPage"],"mappings":";;;;;;;;;;;;;;AACA,GAAG,WAAWA,SAAe;"}

View File

@ -1 +0,0 @@
{"version":3,"file":"canvas.js","sources":["static/canvas.jpg"],"sourcesContent":["export default \"__VITE_ASSET__72ea9485__\""],"names":[],"mappings":";;AAAA,MAAe,SAAA;;"}

View File

@ -1,28 +0,0 @@
"use strict";
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
const common_vendor = require("./common/vendor.js");
if (!Math) {
"./pages/index/index_step4.js";
"./pages/index/step2.js";
"./pages/index/index.js";
}
const _sfc_main = {
onLaunch: function() {
common_vendor.index.__f__("log", "at App.vue:4", "App Launch");
},
onShow: function() {
common_vendor.index.__f__("log", "at App.vue:7", "App Show");
},
onHide: function() {
common_vendor.index.__f__("log", "at App.vue:10", "App Hide");
}
};
function createApp() {
const app = common_vendor.createSSRApp(_sfc_main);
return {
app
};
}
createApp().app.mount("#app");
exports.createApp = createApp;
//# sourceMappingURL=../.sourcemap/mp-weixin/app.js.map

View File

@ -1,14 +0,0 @@
{
"pages": [
"pages/index/index_step4",
"pages/index/step2",
"pages/index/index"
],
"window": {
"navigationBarTextStyle": "black",
"navigationBarTitleText": "uni-app",
"navigationBarBackgroundColor": "#F8F8F8",
"backgroundColor": "#F8F8F8"
},
"usingComponents": {}
}

View File

@ -1,3 +0,0 @@
/*每个页面公共css */
page{--status-bar-height:25px;--top-window-height:0px;--window-top:0px;--window-bottom:0px;--window-left:0px;--window-right:0px;--window-magin:0px}[data-c-h="true"]{display: none !important;}

File diff suppressed because it is too large Load Diff

View File

@ -1,93 +0,0 @@
"use strict";
const common_vendor = require("./common/vendor.js");
const _sfc_main = {
__name: "index",
setup(__props) {
common_vendor.ref(375);
common_vendor.ref(400);
const instance = common_vendor.getCurrentInstance();
const scale = common_vendor.ref(1);
const offsetX = common_vendor.ref(0);
const offsetY = common_vendor.ref(0);
const lastDistance = common_vendor.ref(-1);
const startX = common_vendor.ref(0);
const startY = common_vendor.ref(0);
const isDragging = common_vendor.ref(false);
const imgUrl = common_vendor.ref("https://assets.sx25.troyrc.com/sx25/images/events/XBDT.jpg");
async function draw() {
const ctx = common_vendor.index.createCanvasContext("canvas", instance);
ctx.save();
ctx.translate(offsetX.value, offsetY.value);
ctx.scale(scale.value, scale.value);
const res = await common_vendor.index.getImageInfo({ src: imgUrl.value });
ctx.drawImage(res.path, 0, 0);
ctx.restore();
ctx.draw();
}
const handleTouchStart = (e) => {
common_vendor.index.__f__("log", "at pages/index/index.vue:103", "handleTouchStart");
if (e.touches.length === 1) {
startX.value = e.touches[0].clientX - offsetX.value;
startY.value = e.touches[0].clientY - offsetY.value;
isDragging.value = true;
} else if (e.touches.length === 2) {
const x1 = e.touches[0].clientX;
const y1 = e.touches[0].clientY;
const x2 = e.touches[1].clientX;
const y2 = e.touches[1].clientY;
lastDistance.value = Math.sqrt(Math.pow(x2 - x1, 2) + Math.pow(y2 - y1, 2));
}
};
const handleTouchMove = (e) => {
if (e.touches.length === 1 && isDragging.value) {
offsetX.value = e.touches[0].clientX - startX.value;
offsetY.value = e.touches[0].clientY - startY.value;
} else if (e.touches.length === 2) {
const x1 = e.touches[0].clientX, y1 = e.touches[0].clientY;
const x2 = e.touches[1].clientX, y2 = e.touches[1].clientY;
const distance = Math.sqrt(Math.pow(x2 - x1, 2) + Math.pow(y2 - y1, 2));
if (lastDistance.value > 0) {
scale.value = Math.min(Math.max(scale.value * (distance / lastDistance.value), 0.5), 4);
draw();
}
lastDistance.value = distance;
}
};
const handleTouchEnd = () => {
common_vendor.index.__f__("log", "at pages/index/index.vue:167", "handleTouchEnd");
lastDistance.value = -1;
isDragging.value = false;
};
const handleDraw = () => {
draw();
};
common_vendor.onReady(() => {
common_vendor.index.__f__("log", "at pages/index/index.vue:184", "onReadyonReady");
common_vendor.index.downloadFile({
url: imgUrl.value,
success: function(sres) {
common_vendor.index.__f__("log", "at pages/index/index.vue:188", sres, "sres");
imgUrl.value = sres.tempFilePath || sres.path;
draw();
},
fail: function(fres) {
common_vendor.index.__f__("log", "at pages/index/index.vue:194", "fres", fres);
}
});
});
return (_ctx, _cache) => {
return {
a: common_vendor.o(handleTouchStart),
b: common_vendor.o(handleTouchMove),
c: common_vendor.o(handleTouchEnd),
d: "1000px",
e: "800px",
f: `translate(${offsetX.value}px, ${offsetY.value}px) scale(${scale.value})`,
g: common_vendor.o(handleDraw)
};
};
}
};
const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__scopeId", "data-v-1cf27b2a"]]);
exports.MiniProgramPage = MiniProgramPage;
//# sourceMappingURL=../.sourcemap/mp-weixin/index.js.map

View File

@ -1,4 +0,0 @@
"use strict";
const index = require("../../index.js");
wx.createPage(index.MiniProgramPage);
//# sourceMappingURL=../../../.sourcemap/mp-weixin/pages/index/index.js.map

View File

@ -1,4 +0,0 @@
{
"navigationBarTitleText": "uni-app",
"usingComponents": {}
}

View File

@ -1 +0,0 @@
<view class="data-v-1cf27b2a"><block wx:if="{{r0}}"><canvas class="data-v-1cf27b2a" bindtouchstart="{{a}}" bindtouchmove="{{b}}" bindtouchend="{{c}}" style="{{'width:' + d + ';' + ('height:' + e) + ';' + ('transform:' + f)}}" canvas-id="canvas" id="canvas"></canvas></block><image class="data-v-1cf27b2a" src="https://assets.sx25.troyrc.com/sx25/images/events/XBDT.jpg"></image><button class="data-v-1cf27b2a" bindtap="{{g}}">点击绘制圆形</button></view>

View File

@ -1,4 +0,0 @@
button.data-v-1cf27b2a {
margin-top: 10px;
}

View File

@ -1,4 +0,0 @@
"use strict";
const index = require("../../index.js");
wx.createPage(index.MiniProgramPage);
//# sourceMappingURL=../../../.sourcemap/mp-weixin/pages/index/index2.js.map

View File

@ -1,42 +0,0 @@
"use strict";
const common_vendor = require("../../common/vendor.js");
const _sfc_main = {
__name: "index_step4",
setup(__props) {
const canvasWidth = common_vendor.ref(200);
const canvasHeight = common_vendor.ref(200);
const instance = common_vendor.getCurrentInstance();
function draw() {
const ctx = common_vendor.index.createCanvasContext("canvas", instance);
common_vendor.index.__f__("log", "at pages/index/index_step4.vue:20", ctx, "12");
ctx.beginPath();
ctx.arc(100, 100, 80, 0, Math.PI * 2);
ctx.setFillStyle("rgba(100, 220, 0, 1)");
ctx.fill();
ctx.beginPath();
ctx.arc(100, 100, 75, 0, Math.PI * 2);
ctx.setFillStyle("white");
ctx.fill();
ctx.draw();
}
const handleDraw = () => {
common_vendor.index.navigateTo({
url: "/pages/index/step2"
});
draw();
};
common_vendor.onMounted(() => {
draw();
});
return (_ctx, _cache) => {
return {
a: canvasWidth.value,
b: canvasHeight.value,
c: common_vendor.o(handleDraw)
};
};
}
};
const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__scopeId", "data-v-7e4ca425"]]);
wx.createPage(MiniProgramPage);
//# sourceMappingURL=../../../.sourcemap/mp-weixin/pages/index/index_step4.js.map

View File

@ -1,4 +0,0 @@
{
"navigationBarTitleText": "step",
"usingComponents": {}
}

View File

@ -1 +0,0 @@
<view class="data-v-7e4ca425"><canvas class="data-v-7e4ca425" canvas-id="canvas" id="canvas" style="width:200px;height:200px;border:1px solid red" width="{{a}}" height="{{b}}"></canvas><button class="data-v-7e4ca425" bindtap="{{c}}">跳转step2</button></view>

View File

@ -1,4 +0,0 @@
button.data-v-7e4ca425 {
margin-top: 10px;
}

View File

@ -1,16 +0,0 @@
"use strict";
require("../../common/vendor.js");
if (!Math) {
indexstep2();
}
const indexstep2 = () => "./index2.js";
const _sfc_main = {
__name: "step2",
setup(__props) {
return (_ctx, _cache) => {
return {};
};
}
};
wx.createPage(_sfc_main);
//# sourceMappingURL=../../../.sourcemap/mp-weixin/pages/index/step2.js.map

View File

@ -1,6 +0,0 @@
{
"navigationBarTitleText": "fu",
"usingComponents": {
"indexstep2": "./index"
}
}

View File

@ -1 +0,0 @@
<view><indexstep2 u-i="4f007cb8-0" bind:__l="__l"></indexstep2></view>

View File

@ -1,29 +0,0 @@
{
"description": "项目配置文件。",
"packOptions": {
"ignore": [],
"include": []
},
"setting": {
"urlCheck": false,
"es6": true,
"postcss": false,
"minified": false,
"newFeature": true,
"bigPackageSizeSupport": true,
"babelSetting": {
"ignore": [],
"disablePlugins": [],
"outputPath": ""
}
},
"compileType": "miniprogram",
"libVersion": "3.8.3",
"appid": "wx5c9edf82da6032c4",
"projectname": "canvas",
"condition": {},
"editorSetting": {
"tabIndent": "insertSpaces",
"tabSize": 4
}
}

View File

@ -1,8 +0,0 @@
{
"description": "项目私有配置文件。此文件中的内容将覆盖 project.config.json 中的相同字段。项目的改动优先同步到此文件中。详见文档https://developers.weixin.qq.com/miniprogram/dev/devtools/projectconfig.html",
"projectname": "canvas",
"setting": {
"compileHotReLoad": true,
"urlCheck": false
}
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 191 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.9 KiB