修改cookie地址
parent
9f74694d4f
commit
d33f327827
|
|
@ -5,7 +5,7 @@ NODE_ENV='dev'
|
|||
|
||||
VITE_APP_TITLE = 'shopxo'
|
||||
VITE_APP_PORT = 3000
|
||||
VITE_APP_BASE_API = '/dev-api'
|
||||
VITE_APP_BASE_API = '/dev-admin'
|
||||
VITE_APP_BASE_API_URL = 'http://shopxo.com/admin.php/'
|
||||
VITE_APP_BASE_API_PHP = '/dev-php'
|
||||
VITE_APP_BASE_API_PHP = '/dev-api'
|
||||
VITE_APP_BASE_API_PHP_URL = 'http://shopxo.com/api.php'
|
||||
|
|
@ -1,25 +1,25 @@
|
|||
import request from '@/utils/request';
|
||||
import api_request from '@/utils/api-request';
|
||||
|
||||
class ArticleAPI {
|
||||
/** 链接初始化接口 */
|
||||
static getInit() {
|
||||
return request({
|
||||
url: `diyapi/linkinit`,
|
||||
return api_request({
|
||||
url: `?s=diyapi/linkinit`,
|
||||
method: 'post',
|
||||
});
|
||||
}
|
||||
/** 文章指定数据 */
|
||||
static getAppointList(data: any) {
|
||||
return request({
|
||||
url: `diyapi/articleappointdata`,
|
||||
return api_request({
|
||||
url: `?s=diyapi/articleappointdata`,
|
||||
method: 'post',
|
||||
data,
|
||||
});
|
||||
}
|
||||
/** 文章自动数据 */
|
||||
static getAutoList(data: any) {
|
||||
return request({
|
||||
url: `diyapi/articleautodata`,
|
||||
return api_request({
|
||||
url: `?s=diyapi/articleautodata`,
|
||||
method: 'post',
|
||||
data,
|
||||
});
|
||||
|
|
|
|||
|
|
@ -1,10 +1,10 @@
|
|||
import request from '@/utils/request';
|
||||
import api_request from '@/utils/api-request';
|
||||
|
||||
class ShopAPI {
|
||||
/** 自动查询商品接口*/
|
||||
static getBrandLists(data: any) {
|
||||
return request({
|
||||
url: `diyapi/brandautodata`,
|
||||
return api_request({
|
||||
url: `?s=diyapi/brandautodata`,
|
||||
method: 'post',
|
||||
data,
|
||||
});
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
import request from '@/utils/request';
|
||||
import { isEmpty } from 'lodash';
|
||||
|
||||
class CommonAPI {
|
||||
/** 链接初始化接口 */
|
||||
|
|
@ -8,6 +9,20 @@ class CommonAPI {
|
|||
method: 'post',
|
||||
});
|
||||
}
|
||||
/** 动态接口 */
|
||||
static getDynamicApi(url: string, data: any, is_header: boolean = false) {
|
||||
if (!isEmpty(url)) {
|
||||
return request({
|
||||
url: url,
|
||||
method: 'post',
|
||||
...(is_header ? { data: data } : { data }),
|
||||
...(is_header ? { headers: {
|
||||
'Content-Type': 'multipart/form-data',
|
||||
}}: {}),
|
||||
});
|
||||
}
|
||||
return Promise.reject('接口不存在');
|
||||
}
|
||||
}
|
||||
|
||||
export default CommonAPI;
|
||||
export default CommonAPI;
|
||||
|
|
@ -1,10 +1,10 @@
|
|||
import request from '@/utils/request';
|
||||
import api_request from '@/utils/api-request';
|
||||
|
||||
class CustomAPI {
|
||||
/** 分类品牌查询接口*/
|
||||
static getCustominit() {
|
||||
return request({
|
||||
url: `diyapi/custominit`,
|
||||
return api_request({
|
||||
url: `?s=diyapi/custominit`,
|
||||
method: 'post',
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,10 +1,10 @@
|
|||
import request from '@/utils/request';
|
||||
import api_request from '@/utils/api-request';
|
||||
|
||||
class CustomAPI {
|
||||
/** 分类品牌查询接口*/
|
||||
static getGoodsmagicinit() {
|
||||
return request({
|
||||
url: `diyapi/goodsmagicinit`,
|
||||
return api_request({
|
||||
url: `?s=diyapi/goodsmagicinit`,
|
||||
method: 'post',
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,17 +1,16 @@
|
|||
import request from '@/utils/request';
|
||||
import api_request from '@/utils/api-request';
|
||||
class ShopAPI {
|
||||
/** 分类品牌查询接口*/
|
||||
static getShop() {
|
||||
return request({
|
||||
url: `diyapi/goodsinit`,
|
||||
return api_request({
|
||||
url: `?s=diyapi/goodsinit`,
|
||||
method: 'post',
|
||||
});
|
||||
}
|
||||
/** 自动查询商品接口*/
|
||||
static getShopLists(data: any) {
|
||||
return request({
|
||||
url: `diyapi/goodsautodata`,
|
||||
return api_request({
|
||||
url: `?s=diyapi/goodsautodata`,
|
||||
method: 'post',
|
||||
data,
|
||||
});
|
||||
|
|
|
|||
|
|
@ -1,33 +1,33 @@
|
|||
import request from '@/utils/request';
|
||||
import api_request from '@/utils/api-request';
|
||||
|
||||
class UploadAPI {
|
||||
/** 分类查询接口*/
|
||||
static getTree() {
|
||||
return request({
|
||||
url: `attachmentapi/attachmentcategory`,
|
||||
return api_request({
|
||||
url: `?s=attachmentapi/attachmentcategory`,
|
||||
method: 'post',
|
||||
});
|
||||
}
|
||||
/** 分类新增,修改接口 */
|
||||
static saveTree(data: any) {
|
||||
return request({
|
||||
url: `attachmentapi/attachmentcategorysave`,
|
||||
return api_request({
|
||||
url: `?s=attachmentapi/attachmentcategorysave`,
|
||||
method: 'post',
|
||||
data,
|
||||
});
|
||||
}
|
||||
/** 分类删除接口 */
|
||||
static delTree(data: any) {
|
||||
return request({
|
||||
url: `attachmentapi/attachmentcategorydelete`,
|
||||
return api_request({
|
||||
url: `?s=attachmentapi/attachmentcategorydelete`,
|
||||
method: 'post',
|
||||
data,
|
||||
});
|
||||
}
|
||||
/** 附件移动分类 */
|
||||
static moveTree(data: any) {
|
||||
return request({
|
||||
url: `attachmentapi/attachmentmovecategory`,
|
||||
return api_request({
|
||||
url: `?s=attachmentapi/attachmentmovecategory`,
|
||||
method: 'post',
|
||||
data,
|
||||
});
|
||||
|
|
@ -35,32 +35,32 @@ class UploadAPI {
|
|||
|
||||
// 附件列表
|
||||
static getAttachmentList(data: any) {
|
||||
return request({
|
||||
url: `attachmentapi/attachmentlist`,
|
||||
return api_request({
|
||||
url: `?s=attachmentapi/attachmentlist`,
|
||||
method: 'post',
|
||||
data,
|
||||
});
|
||||
}
|
||||
// 附件名称修改
|
||||
static saveAttachmentName(data: any) {
|
||||
return request({
|
||||
url: `attachmentapi/attachmentsave`,
|
||||
return api_request({
|
||||
url: `?s=attachmentapi/attachmentsave`,
|
||||
method: 'post',
|
||||
data,
|
||||
});
|
||||
}
|
||||
// 附件删除
|
||||
static delAttachment(data: any) {
|
||||
return request({
|
||||
url: `attachmentapi/attachmentdelete`,
|
||||
return api_request({
|
||||
url: `?s=attachmentapi/attachmentdelete`,
|
||||
method: 'post',
|
||||
data,
|
||||
});
|
||||
}
|
||||
// 附件上传
|
||||
static uploadAttachment(data: any, progress: any) {
|
||||
return request({
|
||||
url: `attachmentapi/attachmentupload`,
|
||||
return api_request({
|
||||
url: `?s=attachmentapi/attachmentupload`,
|
||||
method: 'post',
|
||||
data,
|
||||
headers: {
|
||||
|
|
@ -71,16 +71,16 @@ class UploadAPI {
|
|||
}
|
||||
// 扫码上传
|
||||
static uploadQrcode(data: any) {
|
||||
return request({
|
||||
url: `attachmentapi/attachmentscanuploaddata`,
|
||||
return api_request({
|
||||
url: `?s=attachmentapi/attachmentscanuploaddata`,
|
||||
method: 'post',
|
||||
data,
|
||||
});
|
||||
}
|
||||
// 提取链接 --------附件远程下载
|
||||
static getAttachmentCatch(data: any) {
|
||||
return request({
|
||||
url: `attachmentapi/attachmentcatch`,
|
||||
return api_request({
|
||||
url: `?s=attachmentapi/attachmentcatch`,
|
||||
method: 'post',
|
||||
data,
|
||||
});
|
||||
|
|
|
|||
|
|
@ -1,35 +1,34 @@
|
|||
import request from '@/utils/request';
|
||||
import api_request from '@/utils/api-request';
|
||||
|
||||
class UrlValueAPI {
|
||||
/** 获取商品列表 */
|
||||
static getGoodsList(data: any) {
|
||||
return request({
|
||||
url: `diyapi/goodslist`,
|
||||
return api_request({
|
||||
url: `?s=diyapi/goodslist`,
|
||||
method: 'post',
|
||||
data,
|
||||
});
|
||||
}
|
||||
/** 获取文章列表 */
|
||||
static getArticleList(data: any) {
|
||||
return request({
|
||||
url: `diyapi/articlelist`,
|
||||
return api_request({
|
||||
url: `?s=diyapi/articlelist`,
|
||||
method: 'post',
|
||||
data,
|
||||
});
|
||||
}
|
||||
/** 获取diy列表 */
|
||||
static getDiyList(data: any) {
|
||||
return request({
|
||||
url: `diyapi/diylist`,
|
||||
return api_request({
|
||||
url: `?s=diyapi/diylist`,
|
||||
method: 'post',
|
||||
data,
|
||||
});
|
||||
}
|
||||
/** 获取页面设计列表 */
|
||||
static getDesignList(data: any) {
|
||||
return request({
|
||||
url: `diyapi/designlist`,
|
||||
return api_request({
|
||||
url: `?s=diyapi/designlist`,
|
||||
method: 'post',
|
||||
data,
|
||||
});
|
||||
|
|
@ -37,16 +36,16 @@ class UrlValueAPI {
|
|||
|
||||
/** 获取自定义列表 */
|
||||
static getCustomList(data: any) {
|
||||
return request({
|
||||
url: `diyapi/customviewlist`,
|
||||
return api_request({
|
||||
url: `?s=diyapi/customviewlist`,
|
||||
method: 'post',
|
||||
data,
|
||||
});
|
||||
}
|
||||
/** 获取品牌列表 */
|
||||
static getBrandList(data: any) {
|
||||
return request({
|
||||
url: `diyapi/brandlist`,
|
||||
return api_request({
|
||||
url: `?s=diyapi/brandlist`,
|
||||
method: 'post',
|
||||
data,
|
||||
});
|
||||
|
|
|
|||
|
|
@ -13,6 +13,7 @@
|
|||
<script setup lang="ts">
|
||||
import { get_cookie, set_cookie, get_math } from '@/utils';
|
||||
import { commonStore } from '@/store';
|
||||
import { get_type } from '@/utils/common';
|
||||
const common_store = commonStore();
|
||||
const props = defineProps({
|
||||
dataId: {
|
||||
|
|
@ -24,15 +25,15 @@ const dialog_visible = defineModel({ type: Boolean, default: false });
|
|||
const new_link = ref('');
|
||||
const index = window.location.href.lastIndexOf('?s=');
|
||||
const pro_url = window.location.href.substring(0, index);
|
||||
// 如果是本地则使用静态tonken如果是线上则使用cookie的token
|
||||
const cookie = get_cookie('admin_info') || '';
|
||||
const token = ref('');
|
||||
const key = ref(0);
|
||||
onMounted(async () => {
|
||||
if (import.meta.env.VITE_APP_BASE_API == '/dev-api') {
|
||||
let temp_data = await import(import.meta.env.VITE_APP_BASE_API == '/dev-api' ? '../../../../temp.d.ts' : '../../../../temp_pro.d');
|
||||
if (import.meta.env.VITE_APP_BASE_API == '/dev-admin') {
|
||||
let temp_data = await import(import.meta.env.VITE_APP_BASE_API == '/dev-admin' ? '../../../../temp.d.ts' : '../../../../temp_pro.d');
|
||||
token.value = '&token=' + temp_data.default.temp_token;
|
||||
} else {
|
||||
// 如果是shop认为是多商户插件使用user_info的cookie
|
||||
const cookie = get_type() == 'shop' ? get_cookie('user_info') : get_cookie('admin_info');
|
||||
if (cookie && cookie !== null && cookie !== 'null') {
|
||||
token.value = '&token=' + JSON.parse(cookie).token;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -132,8 +132,9 @@
|
|||
<script lang="ts" setup>
|
||||
import type { UploadFile } from 'element-plus';
|
||||
import { annex_size_to_unit } from '@/utils';
|
||||
import DiyAPI from '@/api/diy';
|
||||
import CommonAPI from '@/api/common';
|
||||
import { commonStore } from '@/store';
|
||||
import { get_id } from '@/utils/common';
|
||||
const common_store = commonStore();
|
||||
const app = getCurrentInstance();
|
||||
/**
|
||||
|
|
@ -207,7 +208,7 @@ const get_import_list = (type?: string) => {
|
|||
...form.value,
|
||||
is_already_buy: form.value.status ? '1' : '0',
|
||||
};
|
||||
DiyAPI.getImportList(new_data)
|
||||
CommonAPI.getDynamicApi(common_store.common.diy_market_url, new_data)
|
||||
.then((res: any) => {
|
||||
const data = res.data;
|
||||
form.value.data_total = data.data_total;
|
||||
|
|
@ -264,7 +265,7 @@ interface install_data {
|
|||
}
|
||||
const install = async (item: install_data) => {
|
||||
let new_data = item;
|
||||
DiyAPI.install(item)
|
||||
CommonAPI.getDynamicApi(common_store.common.diy_install_url ,item)
|
||||
.then((res: any) => {
|
||||
switch (item.opt) {
|
||||
case 'url':
|
||||
|
|
@ -317,7 +318,7 @@ const confirm_event = () => {
|
|||
if (file_list.value && file_list.value[0].raw) {
|
||||
form_data.append('file', file_list.value[0]?.raw);
|
||||
}
|
||||
DiyAPI.import(form_data)
|
||||
CommonAPI.getDynamicApi(common_store.common.diy_upload_url, form_data, true)
|
||||
.then((res: any) => {
|
||||
ElMessage.success(res.msg);
|
||||
history.pushState({}, '', '?s=diy/saveinfo/id/' + res.data + '.html');
|
||||
|
|
@ -328,21 +329,6 @@ const confirm_event = () => {
|
|||
}
|
||||
};
|
||||
|
||||
// 截取document.location.search字符串内id/后面的所有字段
|
||||
const get_id = () => {
|
||||
let new_id = '';
|
||||
if (document.location.search.indexOf('id/') != -1) {
|
||||
new_id = document.location.search.substring(document.location.search.indexOf('id/') + 3);
|
||||
// 去除字符串的.html
|
||||
let html_index = new_id.indexOf('.html');
|
||||
if (html_index != -1) {
|
||||
new_id = new_id.substring(0, html_index);
|
||||
}
|
||||
return new_id;
|
||||
} else {
|
||||
return new_id;
|
||||
}
|
||||
};
|
||||
</script>
|
||||
<style lang="scss" scoped>
|
||||
.url-value-content {
|
||||
|
|
|
|||
|
|
@ -259,7 +259,7 @@ const category_id_change = (val: any) => {
|
|||
is_mask.value = false;
|
||||
scan_uuid.value = get_math() + '';
|
||||
let new_url = '';
|
||||
if (import.meta.env.VITE_APP_BASE_API == '/dev-api') {
|
||||
if (import.meta.env.VITE_APP_BASE_API == '/dev-admin') {
|
||||
new_url = get_before_string(import.meta.env.VITE_APP_BASE_API_URL);
|
||||
} else {
|
||||
new_url = window.location.origin + '/';
|
||||
|
|
|
|||
|
|
@ -59,7 +59,9 @@
|
|||
<script setup lang="ts">
|
||||
import { cloneDeep } from 'lodash';
|
||||
import { get_math } from '@/utils';
|
||||
import DiyAPI from '@/api/tabbar';
|
||||
import CommonAPI from '@/api/common';
|
||||
import { commonStore } from '@/store';
|
||||
const common_store = commonStore();
|
||||
import defaultFooterNav from '@/config/const/footer-nav';
|
||||
const app = getCurrentInstance();
|
||||
/**
|
||||
|
|
@ -130,7 +132,7 @@ const sync_sys_event = () => {
|
|||
config: clone_form,
|
||||
};
|
||||
app?.appContext.config.globalProperties.$common.message_box('将数据同步到系统底部菜单,确定继续吗?', 'warning').then(() => {
|
||||
DiyAPI.saveTabbar(new_data).then((res: any) => {
|
||||
CommonAPI.getDynamicApi(common_store.common.app_tabbar_save_url, new_data).then((res: any) => {
|
||||
ElMessage.success('同步成功');
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -8,6 +8,14 @@ export const commonStore = defineStore('common', () => {
|
|||
const is_tabs_0_up = ref(false);
|
||||
const header_height = ref(0);
|
||||
const common = ref({
|
||||
app_tabbar_data_url: '' as string, //获取tabbar列表
|
||||
app_tabbar_save_url: '' as string, //保存tabbar
|
||||
diy_detail_url: '' as string, //获取diy详情
|
||||
diy_download_url: '' as string, //diy导出
|
||||
diy_install_url: '' as string, //diy导入 -- 安装
|
||||
diy_market_url: '' as string, //diy导入--获取列表
|
||||
diy_save_url: '' as string, //diy导入--保存
|
||||
diy_upload_url: '' as string, //diy导入
|
||||
article_category: [] as any[], //---- 文章分类
|
||||
blog_category: [] as any[], //---- 文章分类
|
||||
attachment_category: [] as any[], //---- 附件分类
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
import axios, { InternalAxiosRequestConfig, AxiosResponse } from 'axios';
|
||||
import { ElMessage, ElMessageBox, type MessageHandler } from 'element-plus';
|
||||
import { get_cookie } from './index';
|
||||
import { get_type } from './common';
|
||||
|
||||
// 提示拦截
|
||||
|
||||
|
|
@ -30,7 +31,7 @@ const new_data = window.location.href.substring(0, index);
|
|||
const new_index = new_data.lastIndexOf('/');
|
||||
const pro_url = window.location.href.substring(0, new_index);
|
||||
const service = axios.create({
|
||||
baseURL: import.meta.env.VITE_APP_BASE_API_PHP == '/dev-php' ? import.meta.env.VITE_APP_BASE_API_PHP : pro_url + '/api.php',
|
||||
baseURL: import.meta.env.VITE_APP_BASE_API_PHP == '/dev-api' ? import.meta.env.VITE_APP_BASE_API_PHP : pro_url + '/api.php',
|
||||
timeout: 60000,
|
||||
headers: { 'Content-Type': 'application/json;charset=utf-8', 'X-Requested-With': 'XMLHttpRequest' },
|
||||
});
|
||||
|
|
@ -39,12 +40,13 @@ const service = axios.create({
|
|||
service.interceptors.request.use(
|
||||
async (config: InternalAxiosRequestConfig) => {
|
||||
// 如果是本地则使用静态tonken如果是线上则使用cookie的token
|
||||
const cookie = get_cookie('admin_info') || '';
|
||||
const symbol = config.url?.includes('?') ? '&' : '?';
|
||||
if (import.meta.env.VITE_APP_BASE_API_PHP == '/dev-php') {
|
||||
let temp_data = await import(import.meta.env.VITE_APP_BASE_API_PHP == '/dev-php' ? '../../temp.d' : '../../temp_pro.d');
|
||||
if (import.meta.env.VITE_APP_BASE_API_PHP == '/dev-api') {
|
||||
let temp_data = await import(import.meta.env.VITE_APP_BASE_API_PHP == '/dev-api' ? '../../temp.d' : '../../temp_pro.d');
|
||||
config.url = config.url + symbol + 'token=' + temp_data.default.temp_token;
|
||||
} else {
|
||||
// 如果是shop认为是多商户插件使用user_info的cookie
|
||||
const cookie = get_type() == 'shop' ? get_cookie('user_info') : get_cookie('admin_info');
|
||||
if (cookie && cookie !== null && cookie !== 'null') {
|
||||
config.url = config.url + '&token=' + (JSON.parse(cookie) !== 'null' ? JSON.parse(cookie)?.token : '');
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,4 +13,45 @@ export const old_border_and_box_shadow = { border_is_show: '0', border_color: '#
|
|||
export const font_weight = [
|
||||
{ name: '加粗', value: 'bold' },
|
||||
{ name: '正常', value: '400' },
|
||||
];
|
||||
];
|
||||
|
||||
|
||||
// 截取document.location.search字符串内id/后面的所有字段
|
||||
export const get_id = () => {
|
||||
let new_id = '';
|
||||
if (document.location.search.indexOf('id/') != -1) {
|
||||
new_id = document.location.search.substring(document.location.search.indexOf('id/') + 3);
|
||||
// 去除字符串的.html
|
||||
let html_index = new_id.indexOf('.html');
|
||||
if (html_index != -1) {
|
||||
new_id = new_id.substring(0, html_index);
|
||||
}
|
||||
return new_id;
|
||||
} else if (document.location.search.indexOf('shop-diy-saveinfo') != -1) {
|
||||
new_id = document.location.search.substring(document.location.search.indexOf('shop-diy-saveinfo-') + 18);
|
||||
// 去除字符串的.html
|
||||
const dot_data = new_id.split('.')[0];
|
||||
if (dot_data != '') {
|
||||
new_id = dot_data.split('/')[0];
|
||||
}
|
||||
return new_id;
|
||||
} else {
|
||||
return new_id;
|
||||
}
|
||||
};
|
||||
|
||||
export const get_type = () => {
|
||||
let new_type = '';
|
||||
if (document.location.search.indexOf('type/') != -1) {
|
||||
new_type = document.location.search.substring(document.location.search.indexOf('type/') + 5);
|
||||
// 去除字符串的.html
|
||||
// 去除字符串的.html
|
||||
const dot_data = new_type.split('.')[0];
|
||||
if (dot_data != '') {
|
||||
new_type = dot_data.split('/')[0];
|
||||
}
|
||||
return new_type;
|
||||
} else {
|
||||
return new_type;
|
||||
}
|
||||
}
|
||||
|
|
@ -792,15 +792,15 @@ export const tabs_style = (color: string, style: string | number | boolean | und
|
|||
/**
|
||||
* 获取在线资源URL的异步函数
|
||||
* 该函数根据当前环境变量的配置选择不同的方式来获取资源URL
|
||||
* 如果环境变量VITE_APP_BASE_API被设置为'/dev-api',则从本地开发环境中导入临时数据
|
||||
* 如果环境变量VITE_APP_BASE_API被设置为'/dev-admin',则从本地开发环境中导入临时数据
|
||||
* 否则,从cookie中获取资源主机地址
|
||||
* 这种设计允许开发者在不同的环境中灵活切换资源URL的来源,以适应不同的开发和生产需求
|
||||
* @param directory {string} - 资源目录名称
|
||||
* @returns {Promise<string>} 返回一个Promise,解析为包含资源URL的字符串
|
||||
*/
|
||||
export const online_url = async (directory: string = '') => {
|
||||
if (import.meta.env.VITE_APP_BASE_API == '/dev-api') {
|
||||
let temp_data = await import(import.meta.env.VITE_APP_BASE_API == '/dev-api' ? '../../temp.d' : '../../temp_pro.d');
|
||||
if (import.meta.env.VITE_APP_BASE_API == '/dev-admin') {
|
||||
let temp_data = await import(import.meta.env.VITE_APP_BASE_API == '/dev-admin' ? '../../temp.d' : '../../temp_pro.d');
|
||||
return temp_data.default.temp_attachment_host + directory;
|
||||
} else {
|
||||
// let attachemnt_host = common.config.attachment_host;
|
||||
|
|
|
|||
|
|
@ -1,9 +1,8 @@
|
|||
import axios, { InternalAxiosRequestConfig, AxiosResponse } from 'axios';
|
||||
import { ElMessage, ElMessageBox, type MessageHandler } from 'element-plus';
|
||||
import { get_cookie } from './index';
|
||||
|
||||
import { get_type } from '@/utils/common';
|
||||
// 提示拦截
|
||||
|
||||
let messageInstance: MessageHandler;
|
||||
const message_error = (info: string) => {
|
||||
if (messageInstance) {
|
||||
|
|
@ -28,7 +27,7 @@ const release_url = ['attachmentapi/attachmentupload'];
|
|||
const index = window.location.href.lastIndexOf('?s=');
|
||||
const pro_url = window.location.href.substring(0, index);
|
||||
const service = axios.create({
|
||||
baseURL: import.meta.env.VITE_APP_BASE_API == '/dev-api' ? import.meta.env.VITE_APP_BASE_API : pro_url + '?s=',
|
||||
baseURL: import.meta.env.VITE_APP_BASE_API == '/dev-admin' ? import.meta.env.VITE_APP_BASE_API : pro_url + '?s=',
|
||||
timeout: 60000,
|
||||
headers: { 'Content-Type': 'application/json;charset=utf-8', 'X-Requested-With': 'XMLHttpRequest' },
|
||||
});
|
||||
|
|
@ -36,13 +35,13 @@ const service = axios.create({
|
|||
// 请求拦截器
|
||||
service.interceptors.request.use(
|
||||
async (config: InternalAxiosRequestConfig) => {
|
||||
// 如果是本地则使用静态tonken如果是线上则使用cookie的token
|
||||
const cookie = get_cookie('admin_info') || '';
|
||||
const symbol = config.url?.includes('?') ? '&' : '?';
|
||||
if (import.meta.env.VITE_APP_BASE_API == '/dev-api') {
|
||||
let temp_data = await import(import.meta.env.VITE_APP_BASE_API == '/dev-api' ? '../../temp.d' : '../../temp_pro.d');
|
||||
if (import.meta.env.VITE_APP_BASE_API == '/dev-admin') {
|
||||
let temp_data = await import(import.meta.env.VITE_APP_BASE_API == '/dev-admin' ? '../../temp.d' : '../../temp_pro.d');
|
||||
config.url = config.url + symbol + 'token=' + temp_data.default.temp_token;
|
||||
} else {
|
||||
// 如果是shop认为是多商户插件使用user_info的cookie
|
||||
const cookie = get_type() == 'shop' ? get_cookie('user_info') : get_cookie('admin_info');
|
||||
if (cookie && cookie !== null && cookie !== 'null') {
|
||||
config.url = config.url + '&token=' + (JSON.parse(cookie) !== 'null' ? JSON.parse(cookie)?.token : '');
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@
|
|||
</div>
|
||||
</template>
|
||||
<template v-else>
|
||||
<no-data height="100vh" img-width="260px" size="16px" text="编辑数据有误"></no-data>
|
||||
<no-data height="100vh" img-width="260px" size="16px" :text="empty_data"></no-data>
|
||||
</template>
|
||||
</template>
|
||||
<preview v-model="preview_dialog" :data-id="diy_id"></preview>
|
||||
|
|
@ -24,10 +24,11 @@ import defaultSettings from './components/main/index';
|
|||
import defaultConfigSetting from '@/config/setting';
|
||||
import defaultConfigConst from '@/config/const/index';
|
||||
import { clone, cloneDeep, isEmpty, omit } from 'lodash';
|
||||
import DiyAPI, { diyData, headerAndFooter, diyConfig } from '@/api/diy';
|
||||
import { diyData, headerAndFooter, diyConfig } from '@/api/diy';
|
||||
import CommonAPI from '@/api/common';
|
||||
import { commonStore } from '@/store';
|
||||
import { magic_config } from '@/config/const/tabs-magic';
|
||||
import { get_id } from '@/utils/common';
|
||||
const common_store = commonStore();
|
||||
interface diy_data_item {
|
||||
id: string;
|
||||
|
|
@ -134,9 +135,10 @@ onMounted(() => {
|
|||
common_init();
|
||||
});
|
||||
const is_empty = ref(false);
|
||||
const empty_data = ref('编辑数据有误');
|
||||
const init = () => {
|
||||
if (get_id()) {
|
||||
DiyAPI.getInit({ id: get_id() }).then((res: any) => {
|
||||
CommonAPI.getDynamicApi(common_store.common.diy_detail_url, { id: get_id() }).then((res: any) => {
|
||||
const new_data = res.data?.data || undefined;
|
||||
if (new_data) {
|
||||
let data = form_data_transfor_diy_data(new_data);
|
||||
|
|
@ -157,8 +159,13 @@ const init = () => {
|
|||
form.value = data;
|
||||
} else {
|
||||
is_empty.value = true;
|
||||
empty_data.value = '编辑数据有误';
|
||||
}
|
||||
loading_event();
|
||||
}).catch((err) => {
|
||||
is_empty.value = true;
|
||||
empty_data.value = err;
|
||||
loading_event();
|
||||
});
|
||||
} else {
|
||||
temp_form.value.header.com_data = defaultSettings.header_nav;
|
||||
|
|
@ -451,7 +458,7 @@ const save_formmat_form_data = (data: diy_data_item, close: boolean = false, is_
|
|||
});
|
||||
// 数据改造
|
||||
const new_data = diy_data_transfor_form_data(clone_form);
|
||||
DiyAPI.save(new_data)
|
||||
CommonAPI.getDynamicApi(common_store.common.diy_save_url, new_data)
|
||||
.then((res) => {
|
||||
setTimeout(() => {
|
||||
save_disabled.value = false;
|
||||
|
|
@ -475,7 +482,7 @@ const save_formmat_form_data = (data: diy_data_item, close: boolean = false, is_
|
|||
if (is_export) {
|
||||
const index = window.location.href.lastIndexOf('?s=');
|
||||
const pro_url = window.location.href.substring(0, index);
|
||||
const new_url = import.meta.env.VITE_APP_BASE_API == '/dev-api' ? import.meta.env.VITE_APP_BASE_API_URL : pro_url;
|
||||
const new_url = import.meta.env.VITE_APP_BASE_API == '/dev-admin' ? import.meta.env.VITE_APP_BASE_API_URL : pro_url;
|
||||
window.open(new_url + '?s=diyapi/diydownload/id/' + res.data + '.html', '_blank');
|
||||
}
|
||||
if (is_preview) {
|
||||
|
|
@ -641,22 +648,6 @@ const form_data_transfor_diy_data = (clone_form: diyData) => {
|
|||
};
|
||||
}
|
||||
};
|
||||
|
||||
// 截取document.location.search字符串内id/后面的所有字段
|
||||
const get_id = () => {
|
||||
let new_id = '';
|
||||
if (document.location.search.indexOf('id/') != -1) {
|
||||
new_id = document.location.search.substring(document.location.search.indexOf('id/') + 3);
|
||||
// 去除字符串的.html
|
||||
let html_index = new_id.indexOf('.html');
|
||||
if (html_index != -1) {
|
||||
new_id = new_id.substring(0, html_index);
|
||||
}
|
||||
return new_id;
|
||||
} else {
|
||||
return new_id;
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
|
|
|
|||
|
|
@ -22,7 +22,6 @@ import { get_math, convert_strings_to_numbers } from '@/utils';
|
|||
import { Settings, AppMain } from './components/index';
|
||||
import defaultSettings from './components/main/index';
|
||||
import { cloneDeep } from 'lodash';
|
||||
import DiyAPI from '@/api/tabbar';
|
||||
import CommonAPI from '@/api/common';
|
||||
import { commonStore } from '@/store';
|
||||
const common_store = commonStore();
|
||||
|
|
@ -38,7 +37,7 @@ onMounted(() => {
|
|||
});
|
||||
const is_empty = ref(false);
|
||||
const init = () => {
|
||||
DiyAPI.getTabbar({ type: get_type() })
|
||||
CommonAPI.getDynamicApi(common_store.common.app_tabbar_data_url, { type: get_type() })
|
||||
.then((res: any) => {
|
||||
if (res.data) {
|
||||
let data = res.data;
|
||||
|
|
@ -83,7 +82,7 @@ const save_event = () => {
|
|||
};
|
||||
save_disabled.value = true;
|
||||
// 数据改造
|
||||
DiyAPI.saveTabbar(new_data).then((res: any) => {
|
||||
CommonAPI.getDynamicApi(common_store.common.app_tabbar_save_url, new_data).then((res: any) => {
|
||||
// 如果是导出或预览模式,则不显示保存成功的消息
|
||||
ElMessage.success('保存成功');
|
||||
setTimeout(() => {
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@ export default defineConfig(({ mode }: ConfigEnv): UserConfig => {
|
|||
[env.VITE_APP_BASE_API]: {
|
||||
target: env.VITE_APP_BASE_API_URL, // 接口地址
|
||||
changeOrigin: true,
|
||||
rewrite: (path) => path.replace(new RegExp('^' + env.VITE_APP_BASE_API), ''), // 替换 /dev-api 为 target 接口地址
|
||||
rewrite: (path) => path.replace(new RegExp('^' + env.VITE_APP_BASE_API), ''), // 替换 /dev-admin 为 target 接口地址
|
||||
},
|
||||
// 反向代理解决跨域
|
||||
[env.VITE_APP_BASE_API_PHP]: {
|
||||
|
|
|
|||
Loading…
Reference in New Issue