fix: 去除多余代码

This commit is contained in:
kaizheng(郑凯) 2025-02-20 13:48:08 +08:00
parent 0e22a725fc
commit 10748f97f1
9 changed files with 6 additions and 212 deletions

1
.gitignore vendored
View File

@ -1,5 +1,4 @@
.DS_Store
.upchina
node_modules
/dist
/build

View File

@ -10,7 +10,6 @@
<link rel="icon" href="<%= BASE_URL %>favicon.ico" />
<script src="<%= BASE_URL %>static/js/config.js"></script>
<script src="<%= BASE_URL %>static/js/jquery.min.js"></script>
<script src="<%= BASE_URL %>static/js/up_share.min.js"></script>
<style type="text/css">
@media screen and (min-width: 480px) {
html {

View File

@ -1,6 +1,6 @@
window.config = {
wxAuthUrl: "https://clogin.test.upchina.com/wx_auth?callback=",
webAuthUrl: "https://clogin.test.upchina.com/new",
wxAuthUrl: "",
webAuthUrl: "",
VConsole: true,
userIdList: [],
shareEnv: "production",

View File

@ -1 +0,0 @@
!function(n){function e(n,e){var a="UPEvent."+n;t.exec(a,e)}var t={},a={},o=(new Date).getTime();t.exec=function(n,e){e=e||{};var t=++o;e.callbackId=t,a[t]=e.callback||function(n,e){},delete e.callback;var i='up://["'+n+'",'+JSON.stringify(e)+"]";prompt("TITLE",i)},n.nativeCallback=function(n,e,t){a[n]&&(a[n](e,t,JSON.parse(t)),delete a[n])},n.gCreateEvent=function(n,e){var t=document.createEvent("Events");if(t.initEvent(n,!1,!1),e)for(var a in e)e.hasOwnProperty(a)&&(t[a]=e[a]);return t};var i=function(n){this.type=n,this.handleMap={},this.count=0,this.onHandleCountChange=null};n.gEventHandleMap={create:function(n){return gEventHandleMap[n]=new i(n)},count:0},i.prototype.addEvent=function(n){var e=n.upEventFlag;e||(e=gEventHandleMap.count++,n.upEventFlag=e),this.handleMap[e]||(this.handleMap[e]=n,1==++this.count&&this.onHandleCountChange&&this.onHandleCountChange())},i.prototype.removeEvent=function(n){var e=n.upEventFlag;this.handleMap[e]&&(delete this.handleMap[e],0==--this.count&&this.onHandleCountChange&&this.onHandleCountChange())},i.prototype.fire=function(n){if(this.count){var e=[],t=0,a=Object.keys(this.handleMap);for(t=0;t<a.length;t++)e.push(this.handleMap[a[t]]);for(t=0;t<e.length;t++)e[t](n)}},t.addEventListener=function(n,t){var a=gEventHandleMap[n];a||(a=gEventHandleMap.create(n),a.onHandleCountChange=function(){e(n,{count:this.count})}),a.addEvent(t)},t.removeEventListener=function(n,e){var t=gEventHandleMap[n];t&&t.removeEvent(e)},n.nativeFireEvent=function(e,t){var a=gEventHandleMap[e];if(a){var o=n.gCreateEvent(e,JSON.parse(t));a.fire(o)}},n.upNativeComm=t}(window);

File diff suppressed because one or more lines are too long

View File

@ -1,151 +0,0 @@
const upNativeComm = {};
const cmdQueue = {};
const SCHEME = "up";
let count = new Date().getTime();
upNativeComm.exec = function exec(cmd, option) {
option = option || {};
count += 1;
const callbackId = count;
option.callbackId = callbackId;
cmdQueue[callbackId] = option.callback || function callback() {};
delete option.callback;
const url = `${SCHEME}://["${cmd}",${callbackId},${JSON.stringify(option)}]`;
prompt("TITLE", url);
};
window.nativeCallback = function nativeCallback(callbackId, code, option) {
if (cmdQueue[callbackId]) {
cmdQueue[callbackId](code, option);
}
};
// /////////////////////////////////// 浜嬩欢鏈哄埗 ///////////////////////////////////
// 閫氱煡瀹㈡埛绔簨浠朵俊鎭<E4BF8A>
function notifyEvent(option) {
const cmd = "up.event";
upNativeComm.exec(cmd, option);
}
/**
* 鍒涘缓鍘熺敓鐨別vent瀵硅薄(鍏ㄥ眬鍑芥暟)
* @param type 绫诲瀷
* @param data 鏁版嵁
* @returns {Event}
*/
window.gCreateEvent = function gCreateEvent(type, data) {
const event = document.createEvent("Events");
event.initEvent(type, false, false);
if (data) {
for (const i in data) {
if (Object.prototype.hasOwnProperty.call(data, i)) {
event[i] = data[i];
}
}
}
return event;
};
// 涓€涓被鍨嬩簨浠跺搴斾竴涓狤ventMeta瀹炰緥
const EventMeta = function EventMeta(type) {
this.type = type;
this.handleMap = {}; // 澶勭悊鍑芥暟Map
this.count = 0;
this.onHandleCountChange = null;
};
// 鍏ㄥ眬鍑芥暟
window.gEventHandleMap = {
create(type) {
window.gEventHandleMap[type] = new EventMeta(type);
return window.gEventHandleMap[type];
},
count: 0, // 鍙ユ焺鏍囪瘑
};
EventMeta.prototype.addEvent = function addEvent(handle) {
let flag = handle.upEventFlag;
if (!flag) {
window.gEventHandleMap.count += 1;
flag = window.gEventHandleMap.count;
handle.upEventFlag = flag;
}
// 鍚屼竴涓被鍨嬩簨浠剁粦瀹氬涓浉鍚岀殑澶勭悊鍑芥暟锛屽彧鎵ц涓€娆★紝鑻ユ兂鎵ц澶氭锛屽繀椤婚噰鐢ㄥ尶鍚嶇殑鏂瑰紡
if (!this.handleMap[flag]) {
this.handleMap[flag] = handle;
this.count += 1;
if (this.count === 1) {
if (this.onHandleCountChange) {
this.onHandleCountChange();
}
}
}
};
EventMeta.prototype.removeEvent = function removeEvent(handle) {
const flag = handle.upEventFlag;
if (this.handleMap[flag]) {
delete this.handleMap[flag];
this.count -= 1;
if (this.count === 0) {
if (this.onHandleCountChange) {
this.onHandleCountChange();
}
}
}
};
EventMeta.prototype.fire = function fire(e) {
if (this.count) {
// copy澶勭悊鍑芥暟锛岄槻姝㈠湪璋冪敤澶勭悊鍑芥暟鐨勮繃绋嬩腑handleMap鍙戠敓鏀瑰彉
const handles = [];
let i = 0;
const keys = Object.keys(this.handleMap);
for (i = 0; i < keys.length; i += 1) {
handles.push(this.handleMap[keys[i]]);
}
for (i = 0; i < handles.length; i += 1) {
handles[i](e);
}
}
};
// 娉ㄥ唽浜嬩欢(瀵瑰API)
upNativeComm.addEventListener = function addEventListener(type, handle) {
let eventInstance = window.gEventHandleMap[type];
if (!eventInstance) {
eventInstance = window.gEventHandleMap.create(type);
eventInstance.onHandleCountChange = function onHandleCountChange() {
// 閫氱煡瀹㈡埛绔<E59F9B>
notifyEvent({
count: this.count,
type,
});
};
}
eventInstance.addEvent(handle);
};
// 绉婚櫎浜嬩欢(瀵瑰API)
upNativeComm.removeEventListener = function removeEventListener(type, handle) {
const eventInstance = window.gEventHandleMap[type];
if (eventInstance) {
eventInstance.removeEvent(handle);
}
};
// 鍏ㄥ眬鍑芥暟浜嬩欢瑙﹀彂鍚庯紝瀹㈡埛绔皟鐢ㄧ殑鍑芥暟
window.nativeFireEvent = function nativeFireEvent(type, param) {
const instance = window.gEventHandleMap[type];
if (instance) {
const evt = window.gCreateEvent(type, param);
instance.fire(evt);
}
};
window.upPCNativeComm = upNativeComm;

View File

@ -14,8 +14,8 @@ import { liveStatusObj } from "@/config/constant";
import shieldConfig from "@/config/index";
import { getProductType, dateFormat, getPrice } from "@/utils/filters";
import SvgIcon from "@/components/SvgIcon";
import { terminalType } from "@/utils/index";
import loadScript from "@/utils/loadScript";
// import { terminalType } from "@/utils/index";
// import loadScript from "@/utils/loadScript";
if (window.config.VConsole) {
new VConsole();
@ -44,13 +44,4 @@ const init = () => {
app.component("svg-icon", SvgIcon);
app.mount("#app");
};
if (["App", "PcClient"].includes(terminalType)) {
let url =
terminalType === "App"
? "/h5/static/js/jssdk-app-1.0.1.js"
: "/h5/static/js/webNativeCommunicatePC.js";
loadScript(url, init);
} else {
init();
}
init();

View File

@ -40,6 +40,7 @@ const disabled = ref(true);
const fromData = reactive({
userName: "",
password: "",
loginType: 1,
clientType: 1,
});
watch(fromData, (val) => {

View File

@ -36,18 +36,6 @@ module.exports = defineConfig({
target: "http://8.138.144.54:8080",
changeOrigin: true,
},
"/admin": {
target: "http://lczqvideodev.test.upchina.com",
changeOrigin: true,
},
"/frontend": {
target: "http://lczqvideodev.test.upchina.com",
changeOrigin: true,
},
"/backend": {
target: "http://lczqvideodev.test.upchina.com",
changeOrigin: true,
},
},
},
chainWebpack: (config) => {