添加一些注释

This commit is contained in:
林艺 2022-12-29 10:12:56 +08:00
parent bd94c3c58c
commit a90e7146cb
7 changed files with 272 additions and 76 deletions

174
main.js
View File

@ -1374,13 +1374,22 @@ module.exports = {
username: '', username: '',
password: '' password: ''
}, },
isLogin: false isLogin: false // 是否已登录
} }
}, },
methods: { methods: {
/**
* @description: 扫码登录
* @return {*}
*/
showQrcode() { showQrcode() {
console.log("扫码登录"); console.log("扫码登录");
}, },
/**
* @description: mousedown 事件
* @param {*} e
* @return {*}
*/
mousedownFn(e) { mousedownFn(e) {
// mounted里获取不到dragDiv和moveDiv的offsetWidth所以暂时在这取值 // mounted里获取不到dragDiv和moveDiv的offsetWidth所以暂时在这取值
if (!this.maxwidth) { if (!this.maxwidth) {
@ -1391,7 +1400,11 @@ module.exports = {
this.mouseMoveStata = true; this.mouseMoveStata = true;
this.beginClientX = e.clientX; this.beginClientX = e.clientX;
} }
}, //mousedoen 事件 },
/**
* @description: 验证成功函数
* @return {*}
*/
successFunction() { successFunction() {
this.confirmSuccess = true; this.confirmSuccess = true;
this.confirmWords = "验证通过"; this.confirmWords = "验证通过";
@ -1403,7 +1416,12 @@ module.exports = {
} }
this.$refs.moveBgDiv.style.left = this.maxwidth + "px"; this.$refs.moveBgDiv.style.left = this.maxwidth + "px";
this.$refs.dragBg.style.width = this.maxwidth + "px"; this.$refs.dragBg.style.width = this.maxwidth + "px";
}, //验证成功函数 },
/**
* @description: mousemove事件
* @param {*} e
* @return {*}
*/
mouseMoveFn(e) { mouseMoveFn(e) {
if (this.mouseMoveStata) { if (this.mouseMoveStata) {
let width = e.clientX - this.beginClientX; let width = e.clientX - this.beginClientX;
@ -1414,7 +1432,12 @@ module.exports = {
this.successFunction(); this.successFunction();
} }
} }
}, //mousemove事件 },
/**
* @description: mouseup事件
* @param {*} e
* @return {*}
*/
moseUpFn(e) { moseUpFn(e) {
this.mouseMoveStata = false; this.mouseMoveStata = false;
var width = e.clientX - this.beginClientX; var width = e.clientX - this.beginClientX;
@ -1422,19 +1445,21 @@ module.exports = {
this.$refs.dragBg.style.width = 0 + "px"; this.$refs.dragBg.style.width = 0 + "px";
this.$refs.moveBgDiv.style.left = 0 + "px"; this.$refs.moveBgDiv.style.left = 0 + "px";
} }
}, //mouseup事件 },
// 设置监听事件 /**
* @description: 设置监听事件
* @return {*}
*/
setEventListener() { setEventListener() {
if (!this.isLogin) { if (!this.isLogin) {
this.$refs.moveDiv.addEventListener("mousemove", this.mouseMoveFn); this.$refs.moveDiv.addEventListener("mousemove", this.mouseMoveFn);
this.$refs.moveDiv.addEventListener("mouseup", this.moseUpFn); this.$refs.moveDiv.addEventListener("mouseup", this.moseUpFn);
} }
}, },
resetMoveDiv() { /**
this.setEventListener(); * @description: 登录接口
this.confirmSuccess = false; * @return {*}
this.confirmWords = "按住滑块滑动,拖到最右边"; */
},
async login() { async login() {
if (this.loginForm.username && this.loginForm.password && this.confirmSuccess) { if (this.loginForm.username && this.loginForm.password && this.confirmSuccess) {
const res = await Panel.login(this.loginForm); const res = await Panel.login(this.loginForm);
@ -1541,8 +1566,7 @@ const store = __webpack_require__(/*! ../store/index.js */ "./src/store/index.js
module.exports = { module.exports = {
data() { data() {
return { return {
curpanel: "selected", // 选择的画板 curpanel: "selected", // 选择画板的方式
// artboardsName: [],
state: store.state, state: store.state,
showArtboardsName: [], showArtboardsName: [],
projects: [ projects: [
@ -1560,21 +1584,43 @@ module.exports = {
} }
}, },
methods: { methods: {
// 画板单选框改变 /**
* @description: 选择画板方式的单选框改变
* @return {*}
*/
getRadioVal() { getRadioVal() {
this.curpanel === "selected" && (this.showArtboardsName = this.state.artboardsName); this.curpanel === "selected" && (this.showArtboardsName = this.state.artboardsName);
this.curpanel === "all" && (this.showArtboardsName = this.state.allArtboardsName); this.curpanel === "all" && (this.showArtboardsName = this.state.allArtboardsName);
}, },
// 选择框选项改变 /**
* @description: select选项改变
* @param {*} e
* @param {*} prop: select绑定的参数名
* @return {*}
*/
changeOption(e, prop) { changeOption(e, prop) {
this[prop] = e.target.value; this[prop] = e.target.value;
}, },
/**
* @description: 打开新建版本弹窗
* @return {*}
*/
toNewVer() { toNewVer() {
if (this.dialog) { if (this.dialog) {
this.dialog.showModal(); this.dialog.showModal();
} }
}, },
// 覆盖上传 /**
* @description: 关闭新建版本弹窗
* @return {*}
*/
close() {
this.dialog.close();
},
/**
* @description: 覆盖上传
* @return {*}
*/
toUpload() { toUpload() {
// const msg = { // const msg = {
// curpanel: this.curpanel, // curpanel: this.curpanel,
@ -1583,9 +1629,10 @@ module.exports = {
// } // }
// console.log("上传信息:", msg); // console.log("上传信息:", msg);
}, },
close() { /**
this.dialog.close(); * @description: 获取项目名称列表
}, * @return {*}
*/
async getProjectList() { async getProjectList() {
const data = { const data = {
pageSize: 10, pageSize: 10,
@ -10920,6 +10967,11 @@ __webpack_require__.r(__webpack_exports__);
class Panel { class Panel {
/**
* @description: 登录接口
* @param {*} data
* @return {*}
*/
static async login(data) { static async login(data) {
try { try {
const res = await _xhr_js__WEBPACK_IMPORTED_MODULE_0__["default"].post('/teamco-dev/sys/loginNoCode', data); const res = await _xhr_js__WEBPACK_IMPORTED_MODULE_0__["default"].post('/teamco-dev/sys/loginNoCode', data);
@ -10928,6 +10980,11 @@ class Panel {
return false return false
} }
} }
/**
* @description: 项目名称列表接口
* @param {*} data
* @return {*}
*/
static async getProjectList(data) { static async getProjectList(data) {
try { try {
const res = await _xhr_js__WEBPACK_IMPORTED_MODULE_0__["default"].get('/teamco-dev/project/info/jhTcProjectInfo/list', data); const res = await _xhr_js__WEBPACK_IMPORTED_MODULE_0__["default"].get('/teamco-dev/project/info/jhTcProjectInfo/list', data);
@ -10950,22 +11007,35 @@ class Panel {
"use strict"; "use strict";
__webpack_require__.r(__webpack_exports__); __webpack_require__.r(__webpack_exports__);
/**
* @description: 封装一个类能给 localStorage 存储的值设置过期时间如给存储在本地的用于登录 token 设置过期时间
*/
class Storage { class Storage {
constructor(name) { constructor(name) {
this.name = 'storage'; this.name = 'storage';
} }
//设置缓存 /**
setItem(name, value, expires = null) { * @description: 设置缓存
* @param {*} keyName: 要创建或更新的键名
* @param {*} keyValue: 要创建或更新的键名对应的值
* @param {*} expires: 过期时间单位
* @return {*}
*/
setItem(keyName, keyValue, expires = null) {
const options = { const options = {
value: value, keyValue: keyValue,
expires: expires ? expires * 1000 : null, expires: expires ? expires * 1000 : null,
startTime: expires ? new Date().getTime() : 0 startTime: expires ? new Date().getTime() : 0
} }
localStorage.setItem(name, JSON.stringify(options)); localStorage.setItem(keyName, JSON.stringify(options));
} }
//拿到缓存 /**
getItem(name) { * @description: 返回对应键名的值
let item = localStorage.getItem(name); * @param {*} keyName: 一个包含键名的 DOMString
* @return {*} 一个 DOMString键名对应的值如果键名不存在于存储中则返回 null
*/
getItem(keyName) {
let item = localStorage.getItem(keyName);
if (item === null) return null; if (item === null) return null;
item = JSON.parse(item); item = JSON.parse(item);
//如果有 startTime 的值,说明设置了失效时间 //如果有 startTime 的值,说明设置了失效时间
@ -10974,22 +11044,29 @@ class Storage {
//何时将值取出减去刚存入的时间与item.expires比较如果大于就是过期了如果小于或等于就还没过期 //何时将值取出减去刚存入的时间与item.expires比较如果大于就是过期了如果小于或等于就还没过期
if (date - item.startTime > item.expires) { if (date - item.startTime > item.expires) {
//缓存过期清除缓存返回false //缓存过期清除缓存返回false
localStorage.removeItem(name); localStorage.removeItem(keyName);
return null; return null;
} else { } else {
//缓存未过期,返回值 //缓存未过期,返回值
return item.value; return item.keyValue;
} }
} else { } else {
//如果没有设置失效时间,直接返回值 //如果没有设置失效时间,直接返回值
return item.value; return item.keyValue;
} }
} }
//移出缓存 /**
removeItem(name) { * @description: 接受一个键名作为参数 localStorage 对象中删除该键名
localStorage.removeItem(name); * @param {*} keyName: 想要移除的键名
* @return {*}
*/
removeItem(keyName) {
localStorage.removeItem(keyName);
} }
//移出全部缓存 /**
* @description: 清空存储对象里所有的键值
* @return {*}
*/
clear() { clear() {
localStorage.clear(); localStorage.clear();
} }
@ -11010,6 +11087,11 @@ class Storage {
__webpack_require__.r(__webpack_exports__); __webpack_require__.r(__webpack_exports__);
const { TEAMCO_BASE_URL } = __webpack_require__(/*! ../const.js */ "./src/const.js"); const { TEAMCO_BASE_URL } = __webpack_require__(/*! ../const.js */ "./src/const.js");
/**
* @description: 将对象转可拼接到 url 后的字符串
* @param {Object} data
* @return {*}
*/
const getQueryString = (data) => { const getQueryString = (data) => {
let paramsArr = []; let paramsArr = [];
if (data && data instanceof Object) { if (data && data instanceof Object) {
@ -11022,6 +11104,11 @@ const getQueryString = (data) => {
return '' return ''
} }
/**
* @description: 简单封装 XMLHttpRequest
* @param {*} settings
* @return {*}
*/
function xhrBinary(settings) { function xhrBinary(settings) {
const headers = settings.headers || {}; const headers = settings.headers || {};
let reqCfg = { let reqCfg = {
@ -11136,7 +11223,12 @@ const App = __webpack_require__(/*! ./App.vue */ "./src/App.vue").default;
const store = __webpack_require__(/*! ./store/index.js */ "./src/store/index.js").default; const store = __webpack_require__(/*! ./store/index.js */ "./src/store/index.js").default;
const Storage = __webpack_require__(/*! ./api/storage.js */ "./src/api/storage.js").default; const Storage = __webpack_require__(/*! ./api/storage.js */ "./src/api/storage.js").default;
function show() { /**
* @description: one of the lifecycle methods for a panel plugin(is required), called when your plugin is made visible to the user
* @param {*} event: includes a node property that you can attach your user interface to
* @return {*}
*/
function show(event) {
document.body.innerHTML = `<div id="app"></div>`; document.body.innerHTML = `<div id="app"></div>`;
Vue.prototype.$store = store; Vue.prototype.$store = store;
Vue.prototype.$storage = new Storage(); Vue.prototype.$storage = new Storage();
@ -11144,14 +11236,20 @@ function show() {
render: h => h(App) render: h => h(App)
}).$mount('#app') }).$mount('#app')
let html = document.getElementsByTagName("html")[0]; let html = document.getElementsByTagName("html")[0];
// html.style.width = "375px";
html.style.backgroundColor = "#ffffff"; html.style.backgroundColor = "#ffffff";
// let body = document.getElementsByTagName("body")[0]; // let body = document.getElementsByTagName("body")[0];
// body.classList.remove("uxp-plugin"); // body.classList.remove("uxp-plugin");
} }
function update(selection, SceneNode) { /**
console.log(selection); * @description: an optional function
store.setAllArtboardsAction(SceneNode.children); * called whenever the user changes the selection in the XD document or mutates a node within that selection
* provides two arguments, selection and documentRoot
* @param {*} selection
* @param {*} documentRoot
* @return {*}
*/
function update(selection, documentRoot) {
store.setAllArtboardsAction(documentRoot.children);
const { Artboard } = __webpack_require__(/*! scenegraph */ "scenegraph"); const { Artboard } = __webpack_require__(/*! scenegraph */ "scenegraph");
if (!selection || !(selection.items[0] instanceof Artboard)) { if (!selection || !(selection.items[0] instanceof Artboard)) {
store.clearArtboardsAction(); store.clearArtboardsAction();

View File

@ -99,13 +99,22 @@ module.exports = {
username: '', username: '',
password: '' password: ''
}, },
isLogin: false isLogin: false //
} }
}, },
methods: { methods: {
/**
* @description: 扫码登录
* @return {*}
*/
showQrcode() { showQrcode() {
console.log("扫码登录"); console.log("扫码登录");
}, },
/**
* @description: mousedown 事件
* @param {*} e
* @return {*}
*/
mousedownFn(e) { mousedownFn(e) {
// mounteddragDivmoveDivoffsetWidth // mounteddragDivmoveDivoffsetWidth
if (!this.maxwidth) { if (!this.maxwidth) {
@ -116,7 +125,11 @@ module.exports = {
this.mouseMoveStata = true; this.mouseMoveStata = true;
this.beginClientX = e.clientX; this.beginClientX = e.clientX;
} }
}, //mousedoen },
/**
* @description: 验证成功函数
* @return {*}
*/
successFunction() { successFunction() {
this.confirmSuccess = true; this.confirmSuccess = true;
this.confirmWords = "验证通过"; this.confirmWords = "验证通过";
@ -128,7 +141,12 @@ module.exports = {
} }
this.$refs.moveBgDiv.style.left = this.maxwidth + "px"; this.$refs.moveBgDiv.style.left = this.maxwidth + "px";
this.$refs.dragBg.style.width = this.maxwidth + "px"; this.$refs.dragBg.style.width = this.maxwidth + "px";
}, // },
/**
* @description: mousemove事件
* @param {*} e
* @return {*}
*/
mouseMoveFn(e) { mouseMoveFn(e) {
if (this.mouseMoveStata) { if (this.mouseMoveStata) {
let width = e.clientX - this.beginClientX; let width = e.clientX - this.beginClientX;
@ -139,7 +157,12 @@ module.exports = {
this.successFunction(); this.successFunction();
} }
} }
}, //mousemove },
/**
* @description: mouseup事件
* @param {*} e
* @return {*}
*/
moseUpFn(e) { moseUpFn(e) {
this.mouseMoveStata = false; this.mouseMoveStata = false;
var width = e.clientX - this.beginClientX; var width = e.clientX - this.beginClientX;
@ -147,19 +170,21 @@ module.exports = {
this.$refs.dragBg.style.width = 0 + "px"; this.$refs.dragBg.style.width = 0 + "px";
this.$refs.moveBgDiv.style.left = 0 + "px"; this.$refs.moveBgDiv.style.left = 0 + "px";
} }
}, //mouseup },
// /**
* @description: 设置监听事件
* @return {*}
*/
setEventListener() { setEventListener() {
if (!this.isLogin) { if (!this.isLogin) {
this.$refs.moveDiv.addEventListener("mousemove", this.mouseMoveFn); this.$refs.moveDiv.addEventListener("mousemove", this.mouseMoveFn);
this.$refs.moveDiv.addEventListener("mouseup", this.moseUpFn); this.$refs.moveDiv.addEventListener("mouseup", this.moseUpFn);
} }
}, },
resetMoveDiv() { /**
this.setEventListener(); * @description: 登录接口
this.confirmSuccess = false; * @return {*}
this.confirmWords = "按住滑块滑动,拖到最右边"; */
},
async login() { async login() {
if (this.loginForm.username && this.loginForm.password && this.confirmSuccess) { if (this.loginForm.username && this.loginForm.password && this.confirmSuccess) {
const res = await Panel.login(this.loginForm); const res = await Panel.login(this.loginForm);

View File

@ -1,6 +1,11 @@
import api from "./xhr.js"; import api from "./xhr.js";
class Panel { class Panel {
/**
* @description: 登录接口
* @param {*} data
* @return {*}
*/
static async login(data) { static async login(data) {
try { try {
const res = await api.post('/teamco-dev/sys/loginNoCode', data); const res = await api.post('/teamco-dev/sys/loginNoCode', data);
@ -9,6 +14,11 @@ class Panel {
return false return false
} }
} }
/**
* @description: 项目名称列表接口
* @param {*} data
* @return {*}
*/
static async getProjectList(data) { static async getProjectList(data) {
try { try {
const res = await api.get('/teamco-dev/project/info/jhTcProjectInfo/list', data); const res = await api.get('/teamco-dev/project/info/jhTcProjectInfo/list', data);

View File

@ -1,19 +1,32 @@
/**
* @description: 封装一个类能给 localStorage 存储的值设置过期时间如给存储在本地的用于登录 token 设置过期时间
*/
class Storage { class Storage {
constructor(name) { constructor(name) {
this.name = 'storage'; this.name = 'storage';
} }
//设置缓存 /**
setItem(name, value, expires = null) { * @description: 设置缓存
* @param {*} keyName: 要创建或更新的键名
* @param {*} keyValue: 要创建或更新的键名对应的值
* @param {*} expires: 过期时间单位
* @return {*}
*/
setItem(keyName, keyValue, expires = null) {
const options = { const options = {
value: value, keyValue: keyValue,
expires: expires ? expires * 1000 : null, expires: expires ? expires * 1000 : null,
startTime: expires ? new Date().getTime() : 0 startTime: expires ? new Date().getTime() : 0
} }
localStorage.setItem(name, JSON.stringify(options)); localStorage.setItem(keyName, JSON.stringify(options));
} }
//拿到缓存 /**
getItem(name) { * @description: 返回对应键名的值
let item = localStorage.getItem(name); * @param {*} keyName: 一个包含键名的 DOMString
* @return {*} 一个 DOMString键名对应的值如果键名不存在于存储中则返回 null
*/
getItem(keyName) {
let item = localStorage.getItem(keyName);
if (item === null) return null; if (item === null) return null;
item = JSON.parse(item); item = JSON.parse(item);
//如果有 startTime 的值,说明设置了失效时间 //如果有 startTime 的值,说明设置了失效时间
@ -22,22 +35,29 @@ class Storage {
//何时将值取出减去刚存入的时间与item.expires比较如果大于就是过期了如果小于或等于就还没过期 //何时将值取出减去刚存入的时间与item.expires比较如果大于就是过期了如果小于或等于就还没过期
if (date - item.startTime > item.expires) { if (date - item.startTime > item.expires) {
//缓存过期清除缓存返回false //缓存过期清除缓存返回false
localStorage.removeItem(name); localStorage.removeItem(keyName);
return null; return null;
} else { } else {
//缓存未过期,返回值 //缓存未过期,返回值
return item.value; return item.keyValue;
} }
} else { } else {
//如果没有设置失效时间,直接返回值 //如果没有设置失效时间,直接返回值
return item.value; return item.keyValue;
} }
} }
//移出缓存 /**
removeItem(name) { * @description: 接受一个键名作为参数 localStorage 对象中删除该键名
localStorage.removeItem(name); * @param {*} keyName: 想要移除的键名
* @return {*}
*/
removeItem(keyName) {
localStorage.removeItem(keyName);
} }
//移出全部缓存 /**
* @description: 清空存储对象里所有的键值
* @return {*}
*/
clear() { clear() {
localStorage.clear(); localStorage.clear();
} }

View File

@ -1,5 +1,10 @@
const { TEAMCO_BASE_URL } = require("../const.js"); const { TEAMCO_BASE_URL } = require("../const.js");
/**
* @description: 将对象转可拼接到 url 后的字符串
* @param {Object} data
* @return {*}
*/
const getQueryString = (data) => { const getQueryString = (data) => {
let paramsArr = []; let paramsArr = [];
if (data && data instanceof Object) { if (data && data instanceof Object) {
@ -12,6 +17,11 @@ const getQueryString = (data) => {
return '' return ''
} }
/**
* @description: 简单封装 XMLHttpRequest
* @param {*} settings
* @return {*}
*/
function xhrBinary(settings) { function xhrBinary(settings) {
const headers = settings.headers || {}; const headers = settings.headers || {};
let reqCfg = { let reqCfg = {

View File

@ -6,7 +6,12 @@ const App = require("./App.vue").default;
const store = require("./store/index.js").default; const store = require("./store/index.js").default;
const Storage = require("./api/storage.js").default; const Storage = require("./api/storage.js").default;
function show() { /**
* @description: one of the lifecycle methods for a panel plugin(is required), called when your plugin is made visible to the user
* @param {*} event: includes a node property that you can attach your user interface to
* @return {*}
*/
function show(event) {
document.body.innerHTML = `<div id="app"></div>`; document.body.innerHTML = `<div id="app"></div>`;
Vue.prototype.$store = store; Vue.prototype.$store = store;
Vue.prototype.$storage = new Storage(); Vue.prototype.$storage = new Storage();
@ -14,14 +19,20 @@ function show() {
render: h => h(App) render: h => h(App)
}).$mount('#app') }).$mount('#app')
let html = document.getElementsByTagName("html")[0]; let html = document.getElementsByTagName("html")[0];
// html.style.width = "375px";
html.style.backgroundColor = "#ffffff"; html.style.backgroundColor = "#ffffff";
// let body = document.getElementsByTagName("body")[0]; // let body = document.getElementsByTagName("body")[0];
// body.classList.remove("uxp-plugin"); // body.classList.remove("uxp-plugin");
} }
function update(selection, SceneNode) { /**
console.log(selection); * @description: an optional function
store.setAllArtboardsAction(SceneNode.children); * called whenever the user changes the selection in the XD document or mutates a node within that selection
* provides two arguments, selection and documentRoot
* @param {*} selection
* @param {*} documentRoot
* @return {*}
*/
function update(selection, documentRoot) {
store.setAllArtboardsAction(documentRoot.children);
const { Artboard } = require("scenegraph"); const { Artboard } = require("scenegraph");
if (!selection || !(selection.items[0] instanceof Artboard)) { if (!selection || !(selection.items[0] instanceof Artboard)) {
store.clearArtboardsAction(); store.clearArtboardsAction();

View File

@ -74,8 +74,7 @@ const store = require('../store/index.js').default;
module.exports = { module.exports = {
data() { data() {
return { return {
curpanel: "selected", // curpanel: "selected", //
// artboardsName: [],
state: store.state, state: store.state,
showArtboardsName: [], showArtboardsName: [],
projects: [ projects: [
@ -93,21 +92,43 @@ module.exports = {
} }
}, },
methods: { methods: {
// /**
* @description: 选择画板方式的单选框改变
* @return {*}
*/
getRadioVal() { getRadioVal() {
this.curpanel === "selected" && (this.showArtboardsName = this.state.artboardsName); this.curpanel === "selected" && (this.showArtboardsName = this.state.artboardsName);
this.curpanel === "all" && (this.showArtboardsName = this.state.allArtboardsName); this.curpanel === "all" && (this.showArtboardsName = this.state.allArtboardsName);
}, },
// /**
* @description: select选项改变
* @param {*} e
* @param {*} prop: select绑定的参数名
* @return {*}
*/
changeOption(e, prop) { changeOption(e, prop) {
this[prop] = e.target.value; this[prop] = e.target.value;
}, },
/**
* @description: 打开新建版本弹窗
* @return {*}
*/
toNewVer() { toNewVer() {
if (this.dialog) { if (this.dialog) {
this.dialog.showModal(); this.dialog.showModal();
} }
}, },
// /**
* @description: 关闭新建版本弹窗
* @return {*}
*/
close() {
this.dialog.close();
},
/**
* @description: 覆盖上传
* @return {*}
*/
toUpload() { toUpload() {
// const msg = { // const msg = {
// curpanel: this.curpanel, // curpanel: this.curpanel,
@ -116,9 +137,10 @@ module.exports = {
// } // }
// console.log(":", msg); // console.log(":", msg);
}, },
close() { /**
this.dialog.close(); * @description: 获取项目名称列表
}, * @return {*}
*/
async getProjectList() { async getProjectList() {
const data = { const data = {
pageSize: 10, pageSize: 10,