@sbs-plugin/vue2-image-process 0.0.8 → 0.0.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/demo.html +1 -1
- package/dist/{vue2-image-processing.common.js → vue2-image-process.common.js} +847 -127
- package/dist/vue2-image-process.css +1 -0
- package/dist/{vue2-image-processing.umd.js → vue2-image-process.umd.js} +847 -127
- package/dist/vue2-image-process.umd.min.js +1 -0
- package/package.json +3 -3
- package/dist/vue2-image-processing.css +0 -1
- package/dist/vue2-image-processing.umd.min.js +0 -1
|
@@ -3543,7 +3543,7 @@ if (typeof window !== 'undefined') {
|
|
|
3543
3543
|
// Indicate to webpack that this file can be concatenated
|
|
3544
3544
|
/* harmony default export */ var setPublicPath = (null);
|
|
3545
3545
|
|
|
3546
|
-
;// ./node_modules/.pnpm/thread-loader@3.0.4_webpack@5.99.9/node_modules/thread-loader/dist/cjs.js!./node_modules/.pnpm/babel-loader@8.4.1_@babel+core@7.27.4_webpack@5.99.9/node_modules/babel-loader/lib/index.js??clonedRuleSet-40.use[1]!./node_modules/.pnpm/vue-loader@15.11.1_@vue+compiler-sfc@3.5.16_css-loader@6.11.0_webpack@5.99.9__lodash@4.17.21__w7knhy35vnjmebqosxmmnor4uq/node_modules/vue-loader/lib/loaders/templateLoader.js??ruleSet[1].rules[3]!./node_modules/.pnpm/vue-loader@15.11.1_@vue+compiler-sfc@3.5.16_css-loader@6.11.0_webpack@5.99.9__lodash@4.17.21__w7knhy35vnjmebqosxmmnor4uq/node_modules/vue-loader/lib/index.js??vue-loader-options!./src/components/
|
|
3546
|
+
;// ./node_modules/.pnpm/thread-loader@3.0.4_webpack@5.99.9/node_modules/thread-loader/dist/cjs.js!./node_modules/.pnpm/babel-loader@8.4.1_@babel+core@7.27.4_webpack@5.99.9/node_modules/babel-loader/lib/index.js??clonedRuleSet-40.use[1]!./node_modules/.pnpm/vue-loader@15.11.1_@vue+compiler-sfc@3.5.16_css-loader@6.11.0_webpack@5.99.9__lodash@4.17.21__w7knhy35vnjmebqosxmmnor4uq/node_modules/vue-loader/lib/loaders/templateLoader.js??ruleSet[1].rules[3]!./node_modules/.pnpm/vue-loader@15.11.1_@vue+compiler-sfc@3.5.16_css-loader@6.11.0_webpack@5.99.9__lodash@4.17.21__w7knhy35vnjmebqosxmmnor4uq/node_modules/vue-loader/lib/index.js??vue-loader-options!./src/components/ImageMatting.vue?vue&type=template&id=4def8405&scoped=true
|
|
3547
3547
|
var render = function render() {
|
|
3548
3548
|
var _vm = this,
|
|
3549
3549
|
_c = _vm._self._c;
|
|
@@ -7686,7 +7686,7 @@ axios.default = axios;
|
|
|
7686
7686
|
// EXTERNAL MODULE: ./node_modules/.pnpm/lz-string@1.5.0/node_modules/lz-string/libs/lz-string.js
|
|
7687
7687
|
var lz_string = __webpack_require__(8878);
|
|
7688
7688
|
var lz_string_default = /*#__PURE__*/__webpack_require__.n(lz_string);
|
|
7689
|
-
;// ./node_modules/.pnpm/thread-loader@3.0.4_webpack@5.99.9/node_modules/thread-loader/dist/cjs.js!./node_modules/.pnpm/babel-loader@8.4.1_@babel+core@7.27.4_webpack@5.99.9/node_modules/babel-loader/lib/index.js??clonedRuleSet-40.use[1]!./node_modules/.pnpm/vue-loader@15.11.1_@vue+compiler-sfc@3.5.16_css-loader@6.11.0_webpack@5.99.9__lodash@4.17.21__w7knhy35vnjmebqosxmmnor4uq/node_modules/vue-loader/lib/index.js??vue-loader-options!./src/components/
|
|
7689
|
+
;// ./node_modules/.pnpm/thread-loader@3.0.4_webpack@5.99.9/node_modules/thread-loader/dist/cjs.js!./node_modules/.pnpm/babel-loader@8.4.1_@babel+core@7.27.4_webpack@5.99.9/node_modules/babel-loader/lib/index.js??clonedRuleSet-40.use[1]!./node_modules/.pnpm/vue-loader@15.11.1_@vue+compiler-sfc@3.5.16_css-loader@6.11.0_webpack@5.99.9__lodash@4.17.21__w7knhy35vnjmebqosxmmnor4uq/node_modules/vue-loader/lib/index.js??vue-loader-options!./src/components/ImageMatting.vue?vue&type=script&lang=js
|
|
7690
7690
|
|
|
7691
7691
|
|
|
7692
7692
|
|
|
@@ -7696,8 +7696,8 @@ const requestUrl = {
|
|
|
7696
7696
|
fakeSegment: `https://apollo.51kandianshi.com/imageaicutout/sam/api/segment`,
|
|
7697
7697
|
API_IMG: `https://outerh5.51kandianshi.com/staticsaicoutout`
|
|
7698
7698
|
};
|
|
7699
|
-
/* harmony default export */ var
|
|
7700
|
-
name:
|
|
7699
|
+
/* harmony default export */ var ImageMattingvue_type_script_lang_js = ({
|
|
7700
|
+
name: "ImageMatting",
|
|
7701
7701
|
props: {
|
|
7702
7702
|
visible: {
|
|
7703
7703
|
type: Boolean,
|
|
@@ -7705,13 +7705,13 @@ const requestUrl = {
|
|
|
7705
7705
|
},
|
|
7706
7706
|
src: {
|
|
7707
7707
|
type: String,
|
|
7708
|
-
default:
|
|
7708
|
+
default: ""
|
|
7709
7709
|
}
|
|
7710
7710
|
},
|
|
7711
7711
|
data() {
|
|
7712
7712
|
return {
|
|
7713
|
-
workspaceSrc:
|
|
7714
|
-
path:
|
|
7713
|
+
workspaceSrc: this.src,
|
|
7714
|
+
path: "",
|
|
7715
7715
|
loading: false,
|
|
7716
7716
|
imgRef: null,
|
|
7717
7717
|
canvasRef: null,
|
|
@@ -7720,89 +7720,86 @@ const requestUrl = {
|
|
|
7720
7720
|
w: 0,
|
|
7721
7721
|
h: 0
|
|
7722
7722
|
},
|
|
7723
|
-
w:
|
|
7724
|
-
h:
|
|
7723
|
+
w: "0",
|
|
7724
|
+
h: "0",
|
|
7725
7725
|
left: 0,
|
|
7726
7726
|
scale: 1,
|
|
7727
7727
|
clicks: [],
|
|
7728
7728
|
lock: false,
|
|
7729
7729
|
canvasVisible: true,
|
|
7730
7730
|
isEverything: false,
|
|
7731
|
-
afterEditSrc:
|
|
7731
|
+
afterEditSrc: ""
|
|
7732
7732
|
};
|
|
7733
7733
|
},
|
|
7734
7734
|
watch: {
|
|
7735
|
-
visible: {
|
|
7736
|
-
|
|
7737
|
-
|
|
7738
|
-
|
|
7739
|
-
|
|
7740
|
-
|
|
7741
|
-
|
|
7742
|
-
|
|
7743
|
-
|
|
7735
|
+
visible: async function (newVal) {
|
|
7736
|
+
if (newVal) {
|
|
7737
|
+
await this.$nextTick();
|
|
7738
|
+
this.ctx = this.$refs.canvasRef.getContext("2d");
|
|
7739
|
+
this.initImage();
|
|
7740
|
+
} else {
|
|
7741
|
+
this.workspaceSrc = "";
|
|
7742
|
+
this.afterEditSrc = "";
|
|
7743
|
+
}
|
|
7744
7744
|
}
|
|
7745
7745
|
},
|
|
7746
|
-
mounted() {
|
|
7747
|
-
// 组件挂载时的初始化操作
|
|
7748
|
-
},
|
|
7749
7746
|
methods: {
|
|
7750
7747
|
close() {
|
|
7751
|
-
this.$emit(
|
|
7748
|
+
this.$emit("update:visible", false);
|
|
7752
7749
|
},
|
|
7753
7750
|
handleMask() {
|
|
7754
7751
|
if (this.visible) {
|
|
7755
7752
|
this.close();
|
|
7756
7753
|
}
|
|
7757
7754
|
},
|
|
7758
|
-
initImage() {
|
|
7759
|
-
const
|
|
7760
|
-
|
|
7761
|
-
|
|
7762
|
-
|
|
7763
|
-
|
|
7764
|
-
|
|
7765
|
-
|
|
7766
|
-
|
|
7767
|
-
|
|
7768
|
-
|
|
7769
|
-
|
|
7770
|
-
|
|
7771
|
-
const image = new Image();
|
|
7772
|
-
image.src = `${requestUrl.API_IMG}/sam/api/upload/${res.data.filename}`;
|
|
7773
|
-
self.workspaceSrc = `${requestUrl.API_IMG}/sam/api/upload/${res.data.filename}`;
|
|
7774
|
-
self.path = res.data.path;
|
|
7775
|
-
image.onload = () => {
|
|
7776
|
-
let w_ = image.width,
|
|
7777
|
-
h_ = image.height;
|
|
7778
|
-
let nw, nh;
|
|
7779
|
-
let mw = 800,
|
|
7780
|
-
mh = 600;
|
|
7781
|
-
let ratio = w_ / h_;
|
|
7782
|
-
if (ratio * mh > mw) {
|
|
7783
|
-
nw = mw;
|
|
7784
|
-
nh = mw / ratio;
|
|
7785
|
-
} else {
|
|
7786
|
-
nh = mh;
|
|
7787
|
-
nw = ratio * mh;
|
|
7788
|
-
}
|
|
7789
|
-
self.originalSize = {
|
|
7790
|
-
w: w_,
|
|
7791
|
-
h: h_
|
|
7792
|
-
};
|
|
7793
|
-
nw = parseInt(nw);
|
|
7794
|
-
nh = parseInt(nh);
|
|
7795
|
-
self.w = nw + 'px';
|
|
7796
|
-
self.h = nh + 'px';
|
|
7797
|
-
self.left = (mw - nw) / 2;
|
|
7798
|
-
self.scale = nw / w_;
|
|
7799
|
-
self.$refs.imgRef.addEventListener('contextmenu', e => e.preventDefault());
|
|
7800
|
-
self.$refs.imgRef.addEventListener('mousemove', self.throttle(self.handleMouseMove, 150));
|
|
7801
|
-
self.$refs.canvasRef.style.transform = `scale(${self.scale})`;
|
|
7802
|
-
};
|
|
7803
|
-
}).catch(err => {
|
|
7804
|
-
console.error(err);
|
|
7755
|
+
async initImage() {
|
|
7756
|
+
const response = await fetch(this.src);
|
|
7757
|
+
const blob = await response.blob();
|
|
7758
|
+
const {
|
|
7759
|
+
data: res
|
|
7760
|
+
} = await lib_axios.post(requestUrl.uploadImg, {
|
|
7761
|
+
file: new File([blob], "image.jpg", {
|
|
7762
|
+
type: "image/jpeg"
|
|
7763
|
+
})
|
|
7764
|
+
}, {
|
|
7765
|
+
headers: {
|
|
7766
|
+
"Content-Type": "multipart/form-data"
|
|
7767
|
+
}
|
|
7805
7768
|
});
|
|
7769
|
+
const image = new Image();
|
|
7770
|
+
image.src = `${requestUrl.API_IMG}/sam/api/upload/${res.filename}`;
|
|
7771
|
+
this.workspaceSrc = `${requestUrl.API_IMG}/sam/api/upload/${res.filename}`;
|
|
7772
|
+
this.path = res.path;
|
|
7773
|
+
image.onload = () => {
|
|
7774
|
+
let w_ = image.width,
|
|
7775
|
+
h_ = image.height;
|
|
7776
|
+
let nw, nh;
|
|
7777
|
+
let mw = 800,
|
|
7778
|
+
mh = 600;
|
|
7779
|
+
console.log(mw, mh);
|
|
7780
|
+
let ratio = w_ / h_;
|
|
7781
|
+
if (ratio * mh > mw) {
|
|
7782
|
+
nw = mw;
|
|
7783
|
+
nh = mw / ratio;
|
|
7784
|
+
} else {
|
|
7785
|
+
nh = mh;
|
|
7786
|
+
nw = ratio * mh;
|
|
7787
|
+
}
|
|
7788
|
+
this.originalSize = {
|
|
7789
|
+
w: w_,
|
|
7790
|
+
h: h_
|
|
7791
|
+
};
|
|
7792
|
+
nw = parseInt(nw);
|
|
7793
|
+
nh = parseInt(nh);
|
|
7794
|
+
this.w = nw + "px";
|
|
7795
|
+
this.h = nh + "px";
|
|
7796
|
+
this.left = (mw - nw) / 2;
|
|
7797
|
+
this.scale = nw / w_;
|
|
7798
|
+
this.$refs.imgRef.addEventListener("contextmenu", e => e.preventDefault());
|
|
7799
|
+
this.$refs.imgRef.addEventListener("mousemove", this.throttle(this.handleMouseMove, 150));
|
|
7800
|
+
this.$refs.canvasRef.style.transform = `scale(${this.scale})`;
|
|
7801
|
+
};
|
|
7802
|
+
return;
|
|
7806
7803
|
},
|
|
7807
7804
|
handleMouseMove(e) {
|
|
7808
7805
|
if (this.isEverything) {
|
|
@@ -7861,18 +7858,18 @@ const requestUrl = {
|
|
|
7861
7858
|
return click;
|
|
7862
7859
|
},
|
|
7863
7860
|
placePoint(x, y, clickType) {
|
|
7864
|
-
let box = document.getElementById(
|
|
7865
|
-
let point = document.createElement(
|
|
7866
|
-
point.className =
|
|
7861
|
+
let box = document.getElementById("point-box");
|
|
7862
|
+
let point = document.createElement("div");
|
|
7863
|
+
point.className = "segment-point" + (clickType ? "" : " negative");
|
|
7867
7864
|
point.style = `position: absolute;
|
|
7868
7865
|
width: 10px;
|
|
7869
7866
|
height: 10px;
|
|
7870
7867
|
border-radius: 50%;
|
|
7871
|
-
background-color: ${clickType ?
|
|
7868
|
+
background-color: ${clickType ? "#409EFF" : "#F56C6C "};
|
|
7872
7869
|
left: ${x - 5}px;
|
|
7873
7870
|
top: ${y - 5}px`;
|
|
7874
7871
|
// 点的id是在clicks数组中的下标索引
|
|
7875
|
-
point.id =
|
|
7872
|
+
point.id = "point-" + this.clicks.length;
|
|
7876
7873
|
box.appendChild(point);
|
|
7877
7874
|
},
|
|
7878
7875
|
getMask(clks) {
|
|
@@ -7893,6 +7890,7 @@ const requestUrl = {
|
|
|
7893
7890
|
this.lock = false;
|
|
7894
7891
|
}).catch(err => {
|
|
7895
7892
|
console.error(err);
|
|
7893
|
+
// message.error('生成失败')
|
|
7896
7894
|
this.lock = false;
|
|
7897
7895
|
});
|
|
7898
7896
|
},
|
|
@@ -7918,7 +7916,7 @@ const requestUrl = {
|
|
|
7918
7916
|
this.ctx.putImageData(imgData, 0, 0);
|
|
7919
7917
|
},
|
|
7920
7918
|
removePoint(i) {
|
|
7921
|
-
const selector =
|
|
7919
|
+
const selector = "point-" + i;
|
|
7922
7920
|
let point = document.getElementById(selector);
|
|
7923
7921
|
if (point != null) {
|
|
7924
7922
|
point.remove();
|
|
@@ -7930,18 +7928,20 @@ const requestUrl = {
|
|
|
7930
7928
|
}
|
|
7931
7929
|
this.clicks = [];
|
|
7932
7930
|
this.isEverything = false;
|
|
7933
|
-
this.ctx.clearRect(0, 0, this.canvasRef.width, this.canvasRef.height);
|
|
7931
|
+
this.ctx.clearRect(0, 0, this.$refs.canvasRef.width, this.$refs.canvasRef.height);
|
|
7934
7932
|
},
|
|
7935
7933
|
imageMatting() {
|
|
7936
7934
|
if (this.lock || this.clicks.length === 0) {
|
|
7937
7935
|
return;
|
|
7938
7936
|
}
|
|
7939
|
-
this.cutOutImage(this.originalSize, this.$refs.imgRef, this.$refs.canvasRef,
|
|
7940
|
-
this.afterEditSrc =
|
|
7937
|
+
this.cutOutImage(this.originalSize, this.$refs.imgRef, this.$refs.canvasRef, base64 => {
|
|
7938
|
+
this.afterEditSrc = base64;
|
|
7939
|
+
// 不需要之后用下面的清除文件
|
|
7940
|
+
// URL.revokeObjectURL(url);
|
|
7941
7941
|
});
|
|
7942
7942
|
},
|
|
7943
7943
|
handleOk() {
|
|
7944
|
-
this.$emit(
|
|
7944
|
+
this.$emit("update:visible", false, this.afterEditSrc);
|
|
7945
7945
|
},
|
|
7946
7946
|
throttle(func, delay) {
|
|
7947
7947
|
let timer = null; // 定时器变量
|
|
@@ -7979,8 +7979,8 @@ const requestUrl = {
|
|
|
7979
7979
|
}
|
|
7980
7980
|
return result;
|
|
7981
7981
|
},
|
|
7982
|
-
decodeRleCounts(
|
|
7983
|
-
let arr = new Uint8Array(
|
|
7982
|
+
decodeRleCounts([rows, cols], counts) {
|
|
7983
|
+
let arr = new Uint8Array(rows * cols);
|
|
7984
7984
|
let i = 0;
|
|
7985
7985
|
let flag = 0;
|
|
7986
7986
|
for (let k of counts) {
|
|
@@ -7995,11 +7995,11 @@ const requestUrl = {
|
|
|
7995
7995
|
w,
|
|
7996
7996
|
h
|
|
7997
7997
|
}, image, canvas, callback) {
|
|
7998
|
-
const resultCanvas = document.createElement(
|
|
7999
|
-
resultCtx = resultCanvas.getContext(
|
|
7998
|
+
const resultCanvas = document.createElement("canvas"),
|
|
7999
|
+
resultCtx = resultCanvas.getContext("2d", {
|
|
8000
8000
|
willReadFrequently: true
|
|
8001
8001
|
}),
|
|
8002
|
-
originalCtx = canvas.getContext(
|
|
8002
|
+
originalCtx = canvas.getContext("2d", {
|
|
8003
8003
|
willReadFrequently: true
|
|
8004
8004
|
});
|
|
8005
8005
|
resultCanvas.width = w;
|
|
@@ -8038,26 +8038,29 @@ const requestUrl = {
|
|
|
8038
8038
|
const startY = minY;
|
|
8039
8039
|
resultCtx.putImageData(imageData, 0, 0);
|
|
8040
8040
|
// 创建一个新的canvas来存储特定区域的图像
|
|
8041
|
-
const croppedCanvas = document.createElement(
|
|
8042
|
-
const croppedContext = croppedCanvas.getContext(
|
|
8041
|
+
const croppedCanvas = document.createElement("canvas");
|
|
8042
|
+
const croppedContext = croppedCanvas.getContext("2d");
|
|
8043
8043
|
croppedCanvas.width = width;
|
|
8044
8044
|
croppedCanvas.height = height;
|
|
8045
8045
|
// 将特定区域绘制到新canvas上
|
|
8046
8046
|
croppedContext.drawImage(resultCanvas, startX, startY, width, height, 0, 0, width, height);
|
|
8047
|
-
croppedCanvas.toBlob(blob => {
|
|
8048
|
-
|
|
8049
|
-
|
|
8050
|
-
|
|
8051
|
-
}, 'image/png')
|
|
8047
|
+
// croppedCanvas.toBlob((blob) => {
|
|
8048
|
+
// if(callback) {
|
|
8049
|
+
// callback(blob)
|
|
8050
|
+
// }
|
|
8051
|
+
// }, 'image/png')
|
|
8052
|
+
// let base64 = croppedCanvas.toDataURL('image/png').replace('data:image/png;base64,', '')
|
|
8053
|
+
let base64 = croppedCanvas.toDataURL("image/png");
|
|
8054
|
+
callback(base64);
|
|
8052
8055
|
}
|
|
8053
8056
|
}
|
|
8054
8057
|
});
|
|
8055
|
-
;// ./src/components/
|
|
8056
|
-
/* harmony default export */ var
|
|
8057
|
-
;// ./node_modules/.pnpm/mini-css-extract-plugin@2.9.2_webpack@5.99.9/node_modules/mini-css-extract-plugin/dist/loader.js??clonedRuleSet-32.use[0]!./node_modules/.pnpm/css-loader@6.11.0_webpack@5.99.9/node_modules/css-loader/dist/cjs.js??clonedRuleSet-32.use[1]!./node_modules/.pnpm/vue-loader@15.11.1_@vue+compiler-sfc@3.5.16_css-loader@6.11.0_webpack@5.99.9__lodash@4.17.21__w7knhy35vnjmebqosxmmnor4uq/node_modules/vue-loader/lib/loaders/stylePostLoader.js!./node_modules/.pnpm/postcss-loader@6.2.1_postcss@8.5.6_webpack@5.99.9/node_modules/postcss-loader/dist/cjs.js??clonedRuleSet-32.use[2]!./node_modules/.pnpm/less-loader@8.1.1_less@4.3.0_webpack@5.99.9/node_modules/less-loader/dist/cjs.js??clonedRuleSet-32.use[3]!./node_modules/.pnpm/vue-loader@15.11.1_@vue+compiler-sfc@3.5.16_css-loader@6.11.0_webpack@5.99.9__lodash@4.17.21__w7knhy35vnjmebqosxmmnor4uq/node_modules/vue-loader/lib/index.js??vue-loader-options!./src/components/
|
|
8058
|
+
;// ./src/components/ImageMatting.vue?vue&type=script&lang=js
|
|
8059
|
+
/* harmony default export */ var components_ImageMattingvue_type_script_lang_js = (ImageMattingvue_type_script_lang_js);
|
|
8060
|
+
;// ./node_modules/.pnpm/mini-css-extract-plugin@2.9.2_webpack@5.99.9/node_modules/mini-css-extract-plugin/dist/loader.js??clonedRuleSet-32.use[0]!./node_modules/.pnpm/css-loader@6.11.0_webpack@5.99.9/node_modules/css-loader/dist/cjs.js??clonedRuleSet-32.use[1]!./node_modules/.pnpm/vue-loader@15.11.1_@vue+compiler-sfc@3.5.16_css-loader@6.11.0_webpack@5.99.9__lodash@4.17.21__w7knhy35vnjmebqosxmmnor4uq/node_modules/vue-loader/lib/loaders/stylePostLoader.js!./node_modules/.pnpm/postcss-loader@6.2.1_postcss@8.5.6_webpack@5.99.9/node_modules/postcss-loader/dist/cjs.js??clonedRuleSet-32.use[2]!./node_modules/.pnpm/less-loader@8.1.1_less@4.3.0_webpack@5.99.9/node_modules/less-loader/dist/cjs.js??clonedRuleSet-32.use[3]!./node_modules/.pnpm/vue-loader@15.11.1_@vue+compiler-sfc@3.5.16_css-loader@6.11.0_webpack@5.99.9__lodash@4.17.21__w7knhy35vnjmebqosxmmnor4uq/node_modules/vue-loader/lib/index.js??vue-loader-options!./src/components/ImageMatting.vue?vue&type=style&index=0&id=4def8405&prod&lang=less&scoped=true
|
|
8058
8061
|
// extracted by mini-css-extract-plugin
|
|
8059
8062
|
|
|
8060
|
-
;// ./src/components/
|
|
8063
|
+
;// ./src/components/ImageMatting.vue?vue&type=style&index=0&id=4def8405&prod&lang=less&scoped=true
|
|
8061
8064
|
|
|
8062
8065
|
;// ./node_modules/.pnpm/vue-loader@15.11.1_@vue+compiler-sfc@3.5.16_css-loader@6.11.0_webpack@5.99.9__lodash@4.17.21__w7knhy35vnjmebqosxmmnor4uq/node_modules/vue-loader/lib/runtime/componentNormalizer.js
|
|
8063
8066
|
/* globals __VUE_SSR_CONTEXT__ */
|
|
@@ -8157,7 +8160,7 @@ function normalizeComponent(
|
|
|
8157
8160
|
}
|
|
8158
8161
|
}
|
|
8159
8162
|
|
|
8160
|
-
;// ./src/components/
|
|
8163
|
+
;// ./src/components/ImageMatting.vue
|
|
8161
8164
|
|
|
8162
8165
|
|
|
8163
8166
|
|
|
@@ -8167,19 +8170,19 @@ function normalizeComponent(
|
|
|
8167
8170
|
/* normalize component */
|
|
8168
8171
|
|
|
8169
8172
|
var component = normalizeComponent(
|
|
8170
|
-
|
|
8173
|
+
components_ImageMattingvue_type_script_lang_js,
|
|
8171
8174
|
render,
|
|
8172
8175
|
staticRenderFns,
|
|
8173
8176
|
false,
|
|
8174
8177
|
null,
|
|
8175
|
-
"
|
|
8178
|
+
"4def8405",
|
|
8176
8179
|
null
|
|
8177
8180
|
|
|
8178
8181
|
)
|
|
8179
8182
|
|
|
8180
|
-
/* harmony default export */ var
|
|
8181
|
-
;// ./node_modules/.pnpm/thread-loader@3.0.4_webpack@5.99.9/node_modules/thread-loader/dist/cjs.js!./node_modules/.pnpm/babel-loader@8.4.1_@babel+core@7.27.4_webpack@5.99.9/node_modules/babel-loader/lib/index.js??clonedRuleSet-40.use[1]!./node_modules/.pnpm/vue-loader@15.11.1_@vue+compiler-sfc@3.5.16_css-loader@6.11.0_webpack@5.99.9__lodash@4.17.21__w7knhy35vnjmebqosxmmnor4uq/node_modules/vue-loader/lib/loaders/templateLoader.js??ruleSet[1].rules[3]!./node_modules/.pnpm/vue-loader@15.11.1_@vue+compiler-sfc@3.5.16_css-loader@6.11.0_webpack@5.99.9__lodash@4.17.21__w7knhy35vnjmebqosxmmnor4uq/node_modules/vue-loader/lib/index.js??vue-loader-options!./src/components/
|
|
8182
|
-
var
|
|
8183
|
+
/* harmony default export */ var ImageMatting = (component.exports);
|
|
8184
|
+
;// ./node_modules/.pnpm/thread-loader@3.0.4_webpack@5.99.9/node_modules/thread-loader/dist/cjs.js!./node_modules/.pnpm/babel-loader@8.4.1_@babel+core@7.27.4_webpack@5.99.9/node_modules/babel-loader/lib/index.js??clonedRuleSet-40.use[1]!./node_modules/.pnpm/vue-loader@15.11.1_@vue+compiler-sfc@3.5.16_css-loader@6.11.0_webpack@5.99.9__lodash@4.17.21__w7knhy35vnjmebqosxmmnor4uq/node_modules/vue-loader/lib/loaders/templateLoader.js??ruleSet[1].rules[3]!./node_modules/.pnpm/vue-loader@15.11.1_@vue+compiler-sfc@3.5.16_css-loader@6.11.0_webpack@5.99.9__lodash@4.17.21__w7knhy35vnjmebqosxmmnor4uq/node_modules/vue-loader/lib/index.js??vue-loader-options!./src/components/ExpandResolution.vue?vue&type=template&id=531f26f6&scoped=true
|
|
8185
|
+
var ExpandResolutionvue_type_template_id_531f26f6_scoped_true_render = function render() {
|
|
8183
8186
|
var _vm = this,
|
|
8184
8187
|
_c = _vm._self._c;
|
|
8185
8188
|
return _c('transition', {
|
|
@@ -8265,21 +8268,21 @@ var AIImageExpandResolutionvue_type_template_id_865c5d88_scoped_true_render = fu
|
|
|
8265
8268
|
staticClass: "line-md--loading-alt-loop"
|
|
8266
8269
|
}), _c('div', [_vm._v("加载中...")])])])])], 1)])]) : _vm._e()]);
|
|
8267
8270
|
};
|
|
8268
|
-
var
|
|
8271
|
+
var ExpandResolutionvue_type_template_id_531f26f6_scoped_true_staticRenderFns = [];
|
|
8269
8272
|
|
|
8270
8273
|
// EXTERNAL MODULE: ./node_modules/.pnpm/spark-md5@3.0.2/node_modules/spark-md5/spark-md5.js
|
|
8271
8274
|
var spark_md5 = __webpack_require__(6616);
|
|
8272
8275
|
var spark_md5_default = /*#__PURE__*/__webpack_require__.n(spark_md5);
|
|
8273
|
-
;// ./node_modules/.pnpm/thread-loader@3.0.4_webpack@5.99.9/node_modules/thread-loader/dist/cjs.js!./node_modules/.pnpm/babel-loader@8.4.1_@babel+core@7.27.4_webpack@5.99.9/node_modules/babel-loader/lib/index.js??clonedRuleSet-40.use[1]!./node_modules/.pnpm/vue-loader@15.11.1_@vue+compiler-sfc@3.5.16_css-loader@6.11.0_webpack@5.99.9__lodash@4.17.21__w7knhy35vnjmebqosxmmnor4uq/node_modules/vue-loader/lib/index.js??vue-loader-options!./src/components/
|
|
8276
|
+
;// ./node_modules/.pnpm/thread-loader@3.0.4_webpack@5.99.9/node_modules/thread-loader/dist/cjs.js!./node_modules/.pnpm/babel-loader@8.4.1_@babel+core@7.27.4_webpack@5.99.9/node_modules/babel-loader/lib/index.js??clonedRuleSet-40.use[1]!./node_modules/.pnpm/vue-loader@15.11.1_@vue+compiler-sfc@3.5.16_css-loader@6.11.0_webpack@5.99.9__lodash@4.17.21__w7knhy35vnjmebqosxmmnor4uq/node_modules/vue-loader/lib/index.js??vue-loader-options!./src/components/ExpandResolution.vue?vue&type=script&lang=js
|
|
8274
8277
|
|
|
8275
8278
|
|
|
8276
8279
|
|
|
8277
|
-
const
|
|
8278
|
-
openTask: `https://
|
|
8279
|
-
checkTask: `https://
|
|
8280
|
+
const ExpandResolutionvue_type_script_lang_js_requestUrl = {
|
|
8281
|
+
openTask: `https://apollo.51kandianshi.com/aigc-tools/super-resolve/generate`,
|
|
8282
|
+
checkTask: `https://apollo.51kandianshi.com/aigc-tools/super-resolve/query`
|
|
8280
8283
|
};
|
|
8281
|
-
/* harmony default export */ var
|
|
8282
|
-
name: "
|
|
8284
|
+
/* harmony default export */ var ExpandResolutionvue_type_script_lang_js = ({
|
|
8285
|
+
name: "ExpandResolution",
|
|
8283
8286
|
props: {
|
|
8284
8287
|
visible: {
|
|
8285
8288
|
type: Boolean,
|
|
@@ -8293,7 +8296,7 @@ const AIImageExpandResolutionvue_type_script_lang_js_requestUrl = {
|
|
|
8293
8296
|
data() {
|
|
8294
8297
|
return {
|
|
8295
8298
|
loading: false,
|
|
8296
|
-
workspaceSrc:
|
|
8299
|
+
workspaceSrc: this.src,
|
|
8297
8300
|
afterEditSrc: "",
|
|
8298
8301
|
taskId: "",
|
|
8299
8302
|
interval: null,
|
|
@@ -8307,9 +8310,6 @@ const AIImageExpandResolutionvue_type_script_lang_js_requestUrl = {
|
|
|
8307
8310
|
}]
|
|
8308
8311
|
};
|
|
8309
8312
|
},
|
|
8310
|
-
created() {
|
|
8311
|
-
this.workspaceSrc = "https://cre.51kandianshi.com/iopaint/Images/3bf3f294-e6e8-411d-8531-8eba990a3456.png";
|
|
8312
|
-
},
|
|
8313
8313
|
watch: {
|
|
8314
8314
|
visible(newVal) {
|
|
8315
8315
|
if (newVal) {
|
|
@@ -8339,7 +8339,7 @@ const AIImageExpandResolutionvue_type_script_lang_js_requestUrl = {
|
|
|
8339
8339
|
return;
|
|
8340
8340
|
}
|
|
8341
8341
|
try {
|
|
8342
|
-
const res = await lib_axios.get(`${
|
|
8342
|
+
const res = await lib_axios.get(`${ExpandResolutionvue_type_script_lang_js_requestUrl.checkTask}?taskId=${this.taskId}`, {
|
|
8343
8343
|
headers: {
|
|
8344
8344
|
accessToken: this.$token
|
|
8345
8345
|
}
|
|
@@ -8367,7 +8367,7 @@ const AIImageExpandResolutionvue_type_script_lang_js_requestUrl = {
|
|
|
8367
8367
|
let md5 = await this.getImageMd5(this.workspaceSrc);
|
|
8368
8368
|
this.loading = true;
|
|
8369
8369
|
try {
|
|
8370
|
-
const res = await lib_axios.post(
|
|
8370
|
+
const res = await lib_axios.post(ExpandResolutionvue_type_script_lang_js_requestUrl.openTask, {
|
|
8371
8371
|
fileUrl: this.workspaceSrc,
|
|
8372
8372
|
md5,
|
|
8373
8373
|
mode: 1,
|
|
@@ -8427,14 +8427,369 @@ const AIImageExpandResolutionvue_type_script_lang_js_requestUrl = {
|
|
|
8427
8427
|
}
|
|
8428
8428
|
}
|
|
8429
8429
|
});
|
|
8430
|
-
;// ./src/components/
|
|
8431
|
-
/* harmony default export */ var
|
|
8432
|
-
;// ./node_modules/.pnpm/mini-css-extract-plugin@2.9.2_webpack@5.99.9/node_modules/mini-css-extract-plugin/dist/loader.js??clonedRuleSet-32.use[0]!./node_modules/.pnpm/css-loader@6.11.0_webpack@5.99.9/node_modules/css-loader/dist/cjs.js??clonedRuleSet-32.use[1]!./node_modules/.pnpm/vue-loader@15.11.1_@vue+compiler-sfc@3.5.16_css-loader@6.11.0_webpack@5.99.9__lodash@4.17.21__w7knhy35vnjmebqosxmmnor4uq/node_modules/vue-loader/lib/loaders/stylePostLoader.js!./node_modules/.pnpm/postcss-loader@6.2.1_postcss@8.5.6_webpack@5.99.9/node_modules/postcss-loader/dist/cjs.js??clonedRuleSet-32.use[2]!./node_modules/.pnpm/less-loader@8.1.1_less@4.3.0_webpack@5.99.9/node_modules/less-loader/dist/cjs.js??clonedRuleSet-32.use[3]!./node_modules/.pnpm/vue-loader@15.11.1_@vue+compiler-sfc@3.5.16_css-loader@6.11.0_webpack@5.99.9__lodash@4.17.21__w7knhy35vnjmebqosxmmnor4uq/node_modules/vue-loader/lib/index.js??vue-loader-options!./src/components/
|
|
8430
|
+
;// ./src/components/ExpandResolution.vue?vue&type=script&lang=js
|
|
8431
|
+
/* harmony default export */ var components_ExpandResolutionvue_type_script_lang_js = (ExpandResolutionvue_type_script_lang_js);
|
|
8432
|
+
;// ./node_modules/.pnpm/mini-css-extract-plugin@2.9.2_webpack@5.99.9/node_modules/mini-css-extract-plugin/dist/loader.js??clonedRuleSet-32.use[0]!./node_modules/.pnpm/css-loader@6.11.0_webpack@5.99.9/node_modules/css-loader/dist/cjs.js??clonedRuleSet-32.use[1]!./node_modules/.pnpm/vue-loader@15.11.1_@vue+compiler-sfc@3.5.16_css-loader@6.11.0_webpack@5.99.9__lodash@4.17.21__w7knhy35vnjmebqosxmmnor4uq/node_modules/vue-loader/lib/loaders/stylePostLoader.js!./node_modules/.pnpm/postcss-loader@6.2.1_postcss@8.5.6_webpack@5.99.9/node_modules/postcss-loader/dist/cjs.js??clonedRuleSet-32.use[2]!./node_modules/.pnpm/less-loader@8.1.1_less@4.3.0_webpack@5.99.9/node_modules/less-loader/dist/cjs.js??clonedRuleSet-32.use[3]!./node_modules/.pnpm/vue-loader@15.11.1_@vue+compiler-sfc@3.5.16_css-loader@6.11.0_webpack@5.99.9__lodash@4.17.21__w7knhy35vnjmebqosxmmnor4uq/node_modules/vue-loader/lib/index.js??vue-loader-options!./src/components/ExpandResolution.vue?vue&type=style&index=0&id=531f26f6&prod&lang=less&scoped=true
|
|
8433
|
+
// extracted by mini-css-extract-plugin
|
|
8434
|
+
|
|
8435
|
+
;// ./src/components/ExpandResolution.vue?vue&type=style&index=0&id=531f26f6&prod&lang=less&scoped=true
|
|
8436
|
+
|
|
8437
|
+
;// ./src/components/ExpandResolution.vue
|
|
8438
|
+
|
|
8439
|
+
|
|
8440
|
+
|
|
8441
|
+
;
|
|
8442
|
+
|
|
8443
|
+
|
|
8444
|
+
/* normalize component */
|
|
8445
|
+
|
|
8446
|
+
var ExpandResolution_component = normalizeComponent(
|
|
8447
|
+
components_ExpandResolutionvue_type_script_lang_js,
|
|
8448
|
+
ExpandResolutionvue_type_template_id_531f26f6_scoped_true_render,
|
|
8449
|
+
ExpandResolutionvue_type_template_id_531f26f6_scoped_true_staticRenderFns,
|
|
8450
|
+
false,
|
|
8451
|
+
null,
|
|
8452
|
+
"531f26f6",
|
|
8453
|
+
null
|
|
8454
|
+
|
|
8455
|
+
)
|
|
8456
|
+
|
|
8457
|
+
/* harmony default export */ var ExpandResolution = (ExpandResolution_component.exports);
|
|
8458
|
+
;// ./node_modules/.pnpm/thread-loader@3.0.4_webpack@5.99.9/node_modules/thread-loader/dist/cjs.js!./node_modules/.pnpm/babel-loader@8.4.1_@babel+core@7.27.4_webpack@5.99.9/node_modules/babel-loader/lib/index.js??clonedRuleSet-40.use[1]!./node_modules/.pnpm/vue-loader@15.11.1_@vue+compiler-sfc@3.5.16_css-loader@6.11.0_webpack@5.99.9__lodash@4.17.21__w7knhy35vnjmebqosxmmnor4uq/node_modules/vue-loader/lib/loaders/templateLoader.js??ruleSet[1].rules[3]!./node_modules/.pnpm/vue-loader@15.11.1_@vue+compiler-sfc@3.5.16_css-loader@6.11.0_webpack@5.99.9__lodash@4.17.21__w7knhy35vnjmebqosxmmnor4uq/node_modules/vue-loader/lib/index.js??vue-loader-options!./src/components/ExpandImg.vue?vue&type=template&id=b59d9692&scoped=true
|
|
8459
|
+
var ExpandImgvue_type_template_id_b59d9692_scoped_true_render = function render() {
|
|
8460
|
+
var _vm = this,
|
|
8461
|
+
_c = _vm._self._c;
|
|
8462
|
+
return _c('transition', {
|
|
8463
|
+
attrs: {
|
|
8464
|
+
"name": "fade"
|
|
8465
|
+
}
|
|
8466
|
+
}, [_c('div', {
|
|
8467
|
+
directives: [{
|
|
8468
|
+
name: "show",
|
|
8469
|
+
rawName: "v-show",
|
|
8470
|
+
value: _vm.visible,
|
|
8471
|
+
expression: "visible"
|
|
8472
|
+
}],
|
|
8473
|
+
staticClass: "modal-overlay",
|
|
8474
|
+
on: {
|
|
8475
|
+
"click": function ($event) {
|
|
8476
|
+
if ($event.target !== $event.currentTarget) return null;
|
|
8477
|
+
return _vm.handleMask.apply(null, arguments);
|
|
8478
|
+
}
|
|
8479
|
+
}
|
|
8480
|
+
}, [_c('div', {
|
|
8481
|
+
staticClass: "modal-content"
|
|
8482
|
+
}, [_c('div', {
|
|
8483
|
+
staticClass: "modal-header"
|
|
8484
|
+
}, [_vm._v("AI扩图")]), _c('div', {
|
|
8485
|
+
staticClass: "modal-body"
|
|
8486
|
+
}, [_c('div', {
|
|
8487
|
+
staticClass: "flex",
|
|
8488
|
+
on: {
|
|
8489
|
+
"click": function ($event) {
|
|
8490
|
+
$event.stopPropagation();
|
|
8491
|
+
}
|
|
8492
|
+
}
|
|
8493
|
+
}, [_c('div', {
|
|
8494
|
+
staticClass: "workspace"
|
|
8495
|
+
}, [_c('img', {
|
|
8496
|
+
staticClass: "originalimg",
|
|
8497
|
+
attrs: {
|
|
8498
|
+
"src": _vm.workspaceSrc,
|
|
8499
|
+
"alt": "AI扩图"
|
|
8500
|
+
}
|
|
8501
|
+
})]), _c('div', {
|
|
8502
|
+
staticClass: "config"
|
|
8503
|
+
}, [_c('div', {
|
|
8504
|
+
staticClass: "title"
|
|
8505
|
+
}, [_vm._v("尺寸比例")]), _c('div', {
|
|
8506
|
+
staticClass: "ratio"
|
|
8507
|
+
}, _vm._l(_vm.ratio, function (item, index) {
|
|
8508
|
+
return _c('div', {
|
|
8509
|
+
key: index,
|
|
8510
|
+
staticClass: "ratio-item",
|
|
8511
|
+
on: {
|
|
8512
|
+
"click": function ($event) {
|
|
8513
|
+
_vm.currentRatio = index;
|
|
8514
|
+
}
|
|
8515
|
+
}
|
|
8516
|
+
}, [_c('img', {
|
|
8517
|
+
staticClass: "ratio-img",
|
|
8518
|
+
attrs: {
|
|
8519
|
+
"src": _vm.currentRatio == index ? item.icon_active : item.icon
|
|
8520
|
+
}
|
|
8521
|
+
})]);
|
|
8522
|
+
}), 0), _vm.currentRatio == 0 ? _c('div', {
|
|
8523
|
+
staticClass: "title"
|
|
8524
|
+
}, [_vm._v("方位扩图百分比")]) : _vm._e(), _vm.currentRatio == 0 ? _c('div', {
|
|
8525
|
+
staticClass: "position"
|
|
8526
|
+
}, _vm._l(_vm.position, function (item, index) {
|
|
8527
|
+
return _c('div', {
|
|
8528
|
+
key: index,
|
|
8529
|
+
staticClass: "position-item"
|
|
8530
|
+
}, [_c('span', [_vm._v(_vm._s(item.title))]), _c('div', {
|
|
8531
|
+
staticClass: "position-input"
|
|
8532
|
+
}, [_c('input', {
|
|
8533
|
+
domProps: {
|
|
8534
|
+
"value": item.value
|
|
8535
|
+
}
|
|
8536
|
+
}), _c('span', {
|
|
8537
|
+
staticClass: "suffix"
|
|
8538
|
+
}, [_vm._v("%")])])]);
|
|
8539
|
+
}), 0) : _vm._e(), _c('div', {
|
|
8540
|
+
staticClass: "button",
|
|
8541
|
+
on: {
|
|
8542
|
+
"click": _vm.expandImg
|
|
8543
|
+
}
|
|
8544
|
+
}, [_vm._v("扩图")]), _c('div', {
|
|
8545
|
+
staticClass: "button",
|
|
8546
|
+
on: {
|
|
8547
|
+
"click": _vm.handleOk
|
|
8548
|
+
}
|
|
8549
|
+
}, [_vm._v("应用")])])]), _c('transition', {
|
|
8550
|
+
attrs: {
|
|
8551
|
+
"name": "fade"
|
|
8552
|
+
}
|
|
8553
|
+
}, [_c('div', {
|
|
8554
|
+
directives: [{
|
|
8555
|
+
name: "show",
|
|
8556
|
+
rawName: "v-show",
|
|
8557
|
+
value: _vm.loading,
|
|
8558
|
+
expression: "loading"
|
|
8559
|
+
}],
|
|
8560
|
+
staticClass: "spin-mask"
|
|
8561
|
+
}, [_c('div', {
|
|
8562
|
+
staticClass: "spin-loading"
|
|
8563
|
+
}, [_c('span', {
|
|
8564
|
+
staticClass: "line-md--loading-alt-loop"
|
|
8565
|
+
}), _c('div', [_vm._v("加载中...")])])])])], 1)])])]);
|
|
8566
|
+
};
|
|
8567
|
+
var ExpandImgvue_type_template_id_b59d9692_scoped_true_staticRenderFns = [];
|
|
8568
|
+
|
|
8569
|
+
;// ./node_modules/.pnpm/thread-loader@3.0.4_webpack@5.99.9/node_modules/thread-loader/dist/cjs.js!./node_modules/.pnpm/babel-loader@8.4.1_@babel+core@7.27.4_webpack@5.99.9/node_modules/babel-loader/lib/index.js??clonedRuleSet-40.use[1]!./node_modules/.pnpm/vue-loader@15.11.1_@vue+compiler-sfc@3.5.16_css-loader@6.11.0_webpack@5.99.9__lodash@4.17.21__w7knhy35vnjmebqosxmmnor4uq/node_modules/vue-loader/lib/index.js??vue-loader-options!./src/components/ExpandImg.vue?vue&type=script&lang=js
|
|
8570
|
+
|
|
8571
|
+
/* harmony default export */ var ExpandImgvue_type_script_lang_js = ({
|
|
8572
|
+
name: "ExpandImg",
|
|
8573
|
+
props: {
|
|
8574
|
+
visible: {
|
|
8575
|
+
type: Boolean,
|
|
8576
|
+
default: false
|
|
8577
|
+
},
|
|
8578
|
+
src: {
|
|
8579
|
+
type: String,
|
|
8580
|
+
default: ""
|
|
8581
|
+
}
|
|
8582
|
+
},
|
|
8583
|
+
data() {
|
|
8584
|
+
return {
|
|
8585
|
+
token: this.$token,
|
|
8586
|
+
requestUrl: {
|
|
8587
|
+
openTask: `https://apollo.51kandianshi.com/aigc-tools/text2pic/outPaintImage/task`,
|
|
8588
|
+
checkTask: `https://apollo.51kandianshi.com/aigc-tools/text2pic/outPaintImage/info`
|
|
8589
|
+
},
|
|
8590
|
+
currentRatio: 0,
|
|
8591
|
+
ratio: [{
|
|
8592
|
+
title: "自定义",
|
|
8593
|
+
icon: "https://cre.51kandianshi.com/sbs/2025/06/24/57c2fa87-8147-4985-b877-0463e438fb9a.png",
|
|
8594
|
+
icon_active: "https://cre.51kandianshi.com/sbs/2025/06/24/44453238-c141-4bc7-9a27-87a1520313cc.png"
|
|
8595
|
+
}, {
|
|
8596
|
+
title: "16:9",
|
|
8597
|
+
icon: "https://cre.51kandianshi.com/sbs/2025/06/24/eb51514a-b062-4fd9-94ea-63f12f1f58c6.png",
|
|
8598
|
+
icon_active: "https://cre.51kandianshi.com/sbs/2025/06/24/2aa48c95-20d6-46bc-95b3-bd1f8996c23b.png",
|
|
8599
|
+
ratio: 16 / 9
|
|
8600
|
+
}, {
|
|
8601
|
+
title: "9:16",
|
|
8602
|
+
icon: "https://cre.51kandianshi.com/sbs/2025/06/24/de27bc9c-247a-4e53-ab62-8c23e8acdeeb.png",
|
|
8603
|
+
icon_active: "https://cre.51kandianshi.com/sbs/2025/06/24/40d06111-21f6-4893-aefe-2da95043647b.png",
|
|
8604
|
+
ratio: 9 / 16
|
|
8605
|
+
}, {
|
|
8606
|
+
title: "1:1",
|
|
8607
|
+
icon: "https://cre.51kandianshi.com/sbs/2025/06/24/4493c8b5-9e44-46d0-aa14-f48fc0220cc3.png",
|
|
8608
|
+
icon_active: "https://cre.51kandianshi.com/sbs/2025/06/24/0c0a1962-5e25-419d-8d1a-51cb974aa558.png",
|
|
8609
|
+
ratio: 1
|
|
8610
|
+
}, {
|
|
8611
|
+
title: "3:2",
|
|
8612
|
+
icon: "https://cre.51kandianshi.com/sbs/2025/06/24/cf85a09f-c902-4858-b535-190353902961.png",
|
|
8613
|
+
icon_active: "https://cre.51kandianshi.com/sbs/2025/06/24/45a1fbf6-4aaa-48da-abc7-e7ea5a875739.png",
|
|
8614
|
+
ratio: 3 / 2
|
|
8615
|
+
}, {
|
|
8616
|
+
title: "2:3",
|
|
8617
|
+
icon: "https://cre.51kandianshi.com/sbs/2025/06/24/f767a51b-9f83-4069-987a-64f2283c3883.png",
|
|
8618
|
+
icon_active: "https://cre.51kandianshi.com/sbs/2025/06/24/5e29a1ae-e0bc-4da6-92ce-6fa44e8a58a8.png",
|
|
8619
|
+
ratio: 2 / 3
|
|
8620
|
+
}],
|
|
8621
|
+
position: [{
|
|
8622
|
+
title: "左",
|
|
8623
|
+
value: 0
|
|
8624
|
+
}, {
|
|
8625
|
+
title: "右",
|
|
8626
|
+
value: 0
|
|
8627
|
+
}, {
|
|
8628
|
+
title: "上",
|
|
8629
|
+
value: 0
|
|
8630
|
+
}, {
|
|
8631
|
+
title: "下",
|
|
8632
|
+
value: 0
|
|
8633
|
+
}],
|
|
8634
|
+
workspaceSrc: this.src,
|
|
8635
|
+
loading: false,
|
|
8636
|
+
taskId: "",
|
|
8637
|
+
interval: null
|
|
8638
|
+
};
|
|
8639
|
+
},
|
|
8640
|
+
methods: {
|
|
8641
|
+
close() {
|
|
8642
|
+
this.$emit("update:visible", false);
|
|
8643
|
+
},
|
|
8644
|
+
handleMask() {
|
|
8645
|
+
if (this.visible) {
|
|
8646
|
+
this.close();
|
|
8647
|
+
}
|
|
8648
|
+
},
|
|
8649
|
+
handleSize() {
|
|
8650
|
+
return new Promise((resolve, reject) => {
|
|
8651
|
+
const img = new Image();
|
|
8652
|
+
img.src = this.workspaceSrc;
|
|
8653
|
+
img.onload = () => {
|
|
8654
|
+
const imgWidth = img.naturalWidth;
|
|
8655
|
+
const imgHeight = img.naturalHeight;
|
|
8656
|
+
const imgRatio = imgWidth / imgHeight;
|
|
8657
|
+
// ratio < transRatio => h不变,改w
|
|
8658
|
+
// ratio > transRatio => w不变,改h
|
|
8659
|
+
if (this.currentRatio == 0) {
|
|
8660
|
+
resolve({
|
|
8661
|
+
left: 0,
|
|
8662
|
+
right: 0,
|
|
8663
|
+
top: 0,
|
|
8664
|
+
bottom: 0,
|
|
8665
|
+
maxWidth: imgWidth,
|
|
8666
|
+
maxHeight: imgHeight
|
|
8667
|
+
});
|
|
8668
|
+
} else if (imgRatio == Number(this.ratio[this.currentRatio].ratio)) {
|
|
8669
|
+
// message.warning('目前的比例和原图比例一致,请选择其他比例')
|
|
8670
|
+
reject(new Error("目前的比例和原图比例一致,请选择其他比例"));
|
|
8671
|
+
} else if (imgRatio < this.ratio[this.currentRatio].ratio) {
|
|
8672
|
+
let transWidth = imgHeight * this.ratio[this.currentRatio].ratio;
|
|
8673
|
+
let leftright = (transWidth - imgWidth) / 2 / imgWidth;
|
|
8674
|
+
resolve({
|
|
8675
|
+
left: leftright,
|
|
8676
|
+
right: leftright,
|
|
8677
|
+
top: 0,
|
|
8678
|
+
bottom: 0,
|
|
8679
|
+
maxWidth: transWidth,
|
|
8680
|
+
maxHeight: imgHeight
|
|
8681
|
+
});
|
|
8682
|
+
} else {
|
|
8683
|
+
let transHeight = imgWidth / this.ratio[this.currentRatio].ratio;
|
|
8684
|
+
let topbottom = (transHeight - imgHeight) / 2 / imgHeight;
|
|
8685
|
+
resolve({
|
|
8686
|
+
left: 0,
|
|
8687
|
+
right: 0,
|
|
8688
|
+
top: topbottom,
|
|
8689
|
+
bottom: topbottom,
|
|
8690
|
+
maxWidth: imgWidth,
|
|
8691
|
+
maxHeight: transHeight
|
|
8692
|
+
});
|
|
8693
|
+
}
|
|
8694
|
+
};
|
|
8695
|
+
});
|
|
8696
|
+
},
|
|
8697
|
+
async checkResult() {
|
|
8698
|
+
if (this.taskId == "") {
|
|
8699
|
+
return;
|
|
8700
|
+
}
|
|
8701
|
+
try {
|
|
8702
|
+
const res = await lib_axios.get(`${this.requestUrl.checkTask}?taskId=${this.taskId}`, {
|
|
8703
|
+
headers: {
|
|
8704
|
+
accessToken: this.$token
|
|
8705
|
+
}
|
|
8706
|
+
});
|
|
8707
|
+
if (res.data.code == 0 && res.data.data.status == 1) {
|
|
8708
|
+
return res.data.data.picUrl;
|
|
8709
|
+
} else if (res.data.code == 0 && res.data.data.status == 2) {
|
|
8710
|
+
// message.warning('生成失败,请重新尝试')
|
|
8711
|
+
this.loading = false;
|
|
8712
|
+
clearInterval(this.interval);
|
|
8713
|
+
return false;
|
|
8714
|
+
}
|
|
8715
|
+
} catch (error) {
|
|
8716
|
+
this.loading = false;
|
|
8717
|
+
clearInterval(this.interval);
|
|
8718
|
+
// message.warning('请重新尝试')
|
|
8719
|
+
}
|
|
8720
|
+
},
|
|
8721
|
+
async expandImg() {
|
|
8722
|
+
this.loading = true;
|
|
8723
|
+
let left = 0,
|
|
8724
|
+
right = 0,
|
|
8725
|
+
top = 0,
|
|
8726
|
+
bottom = 0,
|
|
8727
|
+
maxWidth = 0,
|
|
8728
|
+
maxHeight = 0;
|
|
8729
|
+
try {
|
|
8730
|
+
const result = await this.handleSize();
|
|
8731
|
+
left = result.left;
|
|
8732
|
+
right = result.right;
|
|
8733
|
+
top = result.top;
|
|
8734
|
+
bottom = result.bottom;
|
|
8735
|
+
maxWidth = result.maxWidth;
|
|
8736
|
+
maxHeight = result.maxHeight;
|
|
8737
|
+
} catch (error) {
|
|
8738
|
+
this.loading = false;
|
|
8739
|
+
return;
|
|
8740
|
+
}
|
|
8741
|
+
if (this.currentRatio == 0) {
|
|
8742
|
+
left = this.position[0].value / 100;
|
|
8743
|
+
right = this.position[1].value / 100;
|
|
8744
|
+
top = this.position[2].value / 100;
|
|
8745
|
+
bottom = this.position[3].value / 100;
|
|
8746
|
+
}
|
|
8747
|
+
try {
|
|
8748
|
+
const res = await lib_axios.post(this.requestUrl.openTask, {
|
|
8749
|
+
imageUrl: this.workspaceSrc,
|
|
8750
|
+
left,
|
|
8751
|
+
right,
|
|
8752
|
+
top,
|
|
8753
|
+
bottom,
|
|
8754
|
+
maxWidth: maxWidth * 2,
|
|
8755
|
+
maxHeight: maxHeight * 2
|
|
8756
|
+
}, {
|
|
8757
|
+
headers: {
|
|
8758
|
+
accessToken: this.$token
|
|
8759
|
+
}
|
|
8760
|
+
});
|
|
8761
|
+
if (res.data.code == 0) {
|
|
8762
|
+
this.taskId = res.data.data.taskId;
|
|
8763
|
+
this.interval = setInterval(async () => {
|
|
8764
|
+
let result = await this.checkResult();
|
|
8765
|
+
if (result) {
|
|
8766
|
+
clearInterval(this.interval);
|
|
8767
|
+
this.loading = false;
|
|
8768
|
+
this.workspaceSrc = result;
|
|
8769
|
+
}
|
|
8770
|
+
}, 2000);
|
|
8771
|
+
} else {
|
|
8772
|
+
this.loading = false;
|
|
8773
|
+
// message.warning(res.data.message)
|
|
8774
|
+
}
|
|
8775
|
+
} catch (error) {
|
|
8776
|
+
this.loading = false;
|
|
8777
|
+
// message.warning('请重新尝试')
|
|
8778
|
+
}
|
|
8779
|
+
},
|
|
8780
|
+
handleOk() {
|
|
8781
|
+
this.$emit("update:visible", false, this.workspaceSrc);
|
|
8782
|
+
}
|
|
8783
|
+
}
|
|
8784
|
+
});
|
|
8785
|
+
;// ./src/components/ExpandImg.vue?vue&type=script&lang=js
|
|
8786
|
+
/* harmony default export */ var components_ExpandImgvue_type_script_lang_js = (ExpandImgvue_type_script_lang_js);
|
|
8787
|
+
;// ./node_modules/.pnpm/mini-css-extract-plugin@2.9.2_webpack@5.99.9/node_modules/mini-css-extract-plugin/dist/loader.js??clonedRuleSet-32.use[0]!./node_modules/.pnpm/css-loader@6.11.0_webpack@5.99.9/node_modules/css-loader/dist/cjs.js??clonedRuleSet-32.use[1]!./node_modules/.pnpm/vue-loader@15.11.1_@vue+compiler-sfc@3.5.16_css-loader@6.11.0_webpack@5.99.9__lodash@4.17.21__w7knhy35vnjmebqosxmmnor4uq/node_modules/vue-loader/lib/loaders/stylePostLoader.js!./node_modules/.pnpm/postcss-loader@6.2.1_postcss@8.5.6_webpack@5.99.9/node_modules/postcss-loader/dist/cjs.js??clonedRuleSet-32.use[2]!./node_modules/.pnpm/less-loader@8.1.1_less@4.3.0_webpack@5.99.9/node_modules/less-loader/dist/cjs.js??clonedRuleSet-32.use[3]!./node_modules/.pnpm/vue-loader@15.11.1_@vue+compiler-sfc@3.5.16_css-loader@6.11.0_webpack@5.99.9__lodash@4.17.21__w7knhy35vnjmebqosxmmnor4uq/node_modules/vue-loader/lib/index.js??vue-loader-options!./src/components/ExpandImg.vue?vue&type=style&index=0&id=b59d9692&prod&lang=less&scoped=true
|
|
8433
8788
|
// extracted by mini-css-extract-plugin
|
|
8434
8789
|
|
|
8435
|
-
;// ./src/components/
|
|
8790
|
+
;// ./src/components/ExpandImg.vue?vue&type=style&index=0&id=b59d9692&prod&lang=less&scoped=true
|
|
8436
8791
|
|
|
8437
|
-
;// ./src/components/
|
|
8792
|
+
;// ./src/components/ExpandImg.vue
|
|
8438
8793
|
|
|
8439
8794
|
|
|
8440
8795
|
|
|
@@ -8443,18 +8798,381 @@ const AIImageExpandResolutionvue_type_script_lang_js_requestUrl = {
|
|
|
8443
8798
|
|
|
8444
8799
|
/* normalize component */
|
|
8445
8800
|
|
|
8446
|
-
var
|
|
8447
|
-
|
|
8448
|
-
|
|
8449
|
-
|
|
8801
|
+
var ExpandImg_component = normalizeComponent(
|
|
8802
|
+
components_ExpandImgvue_type_script_lang_js,
|
|
8803
|
+
ExpandImgvue_type_template_id_b59d9692_scoped_true_render,
|
|
8804
|
+
ExpandImgvue_type_template_id_b59d9692_scoped_true_staticRenderFns,
|
|
8450
8805
|
false,
|
|
8451
8806
|
null,
|
|
8452
|
-
"
|
|
8807
|
+
"b59d9692",
|
|
8453
8808
|
null
|
|
8454
8809
|
|
|
8455
8810
|
)
|
|
8456
8811
|
|
|
8457
|
-
/* harmony default export */ var
|
|
8812
|
+
/* harmony default export */ var ExpandImg = (ExpandImg_component.exports);
|
|
8813
|
+
;// ./node_modules/.pnpm/thread-loader@3.0.4_webpack@5.99.9/node_modules/thread-loader/dist/cjs.js!./node_modules/.pnpm/babel-loader@8.4.1_@babel+core@7.27.4_webpack@5.99.9/node_modules/babel-loader/lib/index.js??clonedRuleSet-40.use[1]!./node_modules/.pnpm/vue-loader@15.11.1_@vue+compiler-sfc@3.5.16_css-loader@6.11.0_webpack@5.99.9__lodash@4.17.21__w7knhy35vnjmebqosxmmnor4uq/node_modules/vue-loader/lib/loaders/templateLoader.js??ruleSet[1].rules[3]!./node_modules/.pnpm/vue-loader@15.11.1_@vue+compiler-sfc@3.5.16_css-loader@6.11.0_webpack@5.99.9__lodash@4.17.21__w7knhy35vnjmebqosxmmnor4uq/node_modules/vue-loader/lib/index.js??vue-loader-options!./src/components/EraserObject.vue?vue&type=template&id=dbae7344&scoped=true
|
|
8814
|
+
var EraserObjectvue_type_template_id_dbae7344_scoped_true_render = function render() {
|
|
8815
|
+
var _vm = this,
|
|
8816
|
+
_c = _vm._self._c;
|
|
8817
|
+
return _c('transition', {
|
|
8818
|
+
attrs: {
|
|
8819
|
+
"name": "fade"
|
|
8820
|
+
}
|
|
8821
|
+
}, [_c('div', {
|
|
8822
|
+
directives: [{
|
|
8823
|
+
name: "show",
|
|
8824
|
+
rawName: "v-show",
|
|
8825
|
+
value: _vm.visible,
|
|
8826
|
+
expression: "visible"
|
|
8827
|
+
}],
|
|
8828
|
+
staticClass: "modal-overlay",
|
|
8829
|
+
on: {
|
|
8830
|
+
"click": function ($event) {
|
|
8831
|
+
if ($event.target !== $event.currentTarget) return null;
|
|
8832
|
+
return _vm.handleMask.apply(null, arguments);
|
|
8833
|
+
}
|
|
8834
|
+
}
|
|
8835
|
+
}, [_c('div', {
|
|
8836
|
+
staticClass: "modal-content"
|
|
8837
|
+
}, [_c('div', {
|
|
8838
|
+
staticClass: "modal-header"
|
|
8839
|
+
}, [_vm._v("AI消除")]), _c('div', {
|
|
8840
|
+
staticClass: "modal-body"
|
|
8841
|
+
}, [_c('div', {
|
|
8842
|
+
staticClass: "container",
|
|
8843
|
+
on: {
|
|
8844
|
+
"click": function ($event) {
|
|
8845
|
+
$event.stopPropagation();
|
|
8846
|
+
}
|
|
8847
|
+
}
|
|
8848
|
+
}, [_c('div', {
|
|
8849
|
+
staticClass: "title"
|
|
8850
|
+
}, [_vm._v("*鼠标框选需要消除的部分后,点击开始消除。消除后,点击应用按钮")]), _c('div', {
|
|
8851
|
+
staticClass: "workspace"
|
|
8852
|
+
}, [_c('img', {
|
|
8853
|
+
ref: "imgRef",
|
|
8854
|
+
attrs: {
|
|
8855
|
+
"src": _vm.workspaceSrc
|
|
8856
|
+
}
|
|
8857
|
+
}), _c('canvas', {
|
|
8858
|
+
ref: "canvasRef",
|
|
8859
|
+
staticStyle: {
|
|
8860
|
+
"z-index": "100",
|
|
8861
|
+
"position": "relative"
|
|
8862
|
+
},
|
|
8863
|
+
on: {
|
|
8864
|
+
"mousedown": _vm.startDrawing,
|
|
8865
|
+
"mousemove": _vm.draw,
|
|
8866
|
+
"mouseup": _vm.stopDrawing
|
|
8867
|
+
}
|
|
8868
|
+
})]), _c('div', {
|
|
8869
|
+
staticStyle: {
|
|
8870
|
+
"display": "flex",
|
|
8871
|
+
"justify-content": "center"
|
|
8872
|
+
}
|
|
8873
|
+
}, [_c('div', {
|
|
8874
|
+
staticClass: "button",
|
|
8875
|
+
on: {
|
|
8876
|
+
"click": _vm.clearCanvas
|
|
8877
|
+
}
|
|
8878
|
+
}, [_vm._v("重置框选")]), _c('div', {
|
|
8879
|
+
staticClass: "button",
|
|
8880
|
+
on: {
|
|
8881
|
+
"click": _vm.eraserObject
|
|
8882
|
+
}
|
|
8883
|
+
}, [_vm._v("开始消除")])]), _c('div', {
|
|
8884
|
+
staticClass: "button",
|
|
8885
|
+
on: {
|
|
8886
|
+
"click": _vm.handleOk
|
|
8887
|
+
}
|
|
8888
|
+
}, [_vm._v("应用")])]), _c('transition', {
|
|
8889
|
+
attrs: {
|
|
8890
|
+
"name": "fade"
|
|
8891
|
+
}
|
|
8892
|
+
}, [_c('div', {
|
|
8893
|
+
directives: [{
|
|
8894
|
+
name: "show",
|
|
8895
|
+
rawName: "v-show",
|
|
8896
|
+
value: _vm.loading,
|
|
8897
|
+
expression: "loading"
|
|
8898
|
+
}],
|
|
8899
|
+
staticClass: "spin-mask"
|
|
8900
|
+
}, [_c('div', {
|
|
8901
|
+
staticClass: "spin-loading"
|
|
8902
|
+
}, [_c('span', {
|
|
8903
|
+
staticClass: "line-md--loading-alt-loop"
|
|
8904
|
+
}), _c('div', [_vm._v("加载中...")])])])])], 1)])])]);
|
|
8905
|
+
};
|
|
8906
|
+
var EraserObjectvue_type_template_id_dbae7344_scoped_true_staticRenderFns = [];
|
|
8907
|
+
|
|
8908
|
+
;// ./node_modules/.pnpm/thread-loader@3.0.4_webpack@5.99.9/node_modules/thread-loader/dist/cjs.js!./node_modules/.pnpm/babel-loader@8.4.1_@babel+core@7.27.4_webpack@5.99.9/node_modules/babel-loader/lib/index.js??clonedRuleSet-40.use[1]!./node_modules/.pnpm/vue-loader@15.11.1_@vue+compiler-sfc@3.5.16_css-loader@6.11.0_webpack@5.99.9__lodash@4.17.21__w7knhy35vnjmebqosxmmnor4uq/node_modules/vue-loader/lib/index.js??vue-loader-options!./src/components/EraserObject.vue?vue&type=script&lang=js
|
|
8909
|
+
|
|
8910
|
+
|
|
8911
|
+
|
|
8912
|
+
const EraserObjectvue_type_script_lang_js_requestUrl = {
|
|
8913
|
+
openTask: `https://apollo.51kandianshi.com/aigc-tools/image-retouch/generate`,
|
|
8914
|
+
checkTask: `https://apollo.51kandianshi.com/aigc-tools/image-retouch/query`
|
|
8915
|
+
};
|
|
8916
|
+
/* harmony default export */ var EraserObjectvue_type_script_lang_js = ({
|
|
8917
|
+
name: "EraserObject",
|
|
8918
|
+
props: {
|
|
8919
|
+
visible: {
|
|
8920
|
+
type: Boolean,
|
|
8921
|
+
default: false
|
|
8922
|
+
},
|
|
8923
|
+
src: {
|
|
8924
|
+
type: String,
|
|
8925
|
+
default: ""
|
|
8926
|
+
}
|
|
8927
|
+
},
|
|
8928
|
+
data() {
|
|
8929
|
+
return {
|
|
8930
|
+
workspaceSrc: this.src,
|
|
8931
|
+
loading: false,
|
|
8932
|
+
taskId: "",
|
|
8933
|
+
interval: null,
|
|
8934
|
+
imgRef: null,
|
|
8935
|
+
canvasRef: null,
|
|
8936
|
+
ctx: null,
|
|
8937
|
+
offscreenCanvas: null,
|
|
8938
|
+
offscreenCtx: null,
|
|
8939
|
+
drawing: false,
|
|
8940
|
+
startX: 0,
|
|
8941
|
+
startY: 0,
|
|
8942
|
+
currentX: 0,
|
|
8943
|
+
currentY: 0,
|
|
8944
|
+
image: new Image()
|
|
8945
|
+
};
|
|
8946
|
+
},
|
|
8947
|
+
watch: {
|
|
8948
|
+
visible: async function (newVal) {
|
|
8949
|
+
if (newVal) {
|
|
8950
|
+
this.workspaceSrc = this.src;
|
|
8951
|
+
await this.$nextTick();
|
|
8952
|
+
this.ctx = this.$refs.canvasRef.getContext("2d");
|
|
8953
|
+
this.initImage();
|
|
8954
|
+
} else {
|
|
8955
|
+
clearInterval(this.interval);
|
|
8956
|
+
}
|
|
8957
|
+
}
|
|
8958
|
+
},
|
|
8959
|
+
methods: {
|
|
8960
|
+
close() {
|
|
8961
|
+
this.$emit("update:visible", false);
|
|
8962
|
+
},
|
|
8963
|
+
handleMask() {
|
|
8964
|
+
if (this.visible) {
|
|
8965
|
+
this.close();
|
|
8966
|
+
}
|
|
8967
|
+
},
|
|
8968
|
+
initImage() {
|
|
8969
|
+
this.image.src = this.workspaceSrc;
|
|
8970
|
+
this.image.onload = () => {
|
|
8971
|
+
this.$refs.canvasRef.width = this.$refs.imgRef.width;
|
|
8972
|
+
this.$refs.canvasRef.height = this.$refs.imgRef.height;
|
|
8973
|
+
this.offscreenCanvas = document.createElement("canvas");
|
|
8974
|
+
this.offscreenCanvas.width = this.$refs.canvasRef.width;
|
|
8975
|
+
this.offscreenCanvas.height = this.$refs.canvasRef.height;
|
|
8976
|
+
this.offscreenCtx = this.offscreenCanvas.getContext("2d");
|
|
8977
|
+
};
|
|
8978
|
+
},
|
|
8979
|
+
startDrawing(event) {
|
|
8980
|
+
this.drawing = true;
|
|
8981
|
+
this.startX = event.offsetX;
|
|
8982
|
+
this.startY = event.offsetY;
|
|
8983
|
+
this.currentX = event.offsetX;
|
|
8984
|
+
this.currentY = event.offsetY;
|
|
8985
|
+
},
|
|
8986
|
+
draw(event) {
|
|
8987
|
+
if (!this.drawing) return;
|
|
8988
|
+
this.currentX = event.offsetX;
|
|
8989
|
+
this.currentY = event.offsetY;
|
|
8990
|
+
this.ctx.clearRect(0, 0, this.$refs.canvasRef.width, this.$refs.canvasRef.height); // Clear canvas
|
|
8991
|
+
this.ctx.drawImage(this.offscreenCanvas, 0, 0);
|
|
8992
|
+
this.drawRect(this.ctx, this.startX, this.startY, this.currentX - this.startX, this.currentY - this.startY);
|
|
8993
|
+
},
|
|
8994
|
+
drawRect(ctx, x, y, width, height, fill = false) {
|
|
8995
|
+
ctx.setLineDash([5, 5]);
|
|
8996
|
+
ctx.strokeStyle = "rgba(104, 106, 237, 1)"; // 保持边框颜色不变
|
|
8997
|
+
ctx.lineWidth = 2;
|
|
8998
|
+
if (fill) {
|
|
8999
|
+
ctx.fillStyle = "rgba(104, 106, 237, 0.4)"; // 保持填充颜色不变
|
|
9000
|
+
ctx.fillRect(x, y, width, height);
|
|
9001
|
+
}
|
|
9002
|
+
ctx.strokeRect(x, y, width, height);
|
|
9003
|
+
ctx.setLineDash([]);
|
|
9004
|
+
},
|
|
9005
|
+
stopDrawing() {
|
|
9006
|
+
if (!this.drawing) return;
|
|
9007
|
+
this.drawing = false;
|
|
9008
|
+
this.drawRect(this.offscreenCtx, this.startX, this.startY, this.currentX - this.startX, this.currentY - this.startY, true);
|
|
9009
|
+
this.ctx.clearRect(0, 0, this.$refs.canvasRef.width, this.$refs.canvasRef.height); // Clear canvas
|
|
9010
|
+
this.ctx.drawImage(this.offscreenCanvas, 0, 0);
|
|
9011
|
+
},
|
|
9012
|
+
clearCanvas() {
|
|
9013
|
+
this.ctx.clearRect(0, 0, this.$refs.canvasRef.width, this.$refs.canvasRef.height);
|
|
9014
|
+
this.offscreenCtx.clearRect(0, 0, this.offscreenCanvas.width, this.offscreenCanvas.height);
|
|
9015
|
+
},
|
|
9016
|
+
async checkResult() {
|
|
9017
|
+
if (this.taskId == "") {
|
|
9018
|
+
return;
|
|
9019
|
+
}
|
|
9020
|
+
try {
|
|
9021
|
+
const res = await lib_axios.get(`${EraserObjectvue_type_script_lang_js_requestUrl.checkTask}?taskId=${this.taskId}`, {
|
|
9022
|
+
headers: {
|
|
9023
|
+
accessToken: this.$token
|
|
9024
|
+
}
|
|
9025
|
+
});
|
|
9026
|
+
if (res.data.code == 0 && res.data.data.status == 1) {
|
|
9027
|
+
return res.data.data.fileUrl;
|
|
9028
|
+
} else if (res.data.code == 0 && res.data.data.status == 2) {
|
|
9029
|
+
// message.warning('生成失败,请重新尝试')
|
|
9030
|
+
this.loading = false;
|
|
9031
|
+
clearInterval(this.interval);
|
|
9032
|
+
return false;
|
|
9033
|
+
}
|
|
9034
|
+
} catch (error) {
|
|
9035
|
+
this.loading = false;
|
|
9036
|
+
clearInterval(this.interval);
|
|
9037
|
+
// message.warning('请重新尝试')
|
|
9038
|
+
}
|
|
9039
|
+
},
|
|
9040
|
+
async eraserObject() {
|
|
9041
|
+
let md5 = await this.getImageMd5(this.workspaceSrc);
|
|
9042
|
+
this.loading = true;
|
|
9043
|
+
let maskFile = this.buildBase64();
|
|
9044
|
+
try {
|
|
9045
|
+
const res = await lib_axios.post(EraserObjectvue_type_script_lang_js_requestUrl.openTask, {
|
|
9046
|
+
sourceFileUrl: this.workspaceSrc,
|
|
9047
|
+
sourceMd5: md5,
|
|
9048
|
+
maskFile
|
|
9049
|
+
}, {
|
|
9050
|
+
headers: {
|
|
9051
|
+
accessToken: this.$token
|
|
9052
|
+
}
|
|
9053
|
+
});
|
|
9054
|
+
if (res.data.code == 0) {
|
|
9055
|
+
this.taskId = res.data.data.taskId;
|
|
9056
|
+
this.interval = setInterval(async () => {
|
|
9057
|
+
let result = await this.checkResult();
|
|
9058
|
+
if (result) {
|
|
9059
|
+
clearInterval(this.interval);
|
|
9060
|
+
this.loading = false;
|
|
9061
|
+
this.clearCanvas();
|
|
9062
|
+
this.workspaceSrc = result;
|
|
9063
|
+
}
|
|
9064
|
+
}, 2000);
|
|
9065
|
+
} else {
|
|
9066
|
+
this.loading = false;
|
|
9067
|
+
// message.warning(res.data.message)
|
|
9068
|
+
}
|
|
9069
|
+
} catch (error) {
|
|
9070
|
+
this.loading = false;
|
|
9071
|
+
// message.warning('请重新尝试')
|
|
9072
|
+
}
|
|
9073
|
+
},
|
|
9074
|
+
handleOk() {
|
|
9075
|
+
this.$emit("update:visible", false, this.workspaceSrc);
|
|
9076
|
+
},
|
|
9077
|
+
async getImageMd5(url) {
|
|
9078
|
+
try {
|
|
9079
|
+
// 使用 fetch 下载图片作为 blob
|
|
9080
|
+
const response = await fetch(url);
|
|
9081
|
+
if (!response.ok) {
|
|
9082
|
+
throw new Error(`HTTP error! status: ${response.status}`);
|
|
9083
|
+
}
|
|
9084
|
+
const blob = await response.blob();
|
|
9085
|
+
|
|
9086
|
+
// 将 blob 转换为 ArrayBuffer
|
|
9087
|
+
const arrayBuffer = await blob.arrayBuffer();
|
|
9088
|
+
const uint8Array = new Uint8Array(arrayBuffer);
|
|
9089
|
+
|
|
9090
|
+
// 计算 MD5 值
|
|
9091
|
+
const spark = new (spark_md5_default()).ArrayBuffer();
|
|
9092
|
+
spark.append(uint8Array);
|
|
9093
|
+
const md5Hash = spark.end();
|
|
9094
|
+
console.log("图片的 MD5 值:", md5Hash);
|
|
9095
|
+
return md5Hash;
|
|
9096
|
+
} catch (error) {
|
|
9097
|
+
console.error("获取图片 MD5 值时出错:", error);
|
|
9098
|
+
}
|
|
9099
|
+
},
|
|
9100
|
+
buildBase64() {
|
|
9101
|
+
// 获取原始图片的宽高
|
|
9102
|
+
const originalWidth = this.$refs.imgRef.naturalWidth;
|
|
9103
|
+
const originalHeight = this.$refs.imgRef.naturalHeight;
|
|
9104
|
+
|
|
9105
|
+
// 获取当前Canvas的宽高
|
|
9106
|
+
const canvasWidth = this.$refs.canvasRef.width;
|
|
9107
|
+
const canvasHeight = this.$refs.canvasRef.height;
|
|
9108
|
+
|
|
9109
|
+
// 比例因子
|
|
9110
|
+
const scaleX = originalWidth / canvasWidth;
|
|
9111
|
+
const scaleY = originalHeight / canvasHeight;
|
|
9112
|
+
|
|
9113
|
+
// 创建一个新Canvas元素
|
|
9114
|
+
const canvasBase64 = document.createElement("canvas");
|
|
9115
|
+
const canvasBase64Ctx = canvasBase64.getContext("2d");
|
|
9116
|
+
canvasBase64.width = originalWidth;
|
|
9117
|
+
canvasBase64.height = originalHeight;
|
|
9118
|
+
canvasBase64Ctx.fillStyle = "black";
|
|
9119
|
+
canvasBase64Ctx.fillRect(0, 0, canvasBase64.width, canvasBase64.height);
|
|
9120
|
+
|
|
9121
|
+
// 将现有Canvas上的图形按比例绘制到新Canvas上
|
|
9122
|
+
canvasBase64Ctx.scale(scaleX, scaleY);
|
|
9123
|
+
canvasBase64Ctx.drawImage(this.$refs.canvasRef, 0, 0);
|
|
9124
|
+
canvasBase64Ctx.scale(1 / scaleX, 1 / scaleY); // 还原缩放
|
|
9125
|
+
|
|
9126
|
+
// 遍历像素数据,将非黑色区域改为白色
|
|
9127
|
+
const imageData = canvasBase64Ctx.getImageData(0, 0, canvasBase64.width, canvasBase64.height);
|
|
9128
|
+
const data = imageData.data;
|
|
9129
|
+
for (let i = 0; i < data.length; i += 4) {
|
|
9130
|
+
const red = data[i];
|
|
9131
|
+
const green = data[i + 1];
|
|
9132
|
+
const blue = data[i + 2];
|
|
9133
|
+
const alpha = data[i + 3];
|
|
9134
|
+
|
|
9135
|
+
// 检查是否是非黑色区域
|
|
9136
|
+
if (!(red === 0 && green === 0 && blue === 0)) {
|
|
9137
|
+
data[i] = 255; // 改为白色
|
|
9138
|
+
data[i + 1] = 255;
|
|
9139
|
+
data[i + 2] = 255;
|
|
9140
|
+
data[i + 3] = 255; // 完全不透明
|
|
9141
|
+
}
|
|
9142
|
+
}
|
|
9143
|
+
canvasBase64Ctx.putImageData(imageData, 0, 0);
|
|
9144
|
+
return canvasBase64.toDataURL("image/png").replace("data:image/png;base64,", "");
|
|
9145
|
+
}
|
|
9146
|
+
}
|
|
9147
|
+
});
|
|
9148
|
+
;// ./src/components/EraserObject.vue?vue&type=script&lang=js
|
|
9149
|
+
/* harmony default export */ var components_EraserObjectvue_type_script_lang_js = (EraserObjectvue_type_script_lang_js);
|
|
9150
|
+
;// ./node_modules/.pnpm/mini-css-extract-plugin@2.9.2_webpack@5.99.9/node_modules/mini-css-extract-plugin/dist/loader.js??clonedRuleSet-32.use[0]!./node_modules/.pnpm/css-loader@6.11.0_webpack@5.99.9/node_modules/css-loader/dist/cjs.js??clonedRuleSet-32.use[1]!./node_modules/.pnpm/vue-loader@15.11.1_@vue+compiler-sfc@3.5.16_css-loader@6.11.0_webpack@5.99.9__lodash@4.17.21__w7knhy35vnjmebqosxmmnor4uq/node_modules/vue-loader/lib/loaders/stylePostLoader.js!./node_modules/.pnpm/postcss-loader@6.2.1_postcss@8.5.6_webpack@5.99.9/node_modules/postcss-loader/dist/cjs.js??clonedRuleSet-32.use[2]!./node_modules/.pnpm/less-loader@8.1.1_less@4.3.0_webpack@5.99.9/node_modules/less-loader/dist/cjs.js??clonedRuleSet-32.use[3]!./node_modules/.pnpm/vue-loader@15.11.1_@vue+compiler-sfc@3.5.16_css-loader@6.11.0_webpack@5.99.9__lodash@4.17.21__w7knhy35vnjmebqosxmmnor4uq/node_modules/vue-loader/lib/index.js??vue-loader-options!./src/components/EraserObject.vue?vue&type=style&index=0&id=dbae7344&prod&lang=less&scoped=true
|
|
9151
|
+
// extracted by mini-css-extract-plugin
|
|
9152
|
+
|
|
9153
|
+
;// ./src/components/EraserObject.vue?vue&type=style&index=0&id=dbae7344&prod&lang=less&scoped=true
|
|
9154
|
+
|
|
9155
|
+
;// ./src/components/EraserObject.vue
|
|
9156
|
+
|
|
9157
|
+
|
|
9158
|
+
|
|
9159
|
+
;
|
|
9160
|
+
|
|
9161
|
+
|
|
9162
|
+
/* normalize component */
|
|
9163
|
+
|
|
9164
|
+
var EraserObject_component = normalizeComponent(
|
|
9165
|
+
components_EraserObjectvue_type_script_lang_js,
|
|
9166
|
+
EraserObjectvue_type_template_id_dbae7344_scoped_true_render,
|
|
9167
|
+
EraserObjectvue_type_template_id_dbae7344_scoped_true_staticRenderFns,
|
|
9168
|
+
false,
|
|
9169
|
+
null,
|
|
9170
|
+
"dbae7344",
|
|
9171
|
+
null
|
|
9172
|
+
|
|
9173
|
+
)
|
|
9174
|
+
|
|
9175
|
+
/* harmony default export */ var EraserObject = (EraserObject_component.exports);
|
|
8458
9176
|
;// ./src/utils/theme.js
|
|
8459
9177
|
function hexToHSL(hex) {
|
|
8460
9178
|
let r = parseInt(hex.slice(1, 3), 16) / 255;
|
|
@@ -8520,7 +9238,9 @@ function lighten(hex, amount) {
|
|
|
8520
9238
|
|
|
8521
9239
|
|
|
8522
9240
|
|
|
8523
|
-
|
|
9241
|
+
|
|
9242
|
+
|
|
9243
|
+
const components = [ImageMatting, ExpandResolution, ExpandImg, EraserObject];
|
|
8524
9244
|
|
|
8525
9245
|
// 暴露安装方法和组件
|
|
8526
9246
|
const ImageProcessing = function (Vue, options = {}) {
|